Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
                if (null != cookie && !string.IsNullOrEmpty(cookie.Value))
                {
                    ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();

                    if (!(zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isGuard || zxpUD._isAdmin)) //make sure this matches whats in Site.Master and Default
                    {
                        Response.BufferOutput = true;
                        Response.Redirect("/ErrorPage.aspx?ErrorCode=5", false);
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    Response.Redirect("/Account/Login.aspx?ReturnURL=/rejectTruck.aspx", false); //zxp live
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in RejectTruck Page_Load(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in RejectTruck Page_Load(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
        }
Пример #2
0
        public static void DeleteFileDBEntry(int SampleID, int MSID)
        {
            DateTime now = DateTime.Now;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText;
                    string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID, TimeStamp, UserID, isHidden) VALUES (@MSID, 4098, @TSTAMP, @UserID, 'false'); " +
                                 "SELECT SCOPE_IDENTITY()";
                    int eventID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID),
                                                                          new SqlParameter("@TSTAMP", now),
                                                                          new SqlParameter("@UserID", zxpUD._uid)));

                    ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Samples", "FileID_COFA", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, null, eventID, "SampleID", SampleID.ToString());
                    cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "UPDATE dbo.Samples SET FileID_COFA = NULL, COFAEventID = NULL WHERE SampleID = @SampleID";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SampleID", SampleID));
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in COFAUpload DeleteFileDBEntry(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
                throw ex;
            }
        }
Пример #3
0
        public static void SetRejectionComment(int MSID, string COMMENT)
        {
            DateTime now = DateTime.Now;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText;
                    string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "RejectionComment", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, TransportHelperFunctions.convertStringEmptyToDBNULL(COMMENT).ToString(), null, "MSID", MSID.ToString());
                    cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "UPDATE dbo.MainSchedule SET RejectionComment = @COMMENT " +
                                 "WHERE (MSID = @MSID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@COMMENT", TransportHelperFunctions.convertStringEmptyToDBNULL(COMMENT)),
                                              new SqlParameter("@MSID", MSID));
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in RejectTruck SetRejectionComment(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                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 = ZXPUserData.GetZXPUserDataFromCookie();
                    zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData);

                    if (!(zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isLoader || zxpUD._isYardMule)) //make sure this matches whats in Site.Master and Default
                    {
                        Response.BufferOutput = true;
                        Response.Redirect("ErrorPage.aspx?ErrorCode=5", false); //zxp live url
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    Response.Redirect("Account/Login.aspx?ReturnURL=~/loaderMobile.aspx", false);//zxp live url
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in loaderMobile Page_Load(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in loaderMobile Page_Load(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
        }//page_load()
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
                //if (null != cookie && !string.IsNullOrEmpty(cookie.Value))

                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                if (zxpUD._uid != new ZXPUserData()._uid)
                {
                    if (!zxpUD._isAdmin) //make sure this matches whats in Site.Master and Default
                    {
                        Response.BufferOutput = true;
                        Response.Redirect("/ErrorPage.aspx?ErrorCode=5", false);
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    //Response.Redirect("/Account/Login.aspx?ReturnURL=/AdminMainPage.aspx", false); mi4 url
                    Response.Redirect("Account/Login.aspx?ReturnURL=~/AdminMainPage.aspx", false);//zxp live url
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in AdminMainPage Page_Load(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
            }
        }
Пример #6
0
        public static void setCOFAComment(int SAMPLEID, string COMMENT)
        {
            DateTime now = DateTime.Now;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText;
                    string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Samples", "COFAComment", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, COMMENT, null, "SampleID", SAMPLEID.ToString());
                    cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "UPDATE dbo.Samples SET COFAComment = @COFAComment " +
                                 "WHERE (SampleID = @SampleID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@COFAComment", COMMENT),
                                              new SqlParameter("@SampleID", SAMPLEID));
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in COFAUpload setCOFAComment(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
                throw ex;
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
                //if (null != cookie && !string.IsNullOrEmpty(cookie.Value))

                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                if (zxpUD._uid != new ZXPUserData()._uid)
                {
                    //ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();

                    if (zxpUD._isAdmin) //make sure this matches whats in Site.Master and Default
                    {
                        sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                        if (sql_connStr == String.Empty)
                        {
                            throw new Exception("Missing SQLConnectionString in web.config");
                        }
                    }
                    else
                    {
                        Response.BufferOutput = true;
                        Response.Redirect("ErrorPage.aspx?ErrorCode=5", false); //zxp live url
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    Response.Redirect("Account/Login.aspx?ReturnURL=~/AdminMainPage.aspx", false);//zxp live url
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in Admin_InspectionLists 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 Admin_InspectionLists Page_Load(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
            }
        }
        public static List <object> canInspectionBeEdited(int prodDetailID, int MSInspectionListID, int MSInspectionID)
        {
            List <object> returnObj = new List <object>();

            try
            {
                string      sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                ZXPUserData zxpUD       = ZXPUserData.GetZXPUserDataFromCookie();
                returnObj = InspectionsHelperFunctions.canInspectionBeEdited(prodDetailID, MSInspectionListID, MSInspectionID, sql_connStr, zxpUD);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in loaderMobile canInspectionBeStarted(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            return(returnObj);
        }
Пример #9
0
        public static void UndoARejectedTruck(int MSID)
        {
            DateTime now = DateTime.Now;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText;
                    string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    //Create an entry in Event Log
                    sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID,Timestamp, UserId, isHidden) " +
                                 "VALUES (@MSID, 3037, @TIME, @USER, 'false'); " +
                                 "SELECT SCOPE_IDENTITY()";
                    int eventID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID),
                                                                          new SqlParameter("@TIME", now),
                                                                          new SqlParameter("@USER", zxpUD._uid)));
                    sqlCmdText = "UPDATE dbo.MainScheduleEvents SET isHidden = 'true' " +
                                 "WHERE (MSID = @MSID) AND EventTypeID = 2037;";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID));

                    ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "isRejected", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "false", eventID, "MSID", MSID.ToString());
                    cl.CreateChangeLogEntryIfChanged();
                    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 isRejected = 'false', LastUpdated = @TIME " +
                                 "WHERE (MSID = @MSID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID),
                                              new SqlParameter("@TIME", now));
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in RejectTruck UndoARejectedTruck(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
        }
        public static void CloseOutTruckSchedules(List <int> MSIDs)
        {
            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                DataTable   tvp   = new DataTable();
                tvp.Columns.Add(new DataColumn("MSID", typeof(int)));

                foreach (int id in MSIDs)
                {
                    tvp.Rows.Add(id);
                }

                using (var scope = new TransactionScope())
                {
                    SqlCommand    cmd     = new SqlCommand("dbo.sp_truckschedapp_closeOutTruckSchedule");
                    SqlConnection sqlConn = new SqlConnection(sql_connStr);
                    if (sqlConn.State != ConnectionState.Open)
                    {
                        sqlConn.Open();
                    }
                    cmd.Connection  = sqlConn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    SqlParameter msidarray = cmd.Parameters.AddWithValue("@MSIDList", tvp);
                    msidarray.SqlDbType = SqlDbType.Structured;
                    msidarray.TypeName  = "dbo.MSIDList";
                    cmd.Parameters.AddWithValue("@UserID", zxpUD._uid);
                    cmd.ExecuteNonQuery();

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in AdminCleanUp CloseOutTruckSchedules(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
                throw ex;
            }
        }
        public static List <object> setInspectionResult(int MSInspectionID, int testID, int result, int prodDetailID)
        {
            List <object> returnData = new List <object>();

            try
            {
                string      sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                ZXPUserData zxpUD       = ZXPUserData.GetZXPUserDataFromCookie();
                returnData = InspectionsHelperFunctions.setInspectionResult(MSInspectionID, testID, result, prodDetailID, sql_connStr, zxpUD);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in loaderMobile setInspectionResult(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }

            //returnData.Add(timestamp);
            //returnData.Add(returnMsg);
            //returnData.Add(hasEnded);
            //returnData.Add(isLastQuestion);
            return(returnData);
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string     sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                HttpCookie cookie      = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
                if (null != cookie && !string.IsNullOrEmpty(cookie.Value))
                {
                    ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                    System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value);
                    zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData);

                    if (!(zxpUD._isGuard || zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isAccountManager || zxpUD._isAdmin)) //make sure this matches whats in Site.Master and Default
                    {
                        Response.BufferOutput = true;
                        Response.Redirect("/ErrorPage.aspx?ErrorCode=5", false);
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    Response.Redirect("/Account/Login.aspx?ReturnURL=/COFAUpload.aspx", false); //zxp live
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in COFAUpload 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 COFAUpload Page_Load(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
            }
        }
Пример #13
0
        public static string RejectATruck(int MSID)
        {
            DateTime now = DateTime.Now;
            string   nowFormatted;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText;
                    string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                    ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "isRejected", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "1", null, "MSID", MSID.ToString());
                    cl.CreateChangeLogEntryIfChanged();
                    cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "LastUpdated", now, zxpUD._uid, ChangeLog.ChangeLogDataType.DATETIME, now.ToString(), null, "MSID", MSID.ToString());
                    cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "UPDATE dbo.MainSchedule SET isRejected = 1, LastUpdated = @TIME " +
                                 "WHERE (MSID = @MSID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@TIME", now),
                                              new SqlParameter("@MSID", MSID));
                    scope.Complete();
                }
                MainScheduleEventLogger msEventLog = new MainScheduleEventLogger();
                MainScheduleEvent       msEvent    = new MainScheduleEvent(MSID, 2037, null, now, zxpUD._uid, false);
                int    newEventID     = msEventLog.createNewEventLog(msEvent);
                string customAlertMsg = CreateCustomRejectTruckMessage(MSID);
                msEventLog.TriggerExistingAlertForEvent(newEventID, customAlertMsg);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in RejectTruck GetGridData(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            nowFormatted = now.ToString("ddd MMM dd yyyy HH:mm:ss K");
            return(now.ToString());
        }
Пример #14
0
        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;
            int autotrigger        = 0;

            try
            {
                truckReservationEmail = ConfigurationManager.AppSettings["SmtpUser"];

                ZXPUserData zxpUD       = ZXPUserData.GetZXPUserDataFromCookie();
                string      sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                if (zxpUD._uid != new ZXPUserData()._uid)
                {
                    sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                    if (sql_connStr == String.Empty)
                    {
                        throw new Exception("Missing SQLConnectionString in web.config");
                    }
                    if (truckReservationEmail == String.Empty)
                    {
                        throw new Exception("Missing SmtpUser in web.config");
                    }
                }
                else
                {
                    Response.BufferOutput = true;
                    bool   isValidLoginURL = false;
                    string userName        = Request.QueryString["UN"];
                    string password        = Request.QueryString["PS"];
                    string strAuto         = Request.QueryString["AUTOTRIGGER"]; //check if this should trigger all
                    autotrigger = Convert.ToInt32(strAuto);
                    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
                    {
                        isValidLoginURL = loginForAlertProcessing(userName, password);
                    }

                    if (isValidLoginURL == 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);
                    }
                    else
                    {
                        exceptionErrorCode = 6;//error code for unable to validate login
                        throw new Exception("Unable to validate user.");
                    }
                }
                if (1 == autotrigger)
                {
                    sendAllAlertsAutomatically();
                }

                showContents();
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in alertsProcessing 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 alertsProcessing 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 DateTime completeRequest(int requestID, int requestTypeID, int MSID)
        {
            SqlConnection sqlConn   = new SqlConnection();
            DateTime      timeStamp = DateTime.Now;

            try
            {
                ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie();
                sqlConn = new SqlConnection();
                string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                string sqlQuery    = string.Empty;
                int    eventID     = 0;
                MainScheduleEventLogger msEventLog = new MainScheduleEventLogger();
                if (requestTypeID == 1) //Load
                {
                    MainScheduleEvent msEvent     = new MainScheduleEvent(MSID, 16, null, timeStamp, zxpUD._uid, false);
                    string            newAlertMsg = createCustomMessageForCompletedTask(requestID);
                    eventID = msEventLog.createNewEventLogAndTriggerExistingAlerts(msEvent, "Loading Finished. " + newAlertMsg);
                }
                else if (requestTypeID == 2) //Unload
                {
                    MainScheduleEvent msEvent     = new MainScheduleEvent(MSID, 14, null, timeStamp, zxpUD._uid, false);
                    string            newAlertMsg = createCustomMessageForCompletedTask(requestID);
                    eventID = msEventLog.createNewEventLogAndTriggerExistingAlerts(msEvent, "Unloading Finished. " + newAlertMsg);
                }
                else if (requestTypeID == 3) //Other
                {
                    MainScheduleEvent msEvent     = new MainScheduleEvent(MSID, 2031, null, timeStamp, zxpUD._uid, false);
                    string            newAlertMsg = createCustomMessageForCompletedTask(requestID);
                    eventID = msEventLog.createNewEventLogAndTriggerExistingAlerts(msEvent, newAlertMsg);
                }

                if (eventID == 0)
                {
                    throw new Exception("Invalid eventID. Error creating new event log.");
                }

                using (var scope = new TransactionScope())
                {
                    sqlQuery = "INSERT INTO dbo.MainScheduleRequestEvents(RequestID, EventID) " +
                               "VALUES(@RID, @EID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlQuery, new SqlParameter("@RID", requestID), new SqlParameter("@EID", eventID));

                    sqlQuery = "UPDATE dbo.MainSchedule SET LastUpdated = @TIME WHERE (MSID = @MSID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlQuery, new SqlParameter("@MSID", MSID), new SqlParameter("@TIME", timeStamp));



                    sqlConn = new SqlConnection(new TruckScheduleConfigurationKeysHelper().sql_connStr);
                    ChangeLog Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleRequestEvents", "RequestID", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, requestID.ToString(), eventID, "RequestID", requestID.ToString(), "EventID", eventID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();
                    Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleRequestEvents", "EventID", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, eventID.ToString(), eventID, "RequestID", requestID.ToString(), "EventID", eventID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();
                    Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "MainSchedule", "LastUpdated", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, timeStamp.ToString(), eventID, "MSID", MSID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();

                    scope.Complete();
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in loaderMobile completeRequest(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in loaderMobile completeRequest(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            finally
            {
                if (sqlConn != null && sqlConn.State != ConnectionState.Closed)
                {
                    sqlConn.Close();
                    sqlConn.Dispose();
                }
            }
            return(timeStamp);
        }
        public static DateTime startRequest(int requestID, int requestTypeID, int MSID)
        {
            DateTime timeStamp = DateTime.Now;

            try
            {
                string      sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;
                ZXPUserData zxpUD       = ZXPUserData.GetZXPUserDataFromCookie();
                using (var scope = new TransactionScope())
                {
                    string sqlCmdText = string.Empty;

                    if (requestTypeID == 1) //Load
                    {
                        //loader - EventTypeID = 15 --> "Loading Started"
                        sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID,Timestamp, UserId, isHidden) " +
                                     "VALUES (@MSID, 15, @TIME, @LOADER, 'false'); " +
                                     "SELECT SCOPE_IDENTITY()";
                    }
                    else if (requestTypeID == 2) //Unload
                    {
                        //loader  - EventTypeID = 13 --> "Unloading Started"
                        sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID,Timestamp, UserId, isHidden) " +
                                     "VALUES (@MSID, 13, @TIME, @LOADER, 'false'); " +
                                     "SELECT SCOPE_IDENTITY()";
                    }
                    else if (requestTypeID == 3) //Other
                    {
                        //loader  - EventTypeID = 2030 --> "Loader Assignment Started"
                        sqlCmdText = "INSERT INTO dbo.MainScheduleEvents (MSID, EventTypeID,Timestamp, UserId, isHidden) " +
                                     "VALUES (@MSID, 2030, @TIME, @LOADER, 'false'); " +
                                     "SELECT SCOPE_IDENTITY()";
                    }
                    int eventID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@MSID", MSID),
                                                                          new SqlParameter("@TIME", timeStamp),
                                                                          new SqlParameter("@LOADER", zxpUD._uid)));

                    ChangeLog Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Requests", "Assignee", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, zxpUD._uid.ToString(), eventID, "RequestID", requestID.ToString(), "RequestID", requestID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "UPDATE dbo.Requests SET Assignee = @LOADER WHERE RequestID = @RID";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@LOADER", zxpUD._uid),
                                              new SqlParameter("@RID", requestID));

                    Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleRequestEvents", "RequestID", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, requestID.ToString(), eventID, "RequestID", requestID.ToString(), "EventID", eventID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();
                    Cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "MainScheduleRequestEvents", "EventID", timeStamp, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, eventID.ToString(), eventID, "RequestID", requestID.ToString(), "EventID", eventID.ToString());
                    Cl.CreateChangeLogEntryIfChanged();

                    sqlCmdText = "INSERT INTO dbo.MainScheduleRequestEvents(RequestID, EventID) " +
                                 "VALUES(@RID, @EID)";
                    SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@RID", requestID),
                                              new SqlParameter("@EID", eventID));
                    scope.Complete();
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in loaderMobile startRequest(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in loaderMobile startRequest(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            return(timeStamp);
        }
Пример #17
0
        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;
            }
        }
 public static ZXPUserData GetLoggedInUser()
 {
     return(ZXPUserData.GetZXPUserDataFromCookie());;
 }