/// <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> /// Vlastní zpracování přijaté zprávy dle jejího typu /// </summary> /// <param name="login"></param> /// <param name="password"></param> /// <param name="partnerCode"></param> /// <param name="messageType"></param> /// <param name="data"></param> /// <param name="encoding"></param> /// <param name="result"></param> /// <param name="authToken"></param> /// <returns></returns> public SubmitDataToProcessingResult DoProcessing(string login, string password, string partnerCode, string messageType, byte[] data, string encoding, SubmitDataToProcessingResult result, AuthService.AuthToken authToken) { string messageTypeNormalized = messageType.ToUpper().Trim(); if (messageTypeNormalized.Contains("TEST")) { messageTypeNormalized = "TEST"; } switch (messageTypeNormalized) { case "TEST": result = TestProcessing.Process(authToken, login, password, partnerCode, messageType, data, encoding); break; case "RECEPTIONCONFIRMATION": case "KITTINGCONFIRMATION": case "SHIPMENTCONFIRMATION": result = ConfirmationProcessing.Process(authToken, login, password, partnerCode, messageType, data, encoding); break; default: ProjectHelper.CreateErrorResult(ref result, "100", String.Format("Unknown messageType = [{0}]", messageType)); break; } return(result); }
/// <summary> /// Vlastní zpracování XML message (zrušení deklarační části, zušení všech jmenných prostorů a volání stored procedure na MS SQL) /// </summary> /// <param name="authToken"></param> /// <param name="login"></param> /// <param name="password"></param> /// <param name="partnerCode"></param> /// <param name="messageType"></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(); string xmlString = String.Empty; try { if (authToken != null) { xmlString = data.ToString(Encoding.GetEncoding(encoding), Encoding.Unicode); xmlString = PrepareXml(xmlString); result = ProjectHelper.AppLogWrite(authToken, "XML", ProjectHelper.CreateAppLogMessage(partnerCode, messageType, "modified XML"), "", xmlString, BC.ZICYZ_USER_ID, Fenix.ApplicationLog.GetMethodName()); if (result.MessageNumber == BC.OK) { FenixAppSvcClient appClient = new FenixAppSvcClient(); appClient.AuthToken = new Fenix.WebService.Service_References.FenixAppService.AuthToken() { Value = authToken.Value }; ProcResult procResult = DoProcess(appClient, xmlString, messageType); appClient.Close(); if (procResult.ReturnValue == (int)BC.OK) { ProjectHelper.CreateOkResult(ref result); } else { ProjectHelper.CreateErrorResult(Fenix.ApplicationLog.GetMethodName(), ref result, "90", procResult.ReturnMessage); } } } } catch (Exception ex) { ProjectHelper.CreateErrorResult(Fenix.ApplicationLog.GetMethodName(), ref result, "100", ex); ProjectHelper.AppLogWrite(authToken, "ERROR", String.Format("Během zpracování XML\n{0}\ndošlo k chybě\n{1}", xmlString, ex.Message), String.Empty, String.Empty, BC.ZICYZ_USER_ID, Fenix.ApplicationLog.GetMethodName()); } return(result); }
/// <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); }