コード例 #1
0
        public override IResult <T> Execute(IContext dataContext)
        {
            var query = dataContext.AsQueryable <T>();

            if (IncludeQuery != null)
            {
                query = IncludeQuery.Include(query);
            }
            foreach (var queryFilter in QueryFilters)
            {
                query = queryFilter.Filter(query);
            }

            var data = Filter != null
                ? query.FirstOrDefault(Filter) : query.FirstOrDefault();

            if (data == null)
            {
                return(new Result <T>(
                           //errorCode: ValidationCodes.Common.Cmn021,
                           entityName: typeof(T).Name.SplitCamelCase()));
            }

            return(new Result <T>(data));
        }
コード例 #2
0
        public IEnumerable <IResource> CollectIncluded(Building building, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("country") && building.Country != null)
            {
                included.Add(_mapper.Map <CountryDto>(building.Country));
            }
            if (includeQuery.Contains("language") && building.Language != null)
            {
                included.Add(_mapper.Map <LanguageDto>(building.Language));
            }
            if (includeQuery.Contains("honorific-prefix") && building.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(building.HonorificPrefix));
            }
            if (includeQuery.Contains("customer") && building.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(building.Customer));
            }

            // many-relations
            if (includeQuery.Contains("telephones") && building.Telephones.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <TelephoneDto> >(building.Telephones));
            }

            return(included);
        }
コード例 #3
0
        public IEnumerable <IResource> CollectIncluded(Customer customer, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("country") && customer.Country != null)
            {
                included.Add(_mapper.Map <CountryDto>(customer.Country));
            }
            if (includeQuery.Contains("language") && customer.Language != null)
            {
                included.Add(_mapper.Map <LanguageDto>(customer.Language));
            }
            if (includeQuery.Contains("honorific-prefix") && customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(customer.HonorificPrefix));
            }

            // many-relations
            if (includeQuery.Contains("contacts") && customer.Contacts.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <ContactDto> >(customer.Contacts));
            }
            if (includeQuery.Contains("buildings") && customer.Buildings.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <BuildingDto> >(customer.Buildings));
            }
            if (includeQuery.Contains("tags") && customer.Tags.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <TagDto> >(customer.Tags));
            }

            return(included);
        }
コード例 #4
0
        public IEnumerable <IResource> CollectIncluded(Telephone telephone, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            if (includeQuery.Contains("country") && telephone.Country != null)
            {
                included.Add(_mapper.Map <CountryDto>(telephone.Country));
            }
            if (includeQuery.Contains("telephone-type") && telephone.TelephoneType != null)
            {
                included.Add(_mapper.Map <TelephoneTypeDto>(telephone.TelephoneType));
            }
            if (includeQuery.Contains("customer") && telephone.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(telephone.Customer));
            }
            if (includeQuery.Contains("contact") && telephone.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(telephone.Contact));
            }
            if (includeQuery.Contains("builidng") && telephone.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(telephone.Building));
            }

            return(included);
        }
コード例 #5
0
        public IEnumerable <IResource> CollectIncluded(Customer customer, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("country") && customer.Country != null)
            {
                included.Add(_mapper.Map <CountryDto>(customer.Country));
            }
            if (includeQuery.Contains("language") && customer.Language != null)
            {
                included.Add(_mapper.Map <LanguageDto>(customer.Language));
            }
            if (includeQuery.Contains("honorific-prefix") && customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(customer.HonorificPrefix));
            }

            // many-relations
            if (includeQuery.Contains("contacts") && customer.Contacts.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <ContactDto> >(customer.Contacts));
            }
            if (includeQuery.Contains("buildings") && customer.Buildings.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <BuildingDto> >(customer.Buildings));
            }
            if (includeQuery.Contains("telephones") && customer.Telephones.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <TelephoneDto> >(customer.Telephones));
            }
            if (includeQuery.Contains("requests") && customer.Requests.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <RequestDto> >(customer.Requests));
            }
            if (includeQuery.Contains("offers") && customer.Offers.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <OfferDto> >(customer.Offers));
            }
            if (includeQuery.Contains("orders") && customer.Orders.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <OrderDto> >(customer.Orders));
            }
            if (includeQuery.Contains("deposit-invoices") && customer.DepositInvoices.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <DepositInvoiceDto> >(customer.DepositInvoices));
            }
            if (includeQuery.Contains("invoices") && customer.Invoices.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <InvoiceDto> >(customer.Invoices));
            }
            if (includeQuery.Contains("tags") && customer.Tags.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <TagDto> >(customer.Tags));
            }

            return(included);
        }
コード例 #6
0
        private void FillSubjectOptions()
        {
            if (!Sems.ValidateControlContent())
            {
                return;
            }

            #region 讀取修課記錄,並群組出科目項目。
            string                       examid        = ExamId;
            List <string>                studentIDs    = Students.ToKeys();
            Dictionary <string, int>     subjectCount  = new Dictionary <string, int>();
            Dictionary <string, decimal> subjectWeight = new Dictionary <string, decimal>();

            foreach (JHSCAttendRecord record in SCAttends.Values)
            {
                JHCourseRecord course = Courses[record.RefCourseID];

                if (!IncludeQuery.Contains(course.RefAssessmentSetupID, examid))
                {
                    continue;
                }

                string subject = course.Subject.Trim();

                //course.RefAssessmentSetupID
                //JHAssessmentSetup.SelectByID("").ID
                //JHAEInclude.SelectByAssessmentSetupID("")[0].ExamName

                //隨機取得一個課程的 Credit 當作是 Subject 的比重。
                if (!subjectWeight.ContainsKey(subject))
                {
                    subjectWeight.Add(subject, 0);
                    subjectWeight[subject] = course.Credit.HasValue ? course.Credit.Value : 0;
                }

                //計算科目的修習人數。
                if (!subjectCount.ContainsKey(subject))
                {
                    subjectCount.Add(subject, 0);
                }
                subjectCount[subject]++;
            }

            List <string> subjects = new List <string>(subjectCount.Keys);
            subjects.Sort(new Comparison <string>(SubjectSorter.Sort));

            dgv.SuspendLayout();
            dgv.Rows.Clear();
            foreach (string eachSubj in subjects)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv, false, subjectWeight[eachSubj], eachSubj, subjectCount[eachSubj]);
                dgv.Rows.Add(row);
            }
            dgv.ResumeLayout();
            #endregion
        }
コード例 #7
0
        public IEnumerable <IResource> CollectIncluded(Invoice invoice, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery     = includeQuery.NestedInclude("customer");
            var workingHoursIncludeQuery = includeQuery.NestedInclude("working-hours");

            // one-relations
            if (includeQuery.Contains("order") && invoice.Order != null)
            {
                included.Add(_mapper.Map <OrderDto>(invoice.Order));
            }
            if (includeQuery.Contains("customer") && invoice.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(invoice.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && invoice.Customer != null && invoice.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(invoice.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && invoice.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(invoice.Contact));
            }
            if (includeQuery.Contains("building") && invoice.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(invoice.Building));
            }
            if (includeQuery.Contains("vat-rate") && invoice.VatRate != null)
            {
                included.Add(_mapper.Map <VatRateDto>(invoice.VatRate));
            }

            // many-relations
            if (includeQuery.Contains("supplements") && invoice.Supplements.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <InvoiceSupplementDto> >(invoice.Supplements));
            }
            if (includeQuery.Contains("deposits") && invoice.Deposits.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <DepositDto> >(invoice.Deposits));
            }
            if (includeQuery.Contains("deposit-invoices") && invoice.DepositInvoices.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <DepositInvoiceDto> >(invoice.DepositInvoices));
            }
            if (includeQuery.Contains("working-hours") && invoice.WorkingHours.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <WorkingHourDto> >(invoice.WorkingHours, opt => opt.Items["include"] = workingHoursIncludeQuery));
            }
            if (includeQuery.Contains("working-hours.employee") && invoice.WorkingHours.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <EmployeeDto> >(invoice.WorkingHours.Select(x => x.Employee).Where(x => x != null)));
            }

            return(included);
        }
コード例 #8
0
        public IncludeQuery <Book, Person> WithObjectAsPreviousProperty()
        {
            var pathMap = new Dictionary <IIncludeQuery, string>();
            var query   = new IncludeQuery <Book, Person>(pathMap);

            pathMap[query] = nameof(Book.Author);

            return(query);
        }
コード例 #9
0
        public IncludeQuery <Person, List <Person> > WithCollectionAsPreviousProperty()
        {
            var pathMap = new Dictionary <IIncludeQuery, string>();
            var query   = new IncludeQuery <Person, List <Person> >(pathMap);

            pathMap[query] = nameof(Person.Friends);

            return(query);
        }
コード例 #10
0
        public IEnumerable <IResource> CollectIncluded(Order order, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery = includeQuery.NestedInclude("customer");

            // one-relations
            if (includeQuery.Contains("offer") && order.Offer != null)
            {
                included.Add(_mapper.Map <OfferDto>(order.Offer));
            }
            if (includeQuery.Contains("invoice") && order.Invoice != null)
            {
                included.Add(_mapper.Map <InvoiceDto>(order.Invoice));
            }
            if (includeQuery.Contains("customer") && order.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(order.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && order.Customer != null && order.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(order.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && order.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(order.Contact));
            }
            if (includeQuery.Contains("building") && order.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(order.Building));
            }
            if (includeQuery.Contains("vat-rate") && order.VatRate != null)
            {
                included.Add(_mapper.Map <VatRateDto>(order.VatRate));
            }

            // many-relations
            if (includeQuery.Contains("deposits") && order.Deposits.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <DepositDto> >(order.Deposits));
            }
            if (includeQuery.Contains("deposit-invoices") && order.DepositInvoices.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <DepositInvoiceDto> >(order.DepositInvoices));
            }
            if (includeQuery.Contains("interventions") && order.Interventions.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <InterventionDto> >(order.Interventions));
            }
            if (includeQuery.Contains("technicians") && order.Technicians.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <EmployeeDto> >(order.Technicians));
            }

            return(included);
        }
コード例 #11
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <Tag> tags, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var tag in tags)
            {
                included.UnionWith(CollectIncluded(tag, includeQuery));
            }

            return(included);
        }
コード例 #12
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <Order> orders, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var order in orders)
            {
                included.UnionWith(CollectIncluded(order, includeQuery));
            }

            return(included);
        }
コード例 #13
0
        public static IIncludeQuery <TEntity, TNewProperty> Include <TEntity, TPreviousProperty, TNewProperty>(
            this IIncludeQuery <TEntity, TPreviousProperty> query,
            Expression <Func <TEntity, TNewProperty> > selector)
        {
            query.Visitor.Visit(selector);

            var includeQuery = new IncludeQuery <TEntity, TNewProperty>(query.PathMap);

            query.PathMap[includeQuery] = query.Visitor.Path;

            return(includeQuery);
        }
コード例 #14
0
        public IEnumerable <IResource> CollectIncluded(Offer offer, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery = includeQuery.NestedInclude("customer");
            var requestIncludeQuery  = includeQuery.NestedInclude("request");

            // one-relations
            if (includeQuery.Contains("order") && offer.Order != null)
            {
                included.Add(_mapper.Map <OrderDto>(offer.Order));
            }
            if (includeQuery.Contains("customer") && offer.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(offer.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && offer.Customer != null && offer.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(offer.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && offer.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(offer.Contact));
            }
            if (includeQuery.Contains("building") && offer.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(offer.Building));
            }
            if (includeQuery.Contains("vat-rate") && offer.VatRate != null)
            {
                included.Add(_mapper.Map <VatRateDto>(offer.VatRate));
            }
            if (includeQuery.Contains("submission-type") && offer.SubmissionType != null)
            {
                included.Add(_mapper.Map <SubmissionTypeDto>(offer.SubmissionType));
            }
            if (includeQuery.Contains("request") && offer.Request != null)
            {
                included.Add(_mapper.Map <RequestDto>(offer.Request, opt => opt.Items["include"] = requestIncludeQuery));
            }
            if (includeQuery.Contains("request.calendar-event") && offer.Request != null && offer.Request.CalendarEvent != null)
            {
                included.Add(_mapper.Map <CalendarEventDto>(offer.Request.CalendarEvent));
            }

            // many-relations
            if (includeQuery.Contains("offerlines") && offer.Offerlines.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <OfferlineDto> >(offer.Offerlines));
            }

            return(included);
        }
コード例 #15
0
        public IEnumerable <IResource> CollectIncluded(Intervention intervention, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery = includeQuery.NestedInclude("customer");

            // one-relations
            if (includeQuery.Contains("customer") && intervention.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(intervention.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && intervention.Customer != null && intervention.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(intervention.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && intervention.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(intervention.Contact));
            }
            if (includeQuery.Contains("building") && intervention.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(intervention.Building));
            }
            if (includeQuery.Contains("way-of-entry") && intervention.WayOfEntry != null)
            {
                included.Add(_mapper.Map <WayOfEntryDto>(intervention.WayOfEntry));
            }
            if (includeQuery.Contains("invoice") && intervention.Invoice != null)
            {
                included.Add(_mapper.Map <InvoiceDto>(intervention.Invoice));
            }
            if (includeQuery.Contains("follow-up-request") && intervention.FollowUpRequest != null)
            {
                included.Add(_mapper.Map <RequestDto>(intervention.FollowUpRequest));
            }
            if (includeQuery.Contains("origin") && intervention.Origin != null)
            {
                included.Add(_mapper.Map <OrderDto>(intervention.Origin));
            }

            // many-relations
            if (includeQuery.Contains("technicians") && intervention.Technicians.Count() > 0)
            {
                included.UnionWith(_mapper.Map <IEnumerable <EmployeeDto> >(intervention.Technicians));
            }

            return(included);
        }
コード例 #16
0
        public IEnumerable <IResource> CollectIncluded(Offerline offerline, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("offer") && offerline.Offer != null)
            {
                included.Add(_mapper.Map <OfferDto>(offerline.Offer));
            }
            if (includeQuery.Contains("vat-rate") && offerline.VatRate != null)
            {
                included.Add(_mapper.Map <VatRateDto>(offerline.VatRate));
            }

            return(included);
        }
コード例 #17
0
        public IEnumerable <IResource> CollectIncluded(WorkingHour workingHour, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("employee") && workingHour.Employee != null)
            {
                included.Add(_mapper.Map <EmployeeDto>(workingHour.Employee));
            }
            if (includeQuery.Contains("invoice") && workingHour.Invoice != null)
            {
                included.Add(_mapper.Map <InvoiceDto>(workingHour.Invoice));
            }

            return(included);
        }
コード例 #18
0
        public IEnumerable <IResource> CollectIncluded(Offer offer, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery = includeQuery.NestedInclude("customer");
            var requestIncludeQuery  = includeQuery.NestedInclude("request");

            // one-relations
            if (includeQuery.Contains("order") && offer.Order != null)
            {
                included.Add(_mapper.Map <OrderDto>(offer.Order));
            }
            if (includeQuery.Contains("customer") && offer.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(offer.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && offer.Customer != null && offer.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(offer.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && offer.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(offer.Contact));
            }
            if (includeQuery.Contains("building") && offer.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(offer.Building));
            }
            if (includeQuery.Contains("vat-rate") && offer.VatRate != null)
            {
                included.Add(_mapper.Map <VatRateDto>(offer.VatRate));
            }
            if (includeQuery.Contains("request") && offer.Request != null)
            {
                included.Add(_mapper.Map <RequestDto>(offer.Request, opt => opt.Items["include"] = requestIncludeQuery));
            }
            return(included);
        }
コード例 #19
0
        public IEnumerable <IResource> CollectIncluded(Request request, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            var customerIncludeQuery = includeQuery.NestedInclude("customer");

            // one-relations
            if (includeQuery.Contains("customer") && request.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(request.Customer, opt => opt.Items["include"] = customerIncludeQuery));
            }
            if (includeQuery.Contains("customer.honorific-prefix") && request.Customer != null && request.Customer.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(request.Customer.HonorificPrefix));
            }
            if (includeQuery.Contains("contact") && request.Contact != null)
            {
                included.Add(_mapper.Map <ContactDto>(request.Contact));
            }
            if (includeQuery.Contains("building") && request.Building != null)
            {
                included.Add(_mapper.Map <BuildingDto>(request.Building));
            }
            if (includeQuery.Contains("way-of-entry") && request.WayOfEntry != null)
            {
                included.Add(_mapper.Map <WayOfEntryDto>(request.WayOfEntry));
            }
            if (includeQuery.Contains("calendar-event") && request.CalendarEvent != null)
            {
                included.Add(_mapper.Map <CalendarEventDto>(request.CalendarEvent));
            }
            if (includeQuery.Contains("offer") && request.Offer != null)
            {
                included.Add(_mapper.Map <OfferDto>(request.Offer));
            }

            return(included);
        }
コード例 #20
0
        public static IIncludeQuery <TEntity, TNewProperty> ThenInclude <TEntity, TPreviousProperty, TNewProperty>(
            this IIncludeQuery <TEntity, IEnumerable <TPreviousProperty> > query,
            Expression <Func <TPreviousProperty, TNewProperty> > selector)
        {
            query.Visitor.Visit(selector);

            // If the visitor did not generated a path, return a new IncludeQuery with an unmodified PathMap.
            if (string.IsNullOrEmpty(query.Visitor.Path))
            {
                return(new IncludeQuery <TEntity, TNewProperty>(query.PathMap));
            }

            var pathMap      = query.PathMap;
            var existingPath = pathMap[query];

            pathMap.Remove(query);

            var includeQuery = new IncludeQuery <TEntity, TNewProperty>(query.PathMap);

            pathMap[includeQuery] = $"{existingPath}.{query.Visitor.Path}";

            return(includeQuery);
        }
コード例 #21
0
        public IEnumerable <IResource> CollectIncluded(Contact contact, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("country") && contact.Country != null)
            {
                included.Add(_mapper.Map <CountryDto>(contact.Country));
            }
            if (includeQuery.Contains("language") && contact.Language != null)
            {
                included.Add(_mapper.Map <LanguageDto>(contact.Language));
            }
            if (includeQuery.Contains("honorific-prefix") && contact.HonorificPrefix != null)
            {
                included.Add(_mapper.Map <HonorificPrefixDto>(contact.HonorificPrefix));
            }
            if (includeQuery.Contains("customer") && contact.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(contact.Customer));
            }

            return(included);
        }
コード例 #22
0
        public IEnumerable <IResource> CollectIncluded(Deposit deposit, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("customer") && deposit.Customer != null)
            {
                included.Add(_mapper.Map <CustomerDto>(deposit.Customer));
            }
            if (includeQuery.Contains("order") && deposit.Order != null)
            {
                included.Add(_mapper.Map <OrderDto>(deposit.Order));
            }
            if (includeQuery.Contains("invoice") && deposit.Invoice != null)
            {
                included.Add(_mapper.Map <InvoiceDto>(deposit.Invoice));
            }
            if (includeQuery.Contains("payment") && deposit.Payment != null)
            {
                included.Add(_mapper.Map <PaymentDto>(deposit.Payment));
            }

            return(included);
        }
コード例 #23
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <DepositInvoice> depositInvoices, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var invoice in depositInvoices)
            {
                included.UnionWith(CollectIncluded(invoice, includeQuery));
            }

            return(included);
        }
コード例 #24
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <Offerline> offerlines, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var offer in offerlines)
            {
                included.UnionWith(CollectIncluded(offer, includeQuery));
            }

            return(included);
        }
コード例 #25
0
        public IEnumerable <IResource> CollectIncluded(Tag tag, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            return(included);
        }
コード例 #26
0
        private void FillItemOptions()
        {
            if (!Sems.ValidateControlContent())
            {
                return;
            }

            dgv.SuspendLayout();
            dgv.Rows.Clear();

            #region 讀取修課記錄,並群組出科目項目。
            string                       examid        = ExamId;
            List <string>                studentIDs    = Students.ToKeys();
            Dictionary <string, int>     subjectCount  = new Dictionary <string, int>();
            Dictionary <string, decimal> subjectWeight = new Dictionary <string, decimal>();

            foreach (JHSCAttendRecord record in SCAttends.Values)
            {
                JHCourseRecord course = Courses[record.RefCourseID];

                if (!IncludeQuery.Contains(course.RefAssessmentSetupID, examid))
                {
                    continue;
                }

                string subject = course.Subject.Trim();

                //隨機取得一個課程的 Credit 當作是 Subject 的比重。
                if (!subjectWeight.ContainsKey(subject))
                {
                    subjectWeight.Add(subject, 0);
                    subjectWeight[subject] = course.Credit.HasValue ? course.Credit.Value : 0;
                }

                //計算科目的修習人數。
                if (!subjectCount.ContainsKey(subject))
                {
                    subjectCount.Add(subject, 0);
                }
                subjectCount[subject]++;
            }

            List <string> subjects = new List <string>(subjectCount.Keys);
            subjects.Sort(new Comparison <string>(SubjectSorter.Sort));

            foreach (string eachSubj in subjects)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv, false, subjectWeight[eachSubj], eachSubj, subjectCount[eachSubj]);
                row.Tag = new ScoreItem(eachSubj, ScoreType.Subject);
                dgv.Rows.Add(row);
            }
            #endregion

            #region 列出領域名稱。
            foreach (string each in NameMapping.Keys)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv, false, 1, each);
                row.Cells[chScoreItem.Index].Style.ForeColor = Color.Blue;
                row.Tag = new ScoreItem(each, ScoreType.Domain);
                dgv.Rows.Add(row);
            }
            #endregion

            dgv.ResumeLayout();
        }
コード例 #27
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <InvoiceSupplement> invoiceSupplements, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var invoiceSupplement in invoiceSupplements)
            {
                included.UnionWith(CollectIncluded(invoiceSupplement, includeQuery));
            }

            return(included);
        }
コード例 #28
0
        public IEnumerable <IResource> CollectIncluded(InvoiceSupplement invoiceSupplement, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            // one-relations
            if (includeQuery.Contains("invoice") && invoiceSupplement.Invoice != null)
            {
                included.Add(_mapper.Map <InvoiceDto>(invoiceSupplement.Invoice));
            }

            return(included);
        }
コード例 #29
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <WorkingHour> workingHours, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var workingHour in workingHours)
            {
                included.UnionWith(CollectIncluded(workingHour, includeQuery));
            }

            return(included);
        }
コード例 #30
0
        public IEnumerable <IResource> CollectIncluded(IEnumerable <Request> requests, IncludeQuery includeQuery)
        {
            ISet <IResource> included = new HashSet <IResource>();

            foreach (var request in requests)
            {
                included.UnionWith(CollectIncluded(request, includeQuery));
            }

            return(included);
        }