Exemplo n.º 1
0
        // GET: BadInputData

        #region "Load Bad Input Data"
        public ActionResult Index(int?page, int?sortby, int?sortorder, int?pagevalue, string sort = null)
        {
            // Clear WorkQueue  for Data
            StewUserActivityCloseWindow();
            if (Request.IsAjaxRequest())
            {
                // Set User name in session.
                CompanyFacade fac = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName);
                #region Set pagination Code
                int pageNumber = (page ?? 1);
                if (!string.IsNullOrEmpty(SessionHelper.CleanMatchPageNo) && pagevalue == null)
                {
                    pagevalue = Convert.ToInt32(SessionHelper.CleanMatchPageNo);
                }

                if (pagevalue == null || Convert.ToInt32(pagevalue) == 0)
                {
                    SettingFacade sfac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString);
                    pagevalue = Convert.ToInt32(sfac.GetDefaultPageSize(Helper.oUser.UserId, "BadInputData"));
                    pagevalue = pagevalue == 0 ? 10 : pagevalue;
                }

                BadInputDataModel model = new BadInputDataModel();
                if (!(sortby.HasValue && sortby.Value > 0))
                {
                    sortby = 1;
                }

                if (!(sortorder.HasValue && sortorder.Value > 0))
                {
                    sortorder = 1;
                }

                int totalCount = 0;
                int pageno     = pagevalue.HasValue ? pagevalue.Value : 10;
                pageno = pageno < 5 ? 5 : pageno;
                // Set page no , sortorder , sortby and Page size to session
                ViewBag.SortBy    = sortby;
                ViewBag.SortOrder = sortorder;
                ViewBag.Page      = pageNumber;
                ViewBag.pageno    = pageno;
                Tuple <List <CompanyEntity>, string> tuplecompany = fac.GetBIDCompany(Helper.oUser.UserId, pageNumber, pageno, out totalCount);
                model.Companies = tuplecompany.Item1;
                SessionHelper.CleanQueueMessage = tuplecompany.Item2;

                SessionHelper.CleanMatchPage      = Convert.ToString(pageNumber);
                SessionHelper.CleanMatchPageNo    = Convert.ToString(pageno);
                SessionHelper.CleanTotalCount     = Convert.ToString(totalCount);
                SessionHelper.CleanMatchedCompany = JsonConvert.SerializeObject(model.Companies);
                #endregion

                IPagedList <CompanyEntity> pagedCompany = new StaticPagedList <CompanyEntity>(model.Companies.ToList(), pageNumber, pageno, totalCount);// Set model of Company entity to pass this model to view.
                return(PartialView("_Index", pagedCompany));
            }
            else
            {
                SessionHelper.BadInputData_IsFirstTimeFilter = true;
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult FilterCleanData(List <FilterData> filters)
        {
            UserSessionFilterEntity filtermodel = new UserSessionFilterEntity();

            foreach (var item in filters)
            {
                if (item.FieldName == "SrcRecordId")
                {
                    filtermodel.SrcRecordId = item.FilterValue;
                }
                else if (item.FieldName == "CompanyName")
                {
                    filtermodel.CompanyName = item.FilterValue;
                }
                else if (item.FieldName == "City")
                {
                    filtermodel.City = item.FilterValue;
                }
                else if (item.FieldName == "State")
                {
                    filtermodel.State = item.FilterValue;
                }
                else if (item.FieldName == "Country")
                {
                    filtermodel.CountryISOAlpha2Code = item.FilterValue;
                }
                else if (item.FieldName == "ImportProcess")
                {
                    filtermodel.ImportProcess = item.FilterValue;
                }
                else if (item.FieldName == "CountryGroup")
                {
                    filtermodel.CountryGroupId = Convert.ToInt32(item.FilterValue);
                }
                else if (item.FieldName == "Tag")
                {
                    filtermodel.Tag = item.FilterValue;
                }
                else if (item.FieldName == "OrderByColumn")
                {
                    filtermodel.OrderByColumn = item.FilterValue;
                }
                else if (item.FieldName == "ErrorCode")
                {
                    filtermodel.ErrorCode = item.FilterValue;
                }
            }
            filtermodel.UserId = Helper.oUser.UserId;
            int pagenumber = 0;

            if (string.IsNullOrEmpty(Convert.ToString(SessionHelper.BadInputData_IsFirstTimeFilter)) || !SessionHelper.BadInputData_IsFirstTimeFilter)
            {
                UserSessionFacade fac = new UserSessionFacade(this.CurrentClient.ApplicationDBConnectionString);
                fac.InsertOrUpdateUserSessionFilter(filtermodel);
                pagenumber = 1;
            }
            else
            {
                if (SessionHelper.BadInputData_IsFirstTimeFilter)
                {
                    pagenumber = 1;
                }
                else
                {
                    if (!string.IsNullOrEmpty(SessionHelper.CleanMatchPage))
                    {
                        pagenumber = Convert.ToInt32(SessionHelper.CleanMatchPage);
                    }
                    else
                    {
                        pagenumber = 1;
                    }
                }
            }
            SessionHelper.BadInputData_IsFirstTimeFilter = false;

            int totalCount = 0;
            int pagevalue  = 0;

            if (!string.IsNullOrEmpty(SessionHelper.CleanMatchPageNo))
            {
                pagevalue = Convert.ToInt32(SessionHelper.CleanMatchPageNo);
            }
            if (pagevalue == null || pagevalue == 0)
            {
                SettingFacade sfac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString);
                pagevalue = Convert.ToInt32(sfac.GetDefaultPageSize(Helper.oUser.UserId, "BadInputData"));
                pagevalue = pagevalue == 0 ? 10 : pagevalue;
            }
            pagevalue = pagevalue < 5 ? 5 : pagevalue;

            BadInputDataModel model = new BadInputDataModel();
            CompanyFacade     cfac  = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName);
            Tuple <List <CompanyEntity>, string> tuplecompany = cfac.GetBIDCompany(Helper.oUser.UserId, 1, pagevalue, out totalCount);

            model.Companies = tuplecompany.Item1;
            SessionHelper.CleanQueueMessage = tuplecompany.Item2;

            SessionHelper.CleanMatchPage      = pagenumber.ToString();
            SessionHelper.CleanMatchPageNo    = Convert.ToString(pagevalue);
            SessionHelper.CleanTotalCount     = Convert.ToString(totalCount);
            SessionHelper.CleanMatchedCompany = JsonConvert.SerializeObject(model.Companies);
            IPagedList <CompanyEntity> pagedCompany = new StaticPagedList <CompanyEntity>(model.Companies.ToList(), pagenumber, pagevalue, totalCount);// Set model of Company entity to pass this model to view.

            return(PartialView("_Index", pagedCompany));
        }
Exemplo n.º 3
0
        public ActionResult GetFilteredCompanyList(int?mode, int?page, int?sortby, int?sortorder, int?pagevalue, string sort = null)
        {
            // For Filtration of data .
            CompanyFacade fac = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName);

            #region Set Pagination code
            //Get Current Page size ,page Number.
            if (!string.IsNullOrEmpty(SessionHelper.CleanMatchPage))
            {
                page = Convert.ToInt32(SessionHelper.CleanMatchPage);
            }

            if (!string.IsNullOrEmpty(SessionHelper.CleanMatchPageNo))
            {
                pagevalue = Convert.ToInt32(SessionHelper.CleanMatchPageNo);
            }

            if (pagevalue == null || Convert.ToInt32(pagevalue) == 0)
            {
                SettingFacade sfac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString);
                pagevalue = Convert.ToInt32(sfac.GetDefaultPageSize(Helper.oUser.UserId, "BadInputData"));
                pagevalue = pagevalue == 0 ? 10 : pagevalue;
            }

            int pageNumber          = (page ?? 1);
            BadInputDataModel model = new BadInputDataModel();
            if (!(sortby.HasValue && sortby.Value > 0))
            {
                sortby = 1;
            }

            if (!(sortorder.HasValue && sortorder.Value > 0))
            {
                sortorder = 1;
            }

            int totalCount = 0;
            int pageno     = pagevalue.HasValue ? pagevalue.Value : 10;
            pageno            = pageno < 5 ? 5 : pageno;
            ViewBag.SortBy    = sortby;
            ViewBag.SortOrder = sortorder;
            ViewBag.Page      = pageNumber;
            ViewBag.pageno    = pageno;
            #endregion

            if (!string.IsNullOrEmpty(SessionHelper.CleanMatchedCompany)) //if Company is already in temp data then don't do db call to find company list
            {
                model.Companies = JsonConvert.DeserializeObject <List <CompanyEntity> >(SessionHelper.CleanMatchedCompany);
                totalCount      = !string.IsNullOrEmpty(SessionHelper.CleanTotalCount) ? Convert.ToInt32(SessionHelper.CleanTotalCount) : 0;
            }
            else
            {
                //model.Companies = fac.GetBIDCompany(Helper.oUser.UserId, pageNumber, pageno, out totalCount);//Get Company List if it is not found from the TempData
                Tuple <List <CompanyEntity>, string> tuplecompany = fac.GetBIDCompany(Helper.oUser.UserId, pageNumber, pageno, out totalCount);
                model.Companies = tuplecompany.Item1;
                SessionHelper.CleanQueueMessage = tuplecompany.Item2;
            }
            if (sortorder != null && sortby != null)
            {
                model.Companies = SortData(model.Companies, Convert.ToInt32(sortorder), Convert.ToInt32(sortby));
            }

            if (totalCount <= 0 && model.Companies.Count == 0 && pageNumber > 1)
            {
                totalCount = Convert.ToInt32(pagevalue);
            }

            // Set model of Company entity to pass this model to view.
            IPagedList <CompanyEntity> pagedCompany = new StaticPagedList <CompanyEntity>(model.Companies.ToList(), pageNumber, pageno, totalCount);
            ViewBag.CloseAlert = "<script type='text/javascript'>$(document).ready(function(){parent.backToparent();});</script>";
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_Index", pagedCompany));
            }

            return(View(pagedCompany));
        }