Ejemplo n.º 1
0
        private void downloadOrderActivations(HttpContext context)
        {
            byte     productId    = 0;
            int      accountId    = 0;
            string   accountName  = string.Empty;
            string   mobile       = string.Empty;
            string   email        = string.Empty;
            string   number       = string.Empty;
            byte     orderStatus  = 0;
            byte     billingMode  = 1;
            DateTime fromDateTime = DateTime.Now.Date;
            DateTime toDateTime   = DateTime.Now.AddDays(1).AddTicks(-1);
            int      pageNumber   = 1;
            byte     limit        = 20;

            if (context.Request["ProductId"] != null && !byte.TryParse(context.Request["productId"].ToString(), out productId))
            {
                GenerateErrorResponse(400, string.Format("ProductId must be a number"));
            }
            if (context.Request["Number"] != null)
            {
                number = context.Request["Number"].ToString();
            }
            if (context.Request["AccountName"] != null)
            {
                accountName = context.Request["AccountName"].ToString();
            }
            if (context.Request["OrderStatus"] != null && !byte.TryParse(context.Request["OrderStatus"].ToString(), out orderStatus))
            {
                GenerateErrorResponse(400, string.Format("OrderStatus must be a number"));
            }
            if (context.Request["BillingMode"] != null && !byte.TryParse(context.Request["BillingMode"].ToString(), out billingMode))
            {
                GenerateErrorResponse(400, string.Format("BillingModeId must be a number"));
            }
            if (context.Request["mobile"] != null)
            {
                mobile = Convert.ToString(context.Request["mobile"]);
            }
            if (context.Request["email"] != null)
            {
                email = Convert.ToString(context.Request["email"]);
            }
            if (context.Request["FromDateTime"] != null)
            {
                fromDateTime = Convert.ToDateTime(context.Request["fromDateTime"]);
            }
            if (context.Request["ToDateTime"] != null)
            {
                toDateTime = Convert.ToDateTime(context.Request["ToDateTime"]);
            }

            TablePreferences ordersTablePreferences = new TablePreferences("", "", true, false);
            Dictionary <string, TablePreferences> ordersDictionary = new Dictionary <string, TablePreferences>();

            ordersDictionary.Add("Orders", ordersTablePreferences);

            OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON);
            context.Response.Write(client.GetOrders(productId: productId, accountId: accountId, mobile: mobile, email: email, orderStatus: orderStatus,
                                                    number: number, billingMode: billingMode, fromDateTime: fromDateTime, toDateTime: toDateTime,
                                                    accountName: accountName, pageNumber: pageNumber, limit: limit, tablePreferences: ordersDictionary, isdownload: true));
        }
Ejemplo n.º 2
0
        private void Search(HttpContext context)
        {
            byte     productId    = 0;
            int      accountId    = 0;
            string   accountName  = string.Empty;
            string   mobile       = string.Empty;
            string   email        = string.Empty;
            string   number       = string.Empty;
            byte     orderStatus  = 0;
            byte     billingMode  = 1;
            DateTime fromDateTime = DateTime.Now.Date;
            DateTime toDateTime   = DateTime.Now.AddDays(1).AddTicks(-1);
            int      pageNumber   = 1;
            byte     limit        = 20;


            JObject searchData = new JObject();

            searchData = JObject.Parse(context.Request["SearchData"]);
            if (searchData.SelectToken("ProductId") != null && !byte.TryParse(searchData.SelectToken("ProductId").ToString(), out productId))
            {
                GenerateErrorResponse(400, string.Format("ProductId must be a number"));
            }
            if (searchData.SelectToken("Number") != null)
            {
                number = searchData.SelectToken("Number").ToString();
            }
            if (searchData.SelectToken("AccountId") != null && !int.TryParse(searchData.SelectToken("AccountId").ToString(), out accountId))
            {
                GenerateErrorResponse(400, string.Format("AccountId must be a number"));
            }
            if (searchData.SelectToken("Mobile") != null)
            {
                mobile = searchData.SelectToken("Mobile").ToString();
            }
            if (searchData.SelectToken("AccountName") != null)
            {
                accountName = searchData.SelectToken("AccountName").ToString();
            }
            if (searchData.SelectToken("Email") != null)
            {
                email = searchData.SelectToken("Email").ToString();
            }
            if (searchData.SelectToken("OrderStatus") != null && !byte.TryParse(searchData.SelectToken("OrderStatus").ToString(), out orderStatus))
            {
                GenerateErrorResponse(400, string.Format("OrderStatus must be a number"));
            }
            if (searchData.SelectToken("BillingMode") != null && !byte.TryParse(searchData.SelectToken("BillingMode").ToString(), out billingMode))
            {
                GenerateErrorResponse(400, string.Format("BillingMode must be a number"));
            }
            if (searchData.SelectToken("FromDateTime") != null && !DateTime.TryParse(searchData.SelectToken("FromDateTime").ToString(), out fromDateTime))
            {
                GenerateErrorResponse(400, string.Format("FromDateTime is not a valid datetime"));
            }
            if (searchData.SelectToken("ToDateTime") != null && !DateTime.TryParse(searchData.SelectToken("ToDateTime").ToString(), out toDateTime))
            {
                GenerateErrorResponse(400, string.Format("ToDateTime is not a valid datetime"));
            }
            if (searchData.SelectToken("PageNumber") != null && !int.TryParse(searchData.SelectToken("PageNumber").ToString(), out pageNumber))
            {
                GenerateErrorResponse(400, string.Format("PageNumber must be a number"));
            }
            if (searchData.SelectToken("Limit") != null && !byte.TryParse(searchData.SelectToken("Limit").ToString(), out limit))
            {
                GenerateErrorResponse(400, string.Format("Limit must be a number"));
            }
            TablePreferences ordersTablePreferences = new TablePreferences("", "", true, false);
            Dictionary <string, TablePreferences> ordersDictionary = new Dictionary <string, TablePreferences>();

            ordersDictionary.Add("Orders", ordersTablePreferences);

            OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON);
            context.Response.Write(client.GetOrders(productId: productId, accountId: accountId, mobile: mobile, email: email, orderStatus: orderStatus,
                                                    number: number, billingMode: billingMode, fromDateTime: fromDateTime, toDateTime: toDateTime,
                                                    accountName: accountName, pageNumber: pageNumber, limit: limit, tablePreferences: ordersDictionary, isdownload: false));
        }