コード例 #1
0
        public int createNewEventLogAndTriggerExistingAlerts(MainScheduleEvent MSEvent, string customAlertMsg)
        {
            this.MSEvent = new MainScheduleEvent(MSEvent);
            int newEventID = 0;

            newEventID = this.createNewEventLogAndTriggerExistingAlerts(customAlertMsg);
            return(newEventID);
        }
コード例 #2
0
 public MainScheduleEvent(MainScheduleEvent newMSEvent)
 {
     this.EventID        = newMSEvent.EventID;
     this.MSID           = newMSEvent.MSID;
     this.EventTypeID    = newMSEvent.EventTypeID;
     this.EventSubtypeID = newMSEvent.EventSubtypeID;
     this.TimeStamp      = newMSEvent.TimeStamp;
     this.UserID         = newMSEvent.UserID;
     this.isHidden       = newMSEvent.isHidden;
     this.EventID        = newMSEvent.EventID;
 }
コード例 #3
0
        public int createNewEventLog(MainScheduleEvent MSEvent)
        {
            int nEventID = 0;

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

                    nEventID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.StoredProcedure, "sp_truckschedapp_LogMainScheduleEvent", new SqlParameter("@pMSID", MSEvent.MSID),
                                                                       new SqlParameter("@pEventTypeID", MSEvent.EventTypeID),
                                                                       new SqlParameter("@pEventSubTypeID", TransportHelperFunctions.convertStringEmptyToDBNULL(MSEvent.EventSubtypeID)),
                                                                       new SqlParameter("@pTimestamp", MSEvent.TimeStamp),
                                                                       new SqlParameter("@pUserID", MSEvent.UserID),
                                                                       new SqlParameter("@pIsHidden", MSEvent.isHidden)));
                    if (nEventID == 0)
                    {
                        throw new Exception("CreateNewEventLog Failed");
                    }
                    scope.Complete();
                }
            }
            catch (SqlException excep)
            {
                string strErr = " SQLException Error in MainScheduleEventLogger createNewEventLog(). Details: " + excep.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                ErrorLogging.sendtoErrorPage(2);
                throw excep;
            }
            catch (Exception ex)
            {
                string strErr = " Exception Error in MainScheduleEventLogger createNewEventLog(). Details: " + ex.ToString();
                ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error);
                ErrorLogging.sendtoErrorPage(1);
                throw ex;
            }
            finally
            {
            }
            return(nEventID);
        }
コード例 #4
0
        public static MainScheduleEvent getEventData(int?EventID)
        {
            string sqlQuery = "SELECT MSID, EventTypeID, EventSubTypeID, TimeStamp, UserId, isHidden FROM dbo.MainScheduleEvents " +
                              "WHERE EventID = @EID AND isHidden = 0";

            string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr;

            DataSet  MSEventData    = SqlHelper.ExecuteDataset(sql_connStr, CommandType.Text, sqlQuery, new SqlParameter("@EID", EventID));
            int      MSID           = Convert.ToInt32(MSEventData.Tables[0].Rows[0]["EventTypeID"]);
            int      EventTypeID    = Convert.ToInt32(MSEventData.Tables[0].Rows[0]["EventTypeID"]);
            int?     EventSubTypeID = (MSEventData.Tables[0].Rows[0]["EventSubTypeID"] == DBNull.Value) ? (int?)null : Convert.ToInt32(MSEventData.Tables[0].Rows[0]["EventSubTypeID"]);
            DateTime TimeStamp      = Convert.ToDateTime(MSEventData.Tables[0].Rows[0]["TimeStamp"]);
            int      UserId         = Convert.ToInt32(MSEventData.Tables[0].Rows[0]["UserId"]);
            bool     isHidden       = Convert.ToBoolean(MSEventData.Tables[0].Rows[0]["isHidden"]);


            MainScheduleEvent newMSEvent = new MainScheduleEvent(MSID, EventTypeID, EventSubTypeID, TimeStamp, UserId, isHidden);

            return(newMSEvent);
        }
コード例 #5
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());
        }
コード例 #6
0
        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);
        }
コード例 #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;
 }