Пример #1
0
        private void downloadInvoices(HttpContext context)
        {
            byte     productId       = 0;
            int      invoiceId       = 0;
            string   quotationNumber = string.Empty;
            string   accountName     = string.Empty;
            string   mobile          = string.Empty;
            string   email           = string.Empty;
            string   ipAddress       = string.Empty;
            int      accountId       = 0;
            int      employeeId      = 0;
            int      ownerShipId     = 0;
            byte     statusId        = 0;
            sbyte    channelId       = 0;
            byte     billingModeId   = 1;
            bool     isdownload      = true;
            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["InvoiceId"] != null && !int.TryParse(context.Request["InvoiceId"].ToString(), out invoiceId))
            //    GenerateErrorResponse(400, string.Format("InvoiceId must be a number"));
            if (context.Request["QuotationNumber"] != null)
            {
                quotationNumber = context.Request["QuotationNumber"].ToString();
            }
            if (context.Request["AccountName"] != null)
            {
                accountName = context.Request["AccountName"].ToString();
            }
            //if (context.Request["AccountId"] != null && !int.TryParse(context.Request["AccountId"].ToString(), out accountId))
            //    GenerateErrorResponse(400, string.Format("AccountId must be a number"));
            //if (context.Request["EmployeeId"] != null && !int.TryParse(context.Request["EmployeeId"].ToString(), out employeeId))
            //    GenerateErrorResponse(400, string.Format("EmployeeId must be a number"));
            //if (context.Request["OwnerShipId"] != null && !int.TryParse(context.Request["OwnerShipId"].ToString(), out ownerShipId))
            //    GenerateErrorResponse(400, string.Format("OwnerShipId must be a number"));
            if (context.Request["StatusId"] != null && !byte.TryParse(context.Request["StatusId"].ToString(), out statusId))
            {
                GenerateErrorResponse(400, string.Format("StatusId must be a number"));
            }
            //if (context.Request["ChannelId"] != null && !sbyte.TryParse(context.Request["ChannelId"].ToString(), out channelId))
            //    GenerateErrorResponse(400, string.Format("ChannelId must be a number"));
            if (context.Request["BillingModeId"] != null && !byte.TryParse(context.Request["BillingModeId"].ToString(), out billingModeId))
            {
                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 invoiceTablePreferences = new TablePreferences("", "", true, false);
            Dictionary <string, TablePreferences> invoiceDictionary = new Dictionary <string, TablePreferences>();

            invoiceDictionary.Add("Invoices", invoiceTablePreferences);
            OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON);
            //JObject jobj = new JObject();
            context.Response.Write(client.GetInvoices(productId: productId, invoiceId: invoiceId, quotationNumber: quotationNumber, accountId: accountId,
                                                      employeeId: employeeId, ownerShipId: ownerShipId, statusId: statusId, channelId: channelId, ipAddress: ipAddress,
                                                      billingModeId: billingModeId, fromDateTime: fromDateTime, toDateTime: toDateTime, pageNumber: pageNumber, limit: limit,
                                                      mobile: mobile, email: email, accountName: accountName, tablePreferences: invoiceDictionary, isdownload: isdownload));
            //string resp = jobj.ToString();
            //if (isdownload == false)
            //  context.Response.Write(jobj);
        }
Пример #2
0
        private void Search(HttpContext context)
        {
            byte     productId       = 0;
            int      invoiceId       = 0;
            string   quotationNumber = string.Empty;
            string   accountName     = string.Empty;
            string   mobile          = string.Empty;
            string   email           = string.Empty;
            int      accountId       = 0;
            int      employeeId      = 0;
            int      ownerShipId     = 0;
            byte     statusId        = 0;
            sbyte    channelId       = 0;
            string   ipAddress       = string.Empty;
            byte     billingModeId   = 1;
            bool     isdownload      = false;
            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("InvoiceId") != null && !int.TryParse(searchData.SelectToken("InvoiceId").ToString(), out invoiceId))
            {
                GenerateErrorResponse(400, string.Format("QuotationId must be a number"));
            }
            if (searchData.SelectToken("QuotationNumber") != null)
            {
                quotationNumber = searchData.SelectToken("QuotationNumber").ToString();
            }
            if (searchData.SelectToken("AccountName") != null)
            {
                accountName = searchData.SelectToken("AccountName").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("EmployeeId") != null && !int.TryParse(searchData.SelectToken("EmployeeId").ToString(), out employeeId))
            {
                GenerateErrorResponse(400, string.Format("EmployeeId must be a number"));
            }
            if (searchData.SelectToken("OwnerShipId") != null && !int.TryParse(searchData.SelectToken("OwnerShipId").ToString(), out ownerShipId))
            {
                GenerateErrorResponse(400, string.Format("OwnerShipId must be a number"));
            }
            if (searchData.SelectToken("StatusId") != null && !byte.TryParse(searchData.SelectToken("StatusId").ToString(), out statusId))
            {
                GenerateErrorResponse(400, string.Format("StatusId must be a number"));
            }
            if (searchData.SelectToken("ChannelId") != null && !sbyte.TryParse(searchData.SelectToken("ChannelId").ToString(), out channelId))
            {
                GenerateErrorResponse(400, string.Format("ChannelId must be a number"));
            }
            if (searchData.SelectToken("BillingModeId") != null && !byte.TryParse(searchData.SelectToken("BillingModeId").ToString(), out billingModeId))
            {
                GenerateErrorResponse(400, string.Format("BillingModeId 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"));
            }
            if (searchData.SelectToken("Mobile") != null)
            {
                mobile = searchData.SelectToken("Mobile").ToString();
            }
            if (searchData.SelectToken("Email") != null)
            {
                email = searchData.SelectToken("Email").ToString();
            }
            TablePreferences invoiceTablePreferences = new TablePreferences("", "", true, false);
            Dictionary <string, TablePreferences> invoiceDictionary = new Dictionary <string, TablePreferences>();

            invoiceDictionary.Add("Invoices", invoiceTablePreferences);
            OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON);
            context.Response.Write(client.GetInvoices(productId: productId, invoiceId: invoiceId, quotationNumber: quotationNumber, accountId: accountId,
                                                      employeeId: employeeId, ownerShipId: ownerShipId, statusId: statusId, channelId: channelId, ipAddress: ipAddress,
                                                      billingModeId: billingModeId, fromDateTime: fromDateTime, toDateTime: toDateTime, pageNumber: pageNumber, limit: limit,
                                                      mobile: mobile, email: email, accountName: accountName, tablePreferences: invoiceDictionary, isdownload: isdownload));
        }