Example #1
0
        protected override void RunCore(Args args)
        {
            var environmentName = args.Arguments.Skip(1).FirstOrDefault();
            var extractions     = ExtractionInstructions.Parse(args.Arguments.Skip(2).ToArray());

            if (environmentName == null)
            {
                throw new Exception("You need to specify an environment");
            }

            var environment = Plans.Environment(environmentName);

            using (var context = new DataContext(environment.ConnectionString))
            {
                var metabase = new ContextMetabase(context);

                foreach (var extraction in extractions)
                {
                    extraction.Update(metabase, Plans);
                }


                new XElement("Extract",
                             extractions.Select(x => x.Run(metabase))
                             ).Save(ExtractFile);
            }
        }
Example #2
0
        /// <summary>
        /// Creates a 3D plan.
        /// </summary>
        /// <param name="fftType">Type of FFT.</param>
        /// <param name="dataType">Data type.</param>
        /// <param name="nx">The number of samples in x dimension.</param>
        /// <param name="ny">The number of samples in y dimension.</param>
        /// <param name="nz">The number of samples in z dimension.</param>
        /// <param name="batchSize">Size of batch.</param>
        /// <returns>Plan.</returns>
        public override FFTPlan3D Plan3D(eFFTType fftType, eDataType dataType, int nx, int ny, int nz, int batchSize)
        {
            int         insize, outsize;
            CUFFTType   cuFFTType = VerifyTypes(fftType, dataType, out insize, out outsize);
            cufftHandle handle    = new cufftHandle();

            CUFFTResult res;

            if (batchSize <= 1)
            {
                res = _driver.cufftPlan3d(ref handle, nx, ny, nz, cuFFTType);
            }
            else
            {
                res = _driver.cufftPlanMany(ref handle, 3, new int[] { nx, ny, nz }, null, 1, 0, null, 1, 0, cuFFTType, batchSize);
            }

            if (res != CUFFTResult.Success)
            {
                throw new CudafyHostException(res.ToString());
            }
            FFTPlan3D   plan   = new FFTPlan3D(nx, ny, nz, batchSize, this);
            FFTPlan3DEx planEx = new FFTPlan3DEx(plan)
            {
                CudaFFTHandle = handle, CudaFFTType = cuFFTType, DataType = dataType
            };

            Plans.Add(plan, planEx);
            return(plan);
        }
        private void GetPlanForSpecficDay( )
        {
            PlanText = "";
            string topBarDayText = ActualDayText.ToLower();

            if (topBarDayText == "today")
            {
                topBarDayText = DayName.ToString().ToLower();
            }
            Plans.Clear();
            string userDayText = "";

            foreach (var item in Session.LoggedUser.Plans)
            {
                string[] daysTab = item.DayOfRepeat.Split(' ');


                foreach (string day in daysTab)
                {
                    userDayText = day.ToLower();
                    if (userDayText == topBarDayText)
                    {
                        ShowPlanInLabel(item);
                        Exs = ConvertListToObservable(item.Excercises);
                    }
                }
            }
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate")] Plans plans)
        {
            if (id != plans.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plans);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlansExists(plans.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(plans));
        }
Example #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Plans = await _context.Plans
                    .Include(p => p.Role)
                    .Include(p => p.SongToPlan)
                    .ThenInclude(p => p.SongAssignment)
                    .ThenInclude(p => p.Song)
                    .Include(p => p.SongToPlan)
                    .ThenInclude(p => p.SongAssignment)
                    .ThenInclude(p => p.SongType)
                    .Include(p => p.PrayerToPlan)
                    .ThenInclude(p => p.PrayerType)
                    .Include(p => p.PrayerToPlan)
                    .ThenInclude(p => p.Member)
                    .Include(p => p.SpeakToPlan)
                    .ThenInclude(p => p.SpeakAssignment)
                    .ThenInclude(p => p.Member)
                    .Include(p => p.SpeakToPlan)
                    .ThenInclude(p => p.SpeakAssignment)
                    .ThenInclude(p => p.Subject)
                    .FirstOrDefaultAsync(m => m.PlansID == id);

            if (Plans == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public static List <Plans> GetCustomerDailyLog(string planID)
        {
            string       day      = System.DateTime.Now.DayOfWeek.ToString();
            List <Plans> lstPlans = new List <Plans>();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            SqlConnection oCon = GetConnection(builder);

            SqlCommand cmd = new SqlCommand("Select Meal.Day,Meal.MealType,FoodDetail.Quantity,FoodDetail.Weight,Food.FoodName,Food.FoodCalorie,Food.FoodCategory from Meal inner join FoodDetail ON Meal.MealID = FoodDetail.MealID inner join Food ON Food.FoodID = FoodDetail.FoodID where Meal.PlanID = @PlanID AND Meal.Day = @Day", oCon);

            cmd.Parameters.AddWithValue("@PlanID", planID);
            cmd.Parameters.AddWithValue("@Day", day);
            oCon.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Plans oPlans = new Plans();
                oPlans.Day          = dr["Day"].ToString();
                oPlans.MealType     = dr["MealType"].ToString();
                oPlans.Quantity     = dr["Quantity"].ToString();
                oPlans.Weight       = dr["Weight"].ToString();
                oPlans.FoodName     = dr["FoodName"].ToString();
                oPlans.FoodCalorie  = dr["FoodCalorie"].ToString();
                oPlans.FoodCategory = dr["FoodCategory"].ToString();
                lstPlans.Add(oPlans);
            }
            oCon.Close();
            return(lstPlans);
        }
Example #7
0
        public void GetPlansForDistributor()
        {
            ConfigLoader.LoadConfig();

            Plans actual = null;

            Account acct = new Account();

            //acct.Email = "*****@*****.**";
            //acct.Password = "******";

            //if (acct.Login() == false)
            //{
            //    return;
            //}

            try
            {
                actual = acct.BillingPlans();
            }
            catch (Exception)
            {
            }

            Assert.IsNotNull(actual);
        }
        /// <inheritdoc/>
        protected async override void OnApplyTemplate()
        {
            ClearTasks();
            Buckets.Clear();
            Plans.Clear();

            if (_list != null)
            {
                _list.ItemClick -= List_ItemClick;
                _list.Tapped    += List_Tapped;
                if (_isPreviewKeyUpEventSupported)
                {
                    _list.PreviewKeyUp -= List_PreviewKeyUp;
                }
            }

            if (_add != null)
            {
                _add.Click -= Add_Click;
            }

            if (_input != null)
            {
                _input.KeyUp -= Input_KeyUp;
            }

            base.OnApplyTemplate();
            if (GetTemplateChild(ControlTasks) is ListView list)
            {
                _list            = list;
                _list.ItemClick += List_ItemClick;
                _list.Tapped    += List_Tapped;
                if (_isPreviewKeyUpEventSupported)
                {
                    _list.PreviewKeyUp += List_PreviewKeyUp;
                }
            }

            if (GetTemplateChild(ControlAdd) is Button add)
            {
                _add        = add;
                _add.Click += Add_Click;
            }

            _input = GetTemplateChild(ControlInput) as TextBox;
            if (_input != null)
            {
                _input.KeyUp += Input_KeyUp;
            }

            if (MicrosoftGraphService.Instance.IsAuthenticated)
            {
                await LoadPlansAsync();
            }
            else
            {
                MicrosoftGraphService.Instance.IsAuthenticatedChanged -= Instance_IsAuthenticatedChanged;
                MicrosoftGraphService.Instance.IsAuthenticatedChanged += Instance_IsAuthenticatedChanged;
            }
        }
Example #9
0
        public async Task <IActionResult> PutPlans([FromRoute] long id, [FromBody] Plans plans)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != plans.Id)
            {
                return(BadRequest());
            }

            _context.Entry(plans).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlansExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public DashboardView()
        {
            InitializeComponent();

            AndonManager = new AndonManager(StationList, null, Andonmanager.AndonManager.MODE.MASTER);

            AndonManager.start();
            StationList = new Queue<int>();

            Plans = new Plans();
            PlanGrid.DataContext = Plans;

            Actuals = new Models.Actuals();
            ActualGrid.DataContext = Actuals;

            AppTimer = new Timer(1000);
            AppTimer.AutoReset = false;
            AppTimer.Elapsed += AppTimer_Elapsed;

            EfficiencyWatch = new Stopwatch();

            using (PSBContext DBContext = new PSBContext())
            {

                Shifts = DBContext.Shifts.ToList();

                foreach (Shift s in Shifts)
                {
                    s.Update();
                }

            }

            AppTimer.Start();
        }
Example #11
0
        public async Task Create_a_valid_invoice()
        {
            // Arrange
            InvoiceModel invoice;

            var customVariables = new List <CustomVariables>
            {
                new CustomVariables {
                    name = "TaxaIugu", value = "2,50"
                },
                new CustomVariables {
                    name = "TaxaPlataformaEdux", value = "1,00"
                }
            };

            var invoiceDate = DateTime.Now.AddDays(2);

            var customer = new CustomerRequestMessage
            {
                Email           = "*****@*****.**",
                Name            = "Client Name",
                CustomVariables = customVariables
            };

            // Act
            using (var apiInvoice = new Invoice())
                using (var apiCustomer = new Customer())
                    using (var apiSubscription = new Subscription())
                        using (var apiPlan = new Plans())
                        {
                            var customerResponse = await apiCustomer.CreateAsync(customer, null).ConfigureAwait(false);

                            var radomPlan = Guid.NewGuid().ToString();
                            var plan      = await apiPlan.CreateAsync($"{radomPlan}-12x", $"{radomPlan}-Plan", 1, "months", 0, "BRL", null, null, Constants.PaymentMethod.BANK_SLIP).ConfigureAwait(false);

                            var subscriptionItems = new List <SubscriptionSubitem> {
                                new SubscriptionSubitem {
                                    description = "Mensalidade", price_cents = 65000, quantity = 1, recurrent = true
                                }
                            };
                            var subscription = await apiSubscription.CreateAsync(new SubscriptionRequestMessage(customerResponse.id)
                            {
                                PlanId          = plan.identifier,
                                IsCreditBased   = false,
                                CustomVariables = customVariables,
                                Subitems        = subscriptionItems
                            }).ConfigureAwait(false);

                            var invoiceItems = new[] { new Item {
                                                           description = "Mensalidade", price_cents = 65000, quantity = 1
                                                       } };
                            invoice = await apiInvoice.CreateAsync("*****@*****.**", invoiceDate, invoiceItems, null, null, null, 0,
                                                                   0, null, false, subscription.id, null, null, customVariables, _payer)
                                      .ConfigureAwait(false);
                        };

            // Assert
            Assert.That(invoice, Is.Not.Null);
            Assert.That(invoice.due_date, Does.Contain(invoiceDate.ToString("yyyy-MM-dd")));
        }
Example #12
0
        public async Task List_all_plans()
        {
            // Arrange
            var radomPlan = Guid.NewGuid().ToString();
            var planId    = $"{radomPlan}-Plan";
            int originalCountPlans;
            var newCountPlans = 0;

            // Act
            using (var apiPlan = new Plans())
            {
                var planRequest = new PlanRequestMessage($"{radomPlan}-12x", planId, 1, PlanIntervalType.Monthly, 0)
                {
                    PaymentMethod = Constants.PaymentMethod.BANK_SLIP
                };

                var currentPlans = await apiPlan.GetAllAsync("74c265aedbfaea379bc0148fae9b5526").ConfigureAwait(false);

                originalCountPlans = currentPlans.TotalItems;
                var response = await apiPlan.CreateAsync(planRequest, "74c265aedbfaea379bc0148fae9b5526").ConfigureAwait(false);

                var newPlan = await apiPlan.GetByIdentifierAsync(response.identifier).ConfigureAwait(false);

                newCountPlans = newPlan != null ? originalCountPlans + 1 : newCountPlans;
            };

            // Assert
            Assert.That(newCountPlans, Is.GreaterThan(originalCountPlans));
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Plans.Clear();
                var plans = await PlanStore.GetDatasAsync(true);

                foreach (var item in plans)
                {
                    Plans.Add(item);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #14
0
 public static void EditPlans(List <Plan> newPlans)
 {
     using (CalendarDBContext db = new CalendarDBContext())
     {
         foreach (Plan plan in Plans)
         {
             if (newPlans.FindAll(p => p.Id == plan.Id).Count == 0)
             {
                 if (db.Plans.Where(p => p.Id == plan.Id).First().Users.Count <= 1)
                 {
                     db.Plans.Remove(db.Plans.Where(p => p.Id == plan.Id).First());
                 }
                 db.Users.Where(u => u.Id == ActiveUser.Id).First().Plans.Remove(db.Plans.Where(p => p.Id == plan.Id).First());
             }
         }
         foreach (Plan plan in newPlans)
         {
             if (Plans.FindAll(p => p.Id == plan.Id).Count == 0)
             {
                 db.Plans.Add(plan);
                 db.Users.Where(u => u.Id == ActiveUser.Id).First().Plans.Add(plan);
             }
         }
         db.SaveChanges();
     }
 }
        public void GetAllSubscriptionsPlans()
        {
            NetellerEnvironment[] environments = new[] { NetellerEnvironment.Test, NetellerEnvironment.Production };

            foreach (var environment in environments)
            {
                api = new RestAPI(environment);

                Console.WriteLine("Plans in " + environment);
                Console.WriteLine("===============================");

                Plans plans = api.GetPlans();

                plans.list.Sort((list, planList) => { return(list.planName.CompareTo(planList.planName)); });

                foreach (var list in plans.list.ToList())
                {
                    Console.WriteLine("PlanID {0}. Status: {7}. Amount {2} {3} Interval {4} count {5} type {6}. Name: {1}",
                                      list.planId,
                                      list.planName,
                                      list.amount / 100,
                                      list.currency,
                                      list.interval,
                                      list.intervalCount,
                                      list.intervalType,
                                      list.status
                                      );
                }

                Assert.That(plans.list, Is.Not.Empty);
            }
        }
        /// <summary>
        /// Checks if changing your plan is possible.
        /// And begins the plan change (upgrade/downgrade) process is requested.
        /// </summary>
        /// <param name="proceed">/if set <c>true</c> then the upgrade process begins (if upgrade/downgrade is possible), otherwise related information only displayed.</param>
        /// <returns></returns>
        public virtual async Task <ActionResult> ChangePlan(bool proceed = false)
        {
            Logger.LogInformation("Getting current user to continue the plan change process.");
            var me = await AppUserCache.GetLoggedOnUser();

            Logger.LogInformation("Found user is {@me}", me);
            Logger.LogInformation("Checking plan change feasibility.");
            var canUpgrage = Plans.CanUpgrade(me.PlanId.Value, me.IsAdmin);

            if (canUpgrage)
            {
                Logger.LogInformation("Plane change is possible.");
                if (proceed)
                {
                    Logger.LogInformation($"Redirecting to {SHOPIFY_ACTIONS.ChoosePlan.ToString()}.");
                    return(RedirectToAction(SHOPIFY_ACTIONS.ChoosePlan.ToString(), Settings.GetShopifyControllerName()));
                }
                else
                {
                    Logger.LogInformation("Rendering change plan view.");
                    Logger.LogInformation($"Change plan view name is {this.Views.MyProfile.ChangePlan}.");
                    return(View(this.Views.MyProfile.ChangePlan));
                }
            }
            else
            {
                Logger.LogWarning("Plane change is not possible already using highest plan.");
                WebMsg.AddTempInfo(this, "You are already using the highest plan.");
                Logger.LogInformation($"Redirecting to {PROFILE_ACTIONS.Index.ToString()}");
                return(RedirectToAction(PROFILE_ACTIONS.Index.ToString(), Settings.GetAppMyProfileControllerName()));
            }
        }
Example #17
0
        public void Delete(int planid)
        {
            Plan PlanToRemove = Plans.FirstOrDefault(w => w.PlanId == planid);

            Plans.Remove(PlanToRemove);
            SaveChanges();
        }
        /// <summary>
        /// Adds the specified plan details.
        /// </summary>
        /// <param name="planDetails">The plan details.</param>
        /// <returns> Plan Id.</returns>
        public int Save(Plans planDetails)
        {
            if (planDetails != null && !string.IsNullOrEmpty(planDetails.PlanId))
            {
                var existingPlan = this.context.Plans.Where(s => s.PlanId == planDetails.PlanId).FirstOrDefault();
                if (existingPlan != null)
                {
                    existingPlan.PlanId      = planDetails.PlanId;
                    existingPlan.Description = planDetails.Description;
                    existingPlan.DisplayName = planDetails.DisplayName;
                    existingPlan.OfferId     = planDetails.OfferId;
                    this.context.Plans.Update(existingPlan);
                    this.context.SaveChanges();
                    return(existingPlan.Id);
                }
                else
                {
                    this.context.Plans.Add(planDetails);
                    this.context.SaveChanges();
                    return(planDetails.Id);
                }
            }

            return(0);
        }
Example #19
0
        public ResultModel Update(PlansModel obj)
        {
            ResultModel oOutput = new ResultModel();

            try
            {
                Plans oPlans = dbSet.Where(m => m.ID == obj.ID).FirstOrDefault();
                if (oPlans == null)
                {
                    oOutput.Status = 0;
                    oOutput.Msg    = "Record not exist";
                }
                else
                {
                    // Removing Already Added

                    Mapper.Map(obj, oPlans);
                    oDB.SaveChanges();
                    oOutput.Data = Mapper.Map <PlansModel>(oPlans);
                }
            }
            catch (Exception ex)
            {
                oOutput.Status = 0;
                oOutput.Msg    = "Data access error";
                Services.Utitilty.Error(ex);
            }
            return(oOutput);
        }
Example #20
0
        public MsSqlService()
        {
            Id          = ServiceId.ToString();
            Name        = "ms-sql";
            Description = "Microsoft SQL Server Service";
            Bindable    = true;
            Requires    = new string[0];
            Tags        = new string[0];
            Metadata    = new ServiceMetadata();

            Plans.Add(new MsSqlPlan
            {
                Id           = FreePlanId.ToString(),
                Name         = "free",
                Description  = "Free plan",
                DatabaseSize = 1024,
                Metadata     = new PlanMetadata
                {
                    DisplayName = "1 gig",
                    Bullets     = new[] { "1 gig database size" },
                    Costs       = new[] { new Cost {
                                              Unit = "Monthly", Amount = new Amount {
                                                  Denomination = "USD", Value = 0
                                              }
                                          } }
                }
            });
        }
Example #21
0
        protected override void RunCore(Args args)
        {
            var environmentName = args.Arguments.Skip(1).FirstOrDefault();
            var extractions     = ExtractionInstructions.Parse(args.Arguments.Skip(2).ToArray());

            if (environmentName == null)
            {
                throw new Exception("You need to specify an environment");
            }

            var environment = Plans.Environment(environmentName);

            using (var context = new DataContext(environment.ConnectionString))
                using (var scope = new TransactionScope())
                {
                    var metabase = new ContextMetabase(context);

                    foreach (var extraction in extractions)
                    {
                        extraction.Update(metabase, Plans);
                    }

                    var extract = XElement.Load(ExtractFile);

                    foreach (var extraction in extractions)
                    {
                        extraction.Insert(metabase, extract);
                    }

                    scope.Complete();
                }
        }
Example #22
0
        public async Task <ActionResult <Plans> > PostPlans(Plans plans)
        {
            _context.Plans.Add(plans);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPlans", new { id = plans.PlanId }, plans));
        }
Example #23
0
        public static Partition CreateNew(Plans plan)
        {
            var partition = new Partition
            {
                Timestamp = DateTime.UtcNow,
                Plan      = plan,
            };

            switch (plan)
            {
            case Plans.Demo:
                partition.MaxUsers            = 2;
                partition.MaxReportsPerMonth  = 10;
                partition.MaxInvoicesPerMonth = 10;
                break;

            case Plans.Free:
                partition.MaxUsers            = 5;
                partition.MaxReportsPerMonth  = 50;
                partition.MaxInvoicesPerMonth = 50;
                break;

            default:
                throw new NotImplementedException($"Plan type '{plan}' not implemented.");
            }

            return(partition);
        }
Example #24
0
        /// <summary>
        /// Saves the plan deployment attributes.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <param name="currentUserId">The current user identifier.</param>
        /// <returns> plan Events Id.</returns>
        public int?SavePlanDeploymentAttributes(Plans plan, int currentUserId)
        {
            var offerAttributes      = this.offerAttributesRepository.GetAllOfferAttributesByOfferId(plan.OfferId);
            var deploymentAttributes = offerAttributes.ToList().Where(s => s.Type.ToLower() == "deployment").ToList();

            foreach (var offerAttribute in deploymentAttributes)
            {
                PlanAttributeMapping attribute = new PlanAttributeMapping();
                var existingPlanAttribute      = this.plansRepository.GetPlanAttributeOnOfferAttributeId(offerAttribute.Id, plan.PlanGuid);
                if (existingPlanAttribute != null)
                {
                    attribute.OfferAttributeId = existingPlanAttribute.OfferAttributeId;
                    attribute.IsEnabled        = existingPlanAttribute.IsEnabled;
                    attribute.PlanId           = plan.PlanGuid;
                    attribute.UserId           = currentUserId;
                    attribute.PlanAttributeId  = existingPlanAttribute.PlanAttributeId;
                    attribute.CreateDate       = DateTime.Now;
                }
                else
                {
                    attribute.OfferAttributeId = offerAttribute.Id;
                    attribute.IsEnabled        = true;
                    attribute.PlanId           = plan.PlanGuid;
                    attribute.UserId           = currentUserId;
                    attribute.PlanAttributeId  = 0;
                    attribute.CreateDate       = DateTime.Now;
                }

                var planEventsId = this.plansRepository.SavePlanAttributes(attribute);
            }

            return(null);
        }
Example #25
0
        public async Task <IActionResult> PutPlans(int id, Plans plans)
        {
            if (id != plans.PlanId)
            {
                return(BadRequest());
            }

            _context.Entry(plans).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlansExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// load the house plan
        /// </summary>
        private async Task ExecuteLoadPlansCommand(bool refresh)
        {
            if (Plans == null || refresh)
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
            }

            try
            {
                var items = await App.ApiService.GetPlans();

                if (items.result != null && items.result.Length > 0)
                {
                    Plans?.ReplaceRange(items.result);
                }

                PlansLoadedMethod?.Invoke();
            }
            catch (Exception ex)
            {
                App.AddLog(ex.Message);
            }
            IsBusy = false;
        }
Example #27
0
 public Plan CreatePlan(Plan plan)
 {
     plan.Id = _nextPlanId;
     _nextPlanId++;
     Plans.Add(plan.Id, plan);
     return(plan);
 }
        public static void Main(string[] args)
        {
            var circuitName = "simple-circuit";
            var circuitPath = Path.GetFullPath($"{assetsDirectoryPath}/tracks/{circuitName}");

            var perceptionPeriod = TimeSpan.FromSeconds(1.0 / 10.0);
            var simulationStep   = TimeSpan.FromSeconds(1.0 / 20.0);

            Console.WriteLine($"Loading track {circuitName}");
            var track = Track.Load($"{circuitPath}/circuit_definition.json");
            var world = new StandardWorld(track, simulationStep, safetyMargin: 0.5);

            var planName = "plan-HybridAStarPlanner-1551383968-15200.json";

            Console.WriteLine($"Loading plan {planName}");
            var plan       = Plans.Load($"{assetsDirectoryPath}/plans/{planName}");
            var trajectory = new Trajectory(plan.Trajectory);

            var agent = new DynamcWindowApproachAgent(
                trajectory,
                world,
                4 * world.VehicleModel.Length,
                perceptionPeriod,
                4 * perceptionPeriod);

            //var agent = new PIDAgent(plan.Trajectory, world.MotionModel, perceptionPeriod);

            Console.WriteLine($"Simulating agent {agent.GetType().Name}");
            var simulation = new Simulation.Simulation(agent, world);
            var summary    = simulation.Simulate(simulationStep, perceptionPeriod, TimeSpan.FromSeconds(60));

            IO.Simulation.StoreResult(track, world.VehicleModel, summary, $"{circuitPath}/visualization.svg", "C:/Users/simon/Projects/racer-experiment/simulator/src/report.json");
            Console.WriteLine($"Time to finish: {summary.SimulationTime.TotalSeconds}s");
        }
Example #29
0
        /// <summary>
        /// Adds the specified plan details.
        /// </summary>
        /// <param name="planDetails">The plan details.</param>
        /// <returns> Plan Id.</returns>
        public int Save(Plans planDetails)
        {
            if (planDetails != null && !string.IsNullOrEmpty(planDetails.PlanId))
            {
                var existingPlan = this.context.Plans.Include(p => p.MeteredDimensions).Where(s => s.PlanId == planDetails.PlanId).FirstOrDefault();
                if (existingPlan != null)
                {
                    //room for improvement as these values dont change we dont make a db trip if something changes?
                    existingPlan.PlanId              = planDetails.PlanId;
                    existingPlan.Description         = planDetails.Description;
                    existingPlan.DisplayName         = planDetails.DisplayName;
                    existingPlan.OfferId             = planDetails.OfferId;
                    existingPlan.IsmeteringSupported = planDetails.IsmeteringSupported;
                    this.CheckMeteredDimension(planDetails, existingPlan);
                    this.context.Plans.Update(existingPlan);
                    this.context.SaveChanges();
                    return(existingPlan.Id);
                }
                else
                {
                    this.context.Plans.Add(planDetails);
                    this.context.SaveChanges();
                    return(planDetails.Id);
                }
            }

            return(0);
        }
Example #30
0
        /// <summary>
        /// Check if there is Metered Dimensions exists or updated
        /// </summary>
        /// <param name="planDetails">Incoming Plans data from Payload</param>
        /// <param name="existingPlan">Existing Plans data from database</param>
        private void CheckMeteredDimension(Plans planDetails, Plans existingPlan)
        {
            // Check if Metered Dimension exists or new Metered Dimension to add
            foreach (MeteredDimensions metered in planDetails.MeteredDimensions)
            {
                // Assign Plan.Id to metered PlandId
                metered.PlanId = existingPlan.Id;

                // Query DB for metered dimension using PlanID and Dimension ID
                var existingMeteredDimensions = this.context.MeteredDimensions.Where(s => s.PlanId == existingPlan.Id && s.Dimension == metered.Dimension).FirstOrDefault();

                // Check if Metered Dimensions exists
                if (existingMeteredDimensions != null)
                {
                    // Metered Dimension exists. No needs to updated Keys. We could update description if it is modified.
                    if (existingMeteredDimensions.Description != metered.Description)
                    {
                        var existingMetered = existingPlan.MeteredDimensions.Where(s => s.PlanId == existingPlan.Id && s.Dimension == metered.Dimension).FirstOrDefault();
                        existingMetered.Description = metered.Description;
                    }
                }
                else
                {
                    // Add new metered Dimension
                    existingPlan.MeteredDimensions.Add(metered);
                }
            }
        }
Example #31
0
        private async Task Init()
        {
            IsEnabled = false;
            await Task.Factory.StartNew(() =>
            {
                lock (mLockObject)
                {
                    Plans.Clear();
                    var books = mBookService.GetBooks();
                    var plans = mPlanService.GetReviewPlanDatas(mUser);
                    foreach (var book in books)
                    {
                        var points = mDocumentService.GetBookPoints(book.Name);
                        var plan   = new UIPlan
                        {
                            Book        = book.Name,
                            BookTitle   = book.Title,
                            PointsCount = points.Count
                        };
                        Plans.Add(plan);
                        var savedPlan = plans.FirstOrDefault(a => a.Book.Equals(plan.Book));
                        if (savedPlan != null)
                        {
                            plan.Days      = savedPlan.Days;
                            plan.StartDate = savedPlan.StartDate;
                        }
                    }
                }
            });

            IsEnabled = true;
        }
Example #32
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // 为控件绑定数据源
            DataSet ds = DBHelper.INST.ExecuteSqlDS("select distinct PlanClassify from StationPlan ");
            DropDownList1.DataSource = ds.Tables[0];
            // 选择为下拉列表提供数据的字段
            DropDownList1.DataValueField = "PlanClassify";
            DropDownList1.DataTextField = "PlanClassify";
            DropDownList1.DataBind();
            ds.Dispose();

            if (Request["StationPlanID"] != null)  // 修改计划
            {
                Plans n = new Plans();
                n.StationPlanID = Convert.ToInt32(Request["StationPlanID"].Trim());
                string sql = "select * from StationPlan where StationPlanID=" + n.StationPlanID;// +" and NewsState<>'0'";
                var r = DBHelper.INST.ExecuteSqlDR(sql);
                if (!r.Read())
                {
                    Response.Write("计划未通过审核");
                    Response.End();
                }
                n.PlanName = r["PlanName"].ToString();
                n.Content = r["Content"].ToString();
                n.PlanAuthor = r["PlanAuthor"].ToString();
                n.PlanClassify = r["PlanClassify"].ToString();
                DropDownList1.SelectedValue = n.PlanClassify;
                txtTitle.Text = n.PlanName;
                txtAuthor.Text = n.PlanAuthor;
                editorContent = n.Content;
                r.Close();
            }
            else  // 添加计划
            {
                editorContent = "&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. ";
            }
        }
    }
        public static List<Plans> GetCustomerDailyLog(string planID)
        {
            string day = System.DateTime.Now.DayOfWeek.ToString();
            List<Plans> lstPlans = new List<Plans>();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            SqlConnection oCon = GetConnection(builder);

            SqlCommand cmd = new SqlCommand("Select Meal.Day,Meal.MealType,FoodDetail.Quantity,FoodDetail.Weight,Food.FoodName,Food.FoodCalorie,Food.FoodCategory from Meal inner join FoodDetail ON Meal.MealID = FoodDetail.MealID inner join Food ON Food.FoodID = FoodDetail.FoodID where Meal.PlanID = @PlanID AND Meal.Day = @Day", oCon);
            cmd.Parameters.AddWithValue("@PlanID", planID);
            cmd.Parameters.AddWithValue("@Day", day);
            oCon.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                Plans oPlans = new Plans();
                oPlans.Day = dr["Day"].ToString();
                oPlans.MealType = dr["MealType"].ToString();
                oPlans.Quantity = dr["Quantity"].ToString();
                oPlans.Weight = dr["Weight"].ToString();
                oPlans.FoodName = dr["FoodName"].ToString();
                oPlans.FoodCalorie = dr["FoodCalorie"].ToString();
                oPlans.FoodCategory = dr["FoodCategory"].ToString();
                lstPlans.Add(oPlans);
            }
            oCon.Close();
            return lstPlans;
        }