Exemplo n.º 1
0
        public static List <OrderSearchEntity> SearchOrder(IQueryable <OrderSearchEntity> billData, IEnumerable <IFilterDescriptor> billFilters, IEnumerable <IFilterDescriptor> detailsFilters, int pageIndex, int pageSize, ref int totalCount)
        {
            var lp = _query.LinqOP;
            var orderDetailsContext = lp.GetDataContext <BillOrderDetails>();
            var brands   = VMGlobal.PoweredBrands;
            var brandIDs = brands.Select(b => b.ID);

            billData = billData.Where(o => brandIDs.Contains(o.BrandID));
            if (FilterConditionHelper.IsConditionSetted(detailsFilters, "StyleCode"))
            {
                var productContext = lp.GetDataContext <ViewProduct>();
                var pdata          = from p in productContext
                                     where brandIDs.Contains(p.BrandID)
                                     select new { ProductID = p.ProductID, StyleCode = p.StyleCode };
                IEnumerable <int> pIDs = ((IQueryable <dynamic>)pdata.Where(detailsFilters)).ToList().Select(p => (int)p.ProductID);
                if (pIDs.Count() == 0)
                {
                    return(null);
                }
                else
                {
                    billData = from d in billData
                               where orderDetailsContext.Any(od => od.BillID == d.BillID && pIDs.Contains(od.ProductID))
                               select d;
                }
            }
            var filtedData = (IQueryable <OrderSearchEntity>)billData.Where(billFilters);

            totalCount = filtedData.Count();
            //var datas = new QueryableCollectionView(filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList()); //filtedData.ToList();
            var orders = filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList();//(List<OrderSearchEntity>)datas.SourceCollection;
            var bIDs   = orders.Select(o => (int)o.BillID);
            var sum    = orderDetailsContext.Where(o => bIDs.Contains(o.BillID) && o.IsDeleted == false).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, OrderQuantity = g.Sum(o => o.Quantity), CancelQuantity = g.Sum(o => o.QuaCancel), DeliveredQuantity = g.Sum(o => o.QuaDelivered) }).ToList();

            orders.ForEach(d =>
            {
                d.BrandName = brands.Find(o => d.BrandID == o.ID).Name;
                var order   = sum.Find(o => o.BillID == d.BillID);
                if (order != null)
                {
                    d.订货数量 = order.OrderQuantity;
                    d.取消量  = order.CancelQuantity;
                    d.已发数量 = order.DeliveredQuantity;
                    var realOrderQuantity = d.订货数量 - d.取消量;
                    d.发货状态 = realOrderQuantity == d.已发数量 ? "已完成" : (d.已发数量 == 0 ? "未发货" : (realOrderQuantity > d.已发数量 ? "部分已发货" : "数据有误"));
                }
            });
            return(orders);
        }
Exemplo n.º 2
0
        private void ValidatePlanName(PlanDTO plan, ICrateStorage crateStorage)
        {
            var configurationControls = crateStorage
                                        .CrateContentsOfType <StandardConfigurationControlsCM>()
                                        .SingleOrDefault();

            var actionUi = new ActivityUi();

            actionUi.ClonePropertiesFrom(configurationControls);

            var criteria = JsonConvert.DeserializeObject <List <FilterConditionDTO> >(
                actionUi.QueryBuilder.Value
                );

            Assert.AreEqual(plan.Name.Trim().ToLower(), FilterConditionHelper.ParseConditionToText(criteria).Trim().ToLower());
        }
        private List <BillSubcontractSearchEntity> SearchSubcontract(IQueryable <BillSubcontractSearchEntity> billData)
        {
            var lp             = VMGlobal.ManufacturingQuery.LinqOP;
            var detailsContext = lp.GetDataContext <BillSubcontractDetails>();
            var brands         = VMGlobal.PoweredBrands;
            var brandIDs       = brands.Select(b => b.ID);

            billData = billData.Where(o => brandIDs.Contains(o.BrandID));
            if (FilterConditionHelper.IsConditionSetted(DetailsDescriptors, "StyleCode") || FilterConditionHelper.IsConditionSetted(DetailsDescriptors, "DeliveryDate"))
            {
                var productContext = lp.GetDataContext <ViewProduct>();
                var detailFilter   = from detail in detailsContext
                                     from p in productContext
                                     where detail.ProductID == p.ProductID && brandIDs.Contains(p.BrandID)
                                     select new DetailsFiltetEntity {
                    ProductID = p.ProductID, StyleCode = p.StyleCode, DeliveryDate = detail.DeliveryDate
                };
                detailFilter = (IQueryable <DetailsFiltetEntity>)detailFilter.Where(DetailsDescriptors);
                var pIDs = detailFilter.ToList().Select(p => p.ProductID);
                if (pIDs.Count() == 0)
                {
                    return(null);
                }
                billData = from d in billData
                           where detailsContext.Any(od => od.BillID == d.ID && pIDs.Contains(od.ProductID))
                           select d;
            }
            var filtedData = (IQueryable <BillSubcontractSearchEntity>)billData.Where(FilterDescriptors);

            TotalCount = filtedData.Count();
            //var datas = new QueryableCollectionView(filtedData.OrderBy(o => o.BillID).Skip(pageIndex * pageSize).Take(pageSize).ToList()); //filtedData.ToList();
            var subcontracts = filtedData.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).ToList();//(List<OrderSearchEntity>)datas.SourceCollection;
            var bIDs         = subcontracts.Select(o => (int)o.ID);
            var sum          = detailsContext.Where(o => bIDs.Contains(o.BillID) && o.IsDeleted == false).GroupBy(o => o.BillID).Select(g => new { BillID = g.Key, Quantity = g.Sum(o => o.Quantity), QuaCancel = g.Sum(o => o.QuaCancel), QuaCompleted = g.Sum(o => o.QuaCompleted) }).ToList();

            subcontracts.ForEach(d =>
            {
                d.BrandName           = brands.Find(o => d.BrandID == o.ID).Name;
                var subcontract       = sum.Find(o => o.BillID == d.ID);
                d.Quantity            = subcontract.Quantity;
                d.QuaCancel           = subcontract.QuaCancel;
                d.QuaCompleted        = subcontract.QuaCompleted;
                var realOrderQuantity = d.Quantity - d.QuaCancel;
                d.StatusName          = realOrderQuantity == d.QuaCompleted ? "已完成" : (d.QuaCompleted == 0 ? "未交货" : (realOrderQuantity > d.QuaCompleted ? "部分已交货" : "数据有误"));
            });
            return(subcontracts);
        }
Exemplo n.º 4
0
        public override async Task Run()
        {
            var salesforceObject = ActivityUI.SalesforceObjectSelector.selectedKey;

            if (string.IsNullOrEmpty(salesforceObject))
            {
                throw new ActivityExecutionException(
                          "No Salesforce object is selected",
                          ActivityErrorCode.DESIGN_TIME_DATA_MISSING);
            }
            var salesforceObjectFields = Storage
                                         .FirstCrate <FieldDescriptionsCM>(x => x.Label == QueryFilterCrateLabel)
                                         .Content
                                         .Fields;

            var filterValue   = ActivityUI.SalesforceObjectFilter.Value;
            var filterDataDTO = JsonConvert.DeserializeObject <List <FilterConditionDTO> >(filterValue);
            //If without filter, just get all selected objects
            //else prepare SOQL query to filter the objects based on the filter conditions
            var parsedCondition = string.Empty;

            if (filterDataDTO.Count > 0)
            {
                parsedCondition = FilterConditionHelper.ParseConditionToText(filterDataDTO);
            }

            var resultObjects = await _salesforceManager
                                .Query(
                salesforceObject.ToEnum <SalesforceObjectType>(),
                salesforceObjectFields,
                parsedCondition,
                AuthorizationToken
                );

            Payload.Add(
                Crate <StandardTableDataCM>
                .FromContent(
                    RuntimeDataCrateLabel,
                    resultObjects
                    )
                );
        }
Exemplo n.º 5
0
 public static IEnumerable <int> GetProductIDArrayWithCondition(IEnumerable <IFilterDescriptor> filterDescriptors, IEnumerable <int> brandIDs = null)
 {
     if (FilterConditionHelper.IsConditionSetted(filterDescriptors, "StyleCode"))
     {
         if (brandIDs == null)
         {
             brandIDs = VMGlobal.PoweredBrands.Select(b => b.ID);
         }
         var productContext = VMGlobal.SysProcessQuery.LinqOP.GetDataContext <ViewProduct>();
         var pdata          = from p in productContext
                              where brandIDs.Contains(p.BrandID)
                              select new { ProductID = p.ProductID, StyleCode = p.StyleCode };
         //注意IQueryable<dynamic>类型的对象调用Where(filters)将产生0<>0的恒假条件
         IEnumerable <int> pIDs = ((IQueryable <dynamic>)pdata.Where(filterDescriptors)).ToList().Select(p => (int)p.ProductID);
         //if (pIDs.Count() == 0)
         //    return null;
         return(pIDs);
     }
     return(null);
 }
Exemplo n.º 6
0
        protected override IEnumerable <VIPCard> SearchData()
        {
            List <VIPCardBO> vips = null;

            if (!FilterConditionHelper.IsConditionSetted(FilterDescriptors, "KindID"))
            {
                vips = base.SearchData().Select(o => new VIPCardBO(o)).ToList();
            }
            else
            {
                var cards = LinqOP.GetDataContext <VIPCard>();
                var maps  = LinqOP.GetDataContext <VIPCardKindMapping>();
                var data  = from card in cards
                            from map in maps
                            where card.ID == map.CardID
                            select new VIPCardEntityForSearch
                {
                    Birthday     = card.Birthday,
                    Code         = card.Code,
                    CustomerName = card.CustomerName,
                    KindID       = map.KindID,
                    Sex          = card.Sex,
                    MobilePhone  = card.MobilePhone,
                    ID           = card.ID
                };
                var filteredData = (IQueryable <VIPCardEntityForSearch>)data.Where(FilterDescriptors);
                var vids         = filteredData.Select(o => o.ID).Distinct().ToArray();
                var result       = cards.Where(o => vids.Contains(o.ID));
                TotalCount = result.Count();
                vips       = result.OrderBy(o => o.ID).Skip(PageIndex * PageSize).Take(PageSize).Select(o => new VIPCardBO(o)).ToList();
            }
            VIPCardVM.ApplyVIPKind(vips);
            vips.ForEach(o =>
            {
                if (!DownHierarchyOrganizationIDArray.Contains(o.OrganizationID))
                {
                    o.MobilePhone = "不可见";
                }
            });
            return(vips);
        }
Exemplo n.º 7
0
        private async Task <PlanDTO> UpdatePlanName()
        {
            if (ConfigurationControls != null)
            {
                var actionUi = new ActivityUi();
                actionUi.ClonePropertiesFrom(ConfigurationControls);
                var criteria = JsonConvert.DeserializeObject <List <FilterConditionDTO> >(
                    actionUi.QueryBuilder.Value
                    );

                if (criteria.Count > 0)
                {
                    return(await _planService.UpdatePlanName(ActivityId, "Generate a DocuSign Report", FilterConditionHelper.ParseConditionToText(criteria)));
                }
            }

            return(null);
        }
        public override async Task Run()
        {
            var feedText = FeedText;

            if (IsPostingToQueryiedChatter)
            {
                try
                {
                    var chatters = await _salesforceManager.Query(SelectedChatter.ToEnum <SalesforceObjectType>(),
                                                                  new[] { new FieldDTO("Id") },
                                                                  FilterConditionHelper.ParseConditionToText(JsonConvert.DeserializeObject <List <FilterConditionDTO> >(ChatterFilter)),
                                                                  AuthorizationToken);

                    var tasks = new List <Task <string> >(chatters.Table.Count);
                    foreach (var chatterId in chatters.DataRows.Select(x => x.Row[0].Cell.Value))
                    {
                        Logger.Info($"Posting message to chatter id: {chatterId}");

                        tasks.Add(_salesforceManager.PostToChatter(StripHTML(feedText), chatterId, AuthorizationToken).ContinueWith(x =>
                        {
                            Logger.Info($"Posting message to chatter succeded with feedId: {x.Result}");
                            return(x.Result);
                        }));
                    }
                    await Task.WhenAll(tasks);

                    //If we did not find any chatter object we don't fail activity execution but rather returns empty list and inform caller about it
                    if (!chatters.HasDataRows)
                    {
                        Logger.Info("No salesforce objects were found to use as chatter id.");
                        Success($"No {SelectedChatter} that satisfies specified conditions were found. No message were posted");
                    }
                    else
                    {
                        var resultPayload = new StandardPayloadDataCM();
                        resultPayload.PayloadObjects.AddRange(tasks.Select(x => new PayloadObjectDTO(new KeyValueDTO(FeedIdKeyName, x.Result))));
                        Payload.Add(Crate <StandardPayloadDataCM> .FromContent(PostedFeedCrateLabel, resultPayload));
                    }
                }
                catch (Exception ex)
                {
                    RaiseError(ex.Message);
                    return;
                }
            }
            else
            {
                var incomingChatterId = IncomingChatterId;
                if (string.IsNullOrWhiteSpace(incomingChatterId))
                {
                    throw new ActivityExecutionException("Upstream crates doesn't contain value for feed parent Id");
                }

                Logger.Info($"Posting message to chatter id: {incomingChatterId}");

                var feedId = await _salesforceManager.PostToChatter(StripHTML(feedText), incomingChatterId, AuthorizationToken);

                Logger.Info($"Posting message to chatter succeded with feedId: {feedId}");

                Payload.Add(Crate.FromContent(PostedFeedCrateLabel, new StandardPayloadDataCM(new KeyValueDTO(FeedIdKeyName, feedId))));
            }
        }