/// <summary>
        /// This is Confusing for now... but necessary. This allows us to Log to the DB and to a separate String Builder for console app display
        /// This will be cleaned up as soon as the UI is completed.
        /// </summary>
        /// <param name="p_objDBLogger"></param>
        /// <param name="p_objProgress"></param>
        /// <param name="p_strMessage"></param>
        /// <param name="p_blnWriteProgressToStringBuilder"></param>
        /// <param name="p_blnNewLine"></param>
        public static void writeProgress(string p_strMessage,
                                         ref Logger p_objDBLogger,
                                         StringBuilder p_objProgress,
                                         actionStatus p_objActionStatus = actionStatus.None,
                                         bool p_blnWriteToStringBuilder = true,
                                         bool p_blnWriteToLogger        = true,
                                         bool p_blnNewLine = true)
        {
            if (p_blnWriteToLogger)
            {
                p_objDBLogger.logToMemory(p_strMessage, p_objActionStatus, p_blnNewLine);
            }

            //Writing to the DB is handled separately.
            if (p_blnWriteToStringBuilder)
            {
                if (p_objProgress == null)
                {
                    p_objProgress = new StringBuilder();
                }

                if (p_blnNewLine)
                {
                    p_objProgress.AppendLine(p_strMessage);
                }
                else
                {
                    p_objProgress.Append(p_strMessage);
                }
            }
        }
Example #2
0
        //public async Task<string> writePendingToDBAsync(actionStatus p_objStatus = actionStatus.None, bool p_blnReturnOutput = false, string p_strUpdatedBy = "GeneralUser")
        public string writePendingToDB(actionStatus p_objStatus = actionStatus.None, bool p_blnReturnOutput = false, string p_strUpdatedBy = "GeneralUser", string p_strFunctionName = "")
        {
            string l_strOutput = "";

            if (myDB != null && m_objMemoryLog != null && m_objMemoryLog.Length > 0)
            {
                l_strOutput = string.Format("{0} {1} {2}", m_strClassName, p_strFunctionName, m_objMemoryLog.ToString());

                myDB.tblOperationStatus.Add(new tblOperationStatu {
                    SessionID       = m_strSessionID,
                    StatusID        = (int)p_objStatus,
                    Description     = l_strOutput,
                    UpdatedBy       = p_strUpdatedBy,
                    UpdatedDateTime = DateTime.Now.ToUniversalTime()
                });
                //Task<int> saveResult = myDB.SaveChangesAsync();
                //For Now we will run these syncronously
                AsyncContext.Run(() => myDB.SaveChangesAsync());
                m_objMemoryLog.Clear(); //Clear to ensure we can log to another record
                if (p_blnReturnOutput == false)
                {
                    l_strOutput = "";                             //Return nothing or everything that was just written
                }
                //await saveResult;
            }
            return(l_strOutput);
        }
Example #3
0
        /// <summary>
        /// Write Out to the DB Immediately
        ///
        /// e.g.: Write for Errors or other important messages that may not be able to wait.
        /// </summary>
        /// <param name="p_strDescription"></param>
        /// <param name="p_objStatus"></param>
        /// <param name="p_strUpdatedBy"></param>
        //public async void logToDBAsync(string p_strDescription, actionStatus p_objStatus = actionStatus.None, string p_strUpdatedBy = "GeneralUser")
        public string logToDB(string p_strDescription, actionStatus p_objStatus = actionStatus.None, bool p_blnReturnOutput = false, string p_strUpdatedBy = "GeneralUser", bool p_blnError_WriteMemoryToDB = false, string p_strFunctionName = "")
        {
            //Let's do the work here so as not to repeat ourselves throughout the project
            string l_strOutput   = "";
            bool   l_blnAddToLog = canLog(p_objStatus);

            if (!(myDB == null) && l_blnAddToLog)
            {
                if (p_blnError_WriteMemoryToDB)
                {
                    writePendingToDB(p_objStatus, p_strFunctionName: p_strFunctionName);
                }
                l_strOutput = string.Format("{0} {1} {2}", m_strClassName, p_strFunctionName, p_strDescription);
                myDB.tblOperationStatus.Add(new tblOperationStatu {
                    SessionID       = m_strSessionID,
                    StatusID        = (int)p_objStatus,
                    Description     = l_strOutput,
                    UpdatedBy       = p_strUpdatedBy,
                    UpdatedDateTime = DateTime.Now.ToUniversalTime()
                });
                //int x = await myDB.SaveChangesAsync();
                //For Now we will run these syncronously
                AsyncContext.Run(() => myDB.SaveChangesAsync());
            }
            return(l_strOutput);
        }
Example #4
0
        public bool logToMemory(string p_strDescription, actionStatus p_objStatus = actionStatus.None, bool p_blnNewLine = true, bool p_blnLogAndWrite = false, string p_strFunctionName = "")
        {
            bool l_blnAddToLog = false;

            try
            {
                if ((m_objMemoryLog != null) && canLog(p_objStatus))
                {
                    l_blnAddToLog = true;
                    if (p_blnNewLine)
                    {
                        m_objMemoryLog.AppendLine(p_strDescription);
                    }
                    else
                    {
                        m_objMemoryLog.Append(p_strDescription);
                    }
                }
                if (p_blnLogAndWrite)
                {
                    writePendingToDB(p_objStatus, p_strFunctionName: p_strFunctionName);
                }
            }
            catch { /* DO NOTHING */ }
            return(l_blnAddToLog);
        }
Example #5
0
    public static string getActionStatusToString(actionStatus status)
    {
        string statusStr = "";

        switch (status)
        {
        case actionStatus.None:
            statusStr = "None";
            break;

        case actionStatus.IDEL:
            statusStr = "IDEL";
            break;

        case actionStatus.WALK:
            statusStr = "WALK";
            break;

        case actionStatus.DIE:
            statusStr = "DIE";
            break;

        case actionStatus.ATTACK:
            statusStr = "ATTACK";
            break;

        case actionStatus.ATTACKWAIT:
            statusStr = "ATTACKWAIT";
            break;

        case actionStatus.SKILL:
            statusStr = "SKILL";
            break;

        case actionStatus.RIDEIDEL:
            statusStr = "RIDEIDEL";
            break;

        case actionStatus.RIDEWALK:
            statusStr = "RIDEWALK";
            break;

        case actionStatus.HURT:
            statusStr = "HURT";
            break;

        default:
            break;
        }
        return(statusStr);
    }
Example #6
0
        private bool canLog(actionStatus p_objStatus)
        {
            bool l_blnCanLog = false;

            if ((m_objLogLevel == logLevel.All) ||
                (m_objLogLevel == logLevel.ErrorOnly &&
                 (p_objStatus == actionStatus.PartialError ||
                  p_objStatus == actionStatus.Error)))
            {
                l_blnCanLog = true;
            }

            return(l_blnCanLog);
        }
        private static void turnOffSystem()
        {
            StringBuilder l_objProgress = new StringBuilder();
            actionStatus  l_objStatus   = actionStatus.None;

            l_objStatus = hallAutomations.turnSystemOff(p_intTVID: 99, p_objProgress: l_objProgress);
            Console.Write(l_objProgress.ToString());

            switch (l_objStatus)
            {
            case actionStatus.Success:
                Console.WriteLine("The System has been successfully turned off.");
                break;

            default:
                Console.WriteLine("Something went wrong. Please check the logs for more details.\nIf this issue persists, please contact the system administrator");
                break;
            }
        }
        private static void turnOnSystem()
        {
            //TODO: NEED TO CREATE A MESSAGEBUS OR SOMETHING TO GIVE THE USER REALTIME UPDATES

            StringBuilder l_objProgress = new StringBuilder();
            actionStatus  l_objStatus   = actionStatus.None;

            //Currently there are multiple TV's, but only one projector and lift.
            l_objStatus = hallAutomations.turnSystemOn(p_intTVID: 99, p_objProgress: l_objProgress);
            Console.Write(l_objProgress.ToString());

            switch (l_objStatus)
            {
            case actionStatus.Success:
                Console.WriteLine("The System has been turned on successfully.");
                break;

            default:
                Console.WriteLine("Something went wrong. Please check the logs for more details.\nIf this issue persists, please contact the system administrator");
                break;
            }
        }