当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Outlook.GetRecurrencePattern方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Outlook.GetRecurrencePattern方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Outlook.GetRecurrencePattern方法的具体用法?C# Microsoft.Office.Interop.Outlook.GetRecurrencePattern怎么用?C# Microsoft.Office.Interop.Outlook.GetRecurrencePattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Outlook的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Outlook.GetRecurrencePattern方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateRecurrenceExceptions

        public static bool UpdateRecurrenceExceptions(List<Event> googleRecurrenceExceptions, Outlook.AppointmentItem slave, Synchronizer sync)
        {
            bool ret = false;

            for (int i = 0; i < googleRecurrenceExceptions.Count; i++)
            {
                Event googleRecurrenceException = googleRecurrenceExceptions[i];
                //if (slave == null || !slave.IsRecurring || slave.RecurrenceState != Outlook.OlRecurrenceState.olApptMaster)
                //    Logger.Log("Google Appointment with OriginalEvent found, but Outlook is not recurring: " + googleAppointment.Summary + " - " + GetTime(googleAppointment), EventType.Warning);
                //else
                //{
                Outlook.AppointmentItem outlookRecurrenceException = null;
                try
                {
                    var slaveRecurrence = slave.GetRecurrencePattern();
                    if (googleRecurrenceException.OriginalStartTime != null && !string.IsNullOrEmpty(googleRecurrenceException.OriginalStartTime.Date))
                        outlookRecurrenceException = slaveRecurrence.GetOccurrence(DateTime.Parse(googleRecurrenceException.OriginalStartTime.Date));
                    else if (googleRecurrenceException.OriginalStartTime != null && googleRecurrenceException.OriginalStartTime.DateTime != null)
                        outlookRecurrenceException = slaveRecurrence.GetOccurrence(googleRecurrenceException.OriginalStartTime.DateTime.Value);
                }
                catch (Exception ignored)
                {
                    Logger.Log("Google Appointment with OriginalEvent found, but Outlook occurrence not found: " + googleRecurrenceException.Summary + " - " + googleRecurrenceException.OriginalStartTime.DateTime + ": " + ignored, EventType.Debug);
                }

                if (outlookRecurrenceException != null)
                {
                    //myInstance.Subject = googleAppointment.Summary;
                    //myInstance.Start = googleAppointment.Times[0].StartTime;
                    //myInstance.End = googleAppointment.Times[0].EndTime;
                    DateTime? timeMin = null;
                    DateTime? timeMax = null;
                    if (googleRecurrenceException.Start != null && !string.IsNullOrEmpty(googleRecurrenceException.Start.Date))
                        timeMin = DateTime.Parse(googleRecurrenceException.Start.Date);
                    else if (googleRecurrenceException.Start != null)
                        timeMin = googleRecurrenceException.Start.DateTime;

                    if (googleRecurrenceException.End != null && !string.IsNullOrEmpty(googleRecurrenceException.End.Date))
                        timeMax = DateTime.Parse(googleRecurrenceException.End.Date);
                    else if (googleRecurrenceException.End != null)
                        timeMax = googleRecurrenceException.End.DateTime;

                    googleRecurrenceException = sync.LoadGoogleAppointments(googleRecurrenceException.Id, 0, 0, timeMin, timeMax); //Reload, just in case it was updated by master recurrence
                    if (googleRecurrenceException != null)
                    {
                        if (googleRecurrenceException.Status.Equals("cancelled"))
                        {
                            outlookRecurrenceException.Delete();
                            string timeToLog = null;
                            if (googleRecurrenceException.OriginalStartTime != null)
                            {
                                timeToLog = googleRecurrenceException.OriginalStartTime.Date;
                                if (string.IsNullOrEmpty(timeToLog) && googleRecurrenceException.OriginalStartTime.DateTime != null)
                                timeToLog =  googleRecurrenceException.OriginalStartTime.DateTime.Value.ToString();
                            }

                            Logger.Log("Deleted obsolete recurrence exception from Outlook: " + slave.Subject + " - " + timeToLog, EventType.Information);
                        }
                        else
                        {
                            if (sync.UpdateAppointment(ref googleRecurrenceException, outlookRecurrenceException, null))
                            {
                                outlookRecurrenceException.Save();
                                Logger.Log("Updated recurrence exception from Google to Outlook: " + googleRecurrenceException.Summary + " - " + Synchronizer.GetTime(googleRecurrenceException), EventType.Information);
                            }
                        }
                        ret = true;

                    }
                    else
                        Logger.Log("Error updating recurrence exception from Google to Outlook (couldn't be reload from Google): " + outlookRecurrenceException.Subject + " - " + outlookRecurrenceException.Start, EventType.Information);

                }

                //}

            }

            return ret;
        }
开发者ID:kcarnold,项目名称:googlesyncmod,代码行数:80,代码来源:AppointmentSync.cs

示例2: UpdateRecurrence

        /// <summary>
        /// Update Recurrence pattern from Google by parsing the string, see also specification http://tools.ietf.org/html/rfc2445
        /// </summary>
        /// <param name="master"></param>
        /// <param name="slave"></param>
        public static void UpdateRecurrence(Event master, Outlook.AppointmentItem slave)
        {
            var masterRecurrence = master.Recurrence;
            if (masterRecurrence == null)
            {
                if (slave.IsRecurring && slave.RecurrenceState == Outlook.OlRecurrenceState.olApptMaster)
                    slave.ClearRecurrencePattern();

                return;
            }

            try
            {

                 Outlook.RecurrencePattern slaveRecurrence = slave.GetRecurrencePattern();

                 if (master.Start != null && !string.IsNullOrEmpty(master.Start.Date))
                 {
                     slaveRecurrence.StartTime = DateTime.Parse(master.Start.Date);
                     slaveRecurrence.PatternStartDate = DateTime.Parse(master.Start.Date);
                 }
                 else if (master.Start != null && master.Start.DateTime != null)
                 {
                     slaveRecurrence.StartTime = master.Start.DateTime.Value;
                     slaveRecurrence.PatternStartDate = master.Start.DateTime.Value;
                 }

                //string[] patterns = masterRecurrence.Value.Split(new char[] {'\r','\n'}, StringSplitOptions.RemoveEmptyEntries);
                //foreach (string pattern in patterns)
                //{
                //    if (pattern.StartsWith(DTSTART))
                //    {
                //        //DTSTART;VALUE=DATE:20070501
                //        //DTSTART;TZID=US-Eastern:19970905T090000
                //        string[] parts = pattern.Split(new char[] {';',':'});

                //        slaveRecurrence.StartTime = GetDateTime(parts[parts.Length-1]);
                //        slaveRecurrence.PatternStartDate = GetDateTime(parts[parts.Length - 1]);
                //        break;
                //    }
                //}

                if (master.End != null && !string.IsNullOrEmpty(master.End.Date))
                     slaveRecurrence.EndTime = DateTime.Parse(master.End.Date);
                 if (master.End != null && master.End.DateTime != null)
                     slaveRecurrence.EndTime = master.End.DateTime.Value;

                //foreach (string pattern in patterns)
                //{
                //    if (pattern.StartsWith(DTEND))
                //    {
                //        string[] parts = pattern.Split(new char[] { ';', ':' });

                //        slaveRecurrence.EndTime = GetDateTime(parts[parts.Length-1]);
                //        //Don't update, otherwise it will end after first occurrence: slaveRecurrence.PatternEndDate = GetDateTime(parts[parts.Length - 1]);

                //        break;
                //    }
                //}

                foreach (string pattern in master.Recurrence)
                {
                    if (pattern.StartsWith(RRULE))
                    {
                        string[] parts = pattern.Split(new char[] { ';', ':' });

                        int instance = 0;
                        foreach (string part in parts)
                        {
                            if (part.StartsWith(BYDAY))
                            {
                                string[] days = part.Split(',');
                                foreach (string day in days)
                                {
                                    string dayValue = day.Substring(day.IndexOf("=") + 1);
                                    if (dayValue.StartsWith("1"))
                                        instance = 1;
                                    else if (dayValue.StartsWith("2"))
                                        instance = 2;
                                    else if (dayValue.StartsWith("3"))
                                        instance = 3;
                                    else if (dayValue.StartsWith("4"))
                                        instance = 4;

                                    break;
                                }

                                break;
                            }

                        }

                        foreach (string part in parts)
                        {

//.........这里部分代码省略.........
开发者ID:kcarnold,项目名称:googlesyncmod,代码行数:101,代码来源:AppointmentSync.cs


注:本文中的Microsoft.Office.Interop.Outlook.GetRecurrencePattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。