/// <summary>
        /// Checks whether the specified message is a message which does not fit
        /// to the WWKS2 workflow and should be skipped.
        /// </summary>
        /// <param name="message">The message to check.</param>
        /// <returns><c>true</c> if the message does not fit the WWKS2 workflow and should be skipped.<c>false</c> otherwise.</returns>
        private bool SkipMessage(MosaicMessage message)
        {
            switch (message.Type)
            {
            case MessageType.StockOutputMessage:
            {
                if (((StockOutputMessage)message).Order.State == StockOutputOrderState.InProcess)
                {
                    return(true);
                }
                break;
            }

            case MessageType.LabelPrintMessage:
            {
                return(true);
            }

            case MessageType.LabelPrintRequest:
            {
                var request  = (LabelPrintRequest)message;
                var response = new LabelPrintResponse();
                response.AdoptHeader(request);
                response.SourceName  = "Mosaic";
                response.OrderNumber = request.OrderNumber;
                response.ArticleCode = request.ArticleCode;
                response.LabelId     = request.LabelId;
                response.TemplateId  = request.TemplateId;
                response.PrintLabel  = false;
                request.ConverterStream.Write(response);
                return(true);
            }

            case MessageType.StockInfoMessage:
            {
                if (((Interfaces.Messages.Stock.StockInfoMessage)message).Packs.Count == 0)
                {
                    return(true);
                }

                if ((((Interfaces.Messages.Stock.StockInfoMessage)message).StockInfoType != Interfaces.Messages.Stock.StockInfoType.StockUpdate) &&
                    (((Interfaces.Messages.Stock.StockInfoMessage)message).StockInfoType != Interfaces.Messages.Stock.StockInfoType.PackInput))
                {
                    return(true);
                }

                // Singapur workaround -> StockInfoMessage signals pack input only
                if ((_configuration.SmallMessageSet) &&
                    ((((Interfaces.Messages.Stock.StockInfoMessage)message).StockInfoType == Interfaces.Messages.Stock.StockInfoType.StockUpdate)))
                {
                    return(true);
                }

                break;
            }
            }

            return(false);
        }
Пример #2
0
        public void SetUp()
        {
            var labelPrint = new LabelPrint
            {
                LabelType        = (int)GeneralPurposeLabelTypes.Labels.Small,
                Printer          = (int)LabelPrinters.Printers.ProdLbl1,
                Quantity         = 2,
                LinesForPrinting = new LabelPrintContents {
                    Line1 = "this line 1", Line2 = "twoooo"
                }
            };

            this.result = this.Sut.PrintLabel(labelPrint);
        }
Пример #3
0
        public void SetUp()
        {
            var labelPrint = new LabelPrint
            {
                LabelType        = (int)GeneralPurposeLabelTypes.Labels.SmallBoldText,
                Printer          = (int)LabelPrinters.Printers.ProdLbl1,
                Quantity         = 7,
                LinesForPrinting = new LabelPrintContents {
                    Line1 = "bold yin"
                }
            };

            this.result = this.Sut.PrintLabel(labelPrint);
        }
Пример #4
0
        public void SetUp()
        {
            var labelPrint = new LabelPrint
            {
                LabelType        = (int)GeneralPurposeLabelTypes.Labels.LargeWeeText,
                Printer          = (int)LabelPrinters.Printers.ProdLbl2,
                Quantity         = 3,
                LinesForPrinting = new LabelPrintContents
                {
                    Line1 = "Large and small",
                    Line2 = "line2",
                    Line3 = "three",
                    Line4 = "four line",
                    Line5 = "funf",
                    Line6 = "siiiixz",
                    Line7 = "siben"
                }
            };

            this.result = this.Sut.PrintLabel(labelPrint);
        }
Пример #5
0
        public void SetUp()
        {
            var labelPrint = new LabelPrint
            {
                LabelType        = (int)GeneralPurposeLabelTypes.Labels.GoodsInLabel,
                Printer          = (int)LabelPrinters.Printers.ProdLbl2,
                Quantity         = 9,
                LinesForPrinting = new LabelPrintContents
                {
                    AddressId  = "11",
                    SupplierId = "77",
                    PoNumber   = "PCAS",
                    PartNumber = "PCSM",
                    Qty        = "99",
                    Initials   = "IC",
                    Date       = "30 Jan 2020"
                }
            };

            this.result = this.Sut.PrintLabel(labelPrint);
        }
Пример #6
0
        public void SetUp()
        {
            var labelPrint = new LabelPrint
            {
                LabelType        = (int)GeneralPurposeLabelTypes.Labels.AddressLabel,
                Printer          = (int)LabelPrinters.Printers.ProdLbl2,
                Quantity         = 6,
                LinesForPrinting = new LabelPrintContents
                {
                    SupplierId = "77",
                    AddressId  = "11",
                    Addressee  = "la addressee",
                    Addressee2 = "duexieme addressee",
                    Line1      = "Large and small",
                    Line2      = "line2",
                    Line3      = "three",
                    Line4      = "four line",
                    PostalCode = "G1",
                    Country    = "schottland"
                }
            };

            this.result = this.Sut.PrintLabel(labelPrint);
        }
Пример #7
0
        public Response <List <LabelPrintResponse> > GetLabelPrintUrl(List <string> orderNumbers)
        {
            var response = new Response <List <LabelPrintResponse> >();
            var list     = new List <LabelPrintResponse>();

            try
            {
                if (orderNumbers.Any())
                {
                    var dictionary = new Dictionary <int, List <LabelPrintModel> >();
                    _printService.GetLabelPrint(orderNumbers.Distinct().ToList(), HttpContext.Current.User.Identity.Name,
                                                templateTypeId).ForEach(p =>
                    {
                        if (dictionary.ContainsKey(p.ShippingMethodId))
                        {
                            dictionary[p.ShippingMethodId].Add(p);
                        }
                        else
                        {
                            dictionary.Add(p.ShippingMethodId, new List <LabelPrintModel> {
                                p
                            });
                        }
                    });
                    foreach (var d in dictionary)
                    {
                        if (d.Key == 0)
                        {
                            var lp = new LabelPrintResponse()
                            {
                                Url = ""
                            };
                            d.Value.ForEach(p => lp.LabelPrintInfos.Add(new LabelPrintInfo()
                            {
                                ErrorBody   = "不存在打印模板",
                                ErrorCode   = 200,
                                OrderNumber = p.OrderNumber
                            }));
                            list.Add(lp);
                        }
                        else
                        {
                            if (d.Value[0].IsHavePrint)
                            {
                                const int pagesize  = 20;//分批查询
                                int       pageindex = 1;
                                do
                                {
                                    var l  = d.Value.Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                                    var lp = new LabelPrintResponse()
                                    {
                                        Url = httpUrl + string.Join(",", l.Select(p => p.OrderNumber))
                                    };
                                    l.ForEach(p => lp.LabelPrintInfos.Add(new LabelPrintInfo()
                                    {
                                        ErrorBody   = "",
                                        ErrorCode   = 100,
                                        OrderNumber = p.OrderNumber
                                    }));
                                    list.Add(lp);
                                    pageindex++;
                                } while (d.Value.Count > (pageindex - 1) * pagesize);
                            }
                            else
                            {
                                var lp = new LabelPrintResponse()
                                {
                                    Url = ""
                                };
                                d.Value.ForEach(p => lp.LabelPrintInfos.Add(new LabelPrintInfo()
                                {
                                    ErrorBody   = "不存在打印模板",
                                    ErrorCode   = 200,
                                    OrderNumber = p.OrderNumber
                                }));
                                list.Add(lp);
                            }
                        }
                    }
                }
                response.Item       = list;
                response.ResultCode = "0000";
                response.ResultDesc = "请求成功";
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                response.Item       = list;
                response.ResultCode = "9999";
                response.ResultDesc = "接口异常";
            }

            return(response);
        }
        public List <LabelPrintResponse> GetLabelPrintUrl(LabelPrintRequest model)
        {
            var list = new List <LabelPrintResponse>();

            if (model != null && model.OrderNumber != null && model.OrderNumber.Any())
            {
                var labellist = _labelPrintWebApiService.GetLabelPrintExtList(model.OrderNumber,
                                                                              HttpContext.Current.User.Identity.Name);
                var cdictionary = new Dictionary <string, LabelPrintExt>();
                labellist.ForEach(p =>
                {
                    if (!string.IsNullOrWhiteSpace(p.CustomerOrderNumber))
                    {
                        cdictionary.Add(p.CustomerOrderNumber, p);
                    }
                });
                var tdictionary = new Dictionary <string, LabelPrintExt>();
                labellist.ForEach(p =>
                {
                    if (!string.IsNullOrWhiteSpace(p.Trackingnumber))
                    {
                        tdictionary.Add(p.Trackingnumber, p);
                    }
                });
                var wdictionary = new Dictionary <string, LabelPrintExt>();
                labellist.ForEach(p =>
                {
                    if (!string.IsNullOrWhiteSpace(p.WayBillNumber))
                    {
                        tdictionary.Add(p.WayBillNumber, p);
                    }
                });
                var dictionary       = new Dictionary <int, LabelPrintInfo>();
                var multiDictionary  = new List <int>();
                var customerOrderIds = new List <int>();
                var nullOrderIds     = new List <string>();
                model.OrderNumber.ForEach(p =>
                {
                    customerOrderIds.Clear();
                    if (cdictionary.ContainsKey(p))
                    {
                        if (!dictionary.ContainsKey(cdictionary[p].CustomerOrderId))
                        {
                            dictionary.Add(cdictionary[p].CustomerOrderId, new LabelPrintInfo()
                            {
                                CustomerOrderId     = cdictionary[p].CustomerOrderId,
                                CustomerOrderNumber = cdictionary[p].CustomerOrderNumber,
                                OriginalNumber      = p,
                                TrackingNumber      = cdictionary[p].Trackingnumber,
                                WayBillNumber       = cdictionary[p].WayBillNumber
                            });
                            customerOrderIds.Add(cdictionary[p].CustomerOrderId);
                        }
                    }
                    if (tdictionary.ContainsKey(p))
                    {
                        if (!dictionary.ContainsKey(tdictionary[p].CustomerOrderId))
                        {
                            dictionary.Add(tdictionary[p].CustomerOrderId, new LabelPrintInfo()
                            {
                                CustomerOrderNumber = tdictionary[p].CustomerOrderNumber,
                                CustomerOrderId     = tdictionary[p].CustomerOrderId,
                                OriginalNumber      = p,
                                TrackingNumber      = tdictionary[p].Trackingnumber,
                                WayBillNumber       = tdictionary[p].WayBillNumber
                            });
                            customerOrderIds.Add(tdictionary[p].CustomerOrderId);
                        }
                    }
                    if (wdictionary.ContainsKey(p))
                    {
                        if (!dictionary.ContainsKey(wdictionary[p].CustomerOrderId))
                        {
                            dictionary.Add(wdictionary[p].CustomerOrderId, new LabelPrintInfo()
                            {
                                CustomerOrderId     = wdictionary[p].CustomerOrderId,
                                CustomerOrderNumber = wdictionary[p].CustomerOrderNumber,
                                OriginalNumber      = p,
                                TrackingNumber      = wdictionary[p].Trackingnumber,
                                WayBillNumber       = wdictionary[p].WayBillNumber
                            });
                            customerOrderIds.Add(wdictionary[p].CustomerOrderId);
                        }
                    }
                    if (customerOrderIds.Count > 1)
                    {
                        if (cdictionary.ContainsKey(p))
                        {
                            multiDictionary.Add(cdictionary[p].CustomerOrderId);
                        }
                        if (tdictionary.ContainsKey(p))
                        {
                            multiDictionary.Add(tdictionary[p].CustomerOrderId);
                        }
                        if (wdictionary.ContainsKey(p))
                        {
                            multiDictionary.Add(wdictionary[p].CustomerOrderId);
                        }
                    }
                    else if (customerOrderIds.Count == 0)
                    {
                        nullOrderIds.Add(p);
                    }
                });
                if (dictionary.Any())
                {
                    int i   = 1;
                    var lpr = new LabelPrintResponse {
                        Url = string.Format(_httpurlFormat, httpUrl, model.TypeId)
                    };
                    foreach (var d in dictionary)
                    {
                        lpr.Url = lpr.Url + d.Key.ToString() + ",";
                        if (multiDictionary.Contains(d.Key))
                        {
                            lpr.LabelPrintInfos.Add(new LabelPrintInfo()
                            {
                                CustomerOrderId     = d.Value.CustomerOrderId,
                                CustomerOrderNumber = d.Value.CustomerOrderNumber,
                                ErrorBody           = string.Format("单号{0}存在多条数据", d.Value.OriginalNumber),
                                ErrorCode           = 200,
                                OriginalNumber      = d.Value.OriginalNumber,
                                Status         = true,
                                TrackingNumber = d.Value.TrackingNumber,
                                WayBillNumber  = d.Value.WayBillNumber
                            });
                        }
                        else
                        {
                            lpr.LabelPrintInfos.Add(new LabelPrintInfo()
                            {
                                CustomerOrderId     = d.Value.CustomerOrderId,
                                CustomerOrderNumber = d.Value.CustomerOrderNumber,
                                ErrorBody           = "",
                                ErrorCode           = 300,
                                OriginalNumber      = d.Value.OriginalNumber,
                                Status         = true,
                                TrackingNumber = d.Value.TrackingNumber,
                                WayBillNumber  = d.Value.WayBillNumber
                            });
                        }
                        if (i == maxpagecount)
                        {
                            list.Add(lpr);
                            lpr = new LabelPrintResponse {
                                Url = string.Format(_httpurlFormat, httpUrl, model.TypeId)
                            };
                            i = 0;
                        }
                        i++;
                    }
                    list.Add(lpr);
                }
                if (nullOrderIds.Any())
                {
                    var lpr = new LabelPrintResponse();
                    nullOrderIds.ForEach(p => lpr.LabelPrintInfos.Add(new LabelPrintInfo()
                    {
                        OriginalNumber = p,
                        Status         = false,
                        ErrorCode      = 100,
                        ErrorBody      = string.Format("单号{0}不存在", p)
                    }));
                    list.Add(lpr);
                }
            }

            return(list);
        }