/// <summary> /// Insert data into NetworkDevices table /// </summary> /// <param name="DSObject">DominoServers object</param> /// <returns></returns> public bool InsertData(SNMPDevices SNMPObject) { bool Insert = false; try { DataTable SNMPDevicesDataTable = new DataTable(); string SqlQuery = "select ID from servertypes where servertype='SNMP Devices'"; SNMPDevicesDataTable = objAdaptor.FetchData(SqlQuery); if (SNMPDevicesDataTable.Rows.Count > 0) { SNMPObject.ServerTypeId = int.Parse(SNMPDevicesDataTable.Rows[0][0].ToString()); } SqlQuery = "INSERT INTO [SNMPDevices] (Description,Category,Port,Username,Password,[Scanning Interval]" + ",OffHoursScanInterval,Enabled,IncludeOnDashBoard,Location,ImageURL,Name,ResponseThreshold,RetryInterval,Address,LocationID,ServerTypeId,OID) " + "VALUES('" + SNMPObject.Description + "','" + SNMPObject.Category + "'," + SNMPObject.Port + ",'" + SNMPObject.Username + "','" + SNMPObject.Password + "'," + SNMPObject.ScanningInterval + "," + SNMPObject.OffHoursScanInterval + ",'" + SNMPObject.Enabled + "','" + SNMPObject.IncludeOnDashBoard + "', '" + SNMPObject.Location + "','" + SNMPObject.ImageURL + "','" + SNMPObject.Name + "'," + SNMPObject.ResponseThreshold + "," + SNMPObject.RetryInterval + ",'" + SNMPObject.Address + "'," + SNMPObject.LocationID + "," + SNMPObject.ServerTypeId + ",'" + SNMPObject.OID + "')"; Insert = objAdaptor.ExecuteNonQuery(SqlQuery); } catch { Insert = false; } finally { } return(Insert); }
public SNMPDevices GetData(SNMPDevices DCObject) { DataTable SNMPDevicesDataTable = new DataTable(); SNMPDevices ReturnObject = new SNMPDevices(); try { //string SqlQuery = "Select nd.*,t2.Location as LocationText from [SNMPDevices] nd INNER JOIN [Locations] t2 ON nd.[LocationID] = t2.[ID] where nd.ID=" + DCObject.ID.ToString(); string SqlQuery = "Select nd.*,t2.Location as LocationText,nm.Name as imagename from [SNMPDevices] nd INNER JOIN [Locations] t2 ON nd.[LocationID] = t2.[ID] Inner join NetworkMaster nm on nd.ImageURL=nm.Image where nd.ID=" + DCObject.ID.ToString(); SNMPDevicesDataTable = objAdaptor.FetchData(SqlQuery); //populate & return data object ReturnObject.Password = SNMPDevicesDataTable.Rows[0]["Password"].ToString(); ReturnObject.Location = SNMPDevicesDataTable.Rows[0]["Location"].ToString(); ReturnObject.ImageURL = SNMPDevicesDataTable.Rows[0]["ImageURL"].ToString(); ReturnObject.imagename = SNMPDevicesDataTable.Rows[0]["imagename"].ToString(); ReturnObject.LocationID = int.Parse(SNMPDevicesDataTable.Rows[0]["LocationID"].ToString()); if (SNMPDevicesDataTable.Rows[0]["Port"].ToString() != "") { ReturnObject.Port = int.Parse(SNMPDevicesDataTable.Rows[0]["Port"].ToString()); } if (SNMPDevicesDataTable.Rows[0]["ResponseThreshold"].ToString() != "") { ReturnObject.ResponseThreshold = int.Parse(SNMPDevicesDataTable.Rows[0]["ResponseThreshold"].ToString()); } ReturnObject.Username = SNMPDevicesDataTable.Rows[0]["Username"].ToString(); ReturnObject.Description = SNMPDevicesDataTable.Rows[0]["Description"].ToString(); ReturnObject.Address = SNMPDevicesDataTable.Rows[0]["Address"].ToString(); ReturnObject.Category = SNMPDevicesDataTable.Rows[0]["Category"].ToString(); if (SNMPDevicesDataTable.Rows[0]["Enabled"].ToString() != "") { ReturnObject.Enabled = bool.Parse(SNMPDevicesDataTable.Rows[0]["Enabled"].ToString()); } if (SNMPDevicesDataTable.Rows[0]["IncludeOnDashBoard"].ToString() != "") { ReturnObject.IncludeOnDashBoard = bool.Parse(SNMPDevicesDataTable.Rows[0]["IncludeOnDashBoard"].ToString()); } ReturnObject.Name = SNMPDevicesDataTable.Rows[0]["Name"].ToString(); if (SNMPDevicesDataTable.Rows[0]["Scanning Interval"].ToString() != "") { ReturnObject.ScanningInterval = int.Parse(SNMPDevicesDataTable.Rows[0]["Scanning Interval"].ToString()); } if (SNMPDevicesDataTable.Rows[0]["OffHoursScanInterval"].ToString() != "") { ReturnObject.OffHoursScanInterval = int.Parse(SNMPDevicesDataTable.Rows[0]["OffHoursScanInterval"].ToString()); } if (SNMPDevicesDataTable.Rows[0]["RetryInterval"].ToString() != "") { ReturnObject.RetryInterval = int.Parse(SNMPDevicesDataTable.Rows[0]["RetryInterval"].ToString()); } ReturnObject.OID = SNMPDevicesDataTable.Rows[0]["OID"].ToString(); } catch (Exception ex) { throw ex; } finally { } return(ReturnObject); }
private void InsertSNMPDevices() { try { SNMPDevices SNMPObj = new SNMPDevices(); SNMPObj.Address = IPTextBox.Text; SNMPObj.Name = NameTextBox.Text; SNMPObj.OID = oidtextbox.Text; //UrlObj.Name = NameTextBox.Text; DataTable returntable = VSWebBL.ConfiguratorBL.SNMPDevicesBL.Ins.GetIPAddress(SNMPObj); if (returntable.Rows.Count > 0) { //3/19/2014 NS modified //ErrorMessageLabel.Text = "This Name or IP Address is already being monitored. Please enter another IP Address or Name."; //ErrorMessagePopupControl.ShowOnPageLoad = true; //10/6/2014 NS modified for VSPLUS-990 errorDiv.InnerHtml = "This Name or IP Address is already being monitored. Please enter another IP Address or Name." + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>"; errorDiv.Style.Value = "display: block"; flag = true; //IPAddressTextBox.Focus(); } else { try { object ReturnValue = VSWebBL.ConfiguratorBL.SNMPDevicesBL.Ins.InsertData(CollectDataForSNMPDevices()); SetFocusOnError(ReturnValue); if (ReturnValue.ToString() == "True") { //3/19/2014 NS modified /* * ErrorMessageLabel.Text = "Network device record created successfully."; * ErrorMessagePopupControl.HeaderText = "Information"; * ErrorMessagePopupControl.ShowCloseButton = false; * ValidationUpdatedButton.Visible = true; * ValidationOkButton.Visible = false; * ErrorMessagePopupControl.ShowOnPageLoad = true; */ Session["SNMPDeviceUpdateStatus"] = NameTextBox.Text; Response.Redirect("SNMPDevicesGrid.aspx", false);//Mukund, 05Aug14, VSPLUS-844:Page redirect on callback Context.ApplicationInstance.CompleteRequest(); } } catch (Exception ex) { //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } finally { } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Validation before submitting data for Server tab /// </summary> /// <param name="SNMPDevicesObject"></param> /// <returns></returns> public Object ValidateDCUpdate(SNMPDevices SNMPDevicesObject) { Object ReturnValue = ""; try { if (SNMPDevicesObject.Name == null || SNMPDevicesObject.Name == "") { return("ER#Please enter a name"); } if (SNMPDevicesObject.Location == null || SNMPDevicesObject.Location == " ") { return("ER#Please enter the location of the device, such as '8th floor server room"); } if (SNMPDevicesObject.Description == null || SNMPDevicesObject.Description == " ") { return("ER#Please enter a description of the device, such as 'Objectionable Content Filter'"); } if (SNMPDevicesObject.Category == null || SNMPDevicesObject.Category == " ") { return("ER#Please enter Category"); } if (SNMPDevicesObject.ScanningInterval.ToString() == "") { return("ER#Please a scan Interval"); } if (SNMPDevicesObject.OffHoursScanInterval.ToString() == " ") { return("ER#Please enter an off-hours Scan Interval"); } if (SNMPDevicesObject.ResponseThreshold.ToString() == "") { return("ER#Please enter a Response Threshold, in milliseconds, over which the device will be considered 'slow'"); } if (SNMPDevicesObject.RetryInterval == null) { return("ER#Please enter a Retry Interval, to be used when the device is down."); } if (SNMPDevicesObject.Address == null) { return("ER#Please enter the IP Address device, such as '127.0.0.1' or host name"); } if ((SNMPDevicesObject.RetryInterval) > (SNMPDevicesObject.ScanningInterval)) { return("ER#Please enter a Retry Interval that is less than the Scan Interval."); } } catch (Exception ex) { throw ex; } finally { } return(""); }
/// <summary> /// Call to Get Data from SNMPDevices based on Primary key /// </summary> /// <param name="SNMPDevicesObject">SNMPDevicesObject object</param> /// <returns></returns> public SNMPDevices GetData(SNMPDevices SNMPDevicesObject) { try { return(VSWebDAL.ConfiguratorDAL.SNMPDevicesDAL.Ins.GetData(SNMPDevicesObject)); } catch (Exception ex) { throw ex; } }
public DataTable GetIPAddress(SNMPDevices SNMPObj) { try { return(VSWebDAL.ConfiguratorDAL.SNMPDevicesDAL.Ins.GetIPAddress(SNMPObj)); } catch (Exception ex) { throw ex; } }
/// <summary> /// Call DAL Delete Data /// </summary> /// <param name="DCObject"></param> /// <returns></returns> public Object DeleteData(SNMPDevices DCObject) { try { return(VSWebDAL.ConfiguratorDAL.SNMPDevicesDAL.Ins.DeleteData(DCObject)); } catch (Exception ex) { throw ex; } }
protected void SNMPDevicesGridView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { SNMPDevices DCObject = new SNMPDevices(); DCObject.ID = Convert.ToInt32(e.Keys[0]); //Delete row from DB Object ReturnValue = VSWebBL.ConfiguratorBL.SNMPDevicesBL.Ins.DeleteData(DCObject); //Update Grid after inserting new row, refresh grid as in page load ASPxGridView gridView = (ASPxGridView)sender; gridView.CancelEdit(); e.Cancel = true; FillSNMPDevicesGrid(); }
//delete Data from NetworkDevices Table public Object DeleteData(SNMPDevices SNMPObject) { Object Update; try { string SqlQuery = "Delete SNMPDevices Where ID=" + SNMPObject.ID; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } catch { Update = false; } finally { } return(Update); }
private SNMPDevices CollectDataForSNMPDevices() { try { //Cluster Settings SNMPDevices SNMPDevicesObject = new SNMPDevices(); SNMPDevicesObject.Name = NameTextBox.Text; SNMPDevicesObject.Enabled = EnabledCheckBox.Checked; SNMPDevicesObject.IncludeOnDashBoard = IncludeOnDashBoardCheckBox.Checked; SNMPDevicesObject.Category = CategoryTextBox.Text; SNMPDevicesObject.ImageURL = Img1.Src; //NetworkDevicesObject.First_Alert_Threshold = int.Parse(AlertTextBox.Text); SNMPDevicesObject.ScanningInterval = int.Parse(ScanIntervalTextBox.Text); SNMPDevicesObject.OffHoursScanInterval = int.Parse(OffScanTextBox.Text); //NetworkDevicesObject.Location = LocComboBox.Text; // LocationTextBox.Text; SNMPDevicesObject.RetryInterval = int.Parse(RetryIntervalTextBox.Text); SNMPDevicesObject.ResponseThreshold = int.Parse(ResponseThrTextBox.Text); SNMPDevicesObject.Address = IPTextBox.Text; SNMPDevicesObject.Description = DescriptionTextBox.Text; Locations LOCobject = new Locations(); LOCobject.Location = LocComboBox.Text; Locations ReturnLocValue = VSWebBL.SecurityBL.LocationsBL.Ins.GetDataForLocation(LOCobject); SNMPDevicesObject.LocationID = ReturnLocValue.ID; SNMPDevicesObject.Location = LocComboBox.Text; SNMPDevicesObject.OID = oidtextbox.Text; if (Mode == "Update") { SNMPDevicesObject.ID = ServerKey; } return(SNMPDevicesObject); } catch (Exception ex) { //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } finally { } }
/// <summary> /// Get all Data from NetworkDevices /// </summary> public DataTable GetAllData() { DataTable SNMPDevicesDataTable = new DataTable(); SNMPDevices ReturnObject = new SNMPDevices(); try { string SqlQuery = "select * from SNMPDevices"; SNMPDevicesDataTable = objAdaptor.FetchData(SqlQuery); } catch (Exception ex) { throw ex; } finally { } return(SNMPDevicesDataTable); }
/// <summary> /// Call to Update Data of DominoServers based on Key /// </summary> /// <param name="SNMPDevicesObject">DominoServers object</param> /// <returns>Object</returns> public Object UpdateData(SNMPDevices SNMPDevicesObject) { Object ReturnValue = ValidateDCUpdate(SNMPDevicesObject); try { if (ReturnValue.ToString() == "") { return(VSWebDAL.ConfiguratorDAL.SNMPDevicesDAL.Ins.UpdateData(SNMPDevicesObject)); } else { return(ReturnValue); } } catch (Exception ex) { throw ex; } }
public DataTable GetIPAddress(SNMPDevices SNMPObj) { //SametimeServers SametimeObj = new SametimeServers(); DataTable SNMPTable = new DataTable(); try { if (SNMPObj.ID == 0) { string sqlQuery = "Select * from SNMPDevices where Address='" + SNMPObj.Address + "' or Name='" + SNMPObj.Name + "' "; SNMPTable = objAdaptor.FetchData(sqlQuery); } else { string sqlQuery = "Select * from SNMPDevices where (Address='" + SNMPObj.Address + "' or Name='" + SNMPObj.Name + "')and ID<>" + SNMPObj.ID + " "; SNMPTable = objAdaptor.FetchData(sqlQuery); } } catch (Exception ex) { throw ex; } return(SNMPTable); }
/// <summary> /// Update data into NetworkDevices table /// </summary> /// <param name="DSObject">DominoServers object</param> /// <returns></returns> public Object UpdateData(SNMPDevices SNMPObject) { Object Update; try { string SqlQuery = "UPDATE [SNMPDevices] SET Description='" + SNMPObject.Description + "',Category='" + SNMPObject.Category + "',Port=" + SNMPObject.Port + ",Username='******',Password='******',[Scanning Interval]=" + SNMPObject.ScanningInterval + ",OffHoursScanInterval=" + SNMPObject.OffHoursScanInterval + ",Enabled='" + SNMPObject.Enabled + "',IncludeOnDashBoard='" + SNMPObject.IncludeOnDashBoard + "',Location='" + SNMPObject.Location + "',ImageURL='" + SNMPObject.ImageURL + "',Name='" + SNMPObject.Name + "',ResponseThreshold=" + SNMPObject.ResponseThreshold + ",RetryInterval=" + SNMPObject.RetryInterval + ",Address='" + SNMPObject.Address + "',LocationID=" + SNMPObject.LocationID + " where [ID]=" + SNMPObject.ID + " and OID='" + SNMPObject.OID + "'"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } catch { Update = false; } finally { } return(Update); }
private void FillData(int ID) { try { SNMPDevices SNMPDevicesObject = new SNMPDevices(); SNMPDevices ReturnObject = new SNMPDevices(); SNMPDevicesObject.ID = ID; ReturnObject = VSWebBL.ConfiguratorBL.SNMPDevicesBL.Ins.GetData(SNMPDevicesObject); NameTextBox.Text = ReturnObject.Name; IPTextBox.Text = ReturnObject.Address; DescriptionTextBox.Text = ReturnObject.Description; CategoryTextBox.Text = ReturnObject.Category; EnabledCheckBox.Checked = ReturnObject.Enabled; IncludeOnDashBoardCheckBox.Checked = ReturnObject.IncludeOnDashBoard; Img1.Src = ReturnObject.ImageURL; CredentialsComboBox.Visible = true; //CredentialsComboBox.Text = ReturnObject.imagename; CredentialsComboBox.Text = ReturnObject.imagename; LocComboBox.Text = ReturnObject.Location; // LocationTextBox.Text = ReturnObject.Location; ScanIntervalTextBox.Text = ReturnObject.ScanningInterval.ToString(); OffScanTextBox.Text = ReturnObject.OffHoursScanInterval.ToString(); RetryIntervalTextBox.Text = ReturnObject.RetryInterval.ToString(); ResponseThrTextBox.Text = ReturnObject.ResponseThreshold.ToString(); oidtextbox.Text = ReturnObject.OID.ToString(); } catch (Exception ex) { //6/27/2014 NS added for VSPLUS-634 Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); throw ex; } finally { } }