public async Task OnGetAsync() { HttpContext.Session.SetString("NoAccess", ""); int count = 1; foreach (Server item in _context.Server) { isItTho.Add(false); if (item.Index != count) { item.Index = count; } count++; } _context.SaveChanges(); IQueryable <string> Query = from m in _context.Server orderby m.Index select m.ServerName; ServerList = new SelectList(Query.Distinct().ToList()); Server = await _context.Server.ToListAsync(); }
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(); } }
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(); } }
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(); } }