Пример #1
0
        private void Sale(decimal money, string terminalId, bool oneStep = false)
        {
            AnsSale    sale;
            string     str    = decimal.ToInt32(money * 100M).ToString("d");
            PipeClient client = new PipeClient();

            client.Logger = Logger;
            string message = string.Empty;

            try
            {
                if (oneStep)
                {
                    message = client.SendPipeMessage("<?xml version='1.0' encoding='windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<info>\r\n\t\t<reqStatus/>\r\n\t</info>\r\n</TCLib>", 0x1388, true);
                    AnsStatus status = (AnsStatus)this.ExtractMessage(message, typeof(AnsStatus));
                }
                //base.CallBack("SetInfo", this._saleWaitingMessage);
                Logger("Ждем", EventEntryType.Event);
                message = client.SendPipeMessage(CardOperationType.reqSaleCard, string.Format("<?xml version='1.0' encoding='Windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<card>\r\n\t\t<reqSaleCard>\r\n\t\t\t<amount>{0}</amount>\r\n\t\t\t<terminalID>{1}</terminalID>\r\n\t\t\t<operation>{2}</operation>\r\n\t\t</reqSaleCard>\r\n\t</card>\r\n</TCLib>", str, terminalId, this.OperationID), 0x1e848, true);
                sale    = (AnsSale)this.ExtractMessage(message, typeof(AnsSale));
            }
            catch (MrkErrorException exception)
            {
                string str3 = string.Format("Ошибка продажи карты: {0}. Деньги возвращены на сдачу.", exception.Error.Description);
                //base.AllMoneyToBalance();
                //this.WriteEntry(str3, EventEntryType.Error);
                Logger(str3, EventEntryType.Error);
                //base.CallBack("SetError", str3);
                //base.CallBack("SetPrintStep", str3);
                return;
            }
            catch (Exception exception2)
            {
                //base.AllMoneyToBalance();
                Logger("Неожиданная ошибка продажи: " + exception2.ToString(), EventEntryType.Error);
                //base.CallBack("SetError", exception2.Message);
                //base.CallBack("SetPrintStep", "Ошибка продажи карты. Деньги возвращены на сдачу");
                return;
            }
            cardInfo cardInfo = sale.card.AnsSaleCard.CardInfo;

            //this.SetAccountInfo(cardInfo);
            object[] args = new object[] { Environment.NewLine, cardInfo.Description, (cardInfo.Balance / 100M).ToString("F"), cardInfo.Pan, this.CreateDate(cardInfo.Date) };
            string   str4 = string.Format("Не забудьте забрать карту!{0}{0}Информация о карте: {1}{0} Текущий баланс: {2} руб.{0}Номер карты: {3}{0}Срок действия: {4}{0}", args);

            Logger(str4, EventEntryType.Event);
            Thread.Sleep(200);
            //base.CallBack("SetPrintStep", "Не забудьте забрать карту!");
        }
Пример #2
0
        private void Add(decimal money, string terminalId)
        {
            decimal    num2 = money;
            AnsWrite   write;
            decimal    balance = 0M;
            string     str     = decimal.ToInt32(num2 * 100M).ToString("d");
            PipeClient client  = new PipeClient();

            client.Logger = Logger;
            try
            {
                //base.CallBack("SetInfo", this._addWaitingMessage);
                string str2 = client.SendPipeMessage(CardOperationType.reqWriteCard, string.Format("<?xml version='1.0' encoding='Windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<card>\r\n\t\t<reqWriteCard>\r\n\t\t\t<amount>{0}</amount>\r\n\t\t\t<terminalID>{1}</terminalID>\r\n\t\t\t<operation>{2}</operation>\r\n\t\t</reqWriteCard>\r\n\t</card>\r\n</TCLib>", str, terminalId, this.OperationID), 0x2ee0, true);
                write = (AnsWrite)this.ExtractMessage(str2, typeof(AnsWrite));
                //base.SetBalance(balance);
                //base.AddTotal(-balance);
            }
            catch (MrkErrorException exception)
            {
                Logger("Ошибка пополнения карты: " + exception.Error.Description, EventEntryType.Error);
                //this.BreakScenario("Ошибка пополнения карты: " + exception.Error.Description);
                return;
            }
            catch (Exception exception2)
            {
                Logger("Неожиданная ошибка пополнения: " + exception2.ToString(), EventEntryType.Error);
                //this.BreakScenario("Неожиданная ошибка пополнения: " + exception2.ToString());
                return;
            }
            cardInfo cardInfo = write.card.CardInfo.CardInfo;

            object[] args    = new object[] { Environment.NewLine, (cardInfo.Balance / 100M).ToString("F"), cardInfo.Pan, this.CreateDate(cardInfo.Date) };
            string   message = string.Format("Карта успешно пополнена.{0} Текущий баланс: {1} руб.{0}Номер карты: {2}{0}Срок действия: {3}{0}", args);

            //this.SetAccountInfo(cardInfo);
            Logger(message, EventEntryType.Event);
            //this.SendCancelCommand(false);
            //base.CallBack("SetPrintStep", message);
        }
Пример #3
0
        private void WorkFunction(object poolingType)
        {
            lock (_lockObject)
            {
                AnsStatus status;
                decimal   maxBalance;
                string    str;
                object[]  objArray;
                decimal   num3;
                int       num = 0;
                this._cancel = false;
                do
                {
                    try
                    {
                        str        = new PipeClient().SendPipeMessage(CardOperationType.reqStatus, "<?xml version='1.0' encoding='windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<info>\r\n\t\t<reqStatus/>\r\n\t</info>\r\n</TCLib>", 0x1388, false);
                        status     = (AnsStatus)this.ExtractMessage(str, typeof(AnsStatus));
                        maxBalance = status.info.MrkStatus.MaxBalance;
                        //base.CallBack("LiveSignal", "");
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        Logger("ERROR! Pooling exception: " + exception.Message, EventEntryType.Error);
                        goto Label_05A4;
                    }
                    Thread.Sleep(0x3e8);
                    if (++num > 20)
                    {
                        Logger("20 секунд прошло, а карту так и не приложили для чтения. Высылаем МРК команду \"Cancel\"", EventEntryType.Event);
                        this.SendCancelCommand(true);
                        goto Label_05A4;
                    }
                }while (!status.info.MrkStatus.CardPresent);
                CardOperationType type = (CardOperationType)poolingType;
                string            arg  = (type == CardOperationType.Info) ? "Пожалуйста, подождите. Получаем выписку по карте..." : "this._readCardMessage";
                //base.CallBack("SetStartPooling", arg);
                //base.CallBack("LiveSignal", "");
                cardInfo cardInfo = null;
                string   str3     = string.Empty;
                string   str4     = string.Empty;
                try
                {
                    AnsWait    wait;
                    PipeClient client = new PipeClient();
                    client.Logger = Logger;
                    if (type == CardOperationType.Info)
                    {
                        str  = client.SendPipeMessage(CardOperationType.Info, string.Format("<?xml version='1.0' encoding='Windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<card>\r\n\t\t<reqWaitCard>\r\n\t\t\t<timeout>{0}</timeout>\r\n\t\t\t<application>1</application>\r\n\t\t\t<getInfo>2</getInfo>\r\n\t\t</reqWaitCard>\r\n\t</card>\r\n</TCLib>", "30"), 0x30d40, true);
                        wait = (AnsWait)this.ExtractMessage(str, typeof(AnsWait));
                        str4 = "this.CreateInfo(wait)";
                        //this.SetAccountInfo(wait.card.AnsWaitCard.CardInfo);
                    }
                    else
                    {
                        str      = client.SendPipeMessage(CardOperationType.reqWaitCard, string.Format("<?xml version='1.0' encoding='Windows-1251'?>\r\n<TCLib version='3.04'>\r\n\t<card>\r\n\t\t<reqWaitCard>\r\n\t\t\t<timeout>{0}</timeout>\r\n\t\t\t<application>1</application>\r\n\t\t\t<getInfo>1</getInfo>\r\n\t\t</reqWaitCard>\r\n\t</card>\r\n</TCLib>", "30"), 0x9c40, true);
                        wait     = (AnsWait)this.ExtractMessage(str, typeof(AnsWait));
                        cardInfo = wait.card.AnsWaitCard.CardInfo;
                        string[] strArray = cardInfo.Description.Split(new char[] { ',' });
                        string   str5     = (strArray.Length > 1) ? (", " + strArray[1]) : string.Empty;
                        this._maxValue = (maxBalance - cardInfo.Balance) / 100M;
                        objArray       = new object[4];
                        objArray[0]    = Environment.NewLine;
                        num3           = cardInfo.Balance / 100M;
                        objArray[1]    = num3.ToString("F").Replace(",", ".") + " руб." + str5;
                        objArray[2]    = cardInfo.Pan;
                        objArray[3]    = this.CreateDate(cardInfo.Date);
                        str3           = string.Format("Текущий баланс: {1}{0}Номер карты: {2}{0}Срок действия: {3}{0}", objArray) + ((this._maxValue > 0M) ? string.Format("Максимальная сумма пополнения: {0} руб.", this._maxValue) : "Карта пополнена на максимальную сумму");
                    }
                }
                catch (MrkErrorException exception2)
                {
                    string message = string.Format("Ошибка ожидания карты: {0}", exception2.Error.Description);
                    Logger(message, EventEntryType.Error);
                    if (exception2.Error.Code == 0x68)
                    {
                        this.SendCancelCommand(true);
                    }
                    else
                    {
                        //base.CallBack("SetCrashScreen", message);
                        Logger(string.Format("{0}: {1}", "SetCrashScreen", message), EventEntryType.Error);
                    }
                    goto Label_05A4;
                }
                catch (Exception exception4)
                {
                    //this.SetErrorScreen("Unexpected. Ошибка ожидания карты: " + exception4.ToString(), "Ошибка ожидания карты.", true);
                    Logger("Unexpected. Ошибка ожидания карты: " + exception4.ToString() + " Ошибка ожидания карты.", EventEntryType.Error);
                    goto Label_05A4;
                }
                switch (type)
                {
                case CardOperationType.reqWriteCard:
                    Logger("Пополнение. Дождались карту: " + Environment.NewLine + str3, EventEntryType.Event);
                    //this.SetAccountInfo(cardInfo);
                    //base.CallBack("SetWaitCardResult", str3);
                    Logger(String.Format("{0}; {1}", "SetWaitCardResult", str3), EventEntryType.Event);
                    if (this._maxValue > 0M)
                    {
                        //base.CallBack("SetButtonNext", "");
                    }
                    break;

                case CardOperationType.Balance:
                    Logger("Просмотр баланса. Дождались карту: " + str3, EventEntryType.Event);
                    //base.CallBack("SetBalanceResult", str3);
                    break;

                case CardOperationType.reqChangePin:
                    Logger("Смена пинкода. Дождались карту: " + str3, EventEntryType.Event);
                    //base.CallBack("StartChangePin", string.Empty);
                    break;

                case CardOperationType.reqPayment:
                    objArray    = new object[4];
                    objArray[0] = Environment.NewLine;
                    num3        = cardInfo.Balance / 100M;
                    objArray[1] = num3.ToString("F").Replace(",", ".");
                    objArray[2] = cardInfo.Pan;
                    objArray[3] = this.CreateDate(cardInfo.Date);
                    str3        = string.Format("Доступная для оплаты сумма: {1} руб.{0}Номер карты: {2}{0}Срок действия: {3}{0}", objArray);
                    Logger("Оплата по карте. Дождались карту: " + str3, EventEntryType.Event);
                    //base.CallBack("SetPan", cardInfo.Pan);
                    //base.CallBack("SetWaitCardResult", str3);
                    //base.CallBack("SetButtonNext", "");
                    break;

                case CardOperationType.Info:
                    //base.CallBack("SetDataGrid", str4);
                    break;
                }
                Label_05A4 :;
            }
        }