Beispiel #1
0
        public static FileMetaData.Classes.CustomerLegacy.Individual CustomerLegacyByOnyxCustomerID(string OnyxCustomerID)
        {
            FileMetaData.Classes.CustomerLegacy.Individual oIndividual = null;
            string UserSalesforceId = string.Empty;
            string serviceUrlForUserSalesforceId = "http://services-uat.macmillan-learning.com/services/GetCustomerLegacy";
            string paramTemplate = "<parameters><secondaryId>{0}</secondaryId><objectType>individual</objectType></parameters>";

            try
            {
                //Assemble the URL string.Format(paramTemplate, OnyxCustomerID);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUrlForUserSalesforceId);// "application /x-www-form-urlencoded";
                byte[]         bytes;
                bytes                 = System.Text.Encoding.ASCII.GetBytes(string.Format(paramTemplate, OnyxCustomerID));
                request.Method        = "POST";
                request.ContentType   = "text/xml; encoding='utf-8'";
                request.ContentLength = bytes.Length;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(bytes, 0, bytes.Length);
                requestStream.Close();
                HttpWebResponse response;
                response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    Stream    responseStream     = response.GetResponseStream();
                    string    serviceXMLResponse = new StreamReader(responseStream).ReadToEnd();
                    XMLHelper hlpr = new XMLHelper();
                    oIndividual = hlpr.XMLDeserialize <CustomerLegacy.Individual>(serviceXMLResponse);
                }
            }
            catch (Exception ex)
            { oIndividual = null; }

            return(oIndividual);
        }
Beispiel #2
0
        private static string GetUserSalesforceIdByOnyxCustomerID(string OnyxCustomerID)
        {
            string UserSalesforceId = string.Empty;

            FileMetaData.Classes.CustomerLegacy.Individual oIndividual = CustomerLegacyByOnyxCustomerID(OnyxCustomerID);
            if (oIndividual != null)
            {
                UserSalesforceId = oIndividual.AssignedId;
            }
            return(UserSalesforceId);
        }