Example #1
0
        public int CallArcusOper(ArcusOp Operation, ArcusRequest inParams, ArcusResponse outParams)
        {
            int Result = -1;

            if (Operation > 0)
            {
                IntPtr pos_obj = IntPtr.Zero;
                try
                {
                    pos_obj = CreateITPos();

                    if (pos_obj == IntPtr.Zero)
                    {
                        return(-1);
                    }

                    if (inParams != null)
                    {
                        foreach (var p in typeof(ArcusRequest).GetProperties())
                        {
                            if (p.GetArcusNonSerialized())
                            {
                                continue;
                            }
                            if (p.GetValue(inParams, null) != null)
                            {
                                string val = p.GetValue(inParams, null).ToString();

                                if (val.Length > 0 && val != "0")
                                {
                                    ITPosSet(pos_obj, p.GetArcusFieldName().GetASCIIBytes(), p.GetValue(inParams, null).GetASCIIBytes(), -1);
                                }
                            }
                        }
                    }

                    Result = ITPosRun(pos_obj, (int)Operation);

                    foreach (var p in typeof(ArcusResponse).GetProperties())
                    {
                        object resValue;
                        try
                        {
                            int    size  = ITPosGet(pos_obj, p.GetArcusFieldName().GetASCIIBytes(), null, -1);
                            byte[] value = new byte[size + 1];

                            ITPosGet(pos_obj, p.GetArcusFieldName().GetASCIIBytes(), value, value.Length);

                            //var resValue = Encoding.ASCII.GetString(value).Trim('\0');
                            resValue = Encoding.ASCII.GetString(value);
                        }
                        catch (Exception e)
                        {
                            Utils.ToCardLog("Error CallArcusOper SetValue prop: " + p.Name + " err: " + e.Message);
                            resValue = e.Message;
                        }
                        p.SetValue(outParams, resValue, null);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    ITPosClear(pos_obj);
                }
                if (pos_obj != IntPtr.Zero)
                {
                    DeleteITPos(pos_obj);
                }
            }

            return(Result);
        }
Example #2
0
        private void RunOper()
        {
            try
            {
                Utils.ToCardLog("Запуск RunOper OperType=" + OperType.ToString() + " Amount= " + Amount.ToString());
                OperInProcess = true;
                var arc     = new Arcus3Wrapper();
                var request = new ArcusRequest()
                {
                    Amount       = (int)Amount,
                    OriginalDate = DateTime.Now,
                    Currency     = "643",
                };
                var response = new ArcusResponse();


                Utils.ToCardLog(String.Format("[RunOper] Запрос операции. Входящий запрос: " + request.ToString()));
                int res = arc.CallArcusOper(OperType, request, response);

                //
                //      Request.Amount = (Amount).ToString();
                //    Request.OperationCode = OperType;
                //  Request.CurrencyCode = "643";
//                Request.DateTimeHost = DateTime.Now.ToString("yyyyMMddHHmmss");

                //Conn.InitResources();
                //Conn.Exchange(ref  Request, ref  Response, 10);

                RespCode = response.Response_code.Trim();

                Utils.ToCardLog(String.Format("[RunOper] Операция выполнена res: " + res + "; Результат:  " + response.ToString()));


                Receipt = ReadChequeFile();

                /*
                 *
                 * if (((RespCode == "00") || (RespCode == "000")) && (!Receipt.ToUpper().Contains("НЕ ОПЛАЧИВАТЬ")))
                 * {
                 *
                 * if ((OperType == Arcus3Wrapper.ArcusOp.Pay) || (OperType == Arcus3Wrapper.ArcusOp.Refund))
                 * {
                 *     string Tmp = Receipt;
                 *     if (!iniFile.Arcus2PrintOneSlip)
                 *     {
                 *         Tmp += Convert.ToChar(31) + Environment.NewLine;
                 *         Tmp += Receipt;
                 *         Receipt = Tmp;
                 *     }
                 *
                 *     try
                 *     {
                 *
                 *         Utils.ToCardLog("[RunOper] Добавляю Слип в Файл.");
                 *
                 *         ArcusSlips AS = Arcus2DataFromXML.ReadArcusSlips();
                 *         DateTime HDT = DateTime.Now;
                 *         try
                 *         {
                 *             HDT = Convert.ToDateTime(response.DateTimeCRM);
                 *         }
                 *         catch
                 *         { }
                 *
                 *         ArcusSlip S = new ArcusSlip()
                 *         {
                 *             HostDt = HDT,
                 *             Sum = Convert.ToDecimal(Response.Amount),
                 *             Void = (Response.OperationCode == 4),
                 *             Num = Response.TrxIDCRM,
                 *             RRN = Response.ReferenceNumber,
                 *             AlohaCheckId = AlohaCheckId,
                 *             AlohaCheckShortNum = AlohaCheckShortNum
                 *         };
                 *         string[] Str = Receipt.Split(char.ConvertFromUtf32(10)[0]);
                 *
                 *         foreach (string str in Str)
                 *         {
                 *             Utils.ToCardLog(str);
                 *             S.Slip.Add(str);
                 *         }
                 *
                 *         decimal SummFromTxt = GetSummFromSlip(S.Slip);
                 *
                 *         if ((SummFromTxt != 0) && (S.Sum != SummFromTxt * 100))
                 *         {
                 *             Utils.ToCardLog("Error Разные суммы в слипе " + SummFromTxt.ToString() + " и ответе от терминала. " + S.Sum.ToString());
                 *             S.Sum = SummFromTxt * 100;
                 *         }
                 *
                 *         AS.Slips.Add(S);
                 *
                 *         Arcus2DataFromXML.WriteArcusSlips(AS);
                 *
                 *         Utils.ToCardLog("[RunOper] Добавлил Слип в Файл.");
                 *
                 *     }
                 *     catch (Exception e)
                 *     {
                 *         Utils.ToCardLog("[Error] Ошибка добавления слипа в файл." + e.Message);
                 *     }
                 *
                 *
                 * }
                 * }
                 * else
                 * {
                 * try
                 * {
                 *     EventSenderClass.SendAlohaAsincEvent(StopListService.AlohaEventType.ErrorCreditCardterminal, "", AlohaTSClass.AlohaCurentState.WaterId,
                 *        AlohaTSClass.GetJobCode(AlohaTSClass.AlohaCurentState.WaterId),
                 *        "",
                 *      Convert.ToInt32(RespCode),
                 *        (int)AlohaTSClass.AlohaCurentState.TableId,
                 *        (int)AlohaTSClass.AlohaCurentState.CheckId);
                 * }
                 * catch
                 * { }
                 *
                 *
                 * }
                 * * */
                resOper = GetCodeDescr(RespCode);
                Utils.ToCardLog(String.Format("[RunOper] Sinc: " + Sinc + " RespCode: " + RespCode));
                if (!Sinc)
                {
                    RunOperationAsincComplitedVoid(OperType, RespCode.Trim(), resOper, Receipt);
                }
                OperInProcess = false;
                Utils.ToCardLog("Отработал RunOper OperType=" + OperType.ToString() + " Amount= " + Amount.ToString());
            }
            catch (Exception e)
            {
                resOper  = "Ошибка программы. " + e.Message;
                RespCode = "-1";
                if (!Sinc)
                {
                    RunOperationAsincComplitedVoid(OperType, RespCode, resOper, "");
                }
                Utils.ToCardLog("[Error] Запускa RunOper " + e.Message);
            }
        }