예제 #1
0
        public List <ModelViewEvidence> GetLisEvidencetAll(string StatusVisitID, string ModuleID, string PriorityID, string StatusOrderID, string ServiceID, string OrderID, string Employee, string StartDate, string EndDate, string User)
        {
            var NegocioUser         = new BusinessUsers();
            var NegocioEmpleado     = new BusinessEmployee();
            var NegocioOrdenes      = new BusinessOrder();
            var NegocioEstatusOrden = new BusinessStatusCauseOrder();
            var NegocioGarantia     = new BusinessGuaranty();
            var NegocioModulosMabe  = new BusinessModuleService();
            var NegocioEvidencia    = new BusinessOrderEvidence();
            //var visitas = GetAll();
            var user         = new List <ModelViewUserList>();
            var estatusorden = NegocioEstatusOrden.GetAll();
            int profileuser  = NegocioUser.GetProfileByToken(User).ProfileID;
            var ordenes      = new List <EntityOrder>();
            var garantia     = new List <EntityGuaranty>();
            var modulos      = new List <EntityModuleService>();
            var estatus      = new List <EntityStatusOrder>();
            var empleado     = new List <EntityEmployee>();
            var visitas      = new List <ModelViewMonitorOrder>();

            user = NegocioUser.GetAll();

            if (StartDate != "" && EndDate != "")
            {
                DateTime inicio = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime fin    = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                //ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderExecuteDate >= inicio && p.OrderExecuteDate <= fin && p.FK_StatusSchemeID != 44).ToList();
                ordenes = NegocioOrdenes.GetByRange(inicio, fin).Where(p => p.FK_StatusSchemeID != 44).ToList();
                if (OrderID != "")
                {
                    ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderID.Contains(OrderID)).ToList();
                }
                if (profileuser == 7)
                {
                    ordenes = (from a in ordenes
                               join b in user on a.FK_ModuleID equals b.FK_ModuleID
                               where b.ProfileID == profileuser
                               select a).ToList();
                }
            }
            else
            {
                ordenes = NegocioOrdenes.GetAll();
            }

            if (StatusVisitID != "")
            {
                int[] nums = StatusVisitID.Split(',').Select(int.Parse).ToArray();
                visitas = GetAll().Where(p => nums.Contains(p.StatusVisitID.Value)).ToList();
            }
            else
            {
                visitas = GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());
            }



            if (Employee != "")
            {
                empleado = NegocioEmpleado.GetAll().Where(p => p.FirstName.ToLower().Contains(Employee.ToLower()) || p.LastName.ToLower().Contains(Employee.ToLower())).ToList();
            }
            else
            {
                empleado = NegocioEmpleado.GetAll();
            }


            if (ServiceID != "")
            {
                int[] nums = ServiceID.Split(',').Select(int.Parse).ToArray();
                garantia = NegocioGarantia.GetAll().Where(p => nums.Contains(p.PK_GuarantyID)).ToList();
            }
            else
            {
                garantia = NegocioGarantia.GetAll();
            }

            if (ModuleID != "")
            {
                int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray();
                modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList();
            }
            else
            {
                modulos = NegocioModulosMabe.GetAll();
            }
            if (StatusOrderID != "")
            {
                int[] nums = StatusOrderID.Split(',').Select(int.Parse).ToArray();
                estatus = NegocioEstatusOrden.GetAll().Where(p => nums.Contains(p.PK_StatusOrderID)).ToList();
            }
            else
            {
                estatus = NegocioEstatusOrden.GetAll();
            }


            var lt = (from a in visitas
                      join b in estatus on a.StatusOrderID equals b.PK_StatusOrderID
                      join c in ordenes on a.OrderID equals c.PK_OrderID
                      join d in empleado on c.TechnicalID equals d.EmployeeID
                      join e in garantia on c.FK_GuarantyID equals e.PK_GuarantyID
                      join f in modulos on c.FK_ModuleID equals f.ModuleID
                      select new ModelViewEvidence()
            {
                OrderID = c.OrderID,
                EmployeeName = d.FirstName + " " + d.LastName,
                Date = c.OrderExecuteDate.ToString("dd/MM/yyyy"),
                EvidenceBadUse = NegocioEvidencia.GetEvidence(a.VisitID, "BadUse").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceFinish = NegocioEvidencia.GetEvidence(a.VisitID, "Finish").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceNoSeriesNumber = NegocioEvidencia.GetEvidence(a.VisitID, "NoSeriesNumber").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidencePurchaseNote = NegocioEvidencia.GetEvidence(a.VisitID, "PurchaseNote").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList(),
                EvidenceStartODS = NegocioEvidencia.GetEvidence(a.VisitID, "StartODS").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).Take(3).ToList(),
                EvidenceSummary = NegocioEvidencia.GetEvidence(a.VisitID, "Summary").Select(p => new EvidenceOrder {
                    TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2)
                }).ToList()
                                  // NegocioEvidencia.GetEvidence
                                  //EvidenceBadUse = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "BadUse").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceFinish = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "Finish").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceNoSeriesNumber = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "NoSeriesNumber").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidencePurchaseNote = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "PurchaseNote").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList(),
                                  //EvidenceStartODS = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "StartODS").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).Take(3).ToList(),
                                  //EvidenceSummary = NegocioEvidencia.GetAll().Where(p => p.MonitorOrdersID == a.VisitID && p.TypeEvidence == "Summary").Select(p => new EvidenceOrder { TypeEvidence = p.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + p.URLEvidence.Substring(2) }).ToList()
            }).ToList();


            return(lt);
        }
예제 #2
0
        public List <ModelViewODS> GetListVisitAll(string StatusVisitID, string ModuleID, string PriorityID, string StatusOrderID, string ServiceID, string OrderID, string Employee, string StartDate, string EndDate, string User)
        {
            var NegocioUser           = new BusinessUsers();
            var NegocioEmpleado       = new BusinessEmployee();
            var NegocioOrdenes        = new BusinessOrder();
            var NegocioEstatusOrden   = new BusinessStatusCauseOrder();
            var NegocioGarantia       = new BusinessGuaranty();
            var NegocioModulosMabe    = new BusinessModuleService();
            var NegocioEvidencia      = new BusinessOrderEvidence();
            var NegocioCausaOrder     = new BusinessCauseOrder();
            var NegocioEstatusEsquema = new BusinessStatusScheme();
            var estatusorden          = NegocioEstatusOrden.GetAll();
            var causaOrder            = NegocioCausaOrder.GetAll();
            int profileuser           = NegocioUser.GetProfileByToken(User).ProfileID;
            var ModuleUser            = NegocioUser.GetProfileByToken(User).ModuleID;
            var ordenes = new List <EntityOrder>();

            var user                 = new List <ModelViewUserList>();
            var garantia             = new List <EntityGuaranty>();
            var modulos              = new List <EntityModuleService>();
            var estatus              = new List <EntityStatusOrder>();
            var empleado             = new List <EntityEmployee>();
            var visitas              = new List <ModelViewMonitorOrder>();
            List <ModelViewODS> list = new List <ModelViewODS>();


            user = NegocioUser.GetAll();


            if (StartDate != "" && EndDate != "")
            {
                DateTime inicio = DateTime.ParseExact(StartDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                DateTime fin    = DateTime.ParseExact(EndDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                ordenes = NegocioOrdenes.GetByRange(inicio, fin);

                if (OrderID != "")
                {
                    ordenes = ordenes.Where(p => p.OrderID.Contains(OrderID)).ToList();
                }
                if (profileuser == 7)
                {
                    ordenes = (from a in ordenes where a.FK_ModuleID == ModuleUser
                               select a).ToList();
                }

                //ordenes = NegocioOrdenes.GetAll().Where(p => p.OrderExecuteDate >= inicio && p.OrderExecuteDate <= fin).ToList();
                //if (OrderID != "")
                //{ ordenes = ordenes.Where(p => p.OrderID.Contains(OrderID)).ToList(); }
            }

            else
            {
                ordenes = NegocioOrdenes.GetAll();
            }

            if (StatusVisitID != "")
            {
                int[] nums = StatusVisitID.Split(',').Select(int.Parse).ToArray();
                visitas = GetAll().Where(p => nums.Contains(p.StatusVisitID.Value)).ToList();
            }
            else
            {
                visitas = GeListByOrder(ordenes.Select(p => p.PK_OrderID).ToList());
            }

            var ordenesFactura = (from a in ordenes
                                  join b in new BusinessInvoice().GetAll() on a.PK_OrderID equals b.FK_OrderID into total
                                  from p in total.DefaultIfEmpty()
                                  select new { a, Invoice = p == null ? "No" : "Si" }).ToList();
            var complete = (from a in ordenes
                            join b in visitas on a.PK_OrderID equals b.OrderID
                            join c  in ordenesFactura on a.PK_OrderID equals c.a.PK_OrderID
                            select new { a, b, c.Invoice }).ToList();

            if (Employee != "")
            {
                var fullEmployee = NegocioEmpleado.GetAll().Select(p => new { PK_EmployeeID = p.PK_EmployeeID, Name = p.FirstName.ToLower() + " " + p.LastName.ToLower() }).ToList();
                var EmployeeID   = fullEmployee.Where(p => p.Name.Contains(Employee.ToLower())).ToList();
                empleado = NegocioEmpleado.GetAll().Where(p => EmployeeID.Select(a => a.PK_EmployeeID).ToList <int>().Contains(p.PK_EmployeeID) && p.FK_UserID != null).ToList();
            }
            else
            {
                empleado = NegocioEmpleado.GetAll().Where(p => p.FK_UserID != null).ToList();
            }

            var completeEmpl = (from a in complete
                                join b in empleado
                                on a.a.FK_EmployeeID equals b.PK_EmployeeID
                                select new { a, b }).ToList();

            if (ServiceID != "")
            {
                int[] nums = ServiceID.Split(',').Select(int.Parse).ToArray();
                garantia = NegocioGarantia.GetAll().Where(p => nums.Contains(p.PK_GuarantyID)).ToList();
            }
            else
            {
                garantia = NegocioGarantia.GetAll();
            }

            var completeSer = (from a in completeEmpl
                               join b in garantia
                               on a.a.a.FK_GuarantyID equals b.PK_GuarantyID
                               select new { a, b }).ToList();

            if (ModuleID != "")
            {
                int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray();
                modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList();
            }
            else
            {
                modulos = NegocioModulosMabe.GetAll();
            }

            var completeMod = (from a in completeSer
                               join b in modulos
                               on a.a.a.a.FK_ModuleID equals b.ModuleID
                               select new { a, b }).ToList();

            if (StatusOrderID != "")
            {
                int[] nums = StatusOrderID.Split(',').Select(int.Parse).ToArray();
                estatus = NegocioEstatusOrden.GetAll().Where(p => nums.Contains(p.PK_StatusOrderID)).ToList();
            }
            else
            {
                estatus = NegocioEstatusOrden.GetAll();
            }

            var completeEst = (from a in completeMod
                               join b in estatus
                               on a.a.a.a.b.StatusOrderID equals b.PK_StatusOrderID
                               select new { a, b }).ToList();

            //var ordenesemple = (from a in visitas
            //                    join b in estatus on a.StatusOrderID equals b.PK_StatusOrderID
            //                    join c in ordenes on a.OrderID equals c.PK_OrderID
            //                    join d in empleado on c.TechnicalID equals d.EmployeeID
            //                    select new
            //                    {
            //                        EmployeeID = d.PK_EmployeeID,
            //                        Status = b.StatusOrder1,
            //                        StatusID = a.StatusVisitID,
            //                        LatitudeAddress = a.LatitudeAddress ,
            //                        LogitudeAddress = a.LogitudeAddress,
            //                        LatitudeStartVisit = a.LatitudeStartVisit,
            //                        LogitudeStartVisit = a.LogitudeStartVisit,
            //                        LatitudeEndVisit = a.LatitudeEndVisit,
            //                        LogitudeEndVisit = a.LogitudeEndVisit,
            //                        OrderID = c.OrderID,
            //                        StarTime = a.StartVisitDate,
            //                        EndTime = a.EndVisitDate,
            //                        OrderExceute = c.OrderExecuteDate,
            //                        Secuence = a.SequenceVisit
            //                    });

            var completeEstEsq = (from a in completeEst
                                  join b in NegocioEstatusEsquema.GetAll()
                                  on a.a.a.a.a.a.FK_StatusSchemeID equals b.PK_StatusSchemeID
                                  select new { a, b }).ToList();


            var lt = completeEstEsq.Select(p => new ModelViewODS()
            {
                MonitorID          = p.a.a.a.a.a.b.VisitID,
                ModuleID           = p.a.a.b.ModuleID,
                StatusVisitID      = p.a.a.a.a.a.b.StatusVisitID.Value,
                Module             = p.a.a.b.ID + " - " + p.a.a.b.Base,
                StatusOrderID      = p.a.b.PK_StatusOrderID,
                StatusODS          = p.a.b.StatusOrder1,
                CauseOrder         = p.b.Description,
                OrderID            = p.a.a.a.a.a.a.PreOrder == false ? p.a.a.a.a.a.a.OrderID : "PreOrden",
                EmployeeName       = p.a.a.a.a.b.FirstName + " " + p.a.a.a.a.b.LastName,
                ServiceType        = p.a.a.a.b.GuarantyID + " " + p.a.a.a.b.Guaranty1,
                StartVisitODS      = p.a.a.a.a.a.b.StartVisitDate.ToString(),
                StartTryODS        = p.a.a.a.a.a.b.StartServiceDate.ToString(),
                StartRunODS        = p.a.a.a.a.a.b.StartOrderDate.ToString(),
                EndVisitODS        = p.a.a.a.a.a.b.EndVisitDate.ToString(),
                EndTryODS          = p.a.a.a.a.a.b.EndServiceDate.ToString(),
                EndRunODS          = p.a.a.a.a.a.b.EndOrderDate.ToString(),
                LatitudeStartVisit = p.a.a.a.a.a.b.LatitudeStartVisit.ToString(),
                LogitudeStartVisit = p.a.a.a.a.a.b.LogitudeStartVisit.ToString(),
                LatitudeEndVisit   = p.a.a.a.a.a.b.LatitudeEndVisit.ToString(),
                LogitudeEndVisit   = p.a.a.a.a.a.b.LogitudeEndVisit.ToString(),
                LatitudeStartOrder = p.a.a.a.a.a.b.LatitudeStartOrder.ToString(),
                LogitudeStartOrder = p.a.a.a.a.a.b.LogitudeStartOrder.ToString(),
                LatitudeEndOrder   = p.a.a.a.a.a.b.LatitudeEndOrder.ToString(),
                LogitudeEndOrder   = p.a.a.a.a.a.b.LogitudeEndOrder.ToString(),
                DurationVisit      = p.a.a.a.a.a.b.DurationVisit.ToString(),
                DurationExecute    = p.a.a.a.a.a.b.DurationExecute.ToString(),
                Notes            = p.a.a.a.a.a.b.NoteOrder,
                URL              = p.a.a.a.a.a.a.URLPreOrder,
                SendCRM          = p.a.a.a.a.a.a.SendCRM,
                OrderExecuteDate = p.a.a.a.a.a.a.OrderExecuteDate,
                Invoice          = p.a.a.a.a.a.Invoice,
                Evidence         = NegocioEvidencia.GetEvidence(p.a.a.a.a.a.b.VisitID, "StartODS").Select(c => new EvidenceOrder
                {
                    TypeEvidence = c.TypeEvidence, URLEvidence = GlobalConfiguration.urlRequest + c.URLEvidence.Substring(2)
                }).Take(3).ToList(),
                // Address = ordenesemple.Where(a => a.EmployeeID == p.a.a.a.a.b.PK_EmployeeID && a.OrderExceute.Date == p.a.a.a.a.a.a.OrderExecuteDate.Date).Select(b => new AddressV
                // {
                //     StatusOrderID = b.StatusID.Value,
                //     LatitudeStartVisit = b.LatitudeStartVisit,
                //     LogitudeStartVisit = b.LogitudeStartVisit,
                //     LatitudeEndVisit = b.LatitudeEndVisit,
                //     LogitudeEndVisit = b.LogitudeEndVisit,
                //     LatitudeAddress = b.LatitudeAddress,
                //     LogitudeAddress = b.LogitudeAddress,
                //     Status = b.Status,
                //     OrderID = b.OrderID,
                //     StarTime = b.StarTime.ToString(),
                //     EndTime = b.EndTime.ToString(),
                //     Secuence = b.Secuence.HasValue ? b.Secuence.Value : 0,
                //}).ToList()
            }).OrderByDescending(p => p.OrderExecuteDate).ToList();

            return(lt);
        }