Inheritance: object_base
Exemplo n.º 1
0
        public async Task <IActionResult> PutOil(int id, Oil oil)
        {
            if (id != oil?.OilId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public void GetOilById_ExistingOil_ShouldReturnOilViewModel()
        {
            // arrange
            var mockOilRepository = new Mock <IOilRepository>();
            var oil = new Oil()
            {
                Id           = Guid.NewGuid(),
                Brand        = "New Oil",
                Description  = "New Description",
                Scent        = "New Scent",
                LiquidVolume = 22,
                UnitPrice    = 20,
                UnitQuantity = 100,
                URL          = "img/oil.jpg"
            };

            mockOilRepository.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(oil);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Oil, OilViewModel>();
            });
            var mapper = config.CreateMapper();

            var oilService = new OilService(mockOilRepository.Object, mapper);

            // act
            var result = oilService.GetOilById(Guid.NewGuid());

            // assert
            result.Should().BeOfType <OilViewModel>();
        }
Exemplo n.º 3
0
        public async Task <ActionResult <Oil> > PostOil(Oil oil)
        {
            _context.Oil.Add(oil);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOil", new { id = oil?.OilId }, oil));
        }
        private void getOldResults()
        {
            storedResutls = Transformer.getResults(currentRecord.ID);
            var counter = 0;

            foreach (var result in storedResutls)
            {
                if (counter == allResults.Count)
                {
                    var tmpCollection = new ObservableCollection <ResultWrapper>();
                    allResults.Add(new ObservableCollection <ResultWrapper>());
                }

                syncResults(result, allResults[counter++]);
                selectedEquipment.Add((int)result.Oil);
                transformerPotentials.Add(String.Empty);
            }

            numSamples = storedResutls.Count();
            if (numSamples > 0)
            {
                selectedEquipmentID   = (int)storedResutls[0].Oil;
                selectedEquipmentItem = Oil.getEquipment(selectedEquipmentID);
            }
        }
Exemplo n.º 5
0
        public static Goods ChoseMarketGoods(Player p, uint func)
        {
            Goods x = new Goods();

            switch (func)
            {
            case 1:
                Grain g = new Grain();
                Ui.PrintGood(p, g);
                return(g);

            case 2:
                Crystal c = new Crystal();
                Ui.PrintGood(p, c);
                return(c);

            case 3:
                Oil o = new Oil();
                Ui.PrintGood(p, o);
                return(o);

            case 4:
                Metal m = new Metal();
                Ui.PrintGood(p, m);
                return(m);

            case 5:
                Game.MainMenue(p);
                return(x);

            default:
                Ui.PrintError("Ungültige Eingabe");
                return(x);
            }
        }
Exemplo n.º 6
0
        public static void Insert()
        {
            Oil oil = new Oil(4, "Indian Oil", 4, 400);

            OilDAL.Insert(oil);
            Console.WriteLine("Inserted");
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Oil oil = db.Oils.Find(id);

            db.Oils.Remove(oil);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Oil?.GetHashCode() ?? 0);
            return(hashCode);
        }
Exemplo n.º 9
0
 void Update()
 {
     Mercury = mercury.value * 100;
     Calcium = calcium.value * 100;
     Oil     = oil.value * 100;
     m1.text = "Mercury \t\t" + Mercury.ToString();
     m2.text = "Calcium\t\t" + Calcium.ToString();
     m3.text = "Oil\t\t" + Oil.ToString();
 }
Exemplo n.º 10
0
 public static uint GetGoodPurchasePrice(Goods g)
 {
     return(g switch
     {
         Grain _ => Grain.PurchasePrice,
         Metal _ => Metal.PurchasePrice,
         Crystal _ => Crystal.PurchasePrice,
         Oil _ => Oil.PurchasePrice,
         _ => 0
     });
Exemplo n.º 11
0
        public IActionResult Post([FromBody] JObject data)
        {
            string raw = JsonConvert.SerializeObject(data["raw"], Formatting.Indented);
            Oil    oil = new Oil {
                Description = data["description"].ToString(), Raw = raw, Timestamp = DateTime.Now
            };

            dbContext.Oils.Add(oil);
            dbContext.SaveChanges();
            return(new ObjectResult(oil));
        }
Exemplo n.º 12
0
 private void CheckOil(Oil current)
 {
     if (stats.costOil <= current.Current)
     {
         colorTextOil = colorAfford;
     }
     else
     {
         colorTextOil = colorTooLow;
     }
 }
Exemplo n.º 13
0
 public OilChangeInfo(int id, Vehicle car, Oil oil, double laborHours, DateTime servicedDate, int servicedMileage, DateTime nextService, int nextServiceMileage)
 {
     Id                 = id;
     Car                = car;
     Oil                = oil;
     LaborHours         = laborHours;
     ServicedDate       = servicedDate;
     ServicedMileage    = servicedMileage;
     NextService        = nextService;
     NextServiceMileage = nextServiceMileage;
 }
Exemplo n.º 14
0
        public bool Put(Oil myOil)
        {
            using (var db = new StationContext())
            {
                myOil.LastEditDate = DateTime.Now;

                db.Oils.Attach(myOil);
                db.Entry(myOil).State = EntityState.Modified;
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 15
0
 public ActionResult Edit([Bind(Include = "OilID,VehicleID,ODOService,OilType,NextODO,Notes,datetime,Photo")] Oil oil)
 {
     if (ModelState.IsValid)
     {
         db.Entry(oil).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OilType   = new SelectList(db.OilTypes, "OilTypeID", "OilTypeName", oil.OilType);
     ViewBag.VehicleID = new SelectList(db.Vehicles, "VehicleID", "VehicleID", oil.VehicleID);
     return(View(oil));
 }
Exemplo n.º 16
0
        public static Dictionary <Oil, double> GetOilData()
        {
            var data = QueryOilData();

            var dict = new Dictionary <Oil, double>();

            foreach (var line in data?.Lines)
            {
                var oil = Oil.Parse(line.Name);
                dict[oil] = line.ChaosValue;
            }
            return(dict);
        }
Exemplo n.º 17
0
        public HttpResponseMessage Put(int id, OilWrap oilWrap)
        {
            string errMsg             = "";
            string errMsgForChangeset = "";
            bool   isChangesetError   = false;
            Oil    model = oilWrap.Oil;

            model.Id = id;
            Model.Changeset changeset = new Model.Changeset();
            try
            {
                string token     = this.ControllerContext.Request.Headers.GetValues("Token").First();
                bool   isChecked = TokenManage.CheckAuthorizer(token, PowerStatusCode.Systemer, out auth, out errMsg);
                if (isChecked)
                {
                    if (tryValidate(model, out errMsg))
                    {
                        if (this.tryPut(ref model, out errMsg))
                        {
                            if (!ChangesetManager.tryFetch(auth.Sync, ref changeset, out errMsgForChangeset))
                            {
                                isChangesetError = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            var    status = HttpStatusCode.OK;
            string json   = "";

            if (errMsg.Length > 0)
            {
                status = (HttpStatusCode)422;
                var msg = new { errors = new { ServerSideError = errMsg } };
                json = JsonConvert.SerializeObject(msg);
            }
            else
            {
                status = HttpStatusCode.OK;
                var msg = new { Oil = model, Changeset = changeset, IsChangesetError = isChangesetError, ErrMsgForChangeset = errMsgForChangeset };
                json = JsonConvert.SerializeObject(msg);
            }
            return(new HttpResponseMessage(status)
            {
                Content = new StringContent(json, System.Text.Encoding.GetEncoding("UTF-8"), "application/json")
            });
        }
Exemplo n.º 18
0
        void Start()
        {
            MoneyTeam1 = new Money();
            OilTeam1   = new Oil();

            MoneyTeam1.Add(653);
            OilTeam1.Add(55);

            MoneyTeam2 = new Money();
            OilTeam2   = new Oil();

            MoneyTeam2.Add(653);
            OilTeam2.Add(55);
        }
Exemplo n.º 19
0
        // GET: Oils/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Oil oil = db.Oils.Find(id);

            if (oil == null)
            {
                return(HttpNotFound());
            }
            return(View(oil));
        }
Exemplo n.º 20
0
        public ActionResult PriceOil()
        {
            var viewModel = new Oil();
            var client    = new RestClient("https://gas-price.p.rapidapi.com/europeanCountries");
            var request   = new RestRequest(Method.GET);

            request.AddHeader("x-rapidapi-host", "gas-price.p.rapidapi.com");
            request.AddHeader("x-rapidapi-key", "4b0f134ed5mshcc390618454924fp13e12ajsn613f77890a43");
            IRestResponse response = client.Execute(request);

            viewModel.Root = JsonConvert.DeserializeObject <Root>(response.Content);

            return(View(viewModel.Root.results));
        }
Exemplo n.º 21
0
        public override void Update()
        {
            base.Update();

            oilLabel.text                = totals ? Oil.ToString() : Oil.ToString("P");
            farmingLabel.text            = totals ? Farming.ToString() : Farming.ToString("P");
            oreLabel.text                = totals ? Ore.ToString() : Ore.ToString("P");
            forestLabel.text             = totals ? Forest.ToString() : Forest.ToString("P");
            districtNameLabel.text       = Name.ToString();
            sizeLabel.text               = Size.ToString();
            districtTypeLabel.spriteName = GetSpriteFromType(Type);

            districtNameLabel.textColor = new Color32(182, 221, 254, 255);
            farmingLabel.textColor      = Farming == 0 ? new Color32(165, 165, 165, 128) : new Color32(182, 221, 254, 255);
            forestLabel.textColor       = Forest == 0 ? new Color32(165, 165, 165, 128) : new Color32(182, 221, 254, 255);
            if (OreDecline)
            {
                oreLabel.textColor = new Color32(255, 182, 193, 128);
            }
            else
            {
                if (Ore == 0)
                {
                    oreLabel.textColor = new Color32(165, 165, 165, 128);
                }
                else
                {
                    oreLabel.textColor = new Color32(182, 221, 254, 255);
                }
            }

            if (OilDecline)
            {
                oilLabel.textColor = new Color32(255, 182, 193, 128);
            }
            else
            {
                if (Oil == 0)
                {
                    oilLabel.textColor = new Color32(165, 165, 165, 128);
                }
                else
                {
                    oilLabel.textColor = new Color32(182, 221, 254, 255);
                }
            }
            sizeLabel.textColor = new Color32(182, 221, 254, 255);
        }
Exemplo n.º 22
0
        // GET: Oils/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Oil oil = db.Oils.Find(id);

            if (oil == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OilType   = new SelectList(db.OilTypes, "OilTypeID", "OilTypeName", oil.OilType);
            ViewBag.VehicleID = new SelectList(db.Vehicles, "VehicleID", "VehicleID", oil.VehicleID);
            return(View(oil));
        }
Exemplo n.º 23
0
        public bool Post(Oil myOil)
        {
            using (var db = new StationContext())
            {
                if (myOil.OilGuid == Guid.Empty)
                {
                    myOil.OilGuid = Guid.NewGuid();
                }

                myOil.DateAdded    = DateTime.Now;
                myOil.LastEditDate = DateTime.Now;

                db.Oils.Add(myOil);
                return(db.SaveChanges() > 0);
            }
        }
Exemplo n.º 24
0
        public static Oil Get(int id)
        {
            Oil oil = null;

            try
            {
                conString = ConfigurationManager.ConnectionStrings["constrPanditAuto"].ConnectionString;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string     query = "SELECT * FROM Oils WHERE OilId=@OilId";
                    SqlCommand cmd   = new SqlCommand(query, con);
                    cmd.Parameters.Add(new SqlParameter("@OilId", id));
                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        if (reader.HasRows)
                        {
                            reader.Read();
                            oil = new Oil()
                            {
                                OilId = id,

                                Title    = reader["title"].ToString(),
                                Quantity = int.Parse(reader["Quantity"].ToString()),
                                Price    = double.Parse(reader["price"].ToString()),
                            };
                        }
                    }
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //ADO.NET code
            return(oil);
        }
Exemplo n.º 25
0
        public OilChangeInfo(int id, string make, string model, int year, string weight, string brand, double quantity, double oilPrice, string fBrand, double fPrice, double laborHours, DateTime servicedDate, int servicedMileage, DateTime nextService, int nextServiceMileage)
        {
            Id = id;

            Vehicle car = new Vehicle(make, model, year);

            this.Car = car;

            Oil oil = new Oil(weight, brand, quantity, oilPrice, fBrand, fPrice);

            this.Oil = oil;

            LaborHours         = laborHours;
            ServicedDate       = servicedDate;
            ServicedMileage    = servicedMileage;
            NextService        = nextService;
            NextServiceMileage = nextServiceMileage;
        }
Exemplo n.º 26
0
 private void ConnectOkFlushData()
 {
     //将8号地标数据写入到加油机
     frmMain.mMain.AllDataBase.OilData.Write(string.Format("update TestBarCode Set BarCode='{0}'", frmMain.mMain.AllCars.AllStatueLineStation[7].BarCode));
     using (DataTable dt = frmMain.mMain.AllDataBase.OilData.Read("select * from YBZT where 仪表地址=1"))
     {
         if (dt != null && dt.Rows.Count == 1)
         {
             LastStatueTime = All.Class.Num.ToDateTime(dt.Rows[0]["更新时间"]);
             Statue         = All.Class.Num.ToInt(dt.Rows[0]["状态"]);
         }
     }
     using (DataTable dt = frmMain.mMain.AllDataBase.OilData.Read(string.Format("select top 2 * from YFYB where ID>{0} order by ID", frmMain.mMain.AllDataXml.LocalSingleFlush.OilIndex)))
     {
         if (dt != null && dt.Rows.Count > 1)//当有2条以上的记录时才添加,注油机开机会先放一条临时记录,所以要先屏蔽这个临时记录
         {
             Oil tmpOil = new Oil();
             tmpOil.FaLiaoShiJian  = All.Class.Num.ToDateTime(dt.Rows[0]["发料时间"]);
             tmpOil.FaPiaoHaoMa    = All.Class.Num.ToString(dt.Rows[0]["发票号码"]);
             tmpOil.BarCode        = All.Class.Num.ToString(dt.Rows[0]["条码"]);
             tmpOil.ShiBieMa       = All.Class.Num.ToString(dt.Rows[0]["识别码"]);
             tmpOil.GuiJiHao       = All.Class.Num.ToString(dt.Rows[0]["轨迹号"]);
             tmpOil.YouPin         = All.Class.Num.ToString(dt.Rows[0]["油品"]);
             tmpOil.ChengXuShu     = All.Class.Num.ToInt(dt.Rows[0]["程序数"]);
             tmpOil.DingLiangHeJi  = All.Class.Num.ToFloat(dt.Rows[0]["定量合计"]);
             tmpOil.ShiFaHeJi      = All.Class.Num.ToFloat(dt.Rows[0]["实发合计"]);
             tmpOil.GuoChengJieGuo = All.Class.Num.ToString(dt.Rows[0]["过程结果"]);
             tmpOil.YiBiaoDiZhi    = All.Class.Num.ToInt(dt.Rows[0]["仪表地址"]);
             tmpOil.ZiDong         = All.Class.Num.ToBool(dt.Rows[0]["自动"]);
             tmpOil.LiuLiangXiShu  = All.Class.Num.ToFloat(dt.Rows[0]["流量系数"]);
             tmpOil.LeiXingMiaoShu = All.Class.Num.ToString(dt.Rows[0]["类型描述"]);
             for (int i = 0; i < 10; i++)
             {
                 tmpOil.DingLiang[i] = All.Class.Num.ToFloat(dt.Rows[0][string.Format("定量{0}", i + 1)]);
                 tmpOil.ShiFa[i]     = All.Class.Num.ToFloat(dt.Rows[0][string.Format("实发{0}", i + 1)]);
             }
             tmpOil.Save();
             frmMain.mMain.AllDataXml.LocalSingleFlush.OilIndex = All.Class.Num.ToInt(dt.Rows[0]["ID"]);
             frmMain.mMain.AllDataXml.LocalSingleFlush.Save();
         }
     }
 }
Exemplo n.º 27
0
        static void IterationAlgorithm(SectorFromNPStoNPS NPS_Pipe, Oil oil, List <double> HeadArray,
                                       double speed, ref double EndPressure, out string TextMessage)
        {
            TextMessage = "";
            double Q         = (PI * speed * Math.Pow(NPS_Pipe.pipe.Diameter, 2) / 4);
            var    Reyn      = NumberReynolds(Q, NPS_Pipe.pipe.Diameter, oil.Viscosity);
            var    HydroRes  = HydroResist(NPS_Pipe.pipe.Roughness, Reyn);
            var    HydroLoss = HydroLosses(HydroRes, Q, NPS_Pipe.pipe.Diameter) * 1000; // multiply by 1000 to get losses per one km!

            double Head = EndPressure;                                                  // Переменная напора. Изначально равна конечному напору в ТП.

            for (int i = NPS_Pipe.X_SpotsSector.Count - 1; i > 0; i--)
            {
                Head = Head + HydroLoss * (NPS_Pipe.X_SpotsSector[i] - NPS_Pipe.X_SpotsSector[i - 1]);

                // Если начало самотечного участка
                if (Head < NPS_Pipe.Z_SpotsSector[i - 1] + oil.VapourPressure)
                {
                    Head = NPS_Pipe.Z_SpotsSector[i - 1] + oil.VapourPressure;
                }

                // Если напор выше максимального для трубы
                if (Head > NPS_Pipe.pipe.MaxPressure)
                {
                    TextMessage += $"Pressure on {NPS_Pipe.X_SpotsSector[i]} kilometer is exceeded\n";
                }
                HeadArray.Add(Head);
            }
            if (Head > NPS_Pipe.pipe.MaxPressure)
            {
                TextMessage += $"Outlet pressure on station {NPS_Pipe.station.Name} is exceeded\n";
            }
            Head = Head - NPS_Pipe.station.GetDiffPresure(Q);
            if (Head < NPS_Pipe.station.PositionStation.High_mark + NPS_Pipe.station.CavitationPressure)
            {
                TextMessage += $"Inlet pressure on station {NPS_Pipe.station.Name} is too small\n";
            }
            HeadArray.Append(Head);
            EndPressure = Head;
        }
Exemplo n.º 28
0
        public static List <Oil> GetAll()
        {
            List <Oil> oils = new List <Oil>();

            conString = ConfigurationManager.ConnectionStrings["constrPanditAuto"].ConnectionString;
            SqlConnection con    = new SqlConnection(conString);
            string        cmdStr = "SELECT * FROM Oils";
            SqlCommand    cmd    = new SqlCommand(cmdStr, con);

            try
            {
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    int oilId = int.Parse(dr["OilId"].ToString());

                    string title    = dr["Title"].ToString();
                    int    quantity = int.Parse(dr["Quantity"].ToString());
                    double price    = double.Parse(dr["Price"].ToString());

                    Oil oil = new Oil();
                    oil.OilId    = oilId;
                    oil.Title    = title;
                    oil.Quantity = quantity;
                    oil.Price    = price;

                    oils.Add(oil);
                }
            }
            catch (SqlException exp)
            {
                Console.WriteLine(exp.Message);
            }
            finally
            {
                con.Close();
            }
            return(oils);
        }
Exemplo n.º 29
0
        public static bool Update(Oil oil)
        {
            bool status = false;

            try
            {
                conString = ConfigurationManager.ConnectionStrings["constrPanditAuto"].ConnectionString;
                using (SqlConnection con = new SqlConnection(conString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    string query = "UPDATE Oils SET Quantity=@Quantity ,Price=@Price" +
                                   " WHERE OilId=@OilId";
                    SqlCommand cmd = new SqlCommand(query, con);
                    //cmd.CommandType = CommandType.;

                    cmd.Parameters.Add(new SqlParameter("@Title", oil.Title));
                    cmd.Parameters.Add(new SqlParameter("@Quantity", oil.Quantity));
                    cmd.Parameters.Add(new SqlParameter("@Price", oil.Price));
                    cmd.Parameters.Add(new SqlParameter("@OilId", oil.OilId));


                    cmd.ExecuteNonQuery();
                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                    }
                    status = true;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }

            return(status);
        }
Exemplo n.º 30
0
 public void CreateOil(double vapPress, double density, double visc)
 {
     _oil = new Oil(vapPress, density, visc);
 }