Exemple #1
0
        public void RemoveNavLinkFromDataPlan(NavLink nav_link, int admin_id)  //not a component!
        {
            DataPlan admin_data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            admin_data_plan.total_bytes -= nav_link.FindCharLength();
            _dbQuery.UpdateDataPlan(admin_data_plan);
        }
Exemple #2
0
        private void StoreDataPlanAssigment(PhoneNumber phoneNumber, DateTime date)
        {
            if (phoneNumber.DataPlan == null)
            {
                return;
            }

            var dataPlan = _dbContext.DataPlans.Find(phoneNumber.DataPlan);

            if (dataPlan == null)
            {
                dataPlan = new DataPlan()
                {
                    DataPlanId = phoneNumber.DataPlan
                };
                _dbContext.DataPlans.Add(dataPlan);
            }

            _dbContext.DataPlanAssignments.Add(new DataPlanAssignment()
            {
                DataPlanId  = dataPlan.DataPlanId,
                PhoneNumber = phoneNumber.Number,
                Month       = date.Month,
                Year        = date.Year
            });
        }
Exemple #3
0
        public async Task <IActionResult> Edit(string id, [Bind("DataPlanId,Data")] DataPlan dataPlan)
        {
            if (ModelState.IsValid)
            {
                var dp = await _context.DataPlans.FindAsync(id);

                try
                {
                    //_context.Update(costCenter);
                    _context.DataPlans.Remove(dp);
                    _context.Add(dataPlan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DataPlanExists(dataPlan.DataPlanId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { dPCheck = "On", dataCheck = "On" }));
            }
            return(View(dataPlan));
        }
Exemple #4
0
        public void RemoveSiteFromDataPlan(int admin_id)
        {
            DataPlan admin_data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            admin_data_plan.total_bytes -= this._site_container_size;
            _dbQuery.UpdateDataPlan(admin_data_plan);
        }
Exemple #5
0
        public int ExecuteDataPlan(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
        {
            if (nDumpOptions.Export)
            {
                var queryExecutor = new QueryExecutor(nDumpOptions.SourceConnectionString);
                ISelectionFilteringStrategy filteringStrategy = nDumpOptions.ApplyFilters ? (ISelectionFilteringStrategy)
                                                                                         new UseFilterIfPresentStrategy(queryExecutor, logger)
                                                                    : new IgnoreFilterStrategy();
                var exporter = new SqlDataExporter(logger, nDumpOptions.CsvDirectory,
                                                   queryExecutor, filteringStrategy);
                try
                {
                    exporter.ExportToCsv(dataPlan.SetupScripts, dataPlan.DataSelects);

                }
                catch (nDumpApplicationException ex)
                {

                    logger.Log("Export To Csv Failed.\n" + ex.StackTrace);
                    return -1;

                }
            }
            if (nDumpOptions.Transform)
            {
                var transformer = new DataTransformer(nDumpOptions.SqlDirectory, nDumpOptions.CsvDirectory,
                                                      logger);
                try
                {

                    transformer.ConvertCsvToSql(dataPlan.DataSelects);

                }
                catch (nDumpApplicationException ex)
                {

                    logger.Log("Export To Csv Failed.\n" + ex.StackTrace);
                    return -1;

                }
            }
            if (nDumpOptions.Import)
            {
                var importer = new SqlDataImporter(logger,
                                                   new QueryExecutor(nDumpOptions.TargetConnectionString), new IncrementingNumberSqlScriptFileStrategy(nDumpOptions.SqlDirectory));
                try
                {
                    importer.RemoveDataAndImportFromSqlFiles(dataPlan.DataSelects);
                }
                catch (nDumpApplicationException ex)
                {

                    logger.Log("Import Of Sql Failed.\n" + ex.Message + "\n" + ex.StackTrace);
                    return -1;

                }

            }
            return 0;
        }
Exemple #6
0
        public async Task <IActionResult> Edit(int id, [Bind("DataPlanId,NationalData,InternationalData")] DataPlan dataPlan)
        {
            if (id != dataPlan.DataPlanId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dataPlan);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DataPlanExists(dataPlan.DataPlanId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dataPlan));
        }
Exemple #7
0
        //does not remove component itself.
        public void RemoveFromDataPlan(SiteComponent site_component, int admin_id)
        {
            DataPlan admin_data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            admin_data_plan.total_bytes -= site_component.FindCharLength();
            _dbQuery.UpdateDataPlan(admin_data_plan);
        }
Exemple #8
0
        public DataPlan UpdateDataPlan(DataPlan updated_data_plan)
        {
            DataPlan data_plan = GetDataPlanByAdminId(updated_data_plan.admin_id);

            data_plan.total_bytes = updated_data_plan.total_bytes;
            dbContext.SaveChanges();
            return(data_plan);
        }
Exemple #9
0
        public async Task <IActionResult> Create([Bind("DataPlanId,NationalData,InternationalData")] DataPlan dataPlan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dataPlan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dataPlan));
        }
Exemple #10
0
        public async Task <IActionResult> Create([Bind("DataPlanId,Data")] DataPlan dataPlan)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dataPlan);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { dPCheck = "On", dataCheck = "On" }));
            }
            return(View(dataPlan));
        }
Exemple #11
0
        //site components
        public DataPlan ValidateComponentAdditionForDataPlan(int admin_id, SiteComponent site_component)
        {
            DataPlan data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            data_plan.total_bytes += site_component.FindCharLength();

            if (data_plan.total_bytes <= data_plan.max_bytes)
            {
                return(data_plan);
            }
            else
            {
                throw new System.ArgumentException($"New {site_component.GetType().Name.ToString()} exceeds data plan limits. Reduce data use by deleting sites and or components.");
            }
        }
Exemple #12
0
        public static List <DataPlan> AutoPlan(DataTable datatable)
        {
            List <DataPlan> lista = new List <DataPlan>();

            foreach (DataRow DtRow in datatable.Rows)
            {
                if (DtRow[4].Equals("5"))
                {
                    DataPlan item = new DataPlan
                    {
                        Codigo  = Convert.ToString(DtRow[1]),
                        TCodigo = String.Format("{0}  ||  {1}", DtRow[1], DtRow[2]),
                        Cuenta  = Convert.ToString(DtRow[2]),
                    };
                    lista.Add(item);
                }
            }
            return(lista);
        }
Exemple #13
0
        public DataPlan ValidateNavLinkAdditionForDataPlan(int admin_id, NewNavLinkDto new_nav_link)  //Nav Links are not a SiteComponent
        {
            NavLink nav_link = new NavLink();

            nav_link.label = new_nav_link.label;
            nav_link.url   = new_nav_link.url;

            DataPlan data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            data_plan.total_bytes += nav_link.FindCharLength();
            if (data_plan.total_bytes <= data_plan.max_bytes)
            {
                return(data_plan);
            }
            else
            {
                throw new System.ArgumentException($"New {nav_link.GetType().Name.ToString()} exceeds data plan limits. Reduce data use by deleting sites and or components.");
            }
        }
Exemple #14
0
        public DataPlan ValidateDataPlanB(int admin_id, SiteComponent old_site_component, SiteComponent new_site_component)
        {
            DataPlan data_plan = _dbQuery.GetDataPlanByAdminId(admin_id);

            //remove current component byte cost
            data_plan.total_bytes -= old_site_component.FindCharLength();

            //calculate new cost
            data_plan.total_bytes += new_site_component.FindCharLength();

            //compare
            if (data_plan.total_bytes <= data_plan.max_bytes)
            {
                return(data_plan);
            }
            else
            {
                throw new System.ArgumentException("New component exceeds data plan limits.");
            }
        }
Exemple #15
0
        //site
        public DataPlan ValidateSiteAdditionForDataPlan(int admin_id)
        {
            int      total_site_count = _dbQuery.GetSiteCountForAdminId(admin_id);
            DataPlan data_plan        = _dbQuery.GetDataPlanByAdminId(admin_id);

            if (!(total_site_count < data_plan.max_sites)) //must be strictly less than. Will add a site.
            {
                throw new System.ArgumentException($"New site adddition exceeds maximum site count of {total_site_count} for this account.");
            }

            data_plan.total_bytes += this._site_container_size;

            if (data_plan.total_bytes <= data_plan.max_bytes)
            {
                return(data_plan);
            }
            else
            {
                throw new System.ArgumentException("Creating this leaf would exceed the data limits for this account. Delete sites or components to free data.");
            }
        }
Exemple #16
0
 private void LoadDataPlan(DataPlan dataPlan)
 {
     _dataPlan = dataPlan;
     dataPlanPropertyGrid.SelectedObject = _dataPlan;
 }
Exemple #17
0
 public void UpdateDataPlan(DataPlan data_plan)
 {
     _dbQuery.UpdateDataPlan(data_plan);
 }
 private static void AssertLocalCall(long kBytesUsed, long billingFrequencyBytes, long expectedPrice)
 {
     var call = new DataCall(kBytesUsed, TestCalls.LocalCall);
     var plan = new DataPlan(20, billingFrequencyBytes);
     new DataTaxation().CalculatePrice(call, plan).Value.Should().Be(expectedPrice);
 }
 public void LongDistanceCall()
 {
     var call = new DataCall(2.Megabyte(), TestCalls.LongDiscanceCall);
     var plan = new DataPlan(20, 1.Megabyte());
     new DataTaxation().CalculatePrice(call, plan).Value.Should().Be(60);
 }
Exemple #20
0
 public ExportForm(DataPlan dataPlan)
 {
     _dataPlan = dataPlan;
     InitializeComponent();
 }