Example #1
0
        public async Task <ResponseBase <CustomerModel> > GetCustomer(string document)
        {
            var response = new ResponseBase <CustomerModel>();

            if (!string.IsNullOrWhiteSpace(document))
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                var user = new CustomerModel();

                repository.Status.Code = Status.Ok;
                if (repository.Status.Code == Status.Ok)
                {
                    for (var item = 0; item > 100; ++item)
                    {
                        user.CustId = item;
                    }

                    response.Data = user;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field Document is empty";
            }

            return(await Task.Run(() => response));
        }
Example #2
0
        public async Task <ResponseBase <CustomerModel> > LoginCustomer(CustomerAuthModel data)
        {
            var response = new ResponseBase <CustomerModel>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                var user = new CustomerModel()
                {
                    CustId = -1
                };
                if (repository.Status.Code == Status.Ok)
                {
                    user.CustId   = 1;
                    response.Data = user;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #3
0
        public async Task <ResponseBase <Boolean> > InsertCustomer(CustomerModel data)
        {
            var response = new ResponseBase <Boolean>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer creado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #4
0
        private ResponseBase <bool> InsertItem(ItemModel ObjItem)
        {
            var response = new ResponseBase <bool>();
            var validate = ValidateMiddle.Result(ObjItem);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                if (repository.Status.Code == Status.Ok)
                {
                    response.Code = Status.Ok;
                    response.Data = true;
                }
                else
                {
                    response.Code    = repository.Status.Code;
                    response.Message = repository.Status.Message;
                    response.Data    = false;
                }
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(response);
        }
Example #5
0
        public async Task <ResponseBase <bool> > ActualizaEstadoOrder(int IdOrden, int IdEstado)
        {
            var response = new ResponseBase <bool>();

            if (IdOrden > 0 && IdEstado > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Orden actualizada correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field IdOrder or IdEstado is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #6
0
        public async Task <ResponseBase <Boolean> > DeleteCustomer(long id)
        {
            var response = new ResponseBase <Boolean>();

            if (id != 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_CUSTID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Varchar2, 200).Value = id;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction   = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_CUSTOMER.B2C_CUSTOMER_ELIMINAR");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer Eliminado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field Id is zero(0)";
            }
            return(await Task.Run(() => response));
        }
Example #7
0
        public async Task <ResponseBase <bool> > ActualizaEstadoOrder(int IdOrden, int IdEstado)
        {
            var response = new ResponseBase <bool>();

            if (IdOrden > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ROWCOUNT");

                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Value        = IdOrden;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value     = IdEstado;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_ACTUALIZA");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Orden actualizada correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field IdOrder or IdEstado is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #8
0
        public async Task <ResponseBase <Boolean> > DeleteCustomer(long id)
        {
            var response = new ResponseBase <Boolean>();

            if (id != 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer Eliminado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field Id is zero(0)";
            }
            return(await Task.Run(() => response));
        }
        public IActionResult Kcex2(int kcex)
        {
            OracleRepository repo = new OracleRepository();
            var queryRes          = repo.GetEntities <RI_BIND_OB_V>();

            int[] konvenum = { 5, 4, 1, 2, 3 };
            ViewBag.KonveNum = konvenum;
            ViewBag.Colors   = Colors;

            return(View(queryRes.Where(x => x.KCEH == "OP02" && x.KPLOT.StartsWith("20")).OrderBy(x => x.WP).ToList()));
        }
Example #10
0
        public async Task <ResponseBase <List <CustomerModel> > > GetCustomerbyProduct(string product)
        {
            var response = new ResponseBase <List <CustomerModel> >();

            if (!string.IsNullOrWhiteSpace(product))
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var luser = new List <CustomerModel>();
                var user  = new CustomerModel();

                repository.Parameters.Add("P_PRODUCT", OracleDbType.Varchar2, 200).Value = product;
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_CUSTOMER.B2C_CUSTOMER_SELECT_PRODUCT");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        user = new CustomerModel();

                        user.CustId           = long.Parse(item["CUSTID"].ToString());
                        user.FName            = item["FNAME"].ToString();
                        user.LName            = item["LNAME"].ToString();
                        user.PhoneNumber      = item["PHONENUMBER"].ToString();
                        user.Email            = item["EMAIL"].ToString();
                        user.CreditCardType   = item["CREDITCARDTYPE"].ToString();
                        user.CreditCardNumber = item["CREDITCARDNUMBER"].ToString();
                        user.Status           = item["STATUS"].ToString();
                        user.DocNumber        = item["DOCNUMBER"].ToString();
                        user.UserName         = item["USERNAME"].ToString();
                        user.TipoCliente      = item["TIPOCLIENTE"].ToString();
                        user.ORDID            = item["ORDID"].ToString();
                        user.ITEMID           = item["ITEMID"].ToString();

                        luser.Add(user);
                    }

                    response.Data = luser;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field Document is empty";
            }

            return(await Task.Run(() => response));
        }
Example #11
0
 public string CheckMachineParamsByID(string MachineID, string reel_id)
 {
     try
     {
         string    sqlGetID      = "select TERMINAL_NAME from SYS_TERMINAL where TERMINAL_ID='" + MachineID + "'";
         var       dbSearch      = new OracleRepository(NewMesTest);
         DataTable dtMachineName = dbSearch.FindTable(sqlGetID);
         if (dtMachineName.Rows.Count == 0)
         {
             LogHelper.Info("NG:根据机台ID查找不到机台名称" + MachineID);
             return("NG:根据机台ID查找不到机台名称");
         }
         string MachineType = dtMachineName.Rows[0][0].ToString();
         //判断机台类型,分为Masking,Sensor和VCN1,VCN2
         if (MachineType.Contains("Masking"))
         {
             MachineType = "Masking";
         }
         else if (MachineType.Contains("Glue staking"))
         {
             MachineType = "Sensor";
         }
         else if (MachineType.Contains("VCN1"))
         {
             MachineType = "VCN1Coating";
         }
         else if (MachineType.Contains("VCN2"))
         {
             MachineType = "VCN2Coating";
         }
         string    sqlGetParams   = "select A as MachineParam from sajet.machine_name where MACHINE_NAME='" + MachineType + "'";
         DataTable dtMachineParam = dbSearch.FindTable(sqlGetID);
         if (dtMachineParam.Rows.Count == 0)
         {
             LogHelper.Info("NG:根据机台名称查找不到机台胶水料号" + MachineID);
             return("NG:根据机台名称查找不到机台胶水料号");
         }
         LogHelper.Info("查询胶水料号成功;" + dtMachineParam.Rows[0][0].ToString() + ";" + MachineID);
         reel_id = reel_id.Substring(0, 14);//截取前十四位位胶水料号
         if (reel_id != dtMachineParam.Rows[0][0].ToString())
         {
             LogHelper.Info("NG:当前机台应该使用的胶水料号不正确" + MachineID);
             return("NG:当前机台使用的胶水料号不正确");
         }
         return(dtMachineParam.Rows[0][0].ToString());
     }
     catch (Exception ex)
     {
         LogHelper.Info("NG:查询机台胶水料号异常" + ex.ToString() + "请联系系统工程师解决");
         return("NG:查询机台胶水料号异常" + ex.ToString() + "请联系系统工程师解决");
     }
 }
Example #12
0
        public async Task <ResponseBase <CustomerModel> > LoginCustomer(CustomerAuthModel data)
        {
            var response = new ResponseBase <CustomerModel>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var user = new CustomerModel()
                {
                    CustId = -1
                };

                repository.Parameters.Add("P_USERNAME", OracleDbType.Varchar2, 200).Value   = data.Username;
                repository.Parameters.Add("P_CONTRASENA", OracleDbType.Varchar2, 200).Value = data.Password;
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction    = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_CUSTOMER.B2C_CUSTOMER_SELECT_AUTENTICAR");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        user.CustId           = long.Parse(item["CUSTID"].ToString());
                        user.FName            = item["FNAME"].ToString();
                        user.LName            = item["LNAME"].ToString();
                        user.PhoneNumber      = item["PHONENUMBER"].ToString();
                        user.Email            = item["EMAIL"].ToString();
                        user.Password         = item["PASSWORD"].ToString();
                        user.CreditCardType   = item["CREDITCARDTYPE"].ToString();
                        user.CreditCardNumber = item["CREDITCARDNUMBER"].ToString();
                        user.Status           = item["STATUS"].ToString();
                        user.DocNumber        = item["DOCNUMBER"].ToString();
                        user.UserName         = item["USERNAME"].ToString();
                        user.TipoCliente      = item["TIPOCLIENTE"].ToString();
                    }

                    response.Data = user;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #13
0
        public async Task <ResponseBase <AuthenticateResponse> > Authenticate(AuthenticateModel data)
        {
            IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
            var response = new ResponseBase <AuthenticateResponse>();
            var user     = new AuthenticateResponse();

            repository.Parameters.Add("P_USERNAME", OracleDbType.Varchar2).Value        = data.UserName;
            repository.Parameters.Add("P_CONTRASENA", OracleDbType.Varchar2, 200).Value = data.Password;
            repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction    = ParameterDirection.Output;

            var result = repository.Get("PKG_B2C_CUSTOMER.B2C_CUSTOMER_SELECT_AUTENTICAR");

            if (repository.Status.Code == Status.Ok)
            {
                if (result.Count > 0)
                {
                    var r = result[0]["CUSTID"];

                    foreach (var item in result)
                    {
                        user.Id          = long.Parse(item["CUSTID"].ToString());
                        user.Names       = item["FNAME"].ToString();
                        user.Surnames    = item["LNAME"].ToString();
                        user.Status      = item["STATUS"].ToString();
                        user.TipoCliente = item["TIPOCLIENTE"].ToString();

                        //user.CUSTID = long.Parse(item["CUSTID"].ToString());
                        //user.FNAME = item["FNAME"].ToString();
                        //user.LNAME = item["LNAME"].ToString();
                        //user.PHONENUMBER = item["PHONENUMBER"].ToString();
                        //user.EMAIL = item["EMAIL"].ToString();
                        //user.PASSWORD = item["PASSWORD"].ToString();
                        //user.CREDITCARDTYPE = item["CREDITCARDTYPE"].ToString();
                        //user.CREDITCARDNUMBER = item["CREDITCARDNUMBER"].ToString();
                        //user.STATUS = item["STATUS"].ToString();
                    }
                }
                else
                {
                    response.Code = Status.NotFound;
                }

                response.Data = user;
            }
            else
            {
                response.Message = repository.Status.Message;
            }
            response.Code = repository.Status.Code;

            return(await Task.Run(() => response));
        }
Example #14
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, IndividualsServicesConfig config)
        {
            //data layer
            var dataSettingsManager  = new DataSettingsManager();
            var dataProviderSettings = dataSettingsManager.LoadSettings(connectionStringName: config.SqlConnection);

            builder.Register(c => dataProviderSettings).As <DataSettings>();
            builder.Register(x => new EfDataProviderManager(x.Resolve <DataSettings>())).As <BaseDataProviderManager>().InstancePerDependency();

            builder.Register(x => x.Resolve <BaseDataProviderManager>().LoadDataProvider()).As <IDataProvider>().InstancePerDependency();

            if (dataProviderSettings != null && dataProviderSettings.IsValid())
            {
                var efDataProviderManager = new EfDataProviderManager(dataProviderSettings);
                var dataProvider          = efDataProviderManager.LoadDataProvider();
                dataProvider.InitConnectionFactory();

                builder.Register <IDbContext>(c => new IndividualsServicesObjectContext(dataProviderSettings.DataConnectionString)).InstancePerLifetimeScope();
            }
            else
            {
                builder.Register <IDbContext>(c => new IndividualsServicesObjectContext(dataProviderSettings.DataConnectionString)).InstancePerLifetimeScope();
            }

            //repositories
            builder.RegisterGeneric(typeof(EfRepository <,>)).As(typeof(IRepository <,>)).InstancePerLifetimeScope();

            //cache manager
            builder.RegisterType <MemoryCacheManager>().As <ICacheManager>().SingleInstance();


            //services
            builder.RegisterType <LaborerService>().As <ILaborerService>().InstancePerLifetimeScope();
            builder.RegisterType <ServiceLogService>().As <IServiceLogService>().InstancePerLifetimeScope();

            builder.RegisterType <NitaqatService>().As <INitaqatService>().InstancePerLifetimeScope();
            builder.RegisterType <EstablishmentService>().As <IEstablishmentService>().InstancePerLifetimeScope();
            builder.RegisterType <RunawayService>().As <IRunawayService>().InstancePerLifetimeScope();
            builder.RegisterType <SponsorTransferService>().As <ISponsorTransferService>().InstancePerLifetimeScope();

            var oracleRepo = new OracleRepository(config.OracleConnection.ConnectionString, config.OracleConnection.Schema);

            builder.Register <IOracleRepository>(ora => oracleRepo).InstancePerLifetimeScope();


            builder.RegisterType <RoutePublisher>().As <IRoutePublisher>().SingleInstance();
            builder.RegisterType <SettingService>().As <ISettingService>().InstancePerLifetimeScope();
            //register all settings
            builder.RegisterSource(new SettingsSource());
        }
Example #15
0
        public async Task <ResponseBase <Boolean> > UpdateCustomer(CustomerModel data)
        {
            data.Password = !string.IsNullOrWhiteSpace(data.Password) ? data.Password : "******";

            var response = new ResponseBase <Boolean>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                if (data.Password == "=====")
                {
                    data.Password = "";
                }
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_CUSTID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Int64).Value                   = data.CustId;
                repository.Parameters.Add("P_FNAME", OracleDbType.Varchar2, 200).Value            = data.FName;
                repository.Parameters.Add("P_LNAME", OracleDbType.Varchar2, 200).Value            = data.LName;
                repository.Parameters.Add("P_PHONENUMBER", OracleDbType.Varchar2, 200).Value      = data.PhoneNumber;
                repository.Parameters.Add("P_EMAIL", OracleDbType.Varchar2, 200).Value            = data.Email;
                repository.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2, 200).Value         = data.Password;
                repository.Parameters.Add("P_CREDITCARDTYPE", OracleDbType.Varchar2, 200).Value   = data.CreditCardType;
                repository.Parameters.Add("P_CREDITCARDNUMBER", OracleDbType.Varchar2, 200).Value = data.CreditCardNumber;
                repository.Parameters.Add("P_STATUS", OracleDbType.Varchar2, 200).Value           = data.Status;
                repository.Parameters.Add("P_DOCNUMBER", OracleDbType.Varchar2).Value             = data.DocNumber;
                repository.Parameters.Add("P_USERNAME", OracleDbType.Varchar2, 200).Value         = data.UserName;
                repository.Parameters.Add("P_TIPOCLIENTE", OracleDbType.Varchar2, 200).Value      = data.ClientType;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction             = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_CUSTOMER.B2C_CUSTOMER_ACTUALIZAR");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer Actualizado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #16
0
        public static bool oraclelog(string terminal_id, string work_order, string log_detail, string log_status)
        {
            var    dbSearch = new OracleRepository(oracleConnectionStr);
            string sql      = "insert into vsky.tsc_log(terminal_id,time,work_order,logdetail,status) values(:terminal_id,SYSDATE,:work_order,:log_detail,:log_status)";
            var    td       = dbSearch.ExecuteBySql(sql, new { terminal_id = terminal_id, work_order = work_order, log_detail = log_detail, log_status = log_status });

            //int num = td.Rows.Count;
            if (td == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Example #17
0
        public async Task <ResponseBase <long> > InsertOrder(OrderModel data)
        {
            var response = new ResponseBase <long>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ORDID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Int64).Value        = data.CustId;
                repository.Parameters.Add("P_ORDENDATE", OracleDbType.Date, 200).Value = DateTime.Now;
                repository.Parameters.Add("P_PRICE", OracleDbType.Long, 200).Value     = data.Price;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value      = 1;
                //repository.Parameters.Add("P_STATUS", OracleDbType.Varchar2).Value = data.Status;
                repository.Parameters.Add("P_COMMENTS", OracleDbType.Varchar2).Value = data.Comments;
                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Direction   = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_INSERT");
                if (repository.Status.Code == Status.Ok)
                {
                    var OrdId = Int64.Parse(repository.Parameters["P_ORDID"].Value.ToString());
                    foreach (var item in data.LItems)
                    {
                        item.OrdId    = OrdId;
                        item.IdEstado = 1;
                        InsertItem(item);
                    }
                    ;

                    response.Data    = OrdId;
                    response.Message = "Orden insertada correctamente";
                }
                else
                {
                    response.Data    = -1;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #18
0
        public async Task <ResponseBase <List <OrderModel> > > GetOrders(long custId)
        {
            var response = new ResponseBase <List <OrderModel> >();

            if (custId > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var order  = new OrderModel();
                var lOrder = new List <OrderModel>();

                repository.Parameters.Add("P_CUSTID", OracleDbType.Int64).Value          = custId;
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_ORDERS.B2C_ORDERS_SELECT_CLIENTE");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        order           = new OrderModel();
                        order.Comments  = item["COMMENTS"].ToString();
                        order.CustId    = long.Parse(item["CUSTID"].ToString());
                        order.OrdenDate = DateTime.Parse(item["ORDENDATE"].ToString());
                        order.OrdId     = long.Parse(item["ORDID"].ToString());
                        order.Price     = decimal.Parse(item["PRICE"].ToString());
                        order.Status    = item["IDESTADO"].ToString();
                        order.LItems    = GetItemFromOrder(order.OrdId).Result.Data;

                        lOrder.Add(order);
                    }

                    response.Data = lOrder;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field CustId is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #19
0
        public async Task <ResponseBase <List <ReportOrdenModel> > > GetReportOrders(int tipobusqueda, string fecha1, string fecha2)
        {
            var response = new ResponseBase <List <ReportOrdenModel> >();

            if (tipobusqueda > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var order  = new ReportOrdenModel();
                var lOrder = new List <ReportOrdenModel>();

                repository.Parameters.Add("P_TIPO_INFORME", OracleDbType.Int32).Value    = tipobusqueda;
                repository.Parameters.Add("P_FECHA1", OracleDbType.Date).Value           = DateTime.Parse(fecha1);
                repository.Parameters.Add("P_FECHA2", OracleDbType.Date).Value           = DateTime.Parse(fecha2);
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_REPORT.B2C_ORDERS_SELECT");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        order               = new ReportOrdenModel();
                        order.ordid         = long.Parse(item["ORDID"].ToString());
                        order.comments      = item["COMMENTS"].ToString();
                        order.fname         = item["FNAME"].ToString();
                        order.ordendate     = DateTime.Parse(item["ORDENDATE"].ToString());
                        order.nombre_estado = item["NOMBRE_ESTADO"].ToString();
                        order.price         = double.Parse(item["PRICE"].ToString());
                        lOrder.Add(order);
                    }

                    response.Data = lOrder;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field CustId is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #20
0
        public async Task <ResponseBase <List <ItemModel> > > GetItemFromOrder(long IdOrder)
        {
            var response = new ResponseBase <List <ItemModel> >();

            if (IdOrder > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var ObjItem  = new ItemModel();
                var listItem = new List <ItemModel>();

                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Value           = IdOrder;
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_ORDERS.B2C_ITEMS_SELECT_ORDEN");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        ObjItem             = new ItemModel();
                        ObjItem.ItemId      = long.Parse(item["ITEMID"].ToString());
                        ObjItem.OrdId       = long.Parse(item["ORDID"].ToString());
                        ObjItem.PartNum     = item["PARTNUM"].ToString();
                        ObjItem.Price       = decimal.Parse(item["PRICE"].ToString());
                        ObjItem.ProdId      = long.Parse(item["PRODID"].ToString());
                        ObjItem.ProductName = item["PRODUCTNAME"].ToString();
                        ObjItem.Quantity    = int.Parse(item["QUANTITY"].ToString());

                        listItem.Add(ObjItem);
                    }
                    ;
                    response.Data = listItem;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field IdOrder is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #21
0
        public async Task <ResponseBase <List <ReportProductModel> > > GetReportProducto(int tipobusqueda, string fecha1, string fecha2)
        {
            var response = new ResponseBase <List <ReportProductModel> >();

            if (tipobusqueda > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var order  = new ReportProductModel();
                var lOrder = new List <ReportProductModel>();

                repository.Parameters.Add("P_TIPO_INFORME", OracleDbType.Int32).Value    = tipobusqueda;
                repository.Parameters.Add("P_FECHA1", OracleDbType.Date).Value           = DateTime.Parse(fecha1);
                repository.Parameters.Add("P_FECHA2", OracleDbType.Date).Value           = DateTime.Parse(fecha2);
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_REPORT.B2C_ORDERS_SELECT");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        order             = new ReportProductModel();
                        order.productname = item["PRODUCTNAME"].ToString();
                        order.Cantidad    = int.Parse(item["CANTIDAD"].ToString());
                        order.proid       = int.Parse(item["PRODID"].ToString());
                        order.valor       = double.Parse(item["VALOR"].ToString());
                        lOrder.Add(order);
                    }

                    response.Data = lOrder;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field CustId is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #22
0
        public async Task <ResponseBase <List <ReportOrdenModel> > > GetReportOrderMonthDetail(string month)
        {
            var response = new ResponseBase <List <ReportOrdenModel> >();

            if (month.Length > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "C_DATASET");
                var order  = new ReportOrdenModel();
                var lOrder = new List <ReportOrdenModel>();

                repository.Parameters.Add("P_MONTH", OracleDbType.Varchar2).Value        = month;
                repository.Parameters.Add("C_DATASET", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                var result = repository.Get("PKG_B2C_REPORT.B2C_MONTH_RANKING_SELECT");
                if (repository.Status.Code == Status.Ok)
                {
                    foreach (var item in result)
                    {
                        order               = new ReportOrdenModel();
                        order.ordid         = long.Parse(item["ORDID"].ToString());
                        order.comments      = item["COMMENTS"].ToString();
                        order.fname         = item["FNAME"].ToString();
                        order.ordendate     = DateTime.Parse(item["ORDENDATE"].ToString());
                        order.nombre_estado = item["NOMBRE_ESTADO"].ToString();
                        order.price         = double.Parse(item["PRICE"].ToString());
                        lOrder.Add(order);
                    }

                    response.Data = lOrder;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field CustId is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #23
0
        public async Task <ResponseBase <int> > GetCancelaProveedor()
        {
            var response = new ResponseBase <int>();

            IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ORDID");

            repository.Parameters.Add("P_ITEMID", OracleDbType.Int32).Value = 1;

            repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_CANCELA_PROVEEDOR");
            if (repository.Status.Code == Status.Ok)
            {
                response.Data = 1;
            }
            else
            {
                response.Message = repository.Status.Message;
            }
            response.Code = repository.Status.Code;

            return(await Task.Run(() => response));
        }
Example #24
0
    public static IRepository <IBasic> GetRepository(DataSource repositoryType)
    {
        IRepository <IBasic> repo = null;

        switch (repositoryType)
        {
        //break;
        case DataSource.Csv:
            repo = new CsvRepository();
            break;

        case DataSource.Oracle:
            repo = new OracleRepository();
            break;

        default:
            throw new ArgumentException("Invalid Repository Type");
        }

        return(repo);
    }
Example #25
0
        public async Task <ResponseBase <List <OrderModel> > > GetOrders(long custId)
        {
            var response = new ResponseBase <List <OrderModel> >();

            if (custId > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                var order  = new OrderModel();
                var lOrder = new List <OrderModel>();

                repository.Status.Code = Status.Ok;
                if (repository.Status.Code == Status.Ok)
                {
                    for (var item = 0; item < 100; ++item)
                    {
                        order        = new OrderModel();
                        order.CustId = custId;
                        order.OrdId  = item;
                        order.Status = "1";
                        order.LItems = GetItemFromOrder(order.OrdId).Result.Data;

                        lOrder.Add(order);
                    }

                    response.Data = lOrder;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field CustId is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Example #26
0
        public async Task <ResponseBase <bool> > InsertOrder(OrderModel data)
        {
            var response = new ResponseBase <bool>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                repository.Status.Code = Status.Ok;

                if (repository.Status.Code == Status.Ok)
                {
                    var OrdId = 1;
                    foreach (var item in data.LItems)
                    {
                        item.OrdId    = OrdId;
                        item.IdEstado = 1;
                        InsertItem(item);
                    }
                    ;

                    response.Data    = true;
                    response.Message = "Orden insertada correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Example #27
0
        private ResponseBase <Boolean> InsertItem(ItemModel ObjItem)
        {
            var response = new ResponseBase <bool>();
            var validate = ValidateMiddle.Result(ObjItem);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ITEMID");

                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Value          = ObjItem.OrdId;
                repository.Parameters.Add("P_PRODID", OracleDbType.Int64).Value         = ObjItem.ProdId;
                repository.Parameters.Add("P_PRODUCTNAME", OracleDbType.Varchar2).Value = ObjItem.ProductName;
                repository.Parameters.Add("P_PARTNUM", OracleDbType.Varchar2).Value     = ObjItem.PartNum;
                repository.Parameters.Add("P_PRICE", OracleDbType.Long).Value           = ObjItem.Price;
                repository.Parameters.Add("P_QUANTITY", OracleDbType.Int16).Value       = ObjItem.Quantity;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value       = ObjItem.IdEstado;
                repository.Parameters.Add("P_ITEMID", OracleDbType.Int64).Direction     = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ITEMS_INSERT");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Code = Status.Ok;
                    response.Data = true;
                }
                else
                {
                    response.Code    = repository.Status.Code;
                    response.Message = repository.Status.Message;
                    response.Data    = false;
                }
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(response);
        }
Example #28
0
        public async Task <ResponseBase <List <ItemModel> > > GetItemFromOrder(long IdOrder)
        {
            var response = new ResponseBase <List <ItemModel> >();

            if (IdOrder > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository();
                var ObjItem  = new ItemModel();
                var listItem = new List <ItemModel>();

                repository.Status.Code = Status.Ok;
                if (repository.Status.Code == Status.Ok)
                {
                    for (var item = 0; item < 50; ++item)
                    {
                        ObjItem        = new ItemModel();
                        ObjItem.ItemId = item;
                        ObjItem.OrdId  = IdOrder;

                        listItem.Add(ObjItem);
                    }
                    ;
                    response.Data = listItem;
                }
                else
                {
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field IdOrder is zero(0)";
            }

            return(await Task.Run(() => response));
        }
        private void ReplicateOracle_Click(object sender, EventArgs e)
        {
            var msSqlRepo = new MSSQLRepository();
            var oracleRepo = new OracleRepository();
            try
            {
                var productData = oracleRepo.GetOracleProductsData();
                msSqlRepo.FillOracleDataToMsSql(productData);

                MessageBox.Show("Oracle data replicated complete!");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oracle data replicated failed: " + ex.Message);
            }
        }