コード例 #1
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;

            return(View(result.Item1));
        }
コード例 #2
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));
        }
コード例 #3
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;

            return(View(result.Item1));
        }
コード例 #4
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));
        }
コード例 #5
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));
        }
コード例 #6
0
        // GET: SMSPlanAssignments
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string month, string year, string smsPlan,
                                                string pNCheck, string monthCheck, string yearCheck, string sPCheck,
                                                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>()
            {
                pNCheck, monthCheck, yearCheck, sPCheck
            }, new List <string>()
            {
                phoneNumber, month, year, smsPlan
            });
            ViewData["columns"] = show;
            // Filters
            var spa = await _context.SmsPlanAssignments.Include(s => s.PhoneLine).Include(s => s.SmsPlan).ToListAsync();

            List <SMSPlanAssignment> _spa         = spa.ToList();
            List <SMSPlanAssignment> final_result = new List <SMSPlanAssignment>();

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

            _spa = DataFilter <SMSPlanAssignment> .Filter(phoneNumberList, (m) => m.PhoneNumber, _spa).ToList();

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

            _spa = DataFilter <SMSPlanAssignment> .Filter(smsPlanList, (m) => m.SMSPlanId, _spa, true).ToList();

            _spa = DataFilter <SMSPlanAssignment> .Filter(_year, (m) => m.Year, _spa).ToList();

            _spa = DataFilter <SMSPlanAssignment> .Filter(_month, (m) => m.Month, _spa).ToList();

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

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

            return(View(result.Item1));
        }
コード例 #7
0
        // GET: MobilePhoneDataPlanAssignments
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string month, string year, string dataPlanId,
                                                string pNCheck, string monthCheck, string yearCheck, string dPCheck,
                                                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>()
            {
                pNCheck, monthCheck, yearCheck, dPCheck
            }, new List <string>()
            {
                phoneNumber, month, year, dataPlanId
            });
            ViewData["columns"] = show;
            //
            var dpa = await _context.DataPlanAssignments.Include(m => m.DataPlan).Include(m => m.PhoneLine).ToListAsync();

            //IEnumerable<CallingPlan> callingPlans = await _context.CallingPlans.ToListAsync();
            List <DataPlanAssignment> _dpa         = dpa.ToList();
            List <DataPlanAssignment> final_result = new List <DataPlanAssignment>();

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

            _dpa = DataFilter <DataPlanAssignment> .Filter(phoneNumberList, (m) => m.PhoneNumber, _dpa).ToList();

            _dpa = DataFilter <DataPlanAssignment> .Filter(_month, (m) => m.Month, _dpa).ToList();

            _dpa = DataFilter <DataPlanAssignment> .Filter(_year, (m) => m.Year, _dpa).ToList();

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

            _dpa = DataFilter <DataPlanAssignment> .Filter(dataPlanIdList, (m) => m.DataPlanId, _dpa, true).ToList();

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

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

            return(View(result.Item1));
        }
コード例 #8
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));
        }
コード例 #9
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));
        }
コード例 #10
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));
        }
コード例 #11
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));
        }
コード例 #12
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));
        }
コード例 #13
0
        // GET: PhoneLines
        public async Task <IActionResult> Index(int cpage, string phoneNumber, string pUK, string pIN,
                                                string phoneNumberCheck, string pUKCheck, string pINCheck,
                                                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
            }, new List <string>()
            {
                phoneNumber, pUK, pIN
            });
            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();

            //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;

            return(View(result.Item1));
        }
コード例 #14
0
        // GET: SMSPlans
        public async Task <IActionResult> Index(int cpage, string smsPlanId, string messages, string minCost, string maxCost,
                                                string sPCheck, string messagesCheck, string costCheck, string page, string next, string previous)
        {
            var _messages = Parse.IntTryParse(messages);
            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>()
            {
                sPCheck, messagesCheck, costCheck, costCheck
            }, new List <string>()
            {
                smsPlanId, messages, minCost, maxCost
            });
            ViewData["columns"] = show;
            //
            IEnumerable <SMSPlan> smsPlans = await _context.SmsPlans.ToListAsync();

            List <SMSPlan> _smsPlans    = smsPlans.ToList();
            List <SMSPlan> final_result = new List <SMSPlan>();

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

            _smsPlans = DataFilter <SMSPlan> .Filter(smsPlanIdList, (m) => m.SMSPlanId, _smsPlans, true).ToList();

            _smsPlans = DataFilter <SMSPlan> .Filter(_messages, (m) => m.Messages, _smsPlans).ToList();

            _smsPlans = DataFilter <SMSPlan> .Filter(_minCost, _maxCost, (m) => m.Cost, _smsPlans).ToList();

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

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

            return(View(result.Item1));
        }
コード例 #15
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));
        }
コード例 #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;

            return(View(result.Item1));
        }
コード例 #17
0
        // GET: MobilePhoneEmployees
        public async Task <IActionResult> Index(int cpage, string iMEI, string name,
                                                string iMEICheck, string employeeNameCheck,
                                                string page, string next, string previous)
        {
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                iMEICheck, employeeNameCheck
            }, new List <string>()
            {
                iMEI, name
            });
            ViewData["columns"] = show;
            //
            IEnumerable <MobilePhoneEmployee> mobilePhoneEmployees = await _context.MobilePhoneEmployees.Include(m => m.Employee).Include(m => m.MobilePhone).ToListAsync();

            List <MobilePhoneEmployee> _mobilePhoneEmployees = mobilePhoneEmployees.ToList();
            List <MobilePhoneEmployee> final_result          = new List <MobilePhoneEmployee>();

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

            _mobilePhoneEmployees = DataFilter <MobilePhoneEmployee> .Filter(iMEIList, (m) => m.IMEI, _mobilePhoneEmployees).ToList();

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

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

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

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

            return(View(result.Item1));
        }
コード例 #18
0
ファイル: SMSController.cs プロジェクト: Regnod/PhoneService
        // 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));
        }
コード例 #19
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));
        }
コード例 #20
0
        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, callingPlanIdCheck, callsCheck, callsCheck, smsCheck, smsCheck, gprsCheck, gprsCheck, totalCheck, totalCheck, monthCheck, yearCheck, costCenterCodeCheck, costCenterNameCheck
            },
                                                  new List <string>()
            {
                employeeName, phoneNumber, callingPlanId, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, minTotal, maxTotal, month, year, costCenterCode, costCenterName
            });
            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;

            return(View(result.Item1));
        }
コード例 #21
0
        // 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;

            return(View(result.Item1));
        }
コード例 #22
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, totalCostCheck, totalCostCheck, locationCheck, locationCheck, destinationCheck, roamingCheck
            },
                                                  new List <string>()
            {
                phoneNumber, day, month, year, er, min, max, 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;

            return(View(result.Item1));
            //List<List<SMS>> calls = new List<List<SMS>>();
            //List<SMS> list = new List<SMS>();
            //int i = 0;
            //int j = 0;
            //foreach (var call in _mensajes)
            //{
            //    if (i == 20)
            //    {
            //        j++;
            //        i = 0;
            //        calls.Add(list);
            //        list = new List<SMS>();
            //    }
            //    list.Add(call);
            //    i++;
            //}
            //if (i < 20)
            //{
            //    calls.Add(list);
            //    j++;
            //}
            //// elegir pagina
            //int currentPage = 0;
            //if (page != null)
            //{
            //    currentPage = (Parse.IntTryParse(page) != -1) ? Parse.IntTryParse(page) - 1 : (cpage >= j) ? 0 : cpage;
            //}
            //else if (next != null)
            //    currentPage = (cpage + 1 >= j) ? cpage : cpage + 1;
            //else if (previous != null)
            //    currentPage = (cpage - 1 < 0) ? 0 : cpage - 1;

            //int mult = currentPage / 20;

            //if (j > 20 && j - currentPage < 20)
            //    ViewData["top"] = j - currentPage;
            //else if (j < 20 && j - currentPage < 20)
            //    ViewData["top"] = j;
            //else
            //    ViewData["top"] = 20;

            //ViewData["mult"] = mult;
            //ViewData["columns"] = show;
            //ViewData["page"] = currentPage;

            //if (calls.Count != 0)
            //{
            //    if (j > currentPage)
            //    {
            //        ViewData["page"] = currentPage;
            //        return View(calls[currentPage]);
            //    }
            //    else
            //    {
            //        if (j >= cpage)
            //        {
            //            ViewData["page"] = cpage;
            //            return View(calls[cpage]);
            //        }
            //        else
            //        {
            //            cpage = 0;
            //            ViewData["page"] = cpage;
            //            return View(calls[0]);
            //        }
            //    }
            //}
            //else
            //    return View(new List<SMS>());
        }
コード例 #23
0
        // 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));
        }
コード例 #24
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));
        }
コード例 #25
0
        public async Task <IActionResult> Index(int cpage, string management,
                                                string minCalls, string maxCalls, string minSms, string maxSms, string minGprs, string maxGprs, string minTotal, string maxTotal, string minPercent, string maxPercent,
                                                string managementCheck, string callsCheck, string smsCheck, string gprsCheck, string totalCheck, string percentCheck, 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 _minPercent = Parse.FloatTryParse(minPercent);
            var _maxPercent = Parse.FloatTryParse(maxPercent);

            var models = new List <ManagementsMobilePhoneExpense>();

            if (_year == -1 && _month != -1)
            {
                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
                              join m in _context.Managements on cc.ManagementId equals m.ManagementId
                              where pls.Month == _month
                              select new
                {
                    ManagementId = m.ManagementId,
                    ManagementName = m.Name,
                    Calls = pls.AirTime,
                    SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                    GPRS = pls.GprsExpenses + pls.RoamingGprsExpenses,
                    Month = pls.Month,
                    Year = pls.Year,
                    Total = pls.Total
                }
                              ).AsEnumerable();
                query1 = query1.ToList();
                var   query2 = query1.GroupBy(a => a.ManagementId);
                float total  = 0;
                foreach (var _management in query2)
                {
                    var model = new ManagementsMobilePhoneExpense()
                    {
                        Management = _management.Select(a => a.ManagementName).First(),
                        Calls      = _management.Sum(a => a.Calls),
                        GPRS       = _management.Sum(a => a.GPRS),
                        SMS        = _management.Sum(a => a.SMS),
                        Total      = _management.Sum(a => a.Total),
                        Month      = _management.Select(a => a.Month).First(),
                        Year       = _management.Select(a => a.Year).First(),
                        Percent    = 0
                    };
                    total += model.Total;
                    models.Add(model);
                }
                foreach (var model in models)
                {
                    model.Percent = 100 * (model.Total / total);
                }
            }
            else if (_month != -1 && _year != -1)
            {
                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
                              join m in _context.Managements on cc.ManagementId equals m.ManagementId
                              where pls.Month == _month && pls.Year == _year
                              select new
                {
                    ManagementId = m.ManagementId,
                    ManagementName = m.Name,
                    Calls = pls.AirTime,
                    SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                    GPRS = pls.GprsExpenses + pls.RoamingGprsExpenses,
                    Month = pls.Month,
                    Year = pls.Year,
                    Total = pls.Total
                }
                              ).AsEnumerable();
                query1 = query1.ToList();
                var   query2 = query1.GroupBy(a => a.ManagementId);
                float total  = 0;
                foreach (var _management in query2)
                {
                    var model = new ManagementsMobilePhoneExpense()
                    {
                        Management = _management.Select(a => a.ManagementName).First(),
                        Calls      = _management.Sum(a => a.Calls),
                        GPRS       = _management.Sum(a => a.GPRS),
                        SMS        = _management.Sum(a => a.SMS),
                        Total      = _management.Sum(a => a.Total),
                        Month      = _management.Select(a => a.Month).First(),
                        Year       = _management.Select(a => a.Year).First(),
                        Percent    = 0
                    };
                    total += model.Total;
                    models.Add(model);
                }
                foreach (var model in models)
                {
                    model.Percent = 100 * (model.Total / total);
                }
            }
            else if (_month == -1 && _year != -1)
            {
                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
                              join m in _context.Managements on cc.ManagementId equals m.ManagementId
                              where pls.Year == _year
                              select new
                {
                    ManagementId = m.ManagementId,
                    ManagementName = m.Name,
                    Calls = pls.AirTime,
                    SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                    GPRS = pls.GprsExpenses + pls.RoamingGprsExpenses,
                    Month = pls.Month,
                    Year = pls.Year,
                    Total = pls.Total
                }
                              ).AsEnumerable();
                query1 = query1.ToList();
                var   query2 = query1.GroupBy(a => a.ManagementId);
                float total  = 0;
                foreach (var _management in query2)
                {
                    var model = new ManagementsMobilePhoneExpense()
                    {
                        Management = _management.Select(a => a.ManagementName).First(),
                        Calls      = _management.Sum(a => a.Calls),
                        GPRS       = _management.Sum(a => a.GPRS),
                        SMS        = _management.Sum(a => a.SMS),
                        Total      = _management.Sum(a => a.Total),
                        Month      = _management.Select(a => a.Month).First(),
                        Year       = _management.Select(a => a.Year).First(),
                        Percent    = 0
                    };
                    total += model.Total;
                    models.Add(model);
                }
                foreach (var model in models)
                {
                    model.Percent = 100 * (model.Total / total);
                }
            }
            else
            {
                _month = DateTime.Now.Month;
                _year  = DateTime.Now.Year;
                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
                              join m in _context.Managements on cc.ManagementId equals m.ManagementId
                              where pls.Month == _month && pls.Year == _year
                              select new
                {
                    ManagementId = m.ManagementId,
                    ManagementName = m.Name,
                    Calls = pls.AirTime,
                    SMS = pls.SmsExpenses + pls.RoamingSmsExpenses,
                    GPRS = pls.GprsExpenses + pls.RoamingGprsExpenses,
                    Month = pls.Month,
                    Year = pls.Year,
                    Total = pls.Total
                }
                              ).AsEnumerable();
                query1 = query1.ToList();
                var   query2 = query1.GroupBy(a => a.ManagementId);
                float total  = 0;
                foreach (var _management in query2)
                {
                    var model = new ManagementsMobilePhoneExpense()
                    {
                        Management = _management.Select(a => a.ManagementName).First(),
                        Calls      = _management.Sum(a => a.Calls),
                        GPRS       = _management.Sum(a => a.GPRS),
                        SMS        = _management.Sum(a => a.SMS),
                        Total      = _management.Sum(a => a.Total),
                        Month      = _management.Select(a => a.Month).First(),
                        Year       = _management.Select(a => a.Year).First(),
                        Percent    = 0
                    };
                    total += model.Total;
                    models.Add(model);
                }
                foreach (var model in models)
                {
                    model.Percent = 100 * (model.Total / total);
                }
            }
            //
            Tuple <bool, string>[] show = SD.Show(new List <string>()
            {
                managementCheck, callsCheck, callsCheck, smsCheck, smsCheck, gprsCheck, gprsCheck, totalCheck, totalCheck, percentCheck, percentCheck, monthCheck, yearCheck
            },
                                                  new List <string>()
            {
                management, minCalls, maxCalls, minSms, maxSms, minGprs, maxGprs, minTotal, maxTotal, minPercent, maxPercent, month, year
            });

            //
            List <ManagementsMobilePhoneExpense> final_result = new List <ManagementsMobilePhoneExpense>();

            if (management != null)
            {
                foreach (var cp in models)
                {
                    if (cp.Management.ToLower().Contains(management.ToLower()))
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            #region filter Min max
            // calls
            if (_minCalls != -1 && _maxCalls != -1)
            {
                foreach (var cp in models)
                {
                    if (_minCalls <= cp.Calls && cp.Calls <= _maxCalls)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minCalls == -1 && _maxCalls != -1)
            {
                foreach (var cp in models)
                {
                    if (cp.Calls <= _maxCalls)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minCalls != -1 && _maxCalls == -1)
            {
                foreach (var cp in models)
                {
                    if (_minCalls <= cp.Calls)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            // sms
            if (_minSms != -1 && _maxSms != -1)
            {
                foreach (var cp in models)
                {
                    if (_minSms <= cp.SMS && cp.SMS <= _maxSms)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minSms == -1 && _maxSms != -1)
            {
                foreach (var cp in models)
                {
                    if (cp.SMS <= _maxSms)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minSms != -1 && _maxSms == -1)
            {
                foreach (var cp in models)
                {
                    if (_minSms <= cp.SMS)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            // gprs
            if (_minGprs != -1 && _maxGprs != -1)
            {
                foreach (var cp in models)
                {
                    if (_minGprs <= cp.GPRS && cp.GPRS <= _maxGprs)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minGprs == -1 && _maxGprs != -1)
            {
                foreach (var cp in models)
                {
                    if (cp.GPRS <= _maxGprs)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minGprs != -1 && _maxGprs == -1)
            {
                foreach (var cp in models)
                {
                    if (_minGprs <= cp.GPRS)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            // total
            if (_minTotal != -1 && _maxTotal != -1)
            {
                foreach (var cp in models)
                {
                    if (_minTotal <= cp.Total && cp.Total <= _maxTotal)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minTotal == -1 && _maxTotal != -1)
            {
                foreach (var cp in models)
                {
                    if (cp.Total <= _maxTotal)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            if (_minTotal != -1 && _maxTotal == -1)
            {
                foreach (var cp in models)
                {
                    if (_minTotal <= cp.Total)
                    {
                        final_result.Add(cp);
                    }
                }
                models       = final_result;
                final_result = new List <ManagementsMobilePhoneExpense>();
            }
            //
            #endregion
            //separar en paginas
            List <List <ManagementsMobilePhoneExpense> > pages = new List <List <ManagementsMobilePhoneExpense> >();
            List <ManagementsMobilePhoneExpense>         list  = new List <ManagementsMobilePhoneExpense>();
            int i = 0;
            int j = 0;
            foreach (var item in models)
            {
                if (i == 20)
                {
                    j++;
                    i = 0;
                    pages.Add(list);
                    list = new List <ManagementsMobilePhoneExpense>();
                }
                list.Add(item);
                i++;
            }
            if (i < 20)
            {
                pages.Add(list);
                j++;
            }
            // elegir pagina
            int currentPage = 0;
            if (page != null)
            {
                currentPage = (Parse.IntTryParse(page) != -1) ? Parse.IntTryParse(page) - 1 : (cpage >= j) ? 0 : cpage;
            }
            else if (next != null)
            {
                currentPage = (cpage + 1 >= j) ? cpage : cpage + 1;
            }
            else if (previous != null)
            {
                currentPage = (cpage - 1 < 0) ? 0 : cpage - 1;
            }

            int mult = currentPage / 20;

            if (j > 20 && j - currentPage < 20)
            {
                ViewData["top"] = j - currentPage;
            }
            else if (j < 20 && j - currentPage < 20)
            {
                ViewData["top"] = j;
            }
            else
            {
                ViewData["top"] = 20;
            }

            ViewData["mult"]    = mult;
            ViewData["columns"] = show;
            //return View(_mobilePhoneCalls);

            //Arreglar la parte de paginado y cambiar el 2do parametro de csvstringconstructor x result.item1 y poner las 2 instucciones del csv aqui

            ViewData["page"] = currentPage;
            if (pages.Count != 0)
            {
                if (j > currentPage)
                {
                    string ss = CSVStringConstructor(show, pages[currentPage]);
                    ViewData["csv"]  = ss;
                    ViewData["page"] = currentPage;
                    return(View(pages[currentPage]));
                }
                else
                {
                    if (j >= cpage)
                    {
                        string ss = CSVStringConstructor(show, pages[cpage]);
                        ViewData["csv"]  = ss;
                        ViewData["page"] = cpage;
                        return(View(pages[cpage]));
                    }
                    else
                    {
                        cpage = 0;
                        string ss = CSVStringConstructor(show, pages[0]);
                        ViewData["csv"]  = ss;
                        ViewData["page"] = cpage;
                        return(View(pages[0]));
                    }
                }
            }
            else
            {
                return(View(new List <ManagementsMobilePhoneExpense>()));
            }
        }