示例#1
0
        private void LoadCrmItems()
        {
            cbbSiteMapArea.Items.Clear();
            cbbSiteMapSubArea.Items.Clear();
            cbbTimeZones.Items.Clear();
            userSelector1.Service = Service;
            userSelector1.LoadViews();

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Initializing...",
                AsyncArgument = null,
                Work          = (bw, e) =>
                {
                    var sc = new SettingsCollection();

                    bw.ReportProgress(0, "Loading Available languages...");
                    var ush      = new UserSettingsHelper(Service, ConnectionDetail);
                    sc.Languages = ush.RetrieveAvailableLanguages();

                    bw.ReportProgress(0, "Loading Currencies...");
                    ush           = new UserSettingsHelper(Service, ConnectionDetail);
                    sc.Currencies = ush.RetrieveCurrencies();

                    bw.ReportProgress(0, "Loading Time Zones...");
                    ush          = new UserSettingsHelper(Service, ConnectionDetail);
                    sc.TimeZones = ush.RetrieveTimeZones();

                    bw.ReportProgress(0, "Loading SiteMap elements...");
                    var smm  = new SiteMapManager(Service);
                    areas    = smm.GetAreaList();
                    subAreas = smm.GetSubAreaList();

                    e.Result = sc;
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        cbbTimeZones.Items.Clear();
                        cbbHelpLanguage.Items.Clear();
                        cbbUiLanguage.Items.Clear();
                        cbbSiteMapArea.Items.Clear();
                        cbbSiteMapSubArea.Items.Clear();
                        cbbCurrencies.Items.Clear();

                        var sc = (SettingsCollection)e.Result;

                        // TimeZones
                        cbbTimeZones.Items.Add(new AppCode.TimeZone
                        {
                            Code = -1,
                            Name = "No change"
                        });
                        cbbTimeZones.Items.AddRange(
                            sc.TimeZones.Entities.ToList()
                            .Select(
                                t =>
                                new AppCode.TimeZone
                        {
                            Code = t.GetAttributeValue <int>("timezonecode"),
                            Name = t.GetAttributeValue <string>("userinterfacename")
                        })
                            .Cast <object>().ToArray());
                        cbbTimeZones.SelectedIndex = 0;

                        // Language
                        cbbHelpLanguage.Items.Add("No change");
                        cbbHelpLanguage.Items.AddRange(sc.Languages.ToArray());
                        cbbUiLanguage.Items.Add("No change");
                        cbbUiLanguage.Items.AddRange(sc.Languages.ToArray());

                        // Currencies
                        cbbCurrencies.Items.Add("No change");
                        cbbCurrencies.Items.AddRange(sc.Currencies.ToArray());

                        // SiteMap
                        cbbSiteMapArea.Items.Add("No change");
                        cbbSiteMapArea.Items.AddRange(areas.ToArray());
                        cbbSiteMapSubArea.Items.Add("No change");
                        cbbSiteMapSubArea.Items.AddRange(subAreas.Select(t => t.Item1).ToArray());
                        cbbSiteMapSubArea.Enabled = false;

                        foreach (var ctrl in panel1.Controls)
                        {
                            var gb = ctrl as GroupBox;
                            if (gb != null)
                            {
                                foreach (var ctrl2 in gb.Controls)
                                {
                                    var cbb = ctrl2 as ComboBox;
                                    if (cbb != null && cbb.Items.Count > 0)
                                    {
                                        cbb.SelectedIndex = 0;
                                    }
                                }
                            }
                        }

                        panel1.Enabled = true;
                    }
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }
示例#2
0
        private void LoadSettings()
        {
            cbbSiteMapArea.Items.Clear();
            cbbSiteMapSubArea.Items.Clear();
            cbbTimeZones.Items.Clear();

            var ush = new UserSettingsHelper(Service, ConnectionDetail);
            var smm = new SiteMapManager(Service);

            tsbLoadCrmItems.Enabled = false;

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Initializing...",
                AsyncArgument = null,
                Work          = (bw, e) =>
                {
                    var sc = new SettingsCollection();

                    bw.ReportProgress(0, "Loading users...");
                    userSelector1.Service = Service;
                    sc.Views = userSelector1.LoadViews();

                    bw.ReportProgress(0, "Loading Available languages...");
                    sc.Languages = ush.RetrieveAvailableLanguages();

                    bw.ReportProgress(0, "Loading Currencies...");
                    sc.Currencies = ush.RetrieveCurrencies();

                    bw.ReportProgress(0, "Loading Time Zones...");
                    sc.TimeZones = ush.RetrieveTimeZones();

                    bw.ReportProgress(0, "Loading SiteMap elements...");
                    areas    = smm.GetAreaList();
                    subAreas = smm.GetSubAreaList();

                    bw.ReportProgress(0, "Loading Dashboards...");
                    sc.Dashboards = ush.RetrieveDashboards();

                    bw.ReportProgress(0, "Loading Environment Settings...");
                    sc.OrgSettings = ush.RetrieveOrgSettings();
                    e.Result       = sc;
                },
                PostWorkCallBack = e =>
                {
                    tsbLoadCrmItems.Enabled = true;

                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        cbbTimeZones.Items.Clear();
                        cbbHelpLanguage.Items.Clear();
                        cbbUiLanguage.Items.Clear();
                        cbbSiteMapArea.Items.Clear();
                        cbbSiteMapSubArea.Items.Clear();
                        cbbCurrencies.Items.Clear();
                        cbbDefaultDashboard.Items.Clear();
                        cbbFormat.Items.Clear();
                        cbbSearch.Items.Clear();

                        var sc = (SettingsCollection)e.Result;

                        // Views
                        if (sc.Views != null)
                        {
                            userSelector1.SetViews(sc.Views);
                        }

                        // TimeZones
                        cbbTimeZones.Items.Add(new AppCode.TimeZone
                        {
                            Code = -1,
                            Name = "No change"
                        });
                        cbbTimeZones.Items.AddRange(
                            sc.TimeZones.Entities.ToList()
                            .Select(
                                t =>
                                new AppCode.TimeZone
                        {
                            Code = t.GetAttributeValue <int>("timezonecode"),
                            Name = t.GetAttributeValue <string>("userinterfacename")
                        })
                            .Cast <object>()
                            .ToArray());
                        cbbTimeZones.SelectedIndex = 0;

                        // Language
                        cbbHelpLanguage.Items.Add("No change");
                        cbbHelpLanguage.Items.AddRange(sc.Languages.ToArray());
                        cbbUiLanguage.Items.Add("No change");
                        cbbUiLanguage.Items.AddRange(sc.Languages.ToArray());

                        // Currencies
                        cbbCurrencies.Items.Add("No change");
                        cbbCurrencies.DisplayMember = "Name";
                        foreach (var c in sc.Currencies)
                        {
                            var currency  = c.ToEntityReference();
                            currency.Name = c.GetAttributeValue <string>("currencyname");
                            cbbCurrencies.Items.Add(currency);
                        }

                        var version = ush.RetrieveVersion();
                        // Default search
                        cbbSearch.Items.Add("No change");
                        if (version.Major >= 9)
                        {
                            cbbSearch.Items.Add("Relevance search");
                            cbbSearch.Items.Add("Categorized search");
                            cbbSearch.Items.Add("Use last search");
                            cbbSearch.Items.Add("Custom search");
                            cbbSearch.Enabled = true;
                        }
                        else
                        {
                            cbbSearch.Enabled = false;
                        }

                        // AutoDataCapture
                        var isDataCaptureEnabled =
                            sc.OrgSettings.GetAttributeValue <bool>(OrganizationSettings.Fields
                                                                    .IsAutoDataCaptureEnabled);
                        cbbAutoDataCaptureEnabled.Enabled = isDataCaptureEnabled &&
                                                            (version.Major == 8 && version.Minor >= 2 || version.Major >= 9);

                        // Sync Resources booking with Outlook
                        // For now, it's not necessary to have org level setting enabled to change
                        // user setting. Not using the org level settings for now.
                        var isResourceBookingExchangeSyncEnabled =
                            sc.OrgSettings.GetAttributeValue <bool>(OrganizationSettings.Fields
                                                                    .IsResourceBookingExchangeSyncEnabled);
                        cbbSynchronizeResourceBookingWithOutlook.Enabled = //isResourceBookingExchangeSyncEnabled &&
                                                                           (version.Major == 8 && version.Minor >= 2 || version.Major >= 9);

                        cbbShowEmailsAsConversation.Enabled =
                            version.Major == 9 && version.Minor >= 1 || version.Major > 9;

                        // SiteMap
                        cbbSiteMapArea.Items.Add("No change");
                        cbbSiteMapArea.Items.AddRange(areas.ToArray());
                        cbbSiteMapSubArea.Items.Add("No change");
                        cbbSiteMapSubArea.Items.AddRange(subAreas.Select(t => t.Item1).ToArray());
                        cbbSiteMapSubArea.Enabled = false;

                        cbbDefaultDashboard.Items.Add("No change");
                        cbbDefaultDashboard.DisplayMember = "Name";
                        foreach (var d in sc.Dashboards)
                        {
                            var dashboard  = d.ToEntityReference();
                            dashboard.Name = d.GetAttributeValue <string>("name");
                            cbbDefaultDashboard.Items.Add(dashboard);
                        }

                        foreach (var ctrl in panel1.Controls)
                        {
                            var gb = ctrl as GroupBox;
                            if (gb != null)
                            {
                                foreach (var ctrl2 in gb.Controls)
                                {
                                    var cbb = ctrl2 as ComboBox;
                                    if (cbb != null && cbb.Items.Count > 0)
                                    {
                                        cbb.SelectedIndex = 0;
                                    }
                                }
                            }
                        }
                        cbbFormat.Items.Add("No change");
                        cbbFormat.DisplayMember = "NativeName";
                        cbbFormat.Items.AddRange(CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures)
                                                 .Where(x => !x.IsNeutralCulture && x.LCID != 127)
                                                 .OrderBy(ci => ci.DisplayName)
                                                 .ToArray());
                        cbbFormat.SelectedIndex = 0;
                        panel1.Enabled          = true;
                    }
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }
示例#3
0
        private void LoadSettings()
        {
            cbbSiteMapArea.Items.Clear();
            cbbSiteMapSubArea.Items.Clear();
            cbbTimeZones.Items.Clear();

            var ush = new UserSettingsHelper(Service, ConnectionDetail);
            var smm = new SiteMapManager(Service);

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Initializing...",
                AsyncArgument = null,
                Work          = (bw, e) =>
                {
                    var sc = new SettingsCollection();

                    bw.ReportProgress(0, "Loading Available languages...");
                    sc.Languages = ush.RetrieveAvailableLanguages();

                    bw.ReportProgress(0, "Loading Currencies...");
                    sc.Currencies = ush.RetrieveCurrencies();

                    bw.ReportProgress(0, "Loading Time Zones...");
                    sc.TimeZones = ush.RetrieveTimeZones();

                    bw.ReportProgress(0, "Loading SiteMap elements...");
                    areas    = smm.GetAreaList();
                    subAreas = smm.GetSubAreaList();

                    bw.ReportProgress(0, "Loading Dashboards...");
                    sc.Dashboards = ush.RetrieveDashboards();

                    e.Result = sc;
                },
                PostWorkCallBack = e =>
                {
                    if (e.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + e.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        cbbTimeZones.Items.Clear();
                        cbbHelpLanguage.Items.Clear();
                        cbbUiLanguage.Items.Clear();
                        cbbSiteMapArea.Items.Clear();
                        cbbSiteMapSubArea.Items.Clear();
                        cbbCurrencies.Items.Clear();
                        cbbDefaultDashboard.Items.Clear();
                        cbbFormat.Items.Clear();

                        var sc = (SettingsCollection)e.Result;

                        // TimeZones
                        cbbTimeZones.Items.Add(new AppCode.TimeZone
                        {
                            Code = -1,
                            Name = "No change"
                        });
                        cbbTimeZones.Items.AddRange(
                            sc.TimeZones.Entities.ToList()
                            .Select(
                                t =>
                                new AppCode.TimeZone
                        {
                            Code = t.GetAttributeValue <int>("timezonecode"),
                            Name = t.GetAttributeValue <string>("userinterfacename")
                        })
                            .Cast <object>()
                            .ToArray());
                        cbbTimeZones.SelectedIndex = 0;

                        // Language
                        cbbHelpLanguage.Items.Add("No change");
                        cbbHelpLanguage.Items.AddRange(sc.Languages.ToArray());
                        cbbUiLanguage.Items.Add("No change");
                        cbbUiLanguage.Items.AddRange(sc.Languages.ToArray());

                        // Currencies
                        cbbCurrencies.Items.Add("No change");
                        cbbCurrencies.DisplayMember = "Name";
                        foreach (var c in sc.Currencies)
                        {
                            var currency  = c.ToEntityReference();
                            currency.Name = c.GetAttributeValue <string>("currencyname");
                            cbbCurrencies.Items.Add(currency);
                        }

                        // SiteMap
                        cbbSiteMapArea.Items.Add("No change");
                        cbbSiteMapArea.Items.AddRange(areas.ToArray());
                        cbbSiteMapSubArea.Items.Add("No change");
                        cbbSiteMapSubArea.Items.AddRange(subAreas.Select(t => t.Item1).ToArray());
                        cbbSiteMapSubArea.Enabled = false;

                        cbbDefaultDashboard.Items.Add("No change");
                        cbbDefaultDashboard.DisplayMember = "Name";
                        foreach (var d in sc.Dashboards)
                        {
                            var dashboard  = d.ToEntityReference();
                            dashboard.Name = d.GetAttributeValue <string>("name");
                            cbbDefaultDashboard.Items.Add(dashboard);
                        }

                        foreach (var ctrl in panel1.Controls)
                        {
                            var gb = ctrl as GroupBox;
                            if (gb != null)
                            {
                                foreach (var ctrl2 in gb.Controls)
                                {
                                    var cbb = ctrl2 as ComboBox;
                                    if (cbb != null && cbb.Items.Count > 0)
                                    {
                                        cbb.SelectedIndex = 0;
                                    }
                                }
                            }
                        }
                        cbbFormat.Items.Add("No change");
                        cbbFormat.DisplayMember = "NativeName";
                        cbbFormat.Items.AddRange(CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures)
                                                 .Where(x => !x.IsNeutralCulture && x.LCID != 127)
                                                 .OrderBy(ci => ci.DisplayName)
                                                 .ToArray());
                        cbbFormat.SelectedIndex = 0;
                        panel1.Enabled          = true;
                    }
                },
                ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }
            });
        }