Ejemplo n.º 1
0
        private string ParseObjectToXml(response res)
        {
            //Create our own namespaces for the output
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            //Add an empty namespace and empty value
            ns.Add(string.Empty, string.Empty);
            XmlSerializer xsSubmit = new XmlSerializer(typeof(response));
            XmlSerializer deserializer = new XmlSerializer(typeof(response), "ABC");

            System.IO.StringWriter sww = new System.IO.StringWriter();
            XmlWriter writer = XmlWriter.Create(sww);
            deserializer.Serialize(writer, res, ns);

            var xml = sww.ToString(); // Your xml
            var index = xml.IndexOf("<response");

            return xml.Substring(index);
        }
Ejemplo n.º 2
0
        public response GetExtension(string userName, string password, int customerId, string callerId)
        {
            var res = new response()
            {
                result = new ResponseResult()
                {
                    ivr_info = new ivr_info()
                    {
                        variables = new variable[1]
                    }
                }

            };
            //check login
            bool isLogined = userService.ValidateUser(userName, password);
            if (!isLogined)
            {
                return res;
            }
            if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(password) && customerId > 0 && !String.IsNullOrEmpty(callerId))
            {
                //TODO:
                //1. Telego call HHAExchange : callerId, appname,AppKey, AppSercret
                var getUrl = UrlRest + AppName + "/" + AppSecret + "/" + AppKey + "/" + callerId + "/" + Filter;
                WebClient client = new WebClient();
                string s = client.DownloadString(getUrl);

                CallerIDLookup restResult = ParseXMlToCallerIDLookup(s);

                //2. HHAExchange return a Coordinator1 Name
                if (restResult != null && restResult.Result != null)
                {
                    if (restResult.Result.Status.Equals(Infrastructure.StatusCode.Success))
                    {

                        if (restResult.LookupData != null)
                            if (!String.IsNullOrEmpty(restResult.LookupData.Coordinator1))
                            {
                                // get extension and coordinator
                                //3. Query Extension Number of Coordinator in TeleGo DB
                                string strvalue = customerCoordinateService.GetExtension(customerId, restResult.LookupData.Coordinator1);
                                variable varextension = new variable() { name = "extension", value = strvalue };
                                res.result.ivr_info.variables[0] = varextension;
                                //return ParseObjectToXml(res);

                                return res;
                            }

                    }
                    else if (restResult.Result.Status.Equals(Infrastructure.StatusCode.Failure.ToString()))
                    {
                        return default(response);
                    }
                }

            }
            else
            {
                return default(response);
            }
            //4. Return Extension to PBX
            return res;
        }