Beispiel #1
0
        /// <summary>
        /// Vytvoří chybový ProcResult
        /// </summary>
        /// <param name="methodName">Název metody</param>
        /// <param name="exception">Instance vyjímky</param>
        /// <returns></returns>
        internal static ProcResult CreateErrorResult(string methodName, Exception exception)
        {
            ProcResult result = new ProcResult();

            result.ReturnValue   = Bc.NotOk;
            result.ReturnMessage = String.Format("{0}{1}{2}", methodName, Environment.NewLine, exception.Message);

            Exception innerExeption = exception.InnerException;

            while (innerExeption != null)
            {
                result.ReturnMessage += result.ReturnMessage + Environment.NewLine + exception.InnerException.Message;
                innerExeption         = innerExeption.InnerException;
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Zápis do logu aplikace (v případě xml se xml deklarace a root element se zapisují zvlášť)
        /// </summary>
        /// <param name="type">Typ zprávy</param>
        /// <param name="message">Textová zpráva</param>
        /// <param name="xmlDeclaration">Hodnota xml deklarace</param>
        /// <param name="xmlMessage">Zpráva ve formátu xml</param>
        /// <param name="zicyzUserId">Id uživatele, zapisuje se do logu spolu s výsledkem operace</param>
        /// <param name="source">Zdroj relevantní k logované zprávě</param>
        /// <returns>Vrací instanci třídy <see cref="ProcResult"/> popisující výsledek operace</returns>
        public ProcResult AppLogWriteNew(string type, string message, string xmlDeclaration, string xmlMessage, int zicyzUserId, string source)
        {
            ProcResult result = new ProcResult();

            result.ReturnValue = Bc.NotOk;

            if (this.VerifyToken() == false)
            {
                return(result);
            }

            using (var db = new FenixEntities())
            {
                try
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    ObjectParameter retVal = new ObjectParameter("ReturnValue", typeof(int));
                    ObjectParameter retMsg = new ObjectParameter("ReturnMessage", typeof(string));

                    db.prAppLogWriteNew(type, message, xmlDeclaration, xmlMessage, zicyzUserId, source, retVal, retMsg);

                    result.ReturnValue   = retVal.Value.ToInt32(Bc.NotOk);
                    result.ReturnMessage = retMsg.Value.ToString(String.Empty);
                    SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult()
                    {
                        StatusId = ActionStatus.Success.ToShort(), StatusDesc = "OK"
                    });
                }
                catch (Exception ex)
                {
                    result = Bc.CreateErrorResult(ApplicationLog.GetMethodName(), ex);
                    SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult()
                    {
                        StatusId = ActionStatus.Failure.ToShort(), StatusDesc = ex.Message
                    });
                }
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// zápis výsledku operace do tabulky logu
        /// <para>token se neverifikuje - předpokládá se verifikace ve volající metodě!</para>
        /// <para>jde o pomocnou metodu - případná chyba se ignoruje</para>
        /// </summary>
        /// <param name="result"></param>
        /// <param name="source"></param>
        /// <param name="zicyzUserId"></param>
        private void logResult(ProcResult result, string source, int zicyzUserId)
        {
            try
            {
                string logType = result.ReturnValue == Bc.Ok ? "INFO" : "ERROR";
                string message = String.Format("MethodName [{0}] result.ReturnValue [{1}] result.ReturnMessage [{2}]", source, result.ReturnValue, result.ReturnMessage);

                using (var db = new FenixEntities())
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    ObjectParameter retVal = new ObjectParameter("ReturnValue", typeof(int));
                    ObjectParameter retMsg = new ObjectParameter("ReturnMessage", typeof(string));

                    db.prAppLogWriteNew(logType, message, String.Empty, String.Empty, zicyzUserId, source, retVal, retMsg);
                }
            }
            catch
            {
                ;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Vlastní zpracování daného typu procesu (ReceptionConfirmation, KittingConfirmation ...)
        /// </summary>
        /// <param name="processType"></param>
        /// <param name="xmlMessage">Zpráva ve formátu xml</param>
        /// <param name="zicyzUserId">Id uživatele, zapisuje se do logu spolu s výsledkem operace</param>
        /// <returns></returns>
        private ProcResult DoConfirmationProcess(ProcessType processType, string xmlMessage, int zicyzUserId)
        {
            ProcResult result = new ProcResult();

            result.ReturnValue = Bc.NotOk;

            if (this.VerifyToken() == false)
            {
                return(result);
            }

            using (var db = new FenixEntities())
            {
                try
                {
                    db.Configuration.LazyLoadingEnabled   = false;
                    db.Configuration.ProxyCreationEnabled = false;
                    db.Database.CommandTimeout            = Bc.DbCommandTimeout;

                    var par1Parameter = new SqlParameter();
                    par1Parameter.ParameterName = "@par1";
                    par1Parameter.Value         = xmlMessage;
                    par1Parameter.Direction     = System.Data.ParameterDirection.Input;
                    par1Parameter.SqlDbType     = System.Data.SqlDbType.NVarChar;
                    par1Parameter.Size          = int.MaxValue - 1;

                    var returnValue = new SqlParameter();
                    returnValue.ParameterName = "@ReturnValue";
                    returnValue.Direction     = System.Data.ParameterDirection.InputOutput;
                    returnValue.SqlDbType     = System.Data.SqlDbType.Int;
                    returnValue.Value         = 0;

                    var returnMessage = new SqlParameter();
                    returnMessage.ParameterName = "@ReturnMessage";
                    returnMessage.Direction     = System.Data.ParameterDirection.InputOutput;
                    returnMessage.SqlDbType     = System.Data.SqlDbType.NVarChar;
                    returnMessage.Size          = 2048;
                    returnMessage.Value         = "";

                    // diky problémům v EF 6 (rollback ve SP) je nutno SP volat tímto způsobem
                    var res = db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, this.createSqlCommand(processType), par1Parameter, returnValue, returnMessage);

                    result.ReturnValue   = returnValue.Value.ToInt32(Bc.NotOk);
                    result.ReturnMessage = returnMessage.Value.ToString(String.Empty);
                    SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult()
                    {
                        StatusId = ActionStatus.Success.ToShort(), StatusDesc = "OK"
                    });
                }
                catch (Exception ex)
                {
                    result = Bc.CreateErrorResult(ApplicationLog.GetMethodName(), ex);
                    SoapHeaderHelper <ActionResult> .SetOutputHeader("ActionResult", new ActionResult()
                    {
                        StatusId = ActionStatus.Failure.ToShort(), StatusDesc = ex.Message
                    });
                }
            }

            logResult(result, ApplicationLog.GetMethodName(), zicyzUserId);
            return(result);
        }