public static void XReport() { FRSSrv.RemoteDataClient FClient = GetFRSClient(); if (FClient != null) { FRSSrv.XReportResponce res = FClient.XReport(AlohainiFile.BDate, AlohainiFile.DepNum, AlohaTSClass.GetTermNum()); if (res.Result) { if (iniFile.XFromGes) { decimal cash = 0; decimal card = 0; GesData.GetGesData(AlohainiFile.BDate, AlohainiFile.DepNum, out cash, out card); decimal VCash = 0; try { VCash = res.VoidPayments.Where(a => a.ExternalId == 1 && a.Term == 0).First().Summ; } catch { } try { res.Payments.Where(a => a.ExternalId == 1 && a.Term == 0).First().Summ = cash + VCash; } catch { } } //if (iniFile.FRSPrintCheck) { PrintOnWinPrinter.PrintDoc2(FiscalCheckCreator.GetXReportVisual(res)); } } FClient.Close(); } }
static public void PrintDoc2(PrintDocArgs Args, int TryCount) { int W = 268; //268 double H = 5000; ctrlCheckVisual vis = new ctrlCheckVisual(); if (Args.FStrs != null) { BitmapImage QrImg = FiscalCheckCreator.CreateQRBitmap(Args.QRAsStr, 130, 130); vis.CreateCheck(Args.FStrs, QrImg); vis.Visibility = Visibility.Visible; // string PrName = @"Predchek4"; string PrName = iniFile.FRSPrinterName; try { Utils.ToCardLog("PrintDoc PrName " + PrName); PrintDialog Pd = new PrintDialog(); Pd.PageRangeSelection = PageRangeSelection.AllPages; PrintServer Ps = new PrintServer(); PrintQueue PQ = new PrintQueue(Ps, PrName); Pd.PrintQueue = PQ; // Pd.ShowDialog(); PrintTicket Pt = Pd.PrintTicket; Pt.PageMediaSize = new PageMediaSize(W, 11349); Pt.PageBorderless = PageBorderless.Borderless; Pt.PageResolution = new PageResolution(203, 203); Pt.PageScalingFactor = 1; Pt.TrueTypeFontMode = TrueTypeFontMode.DownloadAsRasterFont; Size pageSize = new Size(W - 10, Pd.PrintableAreaHeight); //pageSize = new Size(W, H); ((UserControl)vis).Measure(pageSize); ((UserControl)vis).Arrange(new Rect(0, 0, W - 10, ((UserControl)vis).Height)); //((UserControl)vis).Arrange(new Rect(0, 0, W, H)); if (iniFile.FRSSaveCheckToImg2) { SaveCheckVisualToFile(vis, W, Convert.ToInt32(((UserControl)vis).Height)); } Pd.PrintVisual(vis, "Hello"); Ps.Dispose(); Pd.PrintQueue.Dispose(); Pd = null; QrImg = null; } catch (Exception e) { Utils.ToCardLog("PrintDoc Error " + e.Message); if (TryCount < 5) { Utils.ToCardLog("Try again " + TryCount); System.Threading.Thread.Sleep(300); GC.Collect(); PrintDoc2(Args, TryCount + 1); } } } vis = null; GC.Collect(); }
public static void ZReport(DateTime BD) { Utils.ToCardLog("FClient.ZReport"); FRSSrv.RemoteDataClient FClient = GetFRSClient(); //DateTime BD = AlohainiFile.BDate; if (FClient != null) { FRSSrv.ZReportResponce Res = null; try { Res = FClient.ZReport(AlohainiFile.DepNum, AlohaTSClass.GetTermNum(), BD); } catch (Exception e) { Utils.ToCardLog("Error FClient.ZReport" + e.Message); ZReportAskSaver.SaveZRepFRSAsk(BD); } if (Res != null) { if (Res.Result) { if (iniFile.XFromGes) { decimal cash = 0; decimal card = 0; GesData.GetGesData(AlohainiFile.BDate, AlohainiFile.DepNum, out cash, out card); decimal VCash = 0; try { VCash = Res.OutData.VoidPayments.Where(a => a.ExternalId == 1 && a.Term == 0).First().Summ; } catch { } try { Res.OutData.Payments.Where(a => a.ExternalId == 1 && a.Term == 0).First().Summ = cash + VCash; } catch { } } //if (iniFile.FRSPrintCheck) { if (Res.OutData.Payments.Count() > 0) { Utils.ToCardLog("FClient.ZReport print"); PrintOnWinPrinter.PrintDoc2(FiscalCheckCreator.GetEndOfSmenaVisual(Res)); } else { PrintOnWinPrinter.PrintDoc2(FiscalCheckCreator.GetZReportVisual(Res)); } } } } FClient.Close(); } else { Utils.ToCardLog("FClient == null"); ZReportAskSaver.SaveZRepFRSAsk(BD); } }
public static void ReprintFChk(Guid CheckId) { try { FRSSrv.RemoteDataClient FClient = GetFRSClient(); if (FClient != null) { FRSSrv.AddCheckResponce Resp = FClient.PrintCheck(CheckId); if (Resp.Check.Sucсess) { Utils.ToCardLog("ReprintFChk ExtNum " + Resp.Check.ExtNum + " ReprintFChk"); // if (iniFile.FRSPrintCheck) { PrintOnWinPrinter.PrintDoc2(new PrintDocArgs() { FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp), QRAsStr = Resp.Check.FROutData.QRAsStr }); } } try { if (Resp.ParentCheck != null) { if (Resp.ParentCheck.Sucсess) { Utils.ToCardLog("ReprintFChk Parent ExtNum " + Resp.Check.ExtNum + " ReprintFChk"); // if (iniFile.FRSPrintCheck) { PrintOnWinPrinter.PrintDoc2(new PrintDocArgs() { FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp, true), QRAsStr = Resp.ParentCheck.FROutData.QRAsStr }); } } } } catch (Exception ee) { Utils.ToCardLog("Error SendChk ParentCheck" + ee.Message); } FClient.Close(); } } catch (Exception e) { Utils.ToCardLog("Error SendChk " + e.Message); } }
private static FRSSrv.AddCheckResponce SendChk(FRSSrv.FiskalCheck Chk) { try { long Mbefore = GC.GetTotalMemory(false); Utils.ToCardLog("SendChk memory " + Mbefore); FRSSrv.AddCheckResponce Resp = new AddCheckResponce(); FRSSrv.RemoteDataClient FClient = GetFRSClient(); if (FClient != null) { FRSSrv.AddCheckRequest Request = new FRSSrv.AddCheckRequest() { Id = new Guid(), Check = Chk }; Resp = FClient.AddCheck(Request); if (Resp.Check.Sucсess) { Utils.ToCardLog("SendChk ExtNum " + Chk.ExtNum + " ClosedSucsees"); if ((iniFile.FRSPrintCheck) && (!Resp.Check.WrongChk)) { PrintOnWinPrinter.PrintDoc2(new PrintDocArgs() { FStrs = FiscalCheckCreator.GetFisckalCheckVisual(Resp), QRAsStr = Resp.Check.FROutData.QRAsStr }); } } FClient.InnerChannel.Close(); FClient.InnerChannel.Dispose(); FClient.Close(); long MAfter = GC.GetTotalMemory(false); Utils.ToCardLog("SendChk memory " + MAfter); } return(Resp); } catch (Exception e) { Utils.ToCardLog("Error SendChk " + e.Message); return(null); } //System.Windows.Forms.MessageBox.Show(Resp.Check.FD+" "+Resp.Check.FP); }