コード例 #1
0
        private ChartSerieViewModel[] CreateEntityFrameworkSensorValuesSeries(long shipId, List <ESensor> sensors, DateTime rangeBegin, DateTime rangeEnd)
        {
            using (var context = new PrototypeContext())
            {
                ChartSerieViewModel[] series = new ChartSerieViewModel[sensors.Count];
                for (int i = 0; i < series.Length; i++)
                {
                    var sensor       = sensors[i];
                    var sensorValues = context.SensorValuesRows.Where(x => x.ShipId == shipId &&
                                                                      x.ImportTimestamp >= rangeBegin &&
                                                                      x.ImportTimestamp <= rangeEnd)
                                       .ToList();

                    var sensorValuesAsChartDataPoints = sensorValues.Select(sv => new ChartDataPointViewModel()
                    {
                        x = sv.RowTimestamp,
                        y = sv.GetValue(sensor)
                    });

                    var serieForThisSensor = new ChartSerieViewModel()
                    {
                        name = sensor.ToString(), data = sensorValuesAsChartDataPoints.ToArray()
                    };
                    series[i] = serieForThisSensor;
                }

                return(series);
            }
        }
コード例 #2
0
        /// <summary>
        /// Seeds the database and the ASP.NET identity system with some starting users.
        /// This is done in this separate class rather than in the PrototypeContext,
        /// because we need a UserManager in order to create the users, and this cannot be injected
        /// into the PrototypeContext OnModelCreating() method.
        /// </summary>
        public static void SeedUsers(UserManager <User> userManager)
        {
            using (var context = new PrototypeContext())
            {
                var usersToBeSeeded = new List <User>()
                {
                    new User()
                    {
                        UserId = 1, FirstName = "User", LastName = "1", UserName = "******", Email = "*****@*****.**"
                    },
                    new User()
                    {
                        UserId = 2, FirstName = "User", LastName = "2", UserName = "******", Email = "*****@*****.**"
                    },
                    new User()
                    {
                        UserId = 3, FirstName = "User", LastName = "3", UserName = "******", Email = "*****@*****.**"
                    }
                };

                foreach (var user in usersToBeSeeded)
                {
                    if (user.Email != null && userManager.FindByEmailAsync(user.Email).Result == null)
                    {
                        IdentityResult result = userManager.CreateAsync(user, password: "******").Result;

                        if (!result.Succeeded)
                        {
                            throw new Exception("User identity seeding failed.");
                        }
                    }
                }
            }
        }
コード例 #3
0
        public IActionResult Details(long shipId)
        {
            using (var context = new PrototypeContext())
            {
                try
                {
                    Ship ship = context.Ships.Single(x => x.ShipId == shipId);

                    long defaultChartRangeBeginTs = DateTime.Today.AddMonths(-1).ToUnixMilliTs();
                    long defaultChartRangeEndTs   = DateTime.Today.ToUnixMilliTs();

                    List <ChartViewModel> defaultCharts = GetCharts(ship.ShipId,
                                                                    defaultChartRangeBeginTs,
                                                                    defaultChartRangeEndTs);

                    ViewBag.DefaultChartRangeBeginTs = defaultChartRangeBeginTs;
                    ViewBag.DefaultChartRangeEndTs   = defaultChartRangeEndTs;
                    ViewBag.ShipName = ship.Name;
                    ViewBag.ShipImo  = ship.ImoNumber;
                    ViewBag.ShipId   = ship.ShipId;
                    return(View(defaultCharts));
                }
                catch (Exception)
                {
                    return(Index());
                }
            }
        }
コード例 #4
0
        public IActionResult CreateNewShip(ShipCreateViewModel newShipModel)
        {
            try
            {
                using (var context = new PrototypeContext())
                {
                    var shipsUser = base.GetCurrentUserEntity();

                    context.Ships.Add(new Ship()
                    {
                        Name        = newShipModel.ShipName,
                        ImageName   = newShipModel.ImageName,
                        CountryName = newShipModel.CountryName,
                        ImoNumber   = Int32.Parse(newShipModel.ImoNumber),
                        UserId      = shipsUser.UserId
                    });
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Something went wrong, please try again.");
            }

            return(View("Index"));
        }
コード例 #5
0
 protected void SaveDataImportMeta(DataImportMeta dataImportMeta)
 {
     using (var context = new PrototypeContext())
     {
         context.DataImportMetas.Add(dataImportMeta);
         context.SaveChanges();
     }
 }
コード例 #6
0
 /// <summary>
 /// Returns a list of Kpi's who have the given EKpiType.
 /// </summary>
 public List <Kpi> GetKpisByType(EKpiType kpiType)
 {
     using (var context = new PrototypeContext())
     {
         return(context.Kpis.Where(x => x.KpiType.Equals(kpiType))
                .ToList());
     }
 }
コード例 #7
0
        protected ICollection <Ship> GetShipsEntitiesOfCurrentUser()
        {
            var currentUser = GetCurrentUserEntity();

            using (var context = new PrototypeContext())
            {
                var currUser = GetCurrentUserEntity();
                return(context.Ships.Where(s => s.UserId == currentUser.UserId).ToList());
            }
        }
コード例 #8
0
        protected long GetShipIdFromFileName(string fileName)
        {
            // filename is like 1111111_20180604_030000.csv. First 7 numbers are imo
            var imo = int.Parse(fileName.Split('_')[0]);

            using (var ctx = new PrototypeContext())
            {
                return(ctx.Ships.Where(x => x.ImoNumber == imo).First().ShipId);
            }
        }
コード例 #9
0
 /// <summary>
 /// Seeds the EF-powered MySQL database with all KPI's.
 /// </summary>
 public static void SeedKpis()
 {
     using (var ctx = new PrototypeContext())
     {
         foreach (EKpi kpi in Enum.GetValues(typeof(EKpi)))
         {
             if (ctx.Kpis.Any(x => x.KpiEnum.Equals(kpi)) == false)
             {
                 ctx.Kpis.Add(new Kpi(kpi, GetKpiTypeFromEnumName(kpi)));
             }
         }
         ctx.SaveChanges();
     }
 }
コード例 #10
0
        /// <summary>
        /// Calculates the KpiValue for each Kpi and saves them to the Redis DB using the Redis API for the given
        /// RedisSensorValuesRows. Makes use of the KpiCalculatorFactory in order to get the appropriate KpiCalculator.
        /// The DateOfImport and shipId parameters are used for the creation of the Redis keys for each KpiValue.
        /// </summary>
        public void Handle(List <RedisSensorValuesRow> importedRows, long shipId, DateTime DateOfImport)
        {
            List <RedisKpiValue> KpiValuesToSave = new List <RedisKpiValue>();

            using (var ctx = new PrototypeContext())
            {
                foreach (var kpi in ctx.Kpis)
                {
                    var calculatorForKpi = _kpiCalculatorFactory.GetCalculator(shipId, kpi);

                    var calculatedKpiValue = calculatorForKpi.Calculate(importedRows, DateOfImport);
                    KpiValuesToSave.Add(calculatedKpiValue);
                }
            }

            RedisDatabaseApi.Create <RedisKpiValue>(KpiValuesToSave);
        }
コード例 #11
0
        public IActionResult UpdatingAllSensorValues(long shipId)
        {
            var  firstAndLastImportMillis  = GetFirstAndLastImportUnixTs(shipId);
            long firstImportUnixTimeMillis = firstAndLastImportMillis.Item1;
            long lastImportUnixTimeMillis  = firstAndLastImportMillis.Item2;


            // Redis
            var sw = new Stopwatch();

            sw.Start();

            var allRedisSensorValuesForShip = _sensorValuesRowRetriever.GetRange(shipId, firstImportUnixTimeMillis, lastImportUnixTimeMillis)
                                              .Take(25000)
                                              .ToList();

            allRedisSensorValuesForShip.ForEach(x => x.SensorValues[ESensor.sensor1] = 100.0);

            RedisDatabaseApi.Update(allRedisSensorValuesForShip);

            sw.Stop();
            RedisUpdatingTimesMillis.Add(sw.ElapsedMilliseconds);
            AverageRedisUpdatingTimeMillis = RedisUpdatingTimesMillis.Average();


            // Entity Framework
            sw = new Stopwatch();
            sw.Start();

            using (var context = new PrototypeContext())
            {
                var allEfSensorValuesForShip = context.SensorValuesRows.Where(x => x.ShipId == shipId &&
                                                                              x.RowTimestamp >= firstImportUnixTimeMillis &&
                                                                              x.RowTimestamp <= lastImportUnixTimeMillis)
                                               .Take(25000)
                                               .ToList();
                allEfSensorValuesForShip.ForEach(sv => sv.sensor1 += 100);
                context.SaveChanges();
            }

            sw.Stop();
            EfUpdatingTimesMillis.Add(sw.ElapsedMilliseconds);
            AverageEfUpdatingTimeMillis = EfUpdatingTimesMillis.Average();

            return(Ok());
        }
コード例 #12
0
        internal static string GetPrototypeName(this PrototypeContext prototype)
        {
            switch (prototype)
            {
            case FunctionPrototypeContext func:
                return(func.Name);

            case UnaryPrototypeContext unaryOp:
                return($"$unary{unaryOp.Op}");

            case BinaryPrototypeContext binOp:
                return($"$binary{binOp.Op}");

            default:
                throw new ArgumentException("unknown prototype");
            }
        }
コード例 #13
0
        private Tuple <long, long> GetFirstAndLastImportUnixTs(long shipId)
        {
            long firstImportUnixTimeMillis;
            long lastImportUnixTimeMillis;

            using (var context = new PrototypeContext())
            {
                firstImportUnixTimeMillis = context.DataImportMetas.Where(x => x.ShipId == shipId)
                                            .First()
                                            .ImportDate
                                            .ToUnixMilliTs();
                lastImportUnixTimeMillis = context.DataImportMetas.Where(x => x.ShipId == shipId)
                                           .Last()
                                           .ImportDate
                                           .ToUnixMilliTs();
            }
            return(new Tuple <long, long>(firstImportUnixTimeMillis, lastImportUnixTimeMillis));
        }
コード例 #14
0
        public IActionResult DeleteShip(long shipId)
        {
            try
            {
                using (var context = new PrototypeContext())
                {
                    var shipToBeDeleted = context.Ships.Single(s => s.ShipId == shipId);

                    context.Ships.Remove(shipToBeDeleted);
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Something went wrong, please try again.");
            }

            return(Index());
        }
コード例 #15
0
        /// <summary>
        /// Seeds the EF-powered MySQL database with 35 ships.
        /// </summary>
        public static void SeedShips()
        {
            using (var context = new PrototypeContext())
            {
                var firstUserId = context.Users.First().UserId;

                var random       = new Random();
                var countryNames = new string[6] {
                    "Nederland", "Deutschland", "United States of America", "United Kingdom", "Italia", "San Marino"
                };
                var namesPrefixes = new string[6] {
                    "H.M.S.", "H.N.L.M.S.", "F.S.", "F.G.S.", "U.S.S.", "I.J.N."
                };
                var namesPostfixes = new string[] { "Knuth", "Russell", "Newell", "Stonebraker", "Beck", "Torvalds", "Thompson", "Tukey", "Babbage", "Boole", "Lovelace", "Cormack", "Neumann", "Codd", "Dijkstra", "Liskov", "Haskell", "Turing", "Curry" };
                var usedNames      = new HashSet <string>();

                for (int i = 0; i < AMOUNT_OF_SHIPS_TO_SEED; i++)
                {
                    var country = countryNames[random.Next(0, countryNames.Length)];

                    var newShip = new Ship()
                    {
                        ShipId      = i + 1,
                        ImoNumber   = i + 1,
                        Name        = GetRandomShipName(namesPrefixes, namesPostfixes, random, usedNames),
                        ImageName   = "0.jpg",
                        CountryName = country,
                        UserId      = firstUserId
                    };

                    if (context.Ships.Any(x => x.ShipId == newShip.ShipId) == false)
                    {
                        context.Ships.Add(newShip);
                    }
                }
                context.SaveChanges();
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, PrototypeContext context)
        {
            if (env.IsDevelopment())
            {
                // context.Database.Migrate();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });
            app.UseHttpsRedirection();
            app.UseMvc();
            //context.Database.Migrate();
        }
コード例 #17
0
 public PrototypeController(IPrototypeService service, PrototypeContext context)
 {
     _service = service;
     _context = context;
 }
コード例 #18
0
 public PrototypeService(PrototypeContext context)
 {
     _context = context;
 }
コード例 #19
0
 public MovieService(PrototypeContext dbContext) : base(dbContext)
 {
     _movies = DbContext.Movies;
     _actors = DbContext.Actors;
 }
コード例 #20
0
        public override void Handle(FileStream importFile, bool calculateKpis = true)
        {
            string   importFileName   = importFile.Name.Split('\\').Last();
            long     shipIdOfImport   = GetShipIdFromFileName(importFileName);
            DateTime dateTimeOfImport = GetImportDateFromFileName(importFileName);


            if (importFile.Length > 0)
            {
                using (var context = new PrototypeContext())
                {
                    using (var stream = new StreamReader(importFile))
                    {
                        string header = null;
                        string currentLine;

                        while (stream.Peek() >= 0)
                        {
                            currentLine = stream.ReadLine();

                            if (header == null)
                            {
                                header = currentLine;
                                continue; // Skipping header
                            }

                            Dictionary <ESensor, string> rowAsDict = base.RowToDictionary(header, currentLine);

                            #region Horrible dictionary to entity assignment code which avoids reflection

                            DateTime timeStampValue = DateTime.Parse(rowAsDict[ESensor.ts]);
                            long     rowTimestamp   = timeStampValue.ToUnixMilliTs();

                            context.SensorValuesRows.Add(new EfSensorValuesRow()
                            {
                                ShipId          = shipIdOfImport,
                                RowTimestamp    = rowTimestamp,
                                ImportTimestamp = dateTimeOfImport,

                                sensor1   = double.Parse(rowAsDict[ESensor.sensor1]),
                                sensor2   = double.Parse(rowAsDict[ESensor.sensor2]),
                                sensor3   = double.Parse(rowAsDict[ESensor.sensor3]),
                                sensor4   = double.Parse(rowAsDict[ESensor.sensor4]),
                                sensor5   = double.Parse(rowAsDict[ESensor.sensor5]),
                                sensor6   = double.Parse(rowAsDict[ESensor.sensor6]),
                                sensor7   = double.Parse(rowAsDict[ESensor.sensor7]),
                                sensor8   = double.Parse(rowAsDict[ESensor.sensor8]),
                                sensor9   = double.Parse(rowAsDict[ESensor.sensor9]),
                                sensor10  = double.Parse(rowAsDict[ESensor.sensor10]),
                                sensor11  = double.Parse(rowAsDict[ESensor.sensor11]),
                                sensor12  = double.Parse(rowAsDict[ESensor.sensor12]),
                                sensor13  = double.Parse(rowAsDict[ESensor.sensor13]),
                                sensor14  = double.Parse(rowAsDict[ESensor.sensor14]),
                                sensor15  = double.Parse(rowAsDict[ESensor.sensor15]),
                                sensor16  = double.Parse(rowAsDict[ESensor.sensor16]),
                                sensor17  = double.Parse(rowAsDict[ESensor.sensor17]),
                                sensor18  = double.Parse(rowAsDict[ESensor.sensor18]),
                                sensor19  = double.Parse(rowAsDict[ESensor.sensor19]),
                                sensor20  = double.Parse(rowAsDict[ESensor.sensor20]),
                                sensor21  = double.Parse(rowAsDict[ESensor.sensor21]),
                                sensor22  = double.Parse(rowAsDict[ESensor.sensor22]),
                                sensor23  = double.Parse(rowAsDict[ESensor.sensor23]),
                                sensor24  = double.Parse(rowAsDict[ESensor.sensor24]),
                                sensor25  = double.Parse(rowAsDict[ESensor.sensor25]),
                                sensor26  = double.Parse(rowAsDict[ESensor.sensor26]),
                                sensor27  = double.Parse(rowAsDict[ESensor.sensor27]),
                                sensor28  = double.Parse(rowAsDict[ESensor.sensor28]),
                                sensor29  = double.Parse(rowAsDict[ESensor.sensor29]),
                                sensor30  = double.Parse(rowAsDict[ESensor.sensor30]),
                                sensor31  = double.Parse(rowAsDict[ESensor.sensor31]),
                                sensor32  = double.Parse(rowAsDict[ESensor.sensor32]),
                                sensor33  = double.Parse(rowAsDict[ESensor.sensor33]),
                                sensor34  = double.Parse(rowAsDict[ESensor.sensor34]),
                                sensor35  = double.Parse(rowAsDict[ESensor.sensor35]),
                                sensor36  = double.Parse(rowAsDict[ESensor.sensor36]),
                                sensor37  = double.Parse(rowAsDict[ESensor.sensor37]),
                                sensor38  = double.Parse(rowAsDict[ESensor.sensor38]),
                                sensor39  = double.Parse(rowAsDict[ESensor.sensor39]),
                                sensor40  = double.Parse(rowAsDict[ESensor.sensor40]),
                                sensor41  = double.Parse(rowAsDict[ESensor.sensor41]),
                                sensor42  = double.Parse(rowAsDict[ESensor.sensor42]),
                                sensor43  = double.Parse(rowAsDict[ESensor.sensor43]),
                                sensor44  = double.Parse(rowAsDict[ESensor.sensor44]),
                                sensor45  = double.Parse(rowAsDict[ESensor.sensor45]),
                                sensor46  = double.Parse(rowAsDict[ESensor.sensor46]),
                                sensor47  = double.Parse(rowAsDict[ESensor.sensor47]),
                                sensor48  = double.Parse(rowAsDict[ESensor.sensor48]),
                                sensor49  = double.Parse(rowAsDict[ESensor.sensor49]),
                                sensor50  = double.Parse(rowAsDict[ESensor.sensor50]),
                                sensor51  = double.Parse(rowAsDict[ESensor.sensor51]),
                                sensor52  = double.Parse(rowAsDict[ESensor.sensor52]),
                                sensor53  = double.Parse(rowAsDict[ESensor.sensor53]),
                                sensor54  = double.Parse(rowAsDict[ESensor.sensor54]),
                                sensor55  = double.Parse(rowAsDict[ESensor.sensor55]),
                                sensor56  = double.Parse(rowAsDict[ESensor.sensor56]),
                                sensor57  = double.Parse(rowAsDict[ESensor.sensor57]),
                                sensor58  = double.Parse(rowAsDict[ESensor.sensor58]),
                                sensor59  = double.Parse(rowAsDict[ESensor.sensor59]),
                                sensor60  = double.Parse(rowAsDict[ESensor.sensor60]),
                                sensor61  = double.Parse(rowAsDict[ESensor.sensor61]),
                                sensor62  = double.Parse(rowAsDict[ESensor.sensor62]),
                                sensor63  = double.Parse(rowAsDict[ESensor.sensor63]),
                                sensor64  = double.Parse(rowAsDict[ESensor.sensor64]),
                                sensor65  = double.Parse(rowAsDict[ESensor.sensor65]),
                                sensor66  = double.Parse(rowAsDict[ESensor.sensor66]),
                                sensor67  = double.Parse(rowAsDict[ESensor.sensor67]),
                                sensor68  = double.Parse(rowAsDict[ESensor.sensor68]),
                                sensor69  = double.Parse(rowAsDict[ESensor.sensor69]),
                                sensor70  = double.Parse(rowAsDict[ESensor.sensor70]),
                                sensor71  = double.Parse(rowAsDict[ESensor.sensor71]),
                                sensor72  = double.Parse(rowAsDict[ESensor.sensor72]),
                                sensor73  = double.Parse(rowAsDict[ESensor.sensor73]),
                                sensor74  = double.Parse(rowAsDict[ESensor.sensor74]),
                                sensor75  = double.Parse(rowAsDict[ESensor.sensor75]),
                                sensor76  = double.Parse(rowAsDict[ESensor.sensor76]),
                                sensor77  = double.Parse(rowAsDict[ESensor.sensor77]),
                                sensor78  = double.Parse(rowAsDict[ESensor.sensor78]),
                                sensor79  = double.Parse(rowAsDict[ESensor.sensor79]),
                                sensor80  = double.Parse(rowAsDict[ESensor.sensor80]),
                                sensor81  = double.Parse(rowAsDict[ESensor.sensor81]),
                                sensor82  = double.Parse(rowAsDict[ESensor.sensor82]),
                                sensor83  = double.Parse(rowAsDict[ESensor.sensor83]),
                                sensor84  = double.Parse(rowAsDict[ESensor.sensor84]),
                                sensor85  = double.Parse(rowAsDict[ESensor.sensor85]),
                                sensor86  = double.Parse(rowAsDict[ESensor.sensor86]),
                                sensor87  = double.Parse(rowAsDict[ESensor.sensor87]),
                                sensor88  = double.Parse(rowAsDict[ESensor.sensor88]),
                                sensor89  = double.Parse(rowAsDict[ESensor.sensor89]),
                                sensor90  = double.Parse(rowAsDict[ESensor.sensor90]),
                                sensor91  = double.Parse(rowAsDict[ESensor.sensor91]),
                                sensor92  = double.Parse(rowAsDict[ESensor.sensor92]),
                                sensor93  = double.Parse(rowAsDict[ESensor.sensor93]),
                                sensor94  = double.Parse(rowAsDict[ESensor.sensor94]),
                                sensor95  = double.Parse(rowAsDict[ESensor.sensor95]),
                                sensor96  = double.Parse(rowAsDict[ESensor.sensor96]),
                                sensor97  = double.Parse(rowAsDict[ESensor.sensor97]),
                                sensor98  = double.Parse(rowAsDict[ESensor.sensor98]),
                                sensor99  = double.Parse(rowAsDict[ESensor.sensor99]),
                                sensor100 = double.Parse(rowAsDict[ESensor.sensor100]),
                                sensor101 = double.Parse(rowAsDict[ESensor.sensor101]),
                                sensor102 = double.Parse(rowAsDict[ESensor.sensor102]),
                                sensor103 = double.Parse(rowAsDict[ESensor.sensor103]),
                                sensor104 = double.Parse(rowAsDict[ESensor.sensor104]),
                                sensor105 = double.Parse(rowAsDict[ESensor.sensor105]),
                                sensor106 = double.Parse(rowAsDict[ESensor.sensor106]),
                                sensor107 = double.Parse(rowAsDict[ESensor.sensor107]),
                                sensor108 = double.Parse(rowAsDict[ESensor.sensor108]),
                                sensor109 = double.Parse(rowAsDict[ESensor.sensor109]),
                                sensor110 = double.Parse(rowAsDict[ESensor.sensor110]),
                                sensor111 = double.Parse(rowAsDict[ESensor.sensor111]),
                                sensor112 = double.Parse(rowAsDict[ESensor.sensor112]),
                                sensor113 = double.Parse(rowAsDict[ESensor.sensor113]),
                                sensor114 = double.Parse(rowAsDict[ESensor.sensor114]),
                                sensor115 = double.Parse(rowAsDict[ESensor.sensor115]),
                                sensor116 = double.Parse(rowAsDict[ESensor.sensor116]),
                                sensor117 = double.Parse(rowAsDict[ESensor.sensor117]),
                                sensor118 = double.Parse(rowAsDict[ESensor.sensor118]),
                                sensor119 = double.Parse(rowAsDict[ESensor.sensor119]),
                                sensor120 = double.Parse(rowAsDict[ESensor.sensor120]),
                                sensor121 = double.Parse(rowAsDict[ESensor.sensor121]),
                                sensor122 = double.Parse(rowAsDict[ESensor.sensor122]),
                                sensor123 = double.Parse(rowAsDict[ESensor.sensor123]),
                                sensor124 = double.Parse(rowAsDict[ESensor.sensor124]),
                                sensor125 = double.Parse(rowAsDict[ESensor.sensor125]),
                                sensor126 = double.Parse(rowAsDict[ESensor.sensor126]),
                                sensor127 = double.Parse(rowAsDict[ESensor.sensor127]),
                                sensor128 = double.Parse(rowAsDict[ESensor.sensor128]),
                                sensor129 = double.Parse(rowAsDict[ESensor.sensor129]),
                                sensor130 = double.Parse(rowAsDict[ESensor.sensor130]),
                                sensor131 = double.Parse(rowAsDict[ESensor.sensor131]),
                                sensor132 = double.Parse(rowAsDict[ESensor.sensor132]),
                                sensor133 = double.Parse(rowAsDict[ESensor.sensor133]),
                                sensor134 = double.Parse(rowAsDict[ESensor.sensor134]),
                                sensor135 = double.Parse(rowAsDict[ESensor.sensor135]),
                                sensor136 = double.Parse(rowAsDict[ESensor.sensor136]),
                                sensor137 = double.Parse(rowAsDict[ESensor.sensor137]),
                                sensor138 = double.Parse(rowAsDict[ESensor.sensor138]),
                                sensor139 = double.Parse(rowAsDict[ESensor.sensor139]),
                                sensor140 = double.Parse(rowAsDict[ESensor.sensor140]),
                                sensor141 = double.Parse(rowAsDict[ESensor.sensor141]),
                                sensor142 = double.Parse(rowAsDict[ESensor.sensor142]),
                                sensor143 = double.Parse(rowAsDict[ESensor.sensor143]),
                                sensor144 = double.Parse(rowAsDict[ESensor.sensor144]),
                                sensor145 = double.Parse(rowAsDict[ESensor.sensor145]),
                                sensor146 = double.Parse(rowAsDict[ESensor.sensor146]),
                                sensor147 = double.Parse(rowAsDict[ESensor.sensor147]),
                                sensor148 = double.Parse(rowAsDict[ESensor.sensor148]),
                                sensor149 = double.Parse(rowAsDict[ESensor.sensor149]),
                            });

                            #endregion
                        }
                    }
                    context.SaveChanges();
                }

                var dataImportMeta = new DataImportMeta(shipIdOfImport, dateTimeOfImport);
                SaveDataImportMeta(dataImportMeta);
            }
            else
            {
                throw new Exception("Empty import file.");
            }
        }
コード例 #21
0
 /// <summary>Initializes a new instance of the <see cref="Prototype"/> class.</summary>
 /// <param name="ctx"><see cref="PrototypeContext"/> to extract parameter and source location information from</param>
 public Prototype(PrototypeContext ctx)
     : this(ctx.GetSourceSpan(), ctx.Name, ctx.Parameters.Select(p => new ParameterDeclaration(p.Span, p.Name, p.Index)))
 {
     IsExtern = ctx.Parent is ExternalDeclarationContext;
 }
コード例 #22
0
 public ProximityMappingRepository(PrototypeContext context)
 {
     _context = context;
 }
コード例 #23
0
        public ImportViewModel GetImportViewModel(string path)
        {
            var repo = new ImportRepository(path);

            var vm = new ImportViewModel {
                Headers  = repo.Headers,
                Products = repo.Products.ToList(),
            };

            vm.RowDetails = GetRowDetails(vm.Headers, vm.Products);
            var list = new List <MappingOption> {
                new MappingOption {
                    Id = 1, Name = "Feature"
                },
                new MappingOption {
                    Id = 2, Name = "Identifers"
                },
                new MappingOption {
                    Id = 3, Name = "Specification"
                },
                new MappingOption {
                    Id = 4, Name = "Class"
                },
                new MappingOption {
                    Id = 5, Name = "Price"
                },
                new MappingOption {
                    Id = 6, Name = "Color"
                },
                new MappingOption {
                    Id = 7, Name = "Marketing Detail"
                },
                new MappingOption {
                    Id = 8, Name = "Activity"
                },
                new MappingOption {
                    Id = 9, Name = "Designation"
                },
                new MappingOption {
                    Id = 10, Name = "Model"
                },
                new MappingOption {
                    Id = 11, Name = "Sub Model"
                },
                new MappingOption {
                    Id = 12, Name = "Make"
                },
                new MappingOption {
                    Id = 13, Name = "Condition"
                },
                new MappingOption {
                    Id = 14, Name = "Quantity"
                },
                new MappingOption {
                    Id = 15, Name = "Media"
                },
                new MappingOption {
                    Id = 16, Name = "Status"
                }
            };

            vm.MappingOptions = list.OrderBy(l => l.Name).ToList();
            using (var ctx = new PrototypeContext()) {
                var mRepo = new ProximityMappingRepository(ctx);
                vm.Industries     = mRepo.GetIndustries();
                vm.ReferenceCodes = mRepo.GetReferenceCodes();
            }
            vm.SelectedIndustry = 2;

            vm.ActivityTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Activity" &&
                                                       rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.ClassTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Class" &&
                                                    rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.ColorTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Color" &&
                                                    rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.Designations = vm.ReferenceCodes.Where(rc => rc.Name == "Designation" &&
                                                      rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.PriceTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Price" &&
                                                    rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.SpecificationTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Specification" &&
                                                            rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.StatusTypes = vm.ReferenceCodes.Where(rc => rc.Name == "Status" &&
                                                     rc.IndustryId == vm.SelectedIndustry).ToList();
            vm.UnitTypes = vm.ReferenceCodes.Where(rc => rc.Name == "UnitType" &&
                                                   rc.IndustryId == vm.SelectedIndustry).ToList();

            return(vm);
        }