Esempio n. 1
0
        public async Task <CKSSubjects> GetClientInfo(long id)
        {
            XDocument msg = new XDocument(
                new XElement("rabbitMsg",
                             new XElement("operation", "Get_Client_Info"),
                             new XElement("UUID", _uuid),
                             new XElement("xml",
                                          new XElement("cks",
                                                       new XElement("search",
                                                                    new XElement("clients",
                                                                                 new XElement("client",
                                                                                              new XAttribute("id", id)
                                                                                              )
                                                                                 )
                                                                    )
                                                       ).ToString()
                                          )
                             )
                );
            string response = await Task.Run(() => _cahannel.Call(msg.ToString()));

            var info = new CKSSubjects(response);

            if (info.Status == CKSOperationStatus.error)
            {
                throw new CKSOperationException(info.Error.Status, info.Error.ErrorMessage);
            }
            return(info);
        }
Esempio n. 2
0
        public async Task <CKSSubjects> PerformClientSearch(params object[] searchParameters)
        {
            XDocument msg  = new XDocument();
            XElement  root = new XElement("rabbitMsg");

            root.Add(
                new XElement("operation", "Perform_Client_Search"),
                new XElement("UUID", _uuid)
                );

            XElement xsearch = new XElement("search");
            XElement xcks    = new XElement("cks", xsearch);

            string pname = string.Empty;

            for (int i = 0; i < searchParameters.Length; i++)
            {
                if (i % 2 == 0)
                {
                    pname = (string)searchParameters[i];
                }
                else
                {
                    xsearch.Add(new XElement(pname, searchParameters[i]));
                }
            }
            root.Add(new XElement("xml", xcks.ToString()));
            msg.Add(root);

            string response = await Task.Run(() => _cahannel.Call(msg.ToString()));

            var info = new CKSSubjects(response);

            if (info.Status == CKSOperationStatus.error)
            {
                throw new CKSOperationException(info.Error.Status, info.Error.ErrorMessage);
            }
            return(info);
        }