public void CreateChangeLogEntryIfChanged(SqlConnection _sqlconn, bool writeLog, bool setbyUndo) { bool rethrow = false; Exception ExToRethrow = new Exception(); SqlCommand sqlCmd = new SqlCommand(); SqlConnection sqlConn = _sqlconn; try { using (var scope = new TransactionScope()) { this._writeLogEvenIfNotNewValue = writeLog; this._setByUndo = setbyUndo; //string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } sqlCmd.Connection = sqlConn; SqlParameter paramChangeType = new SqlParameter("@CHANGETYPE", SqlDbType.NVarChar); SqlParameter paramTableName = new SqlParameter("@TABLE", SqlDbType.NVarChar); SqlParameter paramColumnName = new SqlParameter("@COLNAME", SqlDbType.NVarChar); SqlParameter paramTimestamp = new SqlParameter("@TIME", SqlDbType.DateTime); SqlParameter paramChangeBy = new SqlParameter("@CHANGEBY", SqlDbType.Int); SqlParameter paramDataType = new SqlParameter("@DATA", SqlDbType.NVarChar); SqlParameter paramValueOld = new SqlParameter("@OLDVAL", SqlDbType.NVarChar); SqlParameter paramValueNew = new SqlParameter("@NEWVAL", SqlDbType.NVarChar); SqlParameter paramEventID = new SqlParameter("@EID", SqlDbType.Int); SqlParameter paramPK1ColName = new SqlParameter("@PK1COL", SqlDbType.NVarChar); SqlParameter paramPK1Value = new SqlParameter("@PK1VAL", SqlDbType.NVarChar); SqlParameter paramPK2ColName = new SqlParameter("@PK2COL", SqlDbType.NVarChar); SqlParameter paramPK2Value = new SqlParameter("@PK2VAL", SqlDbType.NVarChar); SqlParameter paramPK3ColName = new SqlParameter("@PK3COL", SqlDbType.NVarChar); SqlParameter paramPK3Value = new SqlParameter("@PK3VAL", SqlDbType.NVarChar); SqlParameter paramSetBYUndo = new SqlParameter("@UNDO", SqlDbType.Bit); paramChangeType.Value = this._ChangeType; paramTableName.Value = this._TableName; paramColumnName.Value = this._ColumnName; paramTimestamp.Value = this._Timestamp; paramChangeBy.Value = this._ChangedBy; paramDataType.Value = this._DataType; paramValueNew.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._Value_New); paramEventID.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._EventID); paramPK1ColName.Value = this._PK1_ColumnName; paramPK1Value.Value = this._PK1_Value; paramPK2ColName.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_ColumnName); paramPK2Value.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_Value); paramPK3ColName.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK3_ColumnName); paramPK3Value.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK3_Value); paramSetBYUndo.Value = this._setByUndo; sqlCmd.Parameters.Add(paramChangeType); sqlCmd.Parameters.Add(paramTableName); sqlCmd.Parameters.Add(paramColumnName); sqlCmd.Parameters.Add(paramTimestamp); sqlCmd.Parameters.Add(paramChangeBy); sqlCmd.Parameters.Add(paramDataType); sqlCmd.Parameters.Add(paramValueNew); sqlCmd.Parameters.Add(paramEventID); sqlCmd.Parameters.Add(paramPK1ColName); sqlCmd.Parameters.Add(paramPK1Value); sqlCmd.Parameters.Add(paramPK2ColName); sqlCmd.Parameters.Add(paramPK2Value); sqlCmd.Parameters.Add(paramPK3ColName); sqlCmd.Parameters.Add(paramPK3Value); sqlCmd.Parameters.Add(paramSetBYUndo); // !!!!!!!!!Update version of change log. Will be for 2.0!!!!!!!!!! /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //object oldVal = new object(); //bool hasOldValUpdated = false; //if (this._ChangeType == ChangeLog.ChangeLogChangeType.UPDATE) //{ // sqlCmdText = "SELECT " + this._ColumnName + " FROM " + this._TableName + " WHERE " + this._PK1_ColumnName + "= @PK1VAL"; // if (!string.IsNullOrEmpty(this._PK2_ColumnName)) // { // sqlCmdText = sqlCmdText + " AND " + this._PK2_ColumnName + "= @PK2VAL"; // } // if (!string.IsNullOrEmpty(this._PK3_ColumnName)) // { // sqlCmdText = sqlCmdText + " AND " + this._PK3_ColumnName + " = @PK3VAL"; // } // if (string.IsNullOrEmpty(this._PK2_ColumnName) && string.IsNullOrEmpty(this._PK3_ColumnName)) // { // oldVal = SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PK1VAL", this._PK1_Value)); // } // else if (!string.IsNullOrEmpty(this._PK2_ColumnName) && string.IsNullOrEmpty(this._PK3_ColumnName)) // { // oldVal = SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PK1VAL", this._PK1_Value) // , new SqlParameter("@PK2VAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_Value))); // } // else if (!string.IsNullOrEmpty(this._PK2_ColumnName) && !string.IsNullOrEmpty(this._PK3_ColumnName)) // { // oldVal = SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PK1VAL", this._PK1_Value) // , new SqlParameter("@PK2VAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_Value)) // , new SqlParameter("@PK3VAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK3_Value))); // } //} //var needsNewLog = false; //sqlCmdText = ""; //if (this._ChangeType == ChangeLogChangeType.UPDATE) //{ // //Check if values are different. If different, create log // //if date type, parse before compare // if (this._DataType == ChangeLog.ChangeLogDataType.DATE || this._DataType == ChangeLog.ChangeLogDataType.DATETIME) // { // if (DBNull.Value.Equals(oldVal)) // { // needsNewLog = true; // } // else // { // DateTime oldDate = DateTime.Parse(oldVal.ToString()); // DateTime newDate = DateTime.Parse(this._Value_New); // if (oldDate.CompareTo(newDate) != 0) // { // needsNewLog = true; // } // } // } // else if (!string.Equals(oldVal.ToString(), this._Value_New)) //all other non date/datetime type // { // needsNewLog = true; // } //} //else //{ // needsNewLog = true; //} //if (needsNewLog || this._writeLogEvenIfNotNewValue) //{ // sqlCmdText = "INSERT INTO dbo.ChangeLog VALUES (@CHANGETYPE, @TABLE, @COLNAME, @TIME, @CHANGEBY, @DATA, @OLDVAL, @NEWVAL, @EID, @PK1COL, @PK1VAL, @PK2COL, @PK2VAL, @PK3COL, @PK3VAL, @UNDO)"; // SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@CHANGETYPE", this._ChangeType), // new SqlParameter("@TABLE", this._TableName), // new SqlParameter("@COLNAME", this._ColumnName), // new SqlParameter("@TIME", this._Timestamp), // new SqlParameter("@CHANGEBY", this._ChangedBy), // new SqlParameter("@DATA", this._DataType), // new SqlParameter("@OLDVAL", TransportHelperFunctions.convertStringEmptyToDBNULL(oldVal)), // new SqlParameter("@NEWVAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._Value_New)), // new SqlParameter("@EID", TransportHelperFunctions.convertStringEmptyToDBNULL(this._EventID)), // new SqlParameter("@PK1COL", this._PK1_ColumnName), // new SqlParameter("@PK1VAL", this._PK1_Value), // new SqlParameter("@PK2COL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_ColumnName)), // new SqlParameter("@PK2VAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK2_Value)), // new SqlParameter("@PK3COL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK3_ColumnName)), // new SqlParameter("@PK3VAL", TransportHelperFunctions.convertStringEmptyToDBNULL(this._PK3_Value)), // new SqlParameter("@UNDO", this._setByUndo)); //} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //get old value by querying //create query using inputted tablename, columnname and primary cols and pkeys if (this._ChangeType == ChangeLog.ChangeLogChangeType.UPDATE) { sqlCmd.CommandText = "SELECT " + this._ColumnName + " FROM " + this._TableName + " WHERE " + this._PK1_ColumnName + "= @PK1VAL"; if (!string.IsNullOrEmpty(this._PK2_ColumnName)) { sqlCmd.CommandText = sqlCmd.CommandText + " AND " + this._PK2_ColumnName + "= @PK2VAL"; } if (!string.IsNullOrEmpty(this._PK3_ColumnName)) { sqlCmd.CommandText = sqlCmd.CommandText + " AND " + this._PK3_ColumnName + " = @PK3VAL"; } object oldVal = sqlCmd.ExecuteScalar(); paramValueOld.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(oldVal); sqlCmd.Parameters.Add(paramValueOld); } else { paramValueOld.Value = TransportHelperFunctions.convertStringEmptyToDBNULL(string.Empty);; sqlCmd.Parameters.Add(paramValueOld); } var needsNewLog = false; //check if new log needed if (this._ChangeType == ChangeLogChangeType.UPDATE) { //Check if values are different. If different, create log //if date type, parse before compare if (this._DataType == ChangeLog.ChangeLogDataType.DATE || this._DataType == ChangeLog.ChangeLogDataType.DATETIME) { if (DBNull.Value.Equals(paramValueOld.Value)) { needsNewLog = true; } else { DateTime oldDate = DateTime.Parse(paramValueOld.Value.ToString()); DateTime newDate = DateTime.Parse(this._Value_New); if (oldDate.CompareTo(newDate) != 0) { needsNewLog = true; } } } else if (!string.Equals(paramValueOld.Value.ToString(), this._Value_New)) //all other non date/datetime type { needsNewLog = true; } } else { needsNewLog = true; } if (needsNewLog || this._writeLogEvenIfNotNewValue) { sqlCmd.CommandText = "INSERT INTO dbo.ChangeLog VALUES (@CHANGETYPE, @TABLE, @COLNAME, @TIME, @CHANGEBY, @DATA, @OLDVAL, @NEWVAL, @EID, @PK1COL, @PK1VAL, @PK2COL, @PK2VAL, @PK3COL, @PK3VAL, @UNDO)"; sqlCmd.ExecuteNonQuery(); } scope.Complete(); } } catch (SqlException excep) { string strErr = " SQLException Error in ChangeLog CreateChangeLogEntry(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); rethrow = true; ExToRethrow = excep; } catch (Exception ex) { string strErr = " Exception Error in ChangeLog CreateChangeLogEntry(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); rethrow = true; ExToRethrow = ex; } finally { if (rethrow) { throw ExToRethrow; } if (this._closeConnectionAfter && sqlConn != null && sqlConn.State != ConnectionState.Closed) { sqlConn.Close(); sqlConn.Dispose(); } } }
private void createMenuItems() { try { string currentUrl = Request.Url.ToString(); HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); ZXPUserData zxpUD = new ZXPUserData(); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); AuditLog aLog = new AuditLog(zxpUD._uid); aLog.createNewAuditLogEntry(aLog); MenuItem temp = new MenuItem(); if (true) { temp.NavigateUrl = "~/Default.aspx"; temp.Text = "Home"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isGuard || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin || zxpUD._isAccountManager) { temp.NavigateUrl = "~/trailerOverview.aspx"; temp.Text = "Truck Schedule"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); //need to set to new Menuitem for next and prevent index bound error } if (zxpUD._isAdmin || zxpUD._isGuard || zxpUD._isAccountManager) { temp.NavigateUrl = "~/guardStation.aspx"; temp.Text = "Guard Station"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); //need to set to new Menuitem for next and prevent index bound error } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin || zxpUD._isGuard || zxpUD._isYardMule) { temp.NavigateUrl = "~/yardAndWaiting.aspx"; temp.Text = "Yard and Waiting Area"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLoader) { temp.NavigateUrl = "~/inspectionMobile.aspx"; temp.Text = "Inspections"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin) { temp.NavigateUrl = "~/Samples.aspx"; temp.Text = "Samples"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._uid != -1) //make available to everyone logged in { temp.NavigateUrl = "~/waitAndDockOverview.aspx"; temp.Text = "Dashboard"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager) { temp.NavigateUrl = "~/dockManager.aspx"; temp.Text = "Dock Manager"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (true) { temp.NavigateUrl = "~/loadermobile.aspx"; temp.Text = "Loader Mobile"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isLoader) { temp.NavigateUrl = "~/loaderTimeTracking.aspx"; temp.Text = "Loader Requests"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isYardMule) { temp.NavigateUrl = "~/yardMuleRequestOverview.aspx"; temp.Text = "Yard Mule Requests"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._canViewReports) { temp.NavigateUrl = Properties.Settings.Default.ReportViewerLink; temp.Text = "Reports"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isGuard || zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isAccountManager || zxpUD._isAdmin) { temp.NavigateUrl = "~/COFAUpload.aspx"; temp.Text = "COFA Upload"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isGuard || zxpUD._isAdmin) { temp.NavigateUrl = "~/rejectTruck.aspx"; temp.Text = "Reject Truck"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin) { temp.NavigateUrl = "~/AdminMainPage.aspx"; temp.Text = "Admin"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } } } catch (Exception ex) { string strErr = " Exception Error in Site.Master createMenuItems(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } }
public List <object> sendAlertMessage(bool isHtml) { bool didSucceed = false; string returnMsg = string.Empty; MailMessage newAlertMsg = new MailMessage(); newAlertMsg.IsBodyHtml = isHtml; newAlertMsg.From = new MailAddress(this._from); foreach (string eaTO in this._emailAddressesTO) { newAlertMsg.To.Add(eaTO); } foreach (string eaCC in this._emailAddressesCC) { newAlertMsg.CC.Add(eaCC); } foreach (string eaCC in this._emailAddressesCC) { newAlertMsg.CC.Add(eaCC); } newAlertMsg.Subject = this._subject; newAlertMsg.Body = this._body; try { string smtpHost = ConfigurationManager.AppSettings["SmtpHost"]; string smtpIP = ConfigurationManager.AppSettings["SmtpIPAddress"]; int smtpPort = Convert.ToInt16(ConfigurationManager.AppSettings["SmtpPort"]); string smtpUser = ConfigurationManager.AppSettings["SmtpUser"]; string smtpPass = ConfigurationManager.AppSettings["SmtpPass"]; if (string.IsNullOrEmpty(smtpHost) || string.IsNullOrEmpty(smtpIP) || (0 == smtpPort) || string.IsNullOrEmpty(smtpUser) || string.IsNullOrEmpty(smtpPass)) { returnMsg = "Missing Configuration for Alert Messaging. "; throw new Exception(returnMsg); } using (SmtpClient smtp = new SmtpClient(smtpIP)) { smtp.Host = smtpHost; smtp.EnableSsl = true; smtp.Port = smtpPort; smtp.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPass); smtp.Send(newAlertMsg); didSucceed = true; returnMsg = "Alert message sent successfully."; } } catch (Exception ex) { string strErr = " Exception Error in AlertMessenger sendAlertMessage(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); didSucceed = false; returnMsg = returnMsg + "Unable to send alert message due to an error. Please try again. If the error continues please contact your IT Administrator or Application Manager. "; throw ex; } List <object> returnObj = new List <object>(); returnObj.Add(didSucceed); returnObj.Add(returnMsg); return(returnObj); }
public static string CreateCustomRejectTruckMessage(int MSID) { string customAlertMsg = string.Empty; string PONum = null; string customerOrderNum = null; string customerID = null; string trailerNum = null; int prodCount = 0; string prodName = null; string prodDesc = null; string rejComment = null; string firstName = null; string lastName = null; try { DataSet truckDetailsDS = GetTruckInfoForRejectCustomMessage(MSID); if (truckDetailsDS != null && truckDetailsDS.Tables.Count != 0) { if (truckDetailsDS.Tables[0].Rows[0]["PONumber"].Equals(DBNull.Value)) { PONum = "N/A"; } else { PONum = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["PONumber"]); } if (truckDetailsDS.Tables[0].Rows[0]["PONumber_ZXPOutbound"].Equals(DBNull.Value)) { customerOrderNum = "N/A"; } else { customerOrderNum = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["PONumber_ZXPOutbound"]); } if (truckDetailsDS.Tables[0].Rows[0]["CustomerID"].Equals(DBNull.Value)) { customerID = "N/A"; } else { customerID = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["CustomerID"]); } if (truckDetailsDS.Tables[0].Rows[0]["TrailerNumber"].Equals(DBNull.Value)) { trailerNum = "N/A"; } else { trailerNum = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["TrailerNumber"]); } if (truckDetailsDS.Tables[0].Rows[0]["RejectionComment"].Equals(DBNull.Value)) { rejComment = " "; } else { rejComment = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["RejectionComment"]); } if (truckDetailsDS.Tables[0].Rows[0]["FirstName"].Equals(DBNull.Value)) { firstName = " "; } else { firstName = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["FirstName"]); } if (truckDetailsDS.Tables[0].Rows[0]["LastName"].Equals(DBNull.Value)) { lastName = " "; } else { lastName = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["LastName"]); } if (truckDetailsDS.Tables[0].Rows[0]["ProdCount"].Equals(DBNull.Value)) { prodCount = 0; } else { prodCount = Convert.ToInt32(truckDetailsDS.Tables[0].Rows[0]["ProdCount"]); } if (prodCount == 0) { customAlertMsg = "Truck Rejected. Details: " + System.Environment.NewLine + "PO - Trailer: " + PONum + " - " + trailerNum + System.Environment.NewLine + "Customer Order #: " + customerOrderNum + " Customer ID:" + customerID + System.Environment.NewLine + "Rejected by: " + firstName + " " + lastName + System.Environment.NewLine + "Rejected Comment: " + rejComment + System.Environment.NewLine + "Product: Not defined" + System.Environment.NewLine; } if (prodCount == 1) { if (truckDetailsDS.Tables[0].Rows[0]["topProdID"].Equals(DBNull.Value)) { prodName = "N/A"; } else { prodName = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["topProdID"]); } if (truckDetailsDS.Tables[0].Rows[0]["ProductName_CMS"].Equals(DBNull.Value)) { prodDesc = "N/A"; } else { prodDesc = Convert.ToString(truckDetailsDS.Tables[0].Rows[0]["ProductName_CMS"]); } customAlertMsg = "Truck Rejected. Details: " + System.Environment.NewLine + "PO - Trailer: " + PONum + " - " + trailerNum + System.Environment.NewLine + "Customer Order #: " + customerOrderNum + " Customer ID:" + customerID + System.Environment.NewLine + "Rejected by: " + firstName + " " + lastName + System.Environment.NewLine + "Rejected Comment: " + rejComment + System.Environment.NewLine + "Product: " + prodName + " Part # " + prodDesc + System.Environment.NewLine; } else if (prodCount > 1) { string productString = "Products: " + System.Environment.NewLine; ICollection <Tuple <string, string> > listOfProductDetails = new List <Tuple <string, string> >(); listOfProductDetails = GetProductInfoRejectCustomMessage(MSID); foreach (var item in listOfProductDetails) { productString = productString + "Product Name: " + Convert.ToString(item.Item1) + "Part# :" + Convert.ToString(item.Item2) + System.Environment.NewLine; } customAlertMsg = "Truck Rejected. Details: " + System.Environment.NewLine + "PO - Trailer: " + PONum + " - " + trailerNum + System.Environment.NewLine + "Customer Order #: " + customerOrderNum + " Customer ID:" + customerID + System.Environment.NewLine + "Rejected by: " + firstName + " " + lastName + System.Environment.NewLine + "Rejected Comment: " + rejComment + System.Environment.NewLine + productString + System.Environment.NewLine; } } else { Exception ex = new Exception("No truck info was found. Please check if this is the correct inspection"); throw ex; } } catch (Exception ex) { string strErr = " Exception Error in RejectTruck CreateCustomRejectTruckMessage(). Details: " + ex.ToString(); ErrorLogging.LogErrorAndRedirect(1, strErr); } return(customAlertMsg); }
public static List <object> updateTanksWithCurrentVolumesFromCMS() { int specialTanksConfigurationCount = 0; int prodWithMismatchedUnit = 0; try { //TODO use webservice once set up on server // localhost.CleanUpAndProcessing CAPservice = new localhost.CleanUpAndProcessing(); // CAPservice.Timeout = 10 * 60 * 60 * 1000; //set to 10 min // check = CAPservice.updateTanksWithCurrentVolumesFromCMS().ToList(); List <object[]> cmsAllProdData = getProductsAndVolumeDataFromCMS().ToList(); foreach (object[] cmsProd in cmsAllProdData) { string productName = cmsProd[0].ToString(); double productVolume = Convert.ToDouble(cmsProd[1]); List <object> tankData = GetTankDataByProduct(productName).ToList(); int numOfTanksWProductFound = Convert.ToInt32(tankData[2]); int maxTotalNumOfProductsInTanksFound = Convert.ToInt32(tankData[3]); if (1 == numOfTanksWProductFound && 1 == maxTotalNumOfProductsInTanksFound) { string unit = cmsProd[4].ToString().ToUpper(); if (unit.CompareTo("GAL") == 0 || unit.CompareTo("GALS") == 0) //TODO: ask if tanks update should only check for units with GAL { int tankID = getFirstTankIDOfTankContainingProduct(productName); updateTankCurrentVolume(tankID, productVolume); } else { prodWithMismatchedUnit += 1; } } else if (numOfTanksWProductFound > 1 || maxTotalNumOfProductsInTanksFound > 1) { specialTanksConfigurationCount += 1; } } } catch (SqlException excep) { string strErr = " SQLException Error in dataProcessingAndCleanup updateTanksWithCurrentVolumesFromCMS(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in dataProcessingAndCleanup updateTanksWithCurrentVolumesFromCMS(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } finally { } List <object> returnObj = new List <object>(); returnObj.Add(specialTanksConfigurationCount); returnObj.Add(prodWithMismatchedUnit); return(returnObj); }
public void createAndSendAlertSMS(int alertID, string additionalMsg) { DataSet dataSet = new DataSet(); aMsgr = new AlertMessenger(); try { using (var scope = new TransactionScope()) { sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.StoredProcedure, "sp_truckschedapp_getSMSSubscribersForAlertwAll", new SqlParameter("@pAlertID", alertID)); List <string> SentList = new List <string>(); bool canSendAlert = true; //populate return object foreach (System.Data.DataRow row in dataSet.Tables[0].Rows) { canSendAlert = true; if (SentList.Contains(Convert.ToString(row["SMSemail"]))) { canSendAlert = false; } if (canSendAlert == true) { aMsgr._emailAddressesTO.Add(Convert.ToString(row["SMSemail"])); aMsgr._from = TSConfigHelper.truckReservationEmail; aMsgr._subject = Convert.ToString(row["SMSMessageSubject"]); aMsgr._body = "Default Message: " + Convert.ToString(row["SMSMessageBody"]); aMsgr._body = (additionalMsg != string.Empty) ? ("Additional Message: " + additionalMsg + aMsgr._body) : aMsgr._body; aMsgr.sendAlertMessage(); SentList.Add(Convert.ToString(row["SMSemail"])); aMsgr._emailAddressesTO.Clear(); } } scope.Complete(); } } catch (SqlException excep) { string strErr = " SQLException Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); throw excep; } catch (Exception ex) { string strErr = " Exception Error in EventAlertsHelper createAndSendAlertSMS(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } finally { } }
protected void Page_Load(object sender, EventArgs e) { //1- Check if user already authenticated //2- IF user auth. then show all contents //else look for query string user/passhash params // if they exist - attempt to auth. // if auth. success show all contents //else show error message and quit // else show error message and quit int exceptionErrorCode = 0; try { string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; if (sql_connStr == String.Empty) { throw new Exception("Missing SQLConnectionString in web.config"); } as400_connStr = ConfigurationManager.ConnectionStrings["AS400ConnectionString"].ConnectionString; //as400_connStr = ConfigurationManager.AppSettings["AS400ConnectionString"]; if (string.IsNullOrEmpty(as400_connStr)) { throw new Exception("Missing AS400ConnectionString in web.config"); } HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); } else { Response.BufferOutput = true; bool isValidUser = false; string userName = Request.QueryString["UN"]; string password = Request.QueryString["PS"]; if ((userName == null || userName == String.Empty) || (password == null || password == String.Empty)) { exceptionErrorCode = 6;//error code for unable to validate login throw new Exception("Unable to validate user: no login provided."); } else { isValidUser = isUserCredentialsValid(userName, password); } if (isValidUser == true) { string strUserData = zxpUD.SerializeZXPUserData(zxpUD); System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddDays(5), true, strUserData); string enticket = System.Web.Security.FormsAuthentication.Encrypt(ticket); System.Web.HttpCookie authcookie = new System.Web.HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, enticket); if (ticket.IsPersistent) { authcookie.Expires = ticket.Expiration; } Response.Cookies.Add(authcookie); callAllCleanUpFunctions(); callAllUpdateFunctions(); } else { exceptionErrorCode = 6;//error code for unable to validate login throw new Exception("User is not valid or does not have permission."); } } } catch (SqlException excep) { string strErr = " SQLException Error in dataProcessingAndCleanup Page_Load(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in dataProcessingAndCleanup Page_Load(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); if (exceptionErrorCode > 0) { System.Web.HttpContext.Current.Session["ErrorNum"] = exceptionErrorCode; ErrorLogging.sendtoErrorPage(exceptionErrorCode); } else { System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } } }
public static void deleteInspectionFromInspectionList(int INSPECTIONLISTID, int INSPECTIONHEADERID, int SORTORDER) { DateTime now = DateTime.Now; Int32 rowCount = 0; bool needsVerificationTest = false; int highSortOrderOfTwo = 0; int lowerSortOrderOfTwo = 0; DataSet dataSet = new DataSet(); try { using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; SqlParameter paramInspectionHeaderID = new SqlParameter("@InspectionHeaderID", SqlDbType.Int); SqlParameter paramSortOrder = new SqlParameter("@SortOrder", SqlDbType.Int); SqlParameter paramInspectionListID = new SqlParameter("@InspectionListID", SqlDbType.Int); paramInspectionHeaderID.Value = INSPECTIONHEADERID; paramInspectionListID.Value = INSPECTIONLISTID; sqlCmdText = "Select ISNULL(needsVerificationTest, 0) FROM dbo.InspectionHeader WHERE InspectionHeaderID = @InspectionHeaderID"; needsVerificationTest = Convert.ToBoolean(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID))); if (needsVerificationTest == true) { sqlCmdText = "Select SortOrder FROM dbo.InspectionListsDetails WHERE (InspectionHeaderID = @InspectionHeaderID AND InspectionListID = @InspectionListID) order by SortOrder desc"; dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID), new SqlParameter("@InspectionListID", INSPECTIONLISTID)); var index = 1; //populate return object foreach (System.Data.DataRow row in dataSet.Tables[0].Rows) { if (index == 1) { highSortOrderOfTwo = Convert.ToInt16(row.ItemArray[0]); } else { lowerSortOrderOfTwo = Convert.ToInt16(row.ItemArray[0]); } index++; } } sqlCmdText = "UPDATE dbo.InspectionListsDetails SET isHidden = 'true' WHERE (InspectionHeaderID = @InspectionHeaderID AND InspectionListID = @InspectionListID)"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID), new SqlParameter("@InspectionListID", INSPECTIONLISTID)); sqlCmdText = "SELECT COUNT(InspectionHeaderID) FROM dbo.InspectionListsDetails WHERE InspectionListID = @InspectionListID"; rowCount = Convert.ToInt16(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", INSPECTIONLISTID))); if (rowCount == 0) { //disable inspection list if no inspections are present sqlCmdText = "UPDATE dbo.InspectionLists SET isHidden = 'true' WHERE InspectionListID = @InspectionListID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", INSPECTIONLISTID)); } else { if (needsVerificationTest == true) { dataSet = new DataSet(); sqlCmdText = "SELECT InspectionListDetailsID from dbo.InspectionListsDetails WHERE (InspectionListID = @InspectionListID AND isHidden = 'false') ORDER BY SortOrder"; dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", INSPECTIONLISTID)); int newSortOrderVal = 1; foreach (System.Data.DataRow row in dataSet.Tables[0].Rows) { sqlCmdText = "UPDATE dbo.InspectionListsDetails SET SortOrder = @SortOrder WHERE (InspectionListDetailsID = @InspectionListDetailsID AND InspectionListID = @InspectionListID AND isHidden = 'false')"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SortOrder", newSortOrderVal), new SqlParameter("@InspectionListDetailsID", Convert.ToInt32(row.ItemArray[0])), new SqlParameter("@InspectionListID", INSPECTIONLISTID)); newSortOrderVal++; } } else { //other wise reorder existing inspections in list sqlCmdText = "UPDATE dbo.InspectionListsDetails SET SortOrder = (SortOrder - 1) WHERE (InspectionListID = @InspectionListID AND SortOrder > @SortOrder)"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", INSPECTIONLISTID), new SqlParameter("@SortOrder", SORTORDER)); } } scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_InspectionLists deleteInspectionFromInspectionList(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static int[] setNewInspectionListSetNewInspectionAndAssociate(string INSPECTIONLISTNAME, int INSPECTIONHEADERID) { int rowCount = 0; Int32 InspectionListID = 0; bool needsVerificationTest = false; int[] returnArray = new int[2]; try { using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; SqlParameter paramInspectionListName = new SqlParameter("@InspectionListName", SqlDbType.NVarChar); paramInspectionListName.Value = INSPECTIONLISTNAME; sqlCmdText = "SELECT COUNT (*) FROM dbo.InspectionLists WHERE (InspectionListName = @InspectionListName AND isHidden = 'false')"; rowCount = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListName", INSPECTIONLISTNAME))); if (rowCount > 0) { throw new Exception("Inspection List Name already exist."); } else { sqlCmdText = "INSERT INTO dbo.InspectionLists (InspectionListName, isHidden) " + "VALUES (@InspectionListName, 'false'); " + "SELECT CAST(scope_identity() AS int)"; InspectionListID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListName", INSPECTIONLISTNAME))); returnArray[0] = InspectionListID; sqlCmdText = "Select ISNULL(needsVerificationTest, 0) FROM dbo.InspectionHeader WHERE InspectionHeaderID = @InspectionHeaderID"; needsVerificationTest = Convert.ToBoolean(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID))); sqlCmdText = "INSERT INTO dbo.InspectionListsDetails (InspectionListID, InspectionHeaderID, SortOrder, isHidden) " + "VALUES (@InspectionListID, @InspectionHeaderID, 1, 'false'); " + "SELECT CAST(scope_identity() AS int)"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", InspectionListID), new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID)); if (needsVerificationTest == true) { sqlCmdText = "INSERT INTO dbo.InspectionListsDetails (InspectionListID, InspectionHeaderID, SortOrder, isHidden) " + "VALUES (@InspectionListID, @InspectionHeaderID, 2, 'false'); " + "SELECT CAST(scope_identity() AS int)"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@InspectionListID", InspectionListID), new SqlParameter("@InspectionHeaderID", INSPECTIONHEADERID)); returnArray[1] = 1; } } scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_InspectionLists setNewInspectionListSetNewInspectionAndAssociate(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(returnArray); }
public static Object checkIfCOFAcanBeDeleted(int MSID, int SampleID) { List <string> returnValue = new List <string>(); bool isHidden; string testStatus; string location; int COFA_File; DataSet dataSet = new DataSet(); try { using (var scope = new TransactionScope()) { string sqlCmdText; string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "SELECT S.isHidden, ISNULL(FileID_COFA, 0) AS FileID_COFA, \"testStatus\" = " + "CASE S.TestApproved " + "WHEN 'true' THEN 'approved' " + "WHEN 'false' THEN 'rejected' " + "ELSE 'incomplete' " + "END " + "FROM dbo.Samples AS S " + "WHERE S.SampleID = @sampleID"; dataSet = SqlHelper.ExecuteDataset(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@sampleID", SampleID)); isHidden = Convert.ToBoolean(dataSet.Tables[0].Rows[0]["isHidden"]); testStatus = Convert.ToString(dataSet.Tables[0].Rows[0]["testStatus"]); COFA_File = Convert.ToInt32(dataSet.Tables[0].Rows[0]["FileID_COFA"]); if (isHidden == true) { returnValue.Add("false"); returnValue.Add("This sample no longer exist. Please refresh the page to get the current list of samples."); return(returnValue); } if (testStatus != "incomplete") { returnValue.Add("false"); returnValue.Add("Sample has been " + testStatus + " and its COFA can not be deleted. You can reupload the COFA to replace the current file."); return(returnValue); } if (COFA_File == 0) { returnValue.Add("false"); returnValue.Add("COFA has already been deleted. Please refresh the page to get latest data."); return(returnValue); } sqlCmdText = "SELECT LocationShort from dbo.MainSchedule as MS WHERE MSID = @MSID"; location = Convert.ToString(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID))); if (location == "NOS") { returnValue.Add("false"); returnValue.Add("This order is no longer on site and can not be updated. Please refresh the page to get latest data."); } returnValue.Add("true"); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in COFAUpload getAvailableDockSpots(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(returnValue); }
public static void AddFileDBEntry(int MSID, string fileType, string filenameOld, string filenameNew, string filepath, string fileDescription, int SampleID) { DateTime now = DateTime.Now; int eventID = 0; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; //First find filetypeID sqlCmdText = "SELECT FileTypeID FROM dbo.FileTypes WHERE FileType = @FTYPE"; int filetypeID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@FTYPE", fileType))); //1. create event in Main Schedule Events sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID, TimeStamp, UserID, isHidden) VALUES (@PMSID, 4097, @TSTAMP, @UserID, 'false'); " + "SELECT CAST(scope_identity() AS int)"; eventID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PMSID", MSID), new SqlParameter("@TSTAMP", now), new SqlParameter("@UserID", zxpUD._uid))); //2. create file data in Main Schedule Files sqlCmdText = "INSERT INTO dbo.MainScheduleFiles (MSID, FileTypeID, FileDescription, Filepath, FilenameNew, FilenameOld, isHidden) " + "VALUES (@PMSID, @PFTID, @PDESC, @PFPATH, @PFNEW, @PFOLD, 0);" + "SELECT SCOPE_IDENTITY()"; int newFileID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PMSID", MSID), new SqlParameter("@PFTID", filetypeID), new SqlParameter("@PDESC", fileDescription), new SqlParameter("@PFPATH", filepath), new SqlParameter("@PFNEW", filenameNew), new SqlParameter("@PFOLD", filenameOld))); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "MSID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, MSID.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "FileTyepID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, filetypeID.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "FileDescription", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, fileDescription.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "Filepath", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, filepath.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "FilenameNew", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, filenameNew.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "FilenameOld", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, filenameOld.ToString(), eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleFiles", "isHidden", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "0", eventID, "FileID", newFileID.ToString()); cl.CreateChangeLogEntryIfChanged(); //3.Update LastUpdated in MainSchedule cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "LastUpdated", now, zxpUD._uid, ChangeLog.ChangeLogDataType.DATETIME, now.ToString(), eventID, "MSID", MSID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.MainSchedule SET LastUpdated = @TSTAMP WHERE (MSID = @PMSID)"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@TSTAMP", now), new SqlParameter("@PMSID", MSID)); //4. update samples tbl cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Samples", "FileID_COFA", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, newFileID.ToString(), eventID, "SampleID", SampleID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Samples SET FileID_COFA = @FID, COFAEventID = @eventID WHERE SampleID = @SampleID; "; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@FID", newFileID), new SqlParameter("@eventID", eventID), new SqlParameter("@SampleID", SampleID)); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in COFAUpload AddFileDBEntry(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }