예제 #1
0
        private IEnumerable <GuoLuModel> GetGuoLuModelData(System.Data.Objects.IObjectSet <BaseInfo> base_data, IQueryable <Data1> data1_list)
        {
            var dbResult = (from bdata in base_data
                            join data1 in data1_list
                            on bdata.SheBei equals data1.SheBei
                            select new GuoLuModel
            {
                id = data1.id,
                Chang = bdata.Chang,
                DCWD07 = data1.DCWD07,
                DRWD08 = data1.DRWD08,
                YQHY20 = data1.YQHY20,
                ZQGD17 = data1.ZQGD17,
                ZQWD01 = data1.ZQWD01,
                ZQYL02 = data1.ZQYL02,
                ShiJian = data1.ShiJian,
                FSWD09 = data1.FSWD09,
                GBWD05 = data1.GBWD05,
                GFPL14 = data1.GFPL14,
                GouLu = data1.GuoLu,
                GSLL10 = data1.GSLL10,
                Nian = data1.Nian,
                PYWD03 = data1.PYWD03,
                Ri = data1.Ri,
                RQDH = data1.RQDH,
                RQLJ = data1.RQLJ,
                RYDH = data1.RYDH,
                RYLJ = data1.RYLJ,
                RYLL16 = data1.RYLL16,
                RYYL = data1.RYYL,
                SheBei = data1.SheBei,
                SLLJQ = data1.SLLJQ,
                SLLJY = data1.SLLJY,
                WKWD04 = data1.WKWD04,
                YDDH = data1.YDDH,
                YDLJ = data1.YDLJ,
                Yue = data1.Yue,
                Zhan = data1.Zhan,
                Max = bdata.Max ?? 0
            }).ToArray();


            var maxids = (from dl in dbResult
                          group dl by dl.GouLu
                          into dlg
                          select new
            {
                dlg.Key,
                maxid = dlg.Max(g => g.id)
            });

            var allData = (from d in dbResult
                           from mi in maxids
                           where d.id == mi.maxid && d.GouLu.Equals(mi.Key)
                           select d);

            return(allData);
        }
예제 #2
0
        private IQueryable <ImportHcepPreviewRow> PreviewDataQuery(Guid id, ccEntities db, System.Data.Objects.IObjectSet <HomeCareEntitledPeriod> HomeCareEntitledPeriods, System.Data.Objects.IObjectSet <ImportHcep> ImportHceps)
        {
            var isAdmin = this.Permissions.User.RoleId == (int)FixedRoles.Admin;
            var q       = from i in ImportHceps
                          where i.ImportId == id
                          join c in db.Clients.Where(this.Permissions.ClientsFilter) on i.ClientId equals c.Id into cG
                          from c in cG.DefaultIfEmpty()
                          join ol in HomeCareEntitledPeriods on i.ClientId equals ol.ClientId into olg
                          join sol in ImportHceps.Where(f => f.ImportId == id) on i.ClientId equals sol.ClientId into solg
                          let lastReport = (from cr in db.ClientReports
                                            where cr.ClientId == c.Id
                                            join sr in db.SubReports on cr.SubReportId equals sr.Id
                                            join mr in db.MainReports.Where(MainReport.Submitted) on sr.MainReportId equals mr.Id
                                            where sr.AppBudgetService.Service.ReportingMethodId == (int)Service.ReportingMethods.Homecare ||
                                            sr.AppBudgetService.Service.ReportingMethodId == (int)Service.ReportingMethods.HomecareWeekly
                                            select mr).OrderByDescending(f => f.Start).FirstOrDefault()
                                           let max = lastReport != null ? (DateTime?)lastReport.End : (DateTime?)null
                                                     let firstApprove = (from h in db.Histories
                                                                         where h.ReferenceId == c.Id && h.TableName == "Clients" && h.FieldName == "ApprovalStatusId"
                                                                         where h.NewValue == "2" || h.NewValue == "2048"
                                                                         select h).OrderBy(f => f.UpdateDate).OrderBy(f => f.UpdateDate).FirstOrDefault()
                                                                        select new ImportHcepPreviewRow
            {
                RowIndex   = i.RowIndex,
                ClientId   = i.ClientId,
                ClientName = c.FirstName + " " + c.LastName,
                StartDate  = i.StartDate,
                EndDate    = System.Data.Objects.EntityFunctions.AddDays(i.EndDate, -1),
                Errors     = new List <string>
                {
                    (c == null? "Invalid CC_ID":null),
                    (i.ClientId == null?"CC_ID is required":null),
                    (i.StartDate == null?"START_DATE is required":null),
                    (i.EndDate < i.StartDate?"END_DATE must be greater than START_DATE":null),
                    (olg.Any(ol => ol.Id != i.Id && (ol.EndDate == null && i.EndDate == null || ol.EndDate == null && i.EndDate > ol.StartDate || (i.StartDate < ol.EndDate) && (i.EndDate == null || (ol.StartDate < i.EndDate))))?
                     "There is an overlapping or duplicate period in the system":null),
                    (solg.Any(ol => ol.Id != i.Id && (ol.EndDate == null && i.EndDate == null || ol.EndDate == null && i.EndDate > ol.StartDate || (i.StartDate < ol.EndDate) && (i.EndDate == null || (ol.StartDate < i.EndDate))))?
                     "There is an overlapping or duplicate period in the same file": null),
                    ((!isAdmin && (i.StartDate < max || i.EndDate < max)) ?
                     "Start Date cannot be within an already submitted Financial Report period": null),
                    (!isAdmin && (!(c.HomeCareEntitledPeriods.Any() && (c.ApprovalStatusId == (int)ApprovalStatusEnum.Approved || c.ApprovalStatusId == (int)ApprovalStatusEnum.ResearchinProgresswithProof) &&
                                    firstApprove != null && i.StartDate >= firstApprove.UpdateDate))
                                                                        ? "You are not allowed to add eligibility for this client on this period" : null)
                }.Where(f => f != null)
            };

            return(q);
        }
예제 #3
0
 public TestTaskModelContainer(System.Data.Objects.IObjectSet<GetItDone.Task> tasks)
 {
     _Tasks = tasks;
 }