public int ProcessScheduleDataUpdate(Prb_ScheduleRequest request) { ProbeDBEntities _Db = DBHelper.Instance._Db;; try { Prb_SiteResponse response = new Prb_SiteResponse(); var _Prb_Schedule = (from s in _Db.Prb_Schedule where s.ScheduleId == request.Prb_Schedule.ScheduleId && s.IsDeleted == false select s).FirstOrDefault(); if (_Prb_Schedule != null) { _Prb_Schedule.StatusId = request.Prb_Schedule.StatusId; _Prb_Schedule.EndDateTime = request.Prb_Schedule.EndDateTime; _Prb_Schedule.ModifiedBy = 1; _Prb_Schedule.ModifiedDate = DateTime.Now; _Db.SaveChanges(); } return(Convert.ToInt32(_Prb_Schedule.ScheduleId.ToString())); } catch (Exception ex) { // throw ex; return(0); } }
public int ProcessScheduleDataAdd(Prb_ScheduleRequest request) { ProbeDBEntities _Db = DBHelper.Instance._Db;; try { Prb_Schedule _Prb_Schedule = new Prb_Schedule() { SiteId = request.Prb_Schedule.SiteId, //ScheduleId = request.Prb_Schedule.ScheduleId, SettingId = request.Prb_Schedule.SettingId, StartDateTime = request.Prb_Schedule.StartDateTime, EndDateTime = request.Prb_Schedule.EndDateTime, Description = request.Prb_Schedule.Description, StatusId = request.Prb_Schedule.StatusId, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Prb_Schedule.Add(_Prb_Schedule); _Db.SaveChanges(); return(Convert.ToInt32(_Prb_Schedule.ScheduleId.ToString())); } catch (Exception ex) { throw ex; // return 0; } }
public void UpdateIsRead(int settingId) { ProbeDBEntities _Db = DBHelper.Instance._Db;; var setting = (from s in _Db.Prb_Setting where s.SettingId == settingId select s).FirstOrDefault(); setting.IsRead = 1; _Db.Entry(setting).State = System.Data.Entity.EntityState.Modified; _Db.SaveChanges(); }
public void AddProbeFailure(Prb_ADConnectionFailureDTO obj) { Prb_ADConnectionFailure data = new Prb_ADConnectionFailure(); ProbeDBEntities _Db = DBHelper.Instance._Db;; try { data.SettingId = obj.SettingId; data.FailureReason = obj.Description; _Db.Prb_ADConnectionFailure.Add(data); _Db.SaveChanges(); } catch (Exception e) { } }
public int AddProbeSetting(Prb_SettingDTO obj) { ProbeDBEntities _Db = DBHelper.Instance._Db;// DBHelper.Instance._Db;; try { data.SiteId = obj.SiteId; data.DomainName = obj.CustomerName; data.DomainAdminUser = obj.DomainAdminUser; data.Password = obj.Password; data.DomainType = obj.DomainType; data.WindowsAccess = obj.WindowsAccess; data.MacAccess = obj.MacAccess; data.LinuxAccess = obj.LinuxAccess; data.PrintersAccess = obj.PrintersAccess; data.RoutersSwitchesAccess = obj.RoutersSwitchesAccess; data.OthersAccess = obj.OthersAccess; data.HardwareDetail = obj.HardwareDetail; data.SoftwareDetail = obj.SoftwareDetail; data.CreatedDate = DateTime.Now; data.ModifiedDate = DateTime.Now; data.CreatedBy = 0; data.ModifiedBy = 0; data.IsActive = true; data.IsDeleted = false; data.IsRead = 0; data.ProbeRunningMachine = Environment.MachineName; data.ProbeRunningDomain = Environment.UserDomainName; _Db.Prb_Setting.Add(data); _Db.SaveChanges(); // Probe Site Data return(Convert.ToInt32(data.SettingId.ToString())); } catch (Exception ex) { return(Convert.ToInt32(data.SettingId.ToString())); // return ex.Message; } }
public Hw_MasterInfoResponse Hw_MasterInfo_InsertData(List <Hw_MasterInfoDTO> LstHw_MasterInfoDTO) { Hw_MasterInfoResponse response = new Hw_MasterInfoResponse(); try { foreach (Hw_MasterInfoDTO datarow in LstHw_MasterInfoDTO) { datarow.StatusId = 1; Hw_MasterInfo _Prb_Schedule = new Hw_MasterInfo() { HwMasterInfoId = datarow.HwMasterInfoId, SiteId = datarow.SiteId, ScheduleId = datarow.ScheduleId, HwTypeId = datarow.HwTypeId, DevType = datarow.DevType, DevCategory = datarow.DevCategory, ComType = datarow.ComType, HwName = datarow.HwName, Description = datarow.Description, IPAddress = datarow.IPAddress, MacAddress = datarow.MacAddress, StatusId = datarow.StatusId, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_MasterInfo.Add(_Prb_Schedule); } _Db.SaveChanges(); return(response); } catch (Exception ex) { throw ex; } }
// Select Probe Setting public bool ProbeSettingUpdateStatusAfterComplete(Prb_SettingDTO obj) { ProbeDBEntities _Db = DBHelper.Instance._Db;; var ResData = (from s in _Db.Prb_Setting where s.IsActive == true && s.IsDeleted == false && s.SettingId == obj.SettingId select s).FirstOrDefault(); // Update Status After Probe Is running completed if (ResData != null) { ResData.IsActive = false; } try { _Db.SaveChanges(); return(true); } catch (Exception ex) { throw ex; return(false); } }
public DomainUsersInfoResponse UsersList_InsertData(List <DomainUsersInfo> usersList, int ScheduleId) { var Prb_Schedule = _Db.Prb_Schedule.Where(s => s.ScheduleId == ScheduleId).FirstOrDefault(); DomainUsersInfoResponse response = new DomainUsersInfoResponse(); try { if (usersList != null) { foreach (var datarow in usersList) { DomainUsersInfo _DomainUsersInfo = new DomainUsersInfo() { //DomainUsersInfoId = datarow.DomainUsersInfoId, SiteId = Prb_Schedule.SiteId, ScheduleId = ScheduleId, SamAccountName = datarow.SamAccountName, DisplayName = datarow.DisplayName, Name = datarow.Name, GivenName = datarow.GivenName, Surname = datarow.Surname, Description = datarow.Description, Enabled = datarow.Enabled, EmployeeId = datarow.EmployeeId, LastPasswordSet = datarow.LastPasswordSet, LastBadPasswordAttempt = datarow.LastBadPasswordAttempt, LastLogon = datarow.LastLogon, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.DomainUsersInfoes.Add(_DomainUsersInfo); try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion Dmoain Users. Message: " + ex.Message); } } try { _Db.SaveChanges(); return(response); } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion Dmoain Users. Message: " + ex.Message); // WriteTextFile.WriteErrorLog(". Exception On Data Inserstion for Hw_DetailInfo IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } } } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion Dmoain Users. Message: " + ex.Message); // WriteTextFile.WriteErrorLog(". Exception On Data Inserstion for Hw_DetailInfo IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } return(response); }
public Hw_DetailInfoResponse Hw_DetailInfo_InsertData(Hw_DetailInfoDTO datarow) { Hw_DetailInfoResponse response = new Hw_DetailInfoResponse(); try { //foreach (Hw_DetailInfoDTO datarow in LstHw_DetailInfoDTO) //{ Hw_MasterInfo _Hw_MasterInfo = _Db.Hw_MasterInfo.Where(x => x.IPAddress == datarow.IPAddress && x.IsDeleted == false).OrderByDescending(x => x.HwMasterInfoId).FirstOrDefault(); if (_Hw_MasterInfo != null) { _Hw_MasterInfo.StatusId = 4; // Status set for system not connected or Exception if (datarow.isConnected && (datarow.HwCaption != "" || datarow.HwDescription != "")) { _Hw_MasterInfo.StatusId = 3; // Status set for system connected and Scaning Completed datarow.HwMasterInfoId = Convert.ToInt32(_Hw_MasterInfo.HwMasterInfoId.ToString()); // Hardware MasterId Hw_DetailInfo _Hw_DetailInfo = new Hw_DetailInfo() { //HwDetailInfoId = 1, HwMasterInfoId = datarow.HwMasterInfoId, // Get HwMasterInfoId From Hw_MasterInfo HwManufacturer = datarow.HwManufacturer, HwCaption = datarow.HwCaption, HwDescription = datarow.HwDescription, HwSerialNo = datarow.HwSerialNo, HwStatus = datarow.HwStatus, HwVersion = datarow.HwVersion, HwModelNo = datarow.HwModelNo, IPAddress = datarow.IPAddress, HwSystemType = datarow.HwSystemType, HwPartNo = datarow.HwPartNo, OS = datarow.OS, Processor = datarow.Processor, PhysicalMemory = datarow.PhysicalMemory, NoOfProcessors = datarow.NoOfProcessors, NoOfLogicalProcessors = datarow.NoOfLogicalProcessors, DNSHostName = datarow.DNSHostName, DomainName = datarow.DomainName, CurrentTimeZone = datarow.CurrentTimeZone, CurrentLanguages = datarow.CurrentLanguages, ListOfAvailableLanguages = datarow.ListOfAvailableLanguages, InstalableLanguage = datarow.InstalableLanguage, BiosName = datarow.BiosName, BiosVersion = datarow.BiosVersion, BiosSerialNo = datarow.BiosSerialNo, BiosStatus = datarow.BiosStatus, BiosDisplayConfiguration = datarow.BiosDisplayConfiguration, UserName = datarow.UserName, VmInstanceName = datarow.VmInstanceName, VmInstanceStatus = datarow.VmInstanceStatus, IsVirtual = datarow.IsVirtual, IsServerRole = datarow.IsServerRole, WebServer = datarow.WebServer, MailServer = datarow.MailServer, CMS_SharePoint = datarow.CMS_SharePoint, DatabaseServer = datarow.DatabaseServer, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_DetailInfo.Add(_Hw_DetailInfo); try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion for Hw_DetailInfo IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); // WriteTextFile.WriteErrorLog(". Exception On Data Inserstion for Hw_DetailInfo IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } if (datarow.LstHw_Sw_ServicesDTO != null) { foreach (var RowLstSerivces in datarow.LstHw_Sw_ServicesDTO) { Hw_Sw_Services _Hw_Sw_Services = new Hw_Sw_Services() { HwMasterInfoId = datarow.HwMasterInfoId, // Get HwMasterInfoId From Hw_MasterInfo //SwServiceId = RowLstSerivces.HwMasterInfoId, Caption = RowLstSerivces.Caption, Name = RowLstSerivces.Name, DisplayName = RowLstSerivces.DisplayName, Description = RowLstSerivces.Description, PathName = RowLstSerivces.PathName, ServiceType = RowLstSerivces.ServiceType, Started = RowLstSerivces.Started, StartMode = RowLstSerivces.StartMode, StartName = RowLstSerivces.StartName, State = RowLstSerivces.State, Status = RowLstSerivces.Status, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_Sw_Services.Add(_Hw_Sw_Services); } try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion for Hw_Sw_Services IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); // WriteTextFile.WriteErrorLog(". Exception On Data Inserstion for Hw_Sw_Services IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } } if (datarow.LstHw_Sw_RunningDTO != null) { foreach (var RowLstInstalledSoftwares in datarow.LstHw_Sw_RunningDTO) { if (RowLstInstalledSoftwares.InstalledDate.Year < 1900) { RowLstInstalledSoftwares.InstalledDate = DateTime.ParseExact("1900-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture); } if (RowLstInstalledSoftwares.SwDateModified.Year < 1900) { RowLstInstalledSoftwares.SwDateModified = DateTime.ParseExact("1900-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture); } Hw_Sw_Running _Hw_Sw_Running = new Hw_Sw_Running() { // SwInstalledId = datarow.SwInstalledId, HwMasterInfoId = datarow.HwMasterInfoId, // Get HwMasterInfoId From Hw_MasterInfo SwName = RowLstInstalledSoftwares.SwName, SwDescription = RowLstInstalledSoftwares.SwDescription, SwType = RowLstInstalledSoftwares.SwType, SwVersion = RowLstInstalledSoftwares.SwVersion, ProductName = RowLstInstalledSoftwares.ProductName, ProductVersion = RowLstInstalledSoftwares.ProductVersion, CopyRight = RowLstInstalledSoftwares.CopyRight, Size = RowLstInstalledSoftwares.Size, // SwDateModified = RowLstInstalledSoftwares.SwDateModified, Exception: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Language = RowLstInstalledSoftwares.Language, SerialNo = RowLstInstalledSoftwares.SerialNo, LicenceNo = RowLstInstalledSoftwares.LicenceNo, LicenceType = RowLstInstalledSoftwares.LicenceType, InstalledDate = RowLstInstalledSoftwares.InstalledDate, SwDateModified = RowLstInstalledSoftwares.SwDateModified, PathName = RowLstInstalledSoftwares.PathName, Status = RowLstInstalledSoftwares.Status, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_Sw_Running.Add(_Hw_Sw_Running); } try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(". Exception On Data Inserstion for Hw_Sw_Running IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); // WriteTextFile.WriteErrorLog(". Exception On Data Inserstion for Hw_Sw_Running IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } } if (datarow.LstHw_Sw_InstalledDTO != null) { foreach (var RowLstInstalledSoftwares in datarow.LstHw_Sw_InstalledDTO) { if (RowLstInstalledSoftwares.InstalledDate.Year < 1900) { RowLstInstalledSoftwares.InstalledDate = DateTime.ParseExact("1900-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture); } if (RowLstInstalledSoftwares.SwDateModified.Year < 1900) { RowLstInstalledSoftwares.SwDateModified = DateTime.ParseExact("1900-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture); } Hw_Sw_Installed _Hw_Sw_Installed = new Hw_Sw_Installed() { // SwInstalledId = datarow.SwInstalledId, HwMasterInfoId = datarow.HwMasterInfoId, // Get HwMasterInfoId From Hw_MasterInfo SwName = RowLstInstalledSoftwares.SwName, SwDescription = RowLstInstalledSoftwares.SwDescription, SwType = RowLstInstalledSoftwares.SwType, SwVersion = RowLstInstalledSoftwares.SwVersion, ProductName = RowLstInstalledSoftwares.ProductName, ProductVersion = RowLstInstalledSoftwares.ProductVersion, CopyRight = RowLstInstalledSoftwares.CopyRight, Size = RowLstInstalledSoftwares.Size, // SwDateModified = RowLstInstalledSoftwares.SwDateModified, Exception: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. Language = RowLstInstalledSoftwares.Language, SerialNo = RowLstInstalledSoftwares.SerialNo, LicenceNo = RowLstInstalledSoftwares.LicenceNo, LicenceType = RowLstInstalledSoftwares.LicenceType, InstalledDate = RowLstInstalledSoftwares.InstalledDate, SwDateModified = RowLstInstalledSoftwares.SwDateModified, PathName = RowLstInstalledSoftwares.PathName, Status = RowLstInstalledSoftwares.Status, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_Sw_Installed.Add(_Hw_Sw_Installed); } try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine("Exception On Data Inserstion for Hw_Sw_Installed IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); // WriteTextFile.WriteErrorLog("Exception On Data Inserstion for Hw_Sw_Installed IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } } // Ip-Mac List Info if (datarow.LstHw_IpMacAddressDTO != null) { foreach (var RowLstIpMacAddress in datarow.LstHw_IpMacAddressDTO) { Hw_IpMacAddress _Hw_Sw_IpMac = new Hw_IpMacAddress() { // SwInstalledId = datarow.SwInstalledId, HwMasterInfoId = datarow.HwMasterInfoId, // Get HwMasterInfoId From Hw_MasterInfo Caption = RowLstIpMacAddress.Caption, IpAddress = RowLstIpMacAddress.IpAddress, IPEnabled = RowLstIpMacAddress.IPEnabled, MacAddress = RowLstIpMacAddress.MacAddress, CreatedBy = 1, CreatedDate = DateTime.Now, ModifiedBy = 1, ModifiedDate = DateTime.Now, IsDeleted = false, }; _Db.Hw_IpMacAddress.Add(_Hw_Sw_IpMac); } } try { _Db.SaveChanges(); } catch (Exception ex) { Console.WriteLine("Exception On Data Inserstion for _Hw_Sw_IpMac IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); // WriteTextFile.WriteErrorLog("Exception On Data Inserstion for _Hw_Sw_IpMac IpAddress: " + datarow.IPAddress + " Message: " + ex.Message); } } _Db.SaveChanges(); } //} return(response); } catch (Exception ex) { Console.WriteLine("Exception On Data Inserstion for IP Address: " + datarow.IPAddress + " Message: " + ex.Message); return(null); } }