Изменение цвета встречи в Exchange с помощью Java EWS 1.2

Я использую этот фрагмент кода для установки цвета. Это настройка цвета на моем компьютере, но когда я отправляю встречи другим, цвет не устанавливается в их календаре после того, как они его принимают.

ExtendedPropertyDefinition propDefColor = new ExtendedPropertyDefinition(
  UUID.fromString("00062002-0000-0000-c000-000000000046"),
  0x8214, MapiPropertyType.Integer);
appointment.setExtendedProperty(propDefColor, "6");

Я попытался получить его после сохранения встречи с помощью этого фрагмента кода, но это не сработало.

PropertySet propset=new PropertySet(BasePropertySet.FirstClassProperties, propDefColor);
appointment.bind(service,appointment.getId(), propset);
for(ExtendedProperty extendedProperty : appointment.getExtendedProperties()) {
  System.out.println(extendedProperty.getValue());
}

И я использую:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

По требованию клиента. И Java EWS API1.2.

Пожалуйста, дайте мне знать, как получить цвет в других клиентах. (Я не знаю, как использовать MasterCategorylist или категории или tryGetProperty()).

Пожалуйста, помогите мне в этом. Если нам нужно использовать tryGetProperty(), то как передать в него параметры?

  1. Определение свойстваenter code here
  2. OutParam<Object>

Пожалуйста, помогите.


person user2601787    schedule 20.07.2013    source источник
comment
Вы нашли ответ, как использовать trygetproperty() с OutParam‹Object›?   -  person LostGeek    schedule 05.06.2014


Ответы (2)


Не отвечаю вам «полностью», но, возможно, это поможет вам в дальнейшем.
Я жестко кодирую XML-запросы EWS, и вот как я получаю основной список конфигурации:

<soap:Envelope xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <typ:RequestServerVersion Version="Exchange2010" />
  </soap:Header>
  <soap:Body>
    <mes:GetUserConfiguration>
      <mes:UserConfigurationName Name="CategoryList">
        <typ:DistinguishedFolderId Id="calendar"/>
      </mes:UserConfigurationName>
      <mes:UserConfigurationProperties>All</mes:UserConfigurationProperties>
    </mes:GetUserConfiguration>
  </soap:Body>
</soap:Envelope>

Ответ:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <m:GetUserConfigurationResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
         <m:ResponseMessages>
            <m:GetUserConfigurationResponseMessage ResponseClass="Success">
               <m:ResponseCode>NoError</m:ResponseCode>
               <m:UserConfiguration>
                  <t:UserConfigurationName Name="CategoryList">
                     <typ:DistinguishedFolderId Id="calendar" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"/>
                  </t:UserConfigurationName>
                  <t:ItemId Id="AAMkADkyZ[snip]fSM9AAA=" ChangeKey="CQAAAB[snip]p3Law"/>
                  <t:XmlData>77u/PD94bW[snip]lcz4NCg==</t:XmlData>
               </m:UserConfiguration>
            </m:GetUserConfigurationResponseMessage>
         </m:ResponseMessages>
      </m:GetUserConfigurationResponse>
   </s:Body>
</s:Envelope>

Это xmldata то, что вам нужно. Он закодирован в Base64, если расшифровать его, получится:

<?xml version="1.0"?>
  <categories default="Red Category" lastSavedSession="2" lastSavedTime="2013-07-29T07:47:43.0411241Z" xmlns="CategoryList.xsd">
  <category name="Red Category" color="0" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{61c23d24-ed86-47ec-8565-433e3a6b21b7}" renameOnFirstUse="1" />
  <category name="Blue Category" color="7" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-04-17T09:10:04.043Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-04-17T09:10:04.043Z" lastSessionUsed="2" guid="{e19dd512-bff1-46d8-a858-54cc114872ad}" renameOnFirstUse="0" />
  <category name="Purple Category" color="8" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{fd3afb30-285e-4bf2-885e-f9fdfe00002e}" renameOnFirstUse="1" />
  <category name="Green Category" color="4" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-04-17T09:10:12.782Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-04-17T09:10:12.782Z" lastSessionUsed="2" guid="{c3dc51d0-1cc4-42cf-9fa9-75146905771f}" renameOnFirstUse="0" />
  <category name="Orange Category" color="1" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{10c78b6f-5828-4b3c-af0c-138aaac52dae}" renameOnFirstUse="1" />
  <category name="Yellow Category" color="3" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{37cc21d3-b6a9-4dae-a1fb-422249b9fbb0}" renameOnFirstUse="1" />
  <category name="TimeTell" color="7" keyboardShortcut="0" usageCount="7" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-07-29T07:31:17.8034765Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-07-29T07:31:17.8034765Z" lastSessionUsed="2" guid="{3348e50b-1763-42fb-a9e9-25b74038b9aa}" renameOnFirstUse="0" />
</categories>

И вот у вас есть категории и связанные с ними цвета.

person Jan Doggen    schedule 20.08.2013

Я переделал код, используя другую lib, которая упростила задачу. Он заботится о получении/настройке всех полей.

person Mark    schedule 20.10.2013
comment
Обратите внимание, что ответы только по ссылкам не рекомендуются, ответы SO должны быть конечной точкой поиска для решения (по сравнению с еще одной остановкой ссылок, которые со временем устаревают). Пожалуйста, рассмотрите возможность добавления здесь отдельного синопсиса, оставив ссылку в качестве ссылки. - person kleopatra; 20.10.2013