예제 #1
0
        internal static void SetDefaultCategoriesFromJson()
        {
            Logger.Info("Setting default categories");
            ProblemCategory forProblemCategory = LogCollectorUtils.GetLocalizationForProblemCategory(LogCollectorUtils.sVmName);

            if (forProblemCategory == null || forProblemCategory.Category == null || forProblemCategory.Category.Count <= 0)
            {
                return;
            }
            List <Category> categoryList = new List <Category>((IEnumerable <Category>)forProblemCategory.Category);

            LogCollectorUtils.sProblemCategories                      = new string[categoryList.Count];
            LogCollectorUtils.sCategorySubcategoryMapping             = new Dictionary <string, Dictionary <string, string> >();
            LogCollectorUtils.sCategorySubcategoryMappingWithDropdown = new Dictionary <string, Dictionary <string, string> >();
            for (int index1 = 0; index1 < categoryList.Count; ++index1)
            {
                Category category = categoryList[index1];
                LogCollectorUtils.sProblemCategories[index1] = category.categoryValue;
                LogCollectorUtils.sStringConversions.Add((object)category.categoryValue, (object)category.categoryId);
                LogCollectorUtils.sCategoryShowDropdownMapping.Add(category.categoryId, category.showdropdown);
                if (category.Subcategory != null && category.Subcategory.Count > 0)
                {
                    Dictionary <string, string> dictionary1     = new Dictionary <string, string>();
                    Dictionary <string, string> dictionary2     = new Dictionary <string, string>();
                    List <Subcategory>          subcategoryList = new List <Subcategory>((IEnumerable <Subcategory>)category.Subcategory);
                    for (int index2 = 0; index2 < subcategoryList.Count; ++index2)
                    {
                        dictionary1.Add(subcategoryList[index2].subcategoryId, subcategoryList[index2].subcategoryValue);
                        dictionary2.Add(subcategoryList[index2].subcategoryId, subcategoryList[index2].showdropdown);
                    }
                    LogCollectorUtils.sCategorySubcategoryMapping.Add(category.categoryId, dictionary1);
                    LogCollectorUtils.sCategorySubcategoryMappingWithDropdown.Add(category.categoryId, dictionary2);
                }
            }
        }
예제 #2
0
        internal static void GetCategoryJSON(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            Logger.Info("Getting categories");
            string api        = string.Format((IFormatProvider)CultureInfo.CurrentCulture, "{0}?oem={1}&version={2}&locale={3}", (object)"/app_settings/problem_categories", (object)Oem.Instance.OEM, (object)"4.250.0.1070", (object)LocaleStrings.GetLocaleName(MultiInstanceStrings.VmName, false));
            string jsonString = "";

            try
            {
                jsonString = HTTPUtils.SendRequestToCloud(api, (Dictionary <string, string>)null, MultiInstanceStrings.VmName, 0, (Dictionary <string, string>)null, false, 1, 0, false);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed in fetching problem categories... Err : " + ex.ToString());
            }
            LogCollectorUtils.sStringConversions           = new Hashtable();
            LogCollectorUtils.sCategoryShowDropdownMapping = new Dictionary <string, string>();
            if (string.IsNullOrEmpty(jsonString))
            {
                LogCollectorUtils.SetDefaultCategoriesFromJson();
            }
            else
            {
                try
                {
                    LogCollectorUtils.SetConversions(jsonString);
                }
                catch (Exception ex)
                {
                    Logger.Error("Failed in parsing json string received from cloud... Err : " + ex.ToString());
                    Logger.Error("setting default categories/subcategories");
                    LogCollectorUtils.SetDefaultCategoriesFromJson();
                }
            }
            if (LogCollectorUtils.sProblemCategories == null)
            {
                return;
            }
            foreach (string sProblemCategory in LogCollectorUtils.sProblemCategories)
            {
                Logger.Info(sProblemCategory);
            }
            MainWindow.Instance.Dispatcher.Invoke((Delegate)(() => MainWindow.Instance.AddCategories()));
        }
예제 #3
0
        public static ProblemCategory GetLocalizationForProblemCategory(string vmName)
        {
            ProblemCategory problemCategory = new ProblemCategory();
            string          str             = Thread.CurrentThread.CurrentCulture.Name;
            string          locale          = RegistryManager.Instance.Guest[vmName].Locale;

            if (!string.IsNullOrEmpty(locale))
            {
                str = locale;
            }
            if (string.Compare(str, "en-US", StringComparison.Ordinal) != 0 && LogCollectorUtils.PopulateLocaleProblemCategories(str, problemCategory))
            {
                Logger.Info("Successfully populated localized strings for Problem Categories for locale: " + str);
            }
            else if (LogCollectorUtils.PopulateLocaleProblemCategories("en-US", problemCategory))
            {
                Logger.Info("Successfully populated English strings for Problem Categories");
            }
            return(problemCategory);
        }
예제 #4
0
 public MainWindow(bool quickLogs)
 {
     this.mQuickLogs     = quickLogs;
     MainWindow.Instance = this;
     this.InitializeComponent();
     this.Title = LocaleStrings.GetLocalizedString("STRING_BST_SUPPORT_UTILITY", "");
     this.mEmailTextBox.Text = RegistryManager.Instance.RegisteredEmail;
     this.AddAsteriskToMandatoryFields();
     try
     {
         ImageBehavior.SetAnimatedSource(this.mLoadingImage, (ImageSource) new BitmapImage(new Uri(Path.Combine(RegistryStrings.InstallDir, "loadingCircles.gif"))));
     }
     catch (Exception ex)
     {
         Logger.Warning("Couldn't set loading GIF, Ex: {0}", (object)ex);
     }
     LogCollectorUtils.GetCategoriesInBackground();
     this.Loaded  += new RoutedEventHandler(this.MainWindow_Loaded);
     this.Closing += new CancelEventHandler(this.MainWindow_Closing);
     this.mAlIOemsCheckbox.Visibility = this.mHelpIcon.Visibility = App.sOemApplicableForLogCollection.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
 }