Пример #1
0
        public HttpResponseMessage Get()
        {
            HttpResponseMessage message = null;
            productListModel    prodMdl = new productListModel();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        DataTable dt = dbconn.getTable(appServiceQry._getMainProducts("27,28,29,73"));
                        if (dt.Rows.Count != 0)
                        {
                            List <productDetial> prdList = new List <productDetial>();
                            foreach (DataRow item in dt.Rows)
                            {
                                productDetial prodDetial = new productDetial();
                                prodDetial.productName = item["PRODUCT_NAME_MON"].ToString();
                                prodDetial.productId   = item["PRODUCT_ID"].ToString();
                                prodDetial.smsCode     = item["SMS_CODE"].ToString();
                                prodDetial.productImg  = httpUtil.getProductLogoUrl(item["PRODUCT_ID"].ToString());//"http://my.ddishtv.mn:808/products/bagts.png";
                                //prodDetial.additionalProducts = null;
                                //DataTable dtUp = dbconn.getTable(appServiceQry._getMainProducts(item["UPGRADE_PRODUCTS"].ToString()));
                                //List<addChennelDetial> upChannels = new List<addChennelDetial>();
                                //foreach(DataRow dr in dtUp.Rows)
                                //{
                                //    addChennelDetial upch = new addChennelDetial();
                                //    upch.productName = dr["PRODUCT_NAME_MON"].ToString();
                                //    upch.productId = dr["PRODUCT_ID"].ToString();
                                //    upch.smsCode = dr["SMS_CODE"].ToString();
                                //    upch.productImg = "http://my.ddishtv.mn:808/products/bagts.png";
                                //    upChannels.Add(upch);
                                //}
                                //prodDetial.upProducts = upChannels;
                                // ======================= price List awah =============================

                                DataTable dtPrice = dbconn.getTable(appServiceQry._getMainProductPrices(item["PRODUCT_ID"].ToString()));
                                string    priceP  = string.Empty;
                                if (dtPrice.Rows.Count != 0)
                                {
                                    priceP = dtPrice.Rows[0]["PRICE"].ToString();
                                }
                                prodDetial.price = priceP;
                                ////List<priceList> priceL = new List<priceList>();
                                ////foreach (DataRow rr in dtPrice.Rows)
                                ////{
                                ////    priceList price = new priceList();
                                ////    price.productId = rr["PRODUCT_ID"].ToString();
                                ////    price.price = rr["PRICE"].ToString();
                                ////    price.month = rr["MONTH"].ToString();
                                ////    priceL.Add(price);
                                ////}
                                ////prodDetial.priceList = priceL;

                                prdList.Add(prodDetial);
                            }
                            prodMdl.isSuccess     = true;
                            prodMdl.resultCode    = HttpStatusCode.OK.ToString();
                            prodMdl.resultMessage = appConstantValues.MSG_SUCCESS;
                            prodMdl.productList   = prdList;
                        }
                        else
                        {
                            prodMdl.isSuccess     = false;
                            prodMdl.resultCode    = HttpStatusCode.NotFound.ToString();
                            prodMdl.resultMessage = appConstantValues.MSG_NOFOUND;
                        }
                    }
                    else
                    {
                        prodMdl.isSuccess     = false;
                        prodMdl.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        prodMdl.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    prodMdl.isSuccess     = false;
                    prodMdl.resultCode    = HttpStatusCode.NotFound.ToString();
                    prodMdl.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                prodMdl.isSuccess     = false;
                prodMdl.resultCode    = HttpStatusCode.NotFound.ToString();
                prodMdl.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, prodMdl);
            LogWriter._channelList(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), "", serialzer.Serialize(prodMdl), token));
            return(message);
        }
Пример #2
0
        public async Task <HttpResponseMessage> Get(string searchVal)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            string             ip       = httpUtil.GetClientIPAddress(HttpContext.Current.Request);
            string             secToken = string.Empty;
            ProdutListResponse response = new ProdutListResponse();

            LogWriter._chargeProd(TAG, string.Format(@"[>>] Request: [{0}]", searchVal));
            try
            {
                secToken = HttpContext.Current.Request.Headers["Authorization"].Replace("Basic ", "").Trim();
                if (dbconn.idbStatOK())
                {
                    string insId    = string.Empty;
                    string insPhone = string.Empty;
                    if (dbconn.tabletCheckToken(secToken, out insId, out insPhone))
                    {
                        LogWriter._noti(TAG, string.Format(@"Request Token: [{0}], InstallerId: [{1}]", secToken, insId));
                        DataTable dt = dtS(searchVal);
                        if (dt.Rows.Count != 0)
                        {
                            string ccType = dt.Rows[0]["IS_PREPAID"].ToString();
                            string fname  = dt.Rows[0]["SUBSCRIBER_FNAME"].ToString();
                            string admin  = dt.Rows[0]["PHONE_NO"].ToString();
                            string card   = dt.Rows[0]["CARD_NO"].ToString();
                            if (ccType != "2")
                            {
                                DataTable            dtProd  = dbconn.getTable(appServiceQry._getMainProducts("27,28,29,73"));
                                List <productDetial> prdList = new List <productDetial>();
                                foreach (DataRow item in dtProd.Rows)
                                {
                                    productDetial prodDetial = new productDetial();
                                    prodDetial.productName = item["PRODUCT_NAME_MON"].ToString();
                                    prodDetial.productId   = item["PRODUCT_ID"].ToString();
                                    prodDetial.smsCode     = item["SMS_CODE"].ToString();
                                    prodDetial.productImg  = httpUtil.getProductLogoUrl(item["PRODUCT_ID"].ToString());
                                    DataTable dtPrice = dbconn.getTable(appServiceQry._getMainProductPrices(item["PRODUCT_ID"].ToString()));
                                    string    priceP  = string.Empty;
                                    if (dtPrice.Rows.Count != 0)
                                    {
                                        priceP = dtPrice.Rows[0]["PRICE"].ToString();
                                    }
                                    prodDetial.price = priceP;
                                    prdList.Add(prodDetial);
                                }
                                // additional channel list
                                DataTable dtAct = dbconn.getTable(tabletQuery.getActiveMainProducts(card, "27,28,29,73"));
                                DataTable dtAdd = new DataTable();
                                if (dtAct.Rows.Count != 0)
                                {
                                    string mProd = dtAct.Rows[0]["PRODUCT_ID"].ToString();
                                    dtAdd = dbconn.getTable(appServiceQry._getMainProducts(additionalProductSelector.getAddProd(mProd)));
                                }
                                else
                                {
                                    dtAdd = dbconn.getTable(appServiceQry._getMainProducts(additionalProductSelector.getAddProd("28")));
                                }
                                List <productDetial> addChannels = new List <productDetial>();
                                foreach (DataRow rf in dtAdd.Rows)
                                {
                                    productDetial prd = new productDetial();
                                    prd.productName = rf["PRODUCT_NAME_MON"].ToString();
                                    prd.productId   = rf["PRODUCT_ID"].ToString();
                                    prd.smsCode     = rf["SMS_CODE"].ToString();
                                    prd.productImg  = httpUtil.getProductLogoUrl(rf["PRODUCT_ID"].ToString());
                                    DataTable dtPrice = dbconn.getTable(appServiceQry._getMainProductPrices(rf["PRODUCT_ID"].ToString()));
                                    string    priceP  = string.Empty;
                                    if (dtPrice.Rows.Count != 0)
                                    {
                                        priceP = dtPrice.Rows[0]["PRICE"].ToString();
                                    }
                                    prd.price = priceP;
                                    addChannels.Add(prd);
                                }

                                response.isSuccess             = true;
                                response.errorCode             = Convert.ToString((int)HttpStatusCode.OK);
                                response.resultMessage         = "success";
                                response.firstName             = fname;
                                response.cardNo                = card;
                                response.adminNo               = admin;
                                response.productList           = prdList;
                                response.additionalProductList = addChannels;
                                response.ccType                = ccType;
                            }
                            else
                            {
                                response.isSuccess     = true;
                                response.errorCode     = Convert.ToString((int)HttpStatusCode.OK);
                                response.resultMessage = "Дараа төлбөрт хэрэглэгч";
                                response.firstName     = fname;
                                response.cardNo        = card;
                                response.adminNo       = admin;
                                response.ccType        = ccType;
                            }
                        }
                        else
                        {
                            response.isSuccess     = false;
                            response.errorCode     = Convert.ToString((int)HttpStatusCode.NotFound);
                            response.resultMessage = "Хайлтын үр дүн хоосон байна.";
                        }
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.errorCode     = Convert.ToString((int)HttpStatusCode.Unauthorized);
                        response.resultMessage = "Session has expired";
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                    response.resultMessage = "Internal Error";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, string.Format(@"Token: [{0}], Exception: [{1}]", secToken, ex.ToString()));
                response.isSuccess     = false;
                response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                response.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chargeProd(TAG, string.Format(@"[<<] ClientIp: [{0}], Response: [{1}]", ip, serializer.Serialize(response)));
            return(message);
        }
Пример #3
0
        public HttpResponseMessage Get(string productId)
        {
            HttpResponseMessage   message      = null;
            productAdditionDetial prdAddDetial = new productAdditionDetial();
            string token = HttpContext.Current.Request.Headers["Authorization"].Replace("Bearer ", "").Trim();

            try
            {
                if (dbconn.idbCheck(out dbres))
                {
                    string userCardNo  = string.Empty;
                    string userAdminNo = string.Empty;
                    if (dbconn.checkToken(token, out userCardNo, out userAdminNo))
                    {
                        DataTable dtCh = dbconn.getTable(appServiceQry._getMainProducts(productId));
                        if (dtCh.Rows.Count != 0)
                        {
                            //DataTable dtUp = dbconn.getTable(appServiceQry._getMainProducts(dtCh.Rows[0]["UPGRADE_PRODUCTS"].ToString()));
                            //List<productDetial> upChannels = new List<productDetial>();
                            //foreach (DataRow dr in dtUp.Rows)
                            //{
                            //    productDetial upch = new productDetial();
                            //    upch.productName = dr["PRODUCT_NAME_MON"].ToString();
                            //    upch.productId = dr["PRODUCT_ID"].ToString();
                            //    upch.smsCode = dr["SMS_CODE"].ToString();
                            //    upch.productImg = httpUtil.getProductLogoUrl(dr["PRODUCT_ID"].ToString());
                            //    upChannels.Add(upch);
                            //}
                            DataTable            dtAdd       = dbconn.getTable(appServiceQry._getMainProducts(additionalProductSelector.getAddProd(productId)));
                            List <productDetial> addChannels = new List <productDetial>();
                            foreach (DataRow rf in dtAdd.Rows)
                            {
                                productDetial prd = new productDetial();
                                prd.productName = rf["PRODUCT_NAME_MON"].ToString();
                                prd.productId   = rf["PRODUCT_ID"].ToString();
                                prd.smsCode     = rf["SMS_CODE"].ToString();
                                prd.productImg  = httpUtil.getProductLogoUrl(rf["PRODUCT_ID"].ToString());
                                DataTable dtPrice = dbconn.getTable(appServiceQry._getMainProductPrices(rf["PRODUCT_ID"].ToString()));
                                string    priceP  = string.Empty;
                                if (dtPrice.Rows.Count != 0)
                                {
                                    priceP = dtPrice.Rows[0]["PRICE"].ToString();
                                }
                                prd.price = priceP;
                                addChannels.Add(prd);
                            }
                            prdAddDetial.productId          = productId;
                            prdAddDetial.upProducts         = null;
                            prdAddDetial.additionalProducts = addChannels;
                            prdAddDetial.isSuccess          = true;
                            prdAddDetial.resultCode         = HttpStatusCode.OK.ToString();
                            prdAddDetial.resultMessage      = appConstantValues.MSG_SUCCESS;
                        }
                        else
                        {
                            prdAddDetial.isSuccess     = false;
                            prdAddDetial.resultCode    = HttpStatusCode.NotFound.ToString();
                            prdAddDetial.resultMessage = appConstantValues.MSG_NOFOUND;
                        }
                    }
                    else
                    {
                        prdAddDetial.isSuccess     = false;
                        prdAddDetial.resultCode    = HttpStatusCode.Unauthorized.ToString();
                        prdAddDetial.resultMessage = appConstantValues.MSG_EXPIRED;
                    }
                }
                else
                {
                    prdAddDetial.isSuccess     = false;
                    prdAddDetial.resultCode    = HttpStatusCode.NotFound.ToString();
                    prdAddDetial.resultMessage = appConstantValues.MSG_INTERNAL_ERROR;
                    LogWriter._error(TAG, dbres);
                }
            }
            catch (Exception ex)
            {
                exceptionManager.ManageException(ex, TAG);
                prdAddDetial.isSuccess     = false;
                prdAddDetial.resultCode    = HttpStatusCode.NotFound.ToString();
                prdAddDetial.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, prdAddDetial);
            LogWriter._channelList(TAG, string.Format("IP: [{0}], Request: [{1}], Response: [{2}], Token: [{3}]", httpUtil.GetClientIPAddress(HttpContext.Current.Request), productId, serialzer.Serialize(prdAddDetial), token));
            return(message);
        }
Пример #4
0
        public async Task <HttpResponseMessage> Get(string cardNo, string pref)
        {
            HttpResponseMessage message = new HttpResponseMessage();
            string ip       = httpUtil.GetClientIPAddress(HttpContext.Current.Request);
            string secToken = string.Empty;
            additionalProductListResponse response = new additionalProductListResponse();

            LogWriter._chargeProd(TAG, string.Format(@"[>>] Request: [Card:{0}, Pref:{1}]", cardNo, pref));
            try
            {
                secToken = HttpContext.Current.Request.Headers["Authorization"].Replace("Basic ", "").Trim();
                if (dbconn.idbStatOK())
                {
                    string insId    = string.Empty;
                    string insPhone = string.Empty;
                    if (dbconn.tabletCheckToken(secToken, out insId, out insPhone))
                    {
                        DataTable dtAct = dbconn.getTable(tabletQuery.getActiveMainProducts(cardNo, "27,28,29,73"));
                        DataTable dtAdd = new DataTable();
                        if (dtAct.Rows.Count != 0)
                        {
                            string mProd = dtAct.Rows[0]["PRODUCT_ID"].ToString();
                            dtAdd = dbconn.getTable(appServiceQry._getMainProducts(additionalProductSelector.getAddProd(mProd)));
                        }
                        else
                        {
                            dtAdd = dbconn.getTable(appServiceQry._getMainProducts(additionalProductSelector.getAddProd("28")));
                        }
                        List <productDetial> addChannels = new List <productDetial>();
                        foreach (DataRow rf in dtAdd.Rows)
                        {
                            productDetial prd = new productDetial();
                            prd.productName = rf["PRODUCT_NAME_MON"].ToString();
                            prd.productId   = rf["PRODUCT_ID"].ToString();
                            prd.smsCode     = rf["SMS_CODE"].ToString();
                            prd.productImg  = httpUtil.getProductLogoUrl(rf["PRODUCT_ID"].ToString());
                            DataTable dtPrice = dbconn.getTable(appServiceQry._getMainProductPrices(rf["PRODUCT_ID"].ToString()));
                            string    priceP  = string.Empty;
                            if (dtPrice.Rows.Count != 0)
                            {
                                priceP = dtPrice.Rows[0]["PRICE"].ToString();
                            }
                            prd.price = priceP;
                            addChannels.Add(prd);
                        }
                        response.isSuccess     = true;
                        response.errorCode     = Convert.ToString((int)HttpStatusCode.OK);
                        response.resultMessage = "success";
                        response.productList   = addChannels;
                    }
                    else
                    {
                        response.isSuccess     = false;
                        response.errorCode     = Convert.ToString((int)HttpStatusCode.Unauthorized);
                        response.resultMessage = "Session has expired";
                    }
                }
                else
                {
                    response.isSuccess     = false;
                    response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                    response.resultMessage = "Internal Error";
                }
            }
            catch (Exception ex)
            {
                LogWriter._error(TAG, string.Format(@"Token: [{0}], Exception: [{1}]", secToken, ex.ToString()));
                response.isSuccess     = false;
                response.errorCode     = Convert.ToString((int)HttpStatusCode.InternalServerError);
                response.resultMessage = ex.Message;
            }
            message = Request.CreateResponse(HttpStatusCode.OK, response);
            LogWriter._chargeProd(TAG, string.Format(@"[<<] ClientIp: [{0}], Response: [{1}]", ip, serializer.Serialize(response)));
            return(message);
        }