Ejemplo n.º 1
0
        /// <summary>
        ///This function will retrieve the authentication information for a specified xCBL Web Service username and password found in MER000Authentication table if the user is enabled
        /// </summary>
        /// <param name="username">string - The username assigned to the xCBL web service credentials</param>
        /// <param name="password">string - The password assigned to the xCBL web service credentials</param>
        /// <returns>XCBL_User - XCBL_User class object that contains the authentication information for the record matching the username and password</returns>
        public static XCBL_User sysGetAuthenticationByUsernameAndPassword(string webUsername, string webPassword)
        {
            // If either the username or password are empty then return null for the method
            if (string.IsNullOrEmpty(webUsername) || string.IsNullOrEmpty(webPassword))
            {
                return(null);
            }

            // Try to retrieve the authentication record based on the specified username and password
            try
            {
                DataSet dsRecords = new DataSet();

                using (SqlConnection sqlConnection = new SqlConnection(MeridianGlobalConstants.XCBL_DATABASE_SERVER_URL))
                {
                    sqlConnection.Open();
                    using (SqlCommand sqlCommand = new SqlCommand(MeridianGlobalConstants.XCBL_SP_GetXcblAuthenticationUser, sqlConnection))
                    {
                        sqlCommand.CommandType = CommandType.StoredProcedure;

                        sqlCommand.Parameters.Add("@webUsername", SqlDbType.NVarChar).Value = webUsername;
                        sqlCommand.Parameters.Add("@webPassword", SqlDbType.NVarChar).Value = webPassword;

                        // Fill the data adapter with the sql query results
                        using (SqlDataAdapter sdaAdapter = new SqlDataAdapter(sqlCommand))
                        {
                            sdaAdapter.Fill(dsRecords);
                        }
                    }
                }
                // Parse the authentication record to a XCBL_User class object
                XCBL_User user = new XCBL_User()
                {
                    WebUsername = dsRecords.Tables[0].Rows[0].ItemArray[1].ToString(), WebPassword = dsRecords.Tables[0].Rows[0].ItemArray[2].ToString(), Hashkey = dsRecords.Tables[0].Rows[0].ItemArray[3].ToString(), FtpUsername = dsRecords.Tables[0].Rows[0].ItemArray[4].ToString(), FtpPassword = dsRecords.Tables[0].Rows[0].ItemArray[5].ToString(), FtpServerUrl = dsRecords.Tables[0].Rows[0].ItemArray[6].ToString(), WebContactName = dsRecords.Tables[0].Rows[0].ItemArray[7].ToString(), WebContactCompany = dsRecords.Tables[0].Rows[0].ItemArray[8].ToString(), WebContactEmail = dsRecords.Tables[0].Rows[0].ItemArray[9].ToString(), WebContactPhone1 = dsRecords.Tables[0].Rows[0].ItemArray[10].ToString(), WebContactPhone2 = dsRecords.Tables[0].Rows[0].ItemArray[11].ToString(), Enabled = Boolean.Parse(dsRecords.Tables[0].Rows[0].ItemArray[12].ToString())
                };
                return(user);
            }
            catch (Exception ex)
            {
                // If there was an error encountered in retrieving the authentication record then try to insert a record in MER010TransactionLog table to record the issue
                try
                {
                    LogTransaction(webUsername, "", "sysGetAuthenticationByUsername", "0.0", "Warning - Cannot retrieve record from MER000Authentication table", ex.InnerException.ToString(), "", "", "", new XmlDocument(), "Warning 26 - DB Connection");
                }
                catch
                {
                }
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static ProcessData GetNewProcessData(this XCBL_User xCblServiceUser)
        {
            var processData = new ProcessData
            {
                ScheduleID       = "No Schedule Id",
                OrderNumber      = "No Order Number",
                CsvFileName      = "No FileName",
                XmlFileName      = "No FileName",
                ShippingSchedule = new ShippingSchedule(),
                WebUserName      = xCblServiceUser.WebUsername,
                FtpUserName      = xCblServiceUser.FtpUsername
            };

            return(processData);
        }
        /// <summary>
        /// Method to pass xCBL XML data to the web serivce
        /// </summary>
        /// <param name="currentOperationContext">Operation context inside this XmlElement the xCBL XML data to parse</param>
        /// <returns>XElement - XML Message Acknowledgement response indicating Success or Failure</returns>
        internal MeridianResult ProcessShippingScheduleResponseRequest(OperationContext currentOperationContext)
        {
            _meridianResult        = new MeridianResult();
            _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_SUCCESS;

            XCBL_User xCblServiceUser = new XCBL_User();

            MeridianSystemLibrary.LogTransaction("No WebUser", "No FTPUser", "ProcessShippingScheduleResponseDocument", "01.01", "Success - New SOAP Request Received", "Shipping Schedule Response Process", "No FileName", "No Schedule ID", "No Order Number", null, "Success");
            if (CommonProcess.IsAuthenticatedRequest(currentOperationContext, ref xCblServiceUser))
            {
                MeridianSystemLibrary.LogTransaction(xCblServiceUser.WebUsername, xCblServiceUser.FtpUsername, "IsAuthenticatedRequest", "01.02", "Success - Authenticated request", "Shipping Schedule Response Process", "No FileName", "No Schedule ID", "No Order Number", null, "Success");
                ProcessData processData = ProcessRequestAndCreateFiles(currentOperationContext, xCblServiceUser);
                if (processData == null || string.IsNullOrEmpty(processData.ScheduleResponseID) || string.IsNullOrEmpty(processData.OrderNumber))
                {
                    _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE;
                }
                else
                {
                    processData.FtpUserName            = xCblServiceUser.FtpUsername;
                    processData.FtpPassword            = xCblServiceUser.FtpPassword;
                    processData.FtpServerInFolderPath  = xCblServiceUser.FtpServerInFolderPath;
                    processData.FtpServerOutFolderPath = xCblServiceUser.FtpServerOutFolderPath;
                    processData.LocalFilePath          = xCblServiceUser.LocalFilePath;
                    _meridianResult.WebUserName        = xCblServiceUser.WebUsername;
                    _meridianResult.WebPassword        = xCblServiceUser.WebPassword;
                    _meridianResult.WebHashKey         = xCblServiceUser.Hashkey;

                    if (!CreateLocalCsvFile(processData))
                    {
                        _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE;
                    }
                    _meridianResult.UniqueID = processData.ScheduleResponseID;
                    return(_meridianResult);
                }
            }
            else
            {
                _meridianResult.Status = MeridianGlobalConstants.MESSAGE_ACKNOWLEDGEMENT_FAILURE;
                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 Credential");
            }
            return(_meridianResult);
        }
        /// <summary>
        /// To Process request and create csv and xml files.
        /// </summary>
        /// <param name="operationContext">Current OperationContext</param>
        /// <returns></returns>
        private ProcessData ProcessRequestAndCreateFiles(OperationContext operationContext, XCBL_User xCblServiceUser)
        {
            try
            {
                ProcessData processData = ValidateScheduleShippingResponseXmlDocument(operationContext.RequestContext, xCblServiceUser);
                if (processData != null && !string.IsNullOrEmpty(processData.ScheduleResponseID) &&
                    !string.IsNullOrEmpty(processData.OrderNumber) &&
                    !string.IsNullOrEmpty(processData.CsvFileName))

                {
                    MeridianSystemLibrary.LogTransaction(xCblServiceUser.WebUsername, xCblServiceUser.FtpUsername, "ProcessRequestAndCreateFiles", "01.03", string.Format("Success - Parsed requested xml for CSV file {0}", processData.ScheduleResponseID), "Shipping Schedule Response Process", processData.CsvFileName, processData.ScheduleResponseID, processData.OrderNumber, processData.XmlDocument, "Success");
                    return(processData);
                }
            }
            catch (Exception ex)
            {
                MeridianSystemLibrary.LogTransaction(xCblServiceUser.WebUsername, xCblServiceUser.FtpUsername, "ValidateScheduleShippingXmlDocument", "03.02", "Error - Incorrect request ", string.Format("Exception - Invalid request xml {0}", ex.Message), "No file Name", "No Schedule Id", "No Order Number", null, "Error 03.02 - Invalid request xml");
            }

            return(new ProcessData());
        }
        /// <summary>
        /// To Parse sent SOAP XML and make list of Process data
        /// </summary>
        /// <param name="requestContext"> Current OperationContext's RequestContext</param>
        /// <param name="xCblServiceUser">Service User</param>
        /// <returns>List of process data</returns>
        private ProcessData ValidateScheduleShippingResponseXmlDocument(RequestContext requestContext, XCBL_User xCblServiceUser)
        {
            var         requestMessage = requestContext.RequestMessage.ToString().ReplaceSpecialCharsWithSpace(false);
            XmlDocument xmlDoc         = new XmlDocument();

            xmlDoc.LoadXml(requestMessage);

            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_RESPONSE_HEADER);

            //Find the Shipping schedule response tag and getting the Inner Xml of its Node
            XmlNodeList shippingScheduleResponseNode_xml = xmlDoc.GetElementsByTagName(MeridianGlobalConstants.XCBL_ShippingScheuleResponse_XML_Http);            //Http Request creating this tag

            if (shippingScheduleResponseNode_xml.Count == 0)
            {
                shippingScheduleResponseNode_xml = xmlDoc.GetElementsByTagName(MeridianGlobalConstants.XCBL_ShippingScheuleResponse_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
                foreach (XmlNode element in shippingElement)
                {
                    var processData = xCblServiceUser.GetNewProcessData();
                    processData.XmlDocument     = xmlDoc;
                    _meridianResult.XmlDocument = xmlDoc;

                    var scheduleResponseId                = element.GetNodeByNameAndLogErrorTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_RESPONSE_ID, "10", processData, processData.ScheduleResponseID);
                    var scheduleResponseIssuedDate        = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_RESPONSE_ISSUE_DATE, "21", processData, processData.ScheduleResponseID);
                    var scheduleResponseReference         = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_RESPONSE_REFERENCE, "22", processData, processData.ScheduleResponseID);
                    var scheduleResponsePurposeCoded      = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_RESPONSE_PURPOSE_CODED, "03", processData, processData.ScheduleResponseID);
                    var scheduleResponseResponseTypeCoded = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_RESPONSE_RESPONSE_TYPE_CODED, "23", processData, processData.ScheduleResponseID);

                    if (scheduleResponseId != null && !string.IsNullOrEmpty(scheduleResponseId.InnerText))
                    {
                        processData.ScheduleResponseID = scheduleResponseId.InnerText.ReplaceSpecialCharsWithSpace();
                        processData.ShippingScheduleResponse.ScheduleResponseID = processData.ScheduleResponseID;

                        if (scheduleResponseIssuedDate != null && !string.IsNullOrEmpty(scheduleResponseIssuedDate.InnerText))
                        {
                            processData.ShippingScheduleResponse.ScheduleResponseIssueDate = scheduleResponseIssuedDate.InnerText.ReplaceSpecialCharsWithSpace();
                        }

                        if (scheduleResponseReference != null && !string.IsNullOrEmpty(scheduleResponseReference.InnerText))
                        {
                            processData.OrderNumber = scheduleResponseReference.InnerText.ReplaceSpecialCharsWithSpace();
                            processData.ShippingScheduleResponse.ScheduleResponseOrderNumber = processData.OrderNumber;

                            string formattedOrderNumber = processData.OrderNumber.ReplaceSpecialCharsWithSpace().Replace(" ", "");
                            string fileNameFormat       = DateTime.Now.ToString(MeridianGlobalConstants.XCBL_FILE_DATETIME_FORMAT);
                            processData.CsvFileName = string.Concat(MeridianGlobalConstants.XCBL_AWC_FILE_PREFIX, fileNameFormat, formattedOrderNumber, MeridianGlobalConstants.XCBL_FILE_EXTENSION);
                            processData.XmlFileName = string.Concat(MeridianGlobalConstants.XCBL_AWC_FILE_PREFIX, fileNameFormat, formattedOrderNumber, MeridianGlobalConstants.XCBL_XML_EXTENSION);
                        }
                        else
                        {
                            MeridianSystemLibrary.LogTransaction(processData.WebUserName, processData.FtpUserName, "ValidateScheduleShippingResponseXmlDocument", "03.11", "Error - Schedule Response References XML tag missing or incorrect to get order number", "Exception - Response order number", processData.CsvFileName, processData.ScheduleResponseID, "No Order Number", processData.XmlDocument, "Error 03.14 - Seller OrderNumber not found");
                        }

                        if (scheduleResponsePurposeCoded != null && !string.IsNullOrEmpty(scheduleResponsePurposeCoded.InnerText))
                        {
                            processData.ShippingScheduleResponse.ScheduleResponsePurposeCoded = scheduleResponsePurposeCoded.InnerText.ReplaceSpecialCharsWithSpace();
                        }

                        if (scheduleResponseResponseTypeCoded != null && !string.IsNullOrEmpty(scheduleResponseResponseTypeCoded.InnerText))
                        {
                            processData.ShippingScheduleResponse.ScheduleResponseTypeCoded = scheduleResponseResponseTypeCoded.InnerText.ReplaceSpecialCharsWithSpace();
                        }

                        if (string.IsNullOrWhiteSpace(processData.ShippingScheduleResponse.ScheduleResponseID) || string.IsNullOrWhiteSpace(processData.ShippingScheduleResponse.ScheduleResponseOrderNumber))
                        {
                            break;
                        }

                        var scheduleId         = element.GetNodeByNameAndLogErrorTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_ID, "03", processData, processData.ScheduleResponseID);
                        var scheduleIssuedDate = element.GetNodeByNameAndInnerTextLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_ISSUED_DATE, "01", processData, processData.ScheduleResponseID);

                        //Schedule Header Information --start
                        if (scheduleId != null && !string.IsNullOrEmpty(scheduleId.InnerText))
                        {
                            processData.ShippingScheduleResponse.ScheduleID = scheduleId.InnerText.ReplaceSpecialCharsWithSpace();

                            if (scheduleIssuedDate != null && !string.IsNullOrEmpty(scheduleIssuedDate.InnerText))
                            {
                                processData.ShippingScheduleResponse.ScheduleIssuedDate = scheduleIssuedDate.InnerText.ReplaceSpecialCharsWithSpace();
                            }

                            XmlNode xnScheduleReferences = element.GetNodeByNameAndLogWarningTrans(xmlNsManager, MeridianGlobalConstants.XCBL_SCHEDULE_REFERENCES, "02", processData, processData.ScheduleResponseID);

                            if (xnScheduleReferences != null)
                            {
                                GetPurchaseOrderReference(xmlNsManager, xnScheduleReferences, processData);
                            }
                            else if (string.IsNullOrEmpty(processData.ShippingScheduleResponse.OrderNumber))
                            {
                                MeridianSystemLibrary.LogTransaction(processData.WebUserName, processData.FtpUserName, "ValidateScheduleShippingResponseXmlDocument", "03.04", "Error - Schedule References XML tag missing or incorrect to get seller order number", "Exception - Seller order number", processData.CsvFileName, processData.ScheduleResponseID, "No Order Number", processData.XmlDocument, "Error 03.04 - Seller OrderNumber not found");
                            }

                            if (string.IsNullOrEmpty(processData.ShippingScheduleResponse.ScheduleID) || string.IsNullOrEmpty(processData.ShippingScheduleResponse.OrderNumber))
                            {
                                break;
                            }
                            else
                            {
                                GetOtherScheduleReferences(xmlNsManager, xnScheduleReferences, processData);

                                GetPurposeScheduleTypeCodeAndParty(xmlNsManager, element, processData);

                                GetListOfContactNumber(xmlNsManager, element, processData);

                                GetListOfTransportRouting(xmlNsManager, element, processData);

                                return(processData);
                            }
                        }
                    }
                }
            }
            else
            {
                MeridianSystemLibrary.LogTransaction(xCblServiceUser.WebUsername, xCblServiceUser.FtpUsername, "ValidateScheduleShippingResponseXmlDocument", "03.02", "Error - Shipping Schedule Response Header XML tag missing or incorrect", "Exception - Invalid request xml", "No file Name", "No Schedule Id", "No Order Number", xmlDoc, "Error 03.02 - Invalid request xml");
            }
            return(new ProcessData());
        }
Ejemplo n.º 6
0
        internal static bool SendShippingScheduleResponseRequestFromPBSFTP(XCBL_User currentUser, string fileName, string currentFileData)
        {
            bool shouldDeletePBSOutFile = false;

            try
            {
                List <PBSData> allPBSData = new List <PBSData>();

                var lines = currentFileData.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                if (lines.Count() > 0)
                {
                    for (int i = 1; i < lines.Length; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(lines[i]))
                        {
                            var values = lines[i].Split(',');
                            if (values.Length > 4)
                            {
                                allPBSData.Add(new PBSData()
                                {
                                    ScheduleId  = values[0],
                                    OrderNumber = values[3],
                                    Status      = values[4],
                                    Comment     = (values.Length == 6) ? values[5] : null
                                });
                            }
                        }
                    }
                }

                if (allPBSData.Count > 0)
                {
                    foreach (var pbsData in allPBSData)
                    {
                        var currentShippingScheduleId = pbsData.ScheduleId ?? string.Empty;
                        var currentOrderNumber        = pbsData.OrderNumber ?? string.Empty;
                        var comment = pbsData.Comment ?? string.Empty;
                        pbsData.Status = pbsData.Status ?? string.Empty;

                        currentShippingScheduleId = currentShippingScheduleId.Replace("'", "");
                        currentOrderNumber        = currentOrderNumber.Replace("'", "");
                        comment        = comment.Replace("'", "");
                        pbsData.Status = pbsData.Status.Replace("'", "");

                        var responseTypeCoded = MeridianGlobalConstants.XCBL_RESPONSE_TYPE_CODED_SHIPPING_SCHEDULE_RESPONSE_ACCEPTED;
                        switch (pbsData.Status.Trim().ToUpper())
                        {
                        case "A":
                            responseTypeCoded = MeridianGlobalConstants.XCBL_RESPONSE_TYPE_CODED_SHIPPING_SCHEDULE_RESPONSE_ACCEPTED;
                            break;

                        case "R":
                            responseTypeCoded = MeridianGlobalConstants.XCBL_RESPONSE_TYPE_CODED_SHIPPING_SCHEDULE_RESPONSE_REJECTED;
                            break;

                        default:
                            responseTypeCoded = MeridianGlobalConstants.XCBL_RESPONSE_TYPE_CODED_SHIPPING_SCHEDULE_RESPONSE_REJECTED;
                            comment           = MeridianGlobalConstants.XCBL_COMMENT_RECEIVED_INVALID_CODE_FROM_PBS;
                            break;
                        }

                        if (!string.IsNullOrWhiteSpace(currentShippingScheduleId) && !string.IsNullOrWhiteSpace(currentOrderNumber) && !string.IsNullOrWhiteSpace(responseTypeCoded))
                        {
                            var currentStringifiedRequest = MeridianSystemLibrary.GetShippingScheduleRequest(currentUser.WebUsername, currentShippingScheduleId, currentOrderNumber);

                            if (!string.IsNullOrWhiteSpace(currentStringifiedRequest))
                            {
                                MeridianSystemLibrary.LogTransaction(currentUser.WebUsername, currentUser.FtpUsername, "SendShippingScheduleResponseRequestFromPBSFTP", "04.03", "Success - Saved PBS File", string.Format("Success - Saved PBS file : {0}", fileName), fileName, currentShippingScheduleId, currentOrderNumber, null, "Success", currentFileData);
                                shouldDeletePBSOutFile = true;

                                var savedShippingScheduleRequest = new XmlDocument();
                                savedShippingScheduleRequest.LoadXml(currentStringifiedRequest);

                                /*Below code commented so that later if client will come back on 'AcceptedWithAmendments' then we can use this*/
                                //if (responseTypeCoded.Trim().Equals(MeridianGlobalConstants.XCBL_RESPONSE_TYPE_CODED_ACCEPTED_WITH_AMENDMENTS, StringComparison.OrdinalIgnoreCase))
                                //    savedShippingScheduleRequest = UpdateShippingScheduleRequest(savedShippingScheduleRequest, values);

                                MeridianResult meridianResult = new MeridianResult();
                                meridianResult.XmlDocument = savedShippingScheduleRequest;
                                meridianResult.OrderNumber = currentOrderNumber;
                                meridianResult.UniqueID    = currentShippingScheduleId;
                                meridianResult.Comments    = comment;
                                meridianResult.WebUserName = currentUser.WebUsername;
                                meridianResult.WebPassword = currentUser.WebPassword;
                                meridianResult.WebHashKey  = currentUser.Hashkey;

                                SendShippingScheduleResponse(meridianResult, responseTypeCoded);
                            }
                            else
                            {
                                MeridianSystemLibrary.LogTransaction(currentUser.WebUsername, currentUser.FtpUsername, "SendShippingScheduleResponseRequestFromPBSFTP", "05.05", "Warning - No Request Found", string.Format("No Request found for '{0}' PBS FTP file and ShippingScheduleId is '{1}' and OrderNumber is '{2}'", fileName, currentShippingScheduleId, currentOrderNumber), fileName, string.Empty, string.Empty, null, "Warning");
                            }
                        }
                        else
                        {
                            MeridianSystemLibrary.LogTransaction(currentUser.WebUsername, currentUser.FtpUsername, "SendShippingScheduleResponseRequestFromPBSFTP", "05.06", "Warning - ShippingScheduleId/OrderNumber/ResponseType/PurposeCoded Empty", string.Format("ShippingScheduleId - {0} /OrderNumber - {1} / ResponseType - {2} Empty for '{3}' PBS FTP file", currentShippingScheduleId, currentOrderNumber, responseTypeCoded, fileName), fileName, string.Empty, string.Empty, null, "Warning");
                        }
                    }
                }
                else
                {
                    MeridianSystemLibrary.LogTransaction(currentUser.WebUsername, currentUser.FtpUsername, "SendShippingScheduleResponseRequestFromPBSFTP", "05.04", "Warning - Empty File", string.Format("Empty File - '{0}' in PBS FTP folder", fileName), fileName, string.Empty, string.Empty, null, "Warning");
                }
            }
            catch (Exception ex)
            {
                MeridianSystemLibrary.LogTransaction(currentUser.WebUsername, currentUser.FtpUsername, "SendShippingScheduleResponseRequestFromPBSFTP", "06.05", "Error - While Parsing PBS File", string.Format("Error - While Parsing PBS FTP File - Inside Catch Block : {0}", ex.Message), fileName, string.Empty, string.Empty, null, "Error 06.05 - PBS File Parsing");
            }
            return(shouldDeletePBSOutFile);
        }
Ejemplo n.º 7
0
        /// <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) || string.IsNullOrEmpty(xCblServiceUser.FtpUsername))
                {
                    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);
                }
                return(true);
            }
            catch (Exception ex)
            {
                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);
            }
        }