Example #1
0
        /// <summary>
        /// Hàm mở tài khoản mới
        /// </summary>
        /// <param name="req">chuối ký tự định dạng xml</param>
        private void OpenOneAccount(XmlDocument req)
        {
            string custId;
            string catId;

            try
            {
                _resXml.function_name = this.ToString() + ".OpenOneAccount";
                if (req.SelectSingleNode("//request/customer_id") != null && string.IsNullOrEmpty(req.SelectSingleNode("//request/customer_id").InnerText) == false)
                {
                    custId = req.SelectSingleNode("//request/customer_id").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "Customer id is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/categories_id") != null && string.IsNullOrEmpty(req.SelectSingleNode("//request/categories_id").InnerText) == false)
                {
                    catId = req.SelectSingleNode("//request/categories_id").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "Categories id is null or empty");
                    return;
                }
                _resXml = _meA.Insert(catId, custId);
            }
            catch (Exception ex)
            {
                _resXml.SetError("99", ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Hàm bán hàng.
        /// </summary>
        /// <param name="req"></param>
        private void Retail(XmlDocument req)
        {
            string  account_id;
            string  trancode;
            decimal amount;
            string  desc;

            try
            {
                _resXml.function_name = this.ToString() + ".Retail";
                if (req.SelectSingleNode("//request/account_id") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/account_id").InnerText) == false)
                {
                    account_id = req.SelectSingleNode("//request/account_id").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "account_id is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/trancode") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/trancode").InnerText) == false)
                {
                    trancode = req.SelectSingleNode("//request/trancode").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "trancode is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/amount") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/amount").InnerText) == false)
                {
                    amount = Convert.ToDecimal(req.SelectSingleNode("//request/amount").InnerText);
                }
                else
                {
                    _resXml.SetError("98", "amount is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/descript") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/descript").InnerText) == false)
                {
                    desc = req.SelectSingleNode("//request/descript").InnerText;
                }
                else
                {
                    desc = "";
                }
                _resXml = _meT.Retail(trancode, account_id, amount, desc);
            }
            catch (Exception ex)
            {
                _resXml.SetError("99", ex.Message);
            }
        }
Example #3
0
        private void Analysis()
        {
            res = new xml_response();
            res.function_name = this.ToString() + ".Analysis()";
            try
            {
                string cmdstr = doc.SelectSingleNode("//request/function_name").InnerText;
                switch (cmdstr.ToLower())
                {
                case "createaccountrole":
                    CreateRole();
                    break;

                case "checkaccountbalance":
                    if (!CheckAccountBalance())
                    {
                        res.SetError("61", "Invalid balance day");
                    }
                    break;
                }
            }
            catch (Exception ex)
            { res.SetError("99", ex.Message); }
        }
Example #4
0
        /// <summary>
        /// hàm mở hồ sơ khách hàng
        /// </summary>
        /// <param name="req">chuỗi ký tự theo định dạng xml</param>
        private void OpenOneCustomer(XmlDocument req)
        {
            string cust_name;
            string cust_cert;
            string cust_add;

            try
            {
                _resXml.function_name = this.ToString() + ".OpenOneCustomer";
                if (req.SelectSingleNode("//request/name") != null && string.IsNullOrEmpty(req.SelectSingleNode("//request/name").InnerText) == false)
                {
                    cust_name = req.SelectSingleNode("//request/name").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "Customer name is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/identity_card") != null && string.IsNullOrEmpty(req.SelectSingleNode("//request/identity_card").InnerText) == false)
                {
                    cust_cert = req.SelectSingleNode("//request/identity_card").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "Customer identity card is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/address") != null && string.IsNullOrEmpty(req.SelectSingleNode("//request/address").InnerText) == false)
                {
                    cust_add = req.SelectSingleNode("//request/address").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "Customer address is null or empty");
                    return;
                }

                _resXml = _meCust.Insert(cust_name, cust_add, cust_cert);
            }
            catch (Exception ex)
            {
                _resXml.SetError("99", ex.Message);
            }
        }
Example #5
0
        public string Request(string xmlstring)
        {
            try
            {
                _resXml = new xml_response();
                _resXml.function_name = "Request";
                if (logger.IsDebugEnabled)
                {
                    logger.Debug(string.Format("Request String {0}", xmlstring));
                }
                if (_channel.Security == true)
                {
                    _reqXml = new xml_request(_channel.Key, xmlstring);
                }
                else
                {
                    _reqXml = new xml_request(xmlstring);
                }

                // không xác định được chuối ký tự yêu cầu.
                if (_reqXml.ValidData == false)
                {
                    _resXml.SetError("98", "Invalid data input");
                }
                else
                {
                    _doc = (_reqXml.doc);

                    //====== DEBUG ======
                    if (logger.IsDebugEnabled)
                    {
                        logger.Debug(string.Format("Request String (DECRYPT)\n{0}", _doc.InnerXml));
                    }
                    //====== DEBUG ======

                    // kết nối đã được khởi tạo
                    // thực hiện hàm
                    XmlNode node = _doc.SelectSingleNode("//request/function_name");
                    switch (node.InnerText.ToLower())
                    {
                    case "opencustomer":
                        OpenOneCustomer(_doc);
                        break;

                    case "openaccount":
                        OpenOneAccount(_doc);
                        break;

                    case "closeaccount":
                        CloseOneAccount(_doc);
                        break;

                    case "retail":
                        Retail(_doc);
                        break;

                    case "addfund":
                        Retail(_doc);
                        break;

                    case "reverse":
                        Reverse(_doc);
                        break;

                    case "fundtransfer":
                        FundTransfer(_doc);
                        break;

                    case "customer":
                        Customer(_doc);
                        break;

                    case "account":
                        Account(_doc);
                        break;

                    case "transaction":
                        Transaction(_doc);
                        break;

                    default:
                        // không tìm thấy hàm thực hiện chức năng này
                        //_resXml.SetError("97", "Invalid function");
                        ServiceTest st = new ServiceTest(_doc);
                        _resXml = st.Response;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                _resXml.SetError("99", ex.Message);
                _resXml.function_name = this.ToString() + ".Request(string xmlstring)";
                logger.Error(string.Format("{0}", ex.Message));
            }
            // ==========================
            // Trả kế quả về cho client
            // ==========================
            if (_channel.Security == true)
            {
                return(_resXml.response_string(_channel.Key));
            }
            else
            {
                return(_resXml.response_string());
            }
        }
Example #6
0
        /// <summary>
        /// Hàm chuyển khoản
        /// </summary>
        /// <param name="req"></param>
        private void FundTransfer(XmlDocument req)
        {
            string  trancode;
            string  from_acc;
            string  to_acc;
            decimal amnt;
            string  desc;

            try
            {
                _resXml.function_name = this.ToString() + ".FundTransfer";
                // lấy tham số
                if (req.SelectSingleNode("//request/trancode") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/trancode").InnerText) == false)
                {
                    trancode = req.SelectSingleNode("//request/trancode").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "trancode is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/db_account_id") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/db_account_id").InnerText) == false)
                {
                    from_acc = req.SelectSingleNode("//request/db_account_id").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "db_account_id is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/cr_account_id") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/cr_account_id").InnerText) == false)
                {
                    to_acc = req.SelectSingleNode("//request/cr_account_id").InnerText;
                }
                else
                {
                    _resXml.SetError("98", "cr_account_id is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/amount") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/amount").InnerText) == false)
                {
                    amnt = Convert.ToDecimal(req.SelectSingleNode("//request/amount").InnerText);
                }
                else
                {
                    _resXml.SetError("98", "amount is null or empty");
                    return;
                }
                if (req.SelectSingleNode("//request/descript") != null &&
                    string.IsNullOrEmpty(req.SelectSingleNode("//request/descript").InnerText) == false)
                {
                    desc = req.SelectSingleNode("//request/descript").InnerText;
                }
                else
                {
                    desc = "";
                }
                _resXml = _meT.Fundtransfer(trancode, from_acc, to_acc, amnt, desc);
            }
            catch (Exception ex)
            {
                _resXml.SetError("99", ex.Message);
            }
        }