Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 3
0
 public Inspection()
 {
     this.MSInspectionID           = 0;
     this.InspectionHeaderID       = 0;
     this.MSInspectionListDetailID = 0;
     this.InspectionStartEventID   = 0;
     this.InspectionEndEventID     = 0;
     this.isHidden             = true;
     this.InspectionHeaderName = string.Empty;
     this.InspectionTypeID     = 0;
     this.LoadType             = string.Empty;
     this.UserID                = 0;
     this.RunNumber             = 0;
     this.InspectionComment     = string.Empty;
     this.needsVerificationTest = true;
     this.isFailed              = true;
     this.wasAutoClosed         = true;
     this.questions             = new List <InspectionQuestion>();
     this.MSStartEvent          = new MainScheduleEvent();
     this.MSEndEvent            = new MainScheduleEvent();
     this.UserLastModified      = new ZXPUserData();
     this.UserVerifying         = new ZXPUserData();
     this.UserCreated           = new ZXPUserData();
     this.LastModifiedTimestamp = new DateTime(1900, 1, 1);
 }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
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()
Exemplo n.º 7
0
 public Inspection(int MSInspectionID, int InspectionHeaderID, int MSInspectionListDetailID, int?InspectionStartEventID, int?InspectionEndEventID,
                   bool isHidden, string InspectionHeaderName, int?InspectionTypeID, string LoadType, int?UserID, int?RunNumber, string InspectionComment,
                   bool needsVerificationTest, bool isFailed, bool wasAutoClosed, MainScheduleEvent MSStartEvent, MainScheduleEvent MSEndEvent,
                   ZXPUserData UserCreated, ZXPUserData UserVerifying, ZXPUserData UserLastModified, DateTime LastModifiedTimestamp)
 {
     this.MSInspectionID           = MSInspectionID;
     this.InspectionHeaderID       = InspectionHeaderID;
     this.MSInspectionListDetailID = MSInspectionListDetailID;
     this.InspectionStartEventID   = InspectionStartEventID;
     this.InspectionEndEventID     = InspectionEndEventID;
     this.isHidden             = isHidden;
     this.InspectionHeaderName = InspectionHeaderName;
     this.InspectionTypeID     = InspectionTypeID;
     this.LoadType             = LoadType;
     this.UserID                = UserID;
     this.RunNumber             = RunNumber;
     this.InspectionComment     = InspectionComment;
     this.needsVerificationTest = needsVerificationTest;
     this.isFailed              = isFailed;
     this.wasAutoClosed         = wasAutoClosed;
     this.questions             = new List <InspectionQuestion>();
     this.MSStartEvent          = MSStartEvent;
     this.MSEndEvent            = MSEndEvent;
     this.UserCreated           = UserCreated;
     this.UserVerifying         = UserVerifying;
     this.UserLastModified      = UserLastModified;
     this.LastModifiedTimestamp = LastModifiedTimestamp;
 }
Exemplo n.º 8
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))
         {
             System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value);
             zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData);
         }
         else
         {
             Response.BufferOutput = true;
             //  Response.Redirect("/Account/Login.aspx?ReturnURL=/Default.aspx", false); mi4 url
             Response.Redirect("Account/Login.aspx?ReturnURL=~/Default.aspx", false);//zxp live url
         }
     }
     catch (Exception ex)
     {
         string strErr = " Exception Error in Default Page_Load(). Details: " + ex.ToString();
         ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
         System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
         ErrorLogging.sendtoErrorPage(1);
     }
 }
Exemplo n.º 9
0
        public static ZXPUserData GetZXPUserDataFromCookie()
        {
            ZXPUserData zxpUD = new ZXPUserData();

            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName];
                if (null != cookie)
                {
                    if (!string.IsNullOrEmpty(cookie.Value))
                    {
                        System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value);
                        zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData);
                    }
                }
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in ZXPUserData GetZXPUserDataFromCookie(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                throw;
            }

            return(zxpUD);
        }
Exemplo n.º 10
0
 public string SerializeZXPUserData(ZXPUserData UserData)
 {
     System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
     System.IO.MemoryStream mem = new System.IO.MemoryStream();
     bf.Serialize(mem, UserData);
     return(System.Convert.ToBase64String(mem.ToArray()));
 }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
0
        public static ZXPUserData DeserializeZXPUserData(string strUserData)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            System.IO.MemoryStream mem = new System.IO.MemoryStream(System.Convert.FromBase64String(strUserData));
            ZXPUserData            ud  = (ZXPUserData)bf.Deserialize(mem);

            return(ud);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 15
0
        private bool loginForAlertProcessing(string userName, string password)
        {
            ZXPUserData zxpUD       = new ZXPUserData();
            int         rowCount    = 0;
            bool        isValidUser = false;

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

                    sqlCmdText = "SELECT COUNT (*) FROM dbo.Users WHERE [Password] = @UPASS AND UserName = @UNAME AND isDisabled = 0";
                    rowCount   = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@UNAME", userName), new SqlParameter("@UPASS", DataTransformer.PasswordHash(password))));

                    if (rowCount > 0)
                    {
                        isValidUser = true;
                    }
                    else
                    {
                        isValidUser = false;
                        throw new Exception("Invalid login.");
                    }
                    scope.Complete();
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in alertsProcessing loginForAlertProcessing(). Details: " + excep.ToString();
                ErrorLogging.LogErrorAndRedirect(2, strErr);
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in alertsProcessing loginForAlertProcessing(). Details: " + ex.ToString();
                ErrorLogging.LogErrorAndRedirect(1, strErr);
            }
            finally
            {
            }
            return(isValidUser);
        }
        private bool isUserCredentialsValid(string userName, string password)
        {
            ZXPUserData zxpUD       = new ZXPUserData();
            int         rowCount    = 0;
            bool        isValidUser = false;

            try
            {
                string sqlCmdText;
                string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

                sqlCmdText = "SELECT COUNT (*) FROM dbo.Users WHERE [Password] = @UPASS AND UserName = @UNAME AND isDisabled = 0";
                rowCount   = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@UPASS", DataTransformer.PasswordHash(password)),
                                                                     new SqlParameter("@UNAME", userName)));
                if (rowCount > 0)
                {
                    isValidUser = true;
                }
                else
                {
                    isValidUser = false;
                    throw new Exception("Invalid login.");
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in dataProcessingAndCleanUp isUserCredentialsValid(). 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 isUserCredentialsValid(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                System.Web.HttpContext.Current.Session["ErrorNum"] = 1;
                ErrorLogging.sendtoErrorPage(1);
            }
            finally
            {
            }
            return(isValidUser);
        }
        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;
            }
        }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
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);
            }
        }
        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);
        }
Exemplo n.º 21
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());
        }
Exemplo n.º 22
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 ZXPUserData GetLoggedInUser()
 {
     return(ZXPUserData.GetZXPUserDataFromCookie());;
 }
        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 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);
        }
Exemplo n.º 27
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;
            }
        }
Exemplo n.º 28
0
        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);
            }
        }