示例#1
0
        /// <summary>
        /// Sends the person to nav.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public bool SendPersonToNAV(string xml)
        {
            StringBuilder traceInfo = new StringBuilder();

            traceInfo.Append("---Send Person To NAV -> Call Received----\n\r");
            traceInfo.Append(" Time:" + DateTime.Now + "----\n\r");
            bool isSuccess = true;

            try
            {
                //convert the string to xml object
                XDocument xmlDoc = XDocument.Parse(xml);

                List <person> personObj = Utility.GetNAVPerson(xmlDoc);
                if (personObj != null && personObj.Count > 0)
                {
                    foreach (person person in personObj)
                    {
                        string responseID   = string.Empty;
                        string responseText = string.Empty;
                        navNSLUserPortClient.Person(person, ref responseID, ref responseText);
                        if (!responseID.Equals(Constants.SuccessStatusCode))
                        {
                            isSuccess = false;
                        }
                        traceInfo.Append("---Result received from NAV:" + responseID + "Response:" + responseText + " Time:" + DateTime.Now + "----\n\r");
                    }
                }
                else
                {
                    isSuccess = false;
                    traceInfo.Append("---Failed to read xml----\n\r");
                }
                FileErrorTracing.Log(traceInfo.ToString());
            }
            catch (Exception ex)
            {
                isSuccess = false;
                traceInfo.Append(ex.Message + string.Empty + ex.StackTrace);
                FileErrorTracing.Log(traceInfo.ToString());
            }
            return(isSuccess);
        }
示例#2
0
        /// <summary>
        /// Sends the profile to service.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public bool SendProfileToService(string xml)
        {
            bool          result    = true;
            StringBuilder traceInfo = new StringBuilder();

            traceInfo.Append("---Send Profile To ProfileService -> Call Received----\n\r");
            traceInfo.Append(" Time:" + DateTime.Now + "----\n\r");
            try
            {
                //convert the string to xml object
                XDocument xmlDoc = XDocument.Parse(xml);

                List <ProfileDTO> profileObj = Utility.GetProfile(xmlDoc);
                if (profileObj != null && profileObj.Count > 0)
                {
                    foreach (ProfileDTO profile in profileObj)
                    {
                        var response = Utility.UpdateProfile(profile).Result;
                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            result = false;
                            string error = response.Content.ReadAsStringAsync().Result;
                            traceInfo.Append("---Error received from Service:" + error + " Time:" + DateTime.Now + "----\n\r");
                        }
                        traceInfo.Append("---Result received from Service:" + response + " Time:" + DateTime.Now + "----\n\r");
                    }
                }
                else
                {
                    result = false;
                    traceInfo.Append("---Failed to read xml----\n\r");
                }
                FileErrorTracing.Log(traceInfo.ToString());
            }
            catch (Exception ex)
            {
                result = false;
                traceInfo.Append(ex.Message + string.Empty + ex.StackTrace);
                FileErrorTracing.Log(traceInfo.ToString());
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// Sends the person to service.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public bool SendPersonToService(string xml)
        {
            StringBuilder traceInfo = new StringBuilder();

            traceInfo.Append("---Send Person To Service -> Call Received----\n\r");
            traceInfo.Append(" Time:" + DateTime.Now + "----\n\r");
            bool isSuccess = true;

            try
            {
                bool republish = Convert.ToBoolean(ConfigurationManager.AppSettings[Constants.RePublish]);

                //convert the string to xml object
                XDocument        xmlDoc      = XDocument.Parse(xml);
                string           messageType = string.Empty;
                string           originator  = Utility.GetMessageTypeAndOriginator(xmlDoc, out messageType);
                List <PersonDTO> personObj   = Utility.GetPerson(xmlDoc);
                if (personObj != null && personObj.Count > 0)
                {
                    foreach (PersonDTO person in personObj)
                    {
                        if (person.PersonGuid != null)
                        {
                            PersonDTO personDetails = Utility.GetPersonByGuid(person.PersonGuid.Value).Result;
                            if (personDetails != null && personDetails.PersonGuid != null && personDetails.PersonGuid.HasValue)
                            {
                                messageType = UPDATED_TYPE;
                            }
                            else
                            {
                                messageType = CREATED_TYPE;
                            }

                            if (messageType.Equals(CREATED_TYPE, StringComparison.InvariantCultureIgnoreCase))
                            {
                                var result = Utility.CreatePersonAsync(person, originator, republish).Result;
                                if (result.StatusCode != HttpStatusCode.Created)
                                {
                                    isSuccess = false;
                                    string res = result.Content.ReadAsStringAsync().Result;
                                    traceInfo.Append("---Error received from Service:" + res + " Time:" + DateTime.Now + "----\n\r");
                                }
                                traceInfo.Append("---Result received from Service:" + result + " Time:" + DateTime.Now + "----\n\r");
                            }
                            if (messageType.Equals(UPDATED_TYPE, StringComparison.InvariantCultureIgnoreCase))
                            {
                                PersonDTO updatedPerson = Utility.UpdatePerson(person.PersonGuid.Value, person, originator, republish).Result;
                                if (updatedPerson != null && updatedPerson.PersonGuid != null)
                                {
                                    traceInfo.Append("---Result received from Service: Updation Successful. Time:" + DateTime.Now + "----\n\r");
                                }
                                else
                                {
                                    isSuccess = false;
                                    traceInfo.Append("---Result received from Service: Updation Failed. Time:" + DateTime.Now + "----\n\r");
                                }
                            }
                        }
                        else
                        {
                            traceInfo.Append("---Person Guid is null. Time:" + DateTime.Now + "----\n\r");
                        }
                    }
                }
                else
                {
                    isSuccess = false;
                    traceInfo.Append("---Failed to read xml----\n\r");
                }
                FileErrorTracing.Log(traceInfo.ToString());
            }
            catch (Exception ex)
            {
                isSuccess = false;
                traceInfo.Append(ex.Message + string.Empty + ex.StackTrace);
                FileErrorTracing.Log(traceInfo.ToString());
            }
            return(isSuccess);
        }