示例#1
0
        // Token: 0x06001F1F RID: 7967 RVA: 0x000B2D44 File Offset: 0x000B0F44
        protected override void RenderMenuItems(TextWriter output)
        {
            MasterCategoryList masterCategoryList = this.userContext.GetMasterCategoryList(this.folderId);

            if (masterCategoryList != null)
            {
                MostRecentlyUsedCategories mostRecentlyUsedCategories = MostRecentlyUsedCategories.Create(masterCategoryList, this.outlookModule);
                for (int i = 0; i < mostRecentlyUsedCategories.MostRecentCategories.Length; i++)
                {
                    base.RenderCategoryMenuItem(output, mostRecentlyUsedCategories.MostRecentCategories[i], string.Format(CultureInfo.InvariantCulture, "divCatRct{0}", new object[]
                    {
                        i
                    }));
                }
                if (mostRecentlyUsedCategories.OtherCategories != null && 0 < mostRecentlyUsedCategories.OtherCategories.Length)
                {
                    base.RenderMenuItem(output, 1005271872, ThemeFileId.None, null, null, false, null, null, OtherCategoriesMenu.Create(this.userContext, mostRecentlyUsedCategories.OtherCategories, this));
                }
            }
            if (this.renderAdditionalMenuItem)
            {
                if (this.folderId == null || !this.folderId.IsOtherMailbox)
                {
                    base.RenderMenuItem(output, -1639820326, "mng", masterCategoryList == null);
                }
                ContextMenu.RenderMenuDivider(output, null);
                base.RenderMenuItem(output, -108608469, "clr");
            }
        }
        public void DeleteCategory()
        {
            base.ThrowIfCannotActAsOwner();
            string             categoryName       = (string)base.GetParameter("nm");
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (!masterCategoryList.Contains(categoryName))
            {
                return;
            }
            masterCategoryList.Remove(categoryName);
            masterCategoryList.Save();
        }
示例#3
0
        static MasterCategoryList GetLocalList(string username)
        {
            MasterCategoryList list = new MasterCategoryList();

            try
            {
                TextReader    reader     = new StreamReader(String.Format(".\\templates\\{0}.xml", username));
                XmlSerializer serializer = new XmlSerializer(typeof(MasterCategoryList));
                list = (MasterCategoryList)serializer.Deserialize(reader);
                reader.Close();
            }
            catch
            {
            }


            return(list);
        }
        public void CreateCategory()
        {
            base.ThrowIfCannotActAsOwner();
            string text = (string)base.GetParameter("nm");

            if (text.Length > 255)
            {
                throw new OwaInvalidRequestException("Category name cannot be longer than 255 characters.");
            }
            int color = (int)base.GetParameter("clr");

            if (!CategorySwatch.IsValidCategoryColor(color))
            {
                throw new OwaInvalidRequestException("Category color must be in the range [-1, 24].");
            }
            text = text.Trim();
            if (text.Length == 0)
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            if (text.Contains(",") || text.Contains(";") || text.Contains("؛") || text.Contains("﹔") || text.Contains(";"))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            if (CategoryEventHandler.guidRegEx.IsMatch(text))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, 1243373352);
                return;
            }
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (masterCategoryList.Contains(text))
            {
                RenderingUtilities.RenderError(base.UserContext, this.Writer, -210070156);
                return;
            }
            Category category = Category.Create(text, color, false);

            masterCategoryList.Add(category);
            ManageCategoriesDialog.RenderCategory(this.Writer, category);
            masterCategoryList.Save();
        }
示例#5
0
        public void Render(TextWriter writer)
        {
            ManageCategoriesDialog.RenderStrings(writer);
            writer.Write("<div id=divCtgLst tabindex=0>");
            MasterCategoryList masterCategoryList = this.userContext.GetMasterCategoryList();

            foreach (Category category in masterCategoryList)
            {
                ManageCategoriesDialog.RenderCategory(writer, category);
            }
            writer.Write("</div>");
            writer.Write("<div class=mngCtgLnk><a href=# id=\"lnkCrtCat\">");
            writer.Write(LocalizedStrings.GetHtmlEncoded(-1641878163));
            writer.Write("</a></div><div class=mngCtgLnk><a href=# id=\"lnkChgCatClr\">");
            writer.Write(LocalizedStrings.GetHtmlEncoded(782364430));
            writer.Write("</a></div><div class=mngCtgLnk><a href=# id=\"lnkDelCat\">");
            writer.Write(LocalizedStrings.GetHtmlEncoded(1478174110));
            writer.Write("</a></div>");
        }
        // Token: 0x06001F2A RID: 7978 RVA: 0x000B3190 File Offset: 0x000B1390
        public static void RenderViewCategorySwatches(TextWriter writer, UserContext userContext, string[] categories, bool isToDoItem, FlagStatus flagStatus, int itemColorInt, OwaStoreObjectId folderId, bool renderEmpty)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            int num  = 3;
            int num2 = 0;

            if (categories != null)
            {
                MasterCategoryList masterCategoryList = userContext.GetMasterCategoryList(folderId);
                if (masterCategoryList != null)
                {
                    int num3 = 0;
                    while (num3 < categories.Length && num2 < num)
                    {
                        Category category = masterCategoryList[categories[num3]];
                        if (category != null && category.Color != -1)
                        {
                            CategorySwatch.RenderSwatch(writer, category);
                            num2++;
                        }
                        num3++;
                    }
                }
            }
            if (num2 == 0 && !isToDoItem && flagStatus == FlagStatus.Flagged && itemColorInt != -1)
            {
                CategorySwatch.RenderSwatch(writer, (ItemColor)itemColorInt);
                num2++;
            }
            if (renderEmpty && num2 == 0)
            {
                CategorySwatch.RenderSwatch(writer, null);
            }
        }
        // Token: 0x06001F22 RID: 7970 RVA: 0x000B2F3C File Offset: 0x000B113C
        private CategoryDropDownList(OwaStoreObjectId folderId) : base("divCDd", null, null)
        {
            UserContext        userContext        = UserContextManager.GetUserContext();
            MasterCategoryList masterCategoryList = userContext.GetMasterCategoryList(folderId);

            if (masterCategoryList != null)
            {
                this.categories = masterCategoryList.ToArray();
                Array.Sort <Category>(this.categories, new MostRecentlyUsedCategories.CategoryNameComparer());
                if (0 < this.categories.Length)
                {
                    this.selectedCategory = this.categories[0];
                    base.SelectedValue    = this.selectedCategory.Name;
                    return;
                }
            }
            else
            {
                this.categories = new Category[0];
            }
        }
        // Token: 0x06000C4D RID: 3149 RVA: 0x00054A04 File Offset: 0x00052C04
        private MostRecentlyUsedCategories(MasterCategoryList masterCategoryList, OutlookModule outlookModule)
        {
            Category[] array = masterCategoryList.ToArray();
            Array.Sort <Category>(array, MasterCategoryList.CreateUsageBasedComparer(outlookModule));
            int num = 10;

            if (array.Length < 10)
            {
                num = array.Length;
            }
            this.mostRecentCategories = new Category[num];
            Array.Copy(array, this.mostRecentCategories, num);
            Array.Sort <Category>(this.mostRecentCategories, new MostRecentlyUsedCategories.CategoryNameComparer());
            int num2 = array.Length - num;

            if (0 < num2)
            {
                this.otherCategories = new Category[num2];
                Array.Copy(array, num, this.otherCategories, 0, num2);
                Array.Sort <Category>(this.otherCategories, new MostRecentlyUsedCategories.CategoryNameComparer());
            }
        }
示例#9
0
        public override string GetCssClassName(int index)
        {
            string text = "noClrCal";
            bool   flag = false;

            string[] categories = base.GetCategories(index);
            if (categories != null && 0 < categories.Length)
            {
                MasterCategoryList masterCategoryList = this.userContext.GetMasterCategoryList(this.folderId);
                if (masterCategoryList != null)
                {
                    for (int i = 0; i < categories.Length; i++)
                    {
                        Category category = masterCategoryList[categories[i]];
                        if (category != null && category.Color != -1)
                        {
                            flag = true;
                            text = CategorySwatch.GetCategoryClassName(category);
                            break;
                        }
                    }
                }
            }
            int num;

            if (!flag && base.TryGetPropertyValue <int>(index, CalendarItemBaseSchema.AppointmentColor, out num))
            {
                if (num < 0 || num >= CalendarDataSource.categoryColorOldLabelsToColors.Length)
                {
                    num = 0;
                }
                text = CategorySwatch.GetCategoryClassNameFromColor(CalendarDataSource.categoryColorOldLabelsToColors[num]);
            }
            if (StringComparer.OrdinalIgnoreCase.Compare(text, "noClr") == 0)
            {
                text = "noClrCal";
            }
            return(text);
        }
示例#10
0
        static void UpdateLocalFromMaster(ExchangeService service, string username)
        {
            FileStream    file   = null;
            XmlSerializer writer = new XmlSerializer(typeof(MasterCategoryList));

            try
            {
                var list = MasterCategoryList.Bind(service, String.Format("{0}@millerjohnson.com", username));
                file = File.Create(String.Format(".\\templates\\{0}.xml", username));
                writer.Serialize(file, list);
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Failed to write local category list for {0}", username), ex);
            }
            finally
            {
                if (file != null)
                {
                    file.Close();
                }
            }
        }
        public void ChangeCategoryColor()
        {
            base.ThrowIfCannotActAsOwner();
            string text = (string)base.GetParameter("nm");

            if (string.IsNullOrEmpty(text))
            {
                throw new OwaInvalidRequestException("Category name cannot be null or empty.");
            }
            int color = (int)base.GetParameter("clr");

            if (!CategorySwatch.IsValidCategoryColor(color))
            {
                throw new OwaInvalidRequestException("Category color must be in the range [-1, 24].");
            }
            MasterCategoryList masterCategoryList = base.UserContext.GetMasterCategoryList(true);

            if (!masterCategoryList.Contains(text))
            {
                throw new OwaInvalidRequestException("Category does not exist");
            }
            masterCategoryList[text].Color = color;
            masterCategoryList.Save();
        }
示例#12
0
        protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            MessageCategoryId messageCategoryId = rootId as MessageCategoryId;

            if (sortBy != null)
            {
                throw new NotSupportedException("sortBy");
            }
            if (rootId != null && messageCategoryId == null)
            {
                throw new NotSupportedException("rootId");
            }
            MasterCategoryList categoryList = base.MailboxSession.GetMasterCategoryList();

            if (messageCategoryId == null || (messageCategoryId.Name == null && messageCategoryId.CategoryId == null))
            {
                foreach (Category category in categoryList)
                {
                    yield return((T)((object)this.ConvertCategoryToPresentationObject(category)));
                }
            }
            else if (messageCategoryId.CategoryId != null)
            {
                Category category2 = categoryList[messageCategoryId.CategoryId.Value];
                yield return((T)((object)this.ConvertCategoryToPresentationObject(category2)));
            }
            else
            {
                Category category3 = categoryList[messageCategoryId.Name];
                if (category3 != null)
                {
                    yield return((T)((object)this.ConvertCategoryToPresentationObject(category3)));
                }
            }
            yield break;
        }
 // Token: 0x06000C4C RID: 3148 RVA: 0x000549FA File Offset: 0x00052BFA
 public static MostRecentlyUsedCategories Create(MasterCategoryList masterCategoryList, OutlookModule outlookModule)
 {
     return(new MostRecentlyUsedCategories(masterCategoryList, outlookModule));
 }
        // Token: 0x06001F31 RID: 7985 RVA: 0x000B32DC File Offset: 0x000B14DC
        public static void RenderCategories(OwaContext owaContext, TextWriter writer, IStorePropertyBag storePropertyBag, StoreSession storeSession)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (storePropertyBag == null)
            {
                throw new ArgumentNullException("storePropertyBag");
            }
            string[] property = ItemUtility.GetProperty <string[]>(storePropertyBag, ItemSchema.Categories, null);
            string   value    = owaContext.UserContext.IsRtl ? "rtl" : "ltr";
            int      num      = 0;

            if (property != null && 0 < property.Length)
            {
                MasterCategoryList masterCategoryList = null;
                try
                {
                    if (storeSession != null && owaContext.UserContext.IsOtherMailbox(storeSession))
                    {
                        masterCategoryList = owaContext.UserContext.GetMasterCategoryList(storeSession as MailboxSession);
                    }
                    else
                    {
                        masterCategoryList = owaContext.UserContext.GetMasterCategoryList();
                    }
                }
                catch (QuotaExceededException ex)
                {
                    ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "CategorySwatch.RenderCategories: Failed. Exception: {0}", ex.Message);
                    return;
                }
                if (masterCategoryList != null)
                {
                    for (int i = 0; i < property.Length; i++)
                    {
                        writer.Write("<span class=\"spanCatContainer\" dir=\"");
                        writer.Write(value);
                        writer.Write("\">");
                        CategorySwatch.RenderSwatch(writer, masterCategoryList[property[i]]);
                        writer.Write("&nbsp;");
                        Utilities.SanitizeHtmlEncode(property[i], writer);
                        if (i < property.Length - 1)
                        {
                            writer.Write("; ");
                        }
                        writer.Write("</span><wbr>");
                        num++;
                    }
                }
            }
            if (num == 0)
            {
                writer.Write("<span class=\"spanCatContainer catAfter\" dir=\"");
                writer.Write(value);
                writer.Write("\">");
                int legacyColoredFlag = ItemUtility.GetLegacyColoredFlag(storePropertyBag);
                if (0 < legacyColoredFlag && legacyColoredFlag < CategorySwatch.FlagCategory.Length)
                {
                    CategorySwatch.RenderSwatch(writer, (ItemColor)legacyColoredFlag);
                    writer.Write("<span id=\"vaM\">");
                    writer.Write(SanitizedHtmlString.FromStringId(CategorySwatch.FlagCategory[legacyColoredFlag]));
                    writer.Write("</span>");
                }
                writer.Write("</span>");
            }
        }
示例#15
0
 static MasterCategoryList GetMasterList(ExchangeService service, string username)
 {
     return(MasterCategoryList.Bind(service, String.Format("{0}@millerjohnson.com", username)));
 }
示例#16
0
        static void Main(string[] args)
        {
            log.WriteDebugLog("Main()");

            if (args.Length > 0)
            {
                // getting all arguments from the command line
                var             arguments             = new UtilityArguments(args);
                string          Mailbox               = arguments.Mailbox;
                string          ImportFile            = arguments.Import;
                string          ExportFile            = arguments.Export;
                string          Action                = "none";
                string          User                  = arguments.User;
                bool            UseDefaultCredentials = false;
                ExchangeHelper  EWSHelper             = new ExchangeHelper();
                ExchangeService EWSService            = new ExchangeService();

                if (arguments.Help)
                {
                    DisplayHelp();
                    Environment.Exit(0);
                }



                if (Mailbox == null || Mailbox.Length == 0)
                {
                    Console.WriteLine("No mailbox given.");
                    log.WriteErrorLog("No mailbox given. Aborting");
                    DisplayHelp();
                    Environment.Exit(1);
                }

                if (ImportFile.Length > 0 && ExportFile.Length > 0)
                {
                    Console.WriteLine("Only import or export is allowed");
                    log.WriteErrorLog("-import and -export given at the same time. Aborting");
                    DisplayHelp();
                    Environment.Exit(1);
                }

                if (ImportFile.Length > 0)
                {
                    Action = "import";
                }
                else if (ExportFile.Length > 0)
                {
                    Action = "export";
                }
                else
                {
                    Console.WriteLine("At least one action have to be given. -import or -export.");
                    log.WriteErrorLog("At least one action have to be given. -import or -export. Aborting");
                    DisplayHelp();
                    Environment.Exit(1);
                }

                // Log the arguments
                log.WriteDebugLog("Parsing arguments:");
                log.WriteDebugLog(string.Format("-mailbox {0}", Mailbox));
                if (arguments.Import.Length > 0)
                {
                    log.WriteDebugLog(string.Format("import file: {0}", arguments.Import));
                }
                if (ExportFile.Length > 0)
                {
                    log.WriteDebugLog(string.Format("import file: {0}", arguments.Export));
                }
                if (arguments.User.Length == 0 || arguments.Password.Length == 0)
                {
                    UseDefaultCredentials = true;
                    log.WriteDebugLog("No user or passsword given. Using default credentials.");
                }
                else
                {
                    log.WriteDebugLog(string.Format("-user: {0}", arguments.User));
                    log.WriteDebugLog("-password: set");
                }

                if (arguments.IgnoreCertificate)
                {
                    log.WriteDebugLog("Ignoring SSL error because option -ignorecertificate is set");
                }

                if (arguments.URL.Length == 0)
                {
                    log.WriteDebugLog("-url: not given, using autodiscover");
                }
                else
                {
                    log.WriteDebugLog(string.Format("-url: {0}", arguments.URL));
                }
                log.WriteDebugLog(string.Format("-impersonate: {0}", arguments.Impersonate));


                if (arguments.URL.Length == 0)
                {
                    // Autodiscover
                    if (UseDefaultCredentials)
                    {
                        EWSService = EWSHelper.Service(UseDefaultCredentials, "", null, Mailbox, arguments.AllowRedirection, arguments.Impersonate, arguments.IgnoreCertificate);
                    }
                    else
                    {
                        EWSService = EWSHelper.Service(UseDefaultCredentials, User, SecureStringHelper.StringToSecureString(arguments.Password), Mailbox, arguments.AllowRedirection, arguments.Impersonate, arguments.IgnoreCertificate);
                    }
                }
                else
                {
                    // URL
                    if (UseDefaultCredentials)
                    {
                        EWSService = EWSHelper.Service(UseDefaultCredentials, "", null, Mailbox, arguments.URL, arguments.Impersonate, arguments.IgnoreCertificate);
                    }
                    else
                    {
                        EWSService = EWSHelper.Service(UseDefaultCredentials, User, SecureStringHelper.StringToSecureString(arguments.Password), Mailbox, arguments.URL, arguments.Impersonate, arguments.IgnoreCertificate);
                    }
                }

                if (EWSService != null)
                {
                    switch (Action)
                    {
                    case "import":
                        Import(EWSService, arguments.Import, arguments.ClearOnImport);
                        Environment.Exit(0);
                        break;

                    case "export":
                        Export(EWSService, arguments.Export);
                        Environment.Exit(0);
                        break;

                    default:
                        Environment.Exit(1);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Error on creating the service. Check permissions and if the server is avaiable.");
                    log.WriteErrorLog("Error on creating the service. Check permissions and if the server is avaiable.");
                    Environment.Exit(2);
                }
            }

            void Import(ExchangeService Service, string FileName, bool ClearonImport)
            {
                if (File.Exists(FileName))
                {
                    var CategoryList = new MasterCategoryList();

                    try
                    {
                        TextReader    reader        = new StreamReader(FileName);
                        XmlSerializer newSerializer = new XmlSerializer(typeof(MasterCategoryList));

                        CategoryList = (MasterCategoryList)newSerializer.Deserialize(reader);
                    }
                    catch
                    {
                        Console.WriteLine("Error on reading import file. Check permissions and content.");
                        log.WriteErrorLog("Error on reading import file. Check permissions and content.");
                        Environment.Exit(3);
                    }

                    try
                    {
                        log.WriteInfoLog("Importing categories to mailbox");

                        var targetCategoryList = MasterCategoryList.Bind(Service);
                        if (ClearonImport)
                        {
                            log.WriteInfoLog("Clearing categories on import...");
                            if (targetCategoryList.Categories.Count > 0)
                            {
                                for (int i = 0; i <= targetCategoryList.Categories.Count - 1; i++)
                                {
                                    targetCategoryList.Categories.RemoveAt(i);
                                }
                                // update cleared category targetCategoryList
                                targetCategoryList.Update();
                            }
                        }
                        targetCategoryList.Categories = CategoryList.Categories;
                        targetCategoryList.Update();
                        Console.WriteLine("Categories successfully imported");
                        log.WriteInfoLog("Categories successfully imported");
                    }
                    catch
                    {
                        log.WriteErrorLog("Error on importing categories. Check XML file and permissions to the mailbox.");
                    }
                }
                else
                {
                    Console.WriteLine("File to import doesn't exist.");
                    log.WriteErrorLog("File to import doesn't exist.");
                    Environment.Exit(1);
                }
            }

            void Export(ExchangeService Service, string FileName)
            {
                var CategoryList = MasterCategoryList.Bind(Service);

                if (CategoryList != null)
                {
                    try
                    {
                        log.WriteInfoLog(string.Format("Saving categories to file: {0}", FileName));
                        FileStream    file   = System.IO.File.Create(FileName);
                        XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(MasterCategoryList));
                        writer.Serialize(file, CategoryList);
                        file.Close();
                        log.WriteInfoLog(string.Format("Categories successfully saved to file: {0}", FileName));
                    }
                    catch
                    {
                        log.WriteErrorLog(string.Format("Error on write the file {0}. Check permissions.", FileName));
                    }
                }
            }

            void DisplayHelp()
            {
                Console.WriteLine("ManageCategoriesCmd - Usage for import:");
                Console.WriteLine("ManageCategoriesCmd.exe -mailbox \"[email protected]\" -import \"C:\\categories.xml\" [-ignorecertificate] [-url \"https://server/EWS/Exchange.asmx\"] [-allowredirection] [-user [email protected]] [-password Pa$$w0rd] [-impersonate] [-clearonimport]");
                Console.WriteLine("Usage for export:");
                Console.WriteLine("ManageCategoriesCmd.exe -mailbox \"[email protected]\" -export \"C:\\categories.xml\" [-ignorecertificate] [-url \"https://server/EWS/Exchange.asmx\"] [-allowredirection] [-user [email protected]] [-password Pa$$w0rd] [-impersonate] [-clearonimport]");
                Console.WriteLine("If no user or password is given the application uses the user credentials");
            }
        }