Esempio n. 1
0
        public List <CustomerEntity> GetAll()
        {
            // change to be list of dictionalry
            var mapping = new QuickBooksXmlEntity()
            {
                Name = "Customer",
                Req  = "CustomerQueryRq",
                Ret  = new List <string>()
                {
                    "CustomerRet",
                }
            };

            string xml = ReadText(mapping);

            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }


            int index = xml.IndexOf("<CustomerRet>");

            xml = xml.Substring(index);
            xml = xml.Replace("</CustomerQueryRs>", "")
                  .Replace("</QBXMLMsgsRs>", "").Replace("</QBXML>", "");

            xml = xml.Replace("CustomerRet", "CustomerEntity");
            xml = $"<?xml version=\"1.0\" encoding=\"utf-16\"?><ArrayOfCustomerEntity xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">{xml}</ArrayOfCustomerEntity>";

            var data = (List <CustomerEntity>)xml.ParseToObject(typeof(List <CustomerEntity>));

            return(data);
        }
Esempio n. 2
0
        protected string ReadText(QuickBooksXmlEntity module, string data = null)
        {
            RequestProcessor2 request = null;
            string            input   = string.Format(RequestTemp, module.Req, data);

            if (module.RemoveId)
            {
                input = input.Replace("  requestID=\"whatever\"", "");
            }

            string response = "";

            try
            {
                request  = QuickBooksConection2();
                response = request.ProcessRequest(Ticket, input);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                //LogClass.WriteLogLine(string.Format("ERROR Table{0}: {1} *:* {2}", datamap.Req, ex.StackTrace, ex.Message));
                //MessageBox.Show("COM Error Description = " + ex.Message, "COM error");
                //return;
            }
            catch (Exception ex)
            {
                // -- log
            }
            finally
            {
                if (Ticket != null)
                {
                    request?.EndSession(Ticket);
                }
                request?.CloseConnection();
            }

            return(response);
        }