/// <summary>
        /// Extract the vCal uid from this AppointmentItem, if available.
        /// </summary>
        /// <param name="item">An appointment item, which may relate to a meeting in CRM.</param>
        /// <returns>The vCal id if present, else the empty string.</returns>
        public static string GetVCalId(this Outlook.AppointmentItem item)
        {
            string result = string.Empty;

            //This parses the Global Appointment ID to a byte array. We need to retrieve the "UID" from it (if available).
            byte[] bytes = (byte[])item.PropertyAccessor.StringToBinary(item.GlobalAppointmentID);

            //According to https://msdn.microsoft.com/en-us/library/ee157690(v=exchg.80).aspx we don't need first 40 bytes
            if (bytes.Length >= 40)
            {
                byte[] bytesThatContainData = new byte[bytes.Length - 40];
                Array.Copy(bytes, 40, bytesThatContainData, 0, bytesThatContainData.Length);

                //In some cases, there won't be a UID.
                var decoded = Encoding.UTF8.GetString(bytesThatContainData, 0, bytesThatContainData.Length);

                if (decoded.StartsWith("vCal-Uid"))
                {
                    //remove vCal-Uid from start string and special symbols
                    result = decoded.Replace("vCal-Uid", string.Empty).Replace("\u0001", string.Empty).Replace("\0", string.Empty);
                }
                else
                {
                    // Bad format!!!
                    Globals.ThisAddIn.Log.Warn($"Failed to find vCal-Uid in GlobalAppointmentId '{Encoding.UTF8.GetString(bytes)}' in appointment '{item.Subject}'");
                }
            }
            else
            {
                Globals.ThisAddIn.Log.Warn($"Failed to find vCal-Uid in short GlobalAppointmentId '{Encoding.UTF8.GetString(bytes)}' in appointment '{item.Subject}'");
            }

            return(result);
        }
        public NewJitsiAppointment()
        {
            // Get the Application object
            Outlook.Application application = Globals.ThisAddIn.Application;

            try
            {
                // Generate meeting ID
                string jitsiRoomId = JitsiUrl.generateRoomId();

                // Create meeting object
                newAppointment = (Outlook.AppointmentItem)application.CreateItem(Outlook.OlItemType.olAppointmentItem);


                // Appointment details
                newAppointment.Location = "Jitsi Meet";
                newAppointment.Body     = "Join the meeting: " + (JitsiUrl.getUrlBase() + jitsiRoomId);

                // Display ribbon group, then the appointment window
                Globals.ThisAddIn.ShowRibbonAppointment = true;
                newAppointment.Display(false);
                Globals.ThisAddIn.ShowRibbonAppointment = false;

                // Set Room ID field
                setRoomIdText(jitsiRoomId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message);
            }
        }
        /// <summary>
        /// Create an appropriate sync state for an appointment item.
        /// </summary>
        /// <remarks>Outlook items are not true objects and don't have a common superclass,
        /// so we have to use this rather clumsy overloading.</remarks>
        /// <param name="appointment">The item.</param>
        /// <returns>An appropriate sync state, or null if the appointment was invalid.</returns>
        private AppointmentSyncState CreateSyncState(Outlook.AppointmentItem appointment)
        {
            AppointmentSyncState result;

            CrmId crmId = appointment.GetCrmId();

            if (CrmId.IsValid(crmId) && this.byCrmId.ContainsKey(crmId) && this.byCrmId[crmId] != null)
            {
                result = CheckUnexpectedFoundState <Outlook.AppointmentItem, AppointmentSyncState>(appointment, crmId);
            }
            else
            {
                var modifiedDate = ParseDateTimeFromUserProperty(appointment.UserProperties[ModifiedDatePropertyName]);
                if (appointment.IsCall())
                {
                    result = this.SetByOutlookId <AppointmentSyncState>(appointment.EntryID,
                                                                        new CallSyncState(appointment, crmId, modifiedDate));
                }
                else
                {
                    result = this.SetByOutlookId <AppointmentSyncState>(appointment.EntryID,
                                                                        new MeetingSyncState(appointment, crmId, modifiedDate));
                }
                this.byGlobalId[appointment.GlobalAppointmentID] = result;
            }

            if (result != null && CrmId.IsValid(crmId))
            {
                this.byCrmId[crmId] = result;
            }

            return(result);
        }
示例#4
0
        /// <summary>
        /// 创建约会.
        /// </summary>
        /// <param name="satrtDateTime">开始时间</param>
        /// <param name="endDateTime">结束时间</param>
        /// <param name="reminderMinutesBeforeStart">提前多长时间提醒</param>
        /// <param name="subject">标题</param>
        /// <param name="body">内容</param>
        public void CreateAppointment(
            DateTime satrtDateTime,
            DateTime endDateTime,
            int reminderMinutesBeforeStart,
            string subject,
            string body
            )
        {
            // 创建约会.
            Outlook.AppointmentItem outLookAppointmentItem =
                (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);

            // 开始时间
            outLookAppointmentItem.Start = satrtDateTime;
            // 结束时间
            outLookAppointmentItem.End = endDateTime;

            // 提前多长时间提醒
            outLookAppointmentItem.ReminderMinutesBeforeStart = reminderMinutesBeforeStart;
            // 标题
            outLookAppointmentItem.Subject = subject;
            // 内容
            outLookAppointmentItem.Body = body;

            // 保存.
            outLookAppointmentItem.Save();
        }
示例#5
0
        public void Item_Add(object item)
        {
            if (IsPerformingInitialLoad || PerformingSync)
            {
                return;
            }

            lock ( m_autoSyncEvents )
            {
                Outlook.AppointmentItem aitem = item as Outlook.AppointmentItem;
                if (aitem != null)
                {
                    Outlook.MAPIFolder calender = aitem.Parent as Outlook.Folder;
                    if (calender != null)
                    {
                        var tasks = m_tasks.FindAll(x => x.Event == SchedulerEvent.Automatically &&
                                                    x.Pair.OutlookId.Equals(calender.EntryID));

                        foreach (var schedulerTask in tasks)
                        {
                            m_autoSyncEvents.Add(new AutoSyncEvent
                            {
                                Action  = CalendarItemAction.GoogleAdd,
                                EntryId = aitem.EntryID,
                                Pair    = schedulerTask.Pair
                            });
                        }
                    }
                }
            }
        }
        private Appointment         CreateAppointment(Appointment appointment)
        {
            try
            {
                Outlook.Application     outlookApp = new Outlook.Application();                                                            // creates new outlook app
                Outlook.AppointmentItem newAppo    = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem); // creates a new appointment

                newAppo.AllDayEvent = false;
                newAppo.ReminderSet = false;

                newAppo.Location = appointment.Location;
                newAppo.Start    = appointment.Start;
                newAppo.Duration = appointment.Duration;
                newAppo.Subject  = appointment.Subject;
                newAppo.Body     = appointment.Body;

                newAppo.Save();
                Appointment returnAppo = new Appointment(newAppo.GlobalAppointmentID, newAppo.Start, newAppo.Duration, newAppo.Subject, newAppo.Location, newAppo.Body, t.Bool(sqlController.SettingRead(Settings.colorsRule)), true, sqlController.Lookup);

                Outlook.MAPIFolder calendarFolderDestination = GetCalendarFolder();
                Outlook.NameSpace  mapiNamespace             = outlookApp.GetNamespace("MAPI");
                Outlook.MAPIFolder oDefault = mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

                if (calendarFolderDestination.Name != oDefault.Name)
                {
                    newAppo.Move(calendarFolderDestination);
                }

                return(returnAppo);
            }
            catch (Exception ex)
            {
                throw new Exception("The following error occurred: " + ex.Message);
            }
        }
示例#7
0
        private static void UpdateSubject(Outlook.AppointmentItem item, int selectedItemIndex)
        {
            Debug.WriteLine("RibbonLabel: UpdateSubject");
            Debug.WriteLine("==============================================================================");

            var marking = Config.Current.ProtectiveMarkings[selectedItemIndex];

            // TODO: Force the subject field to save before any changes are mode - Unintended consequence is the draft meeting is saved to the calendar.
            //item.Save();

            // Remove existing subject marking
            if (!string.IsNullOrEmpty(item.Subject))
            {
                item.Subject = Regex.Replace(item.Subject, Config.Current.RegexSubject, string.Empty, Config.Current.RegexOptionSet);
            }

            // Apply new subject marking
            if (string.IsNullOrEmpty(item.Subject))
            {
                item.Subject = marking.Subject();
            }
            else
            {
                item.Subject += " " + marking.Subject();
            }
        }
        /// <summary>
        /// Get the existing sync state for this item, if it exists and is of the appropriate
        /// type, else null.
        /// </summary>
        /// <remarks>Outlook items are not true objects and don't have a common superclass,
        /// so we have to use this rather clumsy overloading.</remarks>
        /// <param name="appointment">The item.</param>
        /// <returns>The appropriate sync state, or null if none.</returns>
        /// <exception cref="UnexpectedSyncStateClassException">if the sync state found is not of the expected class (shouldn't happen).</exception>
        public AppointmentSyncState GetSyncState(Outlook.AppointmentItem appointment)
        {
            SyncState result;

            try
            {
                result = (appointment.IsValid() && this.byOutlookId.ContainsKey(appointment.EntryID)) ? this.byOutlookId[appointment.EntryID] : null;
                CrmId crmId = result == null?appointment.GetCrmId() : CheckForDuplicateSyncState(result, appointment.GetCrmId());

                if (CrmId.IsValid(crmId))
                {
                    if (result == null && this.byCrmId.ContainsKey(crmId))
                    {
                        result = this.byCrmId[crmId];
                    }
                    else if (result != null && this.byCrmId.ContainsKey(crmId) == false)
                    {
                        this.byCrmId[crmId] = result;
                        result.CrmEntryId   = crmId;
                    }
                }

                if (result != null && !(result is AppointmentSyncState))
                {
                    throw new UnexpectedSyncStateClassException("AppointmentSyncState", result);
                }
            }
            catch (COMException)
            {
                // dead item passed.
                result = null;
            }

            return(result as AppointmentSyncState);
        }
示例#9
0
        /// <summary>
        /// Create a new instance of ProtoAppointment, taking values from this Outlook item.
        /// </summary>
        /// <param name="olItem">The Outlook item to take values from.</param>
        public ProtoAppointment(Outlook.AppointmentItem olItem) : base(olItem.MeetingStatus)
        {
            this.olItem     = olItem;
            this.body       = olItem.Body;
            this.CrmEntryId = olItem.GetCrmId();
            this.duration   = olItem.Duration;
            this.end        = olItem.End;
            this.location   = olItem.Location;
            this.start      = olItem.Start;
            this.subject    = olItem.Subject;
            this.globalId   = olItem.GlobalAppointmentID;

            var organiserProperty = olItem.UserProperties[AppointmentsSynchroniser <SyncStateType> .OrganiserPropertyName];

            if (organiserProperty == null || string.IsNullOrWhiteSpace(organiserProperty.Value))
            {
                if (olItem.Organizer == Globals.ThisAddIn.Application.GetCurrentUsername())
                {
                    this.organiser = CrmId.Get(RestAPIWrapper.GetUserId());
                }
                else
                {
                    this.organiser = TryResolveOrganiser(olItem);
                }
            }
            else
            {
                this.organiser = CrmId.Get(organiserProperty.Value.ToString());
            }

            foreach (Outlook.Recipient recipient in olItem.Recipients)
            {
                this.recipientAddresses.Add(recipient.GetSmtpAddress());
            }
        }
        public void                 CalendarItemUpdate(Appointment appointment, WorkflowState workflowState, bool resetBody)
        {
            Outlook.AppointmentItem item = AppointmentItemFind(appointment.GlobalId, appointment.Start);

            item.Body     = appointment.Body;
            item.Location = workflowState.ToString();
            #region item.Categories = 'workflowState'...
            switch (workflowState)
            {
            case WorkflowState.Planned:
                item.Categories = null;
                break;

            case WorkflowState.Processed:
                item.Categories = "Processing";
                break;

            case WorkflowState.Created:
                item.Categories = "Processing";
                break;

            case WorkflowState.Sent:
                item.Categories = "Sent";
                break;

            case WorkflowState.Retrived:
                item.Categories = "Retrived";
                break;

            case WorkflowState.Completed:
                item.Categories = "Completed";
                break;

            case WorkflowState.Canceled:
                item.Categories = "Canceled";
                break;

            case WorkflowState.Revoked:
                item.Categories = "Revoked";
                break;

            case WorkflowState.Failed_to_expection:
                item.Categories = "Error";
                break;

            case WorkflowState.Failed_to_intrepid:
                item.Categories = "Error";
                break;
            }
            #endregion

            if (resetBody)
            {
                item.Body = UnitTest_CalendarBody();
            }

            item.Save();

            log.LogStandard("Not Specified", PrintAppointment(item) + " updated to " + workflowState.ToString());
        }
示例#11
0
 private void Ribbon_Close(object sender, EventArgs e)
 {
     _mail      = null;
     _appt      = null;
     _touch     = null;
     _timerForm = null;
 }
        private AbstractItem CreateAppointment(string outlookId, string crmId, Outlook.OlMeetingStatus status)
        {
            AbstractItem result;

            Outlook.NameSpace session = Globals.ThisAddIn.GetOutlookSession();

            if (session != null)
            {
                Outlook.AppointmentItem legacy = null;
                Outlook.MAPIFolder      folder = session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

                if (!string.IsNullOrEmpty(outlookId))
                {
                    legacy = folder.Items.Add(Outlook.OlItemType.olAppointmentItem);
                    legacy.MeetingStatus = status;
                    result            = new CallItem(legacy);
                    result.CrmEntryId = crmId;

                    this.ByCrmId[crmId] = result;
                    this.ByOutlookId[legacy.EntryID] = result;
                }
                else
                {
                    result = FindExistingAppointmentItem(outlookId, crmId, folder);
                }
            }
            else
            {
                throw new ShouldNotHappenException("No Outlook session!");
            }

            return(result);
        }
示例#13
0
 //[FieldSetter(Field.Reminder)]
 private void SetReminder(Event googleItem, Outlook.AppointmentItem outlookItem, Target target)
 {
     if (target == Target.Google)
     {
         if (outlookItem.ReminderSet)
         {
             if (outlookItem.ReminderOverrideDefault)
             {
                 var reminder = new EventReminder
                 {
                     Minutes = outlookItem.ReminderMinutesBeforeStart,
                     Method  = "popup"
                 };
                 googleItem.Reminders.Overrides = new[] { reminder };
             }
             else
             {
                 googleItem.Reminders.Overrides = null;
             }
             googleItem.Reminders.UseDefault = !outlookItem.ReminderOverrideDefault;
         }
         else
         {
             googleItem.Reminders = null;
         }
     }
     else if (googleItem.Reminders == null)
     {
         ((Outlook.AppointmentItem)outlookItem).ReminderSet = false;
     }
     else
     {
         if (googleItem.Reminders.UseDefault.GetValueOrDefault())
         {
             if (this._defaultReminders.Any())
             {
                 ((Outlook.AppointmentItem)outlookItem).ReminderSet                = true;
                 ((Outlook.AppointmentItem)outlookItem).ReminderOverrideDefault    = true;
                 ((Outlook.AppointmentItem)outlookItem).ReminderMinutesBeforeStart = this._defaultReminders.First().Minutes.GetValueOrDefault();
             }
             else
             {
                 ((Outlook.AppointmentItem)outlookItem).ReminderSet = false;
             }
         }
         else
         {
             if (googleItem.Reminders.Overrides != null && googleItem.Reminders.Overrides.Count > 0)
             {
                 ((Outlook.AppointmentItem)outlookItem).ReminderSet                = true;
                 ((Outlook.AppointmentItem)outlookItem).ReminderOverrideDefault    = true;
                 ((Outlook.AppointmentItem)outlookItem).ReminderMinutesBeforeStart = googleItem.Reminders.Overrides.First().Minutes.GetValueOrDefault();
             }
             else
             {
                 ((Outlook.AppointmentItem)outlookItem).ReminderSet = false;
             }
         }
     }
 }
示例#14
0
 public void SetApptItem(Outlook.AppointmentItem appt)
 {
     _appt     = appt;
     _itemType = Outlook.OlItemType.olAppointmentItem;
     RefreshTouch();
     SetUI();
 }
示例#15
0
        /// <summary>
        /// Check meeting acceptances for all future meetings.
        /// </summary>
        private int CheckMeetingAcceptances()
        {
            int result = 0;

            foreach (MeetingSyncState state in SyncStateManager.Instance.GetSynchronisedItems <MeetingSyncState>().Where(s => s.VerifyItem()))
            {
                Outlook.AppointmentItem item = state.OutlookItem;

                try
                {
                    if (CrmId.Get(item.UserProperties[OrganiserPropertyName]?.Value)
                        .Equals(RestAPIWrapper.GetUserId()) &&
                        item.Start > DateTime.Now)
                    {
                        result += AddOrUpdateMeetingAcceptanceFromOutlookToCRM(item);
                    }
                }
                catch (TypeInitializationException tix)
                {
                    Log.Warn("Failed to create CrmId with value '{item.UserProperties[OrganiserPropertyName]?.Value}'", tix);
                }
                catch (COMException comx)
                {
                    ErrorHandler.Handle($"Item with CRMid {state.CrmEntryId} appears to be invalid (HResult {comx.HResult})", comx);
                    this.HandleItemMissingFromOutlook(state);
                }
            }

            return(result);
        }
示例#16
0
        /// <summary>
        /// Set the meeting acceptance status, in CRM, for this invitee to this meeting from
        /// their acceptance status in Outlook.
        /// </summary>
        /// <param name="meeting">The appointment item representing the meeting</param>
        /// <param name="invitee">The recipient item representing the invitee</param>
        /// <param name="acceptance">The acceptance status of this invitee of this meeting
        /// as a string recognised by CRM.</param>
        ///
        private int AddOrUpdateMeetingAcceptanceFromOutlookToCRM(Outlook.AppointmentItem meeting, Outlook.Recipient invitee, string acceptance)
        {
            int    count       = 0;
            string smtpAddress = invitee.GetSmtpAddress();
            var    meetingId   = meeting.GetCrmId();

            if (meetingId != null &&
                !string.IsNullOrEmpty(acceptance) &&
                SyncDirection.AllowOutbound(this.Direction))
            {
                foreach (AddressResolutionData resolution in this.ResolveRecipient(meeting, invitee))
                {
                    try
                    {
                        RestAPIWrapper.SetMeetingAcceptance(meetingId.ToString(), resolution.ModuleName, resolution.ModuleId.ToString(), acceptance);
                        count++;
                    }
                    catch (System.Exception any)
                    {
                        ErrorHandler.Handle($"Failed to resolve meeting invitee {smtpAddress}:", any);
                    }
                }
            }

            return(count);
        }
示例#17
0
        public ConflictResolution Resolve(Outlook.AppointmentItem outlookAppointment, Event googleAppointment, AppointmentsSynchronizer sync, bool isNewMatch)
        {
            string name = string.Empty;

            _form.OutlookItemTextBox.Text = string.Empty;
            _form.GoogleItemTextBox.Text  = string.Empty;
            if (outlookAppointment != null)
            {
                name = outlookAppointment.Subject + " - " + outlookAppointment.Start;
                _form.OutlookItemTextBox.Text += outlookAppointment.Body;
            }

            if (googleAppointment != null)
            {
                name = googleAppointment.Summary + " - " + AppointmentsSynchronizer.GetTime(googleAppointment);
                _form.GoogleItemTextBox.Text += googleAppointment.Description;
            }

            if (isNewMatch)
            {
                _form.messageLabel.Text =
                    "This is the first time these appointments \"" + name +
                    "\" are synced. Choose which you would like to keep.";
                _form.skip.Text = "Keep both";
            }
            else
            {
                _form.messageLabel.Text =
                    "Both the Outlook and Google Appointment \"" + name +
                    "\" have been changed. Choose which you would like to keep.";
            }

            return(Resolve());
        }
示例#18
0
        public ConflictResolution Resolve(string message, Outlook.AppointmentItem outlookAppointment, Event googleAppointment, AppointmentsSynchronizer sync, bool keepOutlook, bool keepGoogle)
        {
            // string name = string.Empty;

            _form.OutlookItemTextBox.Text = string.Empty;
            _form.GoogleItemTextBox.Text  = string.Empty;
            if (outlookAppointment != null)
            {
                // name = outlookAppointment.Subject + " - " + outlookAppointment.Start;
                _form.OutlookItemTextBox.Text += outlookAppointment.Body;
            }

            if (googleAppointment != null)
            {
                // name = googleAppointment.Summary + " - " + Synchronizer.GetTime(googleAppointment);
                _form.GoogleItemTextBox.Text += googleAppointment.Description;
            }

            //ToDo: Make it more flexible
            _form.keepGoogle.Enabled  = keepGoogle;
            _form.keepOutlook.Enabled = keepOutlook;
            _form.AllCheckBox.Visible = true;
            _form.messageLabel.Text   = message;

            return(Resolve());
        }
示例#19
0
        public static DateTime?GetOutlookLastSync(Synchronizer sync, Outlook.AppointmentItem outlookAppointment)
        {
            DateTime?result = null;

            Outlook.UserProperties userProperties = outlookAppointment.UserProperties;
            try
            {
                Outlook.UserProperty prop = userProperties[sync.OutlookPropertyNameSynced];
                if (prop != null)
                {
                    try
                    {
                        result = (DateTime)prop.Value;
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(prop);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(userProperties);
            }
            return(result);
        }
示例#20
0
        public static string GetOutlookGoogleAppointmentId(Synchronizer sync, Outlook.AppointmentItem outlookAppointment)
        {
            string id = null;

            Outlook.UserProperties userProperties = outlookAppointment.UserProperties;
            try
            {
                Outlook.UserProperty idProp = userProperties[sync.OutlookPropertyNameId];
                if (idProp != null)
                {
                    try
                    {
                        id = (string)idProp.Value;
                        if (id == null)
                        {
                            throw new Exception();
                        }
                    }
                    finally
                    {
                        Marshal.ReleaseComObject(idProp);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(userProperties);
            }
            return(id);
        }
示例#21
0
        private void Initialize(object sender, EventArgs e)
        {
            //Globals.ThisAddIn.IsInspectorOpen = true;

            //Debug.WriteLine("Initialize {0:T}", DateTime.Now);
            if (DataAPI.Ready())
            {
                _timerForm.timerApptRibbon.Stop();

                Outlook.Inspector insp = this.Context as Outlook.Inspector;
                if (insp.CurrentItem is Outlook.MailItem)
                {
                    _mail = insp.CurrentItem;
                    _mail.BeforeDelete += new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Item_BeforeDelete);
                    _itemType           = Outlook.OlItemType.olMailItem;
                }
                else if (insp.CurrentItem is Outlook.AppointmentItem)
                {
                    _appt = insp.CurrentItem;
                    _appt.BeforeDelete   += new Outlook.ItemEvents_10_BeforeDeleteEventHandler(Item_BeforeDelete);
                    _appt.PropertyChange += _appt_PropertyChange;
                    _itemType             = Outlook.OlItemType.olAppointmentItem;
                }
                insp = null;
                RefreshTouch();
                SetUI();
            }
            else
            {
                _timerForm.timerApptRibbon.Interval = (_timerForm.timerApptRibbon.Interval * 2);
            }
        }
示例#22
0
 public static void SetOutlookLastSync(Synchronizer sync, Outlook.AppointmentItem outlookAppointment)
 {
     //save sync datetime
     Outlook.UserProperties userProperties = outlookAppointment.UserProperties;
     try
     {
         Outlook.UserProperty prop = userProperties[sync.OutlookPropertyNameSynced];
         if (prop == null)
         {
             prop = userProperties.Add(sync.OutlookPropertyNameSynced, Outlook.OlUserPropertyType.olDateTime, true);
         }
         try
         {
             prop.Value = DateTime.Now;
         }
         finally
         {
             Marshal.ReleaseComObject(prop);
         }
     }
     finally
     {
         Marshal.ReleaseComObject(userProperties);
     }
 }
示例#23
0
 private static void DeleteProperty(Outlook.AppointmentItem aitem, string property)
 {
     if (aitem.UserProperties.Find(property) != null)
     {
         aitem.UserProperties.Find(property).Delete();
     }
 }
        public NewJitsiAppointment()
        {
            // Get the Application object
            Outlook.Application application = Globals.ThisAddIn.Application;

            try
            {
                // Generate meeting ID
                string jitsiRoomId = getRoomId();

                // Create meeting object
                newAppointment = (Outlook.AppointmentItem)application.CreateItem(Outlook.OlItemType.olAppointmentItem);


                // Appointment details
                newAppointment.Location = "Jitsi Meet";
                newAppointment.Body     = "Join the meeting: " + (JitsiUrl.getUrlBase() + jitsiRoomId);

                // Display ribbon group, then the appointment window
                Globals.ThisAddIn.ShowRibbonAppointment = true;
                newAppointment.Display(false);
                Globals.ThisAddIn.ShowRibbonAppointment = false;

                // Set ribbon control defaults
                findThisRibbon(); // This only works after message is displayed to user
                setRequireDisplayName();
                setStartWithAudioMuted();
                setStartWithVideoMuted();
                setRoomIdText(jitsiRoomId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("The following error occurred: " + ex.Message);
            }
        }
示例#25
0
        public static void SendMeetingRequest(string subject, string Body, string Location, DateTime Start, DateTime End, string Recipient)
        {
            OL.Application oApp = new OL.Application();
            //新建一个约会
            OL.AppointmentItem oItem = (OL.AppointmentItem)oApp.CreateItem(OL.OlItemType.olAppointmentItem);
            //约会为会议形式
            oItem.MeetingStatus = OL.OlMeetingStatus.olMeeting;
            oItem.Subject       = subject;
            oItem.Body          = Body;
            oItem.Location      = Location;
            //开始时间 
            oItem.Start = Start;
            //结束时间
            oItem.End = End;
            //提醒设置
            oItem.ReminderSet = true;
            //时间显示为忙
            oItem.BusyStatus = OL.OlBusyStatus.olBusy;
            //是否在线会议
            oItem.IsOnlineMeeting = false;
            //是否全天事件
            oItem.AllDayEvent = false;
            //邀请人员
            // foreach (string s in Recipients)
            //   {
            oItem.Recipients.Add(Recipient);

            //   }
            oItem.Recipients.ResolveAll();
            //发送邀请
            //  ((OL._MailItem)oItem).Send();
            oItem.Send();
            oItem = null;
            oApp  = null;
        }
示例#26
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            if (reaminder_checkBox.IsChecked.Value)
            {
                Outlook.Application outlookApp = new Outlook.Application();

                Outlook.AppointmentItem appt = outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
                appt.Subject     = "Follow up for" + jobTitle.Text + " post " + companyName.Text;
                appt.Location    = "NA";
                appt.Body        = "Follow up with the HR/Website for the Status ";
                appt.Sensitivity = Outlook.OlSensitivity.olPrivate;
                appt.Start       = DateTime.Parse(remainder_date.SelectedDate.ToString());
                appt.End         = DateTime.Parse(remainder_date.SelectedDate.ToString().Replace("00:00", "10:00"));
                appt.ReminderSet = true;
                appt.ReminderMinutesBeforeStart = 0;
                appt.Save();
            }
            if (save_new_data())
            {
                load_table();
            }
            else
            {
                MessageBox.Show("Data Invalid:Please check");
            }
        }
        /// <summary>
        /// Updates the appointments (GlobalAppointmentID) with new SyncIDs
        /// </summary>
        /// <param name="idMapping">GlobalAppointmentID -> SyncID</param>
        public void UpdateSyncIDs(Dictionary <string, string> idMapping)
        {
            foreach (KeyValuePair <string, string> entry in idMapping)
            {
                Outlook.AppointmentItem foundItem = _customCalendar.Items.Find(String.Format("[GAI] = '{0}'", entry.Key));

                // updating the SyncIDs
                if (foundItem.ItemProperties[ITEM_PROPERTY_SYNC_ID] == null)
                {
                    foundItem.ItemProperties.Add(ITEM_PROPERTY_SYNC_ID, Outlook.OlUserPropertyType.olText);
                    foundItem.Save();
                }

                foundItem.ItemProperties[ITEM_PROPERTY_SYNC_ID].Value = entry.Value;
                foundItem.Save();

                // updating the information, that this item was updated by the sync
                if (foundItem.ItemProperties[ITEM_PROPERTY_SYNC_UPDATE] == null)
                {
                    foundItem.ItemProperties.Add(ITEM_PROPERTY_SYNC_UPDATE, Outlook.OlUserPropertyType.olText);
                    foundItem.Save();
                }

                foundItem.ItemProperties[ITEM_PROPERTY_SYNC_UPDATE].Value = foundItem.LastModificationTime;
                foundItem.Save();

                Marshal.ReleaseComObject(foundItem);
                foundItem = null;
            }
        }
示例#28
0
 void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
 {
     if (Inspector.CurrentItem is Outlook.AppointmentItem)
         appointment = Inspector.CurrentItem as Outlook.AppointmentItem;
     else
         appointment = null;
 }
示例#29
0
        public void MyAfterItemAdded(object obj)
        {
            Outlook.AppointmentItem aitem = obj as Outlook.AppointmentItem;
            if (aitem == null || aitem.IsRecurring ||
                aitem.MeetingStatus != Outlook.OlMeetingStatus.olNonMeeting)
            {
                return;
            }

            Helpers.DebugInfo("ItemAdded callback is fired with appointment: Id: " + aitem.GlobalAppointmentID +
                              " Subject: " + aitem.Subject + " Duration: " + aitem.Duration);

            if (aitem.UserProperties.Find(_RestoredFromDeletedProperty) != null)
            {
                aitem.UserProperties.Find(_RestoredFromDeletedProperty).Delete();
            }
            else
            {
                if (aitem.UserProperties.Find(_TaskIdProperty) != null ||
                    aitem.UserProperties.Find(_TimeReportedProperty) != null ||
                    aitem.UserProperties.Find(_PreviousAssignedSubjectProperty) != null)
                {
                    aitem.Categories = "";
                }
                DeleteProperty(aitem, _TaskIdProperty);
                DeleteProperty(aitem, _TimeReportedProperty);
                DeleteProperty(aitem, _PreviousAssignedSubjectProperty);
            }
            aitem.Save();

            // outlook sends events in really random order => trying to speed-up it
            MyAfterItemChanged(obj);
        }
        private void createAppointment(string startTime, string endTime, String subject, String body, int busyStat)
        {
            Outlook._Application    _app = new Outlook.Application();
            Outlook.AppointmentItem ai   = (Outlook.AppointmentItem)_app.CreateItem(Outlook.OlItemType.olAppointmentItem);



            //MessageBox.Show("startTimeString: " + startTime + " endTime: " + endTime, "data", MessageBoxButtons.OK);
            ai.Subject     = subject;
            ai.AllDayEvent = false;
            ai.Start       = DateTime.Parse(startTime);
            ai.End         = DateTime.Parse(endTime);

            switch (busyStat)
            {
            case 0:
                ai.BusyStatus = Outlook.OlBusyStatus.olFree;
                break;

            case 1:
                ai.BusyStatus = Outlook.OlBusyStatus.olTentative;
                break;

            case 2:
                ai.BusyStatus = Outlook.OlBusyStatus.olBusy;
                break;

            case 3:
                ai.BusyStatus = Outlook.OlBusyStatus.olOutOfOffice;
                break;
            }

            ai.Body = body;
            ai.Save();
        }
        public static int Main(string[] args)
        {
            try
            {
                // Create the Outlook application.
                Outlook.Application oApp = new Outlook.Application();

                // Get the NameSpace and Logon information.
                // Outlook.NameSpace oNS = (Outlook.NameSpace)oApp.GetNamespace("mapi");
                Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

                //Log on by using a dialog box to choose the profile.
                oNS.Logon(Missing.Value, Missing.Value, true, true);

                //Alternate logon method that uses a specific profile.
                // TODO: If you use this logon method,
                // change the profile name to an appropriate value.
                //oNS.Logon("YourValidProfile", Missing.Value, false, true);

                // Get the Calendar folder.
                Outlook.MAPIFolder oCalendar = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);

                // Get the Items (Appointments) collection from the Calendar folder.
                Outlook.Items oItems = oCalendar.Items;

                // Get the first item.
                Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)oItems.GetFirst();


                // Show some common properties.
                Console.WriteLine("Subject: " + oAppt.Subject);
                Console.WriteLine("Organizer: " + oAppt.Organizer);
                Console.WriteLine("Start: " + oAppt.Start.ToString());
                Console.WriteLine("End: " + oAppt.End.ToString());
                Console.WriteLine("Location: " + oAppt.Location);
                Console.WriteLine("Recurring: " + oAppt.IsRecurring);

                //Show the item to pause.
                oAppt.Display(true);

                // Done. Log off.
                oNS.Logoff();

                // Clean up.
                oAppt     = null;
                oItems    = null;
                oCalendar = null;
                oNS       = null;
                oApp      = null;
            }

            //Simple error handling.
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }

            //Default return value
            return(0);
        }
 public AppointmentMatch(Outlook.AppointmentItem outlookAppointment, Event googleAppointment)
 {
     OutlookAppointment = outlookAppointment;
     GoogleAppointment = googleAppointment;
 }
示例#33
0
        /// <summary>
        /// 从约会界面,获取非周期性会议信息
        /// </summary>
        /// <param name="ConfInfo">非周期性会议信息</param>
        private void setConferenceInfo(ref ConferenceInfo ConfInfo, AppointmentItem tempAppt)
        {
            ThisAddIn.g_log.Info("setConferenceInfo begin");
            ConfInfo.name = tempAppt.Subject;
            ConfInfo.beginTime = tempAppt.Start.ToUniversalTime();

            TimeSpan span = tempAppt.End - tempAppt.Start;
            string duration = String.Format("P0Y0M{0}DT{1}H{2}M{3}S", span.Days, span.Hours, span.Minutes, span.Seconds);
            ConfInfo.duration = duration;

            ConfInfo.rate = ThisAddIn.g_SystemSettings.strSiteRate;
            ConfInfo.mediaEncryptType = ThisAddIn.g_SystemSettings.nMediaEncryptType;
            ConfInfo.isRecording = ThisAddIn.g_SystemSettings.nRecording;

            ConfInfo.isLiveBroadcast = ThisAddIn.g_SystemSettings.nLiving;
            ConfInfo.billCode = ThisAddIn.g_SystemSettings.strBillCode;
            ConfInfo.password = ThisAddIn.g_SystemSettings.strConfPWD;
            ConfInfo.chairmanPassword = ThisAddIn.g_SystemSettings.strConfPWD;
            ConfInfo.cpResouce = ThisAddIn.g_SystemSettings.nCPResource;

            GetUserProperties(ref ConfInfo, tempAppt);
            ThisAddIn.g_log.Info(string.Format("conf name is: {0}", ConfInfo.name));
            ThisAddIn.g_log.Info(string.Format("conf begin at: {0}", ConfInfo.beginTime));
            ThisAddIn.g_log.Info(string.Format("conf duration: {0}", ConfInfo.duration));
            ThisAddIn.g_log.Info(string.Format("conf rate is: {0}", ConfInfo.rate));
            ThisAddIn.g_log.Info(string.Format("conf media encrypt type is: {0}", ConfInfo.mediaEncryptType));
            ThisAddIn.g_log.Info(string.Format("conf recording is: {0}", ConfInfo.isRecording));

            ThisAddIn.g_log.Info(string.Format("conf living is: {0}", ConfInfo.isLiveBroadcast));
            ThisAddIn.g_log.Info(string.Format("conf bill code is: {0}", ConfInfo.billCode));
            ThisAddIn.g_log.Info(string.Format("conf password is: ******"));
            ThisAddIn.g_log.Info(string.Format("conf chairman password is: ******"));
            ThisAddIn.g_log.Info(string.Format("conf CPResource is: {0}", ConfInfo.cpResouce));
            // 0:无效类型
            // 1:根据会场标识自动从系统获取(保留)
            // 2:E1 类型会场
            // 3:ISDN 类型会场
            // 4:H.323 类型会场
            // 5:PSTN 类型会场
            // 6:4E1 类型会场
            // 7:SIP 类型会场
            // 8:VoIP SIP 类型会场
            // 9:VoIP H.323 类型会场

            //视频会场
            ArrayList list = new ArrayList();
            SiteInfo tempSite = null;
            int nVideoCount = 0;
            UserProperty up = tempAppt.UserProperties.Find(PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVideoCount = up.Value;
            }
            else
            {
                nVideoCount = ThisAddIn.g_SystemSettings.nVideoSitesCount;
            }

            if (nVideoCount > 0)
            {
                for (int i = 0; i < nVideoCount; i++)
                {
                    tempSite = new SiteInfo();
                    tempSite.type = 4;
                    list.Add(tempSite);
                }
            }
            ThisAddIn.g_log.Info(string.Format("video site count is: {0}", nVideoCount));

            //语音会场
            int nVoiceCount = 0;
            up = tempAppt.UserProperties.Find(PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVoiceCount = up.Value;
            }
            else
            {
                nVoiceCount = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
            }

            if (nVoiceCount > 0)
            {
                for (int i = 0; i < nVoiceCount; i++)
                {
                    tempSite = new SiteInfo();
                    tempSite.type = 9;
                    list.Add(tempSite);
                }
            }
            ThisAddIn.g_log.Info(string.Format("voice site count is: {0}", nVoiceCount));

            //2015-7-8 w00322557 临时会场
            up = tempAppt.UserProperties.Find(PROPERTY_TEMP_SITES, Type.Missing);
            if (up != null)
            {
                List<SiteInfo> listTempSites = XmlHelper.Desrialize<List<SiteInfo>>(up.Value);
                foreach (SiteInfo site in listTempSites)
                {
                    list.Add(site);
                    ThisAddIn.g_log.Info(string.Format("Temp site name: {0}", site.name));
                    ThisAddIn.g_log.Info(string.Format("Temp site uri: {0}", site.uri));
                    ThisAddIn.g_log.Info(string.Format("Temp site type: {0}", site.type));
                }
            }
            else
            {
                ThisAddIn.g_log.Debug("Temp site is null or empty!");
            }

            //从地址栏获取智真会场
            List<string> listSites = GetTPSitesFromLocation(tempAppt);

            if (listSites != null)
            {
                SiteInfo[] sites = new SiteInfo[listSites.Count];
                for (int i = 0; i < listSites.Count; i++)
                {
                    sites[i] = new SiteInfo();
                    sites[i].uri = listSites[i];
                    sites[i].type = -1;
                    list.Add(sites[i]);

                    ThisAddIn.g_log.Info(string.Format("TP site uri is: {0}", sites[i].uri));
                }
            }

            if (list.Count > 0)
            {
                ConfInfo.sites = (SiteInfo[])list.ToArray(typeof(SiteInfo));
                ThisAddIn.g_log.Info(string.Format("ConfInfo sites count is: {0}", ConfInfo.sites.Length));
                ThisAddIn.g_log.Info(string.Format("Total TP sites count is: {0}", list.Count));
            }
            else
            {
                ThisAddIn.g_log.Error(string.Format("There is no TP sites!"));
            }

            ThisAddIn.g_log.Info("setConferenceInfo end");
        }
示例#34
0
        /// <summary>
        /// 保存用户自定义属性
        /// </summary>
        /// <param name="confInfo"></param>
        /// <param name="ai"></param>
        public static void SaveReturnUserProperties(ConferenceInfo confInfo, AppointmentItem ai)
        {
            ThisAddIn.g_log.Info(string.Format("SaveReturnUserProperties begin"));
            try
            {
                ThisAddIn.g_log.Info(string.Format("return conf name is: {0}", confInfo.name));
                ThisAddIn.g_log.Info(string.Format("return conf beginTime is: {0}", confInfo.beginTime.ToLocalTime().ToLongTimeString()));
                ThisAddIn.g_log.Info(string.Format("return conf duration is: {0}", confInfo.duration));
                ThisAddIn.g_log.Info(string.Format("return conf rate is: {0}", confInfo.rate));

                ThisAddIn.g_log.Info(string.Format("return conf isRecording is: {0}", confInfo.isRecording));

                foreach(SiteInfo site in confInfo.sites)
                {
                    ThisAddIn.g_log.Info(string.Format("return conf site name is: {0}",site.name));
                    ThisAddIn.g_log.Info(string.Format("return conf site uri is: {0}", site.uri));
                    ThisAddIn.g_log.Info(string.Format("return conf site type is: {0}", site.type));
                }

                //confId
                UserProperty upConfoID = ai.UserProperties.Add(PROPERTY_NAME_CONF_INFO, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upConfoID.Value = confInfo.confId;
                ThisAddIn.g_log.Info(string.Format("return conf id is: {0}", confInfo.confId));

                //access code
                UserProperty upAccessCode = ai.UserProperties.Add(PROPERTY_ACCESS_CODE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upAccessCode.Value = confInfo.accessCode;
                ThisAddIn.g_log.Info(string.Format("return conf access code is: {0}", confInfo.accessCode));

                //recording address
                UserProperty upRecordingAddress = ai.UserProperties.Add(PROPERTY_RECORDING_ADDRESS, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upRecordingAddress.Value = confInfo.recorderAddr;
                ThisAddIn.g_log.Info(string.Format("return conf recorder url is: {0}", confInfo.recorderAddr));
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("SaveReturnUserProperties exception,{0}", ex.Message));
                MessageBox.Show(ex.Message);
            }
            ThisAddIn.g_log.Info(string.Format("SaveReturnUserProperties end"));
        }
示例#35
0
        public static void SaveRecurrenceReturnUserProperties(RecurrenceConfInfo confInfo, AppointmentItem ai, List<RecurrenceAppoint> rAppoints)
        {
            ThisAddIn.g_log.Info(string.Format("SaveRecurrenceReturnUserProperties begin"));
            try
            {
                ThisAddIn.g_log.Info(string.Format("Recurrence return conf name is: {0}", confInfo.name));
                ThisAddIn.g_log.Info(string.Format("Recurrence return conf beginTime is: {0}", confInfo.beginTime.ToLocalTime()));

                if (confInfo.isLiveBroadcastSpecified)
                {
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf isLiveBroadcast is: {0}", confInfo.isLiveBroadcast));
                }

                if (confInfo.isRecordingSpecified)
                {
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf isRecording is: {0}", confInfo.isRecording));
                }

                if (confInfo.endDateSpecified)
                {
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf endDate is: {0}", confInfo.endDate.ToShortDateString()));
                }

                if (confInfo.frequencySpecified)
                {
                    if (confInfo.frequency != null)
                    {
                        ThisAddIn.g_log.Info(string.Format("Recurrence return conf frequency is: {0}", confInfo.frequency));
                    }
                }

                if (confInfo.intervalSpecified)
                {
                    if (confInfo.interval != null)
                    {
                        ThisAddIn.g_log.Info(string.Format("Recurrence return conf interval is: {0}", confInfo.interval));
                    }
                }

                ThisAddIn.g_log.Info(string.Format("Recurrence return conf monthDay is: {0}", confInfo.monthDay));
                ThisAddIn.g_log.Info(string.Format("Recurrence return conf weekDay is: {0}", confInfo.weekDay));
                if (confInfo.weekDays != null)
                {
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf weekDays is: {0}", confInfo.weekDays));
                }

                foreach (SiteAccessInfo site in confInfo.siteAccessInfos)
                {
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf site mcuUri is: {0}", site.mcuUri));
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf site uri is: {0}", site.uri));
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf site beginTime is: {0}", site.beginTime.ToLocalTime().ToLongTimeString()));
                    ThisAddIn.g_log.Info(string.Format("Recurrence return conf site confAccessCode is: {0}", site.confAccessCode));
                }

                //confId
                UserProperty upConfoID = ai.UserProperties.Add(PROPERTY_NAME_CONF_INFO, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upConfoID.Value = confInfo.confId;
                ThisAddIn.g_log.Info(string.Format("return recurrence conf id is: {0}", confInfo.confId));

                //access code
                UserProperty upAccessCode = ai.UserProperties.Add(PROPERTY_ACCESS_CODE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upAccessCode.Value = confInfo.accessCode;
                ThisAddIn.g_log.Info(string.Format("return recurrence conf access code is: {0}", confInfo.siteAccessInfos[0].confAccessCode));

                //recording address
                UserProperty upRecordingAddress = ai.UserProperties.Add(PROPERTY_RECORDING_ADDRESS, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upRecordingAddress.Value = confInfo.recorderAddr;
                ThisAddIn.g_log.Info(string.Format("return recurrence conf recorder url is: {0}", confInfo.recorderAddr));

                //
                UserProperty upRightBeginTime = ai.UserProperties.Add(PROPERTY_RIGHT_BEGIN_TIME, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upRightBeginTime.Value = XmlHelper.Serialize(rAppoints);
                ThisAddIn.g_log.Info(string.Format("return recurrence conf begin time is: {0}", XmlHelper.Serialize(rAppoints)));
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("SaveRecurrenceReturnUserProperties exception,{0}", ex.Message));
                MessageBox.Show(ex.Message);
            }
            ThisAddIn.g_log.Info(string.Format("SaveRecurrenceReturnUserProperties end"));
        }
示例#36
0
        private int WetherContainTPSites(AppointmentItem appt)
        {
            int nCount = 0;
            int nVideo = 0;
            int nVoice = 0;

            //2014-6-24 如果设置了视频方数或语音方数,则一并计算
            UserProperty up = appt.UserProperties.Find(PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVideo = up.Value;
            }
            else
            {
                nVideo = ThisAddIn.g_SystemSettings.nVideoSitesCount;
            }
            ThisAddIn.g_log.Info(string.Format("WetherContainTPSites video count: {0}", nVideo));

            up = appt.UserProperties.Find(PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVoice = up.Value;
            }
            else
            {
                nVoice = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
            }
            ThisAddIn.g_log.Info(string.Format("WetherContainTPSites voice count: {0}", nVoice));

            nCount = nVideo + nVoice;

            //获取收件人
            Outlook.Recipients recipients = appt.Recipients;
            foreach (Outlook.Recipient recipient in recipients)
            {
                Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
                if (string.IsNullOrEmpty(exchangeUser.JobTitle))
                {
                    continue;
                }

                if (exchangeUser.JobTitle.Equals("VideoRoom"))
                {
                    nCount++;
                    ThisAddIn.g_log.Info(string.Format("WetherContainTPSites TP site: {0}", exchangeUser.PrimarySmtpAddress));
                }
            }

            return nCount;
        }
示例#37
0
        /// <summary>
        /// 会议修改失败,会议属性回滚 2014/11/6
        /// </summary>
        /// <param name="ai"></param>
        /// <param name="bak_appointment"></param>
        private void ValueBackAppointMent(ref AppointmentItem ai, BackUpAppointment bak_appointment)
        {
            try
            {
                ai.Subject = bak_appointment.bak_subject;
                ai.RequiredAttendees = bak_appointment.bak_attdences;
                ai.Resources = "";
                ai.Resources = bak_appointment.bak_resources;
                ai.Location = "";
                ai.Location = bak_appointment.bak_location;
                try
                {
                    UserProperty up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
                    up.Value = bak_appointment.bak_confPwd;

                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
                    up.Value = bak_appointment.bak_videoCount;

                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Type.Missing);
                    up.Value = bak_appointment.bak_voiceCount;

                    //is recording
                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_IS_RECORDING, Type.Missing);
                    up.Value = bak_appointment.bak_record;

                    //is living
                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_IS_LIVING, Type.Missing);
                    up.Value = bak_appointment.bak_liveBoradcast;

                    //site rate
                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_SITE_RATE, Type.Missing);
                    up.Value = bak_appointment.bak_siteRate;

                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_SECURITY_LEVEL, Type.Missing);
                    up.Value = bak_appointment.bak_securityLevel;

                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_BILL_CODE, Type.Missing);
                    up.Value = bak_appointment.bak_billCode;

                    up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CPRESOURCE, Type.Missing);
                    up.Value = bak_appointment.bak_cpResource;

                    ThisAddIn.g_log.Info(string.Format("Set AppointmentItem properties back end"));
                }
                catch (System.Exception ex)
                {
                    ThisAddIn.g_log.Error(string.Format("Set AppointmentItem properties Exception. because {0}", ex.Message));
                }

                //2014/11/10 测试
                if (ai.RecurrenceState == OlRecurrenceState.olApptMaster)
                {
                    RecurrencePattern rPattern = ai.GetRecurrencePattern();
                    rPattern.StartTime = bak_appointment.bak_recurrencePattern.StartTime;
                    rPattern.EndTime = bak_appointment.bak_recurrencePattern.EndTime;
                    rPattern.Duration = bak_appointment.bak_recurrencePattern.Duration;
                    rPattern.PatternStartDate = bak_appointment.bak_recurrencePattern.PatternStartDate;
                    rPattern.PatternEndDate = bak_appointment.bak_recurrencePattern.PatternEndDate;

                    rPattern.Interval = bak_appointment.bak_recurrencePattern.Interval;
                    rPattern.NoEndDate = bak_appointment.bak_recurrencePattern.NoEndDate;
                    rPattern.Occurrences = bak_appointment.bak_recurrencePattern.Occurrences;
                    rPattern.RecurrenceType = (OlRecurrenceType)bak_appointment.bak_recurrencePattern.RecurrenceType;
                }
                else
                {
                    ai.Start = bak_appointment.bak_start;
                    ai.End = bak_appointment.bak_end;
                }
                ThisAddIn.g_log.Info(string.Format("Set AppointmentItem time back end"));
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Info(string.Format("Set AppointmentItem back comes Exception {0}", ex.ToString()));
            }
        }
示例#38
0
        /// <summary>
        /// 获取周期性会议信息
        /// </summary>
        /// <param name="ConfInfo">周期性会议信息</param>
        private void setRecurrenceConferenceInfo(ref RecurrenceConfInfo recurrenceConfInfo, AppointmentItem ai, bool bSingle)
        {
            //获取智真会议参数
            recurrenceConfInfo.name = ai.Subject;
            recurrenceConfInfo.beginTime = ai.Start.ToUniversalTime();

            TimeSpan span = ai.End - ai.Start;
            string duration = String.Format("P0Y0M{0}DT{1}H{2}M{3}S", span.Days, span.Hours, span.Minutes, span.Seconds);
            recurrenceConfInfo.duration = duration;
            recurrenceConfInfo.mediaEncryptType = ThisAddIn.g_SystemSettings.nMediaEncryptType;
            recurrenceConfInfo.rate = ThisAddIn.g_SystemSettings.strSiteRate;

            recurrenceConfInfo.isLiveBroadcast = ThisAddIn.g_SystemSettings.nLiving;
            recurrenceConfInfo.isRecording = ThisAddIn.g_SystemSettings.nRecording;

            recurrenceConfInfo.timeZone = transSysTimezone2SMC(ai.StartTimeZone);

            recurrenceConfInfo.billCode = ThisAddIn.g_SystemSettings.strBillCode;
            recurrenceConfInfo.password = ThisAddIn.g_SystemSettings.strConfPWD;
            recurrenceConfInfo.chairmanPassword = ThisAddIn.g_SystemSettings.strConfPWD;
            recurrenceConfInfo.cpResouce = ThisAddIn.g_SystemSettings.nCPResource;

            #region
            UserProperty up = ai.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.confId = up.Value;
            }
            else
            {
                UserProperty upConfoID = ai.UserProperties.Add(ThisAddIn.PROPERTY_NAME_CONF_INFO, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
            }

            up = ai.UserProperties.Find(PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.password = up.Value;
                recurrenceConfInfo.chairmanPassword = up.Value;
            }
            else
            {
                UserProperty upConfoPassword = ai.UserProperties.Add(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upConfoPassword.Value = ThisAddIn.g_SystemSettings.strConfPWD;
            }

            up = ai.UserProperties.Find(PROPERTY_IS_RECORDING, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.isRecording = Convert.ToInt32(up.Value);
            }
            else
            {
                UserProperty upRecording = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_RECORDING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing);
                upRecording.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nRecording);
            }

            up = ai.UserProperties.Find(PROPERTY_IS_LIVING, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.isLiveBroadcast = Convert.ToInt32(up.Value);
            }
            else
            {
                UserProperty upLiving = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_LIVING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing);
                upLiving.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nLiving);
            }

            up = ai.UserProperties.Find(PROPERTY_SITE_RATE, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.rate = up.Value;
            }
            else
            {
                UserProperty upSiteRate = ai.UserProperties.Add(ThisAddIn.PROPERTY_SITE_RATE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upSiteRate.Value = ThisAddIn.g_SystemSettings.strSiteRate;
            }

            up = ai.UserProperties.Find(PROPERTY_SECURITY_LEVEL, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.mediaEncryptType = up.Value;
            }
            else
            {
                UserProperty upSecurityLevel = ai.UserProperties.Add(ThisAddIn.PROPERTY_SECURITY_LEVEL, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upSecurityLevel.Value = ThisAddIn.g_SystemSettings.nMediaEncryptType;
            }

            up = ai.UserProperties.Find(PROPERTY_BILL_CODE, Type.Missing);
            if (up != null)
            {
                recurrenceConfInfo.billCode = up.Value;
            }
            else
            {
                UserProperty upBillCode = ai.UserProperties.Add(ThisAddIn.PROPERTY_BILL_CODE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upBillCode.Value = ThisAddIn.g_SystemSettings.strBillCode;
            }

            up = ai.UserProperties.Find(PROPERTY_CPRESOURCE, Type.Missing);
            if (up != null)
            {
                if (false == ThisAddIn.g_SystemSettings.bShowCPResource)
                {
                    recurrenceConfInfo.cpResouce = 0;
                }
                else
                {
                    recurrenceConfInfo.cpResouce = up.Value;
                }
            }
            else//非智真会场入口
            {
                UserProperty upCPResource = ai.UserProperties.Add(ThisAddIn.PROPERTY_CPRESOURCE, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);

                if (false == ThisAddIn.g_SystemSettings.bShowCPResource)
                {
                    upCPResource.Value = 0;
                    recurrenceConfInfo.cpResouce = 0;
                }
                else
                {
                    upCPResource.Value = ThisAddIn.g_SystemSettings.nCPResource;
                }
            }

            #endregion
            ThisAddIn.g_log.Info(string.Format("recurrence conf id is: {0}", recurrenceConfInfo.confId));
            ThisAddIn.g_log.Info(string.Format("recurrence conf name is: {0}", recurrenceConfInfo.name));
            ThisAddIn.g_log.Info(string.Format("recurrence conf begin at utc: {0}", recurrenceConfInfo.beginTime.ToString()));
            ThisAddIn.g_log.Info(string.Format("appointment item begin at local: {0}", ai.Start.ToString()));

            ThisAddIn.g_log.Info(string.Format("recurrence conf duration: {0}", recurrenceConfInfo.duration));
            ThisAddIn.g_log.Info(string.Format("recurrence conf rate is: {0}", recurrenceConfInfo.rate));
            ThisAddIn.g_log.Info(string.Format("recurrence conf media encrypt type is: {0}", recurrenceConfInfo.mediaEncryptType));
            ThisAddIn.g_log.Info(string.Format("recurrence conf recording is: {0}", recurrenceConfInfo.isRecording));

            ThisAddIn.g_log.Info(string.Format("recurrence conf living is: {0}", recurrenceConfInfo.isLiveBroadcast));
            ThisAddIn.g_log.Info(string.Format("recurrence conf bill code is: {0}", recurrenceConfInfo.billCode));
            ThisAddIn.g_log.Info(string.Format("recurrence conf password is: ******"));
            ThisAddIn.g_log.Info(string.Format("recurrence conf chairman password is: ******"));
            ThisAddIn.g_log.Info(string.Format("recurrence conf CPResource is: {0}", recurrenceConfInfo.cpResouce));
            ThisAddIn.g_log.Info(string.Format("recurrence conf timezone is: {0}", recurrenceConfInfo.timeZone));

            //视频会场
            ArrayList list = new ArrayList();
            SiteInfo tempSite = null;
            int nVideoCount = 0;

            up = ai.UserProperties.Find(PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVideoCount = up.Value;
            }
            else
            {
                UserProperty upVideoSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upVideoSiteCounts.Value = ThisAddIn.g_SystemSettings.nVideoSitesCount;
                nVideoCount = ThisAddIn.g_SystemSettings.nVideoSitesCount;
            }

            if (nVideoCount > 0)
            {
                for (int i = 0; i < nVideoCount; i++)
                {
                    tempSite = new SiteInfo();
                    tempSite.type = 4;
                    list.Add(tempSite);
                }
            }

            //语音会场
            int nVoiceCount = 0;
            up = ai.UserProperties.Find(PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                nVoiceCount = up.Value;
            }
            else
            {
                UserProperty upVoiceSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upVoiceSiteCounts.Value = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
                nVoiceCount = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
            }

            if (nVoiceCount > 0)
            {
                for (int i = 0; i < nVoiceCount; i++)
                {
                    tempSite = new SiteInfo();
                    tempSite.type = 9;
                    list.Add(tempSite);
                }
            }

            //2015-7-8 w00322557 临时会场
            up = ai.UserProperties.Find(PROPERTY_TEMP_SITES, Type.Missing);
            if (up != null)
            {
                List<SiteInfo> listTempSites = XmlHelper.Desrialize<List<SiteInfo>>(up.Value);
                foreach (SiteInfo site in listTempSites)
                {
                    list.Add(site);
                    ThisAddIn.g_log.Info(string.Format("Temp site name: {0}", site.name));
                    ThisAddIn.g_log.Info(string.Format("Temp site uri: {0}", site.uri));
                    ThisAddIn.g_log.Info(string.Format("Temp site type: {0}", site.type));
                }
            }
            else
            {
                ThisAddIn.g_log.Debug("Temp site is null or empty!");
            }

            //从地址栏获取智真会场
            List<string> listSites = GetTPSitesFromLocation(ai);

            if (listSites != null)
            {
                SiteInfo[] sites = new SiteInfo[listSites.Count];
                for (int i = 0; i < listSites.Count; i++)
                {
                    sites[i] = new SiteInfo();
                    sites[i].uri = listSites[i];
                    sites[i].type = -1;//2015-7-13 w00322557 smc会场类型修改为-1
                    list.Add(sites[i]);

                    ThisAddIn.g_log.Info(string.Format("TP site uri is: {0}", sites[i].uri));
                }
            }

            if (list.Count > 0)
            {
                recurrenceConfInfo.sites = (SiteInfo[])list.ToArray(typeof(SiteInfo));
                ThisAddIn.g_log.Info(string.Format("RecurrenceConfInfo sites length is: {0}", recurrenceConfInfo.sites.Length));
                ThisAddIn.g_log.Info(string.Format("Total TP sites count is: {0}", list.Count));
            }
            else
            {
                ThisAddIn.g_log.Error(string.Format("There is no TP sites!"));
            }

            if (bSingle == false)
            {
                ThisAddIn.g_log.Info("setRecurrenceConferenceInfo recurrence");

                //周期信息
                RecurrencePattern recurrencePattern = ai.GetRecurrencePattern();
                OlDaysOfWeek daysOfWeek = recurrencePattern.DayOfWeekMask;//一周中的天数
                //recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数
                //recurrencePattern.GetOccurrence()//根据指定日期,返回AppointmentItem

                if (recurrencePattern.NoEndDate == true)
                {
                    recurrencePattern.NoEndDate = false;
                }

                //周期类型(天=0、周=1、月=2)
                if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursDaily)//天
                {
                    recurrenceConfInfo.frequency = 0;
                    recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔

                    if (true == recurrenceConfInfo.endDateSpecified)
                    {
                        recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期
                    }
                    else
                    {
                        recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数
                    }
                }
                else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursWeekly)//周
                {
                    recurrenceConfInfo.frequency = 1;
                    //
                    Int32[] weekDays = this.getWeekDays(daysOfWeek);
                    if (weekDays != null)
                    {
                        recurrenceConfInfo.weekDays = weekDays;
                    }

                    if (0 == recurrencePattern.Interval)
                    {
                        recurrenceConfInfo.interval = 1;//周期间隔
                    }
                    else
                    {
                        recurrenceConfInfo.interval = recurrencePattern.Interval;
                    }

                    if (true == recurrenceConfInfo.endDateSpecified)
                    {
                        recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期
                    }
                    else
                    {
                        recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数
                    }
                }
                else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursMonthly)//月
                {
                    recurrenceConfInfo.frequency = 2;
                    int nDay = recurrencePattern.PatternStartDate.Day;
                    recurrenceConfInfo.monthDay = nDay;

                    recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔

                    if (true == recurrenceConfInfo.endDateSpecified)
                    {
                        recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期
                    }
                    else
                    {
                        recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数
                    }
                }
                else if (recurrencePattern.RecurrenceType == OlRecurrenceType.olRecursMonthNth)
                {
                    recurrenceConfInfo.frequency = 2;
                    recurrenceConfInfo.weekDay = recurrencePattern.Instance;
                    recurrenceConfInfo.weekDays = this.getWeekDays(daysOfWeek);
                    recurrenceConfInfo.interval = recurrencePattern.Interval;//周期间隔

                    if (true == recurrenceConfInfo.endDateSpecified)
                    {
                        recurrenceConfInfo.endDate = Convert.ToDateTime(recurrencePattern.PatternEndDate.ToShortDateString());//周期性会议结束日期
                    }
                    else
                    {
                        recurrenceConfInfo.count = recurrencePattern.Occurrences;//周期性会议重复次数
                    }
                }
                else
                {
                    ThisAddIn.g_log.Error("RecurrenceType is year!");
                }
            }
            else
            {
                //recurrenceConfInfo.timeZone = null;
                recurrenceConfInfo.frequency = null;
                recurrenceConfInfo.interval = null;
                ThisAddIn.g_log.Info("setRecurrenceConferenceInfo single");
            }

            ThisAddIn.g_log.Info("setRecurrenceConferenceInfo success");
        }
示例#39
0
        private void CurrentExplorer_Event()
        {
            Outlook.Application myapp = Globals.ThisAddIn.Application;

            Outlook.Explorer localcalendar =
                myapp.ActiveExplorer(); //For local calender appointments.

            Outlook.Explorer sharedcalendar =
                myapp.Session.GetSharedDefaultFolder(
                    myapp.Session.CreateRecipient(myapp.Session.CurrentUser.Address), //our own shared folder
                    Outlook.OlDefaultFolders.olFolderCalendar
                    ).Application.ActiveExplorer();

            if (localcalendar.CurrentFolder.Name == "Calendar" ||
                sharedcalendar.CurrentFolder.Name != "")
            {
                if (localcalendar.Selection.Count > 0 &&
                    localcalendar.Selection[1].Subject != "")
                {
                    object localobject = Globals.ThisAddIn.Application.ActiveExplorer().Selection[1];
                    if (localobject is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem localapptitem =
                            (localobject as Outlook.AppointmentItem);
                        myapptitem_ = localapptitem;
                    }
                }
                else if (sharedcalendar.Selection.Count > 0 &&
                    sharedcalendar.Selection[1].Subject != "")
                {
                    object sharedobject = sharedcalendar.Selection[1];
                    if (sharedobject is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem sharedapptitem =
                            (sharedobject as Outlook.AppointmentItem);
                        myapptitem_ = sharedapptitem;
                    }
                }
                else
                {
                    myapptitem_ = null;
                }
            }
        }
示例#40
0
        /// <summary>
        /// 发送邮件通知
        /// </summary>
        /// <param name="ins"></param>        
        private void sendMailNotifications(AppointmentItem appt, OperatorType opType, Recipients recipients)
        {
            ThisAddIn.g_log.Info("sendMailNotifications enter");
            MailItem mailItem = (MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);//创建mailItem
            string smtpAddress = "";

            #region 发送邮件通知给自己 注销
            //获取自己的邮箱号,数组的第一个是自己
            //Outlook.Recipient recp = appt.Recipients[1];
            //smtpAddress += recp.AddressEntry.GetExchangeUser().PrimarySmtpAddress + ";";

            //smtpAddress += Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser().PrimarySmtpAddress +";";
            #endregion

            foreach (Outlook.Recipient recipient in recipients)
            {
                if (recipient.Sendable)//可发送
                {
                    Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
                    if (exchangeUser != null)
                    {
                        smtpAddress += exchangeUser.PrimarySmtpAddress + "; ";
                    }
                    else
                    {
                        smtpAddress += recipient.Address + "; ";
                    }
                }

            }

            mailItem.To = smtpAddress;  //收件人地址

            //根据不同操作类型,添加邮件主题前缀
            if (opType == OperatorType.Schedule)
            {
                mailItem.Subject = "[Successfully Scheduled]" + appt.Subject;
            }
            else if (opType == OperatorType.Modify)
            {
                mailItem.Subject = "[Successfully Modified]" + appt.Subject;
            }
            else if (opType == OperatorType.Cancel)
            {
                mailItem.Subject = "[Successfully Canceled]" + appt.Subject;
            }
            else
            {
                ThisAddIn.g_log.Error("MailItem OperatorType error!");
            }

            mailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;//body格式

            try
            {
                this.CopyBody(appt, mailItem);//从appointmentitem中拷贝body
                ((Outlook._MailItem)mailItem).Send();//发送邮件
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.ToString());
            }

            ThisAddIn.g_log.Info("sendMailNotifications exit");
        }
示例#41
0
        /// <summary>
        /// 预约周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int scheduleRecurrenceTPConf(ref AppointmentItem ai)
        {
            ThisAddIn.g_log.Info("scheduleRecurrenceTPConf enter");
            Inspector ins = ai.GetInspector;

            RecurrenceConfInfo ConfInfo = new RecurrenceConfInfo();
            setRecurrenceConferenceInfo(ref ConfInfo, ai, false);

            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            TPOASDKResponse<RecurrenceConfInfo> responseRecurrence = null;
            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                responseRecurrence = conferenceServiceEx.scheduleRecurrenceConference(ConfInfo);
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("scheduleRecurrenceTPConf exception,because {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == responseRecurrence.resultCode)
            {
                try
                {
                    //预约成功,将返回的confId作为属性保存
                    RecurrenceConfInfo retConfInfo = responseRecurrence.result;

                    //2014/10/14 新增测试
                    List<RecurrenceAppoint> retConfInfoArray = new List<RecurrenceAppoint>();
                    ArrayList tempCon = new ArrayList();
                    if (retConfInfo.siteAccessInfos != null)
                    {
                        RecurrenceAppoint appo = null;
                        for (int i = 0; i < retConfInfo.siteAccessInfos.Length; i++)
                        {
                            DateTime time = retConfInfo.siteAccessInfos[i].beginTime.ToLocalTime();
                            if (!tempCon.Contains(time))//
                            {
                                tempCon.Add(time);

                                appo = new RecurrenceAppoint();
                                appo.AppointDate = time.ToShortDateString();
                                appo.AppointTime = time.ToLongTimeString();
                                appo.AccessCode = retConfInfo.siteAccessInfos[i].confAccessCode;

                                //2015-6-17 w00322557 保存会场
                                appo.AppointSites += retConfInfo.sites[i].name + ",";
                                retConfInfoArray.Add(appo);
                            }
                            else
                            {
                                appo.AppointSites += retConfInfo.sites[i].name + ",";
                            }

                            ThisAddIn.g_log.Info(string.Format("RecurrenceAppoint sites name: {0}", retConfInfo.sites[i].name));
                        }
                    }

                    SaveRecurrenceReturnUserProperties(retConfInfo, ai, retConfInfoArray);

                    DateTime tmpBeginTime = retConfInfo.siteAccessInfos[0].beginTime.ToLocalTime();
                    if (ai.Start != tmpBeginTime)
                    {
                        RecurrencePattern recurrencePattern = ai.GetRecurrencePattern();
                        recurrencePattern.StartTime = DateTime.Parse(tmpBeginTime.ToShortTimeString());
                    }

                    if (string.IsNullOrEmpty(ai.Subject))
                    {
                        ai.Subject = retConfInfo.name;
                        ThisAddIn.g_log.Info(string.Format("outlook subject is empty. return subject is: {0}", retConfInfo.name));
                    }

                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        //获取当前语言通知模板的路径
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));
                        string strNotify = this.replaceContentsInTemplateRecurrence(ai, textTemplate, ref retConfInfo);

                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("schedule recurrence paste enter.");

                        object start = 0;
                        Range newRang = objDoc.Range(ref start, ref start);

                        int ioo = objDoc.Sections.Count;
                        Section sec = objDoc.Sections.Add(Type.Missing, Type.Missing);

                        sec.Range.InsertBreak(Type.Missing);//插入换行符

                        //2014/11/13 测试,防止异常,邮件体出现空白
                        for (int i = 0; i < 5; i++)
                        {
                            try
                            {
                                sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);
                                break;
                            }
                            catch (System.Exception ex)
                            {
                                ThisAddIn.g_log.Error(ex.Message);
                                Thread.Sleep(500);
                            }
                        }

                        ThisAddIn.g_log.Info("schedule recurrence paste end");

                        #region 2014/11/3 注销,合并入SendMailNotification()
                        ThisAddIn.g_log.Info("schedule send mail enter.");

                        //MailItem email = this.Application.CreateItem(OlItemType.olMailItem);
                        //string smtpAddress = "";

                        //Outlook.Recipients recipients = ai.Recipients;
                        //foreach (Outlook.Recipient recipient in recipients)
                        //{
                        //    Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();

                        //    if (exchangeUser != null)
                        //    {
                        //        smtpAddress += exchangeUser.PrimarySmtpAddress + ";";//获取账户信息,作为默认第一个收件人
                        //    }
                        //    else
                        //    {
                        //        smtpAddress += recipient.Address + ";";//添加收件人地址
                        //    }
                        //}

                        //email.To = smtpAddress;  //收件人地址
                        //email.Subject = "[Successfully Scheduled]" + ai.Subject;
                        //email.BodyFormat = OlBodyFormat.olFormatHTML;//body格式
                        //email.HTMLBody = strNotify;

                        //((Outlook._MailItem)email).Send();//发送邮件

                        //ThisAddIn.g_log.Info("sendMailNotifications exit");
                        //ThisAddIn.g_log.Info("schedule send mail exit.");
                        #endregion

                        Outlook.Recipients recipients = ai.Recipients;
                        sendMailNotifications(ai, OperatorType.Schedule, recipients);

                        //3's
                        MessageBoxTimeOut mes = new MessageBoxTimeOut();
                        string strFormat = GlobalResourceClass.getMsg("OPERATOR_MESSAGE");
                        string messageBody = string.Format(strFormat, GlobalResourceClass.getMsg("OPERATOR_TYPE_SCHEDULE"));
                        mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                    }
                }
                catch (System.Exception ex)
                {
                    ThisAddIn.g_log.Error(string.Format("recurrence email notification error,because {0}.", ex.Message));
                }
            }
            else
            {
                //
                ThisAddIn.g_log.Info(string.Format("scheduleRecurrenceTPConf failed with: {0}", responseRecurrence.resultCode.ToString()));
            }

            ThisAddIn.g_log.Info("scheduleRecurrenceTPConf exit");
            return responseRecurrence.resultCode;
        }
示例#42
0
 /// <summary>
 /// 选择发送人员信息
 /// </summary>
 /// <param name="ai"></param>
 /// <param name="meetingItem"></param>
 private void SendRecipientsInfo(AppointmentItem ai, MeetingItem meetingItem)
 {
     if (meetingItem != null)
     {
         //获取人员
         Outlook.Recipients recipents = meetingItem.Recipients;
         //发送的是会议取消人员
         if (meetingItem.Class.ToString().Equals("olMeetingCancellation"))
         {
             sendMailNotifications(ai, OperatorType.Cancel, recipents);
         }
         else if (meetingItem.Class.ToString().Equals("olMeetingRequest")) //发送的是会议增加人员
         {
             sendMailNotifications(ai, OperatorType.Modify, recipents);
         }
     }
 }
示例#43
0
        /// <summary>
        /// 获取用户自定义属性
        /// </summary>
        /// <param name="confInfo"></param>
        /// <param name="ai"></param>
        public static void GetUserProperties(ref ConferenceInfo confInfo, AppointmentItem ai)
        {
            UserProperty up = ai.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing);
            if (up != null)
            {
                confInfo.confId = up.Value;
            }
            else
            {
                UserProperty upConfoID = ai.UserProperties.Add(ThisAddIn.PROPERTY_NAME_CONF_INFO, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
            }

            up = ai.UserProperties.Find(PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
            if (up != null)
            {
                confInfo.password = up.Value;
                confInfo.chairmanPassword = up.Value;
            }
            else
            {
                UserProperty upConfoPassword = ai.UserProperties.Add(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upConfoPassword.Value = ThisAddIn.g_SystemSettings.strConfPWD;
            }

            up = ai.UserProperties.Find(PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            if (up != null)
            {

            }
            else
            {
                UserProperty upVideoSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upVideoSiteCounts.Value = ThisAddIn.g_SystemSettings.nVideoSitesCount;
            }

            up = ai.UserProperties.Find(PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            if (up != null)
            {

            }
            else
            {
                UserProperty upVoiceSiteCounts = ai.UserProperties.Add(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upVoiceSiteCounts.Value = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
            }

            up = ai.UserProperties.Find(PROPERTY_IS_RECORDING, Type.Missing);
            if (up != null)
            {
                confInfo.isRecording = Convert.ToInt32(up.Value);
            }
            else
            {
                UserProperty upRecording = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_RECORDING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing);
                upRecording.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nRecording);
            }

            up = ai.UserProperties.Find(PROPERTY_IS_LIVING, Type.Missing);
            if (up != null)
            {
                confInfo.isLiveBroadcast = Convert.ToInt32(up.Value);
            }
            else
            {
                UserProperty upLiving = ai.UserProperties.Add(ThisAddIn.PROPERTY_IS_LIVING, Outlook.OlUserPropertyType.olYesNo, Type.Missing, Type.Missing);
                upLiving.Value = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nLiving);
            }

            up = ai.UserProperties.Find(PROPERTY_SITE_RATE, Type.Missing);
            if (up != null)
            {
                confInfo.rate = up.Value;
            }
            else
            {
                UserProperty upSiteRate = ai.UserProperties.Add(ThisAddIn.PROPERTY_SITE_RATE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upSiteRate.Value = ThisAddIn.g_SystemSettings.strSiteRate;
            }

            up = ai.UserProperties.Find(PROPERTY_SECURITY_LEVEL, Type.Missing);
            if (up != null)
            {
                confInfo.mediaEncryptType = up.Value;
            }
            else
            {
                UserProperty upSecurityLevel = ai.UserProperties.Add(ThisAddIn.PROPERTY_SECURITY_LEVEL, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);
                upSecurityLevel.Value = ThisAddIn.g_SystemSettings.nMediaEncryptType;
            }

            up = ai.UserProperties.Find(PROPERTY_BILL_CODE, Type.Missing);
            if (up != null)
            {
                confInfo.billCode = up.Value;
            }
            else
            {
                UserProperty upBillCode = ai.UserProperties.Add(ThisAddIn.PROPERTY_BILL_CODE, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upBillCode.Value = ThisAddIn.g_SystemSettings.strBillCode;
            }

            up = ai.UserProperties.Find(PROPERTY_CPRESOURCE, Type.Missing);
            if (up != null)
            {
                if (false == ThisAddIn.g_SystemSettings.bShowCPResource)
                {
                    confInfo.cpResouce = 0;
                }
                else
                {
                    confInfo.cpResouce = up.Value;
                }
            }
            else
            {
                UserProperty upCPResource = ai.UserProperties.Add(ThisAddIn.PROPERTY_CPRESOURCE, Outlook.OlUserPropertyType.olInteger, Type.Missing, Type.Missing);

                if (false == ThisAddIn.g_SystemSettings.bShowCPResource)
                {
                    upCPResource.Value = 0;
                    confInfo.cpResouce = 0;
                }
                else
                {
                    upCPResource.Value = ThisAddIn.g_SystemSettings.nCPResource;
                }
            }

            //2015-7-8 w00322557
            up = ai.UserProperties.Find(PROPERTY_TEMP_SITES, Type.Missing);
            List<SiteInfo> listSites = new List<SiteInfo>();
            if (up != null)
            {
                listSites = XmlHelper.Desrialize<List<SiteInfo>>(up.Value);
            }
            else
            {
                UserProperty upTempSites = ai.UserProperties.Add(ThisAddIn.PROPERTY_TEMP_SITES, Outlook.OlUserPropertyType.olText, Type.Missing, Type.Missing);
                upTempSites.Value = XmlHelper.Serialize(listSites);
            }
        }
示例#44
0
        /// <summary>
        /// 预约非周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int scheduleTPConf(AppointmentItem ai)
        {
            ThisAddIn.g_log.Info("scheduleTPConf enter");
            //2014-4-29
            Inspector ins = ai.GetInspector;

            ConferenceInfo ConfInfo = new ConferenceInfo();
            setConferenceInfo(ref ConfInfo, ai);

            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            TPOASDKResponse<ConferenceInfo> response = null;
            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                response = conferenceServiceEx.scheduleConf(ConfInfo);
                ThisAddIn.g_log.Info(string.Format("scheduleConf return: {0}", response.resultCode));
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("scheduleConf exception:{0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == response.resultCode)
            {
                //预约成功,将返回的confId作为属性保存
                ConferenceInfo retConfInfo = response.result;

                SaveReturnUserProperties(retConfInfo, ai);

                if (string.IsNullOrEmpty(ai.Subject))
                {
                    ai.Subject = ConfInfo.name;
                }

                //HTML模板
                Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document;
                if (null != objDoc)
                {
                    try
                    {
                        //获取当前语言通知模板的路径
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));
                        string strNotify = this.replaceContentsInTemplate(ai, textTemplate, ref retConfInfo);

                        //Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        //paste notification to body
                        ThisAddIn.g_log.Info("schedule paste enter");

                        Section sec = objDoc.Sections.Add(Type.Missing, Type.Missing);
                        sec.Range.InsertBreak(Type.Missing);//插入换行符

                        //2014/11/13 防止异常,邮件体出现空白
                        for (int i = 0; i < 5; i++)
                        {
                            try
                            {
                                sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);
                                break;
                            }
                            catch (System.Exception ex)
                            {
                                ThisAddIn.g_log.Error(ex.Message);
                                Thread.Sleep(500);
                            }
                        }

                        ThisAddIn.g_log.Info("schedule paste end");

                        //send email
                        Outlook.Recipients recipients = ai.Recipients;
                        sendMailNotifications(ai, OperatorType.Schedule, recipients);

                        //3's
                        MessageBoxTimeOut mes = new MessageBoxTimeOut();
                        string strFormat = GlobalResourceClass.getMsg("OPERATOR_MESSAGE");
                        string messageBody = string.Format(strFormat, GlobalResourceClass.getMsg("OPERATOR_TYPE_SCHEDULE"));
                        mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                    }
                    catch (System.Exception ex)
                    {
                        ThisAddIn.g_log.Error(string.Format("email notification error,because: {0},{1},{2}.", ex.Source, ex.Message, ex.StackTrace));
                    }
                }
            }
            else
            {
                //2014-5-13 返回码映射
                ThisAddIn.g_log.Error(string.Format("scheduleConf failed with return code:{0}", response.resultCode.ToString()));
            }
            ThisAddIn.g_log.Info("scheduleTPConf exit");
            return response.resultCode;
        }
示例#45
0
        /// <summary>
        /// 判断appointmentitem是否含有ConfInfo属性
        /// </summary>
        /// <param name="ai"></param>
        /// <returns></returns>
        private bool IsConfInfoUserPropertyExist(AppointmentItem ai)
        {
            //如果存在这个属性,则取出,本次为修改会议信息
            UserProperty up = ai.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing);
            if (null == up)
            {
                return false;
            }

            string strValue = up.Value;
            if (string.IsNullOrEmpty(strValue))
            {
                return false;
            }

            return true;
        }
示例#46
0
        /// <summary>
        /// 替换通知模板中的内容
        /// </summary>
        /// <param name="textTemplate">通知模板</param>
        /// <param name="confInfo">会议信息</param>  
        /// <returns>新的通知消息</returns>
        private string replaceContentsInTemplateRecurrence(AppointmentItem ai, string textTemplate, ref RecurrenceConfInfo confInfo)
        {
            //begin 替换模板中的数据
            string[] strLanguages = ThisAddIn.g_AccountInfo.strLanguage.Split(';');
            int nLanguage = 1033;
            bool bContain = textTemplate.Contains("{Recurrence_Type}");
            if (true == bContain)
            {
                if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "重复周期");
                    nLanguage = 2052;
                }
                else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "Интервал повтора");
                    nLanguage = 1049;
                }
                else
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "Recurrence");
                    nLanguage = 1033;
                }
            }

            bContain = textTemplate.Contains("{Recurrence_Time}");
            if (true == bContain)
            {
                if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "有效时间");
                }
                else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "Срок действия");
                }
                else
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "Valid Time");
                }
            }
            //替换模板中的"会议名称"
            bContain = textTemplate.Contains("{Conf_Subject}");
            string strNewString = "";
            if (true == bContain)
            {
                if (string.IsNullOrEmpty(ai.Subject))
                {
                    strNewString = textTemplate.Replace("{Conf_Subject}", confInfo.name);
                }
                else
                {
                    string myEncodedString = HttpUtility.HtmlEncode(ai.Subject);
                    strNewString = textTemplate.Replace("{Conf_Subject}", myEncodedString);
                }
            }

            //替换模板中的"会议密码"
            bContain = strNewString.Contains("{Conf_Password}");
            string strNewString2 = "";
            if (true == bContain)
            {
                UserProperty up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
                if (up != null)
                {
                    strNewString2 = strNewString.Replace("{Conf_Password}", up.Value);
                }
                else
                {
                    strNewString2 = strNewString.Replace("{Conf_Password}", ThisAddIn.g_SystemSettings.strConfPWD);
                }

            }
            else
            {
                strNewString2 = strNewString;
            }

            //替换模板中的"会议开始时间"
            bContain = strNewString2.Contains("{Conf_Start_Time}");
            string strNewString3 = "";
            if (true == bContain)
            {
                RecurrencePattern rp = ai.GetRecurrencePattern();
                string strTemp = string.Empty;
                DateTime dateTime = rp.PatternStartDate.AddHours(rp.StartTime.Hour);
                dateTime = dateTime.AddMinutes(rp.StartTime.Minute);
                string strFormat = string.Empty;
                if (rp.RecurrenceType == OlRecurrenceType.olRecursDaily)//天
                {
                    if (rp.Interval < 2)
                    {
                        strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_DAY", nLanguage));
                    }
                    else
                    {
                        strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_DAY", nLanguage), rp.Interval);
                    }

                }
                else if (rp.RecurrenceType == OlRecurrenceType.olRecursWeekly)//周
                {
                    string strDayOfWeek = string.Empty;
                    int[] nDayOfWeek = getWeekDays(rp.DayOfWeekMask);
                    for (int i = 0; i < nDayOfWeek.Length; i++)
                    {
                        switch (nDayOfWeek[i])
                        {
                            case 0:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_SUNDAY", nLanguage);
                                break;
                            case 1:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_MONDAY", nLanguage);
                                break;
                            case 2:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_TUESDAY", nLanguage);
                                break;
                            case 3:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_WEDNESDAY", nLanguage);
                                break;
                            case 4:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_THURSDAY", nLanguage);
                                break;
                            case 5:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_FRIDAY", nLanguage);
                                break;
                            case 6:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_SATURDAY", nLanguage);
                                break;
                            default:
                                break;
                        }
                    }

                    if (!string.IsNullOrEmpty(strDayOfWeek) && strDayOfWeek.Length > 0)
                    {
                        strDayOfWeek = strDayOfWeek.Trim();
                        strDayOfWeek = strDayOfWeek.Remove(strDayOfWeek.Length - 1);
                    }

                    if (rp.Interval < 2)
                    {
                        strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_WEEK", nLanguage), strDayOfWeek);
                    }
                    else
                    {
                        //2014/10/11修改
                        if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))//中文
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_WEEK", nLanguage), rp.Interval, strDayOfWeek);
                        }
                        else//英文
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_WEEK", nLanguage), strDayOfWeek, rp.Interval);
                        }

                    }

                }
                else if (rp.RecurrenceType == OlRecurrenceType.olRecursMonthly)//月
                {
                    if (rp.Interval < 2)
                    {
                        strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_MONTH", nLanguage), rp.DayOfMonth, (rp.DayOfMonth < 4 ? (MonthDayNum)rp.DayOfMonth : (MonthDayNum)4));
                    }
                    else
                    {
                        if (nLanguage == 1033)//2015-4-22 w00322557英文格式
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTH", nLanguage), rp.DayOfMonth, (rp.DayOfMonth < 4 ? (MonthDayNum)rp.DayOfMonth : (MonthDayNum)4), rp.Interval);
                        }
                        else if (nLanguage == 1049)//2015-4-22 w00322557俄文格式
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTH", nLanguage), rp.DayOfMonth, rp.Interval);
                        }
                        else
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTH", nLanguage), rp.Interval, rp.DayOfMonth);
                        }
                    }
                    ThisAddIn.g_log.Info(string.Format("RECURRENCE_WITH_MONTH : {0}", strTemp));
                }
                else if (rp.RecurrenceType == OlRecurrenceType.olRecursMonthNth)
                {
                    string strDayOfWeek = string.Empty;
                    int[] nDayOfWeek = getWeekDays(rp.DayOfWeekMask);
                    for (int i = 0; i < nDayOfWeek.Length; i++)
                    {
                        switch (nDayOfWeek[i])
                        {
                            case 0:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_SUNDAY", nLanguage);
                                break;
                            case 1:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_MONDAY", nLanguage);
                                break;
                            case 2:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_TUESDAY", nLanguage);
                                break;
                            case 3:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_WEDNESDAY", nLanguage);
                                break;
                            case 4:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_THURSDAY", nLanguage);
                                break;
                            case 5:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_FRIDAY", nLanguage);
                                break;
                            case 6:
                                strDayOfWeek += GlobalResourceClass.getMsg("RECURRENCE_SATURDAY", nLanguage);
                                break;
                            default:
                                break;
                        }
                    }

                    if (!string.IsNullOrEmpty(strDayOfWeek) && strDayOfWeek.Length > 0)
                    {
                        strDayOfWeek = strDayOfWeek.Trim();
                        strDayOfWeek = strDayOfWeek.Remove(strDayOfWeek.Length - 1);
                    }

                    if (rp.Interval < 2)//每个
                    {
                        if (string.Equals(strLanguages[0].ToLower(), "en_us"))//English
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_MONTHLY", nLanguage), (MonthWeekNum)rp.Instance, strDayOfWeek);
                        }
                        else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))//russian
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_MONTHLY", nLanguage), (MonthWeekNumRU)rp.Instance, strDayOfWeek);
                        }
                        else//中文
                        {
                            if (rp.Instance > 4)//每月最后一周
                            {
                                strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_MONTHLY_LAST", nLanguage), strDayOfWeek);
                            }
                            else
                            {
                                strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_EVERY_MONTHLY", nLanguage), rp.Instance, strDayOfWeek);
                            }
                        }
                        ThisAddIn.g_log.Info(string.Format("RECURRENCE_EVERY_MONTHLY : {0}", strTemp));
                    }
                    else//每?个
                    {

                        if (string.Equals(strLanguages[0].ToLower(), "en_us"))//English
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTHLY", nLanguage), (MonthWeekNum)rp.Instance, strDayOfWeek, rp.Interval);
                        }
                        else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))//russian
                        {
                            strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTHLY", nLanguage), (MonthWeekNumRU)rp.Instance, strDayOfWeek, rp.Interval);
                        }
                        else// (string.Equals(strLanguages[0].ToLower(), "zh_cn"))//chinese
                        {
                            if (rp.Instance > 4)
                            {
                                strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTHLY_LAST", nLanguage), strDayOfWeek, rp.Interval);
                            }
                            else
                            {
                                strTemp = string.Format(GlobalResourceClass.getMsg("RECURRENCE_WITH_MONTHLY", nLanguage), rp.Instance, strDayOfWeek, rp.Interval);
                            }
                        }
                        ThisAddIn.g_log.Info(string.Format("RECURRENCE_WITH_MONTHLY : {0}", strTemp));
                    }
                }
                strNewString3 = strNewString2.Replace("{Conf_Start_Time}", strTemp);
            }
            else
            {
                strNewString3 = strNewString2;
            }

            //替换模板中的"会议结束"
            bContain = strNewString3.Contains("{Conf_End_Time}");
            string strNewString4 = "";
            if (true == bContain)
            {
                RecurrencePattern rp = ai.GetRecurrencePattern();
                DateTime dateTime = rp.PatternEndDate;

                //time zone
                Outlook.TimeZone tz = ai.StartTimeZone;

                string strRes;
                if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))//中文,2014/11/14 修改,预约过去会议与SMC保持一致
                {
                    strRes = string.Format(GlobalResourceClass.getMsg("RECURRENCE_FROM_TO", nLanguage), rp.PatternStartDate.ToShortDateString(),
                                                                                                rp.PatternEndDate.ToShortDateString(),
                                                                                                rp.StartTime.ToShortTimeString(),
                                                                                                rp.EndTime.ToShortTimeString()) + " " + ai.StartTimeZone.Name;
                }
                else//英文
                {
                    strRes = string.Format(GlobalResourceClass.getMsg("RECURRENCE_FROM_TO", nLanguage), rp.StartTime.ToShortTimeString(),
                                                                                             rp.EndTime.ToShortTimeString(),
                                                                                             rp.PatternStartDate.ToShortDateString(),
                                                                                             rp.PatternEndDate.ToShortDateString()) + " " + ai.StartTimeZone.Name;
                }

                strNewString4 = strNewString3.Replace("{Conf_End_Time}", strRes);
            }
            else
            {
                strNewString4 = strNewString3;
            }

            //替换模板中的"会议接入号"
            bContain = strNewString4.Contains("{Conf_Access_Number}");
            string strNewString5 = "";
            if (true == bContain)
            {
                if (string.IsNullOrEmpty(confInfo.siteAccessInfos[0].confAccessCode))
                {
                    strNewString5 = strNewString4.Replace("{Conf_Access_Number}", "");
                }
                else
                {
                    //2015-6-16 w00322557 有前缀则中间添加“-”分割,若无前缀,则无分隔符
                    if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strLync))
                    {
                        strNewString5 = strNewString4.Replace("{Conf_Access_Number}", confInfo.siteAccessInfos[0].confAccessCode);
                    }
                    else
                    {
                        //2014/10/10 修改,为接入码加入9000- 前缀
                        strNewString5 = strNewString4.Replace("{Conf_Access_Number}", ThisAddIn.g_AccountInfo.strLync + "-" + confInfo.siteAccessInfos[0].confAccessCode);
                    }
                }
            }
            else
            {
                strNewString5 = strNewString4;
            }

            //替换模板中的"终端会场"
            bContain = strNewString5.Contains("{Conf_Sites}");
            string strNewString6 = "";
            if (true == bContain)
            {
                string strTempSites = "";

                //2014/10/20 测试
                ConferenceInfo cInfo = (ConferenceInfo)confInfo;
                for (int i = 0; i < confInfo.siteAccessInfos.Length; i++)
                {
                    SiteAccessInfo sInfo = confInfo.siteAccessInfos[i];

                    if (sInfo.beginTime.ToLocalTime().ToShortDateString() == ai.Start.ToShortDateString())
                    {
                        if ((cInfo.sites[i].uri == sInfo.uri) && (!string.IsNullOrEmpty(sInfo.uri)))
                        {
                            strTempSites += cInfo.sites[i].name + "; ";
                        }
                    }
                }
                strNewString6 = strNewString5.Replace("{Conf_Sites}", strTempSites);
            }

            //替换模板中的"Lync一键入会"
            bContain = strNewString6.Contains("conf_lync_ctc");
            string strNewString7 = "";
            if (true == bContain)
            {
                if (true == ThisAddIn.g_SystemSettings.bLyncCTC)
                {
                    strNewString7 = strNewString6.Replace("conf_lync_ctc", "sip:" + ThisAddIn.g_AccountInfo.strLync + confInfo.siteAccessInfos[0].confAccessCode + ThisAddIn.g_AccountInfo.strMCU);
                }
                else
                {
                    strNewString7 = strNewString6.Replace("conf_lync_ctc", "");
                }
            }
            else
            {
                strNewString7 = strNewString6;
            }

            //替换模板中的"数据会议地址"
            bContain = strNewString7.Contains("conf_living_address");
            string strNewString8 = "";
            if (true == bContain)
            {
                strNewString8 = strNewString7.Replace("conf_living_address", confInfo.recorderAddr);
            }
            else
            {
                strNewString8 = strNewString7;
            }

            //替换模板中的"{Prefix_ISDN}"
            bContain = strNewString8.Contains("{Prefix_ISDN}");
            string strNewString9 = "";
            if (true == bContain)
            {
                strNewString9 = strNewString8.Replace("{Prefix_ISDN}", ThisAddIn.g_AccountInfo.strLync);
            }
            else
            {
                strNewString9 = strNewString8;
            }

            //替换模板中的"{Prefix_Cisco}"
            bContain = strNewString9.Contains("{Prefix_Cisco}");
            string strNewString10 = "";
            if (true == bContain)
            {
                //2015-6-16 w00322557 有前缀则中间添加“-”分割,若无前缀,则无分隔符
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strCisco))
                {
                    strNewString10 = strNewString9.Replace("{Prefix_Cisco}", confInfo.siteAccessInfos[0].confAccessCode);
                }
                else
                {
                    strNewString10 = strNewString9.Replace("{Prefix_Cisco}", ThisAddIn.g_AccountInfo.strCisco + "-" + confInfo.siteAccessInfos[0].confAccessCode);
                }
            }
            else
            {
                strNewString10 = strNewString9;
            }

            //
            if (string.IsNullOrEmpty(strNewString10))
            {
                ThisAddIn.g_log.Error("Recurrence template is empty.");
            }
            else
            {
                ThisAddIn.g_log.Info(string.Format("template length is: {0}", strNewString10.Length));
            }

            return strNewString10;
        }
示例#47
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ai"></param>
        /// <returns></returns>
        private ConferenceInfo GetConfInfoUserProperty(AppointmentItem ai)
        {
            //如果存在这个属性,则取出,本次为修改会议信息
            UserProperty up = ai.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing);
            if (up != null)
            {
                string strValue = up.Value;
                if (string.IsNullOrEmpty(strValue))
                {
                    return null;
                }

                ConferenceInfo confInfo = new ConferenceInfo();
                confInfo.confId = strValue;

                return confInfo;
            }
            else
            {
                return null;
            }
        }
示例#48
0
        /// <summary>
        /// 替换通知模板中的内容
        /// </summary>
        /// <param name="textTemplate">通知模板</param>
        /// <param name="confInfo">会议信息</param>  
        /// <returns>新的通知消息</returns>
        private string replaceContentsInTemplate(AppointmentItem ai, string textTemplate, ref ConferenceInfo confInfo)
        {
            //begin 替换模板中的数据
            bool bContain = textTemplate.Contains("{Recurrence_Type}");
            string[] strLanguages = ThisAddIn.g_AccountInfo.strLanguage.Split(';');
            if (true == bContain)
            {
                if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "开始时间");
                }
                else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "Время Начала");
                }
                else
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Type}", "Start Time");
                }
            }

            bContain = textTemplate.Contains("{Recurrence_Time}");
            if (true == bContain)
            {
                if (string.Equals(strLanguages[0].ToLower(), "zh_cn"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "结束时间");
                }
                else if (string.Equals(strLanguages[0].ToLower(), "ru") || string.Equals(strLanguages[0].ToLower(), "ru_ru"))
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "Время окончания");
                }
                else
                {
                    textTemplate = textTemplate.Replace("{Recurrence_Time}", "End Time");
                }
            }

            //替换模板中的"会议名称"
            bContain = textTemplate.Contains("{Conf_Subject}");
            string strNewString = "";
            if (true == bContain)
            {
                if (string.IsNullOrEmpty(ai.Subject))
                {
                    strNewString = textTemplate.Replace("{Conf_Subject}", confInfo.name);
                    ai.Subject = confInfo.name;
                }
                else
                {
                    string myEncodedString = HttpUtility.HtmlEncode(ai.Subject);
                    strNewString = textTemplate.Replace("{Conf_Subject}", myEncodedString);
                }
            }

            //替换模板中的"会议密码"
            bContain = strNewString.Contains("{Conf_Password}");
            string strNewString2 = "";
            if (true == bContain)
            {
                UserProperty up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
                if (up != null)
                {
                    strNewString2 = strNewString.Replace("{Conf_Password}", up.Value);
                }
                else
                {
                    strNewString2 = strNewString.Replace("{Conf_Password}", ThisAddIn.g_SystemSettings.strConfPWD);
                }
            }
            else
            {
                strNewString2 = strNewString;
            }

            //替换模板中的"会议开始时间"
            bContain = strNewString2.Contains("{Conf_Start_Time}");
            string strNewString3 = "";
            if (true == bContain)
            {
                strNewString3 = strNewString2.Replace("{Conf_Start_Time}", ai.Start.ToString() + "   " + ai.StartTimeZone.Name);
            }
            else
            {
                strNewString3 = strNewString2;
            }

            //替换模板中的"会议时长"
            bContain = strNewString3.Contains("{Conf_End_Time}");
            string strNewString4 = "";
            if (true == bContain)
            {
                strNewString4 = strNewString3.Replace("{Conf_End_Time}", ai.End.ToString() + "   " + ai.StartTimeZone.Name);
            }
            else
            {
                strNewString4 = strNewString3;
            }

            //替换模板中的"会议接入号"
            bContain = strNewString4.Contains("{Conf_Access_Number}");
            string strNewString5 = "";
            if (true == bContain)
            {
                if (string.IsNullOrEmpty(confInfo.accessCode))
                {
                    UserProperty upRightBeginTime = ai.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing);
                    string val = upRightBeginTime.Value;
                    List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val);
                    foreach (RecurrenceAppoint Rappoint in appointList)
                    {
                        if (Rappoint.AppointDate.Equals(ai.Start.ToShortDateString()))
                        {
                            //2015-6-16 w00322557 有前缀则中间添加“-”分割,若无前缀,则无分隔符
                            if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strLync))
                            {
                                strNewString5 = strNewString4.Replace("{Conf_Access_Number}", Rappoint.AccessCode);
                            }
                            else
                            {
                                strNewString5 = strNewString4.Replace("{Conf_Access_Number}", ThisAddIn.g_AccountInfo.strLync + "-" + Rappoint.AccessCode);
                            }

                            confInfo.accessCode = Rappoint.AccessCode;
                            break;
                        }
                    }
                }
                else
                {
                    //2015-6-16 w00322557 有前缀则中间添加“-”分割,若无前缀,则无分隔符
                    if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strLync))
                    {
                        //2014/10/10 修改,增加9000-前缀码
                        strNewString5 = strNewString4.Replace("{Conf_Access_Number}", confInfo.accessCode);
                    }
                    else
                    {
                        //2014/10/10 修改,增加9000-前缀码
                        strNewString5 = strNewString4.Replace("{Conf_Access_Number}", ThisAddIn.g_AccountInfo.strLync + "-" + confInfo.accessCode);
                    }
                }
            }
            else
            {
                strNewString5 = strNewString4;
            }

            //替换模板中的"终端会场"
            bContain = strNewString5.Contains("{Conf_Sites}");
            string strNewString6 = "";
            if (true == bContain)
            {
                string strTempSites = "";

                //2014/10/18 测试
                if (confInfo.sites != null)
                {
                    foreach (SiteInfo site in confInfo.sites)
                    {
                        if (!string.IsNullOrEmpty(site.name))
                        {
                            strTempSites += site.name + "; ";
                        }
                    }
                }
                else
                {
                    foreach (Outlook.Recipient recipient in ai.Recipients)
                    {
                        Outlook.ExchangeUser exchangeUser = recipient.AddressEntry.GetExchangeUser();
                        if (exchangeUser == null || string.IsNullOrEmpty(exchangeUser.JobTitle))
                        {
                            continue;
                        }

                        if (exchangeUser.JobTitle.Equals("VideoRoom"))
                        {
                            strTempSites += recipient.Name + "; ";
                        }
                    }
                }

                strNewString6 = strNewString5.Replace("{Conf_Sites}", strTempSites);
            }

            //替换模板中的"Lync一键入会"
            bContain = strNewString6.Contains("conf_lync_ctc");
            string strNewString7 = "";
            if (true == bContain)
            {
                if (true == ThisAddIn.g_SystemSettings.bLyncCTC)
                {
                    strNewString7 = strNewString6.Replace("conf_lync_ctc", "sip:" + ThisAddIn.g_AccountInfo.strLync + confInfo.accessCode + ThisAddIn.g_AccountInfo.strMCU);
                }
                else
                {
                    strNewString7 = strNewString6.Replace("conf_lync_ctc", "");
                }
            }
            else
            {
                strNewString7 = strNewString6;
            }

            //替换模板中的"数据会议地址"
            bContain = strNewString7.Contains("conf_living_address");
            string strNewString8 = "";
            if (true == bContain)
            {
                strNewString8 = strNewString7.Replace("conf_living_address", confInfo.recorderAddr);
            }
            else
            {
                strNewString8 = strNewString7;
            }

            //替换模板中的"{Prefix_ISDN}"
            bContain = strNewString8.Contains("{Prefix_ISDN}");
            string strNewString9 = "";
            if (true == bContain)
            {
                strNewString9 = strNewString8.Replace("{Prefix_ISDN}", ThisAddIn.g_AccountInfo.strLync);
            }
            else
            {
                strNewString9 = strNewString8;
            }

            //替换模板中的"{Prefix_Cisco}"
            bContain = strNewString9.Contains("{Prefix_Cisco}");
            string strNewString10 = "";
            if (true == bContain)
            {
                //2015-6-16 w00322557 有前缀则中间添加“-”分割,若无前缀,则无分隔符
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strCisco))
                {
                    strNewString10 = strNewString9.Replace("{Prefix_Cisco}", confInfo.accessCode);
                }
                else
                {
                    strNewString10 = strNewString9.Replace("{Prefix_Cisco}", ThisAddIn.g_AccountInfo.strCisco + "-" + confInfo.accessCode);
                }

            }
            else
            {
                strNewString10 = strNewString9;
            }

            //
            if (string.IsNullOrEmpty(strNewString10))
            {
                ThisAddIn.g_log.Error("Single template is empty.");
            }
            else
            {
                ThisAddIn.g_log.Info(string.Format("template length is: {0}", strNewString10.Length));
            }

            return strNewString10;
        }
示例#49
0
        /// <summary>
        /// 修改周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int editRecurrenceTPConf(AppointmentItem ai, ref RecurrenceConfInfo ConfInfo, MeetingItem meetingItem)
        {
            ThisAddIn.g_log.Info("editRecurrenceTPConf enter");
            Inspector ins = ai.GetInspector;

            string accessCode = null;
            List<SiteInfo> siteInfos = new List<SiteInfo>();

            //编辑周期会议中单个子会议
            DateTime? date = null;
            if (OlRecurrenceState.olApptException == ai.RecurrenceState || OlRecurrenceState.olApptOccurrence == ai.RecurrenceState)
            {

                UserProperty upRightBeginTime = ai.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing);
                string val = upRightBeginTime.Value;

                List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val);
                foreach (RecurrenceAppoint Rappoint in appointList)
                {
                    if (Rappoint.AppointDate.Equals(ai.Start.ToShortDateString()))
                    {
                        string s = string.Format("{0} {1}", Rappoint.AppointDate, Rappoint.AppointTime);
                        date = DateTime.Parse(s).ToUniversalTime();
                        break;
                    }
                }

                if (date == null)//证明修改了时间
                {
                    return ERROR_CODE_CHANGE_DATE;
                }

                setRecurrenceConferenceInfo(ref ConfInfo, ai, true);

            }
            else
            {
                setRecurrenceConferenceInfo(ref ConfInfo, ai, false);
            }

            TPOASDKResponse<RecurrenceConfInfo> responseRecurrence = null;
            int resultCode = -1;

            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                responseRecurrence = conferenceServiceEx.editRecurrenceConference(ConfInfo, date);

                //已关联
                resultCode = responseRecurrence.resultCode;

            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf exception with: {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                //预约成功,将返回的会议信息作为属性保存
                if (string.IsNullOrEmpty(ai.Subject))
                {
                    ai.Subject = ConfInfo.name;
                }

                ConferenceInfo confInfo = null;

                if (responseRecurrence != null)
                {
                    //预约成功,将返回的confId作为属性保存
                    RecurrenceConfInfo retConfInfo = responseRecurrence.result;

                    //2014/10/21 测试
                    confInfo = (ConferenceInfo)retConfInfo;

                    //2014/10/14 新增测试
                    List<RecurrenceAppoint> retConfInfoArray = new List<RecurrenceAppoint>();
                    ArrayList tempCon = new ArrayList();
                    try
                    {
                        RecurrenceAppoint appo = null;
                        for (int i = 0; i < retConfInfo.siteAccessInfos.Length; i++)
                        {
                            DateTime time = retConfInfo.siteAccessInfos[i].beginTime.ToLocalTime();

                            if (!tempCon.Contains(time))
                            {
                                tempCon.Add(time);
                                appo = new RecurrenceAppoint();
                                appo.AppointDate = time.ToShortDateString();
                                appo.AppointTime = time.ToLongTimeString();
                                appo.AccessCode = retConfInfo.siteAccessInfos[i].confAccessCode;

                                //2015-6-17 w00322557 保存会场
                                appo.AppointSites = retConfInfo.sites[i].name + ",";
                                retConfInfoArray.Add(appo);
                            }
                            else
                            {
                                appo.AppointSites += retConfInfo.sites[i].name + ",";
                            }

                            ThisAddIn.g_log.Info(string.Format("Edit RecurrenceAppoint sites name: {0}", retConfInfo.sites[i].name));

                            //保存当天会议的接入码
                            if (time.ToString("yyyy-MM-dd HH:mm") == ai.Start.ToString("yyyy-MM-dd HH:mm"))
                            {
                                accessCode = retConfInfo.siteAccessInfos[i].confAccessCode;
                                SiteInfo info = new SiteInfo();
                                //info.name = retConfInfo.siteAccessInfos[i].uri;
                                //siteInfos.Add(info);
                                //2014/10/21 测试
                                info.name = confInfo.sites[i].name;
                                siteInfos.Add(info);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf exception: {0}", ex.Message));
                    }

                    //SaveRecurrenceReturnUserProperties(retConfInfo, ai,retConfInfoArray);

                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        //2014/10/16 测试
                        string strNotify;
                        if (OlRecurrenceState.olApptException == ai.RecurrenceState)//证明修改的是周期会议的子会议
                        {
                            //传接入码
                            confInfo.accessCode = accessCode;

                            //传会场
                            SiteInfo[] infos = siteInfos.ToArray();
                            confInfo.sites = infos;
                            strNotify = this.replaceContentsInTemplate(ai, textTemplate, ref confInfo);
                            SaveRecuConfReturnUserProperties(retConfInfo, ai, retConfInfoArray);
                        }
                        else
                        {
                            SaveRecurrenceReturnUserProperties(retConfInfo, ai, retConfInfoArray);
                            strNotify = this.replaceContentsInTemplateRecurrence(ai, textTemplate, ref retConfInfo);
                        }

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("edit recurrence paste enter");
                        objDoc.Range().WholeStory();

                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }

                        ThisAddIn.g_log.Info("edit recurrence paste end");
                    }
                }
                SendRecipientsInfo(ai, meetingItem);
                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_MODIFY"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
            }
            else
            {
                //返回错误码,计入日志
                ThisAddIn.g_log.Error(string.Format("editRecurrenceTPConf return: {0}", responseRecurrence.resultCode.ToString()));
            }

            ThisAddIn.g_log.Info("editRecurrenceTPConf exit");
            return resultCode;
        }
示例#50
0
        /// <summary>
        /// 根据格式,获取会议时长
        /// </summary>
        /// <returns>会议时长</returns>
        private string getConfLasts(AppointmentItem item)
        {
            TimeSpan span = item.End - item.Start;
            if (span.Days > 0)
            {
                return String.Format("{0}{1}{2}{3}{4}{5}", span.Days, GlobalResourceClass.getMsg("DAY"), span.Hours, GlobalResourceClass.getMsg("HOUR"), span.Minutes, GlobalResourceClass.getMsg("MINUTE"));
            }

            if (span.Hours > 0)
            {
                return String.Format("{0}{1}{2}{3}", span.Hours, GlobalResourceClass.getMsg("HOUR"), span.Minutes, GlobalResourceClass.getMsg("MINUTE"));
            }

            return String.Format("{0}{1}", span.Minutes, GlobalResourceClass.getMsg("MINUTE"));
        }
示例#51
0
        /// <summary>
        /// 删除周期会议的子会议
        /// </summary>
        /// <param name="tempAppt"></param>
        /// <param name="recipients"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        private int DeleteConferenceWithTime(AppointmentItem tempAppt, Recipients recipients, DateTime date)
        {
            ThisAddIn.g_log.Info(string.Format("Delete Conference ,Time is {0}", date.ToString()));

            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date.ToUniversalTime());
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("DeleteConferenceWithTime exception: {0}", ex.Message));
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf result code:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        ConferenceInfo cInfo = new ConferenceInfo();
                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single recurrence paste enter");
                        objDoc.Range().WholeStory();

                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }

                        ThisAddIn.g_log.Info("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
示例#52
0
        /// <summary>
        /// 修改非周期性智真会议
        /// </summary>
        /// <returns>native接口返回值</returns>
        private int editTPConf(AppointmentItem ai, ref ConferenceInfo ConfInfo, MeetingItem meetingItem)
        {
            ThisAddIn.g_log.Info("editTPConf enter");
            Inspector ins = ai.GetInspector;

            setConferenceInfo(ref ConfInfo, ai);
            ConfInfo.accessCode = string.Empty;

            TPOASDKResponse<ConferenceInfo> response = null;
            int resultCode = -1;
            //非周期性会议
            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                response = conferenceServiceEx.editScheduledConf(ConfInfo);
                resultCode = response.resultCode;
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(string.Format("editScheduledConf exception because :{0} ", ex.Message));

                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                if (string.IsNullOrEmpty(ai.Subject))
                {
                    ai.Subject = ConfInfo.name;
                }
                //修改成功,将返回的confId作为属性保存
                if (response != null)//第一次执行的
                {
                    ConferenceInfo retConfInfo = response.result;
                    SaveReturnUserProperties(retConfInfo, ai);

                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = ins.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        //读入会议通知模板数据
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));
                        string strNotify = this.replaceContentsInTemplate(ai, textTemplate, ref retConfInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("edit TP paste enter");
                        objDoc.Range().WholeStory();
                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }
                        ThisAddIn.g_log.Info("edit TP paste end");
                    }
                }
                SendRecipientsInfo(ai, meetingItem);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_MODIFY"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);

            }
            else
            {
                //2014-5-13 返回码映射
                ThisAddIn.g_log.Error(string.Format("editTPConf failed with error code: {0}", response.resultCode.ToString()));
            }

            ThisAddIn.g_log.Info("editTPConf exit");
            return resultCode;
        }
示例#53
0
        /// <summary>
        /// 创建预约会议
        /// </summary>
        /// <param name="tempAppt">相应的AppointmentItem</param>
        private int CreateConference(AppointmentItem tempAppt, MeetingItem meetingItem)
        {
            int nResult = PARAM_ERROR;
            //2014-8-21 wangpai 预约智真会议的
            Outlook.UserProperty property = tempAppt.UserProperties.Find(ThisAddIn.PROPERTY_ENTER_FROM_SELF, Type.Missing);
            if (property != null)
            {
                property.Value = true;
            }
            else
            {
                property = tempAppt.UserProperties.Add(ThisAddIn.PROPERTY_ENTER_FROM_SELF, OlUserPropertyType.olYesNo, Type.Missing, Type.Missing);
                property.Value = true;
            }

            if (true == tempAppt.IsRecurring)
            {
                nResult = this.scheduleRecurrenceTPConf(ref tempAppt);
            }
            else
            {
                nResult = this.scheduleTPConf(tempAppt);
            }

            return nResult;
        }
示例#54
0
        /// <summary>
        /// 修改预约会议
        /// </summary>
        /// <param name="tempAppt">相应的AppointmentItem</param>
        /// <param name="tempAppt">相应的MeetingItem,主要用于获取MeetingItem的人员</param>
        private int EditConference(ref AppointmentItem tempAppt, MeetingItem tempMeet)
        {
            ThisAddIn.g_log.Info("EditConference enter");
            int nResult = PARAM_ERROR;
            UserProperty upConfInfo = tempAppt.UserProperties.Find(PROPERTY_NAME_CONF_INFO, Type.Missing);
            string strContent = upConfInfo.Value;
            if (string.IsNullOrEmpty(strContent))
            {
                ThisAddIn.g_log.Error("ConfInfo UserProperty is empty!");
                return nResult;
            }

            //修改会议
            if (true == tempAppt.IsRecurring)
            {
                //获取ConferenceInfo属性
                RecurrenceConfInfo recurrenceConfInfo = new RecurrenceConfInfo();
                recurrenceConfInfo.confId = strContent;
                nResult = this.editRecurrenceTPConf(tempAppt, ref recurrenceConfInfo, tempMeet);
            }
            else
            {
                ConferenceInfo confInfo = this.GetConfInfoUserProperty(tempAppt);
                nResult = this.editTPConf(tempAppt, ref confInfo, tempMeet);
            }

            //2015-3-20 w00322557 智真或lync会场个数小于2,直接透传产品错误码信息

            ThisAddIn.g_log.Info(string.Format("EditConference exit with {0}", nResult));
            return nResult;
        }
示例#55
0
        private void CopyBody(AppointmentItem ai, MailItem mailItem)
        {
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MailItem enter");
            Word.Document Doc = new Word.Document();
            Word.Document Doc2 = new Word.Document();
            Word.Application App1;
            Word.Selection Sel;
            Doc = ai.GetInspector.WordEditor as Word.Document;
            Word.Application App2;
            Word.Selection Sel2;

            if (Doc != null)
            {
                ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length));
                Doc.Activate();
                Doc.Select();
                App1 = Doc.Windows.Application;
                Sel = App1.Selection;
                Sel.WholeStory();
                Sel.Copy();

                Doc2 = mailItem.GetInspector.WordEditor as Word.Document;
                if (Doc2 != null)
                {
                    Doc2.Activate();
                    Doc2.Select();
                    App2 = Doc2.Windows.Application;
                    Sel2 = App2.Selection;
                    Sel2.WholeStory();

                    try
                    {
                        Sel2.PasteAndFormat(WdRecoveryType.wdPasteDefault);
                    }
                    catch (System.Exception ex)
                    {
                        ThisAddIn.g_log.Error(string.Format("copy to body exception, {0}", ex.ToString()));
                    }

                    mailItem.Save();
                    ThisAddIn.g_log.Info(string.Format("mailItem doc length is {0}.", Doc2.Content.Text.Length));

                    if (mailItem.Body == null || mailItem.Body.Length < 100)
                    {
                        Doc2.Activate();
                        ((_Inspector)(mailItem.GetInspector)).Activate();
                    }
                }
            }

            Doc = null;
            Doc2 = null;
            App1 = null;
            App2 = null;
            Sel = null;
            Sel2 = null;
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MailItem exit");
        }
示例#56
0
        /// <summary>
        /// 删除预约会议
        /// </summary>
        /// <param name="tempAppt">相应的AppointmentItem</param>
        private int DeleteConference(AppointmentItem tempAppt, Recipients recipients)
        {
            int resultCode = PARAM_ERROR;
            object confInfo = null;
            string confId = "";
            DateTime? date = null;

            confInfo = this.GetConfInfoUserProperty(tempAppt);
            if (null == confInfo)
            {
                return PARAM_ERROR;
            }
            confId = ((ConferenceInfo)confInfo).confId;

            //获取已预约的会议信息
            //2015-5-25 w00322557 账号传入“eSDK账号,Outlook邮箱账号”
            //string strAccountName = ThisAddIn.g_AccountInfo.strUserName;
            Outlook.ExchangeUser mainUser = Globals.ThisAddIn.Application.Session.CurrentUser.AddressEntry.GetExchangeUser();
            string strOutlookAccount = string.Empty;
            if (mainUser != null)
            {
                strOutlookAccount = mainUser.PrimarySmtpAddress;
            }

            string strAccountName = string.Format("{0},{1}", ThisAddIn.g_AccountInfo.strUserName, strOutlookAccount);
            string strAccountPWD = ThisAddIn.g_AccountInfo.strPWD;
            string strServerAddress = ThisAddIn.g_AccountInfo.strServer;

            ThisAddIn.g_log.Debug(string.Format("Account is: {0}", strAccountName));
            ThisAddIn.g_log.Debug("PWD is: ******");
            ThisAddIn.g_log.Debug(string.Format("Server is: {0}", strServerAddress));

            if (OlRecurrenceState.olApptException == tempAppt.RecurrenceState)//删除单个
            {
                date = tempAppt.Start.ToUniversalTime();
            }

            try
            {
                //密码不存在,返回
                if (string.IsNullOrEmpty(ThisAddIn.g_AccountInfo.strPWD))
                {
                    ThisAddIn.g_log.Info("pwd is null");
                    MessageBox.Show(GlobalResourceClass.getMsg("INPUT_OUTLOOK_PASSWORD"));
                }

                ConferenceMgrService conferenceServiceEx = ConferenceMgrService.Instance(strAccountName, strAccountPWD, strServerAddress);
                resultCode = conferenceServiceEx.delScheduledConf(confId, date);
            }
            catch (System.Exception ex)
            {
                ThisAddIn.g_log.Error(ex.Message);
                return PARAM_ERROR;
            }

            if (0 == resultCode)
            {
                ThisAddIn.g_log.Info(String.Format("delScheduledConf date: {0}", date.ToString()));
                ThisAddIn.g_log.Info(String.Format("delScheduledConf success:{0:D}", resultCode));

                //2014/10/18 测试
                if (date != null)//删除单个子会议,修改模板
                {
                    //HTML模板
                    Microsoft.Office.Interop.Word.Document objDoc = tempAppt.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
                    if (null != objDoc)
                    {
                        string strFilePath = string.Empty;
                        strFilePath = SetNotificationLanguage(GetNotificationCurrentLanguage(ThisAddIn.g_AccountInfo.strLanguage));

                        if (!File.Exists(strFilePath))
                        {
                            ThisAddIn.g_log.Error("notification file path not exist.");
                            return PARAM_ERROR;
                        }

                        //读取会议邮件通知模板内容
                        string textTemplate = System.IO.File.ReadAllText(strFilePath, Encoding.GetEncoding("utf-8"));

                        ConferenceInfo cInfo = new ConferenceInfo();

                        //2015-6-17 w00322557 增加解析会场
                        try
                        {
                            UserProperty upRightBeginTime = tempAppt.UserProperties.Find(PROPERTY_RIGHT_BEGIN_TIME, Type.Missing);
                            if (upRightBeginTime != null)
                            {
                                string val = upRightBeginTime.Value;

                                List<RecurrenceAppoint> appointList = XmlHelper.Desrialize<List<RecurrenceAppoint>>(val);
                                foreach (RecurrenceAppoint Rappoint in appointList)
                                {

                                    if (Rappoint.AppointDate.Equals(date.Value.ToLocalTime().ToShortDateString()) &&
                                        Rappoint.AppointTime.Equals(date.Value.ToLocalTime().ToLongTimeString()))
                                    {
                                        string sSites = Rappoint.AppointSites.TrimEnd(',');
                                        string[] varSites = sSites.Split(',');
                                        cInfo.sites = new SiteInfo[varSites.Length];
                                        int iCount = 0;
                                        foreach (string sSite in varSites)
                                        {
                                            SiteInfo site = new SiteInfo();
                                            site.name = sSite;
                                            cInfo.sites[iCount] = site;
                                            iCount++;
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(string.Format("Parse site error with: {0}", ex.Message));
                        }

                        string strNotify = replaceContentsInTemplate(tempAppt, textTemplate, ref cInfo);

                        //将会议通知模板数据拷贝/粘贴到文档中
                        Clipboard.Clear();
                        VideoConfSettingsForm.CopyHtmlToClipBoard(strNotify);
                        object html = Clipboard.GetData(DataFormats.Html);

                        ThisAddIn.g_log.Info("delete single recurrence paste enter");
                        objDoc.Range().WholeStory();

                        try
                        {
                            objDoc.Range().PasteAndFormat(WdRecoveryType.wdPasteDefault);
                        }
                        catch (System.Exception ex)
                        {
                            ThisAddIn.g_log.Error(ex.Message);
                        }

                        ThisAddIn.g_log.Info("delete single recurrence paste end");
                    }
                }
                if (recipients == null)
                {
                    recipients = tempAppt.Recipients;
                }

                sendMailNotifications(tempAppt, OperatorType.Cancel, recipients);

                MessageBoxTimeOut mes = new MessageBoxTimeOut();
                string messageBody = string.Format(GlobalResourceClass.getMsg("OPERATOR_MESSAGE"), GlobalResourceClass.getMsg("OPERATOR_TYPE_CANCEL"));
                mes.Show(messageBody, GlobalResourceClass.getMsg("OPERATOR_SUCCESS"), 3000);
                return 0;
            }
            else
            {
                ThisAddIn.g_log.Error(String.Format("delScheduledConf failed:{0:D}", resultCode));
                return resultCode;
            }
        }
示例#57
0
        private bool CompareUserProperty(BackUpAppointment bak_appointment, AppointmentItem ai)
        {
            //保存智真会议属性
            BackUpAppointment bak_Property = new BackUpAppointment();

            UserProperty up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
            bak_Property.bak_confPwd = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            bak_Property.bak_videoCount = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            bak_Property.bak_voiceCount = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_IS_RECORDING, Type.Missing);
            bak_Property.bak_record = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_IS_LIVING, Type.Missing);
            bak_Property.bak_liveBoradcast = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_SITE_RATE, Type.Missing);
            bak_Property.bak_siteRate = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_SECURITY_LEVEL, Type.Missing);
            bak_Property.bak_securityLevel = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_BILL_CODE, Type.Missing);
            bak_Property.bak_billCode = up.Value;

            up = ai.UserProperties.Find(ThisAddIn.PROPERTY_CPRESOURCE, Type.Missing);
            bak_Property.bak_cpResource = up.Value.ToString();

            if (bak_appointment.bak_confPwd == bak_Property.bak_confPwd && bak_appointment.bak_videoCount == bak_Property.bak_videoCount &&
               bak_appointment.bak_voiceCount == bak_Property.bak_voiceCount && bak_appointment.bak_record == bak_Property.bak_record &&
               bak_appointment.bak_liveBoradcast == bak_Property.bak_liveBoradcast && bak_appointment.bak_siteRate == bak_Property.bak_siteRate &&
               bak_appointment.bak_securityLevel == bak_Property.bak_securityLevel && bak_appointment.bak_billCode == bak_Property.bak_billCode &&
               bak_appointment.bak_cpResource == bak_Property.bak_cpResource)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
示例#58
0
        private void CopyBodyToMeeting(AppointmentItem ai, ref MeetingItem meetingItem)
        {
            ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem enter");
            Word.Document Doc = new Word.Document();
            Word.Document Doc2 = new Word.Document();
            Word.Application App1;
            Word.Selection Sel;

            Doc = ai.GetInspector.WordEditor as Word.Document;

            if (Doc != null)
            {
                ThisAddIn.g_log.Info(string.Format("appointmentItem doc length is {0}.", Doc.Content.Text.Length));
                Doc.Activate();
                Doc.Select();
                App1 = Doc.Windows.Application;
                Sel = App1.Selection;
                Sel.WholeStory();
                Sel.Copy();

                Doc2 = meetingItem.GetInspector.WordEditor as Word.Document;
                if (Doc2 != null)
                {
                    Doc2.Activate();
                    object start = 0;
                    Range newRang = Doc2.Range(ref start, ref start);

                    int ioo = Doc2.Sections.Count;
                    Section sec = Doc2.Sections[1];

                    sec.Range.InsertBreak(Type.Missing);//插入换行符
                    sec.Range.PasteAndFormat(WdRecoveryType.wdPasteDefault);

                    meetingItem.Save();
                    ThisAddIn.g_log.Info(string.Format("meetingItem doc length is {0}.", Doc2.Content.Text.Length));
                    //ThisAddIn.g_log.Info(string.Format("mailItem body length is {0}.", meetingItem.Body.Length));

                    if (meetingItem.Body == null || meetingItem.Body.Length < 100)
                    {
                        Doc2.Activate();
                        ((_Inspector)(meetingItem.GetInspector)).Activate();
                    }
                }
            }
            Doc = null;
            Doc2 = null;
            App1 = null;
            Sel = null;

            ThisAddIn.g_log.Info("Copy AppointmentItem body to MeetingItem exit");
        }
示例#59
0
        /// <summary>
        /// 比较用户,判断是修改还是删除
        /// </summary>
        /// <param name="appItem"></param>
        /// <param name="mItem"></param>
        /// <returns>true 是删除会议,false 是修改会议</returns>
        private bool CompareRecipient(AppointmentItem appItem, MeetingItem mItem)
        {
            List<string> meetRecps = new List<string>();
            foreach (Recipient recp in mItem.Recipients)
            {
                meetRecps.Add(recp.Name);
            }

            foreach (Recipient recp in appItem.Recipients)
            {
                if (!meetRecps.Contains(recp.Name))
                {
                    if (recp.Index == 1 && loginRecipient != null && recp.Name == loginRecipient.Name)
                    {
                        continue;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return true;
        }
示例#60
0
        /// <summary>
        /// 保存打开的约会信息 2014/11/6 
        /// </summary>
        /// <param name="item">需要保存的约会</param>
        private BackUpAppointment copyAppointMentItem(AppointmentItem item)
        {
            string attendences = item.RequiredAttendees;
            try
            {
                if (attendences != null && attendences.IndexOf(";") > 0)
                {
                    attendences = attendences.Substring(attendences.IndexOf(";") + 1);
                }
                else
                {
                    attendences = "";
                }
            }
            catch (System.Exception ex)
            {
                attendences = "";
                ThisAddIn.g_log.Error(string.Format("new inspector error: {0}", ex.Message));
            }

            BackUpAppointment bak_app = BackUpAppointment.backUp(item.Subject, item.Start, item.End, item.Location, item.Resources, attendences, item.Body);
            bak_app.IsRecurring = item.IsRecurring;

            //2014/11/10  备份周期会议的会议属性
            if (item.IsRecurring)
            {
                BackUpRecurrencePattern bakRecurrence = new BackUpRecurrencePattern();
                bak_app.bak_recurrencePattern = bakRecurrence.backUpRePattern(item.GetRecurrencePattern());
            }

            UserProperty up = item.UserProperties.Find(ThisAddIn.PROPERTY_CONFERENCE_PASSWORD, Type.Missing);
            if (up != null)
            {
                bak_app.bak_confPwd = up.Value;
            }
            else
            {
                bak_app.bak_confPwd = ThisAddIn.g_SystemSettings.strConfPWD;
            }

            up = item.UserProperties.Find(ThisAddIn.PROPERTY_VIDEO_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                bak_app.bak_videoCount = up.Value;
            }
            else
            {
                bak_app.bak_videoCount = ThisAddIn.g_SystemSettings.nVideoSitesCount;
            }

            up = item.UserProperties.Find(ThisAddIn.PROPERTY_VOICE_SITES_COUNT, Type.Missing);
            if (up != null)
            {
                bak_app.bak_voiceCount = up.Value;
            }
            else
            {
                bak_app.bak_voiceCount = ThisAddIn.g_SystemSettings.nVoiceSitesCount;
            }

            //is recording
            up = item.UserProperties.Find(ThisAddIn.PROPERTY_IS_RECORDING, Type.Missing);
            if (up != null)
            {
                bak_app.bak_record = up.Value;
            }
            else
            {
                bak_app.bak_record = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nRecording);
            }

            //is living
            up = item.UserProperties.Find(ThisAddIn.PROPERTY_IS_LIVING, Type.Missing);
            if (up != null)
            {
                bak_app.bak_liveBoradcast = up.Value;
            }
            else
            {
                bak_app.bak_liveBoradcast = Convert.ToBoolean(ThisAddIn.g_SystemSettings.nLiving);
            }

            //site rate
            up = item.UserProperties.Find(ThisAddIn.PROPERTY_SITE_RATE, Type.Missing);
            if (up != null)
            {
                bak_app.bak_siteRate = up.Value;
            }
            else
            {
                bak_app.bak_siteRate = ThisAddIn.g_SystemSettings.strSiteRate;
            }

            up = item.UserProperties.Find(ThisAddIn.PROPERTY_SECURITY_LEVEL, Type.Missing);
            if (up != null)
            {
                bak_app.bak_securityLevel = up.Value;
            }
            else
            {
                bak_app.bak_securityLevel = ThisAddIn.g_SystemSettings.nMediaEncryptType;
            }

            up = item.UserProperties.Find(ThisAddIn.PROPERTY_BILL_CODE, Type.Missing);
            if (up != null)
            {
                bak_app.bak_billCode = up.Value;
            }
            else
            {
                bak_app.bak_billCode = ThisAddIn.g_SystemSettings.strBillCode;
            }

            up = item.UserProperties.Find(ThisAddIn.PROPERTY_CPRESOURCE, Type.Missing);
            if (up != null)
            {
                bak_app.bak_cpResource = string.Format("{0}", up.Value);
            }
            else
            {
                bak_app.bak_cpResource = string.Format("{0}", ThisAddIn.g_SystemSettings.nCPResource);
            }
            return bak_app;
        }