Example #1
0
 private static Try <MissingMsUpdatesInfo> TryGetMissingUpdates() => () =>
 {
     var missingUpdates =
         F.RunPowerShell(new Some <Func <PowerShell, Collection <PSObject> > >(powerShell =>
                                                                               powerShell
                                                                               .AddCommand("Get-WmiObject")
                                                                               .AddParameter("NameSpace", @"ROOT\ccm\ClientSDK")
                                                                               .AddParameter("Class", "CCM_SoftwareUpdate")
                                                                               .Invoke())
                         );
     var missingUpdatesInfo = new MissingMsUpdatesInfo();
     foreach (var missingUpdate in missingUpdates)
     {
         dynamic mu = missingUpdate;
         missingUpdatesInfo.Updates.Add(new MsUpdate {
             ArticleId = mu.ArticleID, Name = mu.Name, Deadline = mu.Deadline, FirstMeasuredMissing = DateTime.Now
         });
     }
     return(new Result <MissingMsUpdatesInfo>(missingUpdatesInfo));
 };
Example #2
0
        public static MissingMsUpdatesInfo Update(this MissingMsUpdatesInfo previousInfo, Some <MissingMsUpdatesInfo> currentInfo)
        {
            if (previousInfo == null)
            {
                throw new ArgumentNullException(nameof(previousInfo));
            }
            if (currentInfo.Value.Updates.Count == 0)
            {
                return(MissingMsUpdatesInfo.Default);
            }
            if (previousInfo.Updates.Count == 0)
            {
                return(currentInfo);
            }

            var updatedInfo = MissingMsUpdatesInfo.Default;

            var existingUpdates =
                currentInfo.Value
                .Updates
                .Where(update => previousInfo.Updates.Any(msUpdate => update.ArticleId == msUpdate.ArticleId))
                .Select(currentUpdate =>
            {
                var previousUpdate = previousInfo.Updates.First(msUpdate => currentUpdate.ArticleId == msUpdate.ArticleId);
                return(new MsUpdate()
                {
                    ArticleId = currentUpdate.ArticleId, Deadline = currentUpdate.Deadline, Name = currentUpdate.Name, FirstMeasuredMissing = previousUpdate.FirstMeasuredMissing
                });
            });
            var newUpdates = currentInfo.Value.Updates.Where(update => previousInfo.Updates.All(msUpdate => update.ArticleId != msUpdate.ArticleId));

            updatedInfo.Updates.AddRange(existingUpdates);
            updatedInfo.Updates.AddRange(newUpdates);
            return(updatedInfo);

            throw new NotImplementedException();
        }
Example #3
0
        private static ActionDismissToastContentInfo GetCheckMissingMsUpdatesToastContentInfo(Some <NotificationProfile> notificationProfile, string groupName, MissingMsUpdatesInfo info)
        {
            var title                = strings.MissingMsUpdatesTitle;
            var content              = string.Format(CultureInfo.InvariantCulture, strings.MissingUpdatesContent_F0, info.Updates.Count);
            var missingUpdateKbs     = string.Join(Environment.NewLine, info.Updates.Select(u => "\tKB" + u.ArticleId).ToArray()) + Environment.NewLine;
            var content2             = string.Format(CultureInfo.InvariantCulture, strings.MissingUpdatesContent2_F0, Environment.NewLine + missingUpdateKbs);
            var action               = ToastActions.TroubleShootWindowsUpdate;
            var actionActivationType = ToastActivationType.Foreground;
            var greeting             = F.GetGreeting(notificationProfile);

            return(new ActionDismissToastContentInfo(greeting, title, content, content2, action, actionActivationType, strings.MissingMsUpdates_Troubleshooting_ButtonContent, strings.NotNowActionButtonContent, ToastActions.Dismiss, groupName, Option <string> .None, notificationProfile.Value.CompanyName));
        }
Example #4
0
 public static async Task <Result <ToastNotificationVisibility> > ShowMissingUpdatesToastNotification(Some <NotificationProfile> userProfile, string tag, string groupName, MissingMsUpdatesInfo info)
 {
     return(await ToastHelper.ShowToastNotification(async() =>
     {
         var toastContentInfo = GetCheckMissingMsUpdatesToastContentInfo(userProfile, groupName, info);
         var toastContent = await ActionDismissToastContent.CreateToastContent(toastContentInfo).ConfigureAwait(true);
         return toastContent;
     }, tag, groupName).ConfigureAwait(false));
 }