Exemplo n.º 1
0
        public async Task <ActionResult> Save(EfficiencyViewModel model)
        {
            using (EfficiencyServiceClient client = new EfficiencyServiceClient())
            {
                Efficiency obj = new Efficiency()
                {
                    Key = new EfficiencyKey()
                    {
                        Code  = model.Code.ToUpper(),
                        Group = model.Group.ToUpper()
                    },
                    Name        = model.Name,
                    Lower       = model.Lower,
                    Upper       = model.Upper,
                    Description = model.Description,
                    IsUsed      = model.IsUsed,
                    Editor      = User.Identity.Name,
                    EditTime    = DateTime.Now,
                    CreateTime  = DateTime.Now,
                    Creator     = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(ZPVMResources.StringResource.Efficiency_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Efficiency(string core, string speedUp)
        {
            var result = new Efficiency();

            using (var client = new HttpClient())
            {
                var request = CalculatorService.GetRequestEfficiency(core, speedUp);
                var content = new StringContent(request, Encoding.UTF8, "text/xml");
                var action  = "http://tempuri.org/ICalculator/Efficiency";

                client.DefaultRequestHeaders.Add("SOAPAction", action);

                using (var response = await client.PostAsync(CalculatorService.Url, content))
                {
                    var asyncstring = await response.Content.ReadAsStringAsync();

                    var soapResponse = Transform.Exec(asyncstring);
                    var serialize    = JsonConvert.DeserializeObject <EfficiencyRoot>(soapResponse);

                    result.Calculated = serialize.Envelope.Body.EfficiencyResponse.EfficiencyResult.Calculated;
                }
            }

            return(Ok(result));
        }
Exemplo n.º 3
0
        public ContextTurret()
        {
            ContextBehaviors.Add(Navigation = new NavigateToPoint(this)
            {
                BehaviorWeight = 0.00f
            });
            ContextBehaviors.Add(Efficiency = new Efficiency(this)
            {
                BehaviorWeight = 1f, MaximumAngle = MathF.PI / 4
            });
            ContextBehaviors.Add(Dodge0 = new Dodge(this)
            {
                LookAheadMS = 250, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Dodge1 = new Dodge(this)
            {
                LookAheadMS = 500, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Dodge2 = new Dodge(this)
            {
                LookAheadMS = 1000, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Separation = new Separation(this)
            {
                LookAheadMS = 500, BehaviorWeight = 0f
            });
            ContextBehaviors.Add(StayInBounds = new StayInBounds(this)
            {
                LookAheadMS = 1000, BehaviorWeight = 1f
            });

            Navigation.TargetPoint = new Vector2(0, 0);
            Steps = 16;
        }
        public async Task <Efficiency> ReadByIdAsync(int id)
        {
            Efficiency read = await this.DbSet
                              .Where(d => d.Id.Equals(id) && d.IsDeleted.Equals(false))
                              .FirstOrDefaultAsync();

            return(read);
        }
 public async Task <int> CreateAsync(Efficiency model)
 {
     do
     {
         model.Code = CodeGenerator.Generate();
     }while (this.DbSet.Any(d => d.Code.Equals(model.Code)));
     model.Value /= 100;
     efficiencyLogic.Create(model);
     return(await DbContext.SaveChangesAsync());
 }
Exemplo n.º 6
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine($"  {Model}:");
            builder.AppendLine($"    Power: {Power}");
            builder.AppendLine($"    Displacement: {(Displacement == null ? "n/a" : Displacement.ToString())}");
            builder.AppendLine($"    Efficiency: {(Efficiency == null ? "n/a" : Efficiency.ToString())}");

            return(builder.ToString());
        }
        public void Ok_Return_Success()
        {
            //Setup
            ResultFormatter resultFormatter = new ResultFormatter("1", 200, "ok");
            Efficiency      model           = new Efficiency();

            //Act
            Dictionary <string, object> result = resultFormatter.Ok();

            //Assert
            Assert.NotNull(result);
        }
Exemplo n.º 8
0
    public mEntity getFish(GameObject vessel)
    {
        float   fish      = 0f;
        float   totalFish = 0f;
        bool    enough    = false;
        mEntity currentCatch;

        for (int i = 0; i < boatsFishing.Count; i++)
        {
            VesselBehavior boat = boatsFishing[i].GetComponent <VesselBehavior>();
            totalFish += boat.efficiency * boat.capacity * 15;
        }

        enough = currentResource > totalFish ? true : false;

        VesselBehavior vesselComp = vessel.GetComponent <VesselBehavior>();

        if (enough)
        {
            float luck = Random.Range(currentResource / carryCapacity, ((currentResource / carryCapacity) + 1f) / 2);
            vesselComp.entities.GetComponent <Catch>(out currentCatch);

            vesselComp.currentCatch = vesselComp.efficiency * vesselComp.capacity * 15 * luck;

            Catch      catchComp = currentCatch.getComponent <Catch>();
            Efficiency eff       = vesselComp.entities.GetComponent <Efficiency>();
            ByCatch    bycatch   = currentCatch.getComponent <ByCatch>();


            catchComp.size   = vesselComp.efficiency * vesselComp.capacity * 15 * luck;
            bycatch.size     = Random.Range(.1f, .2f) * catchComp.size;
            currentResource -= vesselComp.currentCatch;    //vesselComp.efficiency * vesselComp.capacity * 15;
        }
        else
        {
            vesselComp.entities.GetComponent <Catch>(out currentCatch);

            vesselComp.currentCatch = currentResource / boatsFishing.Count;

            Catch   catchComp = currentCatch.getComponent <Catch>();
            ByCatch bycatch   = currentCatch.getComponent <ByCatch>();
            bycatch.size = Random.Range(.1f, .2f) * catchComp.size;

            vesselComp.currentCatch = currentResource / boatsFishing.Count;
            currentResource        -= currentResource / boatsFishing.Count;
        }

        boatsFishing.Remove(vessel);

        return(currentCatch);
    }
Exemplo n.º 9
0
        public override string GetResult()
        {
            var s = "";

            s += "Backtesting Project " + Name + " from " + TestStartTime.ToString() + " to " + TestEndTime.ToString() + "\n";
            s += "Current Value:" + CurrentValue.ToString() + "\n";
            s += "Pnl:" + Pnl.ToString() + "\n";
            s += "Efficiency:" + Efficiency.ToString() + "\n";
            s += "AverageEfficiency:" + AverageEfficiency.ToString() + "\n";
            s += "Max Lost:" + MaxLost.ToString() + "\n";
            s += "Max Capital:" + MaxCapital.ToString() + "\n";

            s += "Max Lost Percent:" + MaxLostPercent.ToString() + "\n";
            return(s);
        }
        public async Task <Efficiency> ReadModelByQuantity(int Quantity)
        {
            Efficiency result = await this.DbSet
                                .FirstOrDefaultAsync(eff => Quantity > 0 && eff.InitialRange <= Quantity && eff.FinalRange >= Quantity && eff.IsDeleted == false);

            if (result == null)
            {
                return(new Efficiency()
                {
                    Id = 0,
                    Value = 0
                });
            }
            else
            {
                result.Value *= 100;
            }
            return(result);
        }
Exemplo n.º 11
0
        public void CalculateEfficiency()
        {
            Efficiency newEfficiency = 0;

            newEfficiency += budgetEffectOnEfficiency[(int)budget];

            if (currentWorkers > totalWorkers * 0.7f)
            {
                newEfficiency += 2;
            }
            else if (currentWorkers > 0)
            {
                newEfficiency += 1;
            }

            Efficiency oldEfficiency = efficiency;

            efficiency = newEfficiency;

            OnChangeEfficiency(oldEfficiency, newEfficiency);
        }
Exemplo n.º 12
0
        public IActionResult OnGetFindUser(string name)
        {
            string          out_str = "";
            Region          rg      = new Region(name);
            User            user    = new User(100000, 2500, rg);
            ElectricStation e_s     = new ElectricStation(user.power, user.budget);
            Efficiency      eff     = new Efficiency(e_s, user.region);

            ElectricStation[] arr = eff.CalculateMostEfficientStation();
            for (int i = 0; i < arr.Length; i++)
            {
                out_str += $"<table> <tr><th>   Конфигурация: {i + 1}</th></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Аккумулятор - {arr[i].accumulator.name}</p><p><img src = 'img/{arr[i].accumulator.name}.jpg' class ='img-fluid'></p></td></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Электрогенератор - {arr[i].esource.name}</p><p><img src = 'img/{arr[i].esource.name}.jpg' class ='img-fluid'></p></td></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Инвертор - {arr[i].inverter.name}</p><p><img src = 'img/{arr[i].inverter.name}.jpg' class ='img-fluid'></p></td></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Полная стоимость - {arr[i].full_cost}</p></td></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Мощность СЭС - {arr[i].full_power}</p></td></tr>"
                           + $"<tr class='stroke'><td><p style=' text-indent:3px;'>Эффективность - {arr[i].efficiency}</p></td></tr></table>";
            }
            return(new JsonResult(out_str));
        }
Exemplo n.º 13
0
        public CTFBot()
        {
            ContextBehaviors.Add(Navigation = new NavigateToPoint(this)
            {
                BehaviorWeight = 0.1f
            });
            ContextBehaviors.Add(Efficiency = new Efficiency(this)
            {
                BehaviorWeight = 0.1f
            });
            ContextBehaviors.Add(Dodge0 = new Dodge(this)
            {
                LookAheadMS = 250, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Dodge1 = new Dodge(this)
            {
                LookAheadMS = 500, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Dodge2 = new Dodge(this)
            {
                LookAheadMS = 1000, BehaviorWeight = 2
            });
            ContextBehaviors.Add(Separation = new Separation(this)
            {
                LookAheadMS = 500, BehaviorWeight = 0f
            });
            ContextBehaviors.Add(StayInBounds = new StayInBounds(this)
            {
                LookAheadMS = 200, BehaviorWeight = 0.3f
            });

            Sensors.Add(SensorCTF = new SensorCTF(this));

            Navigation.TargetPoint = Vector2.Zero;
            Steps = 16;
        }
Exemplo n.º 14
0
 public virtual void OnChangeEfficiency(Efficiency oldEfficiency, Efficiency newEfficiency)
 {
 }
 public async Task <int> UpdateAsync(int id, Efficiency model)
 {
     model.Value /= 100;
     efficiencyLogic.UpdateAsync(id, model);
     return(await DbContext.SaveChangesAsync());
 }
Exemplo n.º 16
0
        /// <summary>
        /// Guarda los datos del reporte de Eficiecias semanales
        /// </summary>
        /// <param name="list">Listado con las eficiencias de una semana</param>
        /// <param name="salesRoom">Sala de ventas</param>
        /// <param name="dtStart">Fecha inicial</param>
        /// <param name="dtEnd">Fecha Fin</param>
        /// <history>
        /// [ecanul] 18/08/2016 Created
        /// </history>
        /// <returns></returns>
        public async static Task <int> SaveEfficiencies(List <RptEfficiencyWeekly> list, string salesRoom, DateTime dtStart, DateTime dtEnd)
        {
            return(await Task.Run(async() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transact = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            //Lista para agregar las eficiencias nuevas
                            var lstEffAdd = new List <Efficiency>();

                            //Obtener las eficiencias existentes dentro del rango de fechas, sala de ventas y periodo seleccionado
                            var lstEfficiency = dbContext.Efficiencies.Include(Ey => Ey.Personnels).Where(e => e.efsr == salesRoom && e.efDateFrom == dtStart && e.efDateTo == dtEnd && e.efpd == "W").ToList();
                            //Obtiene todos los tipos de eficiencias
                            var lstEfftypes = await BREfficiencyTypes.GetEfficiencyTypes();
                            //Eficiencia vacia
                            Efficiency eff = null;
                            //por cada tipo de Eficiencia
                            lstEfftypes.ForEach(eft =>
                            {
                                //Se busca en el listado todas las eficiencias que concuerden con el tipo de ficicicias actual
                                eff = lstEfficiency.Where(ef => ef.efet == eft.etID).FirstOrDefault();
                                //Si no se encontro la eficiencia se crea una nueva
                                if (eff == null)
                                {
                                    eff = new Efficiency
                                    {
                                        efsr = salesRoom,
                                        efDateFrom = dtStart,
                                        efDateTo = dtEnd,
                                        efet = eft.etID,
                                        efpd = "W"
                                    };
                                    dbContext.Entry(eff).State = EntityState.Added;
                                    var respuesta = dbContext.SaveChanges();
                                }
                                //Se guardan los vendedores del tipo de eficiencia
                                //Se eliminan los vendedores que tengan la eficiencia actual
                                //SP DE ELIMINAR USP_IM_DeleteEfficiencySalesmen
                                dbContext.USP_IM_DeleteEfficiencySalesmen(Convert.ToInt32(eff.efID));
                                //por cada elemento de la lista del reporte y que tengan un id
                                list.Where(add => add.EfficiencyType == eft.etN).ToList().ForEach(a =>
                                {
                                    if (!string.IsNullOrEmpty(a.SalemanID))
                                    {
                                        //Salvar EfficiencySalesman USP_IM_ADDEfficiencySalesmen
                                        dbContext.USP_IM_ADDEfficiencySalesmen((int)eff.efID, a.SalemanID);
                                        //dbContext.Database.ExecuteSqlCommand($"Insert into efficiencysalesman vaues({eff.efID}, {a.SalemanID})");
                                    }
                                });
                            });
                            transact.Commit();
                            return 1;
                        }
                        catch
                        {
                            transact.Rollback();
                            throw;
                        }
                    }
                }
            }));
        }
Exemplo n.º 17
0
 public TableLamp(GoodsType type, Efficiency efficiency)
     : base(type)
 {
     this.efficiency = efficiency;
 }
Exemplo n.º 18
0
        /// <summary>
        /// Get the information about the resource harvester
        /// </summary>
        /// <returns>The information about the harvester</returns>
        public override string GetInfo()
        {
            StringBuilder info = new StringBuilder();

            info.AppendLine(ConverterName);
            string type = string.Empty;

            switch (HarvesterType)
            {
            case 0:
                type = "#autoLOC_6004052";
                break;

            case 1:
                type = "#autoLOC_6004053";
                break;

            case 2:
                type = "#autoLOC_6004054";
                break;

            case 3:
                type = "#autoLOC_6004055";
                break;
            }
            ;

            info.AppendLine(Localizer.Format("#autoLOC_259675", type, (int)(Efficiency * 100.0f)));

            //the used resource
            info.AppendLine(Localizer.Format("#autoLOC_259676"));
            List <PartResourceDefinition> usedResources = GetConsumedResources();

            for (int i = 0; i < usedResources.Count; i++)
            {
                info.Append(Localizer.Format("#autoLOC_244197", usedResources[i].displayName, (eInput.Ratio * Efficiency).ToString("0.00")));
            }

            //the produced resources
            info.AppendLine(Localizer.Format("#autoLOC_259698"));
            for (int i = 0; i < outputResources.Length; i++)
            {
                info.Append(Localizer.Format("#autoLOC_244197", PartResourceLibrary.Instance.resourceDefinitions[outputResources[i].Trim()].displayName, Efficiency.ToString("0.00")));
                if (i < (outputResources.Length - 1))
                {
                    info.AppendLine(Localizer.Format("#autoLOC_230521"));
                }
            }

            return(info.ToString());
        }