Ejemplo n.º 1
0
        public async Task <IActionResult> Export(int page, string name, string nameCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            var    time        = System.DateTime.Now.Day.ToString() + '-' + System.DateTime.Now.Month.ToString() + '-' + System.DateTime.Now.Year.ToString() + ' ' + System.DateTime.Now.Hour.ToString() + '-' + System.DateTime.Now.ToString() + '-' + System.DateTime.Now.Second.ToString();
            var    path        = Path.Combine(uploads, "Managements " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "Managements " + time + ".csv"));
            string       HttpSessionName = SD.HttpSessionString(new List <string> {
                "Managements", page.ToString(), name,
                name.ToString()
            });
            string csv = HttpContext.Session.GetString(HttpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                name = name,
                nameCheck = nameCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Export(int page, string phoneNumber, string month, string year, string callingPlan,
                                                 string phoneNumberCheck, string monthCheck, string yearCheck, string cPCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            var    time        = System.DateTime.Now.Day.ToString() + '-' + System.DateTime.Now.Month.ToString() + '-' + System.DateTime.Now.Year.ToString() + ' ' + System.DateTime.Now.Hour.ToString() + '-' + System.DateTime.Now.ToString() + '-' + System.DateTime.Now.Second.ToString();
            var    path        = Path.Combine(uploads, "CallingPlanAssignments " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }

            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "CallingPlanAssignments " + time + ".csv"));
            string       HttpSessionName = SD.HttpSessionString(new List <string> {
                "CallingPlanAssignment", page.ToString(), phoneNumber, month, year, callingPlan,
                phoneNumberCheck.ToString(), monthCheck.ToString(), yearCheck.ToString(), cPCheck.ToString()
            });
            string csv = HttpContext.Session.GetString(HttpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                month = month,
                year = year,
                callingPlan = callingPlan,
                phoneNumberCheck = phoneNumberCheck == "True"? "True":null,
                monthCheck = monthCheck == "True" ? "True" : null,
                yearCheck = yearCheck == "True" ? "True" : null,
                cPCheck = cPCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Export(int page, string code, string name, string managementName,
                                                 string codeCheck, string nameCheck, string managementNameCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            string time        = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;
            var    path        = Path.Combine(uploads, "costCenter " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw = new StreamWriter(Path.Combine(uploads, "costCenter " + time + ".csv"));

            string httpSessionName = SD.HttpSessionString(new List <string> {
                "CostCenter", page.ToString(), code, name, managementName, codeCheck.ToString(), nameCheck.ToString(), managementNameCheck.ToString()
            });
            string csv = HttpContext.Session.GetString(httpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                codeCheck = codeCheck == "True" ? "True" : null,
                nameCheck = nameCheck == "True" ? "True" : null,
                managementNameCheck = managementNameCheck == "True" ? "True" : null,
                code = code,
                name = name,
                managementName = managementName,
                cpage = page
            }));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Export(int page, string phoneNumber, string pUK, string pIN, string contract,
                                                 string phoneNumberCheck, string pUKCheck, string pINCheck, string contractCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            string time        = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;
            var    path        = Path.Combine(uploads, "phoneLine " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "phoneLine " + time + ".csv"));
            string       httpSessionName = SD.HttpSessionString(new List <string> {
                "PhoneLine", page.ToString(), phoneNumber, pUK, pIN, contract,
                phoneNumberCheck.ToString(), pUKCheck.ToString(), pINCheck.ToString(), contractCheck.ToString()
            });

            string csv = HttpContext.Session.GetString(httpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                pUK = pUK,
                pIN = pIN,
                contract = contract,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                pUKCheck = pUKCheck == "True" ? "True" : null,
                pINCheck = pINCheck == "True" ? "True" : null,
                contractCheck = contractCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Export(int page, string phoneNumber, string month, string year, string smsPlan,
                                                 string pNCheck, string monthCheck, string yearCheck, string sPCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            string time        = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;
            var    path        = Path.Combine(uploads, "sMSPlanAssignment " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "sMSPlanAssignment " + time + ".csv"));
            string       httpSessionName = SD.HttpSessionString(new List <string> {
                "SMSPlanAssignment", page.ToString(), phoneNumber, month, year, smsPlan,
                pNCheck.ToString(), monthCheck.ToString(), yearCheck.ToString(), sPCheck.ToString()
            });

            string csv = HttpContext.Session.GetString(httpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                month = month,
                year = year,
                smsPlan = smsPlan,
                pNCheck = pNCheck == "True" ? "True" : null,
                monthCheck = monthCheck == "True" ? "True" : null,
                yearCheck = yearCheck == "True" ? "True" : null,
                sPCheck = sPCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 6
0
        // GET: MobilePhoneCallingPlanAssignments
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string month, string year, string callingPlan,
                                                string phoneNumberCheck, string monthCheck, string yearCheck, string cPCheck,
                                                string page, string next, string previous)
        {
            //
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year = Parse.IntTryParse(year);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, monthCheck, yearCheck, cPCheck
            }, new List <string>()
            {
                phoneNumber, month, year, callingPlan
            });
            ViewData["columns"] = show;
            //
            var cpa = await _context.CallingPlanAssignments.Include(m => m.CallingPlan).Include(m => m.PhoneLine).ToListAsync();

            List <CallingPlanAssignment> _cpa         = cpa.ToList();
            List <CallingPlanAssignment> final_result = new List <CallingPlanAssignment>();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            _cpa = DataFilter <CallingPlanAssignment> .Filter(phoneNumberList, (m) => m.PhoneNumber, _cpa).ToList();

            var callingPlanList = (callingPlan != null) ? callingPlan.Split(", ").ToList() : new List <string>();

            _cpa = DataFilter <CallingPlanAssignment> .Filter(callingPlanList, (m) => m.CallingPlanId, _cpa).ToList();

            _cpa = DataFilter <CallingPlanAssignment> .Filter(_month, (m) => m.Month, _cpa).ToList();

            _cpa = DataFilter <CallingPlanAssignment> .Filter(_year, (m) => m.Year, _cpa).ToList();

            //separar en paginas
            _cpa = _cpa.OrderBy(m => m.Year).ThenBy(m => m.Month).ToList();
            var result = Paging <CallingPlanAssignment> .Pages(_cpa, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;

            bool[] mask            = { phoneNumberCheck != null, monthCheck != null, yearCheck != null, cPCheck != null };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "CallingPlanAssignment", result.Item4.ToString(), phoneNumber, month, year, callingPlan,
                (phoneNumberCheck != null).ToString(), (monthCheck != null).ToString(), (yearCheck != null).ToString(), (cPCheck != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 7
0
        // GET: Employees
        public async Task <IActionResult> Index(int cpage, string name, string costCenter, string personalCode, string email, string extension,
                                                string nameCheck, string costCenterCheck, string personalCodeCheck, string emailCheck, string extensionCheck,
                                                string page, string next, string previous)
        {
            var _personalCode = Utils.Parse.IntTryParse(personalCode);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                nameCheck, costCenterCheck, personalCodeCheck, emailCheck, extensionCheck
            }, new List <string>()
            {
                name, costCenter, personalCode, email, extension
            });
            ViewData["columns"] = show;
            //
            IEnumerable <Employee> employees = await _context.Employees.ToListAsync();

            List <Employee> _employees   = employees.ToList();
            List <Employee> final_result = new List <Employee>();

            var nameList = (name != null) ? name.Split(", ").ToList() : new List <string>();

            _employees = DataFilter <Employee> .Filter(nameList, (m) => m.Name, _employees, true).ToList();

            var costCenterList = (costCenter != null) ? costCenter.Split(", ").ToList() : new List <string>();

            _employees = DataFilter <Employee> .Filter(costCenterList, (m) => m.CostCenterCode, _employees).ToList();

            var personalCodeList = (personalCode != null) ? personalCode.Split(", ").ToList() : new List <string>();

            _employees = DataFilter <Employee> .Filter(personalCodeList, (m) => m.PersonalCode, _employees).ToList();

            _employees = DataFilter <Employee> .Filter(email, (m) => m.Email, _employees).ToList();

            _employees = DataFilter <Employee> .Filter(extension, (m) => m.Extension, _employees).ToList();

            //Separar en paginas
            _employees = _employees.OrderBy(m => m.Name).ToList();
            var result = Paging <Employee> .Pages(_employees, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { nameCheck != null, costCenterCheck != null, personalCodeCheck != null, emailCheck != null, extensionCheck != null };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "Employee", result.Item4.ToString(), name, costCenter, personalCode, email, extension,
                (nameCheck != null).ToString(), (costCenterCheck != null).ToString(), (personalCodeCheck != null).ToString(), (emailCheck != null).ToString(), (extensionCheck != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
        public async Task <IActionResult> Export(int page, string phoneNumber, string employeeName, string callingPlan, string smsPlan,
                                                 string minMinExc, string maxMinExc, string minSmsExc, string maxSmsExc, string minMinPercent, string maxMinPercent, string minSmsPercent, string maxSmsPercent,
                                                 string phoneNumberCheck, string employeeNameCheck, string callingPlanCheck, string smsPlanCheck, string minExcCheck, string smsExcCheck,
                                                 string minPercentCheck, string smsPercentCheck, string monthCheck, string yearCheck,
                                                 string month, string year)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            string time        = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;
            var    path        = Path.Combine(uploads, "userExceededCallingPlan" + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "userExceededCallingPlan " + time + ".csv"));
            string       httpSessionName = SD.HttpSessionString(new List <string> {
                "UserExceededCallingPlan", page.ToString(), phoneNumber, employeeName, callingPlan, smsPlan, minMinExc, maxMinExc, month, year, minSmsExc, maxSmsExc, minMinPercent, maxMinPercent, minSmsPercent, maxSmsPercent,
                phoneNumberCheck.ToString(), employeeNameCheck.ToString(), callingPlanCheck.ToString(), smsPlanCheck.ToString(), minExcCheck.ToString(), monthCheck.ToString(), yearCheck.ToString(), smsExcCheck.ToString(), minPercentCheck.ToString(), smsPercentCheck.ToString()
            });

            string csv = HttpContext.Session.GetString(httpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                smsPercentCheck = smsPercentCheck,
                phoneNumber = phoneNumber,
                month = month,
                year = year,
                employeeName = employeeName,
                callingPlan = callingPlan,
                smsPlan = smsPlan,
                minMinExc = minMinExc,
                maxMinExc = maxMinExc,
                minSmsExc = minSmsExc,
                maxSmsExc = maxSmsExc,
                minMinPercent = minMinPercent,
                maxMinPercent = maxMinPercent,
                minSmsPercent = minSmsPercent,
                maxSmsPercent = maxSmsPercent,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                employeeNameCheck = employeeNameCheck == "True" ? "True" : null,
                callingPlanCheck = callingPlanCheck == "True" ? "True" : null,
                smsPlanCheck = smsPlanCheck == "True" ? "True" : null,
                minExcCheck = minExcCheck == "True" ? "True" : null,
                smsExcCheck = smsExcCheck == "True" ? "True" : null,
                minPercentCheck = minPercentCheck == "True" ? "True" : null,
                monthCheck = monthCheck == "True" ? "True" : null,
                yearCheck = yearCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
        public async Task <IActionResult> ExportGeneral(int page, string employeeName, string phoneNumber, string callingPlanId, string costCenterCode, string costCenterName,
                                                        string minCalls, string maxCalls, string minSms, string maxSms, string minGprs, string maxGprs, string minTotal, string maxTotal,
                                                        string employeeNameCheck, string phoneNumberCheck, string callingPlanIdCheck, string callsCheck, string smsCheck, string gprsCheck,
                                                        string totalCheck, string costCenterCodeCheck, string costCenterNameCheck, string monthCheck, string yearCheck, string month, string year)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            var    time        = System.DateTime.Now.Day.ToString() + '-' + System.DateTime.Now.Month.ToString() + '-' + System.DateTime.Now.Year.ToString() + ' ' + System.DateTime.Now.Hour.ToString() + '-' + System.DateTime.Now.ToString() + '-' + System.DateTime.Now.Second.ToString();
            var    path        = Path.Combine(uploads, "CostCenterMobilePhoneGeneralExpenses " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "CostCenterMobilePhoneGeneralExpenses " + time + ".csv"));
            string       HttpSessionName = SD.HttpSessionString(new List <string> {
                "CostCenterMobilePhoneGeneralExpenses", page.ToString(), employeeName, phoneNumber, costCenterCode, costCenterName, callingPlanId, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, month, year, minTotal, maxTotal,
                employeeNameCheck.ToString(), phoneNumberCheck.ToString(), costCenterCodeCheck.ToString(), costCenterNameCheck.ToString(), callingPlanIdCheck.ToString(), callsCheck.ToString(), smsCheck.ToString(), gprsCheck.ToString(), monthCheck.ToString(), yearCheck.ToString(), totalCheck.ToString()
            });
            string csv = HttpContext.Session.GetString(HttpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(General), new
            {
                employeeName = employeeName,
                phoneNumber = phoneNumber,
                callingPlanId = callingPlanId,
                minCalls = minCalls,
                maxCalls = maxCalls,
                minSms = minSms,
                maxSms = maxSms,
                minGprs = minGprs,
                maxGprs = maxGprs,
                minTotal = minTotal,
                maxTotal = maxTotal,
                month = month,
                year = year,
                costCenterCode = costCenterCode,
                costCenterName = costCenterName,
                employeeNameCheck = employeeNameCheck == "True" ? "True" : null,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                callingPlanIdCheck = callingPlanIdCheck == "True" ? "True" : null,
                callsCheck = callsCheck == "True" ? "True" : null,
                smsCheck = smsCheck == "True" ? "True" : null,
                gprsCheck = gprsCheck == "True" ? "True" : null,
                totalCheck = totalCheck == "True" ? "True" : null,
                monthCheck = monthCheck == "True" ? "True" : null,
                yearCheck = yearCheck == "True" ? "True" : null,
                costCenterCodeCheck = costCenterCodeCheck == "True" ? "True" : null,
                costCenterNameCheck = costCenterNameCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 10
0
        // GET: PhoneLines
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string pUK, string pIN, string contract,
                                                string phoneNumberCheck, string pUKCheck, string pINCheck, string contractCheck,
                                                string page, string next, string previous)
        {
            //
            var _PUK = Parse.IntTryParse(pUK);
            var _PIN = Parse.IntTryParse(pIN);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, pUKCheck, pINCheck, contractCheck
            }, new List <string>()
            {
                phoneNumber, pUK, pIN, contract
            });
            ViewData["columns"] = show;
            //
            IEnumerable <PhoneLine> phoneLines = await _context.PhoneLines.ToListAsync();

            List <PhoneLine> _phoneLines  = phoneLines.ToList();
            List <PhoneLine> final_result = new List <PhoneLine>();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            _phoneLines = DataFilter <PhoneLine> .Filter(phoneNumberList, (m) => m.PhoneNumber, _phoneLines).ToList();

            _phoneLines = DataFilter <PhoneLine> .Filter(_PIN, (m) => m.PIN, _phoneLines).ToList();

            _phoneLines = DataFilter <PhoneLine> .Filter(_PUK, (m) => m.PUK, _phoneLines).ToList();

            _phoneLines = DataFilter <PhoneLine> .Filter(contract, (m) => m.Contract, _phoneLines).ToList();

            //Separar en paginas
            _phoneLines = _phoneLines.OrderBy(m => m.PhoneNumber).ToList();
            var result = Paging <PhoneLine> .Pages(_phoneLines, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { phoneNumberCheck == "On", pUKCheck == "On", pINCheck == "On", contractCheck == "On" };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "PhoneLine", result.Item4.ToString(), phoneNumber, pUK, pIN, contract,
                (phoneNumberCheck != null).ToString(), (pUKCheck != null).ToString(), (pINCheck != null).ToString(), (contractCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 11
0
        // GET: CallingPlans
        public async Task <IActionResult> Index(int cpage, string callingPlanId, string minutes, string minCost, string maxCost,
                                                string cPCheck, string minutesCheck, string costCheck,
                                                string page, string next, string previous)
        {
            // var _callingPlanId = Utils.Utils.IntTryParse(callingPlanId);
            var _minutes = Parse.IntTryParse(minutes);
            var _minCost = Parse.FloatTryParse(minCost);
            var _maxCost = Parse.FloatTryParse(maxCost);

            // para setear propiedades en la vista
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                cPCheck, minutesCheck, costCheck, costCheck
            }, new List <string>()
            {
                callingPlanId, minutes, minCost, maxCost
            });
            ViewData["columns"] = show;
            //
            IEnumerable <CallingPlan> callingPlans = await _context.CallingPlans.ToListAsync();

            List <CallingPlan> _callingPlans = callingPlans.ToList();
            List <CallingPlan> final_result  = new List <CallingPlan>();

            var callingPlanIdList = (callingPlanId != null) ? callingPlanId.Split(", ").ToList() : new List <string>();

            _callingPlans = DataFilter <CallingPlan> .Filter(callingPlanIdList, (m) => m.CallingPlanId, _callingPlans, true).ToList();

            _callingPlans = DataFilter <CallingPlan> .Filter(_minutes, (m) => m.Minutes, _callingPlans).ToList();

            _callingPlans = DataFilter <CallingPlan> .Filter(_minCost, _maxCost, (m) => m.Cost, _callingPlans).ToList();

            //Separar en paginas
            _callingPlans = _callingPlans.OrderBy(m => m.CallingPlanId).ToList();
            var result = Paging <CallingPlan> .Pages(_callingPlans, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { cPCheck != null, minutesCheck != null, costCheck != null, false };
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "CallingPlan", result.Item4.ToString(), callingPlanId, minutes, minCost, maxCost,
                (cPCheck != null).ToString(), (minutesCheck != null).ToString(), (costCheck != null).ToString()
            });
            string csv = CSVStringConstructor(show, mask, result.Item1);

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 12
0
        // GET: CostCenters
        public async Task <IActionResult> Index(int cpage, string code, string name, string managementName,
                                                string codeCheck, string nameCheck, string managementNameCheck,
                                                string page, string next, string previous)
        {
            //int _managementId = Parse.IntTryParse(managementId);
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                codeCheck, nameCheck, managementNameCheck
            }, new List <string>()
            {
                code, name, managementName
            });
            ViewData["columns"] = show;
            //
            IEnumerable <CostCenter> costCenters = await _context.CostCenters.Include(a => a.Management).ToListAsync();

            List <CostCenter> _costCenter  = costCenters.ToList();
            List <CostCenter> final_result = new List <CostCenter>();

            var codeList = (code != null) ? code.Split(", ").ToList() : new List <string>();

            _costCenter = DataFilter <CostCenter> .Filter(codeList, (m) => m.Code, _costCenter).ToList();

            var nameList = (name != null) ? name.Split(", ").ToList() : new List <string>();

            _costCenter = DataFilter <CostCenter> .Filter(nameList, (m) => m.Name, _costCenter, true).ToList();

            var managementNameList = (managementName != null) ? managementName.Split(", ").ToList() : new List <string>();

            _costCenter = DataFilter <CostCenter> .Filter(managementNameList, (m) => m.Management.Name, _costCenter, true).ToList();

            //Separar en paginas
            _costCenter = _costCenter.OrderBy(m => m.Code).ToList();
            var result = Paging <CostCenter> .Pages(_costCenter, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { codeCheck != null, nameCheck != null, managementNameCheck != null };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "CostCenter", result.Item4.ToString(), code, name, managementName, (codeCheck != null).ToString(), (nameCheck != null).ToString(), (managementNameCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 13
0
        // GET: DataPlans
        public async Task <IActionResult> Index(int cpage, string dataPlanId, string data, string minCost, string maxCost,
                                                string dPCheck, string dataCheck, string costCheck,
                                                string page, string next, string previous)
        {
            int _data    = Parse.IntTryParse(data);
            var _minCost = Parse.FloatTryParse(minCost);
            var _maxCost = Parse.FloatTryParse(maxCost);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                dPCheck, dataCheck, costCheck, costCheck
            }, new List <string>()
            {
                dataPlanId, data, minCost, maxCost
            });
            ViewData["columns"] = show;
            //
            IEnumerable <DataPlan> dataPlans = await _context.DataPlans.ToListAsync();

            List <DataPlan> _dataPlans   = dataPlans.ToList();
            List <DataPlan> final_result = new List <DataPlan>();

            var dataPlanIdList = (dataPlanId != null) ? dataPlanId.Split(", ").ToList() : new List <string>();

            _dataPlans = DataFilter <DataPlan> .Filter(dataPlanIdList, (m) => m.DataPlanId, _dataPlans, true).ToList();

            _dataPlans = DataFilter <DataPlan> .Filter(_data, (m) => m.Data, _dataPlans).ToList();

            _dataPlans = DataFilter <DataPlan> .Filter(_minCost, _maxCost, (m) => m.Cost, _dataPlans).ToList();

            //Separar en paginas
            _dataPlans = _dataPlans.OrderBy(m => m.DataPlanId).ToList();
            var result = Paging <DataPlan> .Pages(_dataPlans, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { dPCheck != null, dataCheck != null, costCheck != null, false };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "DataPlan", result.Item4.ToString(), dataPlanId, data, minCost, maxCost,
                (dPCheck != null).ToString(), (dataCheck != null).ToString(), (costCheck != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
        public async Task <IActionResult> Export(int page, string phoneNumber, string employeeName, string costCenterName, string costCenterCode,
                                                 string addresse, string month, string year, string minExpense, string maxExpense, string minPercent, string maxPercent,
                                                 string phoneNumberCheck, string employeeNameCheck, string costCenterNameCheck, string costCenterCodeCheck,
                                                 string addresseCheck, string expenseCheck, string percentCheck, string monthCheck, string yearCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            var    time        = System.DateTime.Now.Day.ToString() + '-' + System.DateTime.Now.Month.ToString() + '-' + System.DateTime.Now.Year.ToString() + ' ' + System.DateTime.Now.Hour.ToString() + '-' + System.DateTime.Now.ToString() + '-' + System.DateTime.Now.Second.ToString();
            var    path        = Path.Combine(uploads, "InternationalMobilePhoneCalls " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "InternationalMobilePhoneCalls " + time + ".csv"));
            string       HttpSessionName = SD.HttpSessionString(new List <string> {
                "InternationalMobilePhoneCall", page.ToString(), phoneNumber, employeeName, costCenterName, costCenterCode, addresse, month, year, minExpense, maxExpense, minPercent, maxPercent,
                phoneNumberCheck.ToString(), employeeNameCheck.ToString(), costCenterNameCheck.ToString(), costCenterCodeCheck.ToString(), addresseCheck.ToString(), monthCheck.ToString(), yearCheck.ToString(), expenseCheck.ToString(), percentCheck.ToString()
            });
            string csv = HttpContext.Session.GetString(HttpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                employeeName = employeeName,
                costCenterCode = costCenterCode,
                costCenterName = costCenterName,
                addresse = addresse,
                month = month,
                year = year,
                minExpense = minExpense,
                maxExpense = maxExpense,
                minPercent = minPercent,
                maxPercent = maxPercent,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                employeeNameCheck = employeeNameCheck == "True" ? "True" : null,
                costCenterNameCheck = costCenterNameCheck == "True" ? "True" : null,
                costCenterCodeCheck = costCenterCodeCheck == "True" ? "True" : null,
                addresseCheck = addresseCheck == "True" ? "True" : null,
                expenseCheck = expenseCheck == "True" ? "True" : null,
                percentCheck = percentCheck == "True" ? "True" : null,
                monthCheck = monthCheck == "True" ? "True" : null,
                yearCheck = yearCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 15
0
        // GET: PhoneLineEmployees
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string name,
                                                string phoneNumberCheck, string employeeNameCheck,
                                                string page, string next, string previous)
        {
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, employeeNameCheck
            }, new List <string>()
            {
                phoneNumber, name
            });
            ViewData["columns"] = show;
            //
            IEnumerable <PhoneLineEmployee> phoneLineEmployees = await _context.PhoneLineEmployees.Include(p => p.Employee).Include(p => p.PhoneLine).ToListAsync();

            List <PhoneLineEmployee> _phoneLineEmployees = phoneLineEmployees.ToList();
            List <PhoneLineEmployee> final_result        = new List <PhoneLineEmployee>();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            _phoneLineEmployees = DataFilter <PhoneLineEmployee> .Filter(phoneNumberList, (m) => m.PhoneNumber, _phoneLineEmployees).ToList();

            var employeeIdList = (name != null) ? name.Split(", ").ToList() : new List <string>();

            _phoneLineEmployees = DataFilter <PhoneLineEmployee> .Filter(employeeIdList, (m) => m.Employee.Name, _phoneLineEmployees, true).ToList();

            //Separar en paginas
            _phoneLineEmployees = _phoneLineEmployees.OrderBy(m => m.Employee.Name).ToList();
            var result = Paging <PhoneLineEmployee> .Pages(_phoneLineEmployees, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { phoneNumberCheck != null, employeeNameCheck != null };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "PhoneLineEmployee", result.Item4.ToString(), phoneNumber, name,
                (phoneNumberCheck != null).ToString(), (employeeNameCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 16
0
        // GET: MobilePhones
        public async Task <IActionResult> Index(int cpage, string iMEI, string model,
                                                string iMEICheck, string modelCheck,
                                                string page, string next, string previous)
        {
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                iMEICheck, modelCheck
            }, new List <string>()
            {
                iMEI, model
            });
            ViewData["columns"] = show;
            //
            IEnumerable <MobilePhone> mobilePhones = await _context.MobilePhones.ToListAsync();

            List <MobilePhone> _mobilePhones = mobilePhones.ToList();
            List <MobilePhone> final_result  = new List <MobilePhone>();

            var iMEIList = (iMEI != null) ? iMEI.Split(", ").ToList() : new List <string>();

            _mobilePhones = DataFilter <MobilePhone> .Filter(iMEIList, (m) => m.IMEI, _mobilePhones).ToList();

            var modelList = (model != null) ? model.Split(", ").ToList() : new List <string>();

            _mobilePhones = DataFilter <MobilePhone> .Filter(modelList, (m) => m.Model, _mobilePhones).ToList();

            //Separar en paginas
            _mobilePhones = _mobilePhones.OrderBy(m => m.Model).ToList();
            var result = Paging <MobilePhone> .Pages(_mobilePhones, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { iMEICheck != null, modelCheck != null };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "MobilePhone", result.Item4.ToString(), iMEI, model, (iMEICheck != null).ToString(), (modelCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Export(int page, string phoneNumber, string day, string month, string year, string er, string min, string max, string location, string destination, string roaming,
                                                 string phoneNumberCheck, string dateTimeCheck, string erCheck, string totalCostCheck, string locationCheck, string destinationCheck, string roamingCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            string time        = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + " " + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;
            var    path        = Path.Combine(uploads, "sMS " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "sMS " + time + ".csv"));
            string       httpSessionName = SD.HttpSessionString(new List <string> {
                "SMS", page.ToString(), phoneNumber, day, month, year, er, min, max, location, destination, roaming,
                phoneNumberCheck.ToString(), dateTimeCheck.ToString(), erCheck.ToString(), totalCostCheck.ToString(), locationCheck.ToString(), destinationCheck.ToString(), roamingCheck.ToString()
            });

            string csv = HttpContext.Session.GetString(httpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                day = day,
                month = month,
                year = year,
                er = er,
                min = min,
                max = max,
                location = location,
                destination = destination,
                roaming = roaming,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                dateTimeCheck = dateTimeCheck == "True" ? "True" : null,
                erCheck = erCheck == "True" ? "True" : null,
                totalCostCheck = totalCostCheck == "True" ? "True" : null,
                locationCheck = locationCheck == "True" ? "True" : null,
                destinationCheck = destinationCheck == "True" ? "True" : null,
                roamingCheck = roamingCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 18
0
        // GET: Managements
        public async Task <IActionResult> Index(int cpage, string name, string nameCheck, string page, string next, string previous)
        {
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                nameCheck
            }, new List <string>()
            {
                name
            });
            ViewData["columns"] = show;
            //
            IEnumerable <Management> managements = await _context.Managements.ToListAsync();

            List <Management> _managements = managements.ToList();
            List <Management> final_result = new List <Management>();

            var nameList = (name != null) ? name.Split(", ").ToList() : new List <string>();

            _managements = DataFilter <Management> .Filter(nameList, (m) => m.Name, _managements, true).ToList();

            //Separar en paginas
            _managements = _managements.OrderBy(m => m.Name).ToList();
            var result = Paging <Management> .Pages(_managements, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { nameCheck != null };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "Managements", result.Item4.ToString(), name,
                (name != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Export(int page, string phoneNumber, string day, string month, string year, string address, string min, string max, string roaming,
                                                 string phoneNumberCheck, string dateTimeCheck, string addressCheck, string totalCostCheck, string roamingCheck)
        {
            string webRootPath = _hostingEnviroment.WebRootPath;
            var    time        = System.DateTime.Now.Day.ToString() + '-' + System.DateTime.Now.Month.ToString() + '-' + System.DateTime.Now.Year.ToString() + ' ' + System.DateTime.Now.Hour + '-' + System.DateTime.Now.Minute + '-' + System.DateTime.Now.Second;
            var    uploads     = Path.Combine(webRootPath, "ExportFiles");
            var    path        = Path.Combine(uploads, "MobilePhoneCalls " + time + ".csv");

            using (var filesStream = new FileStream(path, FileMode.Create))
            {
            }
            StreamWriter stw             = new StreamWriter(Path.Combine(uploads, "MobilePhoneCalls " + time + ".csv"));
            string       HttpSessionName = SD.HttpSessionString(new List <string> {
                "MobilePhoneCall", page.ToString(), phoneNumber, day, month, year, address, min, max, roaming,
                phoneNumberCheck.ToString(), dateTimeCheck.ToString(), addressCheck.ToString(), totalCostCheck.ToString(), roamingCheck.ToString()
            });
            string csv = HttpContext.Session.GetString(HttpSessionName);

            stw.Write(csv);
            stw.Dispose();
            return(RedirectToAction(nameof(Index), new
            {
                phoneNumber = phoneNumber,
                day = day,
                month = month,
                year = year,
                address = address,
                min = min,
                max = max,
                roaming = roaming,
                phoneNumberCheck = phoneNumberCheck == "True" ? "True" : null,
                dateTimeCheck = dateTimeCheck == "True" ? "True" : null,
                addressCheck = addressCheck == "True" ? "True" : null,
                totalCostCheck = totalCostCheck == "True" ? "True" : null,
                roamingCheck = roamingCheck == "True" ? "True" : null,
                cpage = page
            }));
        }
Ejemplo n.º 20
0
        // GET: SMS
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string day, string month, string year, string er, string min, string max, string location, string destination, string roaming,
                                                string phoneNumberCheck, string dateTimeCheck, string erCheck, string totalCostCheck, string locationCheck, string destinationCheck, string roamingCheck, string page, string next, string previous)
        {
            //
            var _min   = Parse.FloatTryParse(min);
            var _max   = Parse.FloatTryParse(max);
            var _day   = Parse.IntTryParse(day);
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year = Parse.IntTryParse(year);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, dateTimeCheck, dateTimeCheck, dateTimeCheck, erCheck, locationCheck, destinationCheck, totalCostCheck, totalCostCheck, roamingCheck
            },
                                                  new List <string>()
            {
                phoneNumber, day, month, year, er, location, destination, min, max, roaming
            });
            ViewData["columns"] = show;
            //
            var mensajes = await _context.SMS.Include(m => m.PhoneLine).ToListAsync();

            List <SMS> _mensajes    = mensajes.ToList();
            List <SMS> final_result = new List <SMS>();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            _mensajes = DataFilter <SMS> .Filter(phoneNumberList, (m) => m.PhoneNumber, _mensajes).ToList();

            _mensajes = DataFilter <SMS> .Filter(_year, (m) => m.DateTime.Year, _mensajes).ToList();

            _mensajes = DataFilter <SMS> .Filter(_month, (m) => m.DateTime.Month, _mensajes).ToList();

            _mensajes = DataFilter <SMS> .Filter(_day, (m) => m.DateTime.Day, _mensajes).ToList();

            _mensajes = DataFilter <SMS> .Filter(er, (m) => m.E_R, _mensajes).ToList();

            var locationList = (location != null) ? location.Split(", ").ToList() : new List <string>();

            _mensajes = DataFilter <SMS> .Filter(locationList, (m) => m.Location, _mensajes, true).ToList();

            var destinationList = (destination != null) ? destination.Split(", ").ToList() : new List <string>();

            _mensajes = DataFilter <SMS> .Filter(destinationList, (m) => m.Destination, _mensajes, true).ToList();

            _mensajes = DataFilter <SMS> .Filter(_min, _max, (m) => m.Total, _mensajes).ToList();

            _mensajes = DataFilter <SMS> .Filter(roaming, (m) => m.Roaming, _mensajes).ToList();

            //Separar en paginas
            _mensajes = _mensajes.OrderBy(m => m.PhoneNumber).ToList();
            var result = Paging <SMS> .Pages(_mensajes, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { phoneNumberCheck != null, dateTimeCheck != null, false, false, erCheck != null, locationCheck != null, destinationCheck != null, totalCostCheck != null, false, roamingCheck != null };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "SMS", result.Item4.ToString(), phoneNumber, day, month, year, er, min, max, location, destination, roaming,
                (phoneNumberCheck != null).ToString(), (dateTimeCheck != null).ToString(), (erCheck != null).ToString(), (totalCostCheck != null).ToString(), (locationCheck != null).ToString(),
                (destinationCheck != null).ToString(), (roamingCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);

            return(View(result.Item1));
        }
Ejemplo n.º 21
0
        // GET: MobilePhoneCalls
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string day, string month, string year, string address, string min, string max, string roaming,
                                                string phoneNumberCheck, string dateTimeCheck, string addressCheck, string totalCostCheck, string roamingCheck,
                                                string page, string next, string previous)
        {
            var _min   = Parse.FloatTryParse(min);
            var _max   = Parse.FloatTryParse(max);
            var _day   = Parse.IntTryParse(day);
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year = Parse.IntTryParse(year);

            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, dateTimeCheck, dateTimeCheck, dateTimeCheck, addressCheck, totalCostCheck, totalCostCheck, roamingCheck
            }, new List <string>()
            {
                phoneNumber, day, month, year, address, min, max, roaming
            });
            ViewData["columns"] = show;
            //
            var mobilePhoneCalls = await _context.MobilePhoneCalls.Include(m => m.PhoneLine).ToListAsync();

            List <MobilePhoneCall> _mobilePhoneCalls = mobilePhoneCalls.ToList();
            List <MobilePhoneCall> final_result      = new List <MobilePhoneCall>();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(phoneNumberList, (m) => m.PhoneNumber, _mobilePhoneCalls).ToList();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(_year, (m) => m.DateTime.Year, _mobilePhoneCalls).ToList();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(_month, (m) => m.DateTime.Month, _mobilePhoneCalls).ToList();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(_day, (m) => m.DateTime.Day, _mobilePhoneCalls).ToList();

            var addressList = (address != null) ? address.Split(", ").ToList() : new List <string>();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(addressList, (m) => m.Addressee, _mobilePhoneCalls, true).ToList();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(_min, _max, (m) => m.TotalCost, _mobilePhoneCalls).ToList();

            _mobilePhoneCalls = DataFilter <MobilePhoneCall> .Filter(roaming, (m) => m.RoamingCall, _mobilePhoneCalls).ToList();

            //Separar en paginas
            _mobilePhoneCalls = _mobilePhoneCalls.OrderBy(m => m.DateTime.Year).ThenBy(m => m.DateTime.Month).ToList();
            var result = Paging <MobilePhoneCall> .Pages(_mobilePhoneCalls, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { phoneNumberCheck != null, dateTimeCheck != null, false, false, addressCheck != null, totalCostCheck != null, false, roamingCheck != null };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "MobilePhoneCall", result.Item4.ToString(), phoneNumber, day, month, year, address, min, max, roaming,
                (phoneNumberCheck != null).ToString(), (dateTimeCheck != null).ToString(), (addressCheck != null).ToString(), (totalCostCheck != null).ToString(), (roamingCheck != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }
        public async Task <IActionResult> General(int cpage, string employeeName, string phoneNumber, string callingPlanId, string costCenterCode, string costCenterName,
                                                  string minCalls, string maxCalls, string minSms, string maxSms, string minGprs, string maxGprs, string minTotal, string maxTotal,
                                                  string employeeNameCheck, string phoneNumberCheck, string callingPlanIdCheck, string callsCheck, string smsCheck, string gprsCheck,
                                                  string totalCheck, string costCenterCodeCheck, string costCenterNameCheck, string monthCheck, string yearCheck, string month, string year, string page, string previous, string next)
        {
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year     = Parse.IntTryParse(year);
            var _minCalls = Parse.FloatTryParse(minCalls);
            var _maxCalls = Parse.FloatTryParse(maxCalls);
            var _minSms   = Parse.FloatTryParse(minSms);
            var _maxSms   = Parse.FloatTryParse(maxSms);
            var _minGprs  = Parse.FloatTryParse(minGprs);
            var _maxGprs  = Parse.FloatTryParse(maxGprs);
            var _minTotal = Parse.FloatTryParse(minTotal);
            var _maxTotal = Parse.FloatTryParse(maxTotal);

            var models = new List <CostCenterMobilePhoneGeneralExpenses>();

            await Task.Delay(TimeSpan.FromSeconds(3));

            var model = (from pls in _context.PhoneLineSummaries
                         join ple in _context.PhoneLineEmployees on pls.PhoneNumber equals ple.PhoneNumber
                         join e in _context.Employees on ple.EmployeeId equals e.EmployeeId
                         join cc in _context.CostCenters on e.CostCenterCode equals cc.Code
                         join cpa in _context.CallingPlanAssignments on pls.PhoneNumber equals cpa.PhoneNumber
                         join cp in _context.CallingPlans on cpa.CallingPlanId equals cp.CallingPlanId
                         select new
            {
                EmployeeName = e.Name,
                PhoneNumber = pls.PhoneNumber,
                CallingPlanId = cp.CallingPlanId,
                CostCenterCode = cc.Code,
                CostCenterName = cc.Name,
                Gprs = pls.RoamingGprsExpenses + pls.GprsExpenses,
                Minutes = pls.AirTime + pls.RoamingExpenses,
                SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                Month = pls.Month,
                Year = pls.Year,
                cpaMonth = cpa.Month,
                cpaYear = cpa.Year,
                Total = pls.Total
            }).ToList().Where(a => SD.DateFilter(_month, _year, new int[] { a.Month, a.cpaMonth }, new int[] { a.Year, a.cpaYear }, false, true));

            foreach (var item in model)
            {
                var newModel = new CostCenterMobilePhoneGeneralExpenses()
                {
                    EmployeeName   = item.EmployeeName,
                    PhoneNumber    = item.PhoneNumber,
                    CallingPlanId  = item.CallingPlanId,
                    CostCenterCode = item.CostCenterCode,
                    CostCenterName = item.CostCenterName,
                    SMS            = item.SMS,
                    Gprs           = item.Gprs,
                    Minutes        = item.Minutes,
                    Total          = item.Total,
                    Month          = item.Month,
                    Year           = item.Year
                };
                models.Add(newModel);
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                employeeNameCheck, phoneNumberCheck, costCenterCodeCheck, costCenterNameCheck, callingPlanIdCheck, callsCheck, callsCheck, smsCheck, smsCheck, gprsCheck, gprsCheck, monthCheck, yearCheck, totalCheck, totalCheck
            },
                                                  new List <string>()
            {
                employeeName, phoneNumber, costCenterCode, costCenterName, callingPlanId, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, month, year, minTotal, maxTotal
            });
            ViewData["columns"] = show;
            //
            List <CostCenterMobilePhoneGeneralExpenses> final_result = new List <CostCenterMobilePhoneGeneralExpenses>();

            var employeeNameList = (employeeName != null) ? employeeName.Split(", ").ToList() : new List <string>();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(employeeNameList, (m) => m.EmployeeName, models, true).ToList();

            var phoneNumberList = (phoneNumber != null) ? phoneNumber.Split(", ").ToList() : new List <string>();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(phoneNumberList, (m) => m.PhoneNumber, models, true).ToList();

            var callingPlanIdList = (callingPlanId != null) ? callingPlanId.Split(", ").ToList() : new List <string>();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(callingPlanIdList, (m) => m.CallingPlanId, models, true).ToList();

            #region filter Min max
            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(_minCalls, _maxCalls, (m) => m.Minutes, models).ToList();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(_minSms, _maxSms, (m) => m.SMS, models).ToList();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(_minGprs, _maxGprs, (m) => m.Gprs, models).ToList();

            models = DataFilter <CostCenterMobilePhoneGeneralExpenses> .Filter(_minTotal, _maxTotal, (m) => m.Total, models).ToList();

            #endregion
            //separar en paginas
            models = models.OrderBy(m => m.Year).ThenBy(m => m.Month).ToList();
            var result = Paging <CostCenterMobilePhoneGeneralExpenses> .Pages(models, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { employeeNameCheck != null, phoneNumberCheck != null, costCenterCodeCheck != null, costCenterNameCheck != null, callingPlanIdCheck != null, callsCheck != null, false, smsCheck != null, false, gprsCheck != null, false, monthCheck != null, yearCheck != null, totalCheck != null, false };
            string csv             = CSVStringConstructorGeneral(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "CostCenterMobilePhoneGeneralExpenses", result.Item4.ToString(), employeeName, phoneNumber, costCenterCode, costCenterName, callingPlanId, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, month, year, minTotal, maxTotal,
                (employeeNameCheck != null).ToString(), (phoneNumberCheck != null).ToString(), (costCenterCodeCheck != null).ToString(), (costCenterNameCheck != null).ToString(), (callingPlanIdCheck != null).ToString(), (callsCheck != null).ToString(), (smsCheck != null).ToString(), (gprsCheck != null).ToString(), (monthCheck != null).ToString(), (yearCheck != null).ToString(), (totalCheck != null).ToString()
            });
            HttpContext.Session.SetString(HttpSessionName, csv);



            return(View(result.Item1));
        }
Ejemplo n.º 23
0
        // GET
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string employeeName, string callingPlan, string smsPlan,
                                                string minMinExc, string maxMinExc, string minSmsExc, string maxSmsExc, string minMinPercent, string maxMinPercent, string minSmsPercent, string maxSmsPercent,
                                                string phoneNumberCheck, string employeeNameCheck, string callingPlanCheck, string smsPlanCheck, string minExcCheck, string smsExcCheck, string minPercentCheck,
                                                string smsPercentCheck, string monthCheck, string yearCheck,
                                                string month, string year, string page, string next, string previous)
        {
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year          = Parse.IntTryParse(year);
            var _minMinExc     = Parse.FloatTryParse(minMinExc);
            var _maxMinExc     = Parse.FloatTryParse(maxMinExc);
            var _minSmsExc     = Parse.FloatTryParse(minSmsExc);
            var _maxSmsExc     = Parse.FloatTryParse(maxSmsExc);
            var _minMinPercent = Parse.FloatTryParse(minMinPercent);
            var _maxMinPercent = Parse.FloatTryParse(maxMinPercent);
            var _minSmsPercent = Parse.FloatTryParse(minSmsPercent);
            var _maxSmsPercent = Parse.FloatTryParse(maxSmsPercent);

            var query = (from pls in _context.PhoneLineSummaries
                         join ple in _context.PhoneLineEmployees on pls.PhoneNumber equals ple.PhoneNumber
                         join e in _context.Employees on ple.EmployeeId equals e.EmployeeId
                         join mpcpa in _context.CallingPlanAssignments on pls.PhoneNumber equals mpcpa.PhoneNumber
                         join cp in _context.CallingPlans on mpcpa.CallingPlanId equals cp.CallingPlanId
                         join spa in _context.SmsPlanAssignments on ple.PhoneNumber equals spa.PhoneNumber
                         join sp in _context.SmsPlans on spa.SMSPlanId equals sp.SMSPlanId
                         where (pls.AirTime + pls.RoamingExpenses > cp.Cost || pls.SmsExpenses + pls.RoamingSmsExpenses > sp.Cost)
                         select new
            {
                EmployeeName = e.Name,
                EmployeeId = e.EmployeeId,
                PhoneNumber = pls.PhoneNumber,
                CallingPlan = cp.CallingPlanId,
                MinutesExceeded = Math.Max(pls.AirTime + pls.RoamingExpenses - cp.Cost, 0),
                Month = pls.Month,
                Year = pls.Year,
                cpaMonth = mpcpa.Month,
                cpaYear = mpcpa.Year,
                spaMonth = spa.Month,
                spaYear = spa.Year,
                SmsPlan = sp.SMSPlanId,
                MessagesExceeded = Math.Max(pls.SmsExpenses + pls.RoamingSmsExpenses - sp.Cost, 0),
                PerCentCalls = 0,
                PerCentSms = 0
            }).ToList().Where(a => SD.DateFilter(_month, _year, new int[] { a.Month, a.cpaMonth, a.spaMonth }, new int[] { a.Year, a.cpaYear, a.spaYear }, false));

            float totalCallCost     = query.Sum(a => a.MinutesExceeded);
            float totalMessagesCost = query.Sum(a => a.MessagesExceeded);
            var   models            = new List <UserExceededCallingPlan>();

            foreach (var item in query)
            {
                models.Add(new UserExceededCallingPlan()
                {
                    EmployeeId       = item.EmployeeId,
                    EmployeeName     = item.EmployeeName,
                    PhoneNumber      = item.PhoneNumber,
                    CallingPlan      = item.CallingPlan,
                    MinutesExceeded  = item.MinutesExceeded,
                    Month            = item.Month,
                    Year             = item.Year,
                    SmsPlan          = item.SmsPlan,
                    MessagesExceeded = item.MessagesExceeded,
                    PerCentCalls     = item.PerCentCalls,
                    PerCentSms       = item.PerCentSms
                });
            }
            foreach (var userExceededCallingPlan in models)
            {
                userExceededCallingPlan.PerCentCalls = 100 * (userExceededCallingPlan.MinutesExceeded / totalCallCost);
                userExceededCallingPlan.PerCentSms   = 100 * (userExceededCallingPlan.MessagesExceeded / totalMessagesCost);
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, employeeNameCheck, callingPlanCheck, smsPlanCheck, minExcCheck, minExcCheck, smsExcCheck, smsExcCheck, monthCheck, yearCheck, minPercentCheck, minPercentCheck, smsPercentCheck, smsPercentCheck
            },
                                                  new List <string>()
            {
                phoneNumber, employeeName, callingPlan, smsPlan, minMinExc, maxMinExc, minSmsExc, maxSmsExc, month, year, minMinPercent, maxMinPercent, minSmsPercent, maxSmsPercent
            });
            ViewData["columns"] = show;
            //

            models = DataFilter <UserExceededCallingPlan> .Filter(phoneNumber, (m) => m.PhoneNumber, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(employeeName, (m) => m.EmployeeName, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(callingPlan, (m) => m.CallingPlan, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(smsPlan, (m) => m.SmsPlan, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(_minMinExc, _maxMinExc, (m) => m.MinutesExceeded, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(_minSmsExc, _maxSmsExc, (m) => m.MessagesExceeded, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(_minMinPercent, _maxMinPercent, (m) => m.PerCentCalls, models).ToList();

            models = DataFilter <UserExceededCallingPlan> .Filter(_minSmsPercent, _maxSmsPercent, (m) => m.PerCentSms, models).ToList();

            //separar en paginas
            models = models.OrderBy(m => m.EmployeeName).ToList();
            var result = Paging <UserExceededCallingPlan> .Pages(models, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { phoneNumberCheck != null, employeeNameCheck != null, callingPlanCheck != null, smsPlanCheck != null, minExcCheck != null, false, smsExcCheck != null, false, monthCheck != null, yearCheck != null, minPercentCheck != null, false, smsPercentCheck != null, false };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "UserExceededCallingPlan", result.Item4.ToString(), phoneNumber, employeeName, callingPlan, smsPlan, minMinExc, maxMinExc, month, year, minSmsExc, maxSmsExc, minMinPercent, maxMinPercent, minSmsPercent, maxSmsPercent,
                (phoneNumberCheck != null).ToString(), (employeeNameCheck != null).ToString(), (callingPlanCheck != null).ToString(), (smsPlanCheck != null).ToString(), (minExcCheck != null).ToString(), (monthCheck != null).ToString(),
                (yearCheck != null).ToString(), (smsExcCheck != null).ToString(), (minPercentCheck != null).ToString(), (smsPercentCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);
            return(View(result.Item1));
        }
        // GET
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string employeeName, string costCenterName, string costCenterCode,
                                                string addresse, string month, string year, string minExpense, string maxExpense, string minPercent, string maxPercent,
                                                string phoneNumberCheck, string employeeNameCheck, string costCenterNameCheck, string costCenterCodeCheck,
                                                string addresseCheck, string expenseCheck, string percentCheck, string monthCheck, string yearCheck, string page, string previous, string next)
        {
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year       = Parse.IntTryParse(year);
            var _minExpense = Parse.FloatTryParse(minExpense);
            var _maxExpense = Parse.FloatTryParse(maxExpense);
            var _minPercent = Parse.FloatTryParse(minPercent);
            var _maxPercent = Parse.FloatTryParse(maxPercent);

            var query = (from mpc in _context.MobilePhoneCalls
                         join ple in _context.PhoneLineEmployees on mpc.PhoneNumber equals ple.PhoneNumber
                         join e in _context.Employees on ple.EmployeeId equals e.EmployeeId
                         join cc in _context.CostCenters on e.CostCenterCode equals cc.Code
                         select new InternationalMobilePhoneCall()
            {
                PhoneNumber = mpc.PhoneNumber,
                EmployeeName = e.Name,
                CostCenterName = cc.Name,
                CostCenterCode = cc.Code,
                Month = mpc.DateTime.Month,
                Year = mpc.DateTime.Year,
                Addresse = mpc.Addressee,
                Expense = mpc.TotalCost,
                PerCent = 0
            }).ToList();
            var query1 = query.Where(a => Checking(a.Addresse, _month, _year, a.Month, a.Year));
            //(!((a.Addresse[0] == '5' && a.Addresse.Length == 8) && !ProvinceFilter(a.Addresse))) && SD.DateFilter(_month, _year, a.Month, a.Year, false));

            float total  = query1.Sum(a => a.Expense);
            var   models = query1.ToList();

            foreach (var internationalMobilePhoneCall in query)
            {
                internationalMobilePhoneCall.PerCent = (internationalMobilePhoneCall.Expense / total) * 100;
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, employeeNameCheck, costCenterNameCheck, costCenterCodeCheck, addresseCheck, monthCheck, yearCheck, expenseCheck, expenseCheck, percentCheck, percentCheck
            },
                                                  new List <string>()
            {
                phoneNumber, employeeName, costCenterName, costCenterCode, addresse, month, year, minExpense, maxExpense, minPercent, maxPercent
            });
            ViewData["columns"] = show;
            //
            List <InternationalMobilePhoneCall> final_result = new List <InternationalMobilePhoneCall>();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(phoneNumber, (m) => m.PhoneNumber, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(employeeName, (m) => m.EmployeeName, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(costCenterName, (m) => m.CostCenterName, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(costCenterCode, (m) => m.CostCenterCode, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(addresse, (m) => m.Addresse, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(_minExpense, _maxExpense, (m) => m.Expense, models).ToList();

            models = DataFilter <InternationalMobilePhoneCall> .Filter(_minPercent, _maxPercent, (m) => m.PerCent, models).ToList();

            //separar en paginas
            models = models.OrderBy(m => m.CostCenterCode).ThenBy(m => m.EmployeeName).ToList();
            var result = Paging <InternationalMobilePhoneCall> .Pages(models, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { phoneNumberCheck != null, employeeNameCheck != null, costCenterNameCheck != null, costCenterCodeCheck != null, addresseCheck != null, monthCheck != null, yearCheck != null, expenseCheck != null, false, percentCheck != null, false };
            string csv             = CSVStringConstructor(show, mask, result.Item1);
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "InternationalMobilePhoneCall", result.Item4.ToString(), phoneNumber, employeeName, costCenterName, costCenterCode, addresse, month, year, minExpense, maxExpense, minPercent, maxPercent,
                (phoneNumberCheck != null).ToString(), (employeeNameCheck != null).ToString(), (costCenterNameCheck != null).ToString(), (costCenterCodeCheck != null).ToString(), (addresseCheck != null).ToString(), (monthCheck != null).ToString(), (yearCheck != null).ToString(), (expenseCheck != null).ToString(), (percentCheck != null).ToString()
            });

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));

            return(View(query));
        }
Ejemplo n.º 25
0
        // GET
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string employeeName, string dataPlan, string ccc, string ccName, string month, string year,
                                                string minDataExc, string maxDataExc, string minPercent, string maxPercent,
                                                string phoneNumberCheck, string employeeNameCheck, string dataPlanCheck, string cccCheck, string ccNameCheck, string monthCheck, string yearCheck,
                                                string DataExcCheck, string PercentCheck, string page, string next, string previous)
        {
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year       = Parse.IntTryParse(year);
            var _minDataExc = Parse.FloatTryParse(minDataExc);
            var _maxDataExc = Parse.FloatTryParse(maxDataExc);
            var _minPercent = Parse.FloatTryParse(minPercent);
            var _maxPercent = Parse.FloatTryParse(maxPercent);
            //
            var query1 = (from pls in _context.PhoneLineSummaries
                          join pe in _context.PhoneLineEmployees on pls.PhoneNumber equals pe.PhoneNumber
                          join e in _context.Employees on pe.EmployeeId equals e.EmployeeId
                          join dpa in _context.DataPlanAssignments on pls.PhoneNumber equals dpa.PhoneNumber
                          join dp in _context.DataPlans on dpa.DataPlanId equals dp.DataPlanId
                          join cc in _context.CostCenters on e.CostCenterCode equals cc.Code
                          where (pls.GprsExpenses > dp.Cost)
                          select new
            {
                EmployeeId = e.EmployeeId,
                EmployeeName = e.Name,
                CostCenter = cc.Name,
                CC = cc.Code,
                PhoneNumber = pls.PhoneNumber,
                Month = pls.Month,
                Year = pls.Year,
                dpaMonth = dpa.Month,
                dpaYear = dpa.Year,
                DataPlanId = dp.DataPlanId,
                DataExceeded = pls.GprsExpenses - dp.Cost,
                PerCent = 0
            }).ToList();
            var   query  = query1.Where(a => SD.DateFilter(_month, _year, new int[] { a.Month, a.dpaMonth }, new int[] { a.Year, a.dpaYear }, true));
            float total  = query.Sum(a => a.DataExceeded);
            var   models = new List <UserExceededDataPlan>();

            foreach (var item in query)
            {
                models.Add(new UserExceededDataPlan()
                {
                    EmployeeId   = item.EmployeeId,
                    EmployeeName = item.EmployeeName,
                    PhoneNumber  = item.PhoneNumber,
                    CC           = item.CC,
                    CostCenter   = item.CostCenter,
                    Month        = item.Month,
                    Year         = item.Year,
                    DataPlanId   = item.DataPlanId,
                    DataExceeded = item.DataExceeded,
                    PerCent      = item.PerCent
                });
            }
            foreach (var userExceededDataPlan in models)
            {
                userExceededDataPlan.PerCent = 100 * (userExceededDataPlan.DataExceeded / total);
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                phoneNumberCheck, employeeNameCheck, dataPlanCheck, cccCheck, ccNameCheck, monthCheck, yearCheck, DataExcCheck, DataExcCheck, PercentCheck, PercentCheck
            },
                                                  new List <string>()
            {
                phoneNumber, employeeName, dataPlan, ccc, ccName, month, year, minDataExc, maxDataExc, minPercent, maxPercent
            });
            ViewData["columns"] = show;
            //

            models = DataFilter <UserExceededDataPlan> .Filter(phoneNumber, (m) => m.PhoneNumber, models).ToList();

            models = DataFilter <UserExceededDataPlan> .Filter(employeeName, (m) => m.EmployeeName, models).ToList();

            models = DataFilter <UserExceededDataPlan> .Filter(dataPlan, (m) => m.DataPlanId, models).ToList();

            models = DataFilter <UserExceededDataPlan> .Filter(_minDataExc, _maxDataExc, (m) => m.DataExceeded, models).ToList();

            models = DataFilter <UserExceededDataPlan> .Filter(_minPercent, _maxPercent, (m) => m.PerCent, models).ToList();

            //separar en paginas
            models = models.OrderBy(m => m.EmployeeName).ToList();
            var result = Paging <UserExceededDataPlan> .Pages(models, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask = { phoneNumberCheck != null, employeeNameCheck != null, dataPlanCheck != null, cccCheck != null, ccNameCheck != null, monthCheck != null, yearCheck != null, DataExcCheck != null, false, PercentCheck != null, false };
            string csv  = CSVStringConstructor(show, mask, result.Item1);
            //ViewData["csv"] = ss;
            string httpSessionName = SD.HttpSessionString(new List <string> {
                "UserExceededDataPlan", result.Item4.ToString(), phoneNumber, employeeName, dataPlan, ccc, ccName, month, year, minDataExc, maxDataExc, minPercent, maxPercent,
                (phoneNumberCheck != null).ToString(), (employeeNameCheck != null).ToString(), (dataPlanCheck != null).ToString(), (cccCheck != null).ToString(), (ccNameCheck != null).ToString(), (monthCheck != null).ToString(), (yearCheck != null).ToString(), (DataExcCheck != null).ToString(), (PercentCheck != null).ToString()
            });

            HttpContext.Session.SetString(httpSessionName, csv);
            return(View(result.Item1));
        }
        // TODO: Falta revisar detalles y hacer el de detais
        // GET
        public async Task <IActionResult> Index(int cpage, string costCenterCode, string costCenterName, string month, string year,
                                                string minCalls, string maxCalls, string minSms, string maxSms, string minGprs, string maxGprs, string minTotal, string maxTotal, string minPercent, string maxPercent,
                                                string costCenterCodeCheck, string costCenterNameCheck, string callsCheck, string smsCheck, string gprsCheck,
                                                string totalCheck, string percentCheck, string monthCheck, string yearCheck, string page, string previous, string next)
        {
            var _month = (month != null && SD.months.ContainsKey(month)) ? SD.months[month] : -1;

            if (_month == -1)
            {
                _month = Parse.IntTryParse(month);
            }
            var _year       = Parse.IntTryParse(year);
            var _minCalls   = Parse.FloatTryParse(minCalls);
            var _maxCalls   = Parse.FloatTryParse(maxCalls);
            var _minSms     = Parse.FloatTryParse(minSms);
            var _maxSms     = Parse.FloatTryParse(maxSms);
            var _minGprs    = Parse.FloatTryParse(minGprs);
            var _maxGprs    = Parse.FloatTryParse(maxGprs);
            var _minTotal   = Parse.FloatTryParse(minTotal);
            var _maxTotal   = Parse.FloatTryParse(maxTotal);
            var _minPercent = Parse.FloatTryParse(minPercent);
            var _maxPercent = Parse.FloatTryParse(maxPercent);

            var models = new List <CostCenterMobilePhoneExpense>();
            await Task.Delay(TimeSpan.FromSeconds(3));

            var query1 = (from pls in _context.PhoneLineSummaries
                          join ple in _context.PhoneLineEmployees on pls.PhoneNumber equals ple.PhoneNumber
                          join e in _context.Employees on ple.EmployeeId equals e.EmployeeId
                          join cc in _context.CostCenters on e.CostCenterCode equals cc.Code
                          where pls.Month == _month
                          select new
            {
                CostCenterName = cc.Name,
                CostCenterCode = cc.Code,
                Calls = pls.AirTime,
                SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                GPRS = pls.GprsExpenses + pls.RoamingGprsExpenses,
                Month = pls.Month,
                Year = pls.Year,
                Total = pls.Total
            }).ToList().Where(a => SD.DateFilter(_month, _year, new int[] { a.Month }, new int[] { a.Year }, true));
            var   query11 = query1.ToList();
            var   query2  = query11.GroupBy(a => a.CostCenterCode);
            float total   = 0;

            foreach (var costCenter in query2)
            {
                var newModel = new CostCenterMobilePhoneExpense()
                {
                    CostCenterCode = costCenter.Key,
                    CostCenterName = costCenter.Select(a => a.CostCenterName).First(),
                    Calls          = costCenter.Sum(a => a.Calls),
                    SMS            = costCenter.Sum(a => a.SMS),
                    GPRS           = costCenter.Sum(a => a.GPRS),
                    Total          = costCenter.Sum(a => a.Total),
                    Month          = costCenter.Select(a => a.Month).First(),
                    Year           = costCenter.Select(a => a.Year).First(),
                    Percent        = 0,
                };
                total += newModel.Total;
                models.Add(newModel);
            }
            foreach (var model in models)
            {
                model.Percent = (100 * (model.Total / total));
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                costCenterCodeCheck, costCenterNameCheck, callsCheck, callsCheck, smsCheck, smsCheck, gprsCheck, gprsCheck, totalCheck, totalCheck, percentCheck, percentCheck, monthCheck, yearCheck
            },
                                                  new List <string>()
            {
                costCenterCode, costCenterName, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, minTotal, maxTotal, minPercent, maxPercent, month, year
            });
            ViewData["columns"] = show;
            //

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(costCenterCode, (m) => m.CostCenterCode, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(costCenterName, (m) => m.CostCenterName, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(_minCalls, _maxCalls, (m) => m.Calls, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(_minSms, _maxSms, (m) => m.SMS, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(_minGprs, _maxGprs, (m) => m.GPRS, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(_minTotal, _maxTotal, (m) => m.Total, models).ToList();

            models = DataFilter <CostCenterMobilePhoneExpense> .Filter(_minPercent, _maxPercent, (m) => m.Percent, models).ToList();

            //separar en paginas
            models = models.OrderBy(m => m.CostCenterCode).ToList();
            var result = Paging <CostCenterMobilePhoneExpense> .Pages(models, page, cpage, (next != null), (previous != null));

            ViewData["top"]  = result.Item2;
            ViewData["mult"] = result.Item3;
            ViewData["page"] = result.Item4;
            bool[] mask            = { costCenterCodeCheck != null, costCenterNameCheck != null, callsCheck != null, false, smsCheck != null, false, gprsCheck != null, false, totalCheck != null, false, percentCheck != null, false, monthCheck != null, yearCheck != null };
            string HttpSessionName = SD.HttpSessionString(new List <string> {
                "CostCenterMobilePhoneExpense", result.Item4.ToString(), costCenterCode, costCenterName, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, minTotal, maxTotal, minPercent, maxPercent, month, year,
                (costCenterCodeCheck != null).ToString(), (costCenterNameCheck != null).ToString(), (callsCheck != null).ToString(), (smsCheck != null).ToString(), (gprsCheck != null).ToString(), (totalCheck != null).ToString(), (percentCheck != null).ToString(), (monthCheck != null).ToString(), (yearCheck != null).ToString()
            });
            string csv = CSVStringConstructor(show, mask, result.Item1);

            HttpContext.Session.SetString(HttpSessionName, csv);

            return(View(result.Item1));
        }