Esempio n. 1
0
 internal static void XReport()
 {
     if (iniFile.FRSEnabled)
     {
         FRSClientApp.FRSClient.XReport();
     }
     else
     {
         if (iniFile.FiskalDriverNonShtrih)
         {
             /*
              * if (iniFile.FiskalDriverNonShtrihAlohaReport)
              * {
              *
              *  var checks =  PDiscountCard.CloseCheck.ReadAllChecks();
              *  AlohaTSClass.PrintXReport(checks);
              *
              *  //PDiscountCard.FRSClientApp.PrintOnWinPrinter.PrintDoc2(PDiscountCard.FRSClientApp.FiscalCheckCreator.GetXReportVisual(res));
              * }
              * else
              * {
              * */
             FiskalDrivers.FiskalDriver.PrintXReport();
             //}
         }
         else
         {
             if (PDiscountCard.CloseCheck.CheckUnClosedChecks())
             {
                 Utils.ToCardLog("Shtrih2.XReport();");
                 Shtrih2.XReport();
             }
         }
     }
 }
Esempio n. 2
0
        private static void PrintCaptionWithFont(int FontType, ShtrihCommandBlock Cb)
        {
            List <string> Tmp = Shtrih2.GetCaption();

            //Shtrih.FontType = FontType;
            foreach (string s in Tmp)
            {
                Cb.PrintStringWithFont(s, FontType);
                //  Shtrih.StringForPrinting = s;
                //  mPrintStringWithFont();
            }
        }
Esempio n. 3
0
        internal static bool PrinterIsWhite()
        {
            /*
             *  Shtrih.Password = 30;
             *  Shtrih.TableNumber = 1;
             *  Shtrih.RowNumber = 1;
             *  Shtrih.FieldNumber = 49;
             *  Shtrih.GetFieldStruct();
             *
             *  Shtrih.ReadTable();
             */

            return(Shtrih2.ReadTableInt(1, 1, 49) == 0);
        }
Esempio n. 4
0
        /*
         * static  public  bool  Init()
         * {
         *  T1 = new System.Timers.Timer();
         *  T1.Stop();
         *  T1.Elapsed += new System.Timers.ElapsedEventHandler(T1_Elapsed);
         *  T1.Interval = 200;
         *  return  Shtrih.CreateShtrih();
         * }
         *
         * static void T1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
         * {
         *  T1.Stop ();
         *
         *
         *
         * }
         */

        /*
         * static public  bool GetPrinterStatus()
         * {
         *  Shtrih.GetShortECRStatus();
         *  switch (Shtrih.ECRMode )
         *  {
         *      case 0: //Принтер в рабочем режиме
         *          return true ;
         *          break;
         *     case 1: //Выдача данных
         *          return false;
         *              break;
         *      case 2: //Открытая смена, 24 часа не кончились
         *              return true;
         *              break;
         *      case 3: //Открытая смена, 24 часа кончились
         *          return false;
         *              break;
         *      case 4: //Закрытая смена
         *      case 5: //Блокировка по неправильному паролю налогового инспектора
         *          break;
         *      case 6: //Ожидание подтверждения ввода даты
         *      case 7: //Разрешение изменения положения десятичной точки
         *      case 8: //Открытый документ
         *          Shtrih.CancelCheck();
         *          GetPrinterStatus();
         *          break;
         *      case 9: //Режим разрешения технологического обнуления
         *      case 10: //Тестовый прогон
         *      case 11: //Печать полного фискального отчета
         *      case 12: //Печать длинного отчета ЭКЛЗ
         *      case 13: //Работа с фискальным подкладным документом
         *      case 14: //Печать подкладного документа
         *      case 15: //Фискальный подкладной документ сформирован
         *      default:
         *          break;
         *  }
         *  return false;
         * }
         */
        /*
         * static internal void WriteBalanceToShtrih(Balanse B)
         * {
         *  Shtrih.Password = 30;
         *
         *  Shtrih.TableNumber = 4;
         *  Shtrih.GetTableStruct();
         *  Shtrih.RowNumber = 1;
         *  Shtrih.FieldNumber = 1;
         *  Shtrih.ValueOfFieldString = B.Nal.ToString() + ";" + B.Card.ToString() + ";" +
         *      B.VozvrNal.ToString() + ";" + B.VozvrCard.ToString() + ";" +
         *      B.CountNal.ToString() + ";" + B.CountCard.ToString() + ";" +
         *      B.CountVozvrNal.ToString() + ";" + B.CountVozvrCard.ToString();
         *  Shtrih.WriteTable();
         * }
         */
        /*
         * internal static void WriteTableInfo(List<TableRowInfo> Ti)
         * {
         *
         *  Shtrih.TableNumber = 1;
         *  Shtrih.RowNumber = 1;
         *
         *  Shtrih.GetTableStruct();
         *  int MaxRows = Shtrih.FieldNumber;
         *  for (int i = 1; i < MaxRows + 1; i++)
         *  {
         *      Shtrih.FieldNumber = i;
         *      Shtrih.GetFieldStruct();
         *
         *
         *      if (Ti[i - 1].IsCange)
         *      {
         *
         *
         *          if (Shtrih.FieldType)
         *          {
         *              Shtrih.ValueOfFieldString = Ti[i - 1].ValueOfFieldString;
         *          }
         *          else
         *          {
         *              Shtrih.ValueOfFieldInteger = Ti[i - 1].ValueOfFieldInteger;
         *
         *          }
         *          Shtrih.WriteTable();
         *      }
         *
         *  }
         *
         *
         *
         *
         * }
         *
         * internal static void WriteCaption(List<string> Caption)
         * {
         *
         *  Shtrih.TableNumber = 4;
         *  Shtrih.FieldNumber = 1;
         *
         *  for (int i = 12; i < 17; i++)
         *  {
         *      Shtrih.RowNumber = i;
         *      Shtrih.ValueOfFieldString = Caption[i-12];
         *      Shtrih.GetFieldStruct();
         *      Shtrih.WriteTable();
         *
         *
         *  }
         *
         *
         * }
         */



        /*
         * internal static List<TableRowInfo> GetTableInfo()
         * {
         *  List<TableRowInfo> Tmp = new List<TableRowInfo>();
         *  Shtrih.TableNumber = 1;
         *  Shtrih.RowNumber = 1;
         *
         *  Shtrih.GetTableStruct();
         *  if (Shtrih.ResultCode != 0)
         *  {
         *      return Tmp;
         *  }
         *
         *  int MaxRows = Shtrih.FieldNumber ;
         *  for (int i = 1; i < MaxRows + 1; i++)
         *  {
         *      Shtrih.FieldNumber = i;
         *      Shtrih.GetFieldStruct();
         *
         *
         *
         *      TableRowInfo TrI = new TableRowInfo
         *      { Num = i,
         *          FieldSize = Shtrih.FieldSize,
         *          MAXValueOfField = Shtrih.MAXValueOfField,
         *          MINValueOfField = Shtrih.MINValueOfField,
         *          Name = Shtrih.FieldName,
         *          FieldType = Shtrih.FieldType,
         *
         *      };
         *      Shtrih.ReadTable();
         *      if (TrI.FieldType)
         *      {
         *          TrI.ValueOfFieldString = Shtrih.ValueOfFieldString;
         *      }
         *      else
         *      {
         *          TrI.ValueOfFieldInteger = Shtrih.ValueOfFieldInteger;
         *      }
         *
         *      Tmp.Add(TrI);
         *  }
         *
         *
         *
         *  return Tmp;
         * }
         */
        /*
         * internal static void Disconnect()
         * {
         *  try
         *  {
         *      Shtrih.Disconnect();
         *  }
         *  catch(Exception e)
         *  {
         *
         *
         *  }
         * }
         */
        /*
         * internal static bool GoodState()
         * {
         *  Conn();
         *  Shtrih.GetShortECRStatus();
         *  bool b = ((Shtrih.ECRMode == 0) || (Shtrih.ECRMode == 2) || (Shtrih.ECRMode == 4));
         *  Console.WriteLine("Status Printera: " + Shtrih.ECRMode.ToString());
         *  Shtrih.Disconnect();
         *  return b;
         *
         * }
         * */
        internal static bool PrinterColorIsGray()
        {
            /*
             * //Shtrih.Connect ();
             * Shtrih.Password = 30;
             * Shtrih.TableNumber = 1;
             * Shtrih.RowNumber = 1;
             * Shtrih.FieldNumber = 49;
             * Shtrih.ReadTable();
             * bool  i =(Shtrih.ValueOfFieldInteger == 1) ;
             * //Shtrih.Disconnect();
             * return i;
             */

            return(Shtrih2.ReadTableInt(1, 1, 49) == 1);
        }
Esempio n. 5
0
        static internal bool CheckUnClosedChecks()
        {
            DirectoryInfo Di = new DirectoryInfo(ChecksPath);

            if (!Di.Exists)
            {
                Di.Create();
            }
            if (Di.GetFiles("*.1").Count() == 0)
            {
                return(true);
            }

            Utils.ToCardLog("CheckUnClosedChecks");
            frmAllertMessage Mf = new frmAllertMessage("Существуют незакрытые чеки. Будет произведена попытка закрытия чеков. После этого снова запустите отчет.");

            Mf.ShowDialog();


            if (!Shtrih2.QuereIsEmpty())
            {
                frmAllertMessage Mf2 = new frmAllertMessage("Очередь чеков содержит незакрытые чеки. Это говорит о неполадках ФР. Убедитесь в исправности ФР и перезапустите отчет.");
                Mf2.ShowDialog();
                return(false);
            }

            foreach (FileInfo fi in Di.GetFiles("*.1"))
            {
                Utils.ToCardLog("CheckUnClosedChecks " + fi.Name);
                try
                {
                    Check Ch = ReadCheckFromTmp(fi.FullName);
                    Ch.FiskalFileName = fi.FullName;
                    ToShtrih.CloseCheck2(Ch);
                }
                catch (Exception e)
                {
                    Utils.ToCardLog("[Error] CheckUnClosedChecks " + e.Message);
                }
            }
            return(false);
        }
Esempio n. 6
0
        /*
         * internal static string  GetClishe()
         * {
         *  string tmp = "";
         *  Shtrih.Password = 30;
         *  Shtrih.TableNumber = 4;
         *
         *  Shtrih.FieldNumber = 1;
         *  for (int i = 11; i < 17; i++)
         *  {
         *      Shtrih.RowNumber = i;
         *      Shtrih.GetFieldStruct();
         *      Shtrih.ReadTable();
         *      string k="";
         *      if (Shtrih.ValueOfFieldString != null)
         *      {
         *          k = Shtrih.ValueOfFieldString.Replace(" ", "");
         *      }
         *      if (k.Length > 0)
         *      {
         *          tmp += Shtrih.ValueOfFieldString+Environment.NewLine  ;
         *      }
         *  }
         *  return tmp;
         * }
         */

        /*
         * public  static void CloseCheck(double Pr, DateTime dt)
         * {
         *  SetTime(dt);
         *  CloseCheck((decimal )Pr);
         *
         * }
         */
        /*
         * private static void mSale()
         * {
         *  /*
         *  MessageForm Mf = new MessageForm(Shtrih.ResultCodeDescription);
         *  do
         *  {
         *      Shtrih.Sale();
         *
         *      if (Shtrih.ResultCode == 0)
         *      {
         *          Shtrih.WaitForPrinting();
         *      }
         *      else if (Shtrih.ResultCode == 88)
         *      {
         *          Shtrih.ContinuePrint();
         *      }
         *      else
         *      {
         *          Mf.SetCpt(Shtrih.ResultCodeDescription);
         *          Mf.ShowDialog();
         *      }
         *  } while ((Mf.Result == 1)&&(Shtrih.ResultCode != 0));
         *  Mf.Close();
         *  Mf.Dispose ();
         * */
        //        Shtrih.Sale();
        //  }

        //private static void mReturnSale()
        //{

        /*
         * MessageForm Mf = new MessageForm(Shtrih.ResultCodeDescription);
         * do
         * {
         *  Shtrih.ReturnSale ();
         *
         *  if (Shtrih.ResultCode == 0)
         *  {
         *      Shtrih.WaitForPrinting();
         *  }
         *  else if (Shtrih.ResultCode == 88)
         *  {
         *      Shtrih.ContinuePrint();
         *  }
         *  else
         *  {
         *      Mf.SetCpt(Shtrih.ResultCodeDescription);
         *      Mf.ShowDialog();
         *  }
         * } while ((Mf.Result == 1) && (Shtrih.ResultCode != 0));
         * Mf.Close();
         * Mf.Dispose();
         * */
        //  Shtrih.ReturnSale ();
        // }

        //private static void mCloseCheck()
        //{

        /*
         * MessageForm Mf = new MessageForm(Shtrih.ResultCodeDescription);
         *
         * do{
         * Shtrih.CloseCheck ();
         *
         * if (Shtrih.ResultCode == 0)
         * {
         *  Shtrih.WaitForPrinting();
         * }
         * else if (Shtrih.ResultCode == 88)
         * {
         *  Shtrih.ContinuePrint();
         * }
         * else
         * {
         *  Mf.SetCpt(Shtrih.ResultCodeDescription);
         *  Mf.ShowDialog();
         * }
         * } while ((Mf.Result == 1)&&(Shtrih.ResultCode != 0));
         * Mf.Close();
         * Mf.Dispose ();
         * */
        //       Shtrih.CloseCheck();
        //  }

        //    private static int mPrintString()
        //   {

        /*
         * MessageForm Mf = new MessageForm(Shtrih.ResultCodeDescription);
         *
         * int res = 0;
         * do
         * {
         *  Utils.ToLog(Shtrih.StringForPrinting);
         *  Shtrih.PrintString ();
         *
         *  if (Shtrih.ResultCode == 0)
         *  {
         *      Shtrih.WaitForPrinting();
         *  }
         *  else if (Shtrih.ResultCode == 88)
         *  {
         *      Shtrih.ContinuePrint();
         *  }
         *  else
         *  {
         *      Mf.TopMost = true;
         *     // Mf.button3.Visible = true;
         *      Mf.SetCpt(Shtrih.ResultCodeDescription);
         *      Mf.ShowDialog();
         *      res = Mf.Result;
         *  }
         * } while ((Mf.Result != -1) && (Shtrih.ResultCode != 0));
         * Mf.Close();
         *
         * Mf.Dispose();
         * if (Shtrih.ResultCode == 0)
         * {
         *  res = 0;
         * }
         * return res;
         * */
        //        Shtrih.PrintString();
        //       return 0;
        //  }

        //        private static void mPrintStringWithFont()
        //      {

        /*
         * MessageForm Mf = new MessageForm(Shtrih.ResultCodeDescription);
         *
         * do
         * {
         *  Shtrih.PrintStringWithFont ();
         *
         *  if (Shtrih.ResultCode == 0)
         *  {
         *      Shtrih.WaitForPrinting();
         *  }
         *  else if (Shtrih.ResultCode == 88)
         *  {
         *      Shtrih.ContinuePrint();
         *  }
         *  else
         *  {
         *      Mf.SetCpt(Shtrih.ResultCodeDescription);
         *      Mf.ShowDialog();
         *  }
         * } while ((Mf.Result == 1) && (Shtrih.ResultCode != 0));
         * Mf.Close();
         * Mf.Dispose();
         * */
        //       Shtrih.PrintStringWithFont();
        //  }



        public static void ZReportWithCashIncome(decimal IncomeSumm)
        {
            ShtrihCommandBlock CashIncomeCommandBlock = new ShtrihCommandBlock();

            string status = "";

            if (Shtrih2.ClosedSmena(out status))
            {
                CashIncomeCommandBlock.Sale(1, 0, "", 1, 0);
                CashIncomeCommandBlock.CloseCheck(0, 0, 0, 0, 1, 0, 0, 0, "", null);
            }

            CashIncomeCommandBlock.WriteTableInt(1, 1, 2, 1, new List <int>());
            CashIncomeCommandBlock.PrintReportWithCleaning();
            if (IncomeSumm > 0)
            {
                CashIncomeCommandBlock.CashIncome(IncomeSumm);
            }
            CashIncomeCommandBlock.CommandBlockToQwery();
        }
Esempio n. 7
0
        public static ZReportData ZReport()
        {
            ZReportData Data = new ZReportData();

            if (iniFile.FiskalDriverNonShtrih)
            {
                FiskalDrivers.FiskalDriver.PrintZReport();
            }
            else
            {
                if (PDiscountCard.CloseCheck.CheckUnClosedChecks())
                {
                    Data = Shtrih2.GetPreZReportData();
                    Shtrih2.ZReport();
                    Data.DtZRep = DateTime.Now;
                    if (iniFile.SpoolEnabled)
                    {
                        Spool.SpoolCreator.AddZReportToSpool(Data);
                    }
                }
            }
            return(Data);
        }
Esempio n. 8
0
        static public void MainClass2_OnOutCasseta(int Summ, bool Casseta)
        {
            //ToShtrih.PrintOutKassetaReport(Summ, Casseta);

            if (iniFile.FCCZZRepCassetRemove)
            {
                if (Casseta)
                {
                    Utils.ToLog("CurentShtrihCash OutCasseta S");
                    decimal CurentShtrihCash = Shtrih2.GetCashReg(241);
                    Utils.ToLog("CurentShtrihCash OutCasseta E");
                    ToShtrih.ZReportWithCashIncome(CurentShtrihCash - Summ / 100);
                }
                else
                {
                    ToShtrih.CashOutCome(Summ / 100);
                    ToShtrih.PrintOutKassetaReport(Summ / 100, Casseta);
                }
            }
            else
            {
                ToShtrih.PrintOutKassetaReport(Summ / 100, Casseta);
            }
        }
Esempio n. 9
0
        internal static void EOD()
        {
            try
            {
                Utils.ToLog("Закрытие дня");

                //RunExport();

                try
                {
                    if ((iniFile.FRSEnabled) && (iniFile.FRSMaster))
                    {
                        FRSClientApp.FRSClient.ZReport(AlohainiFile.BDate);
                    }

                    if (iniFile.TRPOSXEnables)
                    {
                        if (!TrPosXAlohaIntegrator.Sverka())
                        {
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = true;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                        else
                        {
                            PDiscountCard.CloseCheck.ZeroPlastNum();
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = false;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                    }
                    if (iniFile.ArcusEnabled)
                    {
                        if (!ArcusAlohaIntegrator.Sverka())
                        {
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = true;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                        else
                        {
                            PDiscountCard.CloseCheck.ZeroPlastNum();
                            FiskInfo fi = PDiscountCard.CloseCheck.ReadFiskInfo();
                            fi.NeedSverka = false;
                            PDiscountCard.CloseCheck.WriteFiskInfo(fi);
                        }
                    }

                    /*
                     * if (iniFile.InPasEnabled)
                     * {
                     *  DualConnector.DualConnectorMain.Sverka();
                     * }
                     * */
                    if (CreditCardAlohaIntegration.CreditCardConnectorEnabled)
                    {
                        CreditCardAlohaIntegration.RunSverka();
                    }
                }
                catch (Exception ee)
                {
                    Utils.ToLog(ee.Message);
                }



                do
                {
                    Thread.CurrentThread.Join(3000);
                }while (MainClass.FiskalPrinterIsPrinting);

                string Status = "";

                if (!iniFile.FRSEnabled)
                {
                    Utils.ToLog("!iniFile.FRSEnabled");
                    if (iniFile.FiskalDriverNonShtrih)
                    {
                        Utils.ToLog("iniFile.FiskalDriverNonShtrih");
                        FiskalDrivers.FiskalDriver.PrintZReport();
                        Hamster.HamsterWorker.MoveHamster();
                    }
                    else
                    {
                        if (!Shtrih2.ClosedSmenaInternal(out Status))
                        {
                            //Shtrih2.ZReport();
                            ZReport();
                        }
                        else
                        {
                            Utils.ToLog("Принтер с закрытой сменой. Status :" + Status);
                        }
                    }

                    /*
                     * if (iniFile.FiskalDriverNonShtrihAlohaReport)
                     * {
                     *
                     * }
                     * */
                }

                /*
                 * else
                 * {
                 * if (!Shtrih2.ClosedSmenaInternal(out Status))
                 * {
                 *
                 *  RunFiskalChanger();
                 * }
                 * else
                 * {
                 *  Utils.ToLog("Принтер с закрытой сменой. Status :" + Status);
                 * }
                 * }
                 */
                Shtrih2.ExitFiskalThread();
            }
            catch (Exception e)
            {
                Utils.ToLog(e.Message);
            }
        }
        public void OnClockTick()
        {
            //if (File.Exists(@"C:\Aloha\Check\FiskalChanger.exe")) //А касса ли это?

            //AlohaEventVoids.TrySendZReport();

            /*
             * if (MainClass.TrPosxEnable)
             * {
             *  if (MainClass.DeletedPayment > -1)
             *  {
             *
             *      if (MainClass.DeletedPaymentTry < 10)
             *      {
             *          if (DateTime.Now > MainClass.DeletedPaymentDateTime.AddSeconds(1))
             *          {
             *              Utils.ToCardLog("Удаляяю оплату. Попытка: " + MainClass.DeletedPaymentTry);
             *              if (AlohaTSClass.DeletePayment(MainClass.DeletedPaymentCheck, MainClass.DeletedPayment))
             *              {
             *                  Utils.ToCardLog("Успешно удалил оплату. ");
             *                  MainClass.DeletedPayment = -1;
             *                  MainClass.DeletedPaymentTry = 0;
             *              }
             *              else
             *              {
             *                  MainClass.DeletedPaymentTry++;
             *              }
             *          }
             *      }
             *      else
             *      {
             *          MainClass.DeletedPayment = -1;
             *          MainClass.DeletedPaymentTry = 0;
             *      }
             *  }
             *
             * }
             */



            //Стоп лист
            if (MainClass.TimeTic.AddSeconds(300) < DateTime.Now)
            {
                MainClass.TimeTic = DateTime.Now;

                /*
                 * if (iniFile.StopListOff)
                 * {
                 *  return;
                 * }
                 */
                if ((MainClass.CurentMaster != -1) || MainClass.IamIsMaster)
                {
                    if ((MainClass.CurentMaster == AlohaTSClass.GetTermNum()) || MainClass.IamIsMaster)
                    {
                        MainClass.WHThreadThreadStopList.Set();
                    }
                }

                else
                {
                    MainClass.CurentMaster = DownTimeiniFile.GetMaster();
                }
            }


            //Сообщение
            if (Shtrih2.NeedShowMsg)
            {
                Shtrih2.ShowMessageExt();
            }

            //throw new NotImplementedException();
        }
Esempio n. 11
0
        static internal bool GetCheckColor(Check Ch)
        {
            FiskInfo Fi = ReadFiskInfo();

            if (!Fi.IsMod)
            {
                return(true);
            }

            if (Ch.Vozvr)
            {
                return(true);
            }

            /*
             * if (Ch.Tender!=   TenderType.Cash)
             * {
             *  return true;
             * }
             */
            if (Ch.HasNonCashPayment())
            {
                return(true);
            }

            if ((Ch.TableNumber >= 200) && (Ch.TableNumber <= 240))
            {
                return(true);// FoodFox
            }


            //Shtrih.RegisterNumber = 241;
            // Shtrih.GetCashReg();


            decimal CurentShtrihCash = 5000;

            if (!iniFile.FiskalDriverNonShtrih)
            {
                try
                {
                    Utils.ToLog("CurentShtrihCash S");
                    CurentShtrihCash = Shtrih2.GetCashReg(241);
                    Utils.ToLog("CurentShtrihCash E");
                }
                catch (Exception e)
                {
                    Utils.ToCardLog("[Error] CurentShtrihCash " + e.Message);
                }
            }


            if (CurentShtrihCash < 5000)
            {
                return(true);
            }
            foreach (Dish D in Ch.Dishez)
            {
                if (AlohaTSClass.DishIsTort(D.BarCode))
                {
                    return(true);
                }
            }

            /*
             * if (Ch.CompId != 0)
             * {
             *  return true;
             * }
             */
            if ((Ch.CompId == 8) || (Ch.CompId == 53))
            {
                return(true);
            }


            try
            {
                if (AlohaTSClass.GetVip(Ch.AlohaCheckNum))
                {
                    Utils.ToCardLog("VIP");
                    return(true);
                }
            }
            catch
            {
            }

            try
            {
                int    P     = 0;
                int    V     = 0;
                string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
                if (DCard.Length > 4)
                {
                    if (DCard.Substring(0, 3).ToUpper() == "ZAV")
                    {
                        try
                        {
                            string n   = DCard.Substring(3);
                            int    num = Convert.ToInt32(n);
                            if (SuperCardsZAV.Contains(num))
                            {
                                Utils.ToCardLog("card");
                                return(true);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            { }

            if (VerifyCheckPercent())
            {
                Utils.ToLog("Hamster");
                return(true);
            }

            /*
             * if (RegWorker.GetRegModType() == 3) //Азарика
             * {
             *  Utils.ToCardLog("ModType3");
             *  if ((DateTime.Now.Hour >= 8) && (DateTime.Now.Hour < 22))
             *
             *  //&& (DateTime.Now.DayOfWeek != DayOfWeek.Saturday) && (DateTime.Now.DayOfWeek != DayOfWeek.Sunday))
             *  {
             *      int P = 0;
             *      int V = 0;
             *      string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
             *      if (DCard.Length > 4)
             *      {
             *          if ((DCard.Substring(0, 3).ToUpper() == "ZAV") || (DCard.Substring(0, 3).ToUpper() == "VIP"))
             *          {
             *              return false;
             *          }
             *          else if (Ch.CompId == 2)
             *          {
             *              return false;
             *          }
             *          else
             *          {
             *              return true;
             *          }
             *
             *      }
             *      else if (Ch.CompId == 2)
             *      {
             *          return false;
             *      }
             *      else
             *      {
             *          return true;
             *      }
             *  }
             * }
             *
             */


            if (RegWorker.GetRegModType() == 2)
            {
                if ((DateTime.Now.Hour >= 8) && (DateTime.Now.Hour < 22))

                //&& (DateTime.Now.DayOfWeek != DayOfWeek.Saturday) && (DateTime.Now.DayOfWeek != DayOfWeek.Sunday))
                {
                    Utils.ToCardLog("ModType2");
                    int    P     = 0;
                    int    V     = 0;
                    string DCard = AlohaTSClass.GetDiscountAttr((int)Ch.AlohaCheckNum, out P, out V);
                    if (DCard.Length > 4)
                    {
                        if ((DCard.Substring(0, 3).ToUpper() == "ZAV") || (DCard.Substring(0, 3).ToUpper() == "VIP"))
                        {
                            return(false);
                        }
                        else if (Ch.CompId == 2)
                        {
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else if (Ch.CompId == 2)
                    {
                        return(false);
                    }
                    else if (Ch.Summ > 2500)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            //else
            {
                if ((Ch.CompId == 6) || (Ch.CompId == 54)) //с собой
                {
                    return(false);
                }

                DateTime dt2 = DateTime.Now;
                //  dt2 = AlohaTime(Ch.OpenTimeStr);
                if (dt2 > DateTime.Now)
                {
                    dt2.AddDays(-1);
                }


                if ((Ch.CheckTimeLong < Fi.MaxLong) && (Ch.CheckTimeLong > Fi.MinLong))
                {
                    if ((Ch.Summ < Fi.BigSum) && (Ch.Summ > Fi.LowSum))
                    {
                        //if (Ch.CompId == 0)
                        {
                            Random R = new Random();
                            if (R.Next(1, 100) > Fi.HiPercent)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Esempio n. 12
0
        static void CloseCheckQuere()
        {
            try
            {
                DirectoryInfo Di = new DirectoryInfo(ChecksPath);
                if (!Di.Exists)
                {
                    Di.Create();
                }

                while (!mExitCloseCheckThread)
                {
                    try
                    {
                        //  CreateCloseCheckFileEventWaitHandle.WaitOne();
                        try
                        {
                            foreach (FileInfo fi in Di.GetFiles("*.0"))
                            {
                                try
                                {
                                    Utils.ToCardLog("Очередь на фискальник. Файл " + fi.Name);
                                    String State1FileName = fi.FullName.Substring(0, fi.FullName.Length - 1) + "1";
                                    String State2FileName = fi.FullName.Substring(0, fi.FullName.Length - 1) + "2";
                                    Check  Ch             = ReadCheckFromTmp(fi.FullName);

                                    if (iniFile.FRSEnabled)
                                    {
                                        continue;

                                        /*
                                         * try
                                         * {
                                         *  Utils.ToCardLog("FRSEnabled");
                                         *  if (Ch.GuidId == null) { Ch.GuidId = Guid.NewGuid(); }
                                         *
                                         *  String State5FileName = fi.FullName.Substring(0, fi.FullName.Length - 2) + Ch.GuidId.ToString() + ".5"; //FRS
                                         *  Utils.ToCardLog("State5FileName: " + State5FileName);
                                         *  if (File.Exists(State5FileName))
                                         *  {
                                         *      Utils.ToCardLog("Exist. Delete: ");
                                         *      File.Delete(State5FileName);
                                         *  }
                                         *  fi.CopyTo(State5FileName);
                                         *
                                         *  try
                                         *  {
                                         *      Utils.ToCardLog("fi.MoveTo(State2FileName): " + State2FileName);
                                         *      fi.MoveTo(State2FileName);
                                         *  }
                                         *  catch (Exception e)
                                         *  {
                                         *      Utils.ToCardLog("Error fi.MoveTo(State2FileName):  " + e.Message);
                                         *  }
                                         *  continue;
                                         * }
                                         * catch (Exception e)
                                         * {
                                         *  Utils.ToCardLog("Error FRSEnabled " + e.Message);
                                         * }
                                         * try
                                         * {
                                         *  Utils.ToCardLog("Переименовываю в  " + State2FileName);
                                         *  fi.MoveTo(State2FileName); //Нужен грамотный lock
                                         * }
                                         * catch (Exception ee)
                                         * {
                                         *  Utils.ToCardLog("Error Переименовываю в  " + State2FileName + " " + ee.Message);
                                         * }
                                         */
                                    }
                                    else
                                    {
                                        if (File.Exists(State1FileName))
                                        {
                                            Utils.ToCardLog("Существует " + State1FileName + " переношу в папку багов");
                                            if (!Directory.Exists(BugChecksPath))
                                            {
                                                Directory.CreateDirectory(BugChecksPath);
                                            }
                                            fi.MoveTo(BugChecksPath + fi.Name);
                                            continue;
                                        }

                                        Utils.ToCardLog("Переименовываю в  " + State1FileName);
                                        fi.MoveTo(State1FileName); //Нужен грамотный lock
                                    }

                                    if (Ch != null)
                                    {
                                        if (myAllChecks.Checks.Where(a => a.CheckNum == Ch.CheckNum && a.Summ == Ch.Summ && a.SystemDateOfOpen == Ch.SystemDateOfOpen).Count() > 0)
                                        {
                                            Utils.ToCardLog("Чек присутствует в myAllChecks " + Ch.CheckNum);
                                            fi.Delete();
                                            continue;
                                        }


                                        if (Shtrih2.QuereContainsChk(Ch))
                                        {
                                            Utils.ToCardLog("Чек уже присутствует в очереди закрытия " + Ch.CheckNum);
                                            continue;
                                        }


                                        if ((Ch.HasFiskalPayment() && Ch.Summ != 0) && (!iniFile.NOLocalFR) && (!iniFile.FRSEnabled))
                                        {
                                            Utils.ToCardLog("Отправляю в фискальную очередь  ");
                                            if (!iniFile.FiskalDriverNonShtrih)
                                            {
                                                Ch.FiskalFileName = State1FileName;
                                                ToShtrih.CloseCheck2(Ch);
                                            }
                                            else
                                            {
                                                Utils.ToCardLog("iniFile.FiskalDriverNonShtrih");
                                                if (FiskalDrivers.FiskalDriver.CloseCheck(Utils.GetFiskalCheck(Ch)))
                                                {
                                                    fi.MoveTo(State2FileName);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Utils.ToCardLog("Нет фискальных платежей либо локального ФР");
                                            fi.MoveTo(State2FileName);
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    Utils.ToCardLog("[Error] Очередь на фискальник. Файл " + fi.Name + " Err " + e.Message);
                                }
                            }
                        }
                        catch
                        { }
                        //  CreateCloseCheckFileEventWaitHandle.Set();

                        WriteCheck2FileEventWaitHandle.WaitOne();
                        try
                        {
                            foreach (FileInfo fi in Di.GetFiles("*.2"))
                            {
                                try
                                {
                                    Utils.ToCardLog("*.2 Find " + fi.FullName);
                                    String State3FileName = fi.FullName.Substring(0, fi.FullName.Length - 1) + "3";
                                    Check  Ch             = ReadCheckFromTmp(fi.FullName);
                                    if (File.Exists(Ch.FiskalFileName))
                                    {
                                        File.Delete(Ch.FiskalFileName);
                                    }

                                    if (Ch != null)
                                    {
                                        if (iniFile.SpoolEnabled)
                                        {
                                            //if (Ch.ConSolidateSpoolDishez.Count > 0)
                                            {
                                                Spool.SpoolCreator.AddToSpoolFile(Ch);
                                            }
                                        }
                                        if (iniFile.JMSEnable)
                                        {
                                            //if (Ch.ConSolidateSpoolDishez.Count > 0)
                                            {
                                                JMSSendQuereChecks.Add(Ch);
                                                //Thread th = new Thread(SendJms);
                                                //th.Start(Ch);
                                            }
                                        }

                                        if (iniFile.AlohaFlyExportEnabled)
                                        {
                                            AlohaFlyExport.AlohaFlyExportHelper exp = new AlohaFlyExport.AlohaFlyExportHelper();
                                            exp.SendOrderFlightAsync(Ch);
                                        }
                                    }
                                    if (iniFile.FRSEnabled)
                                    {
                                        String State6FileName = fi.FullName.Substring(0, fi.FullName.Length - 2) + Ch.GuidId.ToString() + ".6"; //FRS
                                        fi.MoveTo(State6FileName);
                                    }
                                    else
                                    {
                                        fi.MoveTo(State3FileName);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Utils.ToCardLog("Error2  *.2 Find " + fi.FullName);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Utils.ToCardLog("Error *.2 Find " + e.Message);
                        }
                        WriteCheck2FileEventWaitHandle.Set();

                        foreach (FileInfo fi in Di.GetFiles("*.3"))
                        {
                            //if ()

                            if (!iniFile.HamsterDisabled)
                            {
                                Check Ch = ReadCheckFromTmp(fi.FullName);
                                try
                                {
                                    AllChecks myAllChecks2 = ReadAllChecks(ChecksPath + @"\hamster.xml");
                                    if ((myAllChecks2.Checks.Count == 0) && File.Exists(ChecksPath + @"\hamster.xml"))
                                    {
                                        File.Copy(ChecksPath + @"\hamster.xml", ChecksPath + @"\hamster" + Guid.NewGuid() + ".xml");
                                    }
                                    myAllChecks2.Checks.Add(Ch);
                                    WriteAllChecks(myAllChecks2);
                                    fi.Delete();
                                }
                                catch (Exception ee)
                                {
                                    Utils.ToCardLog("[Error] CloseCheckQuere state 3 " + ee.Message);
                                }
                                myAllChecks.AddChk(Ch);
                            }
                            else
                            {
                                fi.Delete();
                            }
                        }

                        foreach (FileInfo fi in Di.GetFiles("*.6"))
                        {
                            try
                            {
                                //Check Ch = ReadCheckFromTmp(fi.FullName);
                                Hamster.HamsterWorker.SendHamsterChk(fi.FullName);
                            }
                            catch (Exception ee)
                            {
                                Utils.ToCardLog("[Error] CloseCheckQuere state 6 " + ee.Message);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Utils.ToCardLog("[Error] CloseCheckQuere " + e.Message);
                    }
                    Thread.Sleep(200);
                }
            }
            catch (Exception ee)
            {
                Utils.ToCardLog("[Error] CloseCheckQuere2 " + ee.Message);
            }
        }