protected void Application_Start(object sender, EventArgs e) { LOG.Info("Application_Start"); try { _saveRequestFileName = System.Configuration.ConfigurationManager.AppSettings["RequestSaveFileName"]; } catch (Exception ex) { LOG.Error("Failed to get RequestSaveFileName setting: {0}", ex.Message); } }
public SoapException GetFault(EndpointVersionType endpointVersion, Exception ex) { LOG.Error(ex.Message, ex); ENExceptionCodeType code = ENExceptionCodeType.E_Unknown; if (!string.IsNullOrEmpty(ex.HelpLink)) { try { code = (ENExceptionCodeType)Enum.Parse(typeof(ENExceptionCodeType), ex.HelpLink, true); } catch (Exception enumEx) { LOG.Error("Invalid eror code: " + ex.HelpLink, enumEx); } } return(GetFault(endpointVersion, code, CleanseExceptionMessage(ex))); }
public void RollbackDocument(string transactionId, string id) { try { DeleteDocument(transactionId, id); } catch (Exception ex) { LOG.Error("Failed to DeleteDocument({0}, {1})", ex, transactionId, id); } }
public void ProcessSolicit(string requestId) { try { AppendAuditLogEvent("Getting request..."); LOG.DebugEnter(MethodBase.GetCurrentMethod(), requestId); LazyInit(); DataRequest request = _requestManager.GetDataRequest(requestId); AppendAuditLogEvent("Getting data from request..."); object returnData = GetObjectFromRequest(request); AppendAuditLogEvent("Serializing data to file..."); LOG.Debug("Serializing results to file..."); string serializedFilePath = _serializationHelper.SerializeToTempFile(returnData); LOG.Debug("Serialized file path: " + serializedFilePath); AppendAuditLogEvent("Compressing serialized data..."); LOG.Debug("Compressing serialized file..."); string compressedFilePath = _compressionHelper.CompressFile(serializedFilePath); LOG.Debug("Compressed file path: " + compressedFilePath); AppendAuditLogEvent("Saving compressed data..."); LOG.Debug("Saving data"); _documentManager.AddDocument(request.TransactionId, CommonTransactionStatusCode.Processed, "Request Processed: " + request.ToString(), compressedFilePath); AppendAuditLogEvent("Plugin done"); LOG.Debug("OK"); } catch (Exception ex) { LOG.Error(ex); AppendAuditLogEvent("Error: " + ex.StackTrace); throw new ApplicationException("Error while executing plugin", ex); } }
private static void LogError(Exception exception, string messageFormat, params object[] args) { string message = CollectionUtils.IsNullOrEmpty(args) ? messageFormat : string.Format(messageFormat, args); message += "EXCEPTION: " + ExceptionUtils.ToLongString(exception); try { EventLog.WriteEntry(ServiceName, message, EventLogEntryType.Error); } catch { } if (LOG != null) { try { LOG.Error(message); } catch { } } }
/// <summary> /// Authenticate /// </summary> /// <param name="userId"></param> /// <param name="credential"></param> /// <param name="authenticationMethod"></param> /// <returns></returns> string INetworkNodeBinding.Authenticate(string userId, string credential, string authenticationMethod) { Init(); LOG.Debug("Authenticate"); #region Validate if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(credential)) { throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter, "NULL Authenticate argument"); } #endregion try { LOG.Debug("Getting visit"); AuthEndpointVisit visit = _service11Provider.VisitProvider.GetVisit(userId, credential, null, authenticationMethod); LOG.Debug("Authenticating using visit: " + visit); string token = _service11Provider.SecurityService.Authenticate(visit); LOG.Debug("Token: " + token); return(token); } catch (Exception ex) { LOG.Error("Error while authenticating", ex); throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ex); } }
/// <summary> /// ProcessSubmit /// </summary> /// <param name="transactionId"></param> public void ProcessSubmit(string transactionId) { try { LazyInit(); WriteOut("Runtime arguments:"); foreach (string param in Enum.GetNames(typeof(SdwisRelayServiceParameterType))) { WriteOut("{0} = {1}; ", param, ConfigurationArguments[param]); } WriteOut("Getting documents:"); IList <Document> documents = _documentManager.GetDocuments(transactionId, true); List <string> documentPaths = new List <string>(); string tempDirPath = Path.Combine(_settingsProvider.TempFolderPath, Guid.NewGuid().ToString()); WriteOut("Creating temp. directory: " + tempDirPath); Directory.CreateDirectory(tempDirPath); foreach (Document doc in documents) { WriteOut("Parsing document: {0} ({1}); ", doc.DocumentName, doc.Type); string tempDocPath = Path.Combine(tempDirPath, doc.DocumentName); WriteOut("Saving content: " + tempDocPath); File.WriteAllBytes(tempDocPath, doc.Content); documentPaths.Add(tempDocPath); } WriteOut("Parsing argument values..."); string endpointUrl = GetConfigParameter(SdwisRelayServiceParameterType.SubmitEndpointUri.ToString()); WriteOut(" endpoint url: {0}", endpointUrl); if (!string.IsNullOrEmpty(endpointUrl)) { string submitAsUser = GetConfigParameter(SdwisRelayServiceParameterType.SubmitUsername.ToString()); WriteOut(" submit user: {0}", submitAsUser); string submitPassword = GetConfigParameter(SdwisRelayServiceParameterType.SubmitPassword.ToString()); WriteOut(" submit password: *********", submitPassword); string resultTranId = null; WriteOut("Creating endpoint client..."); INodeEndpointClient client = null; if (!String.IsNullOrEmpty(submitAsUser) && !String.IsNullOrEmpty(submitPassword)) { WriteOut("Using custom credentials"); client = _nodeEndpointClientFactory.Make(endpointUrl, EndpointVersionType.EN11, new AuthenticationCredentials(submitAsUser, submitPassword)); } else { WriteOut("Using default credentials"); client = _nodeEndpointClientFactory.Make(endpointUrl, EndpointVersionType.EN11); } WriteOut("Submitting documents..."); resultTranId = client.Submit(FLOW_NAME, null, documentPaths); if (string.IsNullOrEmpty(resultTranId)) { throw new ApplicationException("Node client did not return any transaction!"); } _transactionManager.SetTransactionStatus(transactionId, CommonTransactionStatusCode.Completed, WriteOut("Remote transaction Id: {1}", endpointUrl, resultTranId), true); _transactionManager.SetNetworkId(transactionId, resultTranId, EndpointVersionType.EN11, endpointUrl, FLOW_NAME, null); WriteOut("Submission done..."); } //********************************************* //HERE //********************************************* string hereEndpointUrl = GetConfigParameter(SdwisRelayServiceParameterType.HereEndpointUri.ToString()); WriteOut("Here endpoint url: {0}", hereEndpointUrl); if (!string.IsNullOrEmpty(hereEndpointUrl)) { WriteOut("Initializing HERE process..."); WriteOut("Validating submitted file name..."); if (documentPaths.Count == 1) { string submittedFileName = Path.GetFileName(documentPaths[0]); WriteOut("submittedFileName: {0}; ", submittedFileName); string hereFileNameFilter = ValidateNonEmptyConfigParameter(SdwisRelayServiceParameterType.HereFileNameFilter.ToString()); WriteOut("hereFileNameFilter: {0}; ", hereFileNameFilter); if (submittedFileName.IndexOf(hereFileNameFilter) > -1) { string hereIsFacilitySource = ValidateNonEmptyConfigParameter(SdwisRelayServiceParameterType.HereIsFacilitySource.ToString()); WriteOut("hereIsFacilitySource: {0}; ", hereIsFacilitySource); bool isFacilitySource = false; if (!bool.TryParse(hereIsFacilitySource, out isFacilitySource)) { throw new ApplicationException(string.Format( "Unable to parse the {0} argument. Must be a valid bool expression.", hereIsFacilitySource)); } string hereSourceSystemName = ValidateNonEmptyConfigParameter(SdwisRelayServiceParameterType.HereSourceSystemName.ToString()); WriteOut("hereSourceSystemName: {0}; ", hereSourceSystemName); WriteOut("creating Here data access object..."); HereDao hereDao = new HereDao(ValidateDBProvider(SdwisRelayServiceDataSourceType.HereDataSource.ToString())); WriteOut("hereDao: {0}; ", hereDao); WriteOut("saving submission in Here..."); hereDao.SetResultData(transactionId, hereEndpointUrl, FLOW_NAME, isFacilitySource, hereSourceSystemName, true); } else { WriteOut("Submitted file name: {0} does match the filter: {1}", submittedFileName, hereFileNameFilter); } } else { WriteOut("Found more than one submission... HERE requires only one file!"); } } else if (string.IsNullOrEmpty(endpointUrl)) { throw new ArgumentException(string.Format("Please specify either \"{0}\" or \"{1}\" configuration parameters", SdwisRelayServiceParameterType.SubmitEndpointUri.ToString(), SdwisRelayServiceParameterType.HereEndpointUri.ToString())); } } catch (Exception ex) { LOG.Error("Error while processing submission:", ex); throw new ApplicationException("Error while processing submission:", ex); } }