Exemple #1
0
        public static List <OrderGroupModel> Convert <T>(List <T> listOrder)
            where T : BaseOrderModel
        {
            var result        = new List <OrderGroupModel>();
            var projectLookup = listOrder.ToLookup(k => k.ProjectNo);

            foreach (var project in projectLookup)
            {
                var model = new OrderGroupModel();
                model.ProjectNo = project.Key;
                var list = project.ToList();
                model.Type      = list.Select(s => s.Type).FirstOrDefault();
                model.OrderTime = list.Max(o => o.OrderTime);
                model.ListData  = list.Select((s, index) => new DisplayRowModel()
                {
                    RowNum = index + 1,
                    Code   = s.Code,
                    Count  = s.Count,
                    Total  = s.Total,
                    BoxNo  = s.BoxNo
                }).ToList();
                result.Add(model);
            }
            return(result);
        }
Exemple #2
0
        private void ShowDataTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var timer = sender as System.Timers.Timer;

            try
            {
                timer.Stop();
                if (!this.IsReady || !this.DeviceOnline)
                {
                    this.Log.Info("正在等待连接设备");
                    return;
                }
                if (this.QueueData.IsEmpty)
                {
                    this.GetData();
                }
                else
                {
                    OrderGroupModel CurData    = null;
                    var             canDequeue = this.QueueData.TryDequeue(out CurData);
                    if (canDequeue)
                    {
                        this.Log.Info($"显示数据:{Environment.NewLine}{JsonConvert.SerializeObject(CurData)}");
                        var showTextSuccess = 0;
                        showTextSuccess = ZHLED.LedAgent.ShowInstantText(this.DeviceId, 0U, 1U, new StringBuilder(CurData.Type), 71U);
                        showTextSuccess = ZHLED.LedAgent.ShowInstantText(this.DeviceId, 0U, 1U, new StringBuilder(CurData.ProjectNo), 72U);
                        showTextSuccess = ZHLED.LedAgent.ShowInstantText(this.DeviceId, 0U, 1U, new StringBuilder(CurData.OrderTime.ToString("yyyy-MM-dd HH:mm")), 73U);
                        if (CurData.ListData.Count > 6)
                        {
                            var newModel = new OrderGroupModel()
                            {
                                Type      = CurData.Type,
                                ProjectNo = CurData.ProjectNo,
                                OrderTime = CurData.OrderTime,
                                ListData  = CurData.ListData.OrderBy(o => o.RowNum).Skip(6).ToList()
                            };
                            this.QueueData.Enqueue(newModel);
                        }
                        var listData = CurData.ListData.OrderBy(o => o.RowNum).Take(6).ToList();
                        for (int i = 0; i < 6; i++)
                        {
                            var item = listData.ElementAtOrDefault(i);
                            var text = new StringBuilder(item == null ? DisplayRowModel.Empty : item.ToString());
                            showTextSuccess = ZHLED.LedAgent.ShowInstantText(this.DeviceId, 0U, 1U, text, (uint)((i + 1) * 10 + 1));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Log.Error(ex.Message, ex);
            }
            finally
            {
                timer.Start();
            }
        }
        internal async Task <OrderGroupModel> AddInformationFromListsToModel(OrderGroupModel model)
        {
            int orderGroupId = model.OrderGroupId.Value;

            await AddInformationFromListsToModel(model, orderGroupId);

            model.PreviousRequestGroups = _dbContext.RequestGroups.GetPreviousRequestGroupsForOrderGroup(orderGroupId)
                                          .Select(r => new BrokerListModel
            {
                Status      = r.Status,
                BrokerName  = r.Ranking.Broker.Name,
                DenyMessage = r.DenyMessage,
            }).ToList();
            return(model);
        }
Exemple #4
0
        public async Task <IActionResult> View(int id)
        {
            OrderGroup orderGroup = await _dbContext.OrderGroups.GetFullOrderGroupById(id);

            if ((await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.View)).Succeeded)
            {
                var allowEdit = (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Edit)).Succeeded;

                var activeRequestGroup = await _dbContext.RequestGroups.GetLastRequestGroupForOrderGroup(id);

                await _orderService.AddOrdersWithListsForGroup(orderGroup);

                await _requestService.AddListsForRequestGroup(activeRequestGroup);

                activeRequestGroup.Requests.ForEach(r => r.Order = orderGroup.Orders.Where(o => o.OrderId == r.OrderId).SingleOrDefault());

                var model = OrderGroupModel.GetModelFromOrderGroup(orderGroup, activeRequestGroup);
                await _listToModelService.AddInformationFromListsToModel(model);

                model.CustomerInformationModel = new CustomerInformationModel
                {
                    IsCustomer                  = true,
                    Name                        = model.CustomerName,
                    CreatedBy                   = model.CreatedBy,
                    OrganisationNumber          = model.CustomerOrganisationNumber,
                    PeppolId                    = model.CustomerPeppolId,
                    UnitName                    = model.CustomerUnitName,
                    DepartmentName              = model.UnitName,
                    ReferenceNumber             = model.CustomerReferenceNumber,
                    InvoiceReference            = model.InvoiceReference,
                    UseSelfInvoicingInterpreter = _cacheService.CustomerSettings.Any(c => c.CustomerOrganisationId == orderGroup.CustomerOrganisationId && c.UsedCustomerSettingTypes.Any(cs => cs == CustomerSettingType.UseSelfInvoicingInterpreter))
                };

                model.ActiveRequestGroup = RequestGroupViewModel.GetModelFromRequestGroup(activeRequestGroup, User.IsInRole(Roles.ApplicationAdministrator) || User.IsInRole(Roles.SystemAdministrator));

                await _listToModelService.AddInformationFromListsToModel(model.ActiveRequestGroup);

                model.AllowProcessing                      = activeRequestGroup.Status == RequestStatus.Accepted && (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Accept)).Succeeded;
                model.AllowCancellation                    = orderGroup.AllowCancellation && (await _authorizationService.AuthorizeAsync(User, orderGroup, Policies.Cancel)).Succeeded;
                model.AllowNoAnswerConfirmation            = orderGroup.AllowNoAnswerConfirmation && allowEdit;
                model.AllowResponseNotAnsweredConfirmation = orderGroup.AllowResponseNotAnsweredConfirmation && allowEdit;
                model.AllowUpdateExpiry                    = orderGroup.AllowUpdateExpiry && allowEdit;
                model.UseAttachments = CachedUseAttachentSetting(orderGroup.CustomerOrganisationId);

                return(View(model));
            }
            return(Forbid());
        }
Exemple #5
0
        public async Task <IActionResult> View(int id)
        {
            var requestGroup = await _dbContext.RequestGroups.GetRequestGroupToView(id);

            OrderGroup orderGroup = await _dbContext.OrderGroups.GetFullOrderGroupById(requestGroup.OrderGroupId);

            if ((await _authorizationService.AuthorizeAsync(User, requestGroup, Policies.View)).Succeeded)
            {
                if (requestGroup.IsToBeProcessedByBroker)
                {
                    return(RedirectToAction(nameof(Process), new { id = requestGroup.RequestGroupId }));
                }

                await _orderService.AddOrdersWithListsForGroup(orderGroup);

                await _requestService.AddListsForRequestGroup(requestGroup);

                requestGroup.Requests.ForEach(r => r.Order = orderGroup.Orders.Where(o => o.OrderId == r.OrderId).SingleOrDefault());
                var model = RequestGroupViewModel.GetModelFromRequestGroup(requestGroup, true, false);
                await _listToModelService.AddInformationFromListsToModel(model);

                model.CustomerInformationModel.IsCustomer = false;
                model.CustomerInformationModel.UseSelfInvoicingInterpreter = _cacheService.CustomerSettings.Any(c => c.CustomerOrganisationId == requestGroup.OrderGroup.CustomerOrganisationId && c.UsedCustomerSettingTypes.Any(cs => cs == CustomerSettingType.UseSelfInvoicingInterpreter));
                model.OrderGroupModel = OrderGroupModel.GetModelFromOrderGroup(requestGroup.OrderGroup, requestGroup, true);
                await _listToModelService.AddInformationFromListsToModel(model.OrderGroupModel, requestGroup.OrderGroupId);

                if (requestGroup.QuarantineId.HasValue)
                {
                    List <OrderOccasionDisplayModel> tempOccasionList = new List <OrderOccasionDisplayModel>();
                    foreach (OrderOccasionDisplayModel occasion in model.OccasionList.Occasions)
                    {
                        var request = requestGroup.Requests.Single(r => r.RequestId == occasion.RouteId);
                        tempOccasionList.Add(OrderOccasionDisplayModel.GetModelFromOrder(request.Order, GetPriceinformationOrderToDisplay(request, model.OrderGroupModel.RequestedCompetenceLevels.ToList()), request));
                    }
                    model.OccasionList.Occasions = tempOccasionList;
                }
                model.OrderGroupModel.UseAttachments = true;
                return(View(model));
            }
            return(Forbid());
        }
        public ActionResult AdministratorPage()
        {
            ViewBag.ItemCount = cart.ItemCount;
            ViewBag.Header    = "Administrator Portal";

            // feedback read
            var feedbacksList = this._uow.Feedback.GetAll();

            foreach (var feedback in feedbacksList)
            {
                feedback.Date = feedback.FeedbackDate.ToShortDateString();
            }

            List <Feedback> feedbackModel = feedbacksList.ToList();

            // orders read
            var ordersList       = this._uow.Orders.GetAll();
            var groupedOdersList = ordersList.GroupBy(o => System.Data.Entity.DbFunctions.TruncateTime(o.ShipDate))
                                   .SelectMany(grp => grp.Select(items => new OrderGroupModel
            {
                OrderCount   = grp.Count(),
                ShippingDate = System.Data.Entity.DbFunctions.TruncateTime(items.ShipDate).Value,
                OrderItems   = items.OrderItems.GroupBy(i => i.ProductFK)
                               .SelectMany(igrp => igrp.Select(itemsList => new OrderItemGroupModel
                {
                    ProductId = itemsList.ProductFK,
                    Quantity  = igrp.Sum(item => item.Quantity),
                    Cost      = igrp.Sum(item => item.Cost)
                })).ToList()
            })).ToList();

            string DateFilter = null;

            if (groupedOdersList.Count() > 0)
            {
                DateFilter = groupedOdersList.FirstOrDefault().ShippingDate.ToShortDateString();
            }

            List <OrderGroupModel> filteredOrderList = new List <OrderGroupModel>();

            if (DateFilter != null)
            {
                int count = 0;

                foreach (var groupedOrder in groupedOdersList)
                {
                    groupedOrder.ShortDate = groupedOrder.ShippingDate.ToShortDateString();

                    if (groupedOrder.ShortDate == DateFilter)
                    {
                        if (count == 0)
                        {
                            OrderGroupModel orderGroup = new OrderGroupModel
                            {
                                OrderCount = groupedOrder.OrderCount,
                                ShortDate  = DateFilter,
                                OrderItems = GetOrdersItems(groupedOdersList, DateFilter)
                            };

                            filteredOrderList.Add(orderGroup);
                            count++;
                        }
                    }
                    else
                    {
                        DateFilter = groupedOrder.ShortDate;
                        count      = 0;
                        OrderGroupModel orderGroup = new OrderGroupModel
                        {
                            OrderCount = groupedOrder.OrderCount,
                            ShortDate  = DateFilter,
                            OrderItems = GetOrdersItems(groupedOdersList, DateFilter)
                        };
                    }
                }
            }

            ViewData["Orders"] = filteredOrderList;

            return(View(feedbackModel));
        }