예제 #1
0
        private static void QueryKey(RegistryKey key)
        {
            SoftwareEntry e = new SoftwareEntry();

            try
            {
                e.DisplayName = key.GetValue("DisplayName").ToString();
            }
            catch (Exception)
            {
                return;
            }

            try
            {
                e.InstallDate = key.GetValue("InstallDate").ToString();
            }
            catch (Exception)
            {
                e.InstallDate = "N/A";
            }

            try
            {
                e.DisplayVersion = key.GetValue("DisplayVersion").ToString();
            }
            catch (Exception)
            {
                e.DisplayVersion = "N/A";
            }

            try
            {
                if (!SoftwareList.ContainsKey(e.DisplayName))
                {
                    // If the software entry doesn't already exist, add it.
                    SoftwareList.Add(e.DisplayName, e);
                }
                else
                {
                    // If the software entry exists, merge the data with the
                    // existing entry.
                    SoftwareEntry e2 = (SoftwareEntry)SoftwareList[e.DisplayName];

                    if (e2.InstallDate == "N/A")
                    {
                        e2.InstallDate = e.InstallDate;
                    }
                    if (e2.DisplayVersion == "N/A")
                    {
                        e2.DisplayVersion = e.DisplayVersion;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        public void UpdateReasoning(SoftwareEntry entity)
        {
            var original = context.SoftwareEntries.FirstOrDefault(x => x.Id == entity.Id);

            original.Reasoning            = entity.Reasoning;
            context.Entry(original).State = System.Data.Entity.EntityState.Modified;
            Save();
            PushEventLog(
                $"Updated reasoning on entry | ID: {entity.Id}",
                EventLogEntryType.Information,
                222);
        }
예제 #3
0
 public IHttpActionResult Reasoning(int id, [FromBody] SoftwareEntry softwareEntry)
 {
     if (ModelState.IsValid)
     {
         SoftwareEntryRepo.UpdateReasoning(softwareEntry);
         return(Content(HttpStatusCode.OK, SoftwareEntryRepo.Find(softwareEntry.Id)));
     }
     else
     {
         return(BadRequest());
     }
 }
예제 #4
0
 public IHttpActionResult Update(int id, [FromBody] SoftwareEntry softwareEntry)
 {
     if (ModelState.IsValid)
     {
         SoftwareEntryRepo.InsertOrUpdate(softwareEntry);
         return(Content(HttpStatusCode.OK, softwareEntry));
     }
     else
     {
         return(BadRequest());
     }
 }
예제 #5
0
        public IHttpActionResult Create([FromBody] SoftwareEntry softwareEntry)
        {
            if (ModelState.IsValid)
            {
                var userName = User.Identity.Name;

                softwareEntry.TimeStamp = DateTime.Now;
                softwareEntry.CreatedBy = userName;
                SoftwareEntryRepo.InsertOrUpdate(softwareEntry);
                return(Content(HttpStatusCode.Created, softwareEntry));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #6
0
 public void InsertOrUpdate(SoftwareEntry entity)
 {
     if (entity.Id == default(int))
     {
         // New entity
         context.SoftwareEntries.Add(entity);
         Save();
         PushEventLog(
             $"Added new entry{StringUtils.Repeat(_NEWLINE_, 2) + EventLogger.FormatEntry(entity)}",
             EventLogEntryType.Information,
             220);
     }
     else
     {
         // Existing entity
         context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         Save();
         PushEventLog(
             $"Updated entry | ID: {entity.Id}",
             EventLogEntryType.Information,
             221);
     }
 }
예제 #7
0
        public void Seed()
        {
            if (this._context.LogEntries.Count() <= 0)
            {
                for (int i = 0; i < logEntries.Length; i++)
                {
                    var entryInfo = SplitValue(logEntries[i]);
                    var entry     = new LogEntry
                    {
                        UserName           = entryInfo[0],
                        ComputerName       = entryInfo[1],
                        Ip                 = entryInfo[2],
                        ProgramDescription = entryInfo[3],
                        RapportDescription = entryInfo[4],
                        TimeStamp          = DateTime.Today,
                        Note               = null,
                        EditedBy           = null
                    };

                    this._context.LogEntries.Add(entry);
                }
            }

            if (this._context.Approvals.Count() <= 0)
            {
                for (int i = 0; i < approvals.Length; i++)
                {
                    var entryInfo = SplitValue(approvals[i]);
                    var entry     = new Approval
                    {
                        UserName  = entryInfo[0],
                        Reasoning = entryInfo[1],
                        TimeStamp = DateTime.Now,
                        Approver  = entryInfo[2]
                    };

                    this._context.Approvals.Add(entry);
                    this._context.SaveChanges();

                    var groupEntry = new AssignedUserGroup
                    {
                        ApprovalID = entry.ID,
                        Group      = entryInfo[3]
                    };
                    this._context.AssignedUserGroups.Add(groupEntry);
                    this._context.SaveChanges();
                }
            }

            if (this._context.SoftwareEntries.Count() <= 0)
            {
                for (int i = 0; i < softwareEntries.Length; i++)
                {
                    var entryInfo = SplitValue(softwareEntries[i]);
                    var entry     = new SoftwareEntry
                    {
                        Name      = entryInfo[0],
                        Vendor    = entryInfo[1],
                        Reasoning = entryInfo[2],
                        TimeStamp = DateTime.Now,
                        CreatedBy = entryInfo[3],
                        State     = entryInfo[4]
                    };
                    this._context.SoftwareEntries.Add(entry);
                    this._context.SaveChanges();
                }
            }
        }
예제 #8
0
        private static void DisplaySoftwareList()
        {
            if (WriteToFile)
            {
                file.WriteLine("Computer Name: " + ComputerName);

                if (OutputPath.Length > 0)
                {
                    file.WriteLine("Output Path:   " + OutputPath);
                }

                if (x64)
                {
                    file.WriteLine("Architecture:  64-bit");
                }
                else
                {
                    file.WriteLine("Architecture:  32-bit");
                }

                file.WriteLine("----------------------------------------------------");
                file.WriteLine();
                file.WriteLine("{0,-20}Program Name", "Install Date");
                file.WriteLine();

                for (int i = 0; i < SoftwareList.Count; i++)
                {
                    SoftwareEntry e = (SoftwareEntry)SoftwareList.GetByIndex(i);

                    file.WriteLine("{0,-20}{1} -- {2}", e.InstallDate, e.DisplayName, e.DisplayVersion);
                }
            }
            else
            {
                Console.WriteLine("Computer Name: " + ComputerName);

                if (OutputPath.Length > 0)
                {
                    Console.WriteLine("Output Path:   " + OutputPath);
                }

                if (x64)
                {
                    Console.WriteLine("Architecture:  64-bit");
                }
                else
                {
                    Console.WriteLine("Architecture:  32-bit");
                }

                Console.WriteLine("----------------------------------------------------");
                Console.WriteLine();
                Console.WriteLine("{0,-20}Program Name", "Install Date");
                Console.WriteLine();

                for (int i = 0; i < SoftwareList.Count; i++)
                {
                    SoftwareEntry e = (SoftwareEntry)SoftwareList.GetByIndex(i);

                    Console.WriteLine("{0,-20}{1} -- {2}", e.InstallDate, e.DisplayName, e.DisplayVersion);
                }
            }
        }
예제 #9
0
        private static void QueryKey(RegistryKey key)
        {
            SoftwareEntry e = new SoftwareEntry();

            try
            {
                e.DisplayName = key.GetValue("DisplayName").ToString();
            }
            catch (Exception)
            {
                return;
            }

            try
            {
                e.InstallDate = key.GetValue("InstallDate").ToString();
            }
            catch (Exception)
            {
                e.InstallDate = "N/A";
            }

            try
            {
                e.DisplayVersion = key.GetValue("DisplayVersion").ToString();
            }
            catch (Exception)
            {
                e.DisplayVersion = "N/A";
            }

            try
            {
                if (!SoftwareList.ContainsKey(e.DisplayName))
                {
                    // If the software entry doesn't already exist, add it.
                    SoftwareList.Add(e.DisplayName, e);
                }
                else
                {
                    // If the software entry exists, merge the data with the
                    // existing entry.
                    SoftwareEntry e2 = (SoftwareEntry)SoftwareList[e.DisplayName];

                    if (e2.InstallDate == "N/A") e2.InstallDate = e.InstallDate;
                    if (e2.DisplayVersion == "N/A") e2.DisplayVersion = e.DisplayVersion;
                }
            }
            catch (Exception)
            {
            }
        }