public static String ApplyRegex(String source, Sync.Direction direction)
        {
            String retStr = source ?? "";

            if (Settings.Instance.Obfuscation.Enabled && direction.Id == Settings.Instance.Obfuscation.Direction.Id)
            {
                foreach (DataGridViewRow row in Forms.Main.Instance.dgObfuscateRegex.Rows)
                {
                    DataGridViewCellCollection cells = row.Cells;
                    if (cells[Obfuscate.findCol].Value != null)
                    {
                        System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex(
                            cells[Obfuscate.findCol].Value.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);

                        System.Text.RegularExpressions.MatchCollection matches = rgx.Matches(retStr);
                        if (matches.Count > 0)
                        {
                            log.Debug("Regex has matched and altered string: " + cells[Obfuscate.findCol].Value.ToString());
                            if (cells[Obfuscate.replaceCol].Value == null)
                            {
                                cells[Obfuscate.replaceCol].Value = "";
                            }
                            retStr = rgx.Replace(retStr, cells[Obfuscate.replaceCol].Value.ToString());
                        }
                    }
                }
            }
            return(retStr);
        }
Пример #2
0
        public void CompareOutlookPattern(Event ev, ref RecurrencePattern aiOpattern, Sync.Direction syncDirection, System.Text.StringBuilder sb, ref int itemModified)
        {
            if (ev.Recurrence == null)
            {
                return;
            }

            log.Fine("Building a temporary recurrent Appointment generated from Event");
            AppointmentItem evAI = OutlookOgcs.Calendar.Instance.IOutlook.UseOutlookCalendar().Items.Add() as AppointmentItem;

            evAI.Start = ev.Start.DateTime ?? DateTime.Parse(ev.Start.Date);

            RecurrencePattern evOpattern = null;

            try {
                buildOutlookPattern(ev, evAI, out evOpattern);
                log.Fine("Comparing Google recurrence to Outlook equivalent");

                //Some versions of Outlook are erroring when 2-way syncing weekday recurring series.
                //Even though Outlook has Interval of zero, which is illegal, when this is updated, it won't save. Issue #398
                Boolean skipIntervalCheck = false;
                if (aiOpattern.RecurrenceType == OlRecurrenceType.olRecursWeekly && aiOpattern.DayOfWeekMask == getDOWmask("BYDAY=MO,TU,WE,TH,FR") && aiOpattern.Interval == 0 &&
                    evOpattern.RecurrenceType == aiOpattern.RecurrenceType && evOpattern.DayOfWeekMask == aiOpattern.DayOfWeekMask && evOpattern.Interval == 1)
                {
                    skipIntervalCheck = true;
                }

                if (Sync.Engine.CompareAttribute("Recurrence Type", syncDirection,
                                                 evOpattern.RecurrenceType.ToString(), aiOpattern.RecurrenceType.ToString(), sb, ref itemModified))
                {
                    aiOpattern.RecurrenceType = evOpattern.RecurrenceType;
                }
                if (!skipIntervalCheck && Sync.Engine.CompareAttribute("Recurrence Interval", syncDirection,
                                                                       evOpattern.Interval.ToString(), aiOpattern.Interval.ToString(), sb, ref itemModified))
                {
                    aiOpattern.Interval = evOpattern.Interval;
                }
                if (Sync.Engine.CompareAttribute("Recurrence Instance", syncDirection,
                                                 evOpattern.Instance.ToString(), aiOpattern.Instance.ToString(), sb, ref itemModified))
                {
                    aiOpattern.Instance = evOpattern.Instance;
                }
                if (Sync.Engine.CompareAttribute("Recurrence DoW", syncDirection,
                                                 evOpattern.DayOfWeekMask.ToString(), aiOpattern.DayOfWeekMask.ToString(), sb, ref itemModified))
                {
                    aiOpattern.DayOfWeekMask = evOpattern.DayOfWeekMask;
                }
                if (Sync.Engine.CompareAttribute("Recurrence MoY", syncDirection,
                                                 evOpattern.MonthOfYear.ToString(), aiOpattern.MonthOfYear.ToString(), sb, ref itemModified))
                {
                    aiOpattern.MonthOfYear = evOpattern.MonthOfYear;
                }
                if (Sync.Engine.CompareAttribute("Recurrence NoEndDate", syncDirection,
                                                 evOpattern.NoEndDate, aiOpattern.NoEndDate, sb, ref itemModified))
                {
                    aiOpattern.NoEndDate = evOpattern.NoEndDate;
                }
                if (Sync.Engine.CompareAttribute("Recurrence Occurences", syncDirection,
                                                 evOpattern.Occurrences.ToString(), aiOpattern.Occurrences.ToString(), sb, ref itemModified))
                {
                    aiOpattern.Occurrences = evOpattern.Occurrences;
                }
            } finally {
                evOpattern = (RecurrencePattern)OutlookOgcs.Calendar.ReleaseObject(evOpattern);
                evAI.Delete();
                evAI = (AppointmentItem)OutlookOgcs.Calendar.ReleaseObject(evAI);
            }
        }