private BillCheque OnBillChequePrintingCallback(Guid orderId)
        {
            BillCheque billCheque = new BillCheque();

            try
            {
                IPrinterRef receiptChequePrinter = PluginContext.Operations.TryGetReceiptChequePrinter(false);
                if (receiptChequePrinter == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: printer is missing", nameof(TemperaturePlugin));
                    return(billCheque);
                }
                IEnumerable <TemperatureResponse> temperature = this._apiClient.GetTemperature();
                if (temperature == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not get temperature info", nameof(TemperaturePlugin));
                    return(billCheque);
                }
                TemperatureResponse temperatureResponse = temperature.FirstOrDefault(i => Guid.Parse(i.StoreExternalId) == _storeExternalId);
                if (temperatureResponse == null)
                {
                    PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not find current store id", nameof(TemperaturePlugin));
                    return(billCheque);
                }

                XElement xelement1 = new XElement("doc");

                var checkDate = temperatureResponse.CheckDate;

                var day = checkDate.Day;
                checkDate = temperatureResponse.CheckDate;
                var month = checkDate.Month;
                checkDate = temperatureResponse.CheckDate;
                var    year    = checkDate.Year;
                string dateStr = string.Format("{0}.{1}.{2}  ", day, month, year);
                checkDate = temperatureResponse.CheckDate;
                var hour = checkDate.Hour;
                checkDate = temperatureResponse.CheckDate;
                var minute = checkDate.Minute;
                checkDate = temperatureResponse.CheckDate;
                var second = checkDate.Second;

                string timeStr     = string.Format("{0}:{1}:{2}", hour, minute, second);
                string dateTimeStr = $"<b>Temperature information on {dateStr} {timeStr}</b>";
                var    xelement2   = new XElement("fill", dateTimeStr);
                var    xelement3   = new XElement("fill", string.Format("Avarage temperature: {0}", temperatureResponse.TemperatureInfo.AverageTemp));
                xelement1.Add(xelement2);
                xelement1.Add(xelement3);

                PluginContext.Operations.Print(receiptChequePrinter, xelement1);
            }
            catch (Exception ex)
            {
                PluginContext.Log.Error("Cannot print temperature: " + ex.Message);
                PluginContext.Operations.AddErrorMessage("Cannot print temperature info: could not get temperature info", nameof(TemperaturePlugin));
            }
            return(billCheque);
        }
示例#2
0
        private static BillCheque AddUniqueChequeExtensions(int chequeNumber)
        {
            var billCheque = new BillCheque
            {
                BeforeHeader = new XElement(Tags.Left, Resources.WelcomeText),
                BeforeFooter = new XElement(Tags.Pair, new XAttribute(Tags.Left, Resources.ChequeNumber), new XAttribute(Tags.Right, chequeNumber.ToString())),
                AfterFooter  = new XElement(Tags.Center, Resources.ValedictoryText)
            };

            if (chequeNumber % 10 == 0)
            {
                billCheque.AfterHeader = new XElement(Tags.Table,
                                                      new XElement(Tags.Columns,
                                                                   new XElement(Tags.Column, new XAttribute(Attributes.AutoWidth, "")),
                                                                   new XElement(Tags.Column, new XAttribute(Attributes.Align, "right"))),
                                                      new XElement(Tags.Cells,
                                                                   new XElement(Tags.Cell, Resources.RoundNumberCongratulation, new XAttribute(Attributes.ColumnSpan, 2)),
                                                                   new XElement(Tags.TextCell, Resources.RoundChequeNumber),
                                                                   new XElement(Tags.TextCell, chequeNumber.ToString())));
            }
            return(billCheque);
        }