예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="parent"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response CreateUpdateCustomer(RMCustomer customer, RMParentID parent, string company)
        {
            var      gpservices = new RMTransactionClient();
            Response response;

            RMParentIDChild[] children = new RMParentIDChild[0];
            response = gpservices.CreateUpdateCustomer(customer, parent, children, company);

            gpservices.Close();

            return(response);
        }
        public Response CustomerCreateUpdate(RMCustomer customer, RMParentID parent, List <RMParentIDChild> children, string company)
        {
            var response = new Response();

            string CustomerXML;
            string server = ConfigKey.ReadSetting("SERVER");
            //var server = Properties.Settings.Default.SERVER.ToString();
            string CNX      = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var    eConnect = new eConnectRequest();

            taUpdateCreateCustomerRcd rmCustomerCreateUpdate;
            taCreateParentID          rmparent;

            taParentIDChild_ItemsTaParentIDChild[] rmchildren;

            try
            {
                rmCustomerCreateUpdate = SetCustomerValues(customer);

                if (children.Count > 0)
                {
                    rmchildren  = SetParentChildValues(children);
                    CustomerXML = SerializeCustomerChild(rmCustomerCreateUpdate, rmchildren);
                }
                else if (children.Count == 0 && !string.IsNullOrEmpty(parent.CPRCSTNM))
                {
                    rmparent    = SetParentValues(parent);
                    CustomerXML = SerializeCustomerParent(rmCustomerCreateUpdate, rmparent);
                }
                else
                {
                    CustomerXML = SerializeCustomer(rmCustomerCreateUpdate);
                }

                //CustomerXML = SerializeCustomer(rmCustomerCreateUpdate, rmparent, rmchildren);
                response = eConnect.CreateGPMaster(CNX, CustomerXML);

                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
        }
        private taCreateParentID SetParentValues(RMParentID parent)
        {
            var rmparent = new taCreateParentID();

            try
            {
                rmparent.CPRCSTNM        = parent.CPRCSTNM;
                rmparent.NAALLOWRECEIPTS = parent.NAALLOWRECEIPTS.GetValueOrDefault();
                rmparent.NACREDITCHECK   = parent.NACREDITCHECK.GetValueOrDefault();
                rmparent.NAFINANCECHARGE = parent.NAFINANCECHARGE.GetValueOrDefault();
                rmparent.NAHOLDINACTIVE  = parent.NAHOLDINACTIVE.GetValueOrDefault();
                rmparent.NADEFPARENTVEN  = parent.NADEFPARENTVEN.GetValueOrDefault();
                rmparent.UpdateIfExists  = parent.UpdateIfExists.GetValueOrDefault();
                rmparent.RequesterTrx    = parent.RequesterTrx.GetValueOrDefault();

                return(rmparent);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// Procesar Customers
        /// </summary>
        public void Process()
        {
            var    customer      = new CustomerBL();
            string integrationid = ConfigKey.ReadSetting("INTEGRATIONID");
            List <SYSFLEX_CUSTOMER> customerlist = customer.GetCustomer();
            var company = ConfigKey.ReadSetting("Company");

            eConnectIntegration.CLASS.Response response;

            try
            {
                foreach (SYSFLEX_CUSTOMER cust in customerlist)
                {
                    try
                    {
                        log.escribirLog(0, "Sincronización de Cliente " + cust.CUSTNMBR);
                        var rmcustomer = new RMCustomer();

                        if (string.IsNullOrEmpty(cust.CUSTNAME))
                        {
                            cust.CUSTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.SHRTNAME))
                        {
                            cust.SHRTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.STMTNAME))
                        {
                            cust.STMTNAME = "";
                        }

                        if (string.IsNullOrEmpty(cust.CUSTCLAS))
                        {
                            cust.CUSTCLAS = "";
                        }

                        if (string.IsNullOrEmpty(cust.CNTCPRSN))
                        {
                            cust.CNTCPRSN = "";
                        }

                        if (string.IsNullOrEmpty(cust.ADDRESS1))
                        {
                            cust.ADDRESS1 = "";
                        }

                        if (string.IsNullOrEmpty(cust.CITY))
                        {
                            cust.CITY = "";
                        }

                        if (string.IsNullOrEmpty(cust.COUNTRY))
                        {
                            cust.COUNTRY = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR1))
                        {
                            cust.PHNUMBR1 = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR2))
                        {
                            cust.PHNUMBR2 = "";
                        }

                        if (string.IsNullOrEmpty(cust.PHNUMBR3))
                        {
                            cust.PHNUMBR3 = "";
                        }

                        if (string.IsNullOrEmpty(cust.fax))
                        {
                            cust.fax = "";
                        }

                        rmcustomer.CUSTNMBR = cust.CUSTNMBR.ToString();
                        //rmcustomer.HOLD = cust.HOLD.GetValueOrDefault();
                        rmcustomer.INACTIVE       = cust.INACTIVE.GetValueOrDefault();
                        rmcustomer.CUSTNAME       = cust.CUSTNAME.Trim() + " " + cust.SHRTNAME.Trim() + " " + cust.STMTNAME.Trim();
                        rmcustomer.SHRTNAME       = cust.CUSTNAME.Trim() + " " + cust.STMTNAME;
                        rmcustomer.STMTNAME       = cust.CUSTNAME.Trim() + " " + cust.STMTNAME;
                        rmcustomer.CUSTCLASS      = cust.CUSTCLAS;
                        rmcustomer.CNTCPRSN       = cust.CNTCPRSN;
                        rmcustomer.ADRSCODE       = "PRIMARY        ";
                        rmcustomer.ADDRESS1       = cust.ADDRESS1;
                        rmcustomer.ADDRESS2       = cust.ADDRESS2.GetValueOrDefault().ToString();
                        rmcustomer.ADDRESS3       = cust.ADDRESS3.GetValueOrDefault().ToString();
                        rmcustomer.CITY           = cust.CITY;
                        rmcustomer.COUNTRY        = cust.COUNTRY;
                        rmcustomer.PHNUMBR1       = cust.PHNUMBR1;
                        rmcustomer.PHNUMBR2       = cust.PHNUMBR2;
                        rmcustomer.PHNUMBR3       = cust.PHNUMBR3;
                        rmcustomer.FAX            = cust.fax;
                        rmcustomer.INTEGRATIONID  = integrationid;
                        rmcustomer.CreateAddress  = 1;
                        rmcustomer.UpdateIfExists = 1;

                        var rmparent = new RMParentID();
                        rmparent.CPRCSTNM        = cust.CUSTNMBR.ToString();
                        rmparent.UpdateIfExists  = 1;
                        rmparent.NAALLOWRECEIPTS = 1;

                        response = customer.CreateUpdateCustomer(rmcustomer, rmparent, company);

                        if (response.SUCCESS)
                        {
                            var customerupdate = new ST_CLIENT_TABLE_SYNC();
                            customerupdate.CUSTNMBR = rmcustomer.CUSTNMBR;
                            customer.Customer_UpdateLastUpdate(customerupdate);
                            log.escribirLog(0, response.MESSAGE);
                        }
                        else
                        {
                            log.escribirLog(1, response.MESSAGE);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.escribirLog(2, "Ocurrió un error con el customer " + cust.CUSTNMBR);
                        log.LogExeption("Detalle del error: ", 2, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                log.LogExeption("Ocurrió un error: ", 2, ex);
                //throw;
            }
        }
예제 #5
0
        public Response CreateUpdateCustomer(RMCustomer customer, RMParentID parent, string company)
        {
            var cust = new Customers();

            return(cust.CreateUpdateCustomer(customer, parent, company));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="parent"></param>
        /// <param name="children"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response CreateUpdateCustomer(RMCustomer customer, RMParentID parent, List <RMParentIDChild> children, string company)
        {
            RMCustomerCreateUpdate createCustomer = new RMCustomerCreateUpdate();

            return(createCustomer.CustomerCreateUpdate(customer, parent, children, company));
        }