Esempio n. 1
0
        /// <summary>
        /// Volání SP pro ověření 'zdraví služeb'
        /// </summary>
        /// <param name="authToken"></param>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <param name="partnerCode"></param>
        /// <param name="messageType"></param>
        /// <returns>result.MessageDescription by měla obsahovat string 'Automat Rows : 1  |   DateTime : yyyy-mm-dd hh:mi:ss.mmm'</returns>
        public static SubmitDataToProcessingResult Process(AuthToken authToken, string login, string password, string partnerCode, string messageType)
        {
            SubmitDataToProcessingResult result = new SubmitDataToProcessingResult();

            try
            {
                if (authToken != null)
                {
                    FenixAppSvcClient appClient = new FenixAppSvcClient();
                    appClient.AuthToken = new Fenix.WebService.Service_References.FenixAppService.AuthToken()
                    {
                        Value = authToken.Value
                    };
                    ProcResult procResult = appClient.GetServicesStatuses(BC.ZICYZ_USER_ID);
                    appClient.Close();

                    if (procResult.ReturnValue == (int)BC.OK)
                    {
                        result.MessageDescription = procResult.ReturnMessage;
                    }
                    else
                    {
                        ProjectHelper.CreateErrorResult(ApplicationLog.GetMethodName(), ref result, "90", procResult.ReturnMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                ProjectHelper.CreateErrorResult(ApplicationLog.GetMethodName(), ref result, "100", ex);
            }

            return(result);
        }
        /// <summary>
        /// Zápis do logovací tabulky AppLogNew
        /// </summary>
        /// <param name="authToken"></param>
        /// <param name="type"></param>
        /// <param name="message"></param>
        /// <param name="xmlDeclaration"></param>
        /// <param name="xmlMessage"></param>
        /// <param name="zicyzUserId"></param>
        /// <param name="sourceName"></param>
        /// <returns></returns>
        public static SubmitDataToProcessingResult AppLogWrite(AuthToken authToken, string type, string message, string xmlDeclaration, string xmlMessage, int zicyzUserId, string sourceName)
        {
            SubmitDataToProcessingResult result = new SubmitDataToProcessingResult();

            try
            {
                if (authToken != null)
                {
                    FenixAppSvcClient appClient = new FenixAppSvcClient();
                    appClient.AuthToken = new Fenix.WebService.Service_References.FenixAppService.AuthToken()
                    {
                        Value = authToken.Value
                    };
                    ProcResult procResult = appClient.AppLogWriteNew(type, message, xmlDeclaration, xmlMessage, zicyzUserId, sourceName);
                    appClient.Close();

                    if (procResult.ReturnValue == (int)BC.OK)
                    {
                        CreateOkResult(ref result);
                    }
                    else
                    {
                        CreateErrorResult(ApplicationLog.GetMethodName(), ref result, "90", procResult.ReturnMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                CreateErrorResult(ApplicationLog.GetMethodName(), ref result, "100", ex);
            }

            return(result);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Zpracování testu (zápis do tabulky AppLogNew)
        /// </summary>
        /// <param name="authToken"></param>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <param name="partnerCode"></param>
        /// <param name="messageType"></param>
        /// <param name="data"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        public static SubmitDataToProcessingResult Process(AuthToken authToken, string login, string password, string partnerCode, string messageType, byte[] data, string encoding)
        {
            SubmitDataToProcessingResult result = new SubmitDataToProcessingResult();

            try
            {
                string xmlStringFromData = data.ToString(Encoding.GetEncoding(encoding), Encoding.Unicode);
                string modifiedXmlString = XmlCreator.CreateXMLRootNode(xmlStringFromData);

                if (authToken != null)
                {
                    return(ProjectHelper.AppLogWrite(authToken, "XML",
                                                     ProjectHelper.CreateAppLogMessage(partnerCode, messageType, "modified XML"), "",
                                                     modifiedXmlString, BC.ZICYZ_USER_ID, ApplicationLog.GetMethodName()));
                }
            }
            catch (Exception ex)
            {
                ProjectHelper.CreateErrorResult(ApplicationLog.GetMethodName(), ref result, "100", ex);
            }

            return(result);
        }
Esempio n. 5
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);
        }