Exemplo n.º 1
0
        private GetRecipientTemplatesResponse parseGetRecipientTemplatesResponse(ServiceResponse Response)
        {
            GetRecipientTemplatesResponse response = Response.Factory <GetRecipientTemplatesResponse>();

            if (Response.IsSuccess)
            {
                try
                {
                    XElement          templates = Response.SOAPContent.Element(NS_SOAP_ENV + "Body").Element(NS_ACTION + "GetRecipientTemplatesResponse").Element(NS_ACTION + "RecipientTemplates");
                    RecipientTemplate newTemplate;

                    foreach (XElement el in templates.Elements())
                    {
                        newTemplate = new RecipientTemplate();

                        newTemplate.TemplateToken = el.Element(NS_ACTION + "TemplateToken").Value;

                        foreach (XElement param in el.Element(NS_ACTION + "Parameters").Elements())
                        {
                            newTemplate.Parameters.Add(param.Attribute("Name").Value, string.Empty);
                        }

                        response.Templates.Add(newTemplate.TemplateToken, newTemplate);
                    }
                }
                catch (Exception ex)
                {
                    response.IsSuccess = false;
                    response.Content   = "[ParseRecipientTemplatesResponse] " + ex.Message;
                }
            }

            return(response);
        }
Exemplo n.º 2
0
        public async Task Get_RecipientTemplates()
        {
            GetRecipientTemplatesResponse response = await actionService.GetRecipientTemplatesAsync(VALID_IP, VALID_USER, VALID_PASS);

            foreach (KeyValuePair <string, RecipientTemplate> t in response.Templates)
            {
                Console.WriteLine("Recipient template token : " + t.Key + "\r\n" + "Template parameters : ");
                foreach (KeyValuePair <string, string> param in t.Value.Parameters)
                {
                    Console.WriteLine("\t" + param.Key);
                }
            }

            Assert.IsTrue(response.IsSuccess && response.HttpStatusCode == System.Net.HttpStatusCode.OK && !response.SOAPContent.IsEmpty && response.Templates.Count > 0);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to retrieve the supported Actions templates of a device
        /// </summary>
        /// <param name="IP">The device ip address</param>
        /// <param name="User">User to authenticate the http request</param>
        /// <param name="Password">Password to use</param>
        /// <returns>GetActionTemplatesResponse, GetActionTemplatesResponse.Templates contains a List<ActionTemplate> with the supported Action Templates of the device</returns>
        ///
        public async Task <GetActionTemplatesResponse> GetActionTemplatesAsync(string IP, string User, string Password)
        {
            GetRecipientTemplatesResponse recTempResp = await this.GetRecipientTemplatesAsync(IP, User, Password);

            GetActionTemplatesResponse actTempResp = parseGetActionTemplatesResponse(await base.sendRequestAsync(IP, User, Password, @"<act:GetActionTemplates />"));

            //Bind a recipientTemplate instance to an actionTemplate instance
            if (recTempResp.IsSuccess)
            {
                foreach (KeyValuePair <string, ActionTemplate> ac in actTempResp.Templates)
                {
                    recTempResp.Templates.TryGetValue(ac.Value.RecipientTemplate, out ac.Value.recipientTemplateObj);
                }
            }
            return(actTempResp);
        }