/// <summary>
        ///
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="children"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response CreateUpdatePolicy(RMCustomer customer, RMParentIDChild[] children, string company)
        {
            var      gpservices = new RMTransactionClient();
            Response response;

            response = gpservices.CreateUpdateCustomer(customer, new RMParentID(), children, company);

            gpservices.Close();

            return(response);
        }
        public async Task <ResultModel <RMCustomer> > CreateCustomer(RMCustomer rmCustomer)
        {
            rmCustomer.ModifiedDate = DateTime.Now;
            var entity = Mapper.Map <ReveEFAccess.Customer>(rmCustomer);

            db.Customers.Add(entity);
            await db.SaveChangesAsync();

            rmCustomer.CustomerID = entity.CustomerID;

            //CacheData.Cache_Stages = null;
            return(Success(rmCustomer));
        }
        private taUpdateCreateCustomerRcd SetCustomerValues(RMCustomer customer)
        {
            var pmCustomer = new taUpdateCreateCustomerRcd();

            try
            {
                pmCustomer.CUSTNMBR         = customer.CUSTNMBR;
                pmCustomer.HOLD             = customer.HOLD.GetValueOrDefault();
                pmCustomer.INACTIVE         = customer.INACTIVE.GetValueOrDefault();
                pmCustomer.CUSTNAME         = customer.CUSTNAME;
                pmCustomer.SHRTNAME         = customer.SHRTNAME;
                pmCustomer.STMTNAME         = customer.STMTNAME;
                pmCustomer.CUSTCLAS         = customer.CUSTCLASS;
                pmCustomer.ADRSCODE         = customer.ADRSCODE;
                pmCustomer.CNTCPRSN         = customer.CNTCPRSN;
                pmCustomer.ADDRESS1         = customer.ADDRESS1;
                pmCustomer.ADDRESS2         = customer.ADDRESS2;
                pmCustomer.ADDRESS3         = customer.ADDRESS3;
                pmCustomer.CITY             = customer.CITY;
                pmCustomer.STATE            = customer.STATE;
                pmCustomer.ZIPCODE          = customer.ZIPCODE;
                pmCustomer.CCode            = customer.CCode;
                pmCustomer.COUNTRY          = customer.COUNTRY;
                pmCustomer.PHNUMBR1         = customer.PHNUMBR1;
                pmCustomer.PHNUMBR2         = customer.PHNUMBR2;
                pmCustomer.PHNUMBR3         = customer.PHNUMBR3;
                pmCustomer.FAX              = customer.FAX;
                pmCustomer.TAXSCHID         = customer.TAXSCHID;
                pmCustomer.SLPRSNID         = customer.SLPRSNID;
                pmCustomer.SALSTERR         = customer.SALESTERR;
                pmCustomer.USERDEF1         = customer.USERDEF1;
                pmCustomer.USERDEF2         = customer.USERDEF2;
                pmCustomer.CRLMTTYP         = customer.CRLMTTYP.GetValueOrDefault();
                pmCustomer.CRLMTPER         = customer.CRLMTPER.GetValueOrDefault();
                pmCustomer.CRLMTAMT         = customer.CRLMTAMT.GetValueOrDefault();
                pmCustomer.TXRGNNUM         = customer.TXRGNNUM;
                pmCustomer.CURNCYID         = customer.CURNCYID;
                pmCustomer.CHEKBKID         = customer.CHEKBKID;
                pmCustomer.UseCustomerClass = customer.UseCustomerClass.GetValueOrDefault();
                pmCustomer.CreateAddress    = customer.CreateAddress.GetValueOrDefault();
                pmCustomer.INTEGRATIONID    = customer.INTEGRATIONID;
                pmCustomer.UpdateIfExists   = customer.UpdateIfExists.GetValueOrDefault();

                return(pmCustomer);
            }
            catch (Exception)
            {
                throw;
            }
        }
        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);
            }
        }
        /// <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;
            }
        }
Exemple #6
0
        public Response CreateCustomer(RMCustomer customer, RMParentIDChild[] children, string company)
        {
            var cust = new Customers();

            return(cust.CreateUpdatePolicy(customer, children, company));
        }
        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));
        }