コード例 #1
0
 public int[] InstalledLanguages()
 {
     if (Service != null)
     {
         RetrieveAvailableLanguagesRequest  req  = new RetrieveAvailableLanguagesRequest();
         RetrieveAvailableLanguagesResponse resp = (RetrieveAvailableLanguagesResponse)Service.Execute(req);
         return(resp.LocaleIds);
     }
     return(null);
 }
コード例 #2
0
        /// <summary>
        /// Check that the requested LCID is a provisioned language - otherwise return the default LCID
        /// </summary>
        /// <param name="service"></param>
        /// <param name="lcid"></param>
        /// <returns></returns>
        private static int CheckLcid(IOrganizationService service, int lcid)
        {
            // Find the provisioned languages and check that we are requesting one - otherwise fallback to the default language
            RetrieveAvailableLanguagesRequest langRequest = new RetrieveAvailableLanguagesRequest();
            var langResponse = (RetrieveAvailableLanguagesResponse)service.Execute(langRequest);

            if (!langResponse.LocaleIds.Contains(lcid))
            {
                lcid = GetDefaultLCID(service);
            }
            return(lcid);
        }
        public void LoadLanguages()
        {
            RetrieveAvailableLanguagesRequest request = new RetrieveAvailableLanguagesRequest();

            RetrieveAvailableLanguagesResponse fullResponse = (RetrieveAvailableLanguagesResponse)Service.Execute(request);

            List <int> LCIDs = fullResponse.LocaleIds.ToList();

            _languageItems.Clear();

            _languageData = new List <LanguageModel>();

            foreach (int l in LCIDs)
            {
                CultureInfo     cInfo           = CultureInfo.GetCultureInfo(l);
                EntityReference websiteLanguage = GetWebsiteLanguage(l);

                _languageData.Add(new LanguageModel()
                {
                    LCID            = l,
                    LanguageName    = cInfo.DisplayName,
                    WebsiteLanguage = websiteLanguage
                });

                string       displayName = string.Format("{0} - {1}", cInfo.DisplayName, l);
                ListViewItem listItem    = new ListViewItem(displayName);
                listItem.Tag     = websiteLanguage.Id;
                listItem.Checked = true;
                if (websiteLanguage.Id == Guid.Empty)
                {
                    listItem.Text       += " - Unavailable";
                    listItem.BackColor   = System.Drawing.Color.DarkSlateGray;
                    listItem.ToolTipText = "This language is available in your CDS/D365, but missing Website Language linked to your Portals";
                    listItem.Checked     = false;
                    listItem.ForeColor   = System.Drawing.Color.Orange;
                }

                _languageItems.Add(listItem);
            }
        }
コード例 #4
0
        /// <summary>
        /// Sets up the application.
        /// </summary>
        private void Setup()
        {
            this.WorkAsync(new WorkAsyncInfo
            {
                Message = "Retrieving languages...",
                Work    = (w, e) =>
                {
                    if (installedLanguages == null)
                    {
                        RetrieveAvailableLanguagesRequest request   = new RetrieveAvailableLanguagesRequest();
                        RetrieveAvailableLanguagesResponse response = (RetrieveAvailableLanguagesResponse)Service.Execute(request);
                        e.Result = response;
                    }
                },
                PostWorkCallBack = e =>
                {
                    if (e.Result != null)
                    {
                        Dictionary <int, string> languages = JsonConvert.DeserializeObject <Dictionary <int, string> >(Properties.Resources.Countries);
                        installedLanguages = new Dictionary <int, string>();
                        foreach (var language in ((RetrieveAvailableLanguagesResponse)e.Result).LocaleIds)
                        {
                            if (languages.ContainsKey(language))
                            {
                                installedLanguages.Add(language, languages[language]);
                            }
                        }

                        GetUser();
                        GetSolutions();
                    }
                },
                AsyncArgument = null,
                IsCancelable  = true,
                MessageWidth  = 340,
                MessageHeight = 150
            });
        }
コード例 #5
0
 /// <summary>
 /// Check that the requested LCID is a provisioned language - otherwise return the default LCID
 /// </summary>
 /// <param name="service"></param>
 /// <param name="lcid"></param>
 /// <returns></returns>
 private static int CheckLcid(IOrganizationService service, int lcid)
 {
     // Find the provisioned languages and check that we are requesting one - otherwise fallback to the default language
     RetrieveAvailableLanguagesRequest langRequest = new RetrieveAvailableLanguagesRequest();
     var langResponse = (RetrieveAvailableLanguagesResponse)service.Execute(langRequest);
     if (!langResponse.LocaleIds.Contains(lcid))
     {
         lcid = GetDefaultLCID(service);
     }
     return lcid;
 }