/// <summary> /// Validation before submitting data for Server Attributes tab /// </summary> /// <param name="ExchangeServersObject"></param> /// <returns></returns> public Object ValidateDSUpdate(ExchangeServers ExchangeServersObject) { Object ReturnValue = ""; try { // if (DominoServersObject.Name == null || DominoServersObject.Name == "") //return "ER#Please enter the server name, in hierarchical format, such as 'NYMail01/US/IBM'"; if (ExchangeServersObject.DeadThreshold.ToString() == "") { return("ER#Please enter the number 'Dead' mail messages, over which you would like to be alerted.'"); } if (ExchangeServersObject.PendingThreshold.ToString() == "") { return("ER#Please enter the number 'Pending' mail messages, over which you would like to be alerted.'"); } if (ExchangeServersObject.HeldThreshold.ToString() == "") { return("ER#Please enter the number 'Held' mail messages, over which you would like to be alerted.'"); } // if (DominoServersObject.Location == null || DominoServersObject.Location == "") // return "ER#Please enter the location of the device, such as '8th floor server room'"; // if (DominoServersObject.Description == null || DominoServersObject.Description == "") // return "ER#Please enter a description of the server, such as 'New York Executives'"; if (ExchangeServersObject.Category == null || ExchangeServersObject.Category == "") { return("ER#Please enter a category"); } if (ExchangeServersObject.ResponseThreshold.ToString() == "") { return("ER#Please enter a Response Threshold, in milliseconds, over which the device will be considered 'slow'."); } if (ExchangeServersObject.ScanInterval.ToString() == "") { return("ER#Please enter a Scan Interval"); } if (ExchangeServersObject.FailureThreshold.ToString() == "") { return("ER#Please enter the failure threshold. How many times can the server be down before an alert is sent?"); } if (ExchangeServersObject.OffHoursScanInterval.ToString() == "") { return("ER#Please enter an off-hours Scan Interval"); } if (ExchangeServersObject.RetryInterval.ToString() == "") { return("ER#Please enter a Retry Interval, to be used when the device is down."); } } catch (Exception ex) { throw ex; } finally { } return(""); }
public ExchangeServers GetData(ExchangeServers ExchangeServersObject) { try { return(VSWebDAL.ConfiguratorDAL.MSServerDAL.Ins.GetData(ExchangeServersObject)); } catch (Exception ex) { throw ex; } }
public Object UpdateDAGData(ExchangeServers ExchangeServersObject) { try { Object ReturnValue = ValidateDSUpdate(ExchangeServersObject); if (ReturnValue.ToString() == "") { return(VSWebDAL.ConfiguratorDAL.ExchangePropertiesDAL.Ins.UpdateDAGData(ExchangeServersObject)); } else { return(ReturnValue); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Insert data into DominoServers table /// </summary> /// <param name="DSObject">DominoServers object</param> /// <returns></returns> public bool InsertData(ExchangeServers DSObject) { bool Insert = false; try { //8/7/2014 NS modified for VSPLUS-853 string SqlQuery = "INSERT INTO DominoServers (DiskSpaceThreshold, BES_Server, BES_Threshold, Category, DeadThreshold, " + "Description, Enabled, RequireSSL,ExternalAlias, FailureThreshold, Location, MailDirectory, Name, OffHoursScanInterval, PendingThreshold, " + "ResponseThreshold, RetryInterval, [Scan Interval], SearchString, AdvancedMailScan, DeadMailDeleteThreshold, " + "IPAddress, HeldThreshold, ScanDBHealth, NotificationGroup, Memory_Threshold, CPU_Threshold, " + "Cluster_Rep_Delays_Threshold,Modified_By,Modified_On,ServerDaysAlert,CredentialsID) " + " VALUES (" + DSObject.DiskSpaceThreshold + ", '" + DSObject.BES_Server + "', " + DSObject.BES_Threshold + ", '" + DSObject.Category + "', " + DSObject.DeadThreshold + "', '" + DSObject.Enabled + "','" + DSObject.RequireSSL + "','" + DSObject.ExternalAlias + "', " + DSObject.FailureThreshold + ", '" + DSObject.LocationID + "', '" + DSObject.MailDirectory + "', " + DSObject.OffHoursScanInterval + ", " + DSObject.PendingThreshold + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", '" + DSObject.SearchString + "', 0, " + DSObject.DeadMailDeleteThreshold + ", " + DSObject.HeldThreshold + ", '" + DSObject.ScanDBHealth + "', '" + DSObject.NotificationGroup + "', " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + ", " + DSObject.Cluster_Rep_Delays_Threshold + ", " + DSObject.ServerDaysAlert + ", " + DSObject.CredentialsID + ")"; Insert = objAdaptor.ExecuteNonQuery(SqlQuery); } catch { Insert = false; } finally { } return(Insert); }
public Object ValidateDSUpdate(ExchangeServers ExchangeServersObject, string ServerType) { Object ReturnValue = ""; try { if (ExchangeServersObject.Category == null || ExchangeServersObject.Category == "") { return("ER#Please enter a category"); } if (ExchangeServersObject.ResponseThreshold.ToString() == "") { return("ER#Please enter a Response Threshold, in milliseconds, over which the device will be considered 'slow'."); } if (ExchangeServersObject.ScanInterval.ToString() == "") { return("ER#Please enter a Scan Interval"); } if (ExchangeServersObject.FailureThreshold.ToString() == "") { return("ER#Please enter the failure threshold. How many times can the server be down before an alert is sent?"); } if (ExchangeServersObject.OffHoursScanInterval.ToString() == "") { return("ER#Please enter an off-hours Scan Interval"); } if (ExchangeServersObject.RetryInterval.ToString() == "") { return("ER#Please enter a Retry Interval, to be used when the device is down."); } } catch (Exception ex) { throw ex; } finally { } return(""); }
/// <summary> /// Get all Data from DominoServers /// </summary> /// <returns></returns> //public DataTable GetAllData() //{ // DataTable DominoServersDataTable = new DataTable(); // DominoServers ReturnDSObject = new DominoServers(); // try // { // //string Query="Select serverid,LocationID from UserLocationRestrictions inner join UserServerRestrictions on UserLocationRestrictions.UserID = UserServerRestrictions.UserID where UserID="++""; // //12/16/2013 NS added sort by name ASC // string SqlQuery = "SELECT DiskSpaceThreshold, BES_Server, BES_Threshold, DominoServers.Category, DeadThreshold, " + // "FailureThreshold,DominoServers.Enabled,MailDirectory,ServerID,OffHoursScanInterval, PendingThreshold, " + // "ResponseThreshold, DominoServers.RetryInterval, [Scan Interval], SearchString, AdvancedMailScan," + // "DeadMailDeleteThreshold,HeldThreshold, ScanDBHealth, NotificationGroup, Memory_Threshold, " + // "DominoServers.CPU_Threshold, Cluster_Rep_Delays_Threshold,description,servername as Name,ipaddress,locationid, " + // "(select Location from Locations where ID = servers.LocationID) Location,ID from Servers " + // "left join DominoServers on servers.ID=DominoServers.serverID where " + // "servers.ServerTypeID=(select ID from ServerTypes where ServerType='Domino') " + // "order by servername "; // //string SqlQuery = "SELECT DiskSpaceThreshold, BES_Server, BES_Threshold, Category, DeadThreshold, Description, Enabled, FailureThreshold, [Key], Location, MailDirectory, Name, " + // // "OffHoursScanInterval, PendingThreshold, ResponseThreshold, RetryInterval, [Scan Interval], SearchString, AdvancedMailScan, DeadMailDeleteThreshold, " + // // " IPAddress, HeldThreshold, ScanDBHealth, NotificationGroup, Memory_Threshold, CPU_Threshold, Cluster_Rep_Delays_Threshold FROM DominoServers" + // // " union " + // // "SELECT '', '', '', '', '', Description, '', '', 0, '', '', ServerName as Name, " + // // "'', '', '', '', '', '', '', '', " + // // "IPAddress, '', '', '', '', '', '' FROM Servers where ServerName not in (SELECT distinct Name FROM DominoServers)"; // DominoServersDataTable = objAdaptor.FetchData(SqlQuery); // } // catch // { // } // finally // { // } // return DominoServersDataTable; //} /// <summary> /// Get Data from DominoServers based on Key /// </summary> /// <param name="DSObject">DominoServers object</param> /// <returns></returns> public ExchangeServers GetData(ExchangeServers DSObject) { DataTable DominoServersDataTable = new DataTable(); ExchangeServers ReturnDSObject = new ExchangeServers(); try { //string SqlQuery = "select *,ISNULL(RequireSSL,0) RS,ServerName as Name,IPAddress,LocationID,Description,servers.ID,Location from Servers left join dominoservers on Servers.ID=DominoServers.ServerID inner join Locations on servers.LocationID=Locations.ID where servers.ID=" + DSObject.Key + ""; //8/7/2014 NS modified for VSPLUS-853 string SqlQuery = "select ServerAttributes.Category, " + "Description,ISNULL(ServerAttributes.Enabled,0) Enabled, " + "Location,ISNULL(LocationID,0) LocationID,ISNULL(ServerAttributes.OffHourInterval,15) OffHoursScanInterval, " + "ISNULL(ServerAttributes.ResponseTime,2500) ResponseThreshold, " + "ISNULL(ServerAttributes.RetryInterval,2) RetryInterval,ISNULL(ServerAttributes.[ScanInterval],8) [Scan Interval], " + "IPAddress, " + "ISNULL(ServerAttributes.MemThreshold,0.9) Memory_Threshold, " + "ISNULL(ServerAttributes.CPU_Threshold,0.9) CPU_Threshold, " + "ServerID,ServerName as Name, " + "servers.ID,Location,ISNULL(CredentialsID,0) CredentialsID from Servers left join ServerAttributes on " + "Servers.ID=ServerAttributes.ServerID inner join Locations on servers.LocationID=Locations.ID " + "where servers.ID=" + DSObject.Key + ""; DominoServersDataTable = objAdaptor.FetchData(SqlQuery); //populate & return data object if (DominoServersDataTable.Rows.Count > 0) { //if (DominoServersDataTable.Rows[0]["BES_Server"].ToString() != "" && DominoServersDataTable.Rows[0]["NotificationGroup"] != null && DominoServersDataTable.Rows[0]["OffHoursScanInterval"] != null) //{ //Commented by Mukund 06Jun14:Error this parameter is not taken now. Disk space is separately dealt //ReturnDSObject.DiskSpaceThreshold = float.Parse(DominoServersDataTable.Rows[0]["DiskSpaceThreshold"].ToString()); ReturnDSObject.Category = DominoServersDataTable.Rows[0]["Category"].ToString(); ReturnDSObject.Name = DominoServersDataTable.Rows[0]["Description"].ToString(); ReturnDSObject.Enabled = bool.Parse(DominoServersDataTable.Rows[0]["Enabled"].ToString()); //ReturnDSObject.FailureThreshold = int.Parse(DominoServersDataTable.Rows[0]["FailureThreshold"].ToString()); ReturnDSObject.Location = DominoServersDataTable.Rows[0]["Location"].ToString(); ReturnDSObject.LocationID = int.Parse(DominoServersDataTable.Rows[0]["LocationID"].ToString()); ReturnDSObject.Name = DominoServersDataTable.Rows[0]["Name"].ToString(); ReturnDSObject.OffHoursScanInterval = int.Parse(DominoServersDataTable.Rows[0]["OffHoursScanInterval"].ToString()); ReturnDSObject.ResponseThreshold = int.Parse(DominoServersDataTable.Rows[0]["ResponseThreshold"].ToString()); ReturnDSObject.RetryInterval = int.Parse(DominoServersDataTable.Rows[0]["RetryInterval"].ToString()); ReturnDSObject.ScanInterval = int.Parse(DominoServersDataTable.Rows[0]["Scan Interval"].ToString()); ReturnDSObject.SearchString = DominoServersDataTable.Rows[0]["Scan Interval"].ToString(); ReturnDSObject.IPAddress = DominoServersDataTable.Rows[0]["IPAddress"].ToString(); ReturnDSObject.Memory_Threshold = float.Parse(DominoServersDataTable.Rows[0]["Memory_Threshold"].ToString()); ReturnDSObject.CPU_Threshold = float.Parse(DominoServersDataTable.Rows[0]["CPU_Threshold"].ToString()); if (DominoServersDataTable.Rows[0]["ServerID"].ToString() != "") { ReturnDSObject.ServerID = int.Parse(DominoServersDataTable.Rows[0]["ServerID"].ToString()); } ReturnDSObject.Key = Convert.ToInt16(DominoServersDataTable.Rows[0]["ID"].ToString()); //ReturnDSObject.Modified_By = Convert.ToInt16(DominoServersDataTable.Rows[0]["Modified_By"].ToString()); //ReturnDSObject.Modified_On = DominoServersDataTable.Rows[0]["Modified_On"].ToString(); //8/7/2014 NS added for VSPLUS-853 ReturnDSObject.CredentialsID = int.Parse(DominoServersDataTable.Rows[0]["CredentialsID"].ToString()); } else { ReturnDSObject.Location = DominoServersDataTable.Rows[0]["Location"].ToString(); ReturnDSObject.Name = DominoServersDataTable.Rows[0]["Name"].ToString(); ReturnDSObject.IPAddress = DominoServersDataTable.Rows[0]["IPAddress"].ToString(); ReturnDSObject.Description = DominoServersDataTable.Rows[0]["Description"].ToString(); ReturnDSObject.Key = Convert.ToInt16(DominoServersDataTable.Rows[0]["ID"].ToString()); ReturnDSObject.LocationID = int.Parse(DominoServersDataTable.Rows[0]["LocationID"].ToString()); } } //} catch (Exception ex) { throw ex; } finally { } return(ReturnDSObject); }
public Object UpdateDAGData(ExchangeServers DSObject) { Object Update; try { System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["VitalSignsConnectionString"].ToString()); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select serverID from ServerAttributes", con); DataTable dt = new DataTable(); da.Fill(dt); int i = 0; foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["serverID"].ToString()) == DSObject.Key) { i++; } } if (dt.Rows.Count > 0) { if (i > 0) { //8/7/2014 NS modified for VSPLUS-853 string SqlQuery = "UPDATE ServerAttributes SET " + ", Category = '" + DSObject.Category + "' " + ", Enabled = '" + DSObject.Enabled + "', RetryInterval = " + DSObject.RetryInterval + ", [ScanInterval] = " + DSObject.ScanInterval + "', MemThreshold = " + DSObject.Memory_Threshold + ", CPU_Threshold = " + DSObject.CPU_Threshold + (DSObject.CredentialsID != 0 ? ", CredentialsID = " + DSObject.CredentialsID : "") + " WHERE ServerID =" + DSObject.Key + ""; //VSPLUS-896: Mukund 28Aug14,In sqlQuery, Credentials is giving FK constraint err. Adding that if selected in UI. Update = objAdaptor.ExecuteNonQuery(SqlQuery); } else { string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ", MemThreshold, CPU_Threshold, CredentialsId,ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + "," + DSObject.CredentialsID.ToString() + "," + "0" + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); SqlQuery = "INSERT INTO DAGSettings (ServerID, PrimaryConnection, BackupConnection,ReplyQThreshold,CopyQThreshold) " + " VALUES (" + DSObject.Key + "," + DSObject.DAGPrimaryServerId.ToString() + "," + DSObject.DAGBackUpServerID.ToString() + "," + DSObject.DAGResponseQTh.ToString() + "," + DSObject.DAGCopyQTh.ToString() + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } } else { string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ",ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + "," + "0" + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); SqlQuery = "INSERT INTO DAGSettings (ServerID, PrimaryConnection, BackupConnection,ReplyQThreshold,CopyQThreshold) " + " VALUES (" + DSObject.Key + "," + DSObject.DAGPrimaryServerId.ToString() + "," + DSObject.DAGBackUpServerID.ToString() + "," + DSObject.DAGResponseQTh.ToString() + "," + DSObject.DAGCopyQTh.ToString() + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } } catch (Exception ex) { Update = false; //7/29/2014 NS added for VSPLUS-634 //WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } finally { } return(Update); }
/// <summary> /// Insert data into DominoServers table /// </summary> /// <param name="DSObject">DominoServers object</param> /// <returns></returns> public Object UpdateData(ExchangeServers DSObject) { Object Update; try { System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["VitalSignsConnectionString"].ToString()); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select serverID from ServerAttributes", con); DataTable dt = new DataTable(); da.Fill(dt); int i = 0; foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["serverID"].ToString()) == DSObject.Key) { i++; } } if (dt.Rows.Count > 0) { if (i > 0) { //8/7/2014 NS modified for VSPLUS-853 string SqlQuery = "UPDATE ServerAttributes SET " + ", Category = '" + DSObject.Category + "' " + ", Enabled = '" + DSObject.Enabled + "', RetryInterval = " + DSObject.RetryInterval + ", [ScanInterval] = " + DSObject.ScanInterval + "', MemThreshold = " + DSObject.Memory_Threshold + ", CPU_Threshold = " + DSObject.CPU_Threshold + (DSObject.CredentialsID != 0? ", CredentialsID = " + DSObject.CredentialsID:"") + " WHERE ServerID =" + DSObject.Key + ""; //VSPLUS-896: Mukund 28Aug14,In sqlQuery, Credentials is giving FK constraint err. Adding that if selected in UI. Update = objAdaptor.ExecuteNonQuery(SqlQuery); } else {//11-04-2016 Durga Modified for VSPLUS-2742 string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ", MemThreshold, CPU_Threshold, CredentialsId,ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + "," + DSObject.CredentialsID.ToString() + "," + "0" + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); SqlQuery = "INSERT INTO ExchangeSettings (ServerID, CasSmtp, CASpop3,CASimap,CASOWA,CASActiveSync,CASEWS,CASECP,CASAutoDiscovery,CASOAB,SUBQTHRESHOLD,POISONQTHRESHOLD,UNREACHABLEQTHRESHOLD,TOTALQTHRESHOLD,VersionNo,ShadowQThreshold) " + " VALUES (" + DSObject.Key + ",0,0,0,0,0,0,0,0,0,100,100,100,2,0,100)"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } } else {//11-04-2016 Durga Modified for VSPLUS-2742 string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ", MemThreshold, CPU_Threshold,CredentialsId,ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + "," + DSObject.CredentialsID.ToString() + "," + "0" + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); SqlQuery = "INSERT INTO ExchangeSettings (ServerID, CasSmtp, CASpop3,CASimap,CASOWA,CASActiveSync,CASEWS,CASECP,CASAutoDiscovery,CASOAB,SUBQTHRESHOLD,POISONQTHRESHOLD,UNREACHABLEQTHRESHOLD,TOTALQTHRESHOLD,VersionNo,ShadowQThreshold) " + " VALUES (" + DSObject.Key + ",0,0,0,0,0,0,0,0,0,100,100,100,2,0,100)"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } } catch (Exception ex) { Update = false; //7/29/2014 NS added for VSPLUS-634 //WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } finally { } return(Update); }
protected void AssignButton_Click(object sender, EventArgs e) { Object ReturnValue; Servers ServersObject; DataTable dtsrv = new DataTable(); DataTable dtdisk = new DataTable(); dtdisk.Columns.Add("ServerName"); dtdisk.Columns.Add("DiskName"); dtdisk.Columns.Add("Threshold"); dtdisk.Columns.Add("ThresholdType"); //3/4/2014 NS added for VSPLUS-431 Object ReturnValueDisk; ExchangeServers ExchangeServersObjectRet = new ExchangeServers(); ExchangeServers ExchangeServersObject = new ExchangeServers(); if (AdvDiskSpaceThTrackBar.Value.ToString() != null) { ExchangeServersObject.DiskSpaceThreshold = float.Parse(AdvDiskSpaceThTrackBar.Value.ToString()); } if (AdvMemoryThTrackBar.Value.ToString() != null) { ExchangeServersObject.Memory_Threshold = float.Parse(AdvMemoryThTrackBar.Value.ToString()); } if (AdvCPUThTrackBar.Value.ToString() != null) { ExchangeServersObject.CPU_Threshold = float.Parse(AdvCPUThTrackBar.Value.ToString()); } if (SrvAtrScanIntvlTextBox.Text != null && SrvAtrScanIntvlTextBox.Text != "") { ExchangeServersObject.ScanInterval = int.Parse(SrvAtrScanIntvlTextBox.Text); } if (SrvAtrOffScanIntvlTextBox.Text != null && SrvAtrOffScanIntvlTextBox.Text != "") { ExchangeServersObject.OffHoursScanInterval = int.Parse(SrvAtrOffScanIntvlTextBox.Text); } if (SrvAtrRetryIntvlTextBox.Text != null && SrvAtrRetryIntvlTextBox.Text != "") { ExchangeServersObject.RetryInterval = int.Parse(SrvAtrRetryIntvlTextBox.Text); } if (SrvAtrResponseThTextBox.Text != null && SrvAtrResponseThTextBox.Text != "") { ExchangeServersObject.ResponseThreshold = int.Parse(SrvAtrResponseThTextBox.Text); } if (SrvAtrFailBefAlertTextBox.Text != null && SrvAtrFailBefAlertTextBox.Text != "") { ExchangeServersObject.FailureThreshold = int.Parse(SrvAtrFailBefAlertTextBox.Text); } ExchangeServersObject.CredentialsID = (CredentialsComboBox.Text == "" ? 0 : Convert.ToInt32(CredentialsComboBox.Value)); if (ServerType == "DAG") { ExchangeServersObject.DAGPrimaryServerId = (PrimaryExchangeServerComboBox.Text == "" ? 0 : Convert.ToInt32(PrimaryExchangeServerComboBox.Value)); ExchangeServersObject.DAGBackUpServerID = (SecondaryExchangeServerComboBox.Text == "" ? 0 : Convert.ToInt32(SecondaryExchangeServerComboBox.Value)); ExchangeServersObject.DAGCopyQTh = int.Parse(CopyQThresholdTetBox.Text); ExchangeServersObject.DAGResponseQTh = int.Parse(ReplyQthresholdTextbox.Text); } SrvCheckBoxList.SelectAll(); if (SrvCheckBoxList.SelectedItems.Count > 0) { dtsrv.Columns.Add("ID"); dtsrv.Columns.Add("ServerName"); dtsrv.Columns.Add("IPAddress"); dtsrv.Columns.Add("Description"); dtsrv.Columns.Add("ServerType"); dtsrv.Columns.Add("Location"); dtsrv.Columns.Add("LocationID"); dtsrv.Columns.Add("PrimaryServerId"); dtsrv.Columns.Add("BackupServerId"); for (int i = 0; i < SrvCheckBoxList.SelectedItems.Count; i++) { DataRow dr = dtsrv.NewRow(); dr["ID"] = ""; dr["ServerName"] = SrvCheckBoxList.SelectedItems[i].ToString(); dr["IPAddress"] = ""; dr["Description"] = "Production"; if (ServerType == "DAG") { dr["ServerType"] = "Database Availability Group"; dr["PrimaryServerId"] = "Exchange"; dr["BackupServerId"] = "Exchange"; } else { dr["ServerType"] = "Exchange"; } dr["Location"] = ""; dr["LocationID"] = 0; ServersObject = CollectDataForServers("Insert", dr); DataTable dt = VSWebBL.SecurityBL.ServersBL.Ins.GetDataByName(ServersObject); if (dt.Rows.Count > 0) { ExchangeServersObject.Key = int.Parse(dt.Rows[0]["ID"].ToString()); } ExchangeServersObject.Category = dr["Description"].ToString(); ExchangeServersObject.Enabled = true; ExchangeServersObjectRet = VSWebBL.ConfiguratorBL.ExchangePropertiesBL.Ins.GetData(ExchangeServersObject); if (ServerType == "DAG") { ReturnValue = VSWebBL.ConfiguratorBL.ExchangePropertiesBL.Ins.UpdateDAGData(ExchangeServersObject); } else { ReturnValue = VSWebBL.ConfiguratorBL.ExchangePropertiesBL.Ins.UpdateData(ExchangeServersObject); } //3/4/2014 NS added for VSPLUS-431 if (ServerType != "DAG") { DataRow row = dtdisk.Rows.Add(); row["ServerName"] = SrvCheckBoxList.SelectedItems[i].ToString(); row["DiskName"] = "AllDisks"; row["Threshold"] = "10"; row["ThresholdType"] = "Percent"; } } if (ServerType != "DAG") { ReturnValueDisk = VSWebBL.ConfiguratorBL.ExchangePropertiesBL.Ins.InsertDiskSettingsData(dtdisk); } Response.Redirect("~/Security/ImportExchangeServers4.aspx", false);//Mukund, 05Aug14, VSPLUS-844:Page redirect on callback Context.ApplicationInstance.CompleteRequest(); } }
public Object UpdateData(ExchangeServers DSObject, string ServerType) { Object Update; try { System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["VitalSignsConnectionString"].ToString()); System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select serverID from ServerAttributes", con); DataTable dt = new DataTable(); da.Fill(dt); int i = 0; foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["serverID"].ToString()) == DSObject.Key) { i++; } } if (dt.Rows.Count > 0) { if (i > 0) { //8/7/2014 NS modified for VSPLUS-853 string SqlQuery = "UPDATE ServerAttributes SET " + ", Category = '" + DSObject.Category + "' " + ", Enabled = '" + DSObject.Enabled + "', RetryInterval = " + DSObject.RetryInterval + ", [ScanInterval] = " + DSObject.ScanInterval + "', MemThreshold = " + DSObject.Memory_Threshold + ", CPU_Threshold = " + DSObject.CPU_Threshold + (DSObject.CredentialsID != 0 ? ", CredentialsID = " + DSObject.CredentialsID : "") + ", ConsFailuresBefAlert=" + DSObject.FailureThreshold + " WHERE ServerID =" + DSObject.Key + ""; //VSPLUS-896: Mukund 28Aug14,In sqlQuery, Credentials is giving FK constraint err. Adding that if selected in UI. Update = objAdaptor.ExecuteNonQuery(SqlQuery); } else { string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ", MemThreshold, CPU_Threshold, CredentialsId,ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + "," + DSObject.CredentialsID.ToString() + "," + DSObject.FailureThreshold + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } } else { string SqlQuery = "INSERT INTO ServerAttributes (ServerID, Category, " + "Enabled, OffHourInterval, " + "ResponseTime, RetryInterval, [ScanInterval]" + ", MemThreshold, CPU_Threshold,CredentialsId,ConsFailuresBefAlert,ConsOvrThresholdBefAlert) " + " VALUES (" + DSObject.Key + ", '" + DSObject.Category + "', '" + DSObject.Enabled + "'," + DSObject.OffHoursScanInterval + ", " + DSObject.ResponseThreshold + ", " + DSObject.RetryInterval + ", " + DSObject.ScanInterval + ", " + DSObject.Memory_Threshold + ", " + DSObject.CPU_Threshold + "," + DSObject.CredentialsID.ToString() + "," + DSObject.FailureThreshold + "," + "0" + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); } if (i == 0 || dt.Rows.Count == 0) { //insert into their respective tables string SqlQuery; switch (ServerType) { case "Exchange": SqlQuery = "INSERT INTO ExchangeSettings (ServerID, CasSmtp, CASpop3,CASimap,CASOWA,CASActiveSync,CASEWS,CASECP,CASAutoDiscovery,CASOAB,SUBQTHRESHOLD,POISONQTHRESHOLD,UNREACHABLEQTHRESHOLD,TOTALQTHRESHOLD,VersionNo,AuthenticationType,ShadowQThreshold) " + " VALUES (" + DSObject.Key + ",0,0,0,0,0,0,0,0,0,100,100,100,2,0,'" + DSObject.AuthenticationType.ToString() + "',100)"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); break; case "Database Availability Group": SqlQuery = "INSERT INTO DAGSettings (ServerID, PrimaryConnection, BackupConnection,ReplyQThreshold,CopyQThreshold) " + " VALUES (" + DSObject.Key + "," + DSObject.DAGPrimaryServerId.ToString() + "," + DSObject.DAGBackUpServerID.ToString() + "," + DSObject.DAGResponseQTh.ToString() + "," + DSObject.DAGCopyQTh.ToString() + ")"; Update = objAdaptor.ExecuteNonQuery(SqlQuery); break; case "Active Directory": //nothing as of now break; case "SharePoint": //nothing as of now break; case "Windows": //nothing as of now and probably forever break; case "Skype for Business": //nothing as of now break; } } } catch (Exception ex) { Update = false; //7/29/2014 NS added for VSPLUS-634 //WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex); } finally { } return(Update); }