/// <summary> /// To authenticate request whether it has valid credential to proceed /// </summary> /// <param name="xCblServiceUser">Service User</param> /// <param name="operationContext">Current OperationContext</param> /// <returns></returns> internal static bool IsAuthenticatedRequest(OperationContext operationContext, ref XCBL_User xCblServiceUser) { try { // If a separate namespace is needed for the Credentials tag use the global const CREDENTIAL_NAMESPACE that is commented below int index = operationContext.IncomingMessageHeaders.FindHeader("Credentials", ""); // Retrieve the first soap headers, this should be the Credentials tag MessageHeaderInfo messageHeaderInfo = operationContext.IncomingMessageHeaders[index]; xCblServiceUser = Meridian_AuthenticateUser(operationContext.IncomingMessageHeaders, messageHeaderInfo, index); if (xCblServiceUser == null || string.IsNullOrEmpty(xCblServiceUser.WebUsername)) { ApplicationError.WriteMessage("UnAuthenticated Request Incorrect Credentials"); return(false); } return(true); } catch (Exception ex) { ApplicationError.logErrors(ex, "IsAuthenticatedRequest"); // MeridianSystemLibrary.LogTransaction("No WebUser", "No FTPUser", "IsAuthenticatedRequest", "03.01", "Error - New SOAP Request not authenticated", "UnAuthenticated Request", "No FileName", "No Schedule ID", "No Order Number", null, "Error 03.01 - Incorrect Credentials"); return(false); } }
internal MeridianResult ProcessDocument(OperationContext currentOperationContext) { _meridianResult = new MeridianResult(); _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_SUCCESS; XCBL_User xCblServiceUser = new XCBL_User(); ProcessData processDatatest = ProcessRequestAndCreateFiles(currentOperationContext, xCblServiceUser); if (processDatatest != null) { WriteScheduleShippingXmlDocument(currentOperationContext.RequestContext); } if (CommonProcess.IsAuthenticatedRequest(currentOperationContext, ref xCblServiceUser)) { ApplicationError.WriteMessage("AuthenticatedRequest Sucess - New SOAP Request authenticated."); ProcessData processData = ProcessRequestAndCreateFiles(currentOperationContext, xCblServiceUser); if (processData == null || string.IsNullOrEmpty(processData.ScheduleID) || string.IsNullOrEmpty(processData.OrderNumber)) { _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE; } else { if (!UpdateToServer(processData)) { // ApplicationError.WriteMessage("NOT FOUND Order Ref Number For Process Is " + processData.ShippingSchedule.OrderNumber); _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE; } _meridianResult.UniqueID = processData.ScheduleID; return(_meridianResult); } } else { _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE; ApplicationError.WriteMessage("Error - New SOAP Request not authenticated. UnAuthenticated Request"); } return(_meridianResult); }
private ProcessData WriteScheduleShippingXmlDocument(RequestContext requestContext) { ApplicationError.WriteMessage("WriteScheduleShippingXmlDocument Starts"); var requestMessage = requestContext.RequestMessage.ToString().ReplaceSpecialCharsWithSpace(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(requestMessage); try { string path = Path.Combine(System.Configuration.ConfigurationManager.AppSettings["FTPXMLPath"].ToString() + "\\" + DateTime.Now.ToString("yyyyMMdd HHss") + ".XML"); using (XmlTextWriter writer = new XmlTextWriter(path, null)) { writer.Formatting = Formatting.Indented; xmlDoc.Save(writer); } } catch (Exception ex) { ApplicationError.logErrors(ex); ApplicationError.logErrors(ex, "WriteScheduleShippingXmlDocument"); } return(new ProcessData()); }
private ProcessData ValidateScheduleShippingXmlDocument(RequestContext requestContext, XCBL_User xCblServiceUser) { ApplicationError.WriteMessage("ValidateScheduleShippingXmlDocument Starts"); var requestMessage = requestContext.RequestMessage.ToString().ReplaceSpecialCharsWithSpace(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(requestMessage); try { string path = Path.Combine(System.Configuration.ConfigurationManager.AppSettings["XmlPath"].ToString() + "\\" + DateTime.Now.ToString("yyyyMMdd HHss") + ".XML"); using (XmlTextWriter writer = new XmlTextWriter(path, null)) { writer.Formatting = Formatting.Indented; xmlDoc.Save(writer); } } catch (Exception ex) { ApplicationError.logErrors(ex); ApplicationError.logErrors(ex, "ValidateScheduleShippingXmlDocument"); } XmlNamespaceManager xmlNsManager = new XmlNamespaceManager(xmlDoc.NameTable); xmlNsManager.AddNamespace("default", "rrn:org.xcbl:schemas/xcbl/v4_0/materialsmanagement/v1_0/materialsmanagement.xsd"); xmlNsManager.AddNamespace("core", "rrn:org.xcbl:schemas/xcbl/v4_0/core/core.xsd"); XmlNodeList shippingElement = xmlDoc.GetElementsByTagName(MeridianGlobalConstants.XCBL_SHIPPING_SCHEDULE_HEADER); //Find the Shipping schedule tag and getting the Inner Xml of its Node XmlNodeList shippingScheduleNode_xml = xmlDoc.GetElementsByTagName(MeridianGlobalConstants.XCBL_ShippingScheule_XML_Http);//Http Request creating this tag if (shippingScheduleNode_xml.Count == 0) { shippingScheduleNode_xml = xmlDoc.GetElementsByTagName(MeridianGlobalConstants.XCBL_ShippingScheule_XML_Https);//Https Request creating this tag } if (shippingElement != null) { // There should only be one element in the Shipping Schedule request, but this should handle multiple ones ApplicationError.WriteMessage("Shipping Schedule Header XML tag are correct processing data"); foreach (XmlNode element in shippingElement) { var processData = xCblServiceUser.GetNewProcessData(); processData.XmlDocument = xmlDoc; _meridianResult.XmlDocument = xmlDoc; var scheduleId = element.GetNodeByNameAndLogErrorTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_ID, "03", processData, processData.ScheduleID); var scheduleIssuedDate = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_ISSUED_DATE, "01", processData, processData.ScheduleID); //Schedule Header Information --start if (scheduleId != null && !string.IsNullOrEmpty(scheduleId.InnerText)) { processData.ScheduleID = scheduleId.InnerText.ReplaceSpecialCharsWithSpace(); processData.ShippingSchedule.ScheduleID = processData.ScheduleID; if (scheduleIssuedDate != null && !string.IsNullOrEmpty(scheduleIssuedDate.InnerText)) { processData.ShippingSchedule.ScheduleIssuedDate = scheduleIssuedDate.InnerText.ReplaceSpecialCharsWithSpace(); } XmlNode xnScheduleReferences = element.GetNodeByNameAndLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_REFERENCES, "02", processData, processData.ScheduleID); if (xnScheduleReferences != null) { GetPurchaseOrderReference(xmlNsManager, xnScheduleReferences, processData); } else if (string.IsNullOrEmpty(processData.ShippingSchedule.OrderNumber)) { ApplicationError.WriteMessage("Error - Schedule References XML tag missing or incorrect to get seller order number No Order Number found"); } if (string.IsNullOrEmpty(processData.ShippingSchedule.ScheduleID) || string.IsNullOrEmpty(processData.ShippingSchedule.OrderNumber)) { break; } else { GetOtherScheduleReferences(xmlNsManager, xnScheduleReferences, processData); GetPurposeScheduleTypeCodeAndParty(xmlNsManager, element, processData); GetListOfContactNumber(xmlNsManager, element, processData); GetListOfTransportRouting(xmlNsManager, element, processData); return(processData); } } } } else { ApplicationError.WriteMessage("Shipping Schedule Header XML tag missing or incorrect Invalid request xml"); } return(new ProcessData()); }
private bool UpdateToServer(ProcessData processData) { bool result = false; try { if (processData != null && !string.IsNullOrEmpty(processData.ScheduleID) && !string.IsNullOrEmpty(processData.OrderNumber) && !string.IsNullOrEmpty(processData.CsvFileName)) { var initialResponse = (processData.ShippingSchedule.Approve01.Equals(MeridianGlobalConstants.XCBL_YES_FLAG) || processData.ShippingSchedule.Approve02.Equals(MeridianGlobalConstants.XCBL_YES_FLAG) || processData.ShippingSchedule.Approve03.Equals(MeridianGlobalConstants.XCBL_YES_FLAG) || processData.ShippingSchedule.Approve04.Equals(MeridianGlobalConstants.XCBL_YES_FLAG) || processData.ShippingSchedule.Approve05.Equals(MeridianGlobalConstants.XCBL_YES_FLAG)) ? MeridianGlobalConstants.XCBL_SHIPPING_SCHEDULE_REQUEST_ACCEPTED_FOR_CSV : processData.ShippingSchedule.Rejected01.Equals(MeridianGlobalConstants.XCBL_YES_FLAG) ? MeridianGlobalConstants.XCBL_SHIPPING_SCHEDULE_REQUEST_REJECTED_FOR_CSV : MeridianGlobalConstants.XCBL_SHIPPING_SCHEDULE_REQUEST_PENDING_FOR_CSV; var record = string.Format(MeridianGlobalConstants.CSV_HEADER_NAMES_FORMAT, processData.ShippingSchedule.ScheduleID, processData.ShippingSchedule.ScheduleIssuedDate, processData.ShippingSchedule.OrderNumber, processData.ShippingSchedule.SequenceNumber, processData.ShippingSchedule.Other_FirstStop, processData.ShippingSchedule.Other_Before7, processData.ShippingSchedule.Other_Before9, processData.ShippingSchedule.Other_Before12, processData.ShippingSchedule.Other_SameDay, processData.ShippingSchedule.Other_OwnerOccupied, processData.ShippingSchedule.Other_7, processData.ShippingSchedule.Other_8, processData.ShippingSchedule.Other_9, processData.ShippingSchedule.Other_10, processData.ShippingSchedule.PurposeCoded, processData.ShippingSchedule.ScheduleType, processData.ShippingSchedule.AgencyCoded, processData.ShippingSchedule.Name1, processData.ShippingSchedule.Street, processData.ShippingSchedule.StreetSupplement1, processData.ShippingSchedule.PostalCode, processData.ShippingSchedule.City, processData.ShippingSchedule.RegionCoded, processData.ShippingSchedule.ContactName, processData.ShippingSchedule.ContactNumber_1, processData.ShippingSchedule.ContactNumber_2, processData.ShippingSchedule.ContactNumber_3, processData.ShippingSchedule.ContactNumber_4, processData.ShippingSchedule.ContactNumber_5, processData.ShippingSchedule.ContactNumber_6, processData.ShippingSchedule.ShippingInstruction, processData.ShippingSchedule.GPSSystem, processData.ShippingSchedule.Latitude.ToString(), processData.ShippingSchedule.Longitude.ToString(), processData.ShippingSchedule.LocationID, processData.ShippingSchedule.EstimatedArrivalDate, processData.ShippingSchedule.OrderType, initialResponse); // StringBuilder strBuilder = new StringBuilder(MeridianGlobalConstants.CSV_HEADER_NAMES); // strBuilder.AppendLine(); // strBuilder.AppendLine(record); // string csvContent = strBuilder.ToString(); DataSet ds = MeridianSystemLibrary.GetDataByRef(processData.ShippingSchedule.OrderNumber); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["CANCELLED"].ToString() == "1") { ApplicationError.WriteMessage("Ref Number Order Canceled : " + processData.ShippingSchedule.OrderNumber.Replace(" ", "") + " Order Canceled Failure Notify. "); return(result = false); } if (ds.Tables[0].Rows[0]["DROPDATE"] != DBNull.Value && ds.Tables[0].Rows[0]["DROPPEDOFF"].ToString() == "1") { ApplicationError.WriteMessage("Ref Number :" + processData.ShippingSchedule.OrderNumber.Replace(" ", "") + " All Ready Deliverd Failure Notify. "); return(result = false); } } else { ApplicationError.WriteMessage("Ref Number Not Found : " + processData.ShippingSchedule.OrderNumber.Replace(" ", "")); return(result = false); } int exeresult = MeridianSystemLibrary.UpdateDataToLocal(processData); if (exeresult > 0) { ApplicationError.WriteMessage("Success Process Ref Number : " + processData.ShippingSchedule.OrderNumber); result = true; } else { result = false; } } else { } } catch (Exception ex) { ApplicationError.logErrors(ex, "UpdateToServer"); } return(result); }