private static List <AnalysisKey> GenerateKeysFromProsumer([NotNull] Prosumer prosumer)
        {
            List <AnalysisKey> keys = new List <AnalysisKey>();

            if (prosumer.TrafoKreis == null)
            {
                throw new FlaException("Trafokreis was null");
            }
            if (prosumer.ProviderName == null)
            {
                throw new FlaException("ProviderName was null");
            }

            if (prosumer.ProfileSourceName == "PV Profile" && prosumer.GenerationOrLoad != GenerationOrLoad.Generation)
            {
                throw  new FlaException("A pv provider is not saved as generation");
            }

            keys.Add(new AnalysisKey(prosumer.TrafoKreis, null, SumType.ByTrafokreis, prosumer.GenerationOrLoad, null, null, null));
            keys.Add(new AnalysisKey(prosumer.TrafoKreis, prosumer.ProviderName, SumType.ByTrafokreisAndProvider, prosumer.GenerationOrLoad, null, null, null));
            keys.Add(new AnalysisKey(null, prosumer.ProviderName, SumType.ByProvider, prosumer.GenerationOrLoad, null, null, null));
            keys.Add(new AnalysisKey(null, null, SumType.ByProfileSource, prosumer.GenerationOrLoad, null, prosumer.ProfileSourceName, null));
            keys.Add(new AnalysisKey(null, null, SumType.ByHouseholdComponentType, prosumer.GenerationOrLoad, null, null, prosumer.HouseComponentType.ToString()));
            return(keys);
        }
        private void ArchiveOneEntry([NotNull] Prosumer prosumer)
        {
            _archiveCount++;
            if (prosumer.GenerationOrLoad == GenerationOrLoad.Load)
            {
                if (_loadSa == null)
                {
                    throw new FlaException("load was null");
                }
                _loadSa.AddRow(prosumer);
                if (_loadSa.RowEntries.Count > 50)
                {
                    _loadSa.SaveDictionaryToDatabase(_services.Logger);
                }
            }

            if (prosumer.GenerationOrLoad == GenerationOrLoad.Generation)
            {
                if (_generationSa == null)
                {
                    throw new FlaException("load was null");
                }
                _generationSa.AddRow(prosumer);
                if (_generationSa.RowEntries.Count > 50)
                {
                    _generationSa.SaveDictionaryToDatabase(_services.Logger);
                }
            }
        }
        private Prosumer MakeFlatProfile([NotNull] CarDistanceEntry carDistance, [NotNull] Hausanschluss ha, [NotNull] Household household)
        {
            var slpprofile = Profile.MakeConstantProfile(carDistance.EnergyEstimate, carDistance.Name, Profile.ProfileResolution.QuarterHour);

            if (slpprofile == null)
            {
                throw new FlaException("No profile? Why?");
            }

            var prosumer = new Prosumer(household.HouseGuid,
                                        carDistance.Name,
                                        carDistance.HouseComponentType,
                                        household.SourceGuid,
                                        household.FinalIsn,
                                        household.HausAnschlussGuid,
                                        ha.ObjectID,
                                        GenerationOrLoad.Load,
                                        ha.Trafokreis,
                                        Name + " - Flat Substitute Profile",
                                        "Flat Substitute Profile due to missing LPG profile")
            {
                Profile = slpprofile
            };

            return(prosumer);
        }
Exemple #4
0
        public async Task <IHttpActionResult> PostProsumer([FromBody] Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Prosumers.Add(prosumer);

            try
            {
                //await _uow.ProsumerRepository.Add(prosumer);
                await _uow.SaveAsync();
            }
            catch (DbUpdateException)
            {
                if (ProsumerExists(prosumer.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = prosumer.Id }, prosumer));
        }
Exemple #5
0
        public Prosumer UpdateProsumer(Prosumer updated)
        {
            prosumerRepo.DeleteProsumer(updated.CopperID);
            prosumerRepo.AddProsumer(updated).Wait();

            return(prosumerRepo.GetProsumerByCopperID(updated.CopperID));
        }
        protected override Prosumer ProvidePrivateProfile([NotNull] ProviderParameterDto ppdto)
        {
            BuildingInfrastructure be = (BuildingInfrastructure)ppdto.HouseComponent;

            if (be.HouseComponentType == HouseComponentType.Infrastructure)
            {
                Hausanschluss ha = _dbDto.Hausanschlusse.Single(x => x.Guid == be.HausAnschlussGuid);
                var           pa = new Prosumer(be.HouseGuid,
                                                be.Standort ?? "nameless house infrastructure",
                                                be.HouseComponentType,
                                                be.SourceGuid,
                                                be.FinalIsn,
                                                be.HausAnschlussGuid,
                                                ha.ObjectID,
                                                GenerationOrLoad.Load,
                                                ha.Trafokreis, Name, "Flat House Infrastructure");
                pa.Profile = Profile.MakeConstantProfile(be.EffectiveEnergyDemand, "Flat House Infrastucture", Profile.ProfileResolution.QuarterHour);
                if (pa.Profile.EnergyOrPower == EnergyOrPower.Power)
                {
                    pa.Profile = pa.Profile.ConvertFromPowerToEnergy();
                }

                pa.SumElectricityPlanned = be.EffectiveEnergyDemand;
                return(pa);
            }
            throw new FlaException("No profile could be created");
        }
        static void Main(string[] args)
        {
            var prosumer = new Prosumer();

            prosumer.CopperID     = "2";
            prosumer.smartmeter   = 131;
            prosumer.wallet       = 10;
            prosumer.prosumerType = "private";

            ProsumerDocumentDBUnitOfWork x = new ProsumerDocDB.DbContext
                                             .ProsumerDocumentDBUnitOfWork(new ProsumerDocDB.DbContext.ProsumerDbContext());

            x._prosumerRepository.AddProsumer(prosumer).Wait();
            var test = x._prosumerRepository.GetProsumerByCopperID(prosumer.CopperID);

            var test2 = x._prosumerRepository.GetProsumerByCopperID("4");

            prosumer.wallet     = 100;
            prosumer.smartmeter = 0;
            x._prosumerRepository.Update(prosumer);
            Console.WriteLine("CopperID: " + test.CopperID + "\n" + "Prosumer Type: " + test.prosumerType + "\n" + "SmartMeter: " + test.smartmeter + "\n" + "Wallet: " + test.wallet + "\n");
            Console.WriteLine("CopperID: " + test2.CopperID + "\n" + "Prosumer Type: " + test2.prosumerType + "\n" + "SmartMeter: " + test2.smartmeter + "\n" + "Wallet: " + test2.wallet + "\n");


            //x._prosumerRepository.DeleteProsumer("4");
        }
        public async Task Test3()
        {
            IPAddress   iPAddress = (await Dns.GetHostAddressesAsync("127.0.0.1"))[0];
            TcpListener server    = new TcpListener(iPAddress, 8414);

            server.Start();
            var service = new Broker(new Service()).Service;

            ServiceCodec.Instance.Debug = true;
            service.Use(Log.IOHandler)
            .Use(Log.InvokeHandler)
            .Bind(server);

            var client1   = new Client("tcp4://127.0.0.1:8414");
            var prosumer1 = new Prosumer(client1, "1")
            {
                OnSubscribe = (topic) => {
                    Console.WriteLine(topic + " is subscribed.");
                },
                OnUnsubscribe = (topic) => {
                    Console.WriteLine(topic + " is unsubscribed.");
                }
            };
            var client2   = new Client("tcp4://127.0.0.1:8414");
            var prosumer2 = new Prosumer(client2, "2");
            await prosumer1.Subscribe <string>("test", (data, from) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("hello", data);
                System.Console.WriteLine(from);
                Assert.AreEqual("2", from);
            });

            await prosumer1.Subscribe <string>("test2", (data) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("world", data);
            });

            await prosumer1.Subscribe <Exception>("test3", (data) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("error", data.Message);
            });

            var r1 = prosumer2.Push("hello", "test", "1");
            var r2 = prosumer2.Push("hello", "test", "1");
            var r3 = prosumer2.Push("world", "test2", "1");
            var r4 = prosumer2.Push("world", "test2", "1");
            var r5 = prosumer2.Push(new Exception("error"), "test3", "1");
            var r6 = prosumer2.Push(new Exception("error"), "test3", "1");
            await Task.WhenAll(r1, r2, r3, r4, r5, r6);

            await Task.Delay(10);

            await prosumer1.Unsubscribe("test");

            await prosumer1.Unsubscribe("test2");

            await prosumer1.Unsubscribe("test3");

            server.Stop();
        }
        private bool MakeErzeugerLastgang([NotNull][ItemNotNull] List <House> houses, [NotNull] LastgangBusinessAssignment assignment, [NotNull][ItemNotNull] List <RlmProfile> profiles,
                                          [NotNull] SaveableEntry <Prosumer> sa)
        {
            var selectedhouses = houses.Where(x => x.ErzeugerIDs.Contains(assignment.ErzeugerID)).ToList();

            if (selectedhouses.Count != 1)
            {
                if (selectedhouses.Count == 0)
                {
                    Log(MessageType.Info, "No house found for " + assignment.ErzeugerID);
                    return(true);
                }

                throw new Exception(selectedhouses.Count + " houses for erzeuger id " + assignment.ErzeugerID);
            }

            Hausanschluss ha = selectedhouses[0].Hausanschluss[0];
            //odo: adjust with new factors
            var rlmrprofile = profiles.Single(x => x.Name == assignment.RlmFilename);
            var pa          = new Prosumer(selectedhouses[0].HouseGuid, assignment.RlmFilename,
                                           ProsumerType.LastgangGeneration, null, selectedhouses[0].GebäudeObjectIDs[0], ha.HausanschlussGuid, ha.ObjectID)
            {
                Profile = rlmrprofile.Profile
            };

            sa.AddRow(pa);
            return(false);
        }
Exemple #10
0
        public async Task <IActionResult> PutProsumer([FromRoute] long id, [FromBody] Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != prosumer.ProsumerId)
            {
                return(BadRequest());
            }
            _uow.ProsumerRepo.Update(prosumer);

            try
            {
                _uow.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProsumerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private Prosumer MakeSlpProfile([NotNull] Household household, [NotNull] Hausanschluss ha)
        {
            var slpprofile = _slpProvider.Run("H0", household.EffectiveEnergyDemand);

            if (slpprofile == null)
            {
                throw new FlaException("No profile? Why?");
            }

            var prosumer = new Prosumer(household.HouseGuid,
                                        household.Name,
                                        HouseComponentType.Household,
                                        household.SourceGuid,
                                        household.FinalIsn,
                                        household.HausAnschlussGuid,
                                        ha.ObjectID,
                                        GenerationOrLoad.Load,
                                        ha.Trafokreis,
                                        Name + " - SLP H0 Substitute Profile",
                                        "H0")
            {
                Profile = slpprofile
            };

            return(prosumer);
        }
        public IHttpActionResult PutProsumer(int id, Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            Prosumer p = _unitOfWork.Prosumers.Get(id);

            if (p == null)
            {
                return(NotFound());
            }

            p.SmartMeterDatas = prosumer.SmartMeterDatas;
            p.Address         = prosumer.Address;
            p.ExpectedDatas   = prosumer.ExpectedDatas;
            p.Name            = prosumer.Name;
            p.TokenBalance    = prosumer.TokenBalance;
            p.Type            = prosumer.Type;

            _unitOfWork.Complete();

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public void Archive([NotNull] Prosumer prosumer)
 {
     if (_myqueue.Count > 2000)
     {
         Console.WriteLine("Archiver queue at over 2000!");
     }
     _myqueue.Add(prosumer);
 }
Exemple #14
0
        protected override void RunActualProcess([NotNull] ScenarioSliceParameters parameters)
        {
            //profile export
            var dbProfileExport =
                Services.SqlConnection.GetDatabaseConnection(Stage.ProfileExport, parameters);
            var prosumers = Prosumer.LoadProsumers(dbProfileExport, TableType.HouseGeneration);

            var resultPathGeneration = Path.Combine(dbProfileExport.GetResultFullPath(SequenceNumber, Name), "Export");

            if (Directory.Exists(resultPathGeneration))
            {
                Directory.Delete(resultPathGeneration, true);
                Thread.Sleep(500);
            }

            if (!Directory.Exists(resultPathGeneration))
            {
                Directory.CreateDirectory(resultPathGeneration);
                Thread.Sleep(500);
            }

            HashSet <string> usedKeys = new HashSet <string>();
            var           trafokreise = prosumers.Select(x => x.TrafoKreis).Distinct().ToList();
            RowCollection rc          = new RowCollection();

            foreach (var trafokreis in trafokreise)
            {
                if (string.IsNullOrWhiteSpace(trafokreis))
                {
                    continue;
                }

                var    filteredProsumers     = prosumers.Where(x => x.TrafoKreis == trafokreis).ToList();
                string tkFileName            = trafokreis.Replace("ä", "ae").Replace("ö", "oe").Replace("ü", "ue");
                var    csvFileNameGeneration = Path.Combine(resultPathGeneration, tkFileName + ".csv");
                var    sw2 = new StreamWriter(csvFileNameGeneration);

                int lines = 0;
                foreach (var prosumer in filteredProsumers)
                {
                    var row = RowBuilder.Start("Trafokreis", trafokreis).Add("Name", prosumer.Name).Add("Energy", prosumer.SumElectricityFromProfile);
                    if (usedKeys.Contains(prosumer.HausanschlussKey))
                    {
                        throw new FlaException("This key was already exported");
                    }
                    usedKeys.Add(prosumer.HausanschlussKey);
                    sw2.WriteLine(prosumer.GetCSVLine());
                    lines++;
                    rc.Add(row);
                }
                Log(MessageType.Info, "Wrote " + lines + " lines to  " + csvFileNameGeneration);
                sw2.Close();
            }

            var fn = MakeAndRegisterFullFilename("Generation.xlsx", parameters);

            XlsxDumper.WriteToXlsx(rc, fn, "Generators");
        }
        private void WriteSumLineToCsv([NotNull] Prosumer p, [NotNull] string trafokreis, GenerationOrLoad generationOrLoad)
        {
            string       tkFileName            = FilenameHelpers.CleanFileName(trafokreis);
            var          csvFileNameGeneration = Path.Combine(_processingResultPathForProfiles, tkFileName + "." + generationOrLoad + ".csv");
            StreamWriter sw = new StreamWriter(csvFileNameGeneration, true);

            sw.WriteLine(p.GetCSVLine());
            sw.Close();
        }
        public IActionResult PostProsumer([FromBody] Prosumer prosumer)
        {
            using (var unitOfWork = new UnitOfWork(fac.db))
            {
                unitOfWork.Prosumer.Add(prosumer);

                return(CreatedAtRoute("DefaultApi", new { id = prosumer.ProsumerId }, prosumer));
            }
        }
Exemple #17
0
        public async Task Test3()
        {
            UdpClient server  = new UdpClient(8414);
            var       service = new Broker(new Service()).Service;

            ServiceCodec.Instance.Debug = true;
            service.Use(Log.IOHandler)
            .Use(Log.InvokeHandler)
            .Bind(server);

            var client1   = new Client("udp://127.0.0.1:8414");
            var prosumer1 = new Prosumer(client1, "1");

            prosumer1.OnSubscribe += (topic) => {
                Console.WriteLine(topic + " is subscribed.");
            };
            prosumer1.OnUnsubscribe += (topic) => {
                Console.WriteLine(topic + " is unsubscribed.");
            };
            var client2   = new Client("udp://127.0.0.1:8414");
            var prosumer2 = new Prosumer(client2, "2");
            await prosumer1.Subscribe <string>("test", (data, from) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("hello", data);
                System.Console.WriteLine(from);
                Assert.AreEqual("2", from);
            }).ConfigureAwait(false);

            await prosumer1.Subscribe <string>("test2", (data) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("world", data);
            }).ConfigureAwait(false);

            await prosumer1.Subscribe <Exception>("test3", (data) => {
                System.Console.WriteLine(data);
                Assert.AreEqual("error", data.Message);
            }).ConfigureAwait(false);

            var r1 = prosumer2.Push("hello", "test", "1");
            var r2 = prosumer2.Push("hello", "test", "1");
            var r3 = prosumer2.Push("world", "test2", "1");
            var r4 = prosumer2.Push("world", "test2", "1");
            var r5 = prosumer2.Push(new Exception("error"), "test3", "1");
            var r6 = prosumer2.Push(new Exception("error"), "test3", "1");
            await Task.WhenAll(r1, r2, r3, r4, r5, r6).ConfigureAwait(false);

            await Task.Delay(10).ConfigureAwait(false);

            await prosumer1.Unsubscribe("test").ConfigureAwait(false);

            await prosumer1.Unsubscribe("test2").ConfigureAwait(false);

            await prosumer1.Unsubscribe("test3").ConfigureAwait(false);

            server.Close();
        }
Exemple #18
0
        public Prosumer CreateProsumer(Prosumer prosumer)
        {
            if (prosumer != null)
            {
                prosumerRepo.AddProsumer(prosumer).Wait();
                return(prosumerRepo.GetProsumerByCopperID(prosumer.CopperID));
            }

            return(null);
        }
        protected override void RunActualProcess([NotNull] ScenarioSliceParameters parameters)
        {
            var dbDstProfiles = Services.SqlConnection.GetDatabaseConnection(Stage.ProfileGeneration,
                                                                             parameters);

            var fieldDefinition = Prosumer.GetSaveableEntry(dbDstProfiles, TableType.HousePart);

            fieldDefinition.MakeTableForListOfFields();
//            Services.SqlConnection.RecreateTable<Prosumer>(Stage.ProfileGeneration, parameters.DstScenario, parameters.DstYear);
            dbDstProfiles.Database.Execute("VACUUM");
        }
Exemple #20
0
        protected override void RunActualProcess([NotNull] ScenarioSliceParameters parameters)
        {
            var dbDstProfiles = Services.SqlConnection.GetDatabaseConnection(Stage.ProfileGeneration, parameters);
            var dbSrcProfiles = Services.SqlConnection.GetDatabaseConnection(Stage.ProfileImport, Constants.PresentSlice).Database;
            var vdewvals      = dbSrcProfiles.Fetch <VDEWProfileValues>();
            var dbHouses      = Services.SqlConnection.GetDatabaseConnection(Stage.Houses, parameters).Database;
            var houses        = dbHouses.Fetch <House>();

            Prosumer.ClearProsumerTypeFromDB(Services.SqlConnection.GetDatabaseConnection(Stage.ProfileGeneration,
                                                                                          parameters), ProsumerType.Household, TableType.HousePart);
            var slp = new SLPProvider(parameters.DstYear);
            //var houses = dbHouses.Fetch<House>();
            var households = dbHouses.Fetch <Household>();

            //var trafoKreise = dbDstProfiles.Database.Fetch<TrafoKreisResult>();
            Log(MessageType.Info, "making " + households.Count + " households");
            var sa = Prosumer.GetSaveableEntry(dbDstProfiles, TableType.HousePart);
            // && idx < 20
            double totalHouseholdEnergy = 0;
            double totalProfileEnergy   = 0;

            for (var idx = 0; idx < households.Count; idx++)
            {
                var           household = households[idx];
                House         house     = houses.Single(x => x.HouseGuid == household.HouseGuid);
                Hausanschluss ha        = house.Hausanschluss.Single(x => x.HausanschlussGuid == household.HausAnschlussGuid);
                // ReSharper disable once UseObjectOrCollectionInitializer
                var pa = new Prosumer(household.HouseGuid, household.StandortIDsAsJson,
                                      ProsumerType.Household, household.HouseholdGuid,
                                      household.FinalIsn, household.HausAnschlussGuid, ha.ObjectID);
                pa.Profile = slp.Run(vdewvals, "H0", household.LowVoltageYearlyTotalElectricityUse);
                pa.SumElectricityPlanned = household.LowVoltageYearlyTotalElectricityUse;
                sa.RowEntries.Add(pa.GetRow());
                totalHouseholdEnergy += pa.SumElectricityPlanned;
                totalProfileEnergy   += pa.Profile?.EnergySum() ?? 0;
                if (sa.RowEntries.Count > 1000)
                {
                    sa.SaveDictionaryToDatabase();
                }
            }
            sa.SaveDictionaryToDatabase();
            if (Math.Abs(totalHouseholdEnergy - totalProfileEnergy) > 1)
            {
                throw new FlaException("energy sums not equal between planned energy and energy in profiles");
            }
            Info("Total Household energy: " + totalHouseholdEnergy);

            /*
             * var loadedProsumers = Prosumer.LoadProsumers(dbDstProfiles, TableType.HousePart);
             * foreach (Prosumer loadedProsumer in loadedProsumers) {
             * Log(MessageType.Info,loadedProsumer.Name + " - " + loadedProsumer.SumElectricityFromProfile + " - " + loadedProsumer.Profile?.Values.Sum() );
             * }*/
            //dbDstProfiles.Database.CompleteTransaction();
        }
Exemple #21
0
        public async Task <IHttpActionResult> Get(string id)
        {
            Prosumer prosumer = db._prosumerRepository.GetProsumerByCopperID(id);

            if (prosumer == null)
            {
                return(NotFound());
            }

            return(Ok(new Prosumer(prosumer)));
        }
        public ProductionSingleDTO CreateSingleProductionDTO(Production production, Prosumer prosumer)
        {

            var dto = new ProductionSingleDTO
            {
                KWH = production.KWH,
                ProductionTime = production.ProductionTime,
                _prosumerID = prosumer.id
            };
            return dto;
        }
Exemple #23
0
        public async Task <IHttpActionResult> Post(Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db._prosumerRepository.AddProsumer(prosumer).Wait();

            return(CreatedAtRoute("DefaultApi", new { id = prosumer.CopperID }, prosumer));
        }
Exemple #24
0
        public async Task <IHttpActionResult> GetProsumer(string id)
        {
            Prosumer prosumer = await db.Prosumers.FindAsync(id);

            if (prosumer == null)
            {
                return(NotFound());
            }

            return(Ok(prosumer));
        }
        protected override Prosumer ProvidePrivateProfile([NotNull] ProviderParameterDto ppdto)
        {
            BusinessEntry be = (BusinessEntry)ppdto.HouseComponent;

            if (be.BusinessType == BusinessType.Unknown)
            {
                throw new FlaException("unknown business type");
            }

            ppdto.HouseComponentResultObject.BusinessCategory = be.BusinessType.ToString();
            //string profileToUse = GetCorrectProfile(be.BusinessType);
            if (be.HouseComponentType == HouseComponentType.BusinessNoLastgangLowVoltage)
            {
                Hausanschluss ha      = _dbDto.Hausanschlusse.Single(x => x.Guid == be.HausAnschlussGuid);
                var           profile = GetCorrectProfile(be.BusinessType, be.EffectiveEnergyDemand, be);
                var           pa      = new Prosumer(be.HouseGuid,
                                                     be.Standort,
                                                     be.HouseComponentType,
                                                     be.Guid,
                                                     be.FinalIsn,
                                                     be.HausAnschlussGuid,
                                                     ha.ObjectID,
                                                     GenerationOrLoad.Load,
                                                     ha.Trafokreis,
                                                     Name,
                                                     profile.Name);
                pa.Profile = profile;
                pa.SumElectricityPlanned = be.EffectiveEnergyDemand;
                return(pa);
            }

            if (be.HouseComponentType == HouseComponentType.BusinessNoLastgangHighVoltage)
            {
                Hausanschluss ha      = _dbDto.Hausanschlusse.Single(x => x.Guid == be.HausAnschlussGuid);
                var           profile = GetCorrectProfile(be.BusinessType, be.EffectiveEnergyDemand, be);
                var           pa      = new Prosumer(be.HouseGuid,
                                                     be.Standort,
                                                     be.HouseComponentType,
                                                     be.Guid,
                                                     be.FinalIsn,
                                                     be.HausAnschlussGuid,
                                                     ha.ObjectID,
                                                     GenerationOrLoad.Load,
                                                     ha.Trafokreis,
                                                     Name,
                                                     profile.Name);
                pa.Profile = GetCorrectProfile(be.BusinessType, be.EffectiveEnergyDemand, be);
                pa.SumElectricityPlanned = be.EffectiveEnergyDemand;
                ppdto.HouseComponentResultObject.ProcessingStatus = "High Voltage Supplied Business without RLM";
                return(pa);
            }

            throw new FlaException("No profile could be created");
        }
        public IHttpActionResult GetProsumer(int id)
        {
            Prosumer prosumer = _unitOfWork.Prosumers.Get(id);

            if (prosumer == null)
            {
                return(NotFound());
            }

            return(Ok(prosumer));
        }
Exemple #27
0
        // POST: api/Prosumer
        public async Task <HttpResponseMessage> Post(Prosumer prosumer)
        {
            var content          = JsonConvert.SerializeObject(prosumer);
            var buf              = System.Text.Encoding.UTF8.GetBytes(content);
            var byteArrayContent = new ByteArrayContent(buf);

            byteArrayContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var responseBody = await mHttpClient.PostAsync(new Uri(mApiUrl), byteArrayContent);

            return(responseBody);
        }
Exemple #28
0
        public void Update(Prosumer prosumer)
        {
            Document doc = GetDoc(prosumer.CopperID);

            doc.SetPropertyValue("wallet", prosumer.wallet);
            doc.SetPropertyValue("smartmeter", prosumer.smartmeter);

            if (doc != null)
            {
                _Context.client.ReplaceDocumentAsync(doc).Wait();
            }
        }
        public IHttpActionResult PostProsumer(Prosumer prosumer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _unitOfWork.Prosumers.Add(prosumer);
            _unitOfWork.Complete();

            return(CreatedAtRoute("DefaultApi", new { id = prosumer.Id }, prosumer));
        }
Exemple #30
0
        public IHttpActionResult Delete(string id)
        {
            Prosumer prosumer = db._prosumerRepository.GetProsumerByCopperID(id);

            if (prosumer == null)
            {
                return(NotFound());
            }

            db._prosumerRepository.DeleteProsumer(prosumer.CopperID);

            return(Ok(prosumer));
        }