Exemplo n.º 1
0
        string FindFilial()
        {
            SvcTypeID = "0";
            if (Service.ToLower() == "rt-acc" && SvcTypeID == "0") // чтоб лишний раз не читать из БД
            {
                // Выберем филиал из таблицы

                try
                {
                    using (IDbConnection db = new SqlConnection(Settings.ConnectionString))
                    {
                        Log($"[FindFilial] select svcTypeId from oldigw.oldigw.filial where Num={Filial.ToInt()}");
                        SvcTypeID = db.Query <string>($"select svcTypeId from oldigw.oldigw.filial where Num={Filial.ToInt()}").FirstOrDefault();
                        Log($"Филилал={Filial} Найден код филиала={SvcTypeID}");
                    }
                }
                catch (SqlException se)
                {
                    RootLog($"{se.Message}, {se.LineNumber}");
                    RootLog($"[FindFilial]: {filial}");
                    return("0");
                }
            }

            Log($"[FindFilial]: {SvcTypeID}");

            return(SvcTypeID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Инициализация значений класса
        /// </summary>
        public override void InitializeComponents()
        {
            base.InitializeComponents();
            CodePage = "utf-8";
            tz       = Settings.Tz;

            agentAccount = "2839";
            commonName   = Settings.Rt.CN;
            host         = Settings.Rt.Host;
            // if (Gateway != "0" && Gateway != "")
            // {
            // int filial = 10;
            // if (!int.TryParse(Gateway, out filial))
            // if (Filial != 255)
            // filial = 10;

            Log("****CHECK: Service={0} Filial={1}", Service, Filial);
            try
            {
                if (!string.IsNullOrEmpty(Filial))
                {
                    if (Service.ToLower() == "rtk-acc")
                    {
                        if (Filial.ToInt() == -1)                                 // не число!
                        {
                            SvcTypeID = filial;
                        }
                        else
                        {
                            // Выберем филиал из таблицы
                            using (Oldigw db = new Oldigw())
                            {
                                IEnumerable <RTFilial> Filials = db.ExecuteQuery <RTFilial>(@"select svcTypeId from oldigw.oldigw.filial where Num={0}", Filial);
                                try
                                {
                                    SvcTypeID = Filials.First().SvcTypeId;
                                    RootLog("Филилал={0} Найден код филиала={1}", Filial, SvcTypeID);
                                }
                                catch
                                {
                                    SvcTypeID = "0";
                                    RootLog("Филилал={0} Код филиала не найден", Filial);
                                }
                            }
                        }
                    }
                    else
                    {
                        SvcTypeID = "0";
                    }
                }
            }
            catch (Exception ex)
            {
                RootLog("{0}\r\n{1}", ex.Message, ex.StackTrace);
            }


            if (string.IsNullOrEmpty(Phone))
            {
                SvcNum = Account;
                if (!string.IsNullOrEmpty(AccountParam))
                {
                    SvcSubNum = AccountParam;
                }
            }
            else
            {
                SvcNum = Phone;
                if (!string.IsNullOrEmpty(PhoneParam))
                {
                    SvcSubNum = PhoneParam;
                }
            }
            if (!string.IsNullOrEmpty(Comment))
            {
                SvcComment = Comment;
            }

            if (pcdate == DateTime.MinValue)
            {
                pcdate = DateTime.Now;
            }

            switch (RequestType.ToLower())
            {
            case "status":
                ReqType = "getPaymentStatus";
                break;

            case "payment":
                ReqType = "createPayment";
                break;

            case "undo":
                ReqType = "abandonPayment";
                break;

            case "check":
                ReqType = "checkPaymentParams";
                break;

            default:
                ReqType = RequestType;
                break;
            }

            if (!string.IsNullOrEmpty(Number))
            {
                queryFlag = Number;
            }
        }