public static List <T> .Node Sort(Sortable segs) => MrgAll(List <T> .Empty, segs.Segs.Value);
Exemple #2
0
        /// <inheritdoc />
        public async Task <PagingResult <BranchModel> > GetBranchesByCompany(int companyId, BranchFilter filter, Sortable sortable, Paginable paginable)
        {
            var company = await _companyRepository.GetAsync(companyId);

            if (company == null)
            {
                throw new KeyNotFoundException();
            }

            IQueryable <Branch> query = await _branchRepository.GetAsync(x => x.Company.Id == companyId);

            query = Filtering(filter, query);

            var queryableCount = query;
            int totalCount     = queryableCount.Count();

            query = Sorting(sortable, query);

            query = Pagination(paginable, query);

            var branches        = query.ToList();
            var branchModelList = new List <BranchModel>();

            var allUsersQuery = await _userRepository.GetAsync(x => !string.IsNullOrEmpty(x.Role)?x.Role.Trim().Equals(salesRoleId) : false);

            foreach (var branch in branches)
            {
                var branchModel = branch.Adapt <BranchModel>();

                branchModel.CountSalesRep = allUsersQuery.Where(x => x.BranchId == branch.Id)?.Count();

                branchModelList.Add(branchModel);
            }

            return(new PagingResult <BranchModel>
            {
                Total = totalCount,
                ItemsPerPage = paginable.Take ?? 0,
                Data = branchModelList
            });
        }
Exemple #3
0
    public int HasMission(int npcId)
    {
        if (-1 == npcId)
        {
            return(-1);
        }

        var list = new List <Sortable>();

        {
            // foreach(var pair in MissionData.Datas)
            var __enumerator1 = (MissionData.Datas).GetEnumerator();
            while (__enumerator1.MoveNext())
            {
                var pair = __enumerator1.Current;
                {
                    var missionId = pair.Key;
                    var tableData = Table.GetMissionBase(missionId);
                    if (null == tableData)
                    {
                        continue;
                    }

                    //任务状态
                    var state = (eMissionState)pair.Value.Exdata[0];
                    var type  = (eMissionMainType)tableData.ViewType;

                    var sort = new Sortable();
                    sort.id       = missionId;
                    sort.priority = 0;
                    if (tableData.FinishNpcId == npcId && eMissionState.Finished == state)
                    {
                        if (eMissionMainType.MainStoryLine == type)
                        {
                            sort.priority = 1;
                        }
                        else
                        {
                            sort.priority = 2;
                        }
                    }
                    else if (tableData.NpcStart == npcId && eMissionState.Acceptable == state)
                    {
                        if (eMissionMainType.MainStoryLine == type)
                        {
                            sort.priority = 3;
                        }
                        else
                        {
                            sort.priority = 4;
                        }
                    }

                    if (sort.priority <= 0)
                    {
                        continue;
                    }

                    list.Add(sort);
                }
            }
        }

        if (list.Count > 0)
        {
            list.Sort((a, b) => { return((a.priority < b.priority) ? -1 : 1); });
            return(list[0].id);
        }
        return(-1);
    }
        public static Sortable Add(T x, Sortable segs)
        {
            var xs = List <T> .Cons(x, List <T> .Empty);

            return(new Sortable(segs.Size + 1, new Lazy <List <List <T> .Node> .Node>(AddSeg(xs, segs.Segs.Value, segs.Size))));
        }
Exemple #5
0
        public void InboundPriceItemsList()
        {
            var items = new WcfPriceProcessItem[0];

#if !DEBUG
            RemoteServiceHelper.RemotingCall(s => {
                items = s.GetPriceItemList();
            });
#else
            items = new[] {
                new WcfPriceProcessItem(1, false, "jjj.AAA", 2983, null, DateTime.Now.AddMinutes(50), 0),
                new WcfPriceProcessItem(2, true, "jjj.123", 384, null, DateTime.Now.AddMinutes(10), 0),
                new WcfPriceProcessItem(3, false, "jjj.BBB", 0, null, DateTime.Now.AddMinutes(100), 0)
                {
                    FormalizedNow = true
                },
                new WcfPriceProcessItem(4, true, "jjj.789", 1264, null, DateTime.Now.AddMinutes(500), 0)
            };
#endif
            var codes      = items.Select(i => Convert.ToUInt32(i.PriceCode)).ToList();
            var prices     = DbSession.Query <Price>().Where(p => codes.Contains(p.Id)).ToList().ToDictionary(k => k.Id);
            var itemsCodes = items.Select(i => (uint)i.PriceItemId).ToList();
            var priceItems = DbSession.Query <PriceItem>().Where(i => itemsCodes.Contains(i.Id)).ToList().ToDictionary(k => k.Id);

#if DEBUG
            prices = new Dictionary <uint, Price>()
            {
                { 1u, new Price {
                      Supplier = new Supplier {
                          HomeRegion = new Region("test")
                      }
                  } }, { 4, new Price()
                         {
                             Supplier = new Supplier {
                                 HomeRegion = new Region("test2")
                             }
                         } }
            };
#endif

            var result = items.Select(i => {
                if (prices.Keys.Contains((uint)i.PriceCode))
                {
                    var price    = prices[(uint)i.PriceCode];
                    DateTime?log = null;
                    if (priceItems.Keys.Contains((uint)i.PriceItemId) && i.Downloaded)
                    {
                        var logs = priceItems[(uint)i.PriceItemId].DownloadLogs;
                        if (logs.Count > 0)
                        {
                            log = logs.Max(d => d.LogTime);
                        }
                    }
                    return(new InboundPriceItems(i.Downloaded, price, i.FilePath, log ?? (i.FileTime ?? i.CreateTime), i.HashCode, i.FormalizedNow));
                }
                return(null);
            }).Where(p => p != null).ToList();

            if (Directory.Exists(Config.ErrorFilesPath))
            {
                var errorsItems = Directory.GetFiles(Config.ErrorFilesPath).Select(f => new { name = Path.GetFileNameWithoutExtension(f), time = File.GetCreationTime(f), file = f, priceItemId = ParseId(Path.GetFileNameWithoutExtension(f)) });
                var itemIds     = errorsItems.Select(e => e.priceItemId).ToList();
                var errorPrices = DbSession.Query <Cost>().Where(p => itemIds.Contains(p.PriceItem.Id)).Select(p => p.Price).Distinct().ToList();
                result.AddRange(errorsItems.Select(e => {
                    var price = errorPrices.FirstOrDefault(p => p.Costs.Select(c => c.PriceItem.Id).Contains(e.priceItemId));
                    if (price != null)
                    {
                        return new InboundPriceItems(false, price, e.file, e.time, 0, false)
                        {
                            Error = true
                        }
                    }
                    ;
                    return(null);
                }));
            }

            result = result.Where(r => r != null).ToList();

            var sortable = new Sortable();
            BindObjectInstance(sortable, "filter");

            var sortBy    = sortable.SortBy;
            var direction = sortable.SortDirection == "asc" ? "ascending" : "descending";
            if (string.IsNullOrEmpty(sortable.SortDirection))
            {
                direction = "ascending";
            }
            var retranse = result.Where(r => !r.Downloaded).Sort(ref sortBy, ref direction, "PriceTime").ToList();
            var form     = result.Where(r => r.Downloaded).Sort(ref sortBy, ref direction, "PriceTime").ToList();
            form.AddRange(retranse);
            form = form.OrderBy(f => f.Error).ToList();

            PropertyBag["items"]  = form.ToList();
            PropertyBag["filter"] = sortable;
        }
 public void SetUp()
 {
     Sortable = new Sortable(driver);
     HomePage.OpenSection("Sortable");
 }
Exemple #7
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            var autoBind = DataSource.Type != DataSourceType.Server && AutoBind.GetValueOrDefault(true);

            var columns = VisibleColumns.Select(c => c.ToJson());

            var idPrefix = "#";

            if (IsInClientTemplate)
            {
                idPrefix = "\\" + idPrefix;
            }

            if (columns.Any())
            {
                options["columns"] = columns;
            }

            if (Grouping.Enabled)
            {
                options["groupable"] = Grouping.ToJson();
            }

            if (Pageable.Enabled)
            {
                Pageable.AutoBind = autoBind;

                options["pageable"] = Pageable.ToJson();
            }

            if (Sortable.Enabled)
            {
                var sorting = Sortable.ToJson();
                options["sortable"] = sorting.Any() ? (object)sorting : true;
            }

            if (Selectable.Enabled)
            {
                options["selectable"] = String.Format("{0}, {1}", Selectable.Mode, Selectable.Type);
            }

            if (Filterable.Enabled)
            {
                var filtering = Filterable.ToJson();
                options["filterable"] = filtering.Any() ? (object)filtering : true;
            }

            if (ColumnMenu.Enabled)
            {
                var menu = ColumnMenu.ToJson();
                options["columnMenu"] = menu.Any() ? (object)menu : true;
            }

            if (Resizable.Enabled)
            {
                options["resizable"] = true;
            }

            if (Reorderable.Enabled)
            {
                options["reorderable"] = true;
            }

            if (!Scrollable.Enabled)
            {
                options["scrollable"] = false;
            }
            else
            {
                var scrolling = Scrollable.ToJson();
                if (scrolling.Any())
                {
                    options["scrollable"] = scrolling;
                }
            }

            if (Editable.Enabled)
            {
                options["editable"] = Editable.ToJson();
            }

            if (ToolBar.Enabled)
            {
                options["toolbar"] = ToolBar.ToJson();
            }

            if (autoBind == false)
            {
                options["autoBind"] = autoBind;
            }

            options["dataSource"] = DataSource.ToJson();

            if (!String.IsNullOrEmpty(ClientDetailTemplateId))
            {
                options["detailTemplate"] = new ClientHandlerDescriptor {
                    HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, ClientDetailTemplateId)
                };
            }

            if (!String.IsNullOrEmpty(ClientRowTemplate))
            {
                options["rowTemplate"] = ClientRowTemplate;
            }

            if (Navigatable.Enabled)
            {
                options["navigatable"] = true;
            }

            writer.Write(Initializer.Initialize(Selector, "Grid", options));

            base.WriteInitializationScript(writer);
        }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SortableBuilder"/> class.
 /// </summary>
 /// <param name="component">The component.</param>
 public SortableBuilder(Sortable component)
 {
     Component = component;
 }
Exemple #9
0
        /// <inheritdoc />
        public async Task <PagingResult <CompanyModel> > GetCompanies(CompanyFilter filter = null, Sortable sortable = null, Paginable paginable = null)
        {
            _logger.LogInformation("GET Companies requested with filters: {filter}, sort params {sortable}, paging params {paginable}", filter, sortable, paginable);

            IQueryable <Company> query = await _companyRepository.GetAsync();

            if (filter != null)
            {
                query = Filtering(filter, query);
            }

            var queryableCount = query;
            int totalCount     = queryableCount.Count();

            if (sortable != null)
            {
                query = Sorting(sortable, query);
            }
            if (paginable != null)
            {
                query = Pagination(paginable, query);
            }

            var companies        = query.ToList();
            var companyModelList = new List <CompanyModel>();

            var allUsersQuery = await _userRepository.GetAsync(x => !string.IsNullOrEmpty(x.Role)?x.Role.Trim().Equals(salesRoleId) : false);

            var allUsers = allUsersQuery.GroupBy(x => x.CompanyId).ToList();
            var Tenants  = (await _TenantRep.GetAsync()).ToHashSet();

            foreach (var company in companies)
            {
                var companyModel = company.Adapt <CompanyModel>();
                var Tenant       = Tenants.FirstOrDefault(x => x.Companies.Select(c => c.CompanyId).ToHashSet().Contains(company.Id));
                companyModel.CountSalesRep = allUsers.FirstOrDefault(x => x.Key == company.Id)?.Count();
                companyModel.CountBranch   = company.Branches.Count;
                companyModel.Tenant        = Tenant?.Adapt <TenantSingleModel>();
                companyModelList.Add(companyModel);
            }

            _logger.LogInformation("GET Companies ended, total companies fetched: {total}", totalCount);

            return(new PagingResult <CompanyModel>
            {
                Total = totalCount,
                ItemsPerPage = paginable?.Take ?? default,
                Data = companyModelList
            });
Exemple #10
0
 public void DoSort(Sortable collection)
 {
     bool isAss = collection.IsAcending;
 }
 public void RemoveSortable(Sortable sortable)
 {
     m_sortables.Remove(sortable);
 }