Ejemplo n.º 1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new UpdateHistoryContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <UpdateHistoryContext> >()))
            {
                if (!context.Server.Any())
                {
                    return;   // DB has been seeded
                }

                foreach (Server item in context.Server)
                {
                    try
                    {
                        Type          t       = Type.GetTypeFromProgID("Microsoft.Update.Session", item.Location); //wcswapp01.intellig.local     OH0KLT733D7S2.global.ds.honeywell.com     labengdemctl00.labmasoh.local  wcbuildapp02.intellig.local
                        UpdateSession session = (UpdateSession)Activator.CreateInstance(t);
                        item.NoAccess = false;
                    }
                    catch
                    {
                        item.NoAccess = true;
                    }
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new UpdateHistoryContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <UpdateHistoryContext> >()))
            {
                if (context.Server.Any())
                {
                    //##### Remove coments to delete all items from Server List

                    /*foreach (Server item in context.Server)
                     * {
                     *  context.Server.Remove(item);
                     * }*/

                    return;   // DB has been seeded
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 public DetailsModel(UpdateHistory.Models.UpdateHistoryContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public EditModel(UpdateHistory.Models.UpdateHistoryContext context)
 {
     _context = context;
 }
Ejemplo n.º 5
0
 public IndexModel(UpdateHistory.Models.UpdateHistoryContext context)
 {
     _context = context;
 }
Ejemplo n.º 6
0
 public DeleteModel(UpdateHistory.Models.UpdateHistoryContext context)
 {
     _context = context;
 }
Ejemplo n.º 7
0
        public static void Initialize(IServiceProvider serviceProvider, List <bool> selServers)
        {
            using (var context = new UpdateHistoryContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <UpdateHistoryContext> >()))
            {
                if (context.Info.Any())
                {
                    //##### Remove coments to delete all items from Info List

                    /*foreach (Info item in context.Info)
                     * {
                     *  context.Info.Remove(item);
                     * }*/

                    //return;   // DB has been seeded
                }
                context.SaveChanges();

                IList <Info> List    = new List <Info>();
                Extract      extract = new Extract();

                int count = 0;
                foreach (Server server in context.Server)
                {
                    if (selServers[count] == true)
                    {
                        if (server.Initiated == false)
                        {
                            List             = extract.ExtractRun(server, false);
                            server.Initiated = true;
                        }
                        else
                        {
                            List = extract.ExtractRun(server, true);
                        }

                        foreach (Info item in List)
                        {
                            bool match = false;
                            foreach (Info itemKB in context.Info)
                            {
                                if ((item.LastReleased == itemKB.LastReleased) && (item.KBID == itemKB.KBID) && (item.Title == itemKB.Title) && (item.updateID == itemKB.updateID) && (item.UpdateStatus == itemKB.UpdateStatus) && (item.Server == itemKB.Server) && (item.ICW == itemKB.ICW))
                                {
                                    match = true;
                                    break;
                                    //context.Info.Remove(itemKB);
                                }
                            }
                            if (match == false)
                            {
                                context.Info.Add(
                                    new Info
                                {
                                    Active             = "Yes",
                                    KBID               = item.KBID,
                                    Title              = item.Title,
                                    ICW                = item.ICW,
                                    Server             = item.Server,
                                    MSRCSeverity       = item.MSRCSeverity,
                                    TestDate           = item.TestDate,
                                    Classification     = item.Classification,
                                    Architecture       = item.Architecture,
                                    SupportedProducts  = item.SupportedProducts,
                                    MSRCNumber         = item.MSRCNumber,
                                    updateID           = item.updateID,
                                    SupportedLanguages = item.SupportedLanguages,
                                    TestResults        = item.TestResults,
                                    LastReleased       = item.LastReleased,
                                    UpdateStatus       = item.UpdateStatus,
                                    Reason             = "",
                                    ID = item.ID
                                }
                                    );
                            }
                        }
                    }
                    count++;
                }
                context.SaveChanges();
            }
        }