Beispiel #1
0
        public async Task <int> GetMenuItemsByCriteria(List <MerchantIdentification_StoreName> lstAllMerchantStoreInformation)
        {
            TokenDetails            objTokenDetails            = new TokenDetails();
            MenuItemsSearchCriteria objMenuItemsSearchCriteria =
                new MenuItemsSearchCriteria()
            {
                storeid       = 1,
                offset        = 0,
                maxRecords    = 1000,
                searchString  = "",
                inventoryOnly = false,
                //categoryId = 123343//546862
            };

            string  jsonString         = JsonConvert.SerializeObject(objMenuItemsSearchCriteria);
            JObject objInputParameters = JObject.Parse(jsonString);

            foreach (var obj in lstAllMerchantStoreInformation)
            {
                using (HttpClient client = new HttpClient())
                {
                    objTokenDetails.SetHTTPClientObjectValues(client);
                    HttpResponseMessage response = await objTokenDetails.
                                                   ExecuteClientPostMethod("managemenu/menuitem/allmenuitems", objInputParameters, client, Token.securityToken, obj.merchantIdentification);

                    if (response.IsSuccessStatusCode)
                    {
                        objTokenDetails.SetRefreshToken(response);
                        var objRes = await response.Content.ReadAsStringAsync();

                        JObject jsonRes          = JObject.Parse(objRes);
                        JToken  jTokenItemResult = jsonRes.FindTokens("items").FirstOrDefault();

                        foreach (var jObjectItem in jTokenItemResult.Children())
                        {
                            AllMenuResultModel objMenu = JsonConvert.DeserializeObject <AllMenuResultModel>(jObjectItem.ToString());
                            if (objMenu != null && !lstAllMenuResultModel.Any(s => s.name == objMenu.name && s.categoryType == objMenu.categoryType))
                            {
                                lstAllMenuResultModel.Add(objMenu);
                            }
                        }
                    }
                }
            }

            LogHelper.Log("Menu Item and Category method completed. Count: " + lstAllMenuResultModel.Count() + " Time: " + DateTime.Now);

            //DataTable dt = lstAllMenuResultModel.ToDataTable();
            return(0);
        }
Beispiel #2
0
        public async Task <List <MerchantIdentification_StoreName> > GetEmployeeByCriteria(List <MerchantIdentification_StoreName> lstAllMerchantStoreInformation)
        {
            TokenDetails objTokenDetails = new TokenDetails();

            EmployeeSearchCriteria objReportSearchCriteria = new EmployeeSearchCriteria();

            objReportSearchCriteria.searchCriteria = new EmpInputModel();
            objReportSearchCriteria.searchCriteria =
                new EmpInputModel()
            {
                activeFilter = 1
            };

            string  jsonString         = JsonConvert.SerializeObject(objReportSearchCriteria);
            JObject objInputParameters = JObject.Parse(jsonString);

            List <EmployeeResultModel> lstEmployee = new List <EmployeeResultModel>();

            foreach (var obj in lstAllMerchantStoreInformation)
            {
                using (HttpClient client = new HttpClient())
                {
                    objTokenDetails.SetHTTPClientObjectValues(client);
                    HttpResponseMessage response = await objTokenDetails.
                                                   ExecuteClientPostMethod("manageemployee/getallemployees", objInputParameters, client, Token.securityToken, obj.merchantIdentification);

                    if (response.IsSuccessStatusCode)
                    {
                        objTokenDetails.SetRefreshToken(response);
                        var objRes = await response.Content.ReadAsStringAsync();

                        JObject jsonRes     = JObject.Parse(objRes);
                        JToken  jTokenUsers = jsonRes.FindTokens("users").FirstOrDefault();

                        foreach (JToken jobject in jTokenUsers.Children())
                        {
                            EmployeeResultModel objEmployee = JsonConvert.DeserializeObject <EmployeeResultModel>(jobject.ToString());
                            lstEmployee.Add(objEmployee);
                        }

                        // add employees in lstEmployee object
                        obj.lstEmployee = new List <EmployeeResultModel>();
                        obj.lstEmployee.AddRange(lstEmployee);
                    }
                }
            }

            return(lstAllMerchantStoreInformation);
        }
Beispiel #3
0
        public async Task <int> GetMenuUpdatesByCriteria(List <MerchantIdentification_StoreName> lstAllMerchantStoreInformation)
        {
            TokenDetails objTokenDetails = new TokenDetails();
            MenuUpdatesSearchCriteria objMenuItemsSearchCriteria =
                new MenuUpdatesSearchCriteria()
            {
                storeId    = 1,
                offset     = 0,
                maxRecords = 30
            };

            string  jsonString         = JsonConvert.SerializeObject(objMenuItemsSearchCriteria);
            JObject objInputParameters = JObject.Parse(jsonString);

            foreach (var obj in lstAllMerchantStoreInformation)
            {
                using (HttpClient client = new HttpClient())
                {
                    objTokenDetails.SetHTTPClientObjectValues(client);
                    HttpResponseMessage response = await objTokenDetails.ExecuteClientPostMethod("managemenu/getMenuUpdates", objInputParameters, client, Token.securityToken, obj.merchantIdentification);

                    if (response.IsSuccessStatusCode)
                    {
                        objTokenDetails.SetRefreshToken(response);
                        var objRes = await response.Content.ReadAsStringAsync();

                        //JObject jsonRes = JObject.Parse(objRes);
                        //JToken jTokenItemResult = jsonRes.FindTokens("items").FirstOrDefault();

                        //foreach (var jObjectItem in jTokenItemResult.Children())
                        //{
                        //    AllMenuResultModel objMenu = JsonConvert.DeserializeObject<AllMenuResultModel>(jObjectItem.ToString());
                        //    if (objMenu != null && !lstAllMenuResultModel.Any(s => s.name == objMenu.name && s.categoryType == objMenu.categoryType))
                        //        lstAllMenuResultModel.Add(objMenu);
                        //}
                    }
                }
            }

            //DataTable dt = lstAllMenuResultModel.ToDataTable();
            return(0);
        }
Beispiel #4
0
        public async Task <int> GetOrderHistoryByCriteriaTestNew(List <MerchantIdentification_StoreName> lstAllMerchantStoreInformation, string startdate, string enddate)
        {
            TokenDetails objTokenDetails = new TokenDetails();
            List <OrderDetailsExportFields> lstFinalResult = new List <OrderDetailsExportFields>();

            LogHelper.Log("Start Date: " + startdate + " End Date: " + enddate);
            foreach (var objAllMerchantStoreInformation in lstAllMerchantStoreInformation)
            {
                OrderHistorySearchCriteria objReportSearchCriteria = new OrderHistorySearchCriteria();
                objReportSearchCriteria.searchCriteria = new OrderHistoryInputParametersModel();
                objReportSearchCriteria.searchCriteria =
                    new OrderHistoryInputParametersModel()
                {
                    offset = 0,
                    limit  = 10000,
                    //searchString = "",
                    startDate = startdate,
                    endDate   = enddate,
                    //paymentTypes = new string[] { "CASH", "CCRD", "DCRD", "CHECK" },
                    orderStatus      = new string[] { "PAID", "PARTIAL_PAID", "OPEN" },
                    transactionTypes = new string[] { "SALE", "VOID", "REFUND", "PARTIALREFUND", "PARTIALVOID", "UPDATETIP" },
                    storeIds         = new int[] { 1 },
                    orderBy          = "firstPaymentDate",
                    //userId = objEmployee.id,//232741//

                    //Sale option
                    hideSale       = false, // To display only refund transaction
                    hideRefund     = true,  // To display only sales transaction
                    onlySplitCheck = false  // To display only split check transaction

                                            //Refund option
                                            //hideSale = true,  // To display only refund transaction
                                            //hideRefund = false, // To display only sales transaction
                                            //onlySplitCheck = false // To display only split check transaction

                                            //Split Check option
                                            //hideSale = false,  // To display only refund transaction
                                            //hideRefund = true, // To display only sales transaction
                                            //onlySplitCheck = true // To display only split check transaction
                };

                string  jsonString         = JsonConvert.SerializeObject(objReportSearchCriteria);
                JObject objInputParameters = JObject.Parse(jsonString);

                try
                {
                    string objRes = string.Empty;
                    OrderHistoryFullObject objOrderHistoryFullObject = null;
                    using (HttpClient client = new HttpClient())
                    {
                        objTokenDetails.SetHTTPClientObjectValues(client);
                        HttpResponseMessage response = await objTokenDetails.ExecuteClientPostMethod("order/getorderhistory", objInputParameters, client, Token.securityToken, objAllMerchantStoreInformation.merchantIdentification);

                        if (response.IsSuccessStatusCode)
                        {
                            objTokenDetails.SetRefreshToken(response);
                            objRes = await response.Content.ReadAsStringAsync();

                            objOrderHistoryFullObject = JsonConvert.DeserializeObject <OrderHistoryFullObject>(objRes);
                        }
                    }

                    //if (!string.IsNullOrEmpty(objRes) && !objRes.ToLower().Contains("records not found"))
                    if (objOrderHistoryFullObject != null && objOrderHistoryFullObject.ResponseCode.statusCode == 200)
                    {
                        try
                        {
                            JObject jsonRes            = JObject.Parse(objRes);
                            JToken  jTokenSearchResult = jsonRes.FindTokens("searchResult").FirstOrDefault();
                            JObject JobjSearchResult   = JObject.Parse(jTokenSearchResult.ToString());
                            JToken  jTokenOrder        = jsonRes.FindTokens("orders").FirstOrDefault();

                            //LogHelper.Log("Employee: " + objEmployee.userName + " Emp ID: " + objEmployee.id + " Orders Count: " + jTokenOrder.Children().Count() + " Time: " + DateTime.Now);
                            LogHelper.Log("Store: " + objAllMerchantStoreInformation.merchantStoreName + " Orders Count: " + jTokenOrder.Children().Count() + " Time: " + DateTime.Now);

                            List <OrderDetailsExportFields> lstStoreResult = new List <OrderDetailsExportFields>();

                            foreach (var jObjectOrder in jTokenOrder.Children())
                            {
                                OrderHistoryResultModel objOrderHistory = JsonConvert.DeserializeObject <OrderHistoryResultModel>(jObjectOrder.ToString());

                                if (!lstStoreResult.Any(s => s.TicketNo == objOrderHistory.transactionCode))
                                {
                                    OrderDetailsExportFields objOrderDetailsExportFields = new OrderDetailsExportFields();
                                    objOrderDetailsExportFields.TicketNo        = objOrderHistory.transactionCode;
                                    objOrderDetailsExportFields.Type            = objOrderHistory.orderType;
                                    objOrderDetailsExportFields.Employee        = objOrderHistory.userFirstName + " " + objOrderHistory.userLastName;
                                    objOrderDetailsExportFields.Store           = objAllMerchantStoreInformation.merchantStoreName;
                                    objOrderDetailsExportFields.Date            = Convert.ToDateTime(objOrderHistory.orderDate).ToString("MM/dd/yyyy");
                                    objOrderDetailsExportFields.Time            = Convert.ToDateTime(objOrderHistory.orderDate).ToString("hh:mm tt");
                                    objOrderDetailsExportFields.ItemName        = objOrderHistory.listOfItems;
                                    objOrderDetailsExportFields.PaymentType     = objOrderHistory.paymentType;
                                    objOrderDetailsExportFields.TransactionType = objOrderHistory.paymentInfo.FirstOrDefault().transactionType;
                                    objOrderDetailsExportFields.GrossSale       = objOrderHistory.subTotal;
                                    objOrderDetailsExportFields.Discounts       = objOrderHistory.discount;
                                    objOrderDetailsExportFields.Refunds         = objOrderHistory.refundAmount;
                                    objOrderDetailsExportFields.NetSale         = objOrderDetailsExportFields.GrossSale - objOrderDetailsExportFields.Discounts - objOrderDetailsExportFields.Refunds;
                                    objOrderDetailsExportFields.Tips            = objOrderHistory.tip;
                                    objOrderDetailsExportFields.Tax             = objOrderHistory.tax;
                                    objOrderDetailsExportFields.Total           = objOrderDetailsExportFields.NetSale + objOrderDetailsExportFields.Tax + objOrderDetailsExportFields.Tips;

                                    lstStoreResult.Add(objOrderDetailsExportFields);
                                    //lstFinalResult.Add(objOrderDetailsExportFields);

                                    //OrderHistoryResultModel objOrderHistory = JsonConvert.DeserializeObject<OrderHistoryResultModel>(jObjectOrder.ToString());
                                    //if (objOrderHistory != null && !string.IsNullOrEmpty(objOrderHistory.orderId))
                                    //{
                                    //    List<OrderDetailsExportFields> objResult = await GetOrderDetailsByOrderID(objOrderHistory.orderId, objOrderHistory.transactionCode, objAllMerchantStoreInformation.merchantIdentification, objOrderHistory.userFirstName + " " + objOrderHistory.userLastName, objAllMerchantStoreInformation.merchantStoreName);

                                    //    if (objResult != null && objResult.Count() > 0)
                                    //        lstFinalResult.AddRange(objResult);
                                    //}
                                }
                            }

                            lstFinalResult.AddRange(lstStoreResult);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Log("Error: " + ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Log("Error: " + ex.Message);
                }
            }

            try
            {
                LogHelper.Log("Total Records: " + lstFinalResult.Count());
                //lstFinalResult = lstFinalResult.OrderBy(s => s.TicketNo).ToList();
                SaveOrderDetailsIntoExcel(lstFinalResult, lstFinalResult.FirstOrDefault().Store + "_" + Convert.ToDateTime(startdate).ToString("MMM-yy"));
                LogHelper.Log("File saved successfully. " + DateTime.Now);
            }
            catch (Exception ex)
            {
                LogHelper.Log("Error in save data into excel. " + ex.Message);
            }

            return(0);
        }
        public async Task <List <MerchantIdentification_StoreName> > GetAllMerchantStoreDetails()
        {
            List <MerchantIdentification_StoreName> lstMerchantdetailsObj = new List <MerchantIdentification_StoreName>();
            AllMerchantStoreInfoModel objResult = new AllMerchantStoreInfoModel();
            TokenDetails objTokenDetails        = new TokenDetails();

            using (HttpClient client = new HttpClient())
            {
                objTokenDetails.SetHTTPClientObjectValues(client);
                HttpResponseMessage response = await objTokenDetails.ExecuteClientPostMethod("authentication/getAllMerchantStoreInfo", null, client, Token.securityToken);

                if (response.IsSuccessStatusCode)
                {
                    objTokenDetails.SetRefreshToken(response);
                    var objRes = await response.Content.ReadAsStringAsync();

                    objResult = JsonConvert.DeserializeObject <AllMerchantStoreInfoModel>(await response.Content.ReadAsStringAsync());

                    if (objResult.ResponseCode.statusCode == 200 && objResult.merchantStoreDetails != null && objResult.merchantStoreDetails.merchantDetails != null)
                    {
                        //securityToken = objResult.merchantStoreDetails.securityToken;
                        //LoginUserID = objResult.merchantStoreDetails.user.id;

                        foreach (var objMerchantDetails in objResult.merchantStoreDetails.merchantDetails)
                        {
                            MerchantIdentification_StoreName obj = new MerchantIdentification_StoreName();
                            obj.merchantIdentification = objMerchantDetails.merchantIdentification.ToString();
                            obj.merchantStoreName      = objMerchantDetails.stores.FirstOrDefault().storeName;
                            obj.storeId    = objMerchantDetails.stores.FirstOrDefault().storeId;
                            obj.merchantId = objMerchantDetails.stores.FirstOrDefault().merchantId;

                            lstMerchantdetailsObj.Add(obj);
                        }

                        #region Download Excel for Merchant Store details
                        //DataTable dtMerchantDetails = new DataTable("Merchant_Store_Details");
                        //dtMerchantDetails.Columns.Add("Merchant ID", typeof(Int64));
                        //dtMerchantDetails.Columns.Add("Business Name");
                        //dtMerchantDetails.Columns.Add("Business Phone");
                        //dtMerchantDetails.Columns.Add("Address1");
                        //dtMerchantDetails.Columns.Add("Address2");
                        //dtMerchantDetails.Columns.Add("City");
                        //dtMerchantDetails.Columns.Add("State");
                        //dtMerchantDetails.Columns.Add("Country");
                        //dtMerchantDetails.Columns.Add("Zip");
                        //dtMerchantDetails.Columns.Add("Store name");
                        //dtMerchantDetails.Columns.Add("Currency");

                        //foreach (var objMerchantDetails in objresult.merchantStoreDetails.merchantDetails)
                        //{
                        //    DataRow dr = dtMerchantDetails.NewRow();

                        //    var storeInfo = objMerchantDetails.stores.FirstOrDefault();
                        //    dr["Merchant ID"] = Convert.ToInt64(objMerchantDetails.merchantIdentification);
                        //    dr["Business Name"] = storeInfo.businessName;
                        //    dr["Business Phone"] = storeInfo.businessPhone;
                        //    dr["Address1"] = storeInfo.address.address1;
                        //    dr["Address2"] = storeInfo.address.address2;
                        //    dr["City"] = storeInfo.address.city;
                        //    dr["State"] = storeInfo.address.state;
                        //    dr["Country"] = storeInfo.address.country;
                        //    dr["Zip"] = storeInfo.address.zip;
                        //    dr["Store name"] = storeInfo.storeName;
                        //    dr["Currency"] = storeInfo.currency;

                        //    dtMerchantDetails.Rows.Add(dr);
                        //}

                        //using (var package = new ExcelPackage())
                        //{
                        //    // Add a new worksheet to the empty workbook
                        //    ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Merchant Store Details");
                        //    worksheet.Cells["A1"].LoadFromDataTable(dtMerchantDetails, true, TableStyles.Light9);
                        //    worksheet.Cells.AutoFitColumns(0);

                        //    FileInfo objFile = GetFileInfo(@"C:\Users\Rajni\Desktop\E\Projects\Custom Data Reports via API\Excel Export", dtMerchantDetails.TableName + ".xlsx");
                        //    package.SaveAs(objFile);
                        //}
                        #endregion
                    }
                }
            }

            return(lstMerchantdetailsObj);
        }