コード例 #1
1
 protected void Page_Load(object sender, EventArgs e)
 {
     IUnityContainer container = new UnityContainer();
     UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
     section.Configure(container);
     if (Request["installation"] != null)
     {
         int installationid = Int32.Parse(Request["installation"]);
         userid = Int32.Parse(Request["userid"]);
         user = Request["user"];
         sservice = container.Resolve<IStatisticService>();
         IInstallationBL iinstall = container.Resolve<IInstallationBL>();
         imodel = iinstall.getInstallation(installationid);
         Dictionary<InstallationModel, List<InstallationState>> statelist = sservice.getInstallationState(imodel.customerid);
         StringBuilder str = new StringBuilder();
         str.Append("<table border = '1'><tr><th>Description</th><th>Messwert</th><th>Einheit</th></tr>");
         foreach (var values in statelist)
         {
             if(values.Key.installationid.Equals(installationid))
             {
                 foreach (var item in values.Value)
                 {
                      str.Append("<tr><td>" + item.description + "</td><td>" + item.lastValue + "</td><td>" + item.unit + "</td></tr>");
                 }
                 break;
             }
         }
         str.Append("</table>");
         anlagenzustand.InnerHtml = str.ToString();
     }
 }
コード例 #2
0
        public void createInstallation(InstallationModel installation)
        {
            try
            {
                ValidationResults vresult = Validation.ValidateFromAttributes<InstallationModel>(installation);

                if (vresult.IsValid)
                {
                    irepo.Add(installation);
                    irepo.Save();
                    log.Info("Installation saved.");
                }
                else
                {
                    log.Warn(vresult.Count + "Validation errors");
                    StringBuilder sb = null;
                    foreach (var error in vresult)
                    {
                        sb = new StringBuilder();
                        sb.Append("Error on property ");
                        sb.Append(error.Target);
                        sb.Append(": ");
                        sb.Append(error.Message);
                    }
                    log.Warn(sb);
                }
            }
            catch (DalException exp)
            {
                log.Error("Installation konnte nicht gespeichert werden.");
                throw new BLException("Installation konnte nicht gespeichert werden.", exp);
            }
        }
コード例 #3
0
 public static Installation ConverttoEntity(InstallationModel ininstallation)
 {
     Installation installation = null;
        try
        {
        CustomerRepository crepo = new CustomerRepository();
        MeasurementRepository mrepo = new MeasurementRepository();
        installation = new Installation();
        installation.customerid = ininstallation.customerid;
        installation.installationid = ininstallation.installationid;
        installation.latitude = ininstallation.latitude;
        installation.longitude = ininstallation.longitude;
        installation.description = ininstallation.description;
        installation.serialno = ininstallation.serialno;
        //installation.Customer = ConvertCustomer.ConverttoEntity(crepo.GetById(installation.customerid));
        foreach (var item in ininstallation.Measurement)
        {
            installation.Measurement.Add(ConvertMeasurement.ConverttoEntity(mrepo.GetById(item)));
        }
        log.Info("InstallationModel wurde konvertiert.");
        }
        catch (Exception exp)
        {
        log.Error("InstallationModel konnte nicht konvertiert werden.");
        throw new DalException("InstallationModel konnte nicht konvertiert werden.", exp);
        }
        return installation;
 }
コード例 #4
0
 public static InstallationModel ConvertfromEntity(Installation ininstallation)
 {
     InstallationModel installation = null;
        try
        {
        installation = new InstallationModel();
        installation.customerid = ininstallation.customerid;
        installation.installationid = ininstallation.installationid;
        installation.latitude = ininstallation.latitude;
        installation.longitude = ininstallation.longitude;
        installation.description = ininstallation.description;
        installation.serialno = ininstallation.serialno;
        foreach (var item in ininstallation.Measurement)
        {
            installation.Measurement.Add(item.measid);
        }
        log.Info("Installation wurde konvertiert.");
        }
        catch (Exception exp)
        {
        log.Error("Installation konnte nicht konvertiert werden.");
        throw new DalException("Installation konnte nicht konvertiert werden.", exp);
        }
        return installation;
 }
コード例 #5
0
        public void createInstallation(Installation installation)
        {
            try
            {
                InstallationModel imodel = new InstallationModel();
                imodel.latitude = installation.latitude;
                imodel.longitude = installation.longitude;
                imodel.serialno = installation.serialno;
                imodel.description = installation.description;
                imodel.customerid = installation.customerid;

                IUnityContainer container = new UnityContainer();
                UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
                section.Configure(container);
                IEngineerBL rservicebl = container.Resolve<IEngineerBL>();

                rservicebl.createInstallation(imodel);
            }
            catch (Exception exp)
            {
                log.Error("Installation via Soap konnte nicht gespeichert werden.");
                throw new Exception("Installation via Soap konnte nicht gespeichert werden.", exp);
            }
        }
コード例 #6
0
        public void TestcreateInstallation()
        {
            Init();
            EngineerBL ebl = new EngineerBL(mockcrepo, mockerepo, mockirepo);

            InstallationModel myinstallation = new InstallationModel
            {
                installationid = 1,
                customerid = 0,
                description = "testinstallation",
                serialno = "testser",
                latitude = 33,
                longitude = 44,
                Measurement = new List<int> { 0 }
            };
            ebl.createInstallation(myinstallation);
            Assert.AreEqual(2, mockirepo.GetAll().Count);
        }