Exemple #1
0
        public static void End(IEnumerable <OKCProcesses> okcProcesseses, Members requestMembers,
                               Members responseMembers, string message)
        {
            OKCProcesses okcProcesses = okcProcesseses.LastOrDefault();

            if (okcProcesses == null)
            {
                return;
            }
            okcProcesses.ProcessDateTime.EndDateTime      = DateTime.Now;
            okcProcesses.ProcessDateTime.TotalProcessTime =
                okcProcesses.ProcessDateTime.EndDateTime - okcProcesses.ProcessDateTime.StartDateTime;
            okcProcesses.ProcessResult.Code        = responseMembers.InternalErrNum;
            okcProcesses.ProcessResult.Description = message;
            okcProcesses.OKCSerialNumber           = responseMembers.FiscalId;
            okcProcesses.ProcessRequest.OkcRequest =
                responseMembers.InternalErrNum == null ? null : (object)requestMembers;
            okcProcesses.ProcessResponse.RawResponse = message;
            okcProcesses.ProcessResponse.OkcResponse =
                responseMembers.InternalErrNum == null ? null : (object)responseMembers;
            File.WriteAllText(Path.Combine(FolderPath, GetFileName()), JsonConvert.SerializeObject(okcProcesseses,
                                                                                                   new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));
        }
 private static void SetLogger()
 {
     OKCProcesses.CreateIfNotExistsPanaromaLogFolderAndFile();
     OKCProcesses.Load(out _okcProcesseses);
 }
        public void DoWork()
        {
            WorkerExceptionHandle workerExceptionHandle = null;

            try
            {
                SetLogger();
                SetSalesLogStat(true);
                OKCParameters oKCParameter = JsonConvert.DeserializeObject <OKCParameters>(TcpCommand.Content);
                OKCProcesses.Start(ref _okcProcesseses, TcpCommand, oKCParameter);
                string type = oKCParameter.Type;
                switch (type)
                {
                case "1":
                {
                    TryReceiptBegin(oKCParameter);
                    break;
                }

                case "2":
                {
                    TryDoTransaction(oKCParameter);
                    break;
                }

                case "3":
                {
                    TryDoBatchTransaction(oKCParameter);
                    break;
                }

                case "4":
                {
                    TryDoPayment(oKCParameter);
                    break;
                }

                case "5":
                {
                    TryReceiptEnd();
                    break;
                }

                case "6":
                {
                    TryFreePrint(oKCParameter);
                    break;
                }

                case "7":
                {
                    TryGetReceiptTotal();
                    break;
                }

                case "8":
                {
                    break;
                }

                case "9":
                {
                    TryPrintZReport();
                    break;
                }

                case "10":
                {
                    TryPrintXReport();
                    break;
                }

                case "11":
                {
                    TryGetOKCStatus();
                    break;
                }

                case "12":
                {
                    TryGMP3Pair();
                    break;
                }

                case "13":
                {
                    TryPrintXPLUSaleReport(oKCParameter);
                    break;
                }

                case "14":
                {
                    TryPrintXPLUProgram(oKCParameter);
                    break;
                }

                case "15":
                {
                    TryPrintEkuDetailReport();
                    break;
                }

                case "16":
                {
                    TryPrintEkuZDetailReport();
                    break;
                }

                case "17":
                {
                    TryPrintEkuReceiptDetailReportWithDatetime(oKCParameter);
                    break;
                }

                case "18":
                {
                    TryPrintLastSaleReceiptCopy();
                    break;
                }

                case "19":
                {
                    TryPrintSalesReportWihtZNo(oKCParameter);
                    break;
                }

                case "20":
                {
                    TryPrintBankEOD();
                    break;
                }

                case "21":
                {
                    TryOpenDrawer();
                    break;
                }

                case "22":
                {
                    TryRestartApp();
                    break;
                }

                case "23":
                {
                    TryPowerOFF();
                    break;
                }

                case "24":
                {
                    TrySetEcrConfig(oKCParameter);
                    break;
                }

                case "25":
                {
                    TryPrintFinancalZDetailReportWithDateTime(oKCParameter);
                    break;
                }

                case "26":
                {
                    TryPrintFinancalZDetailReportWithZNo(oKCParameter);
                    break;
                }

                case "27":
                {
                    TryPrintFinancalZReportWithDateTime(oKCParameter);
                    break;
                }

                case "28":
                {
                    TryPrintFinancalZReportWithZNo(oKCParameter);
                    break;
                }

                case "29":
                {
                    TrySetGroup(oKCParameter);
                    break;
                }

                case "30":
                {
                    TryPrintLastZReportCopy();
                    break;
                }

                case "31":
                {
                    TryPrintBankSlipCopy(oKCParameter);
                    break;
                }

                case "32":
                {
                    TryPing();
                    break;
                }

                case "33":
                {
                    TryGetLastZReportSoftCopy();
                    break;
                }

                case "34":
                {
                    TryFreePrintList(oKCParameter);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                workerExceptionHandle = new WorkerExceptionHandle(ex);
            }
            finally
            {
                try
                {
                    if (_okc.ProcessInformation.HasError || workerExceptionHandle != null)
                    {
                        OKCResult.SetToCommunicationResult(true,
                                                           workerExceptionHandle != null
                                ? workerExceptionHandle.Exception.Message
                                : _okc.ProcessInformation.InformationMessages.Message, TcpCommand,
                                                           workerExceptionHandle != null
                                ? workerExceptionHandle.Exception
                                : _okc.ProcessInformation.InformationMessages.Exception, false);
                    }
                    else
                    {
                        OKCResult.SetToCommunicationResult(false, _okc.ProcessInformation.InformationMessages.Message,
                                                           TcpCommand, null, false);
                    }
                    OKCProcesses.End(_okcProcesseses, _okc.Request, _okc.Result,
                                     JsonConvert.SerializeObject(_okc.ProcessInformation.InformationMessages.Message));
                    _okcProcesseses.Clear();
                }
                catch
                {
                    _okcProcesseses.Clear();
                }
            }
        }