Example #1
0
        public SUUpdatePermissionPromptViewController(SUHost host)
            : base(new SUUpdatePermissionPromptView())
        {
            Host = host;
            UpdateHeaderDescription.Text = String.Format(SULocalizedStrings.StringForKey("Update Automatically Prompt Header"),
                                                         Host.Name, SULocalizedStrings.StringForKey("Help"));
            IconView.Source = host.LargeIcon;
            ExtendedInfoContainer.Expanded  += ExpandWindow;
            ExtendedInfoContainer.Collapsed += CollapseWindow;
            ExtendedInfoContainer.IsExpanded = false;
            oldHeight = 150;

            string systemInfo = "";

            try {
                foreach (Dictionary <string, string> item in SUSystemProfiler.SystemProfileForHost(host))
                {
                    systemInfo = String.Concat(systemInfo, item.ValueForKey(SUConstants.SUProfileItemDisplayKeyKey), ": ",
                                               item.ValueForKey(SUConstants.SUProfileItemDisplayValueKey), Environment.NewLine);
                }

                InfoBox.Text = systemInfo;
            } catch (Exception e) {
                if (e is System.Runtime.InteropServices.COMException || e is System.Management.ManagementException)
                {
                    InfoBox.Text = SULocalizedStrings.StringForKey("Profile Generation Error");
                }
                else
                {
                    throw e;
                }
            }
        }
Example #2
0
        private string ParameterizedFeedURL()
        {
            // Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such.

            if (!SendsSystemProfile || !LastProfileSubmitWasMoreThanAWeekAgo())
            {
                return(FeedURL);
            }
            else
            {
                host.LastProfileSubmitDate = DateTime.Now;

                List <string> parameterStrings = new List <string>();

                try {
                    foreach (Dictionary <string, string> item in SUSystemProfiler.SystemProfileForHost(host))
                    {
                        parameterStrings.Add(String.Format("{0}={1}",
                                                           Uri.EscapeUriString((string)item.ValueForKey(SUConstants.SUProfileItemKeyKey)),
                                                           Uri.EscapeUriString((string)item.ValueForKey(SUConstants.SUProfileItemValueKey))));
                    }
                } catch (Exception e) {
                    if (e is System.Runtime.InteropServices.COMException)
                    {
                        return(FeedURL);
                    }
                    else
                    {
                        throw e;
                    }
                }

                if (parameterStrings.Count > 0)
                {
                    string url     = FeedURL;
                    string divider = "?";

                    if (url.Contains("?"))
                    {
                        // Just in case the url already contains a query
                        divider = "&";
                    }

                    foreach (string item in parameterStrings)
                    {
                        url     = string.Concat(url, divider, item);
                        divider = "&";
                    }

                    return(url);
                }
                else
                {
                    return(FeedURL);
                }
            }
        }