예제 #1
0
        public List <Transmissions> GetAllTransmissions()
        {
            List <Transmissions> transmissions = new List <Transmissions>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("TransmissionsSelectAll", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        Transmissions currentRow = new Transmissions();
                        currentRow.TransmissionId          = (int)dr["TransmissionId"];
                        currentRow.TransmissionDescription = dr["TransmissionDescription"].ToString();

                        transmissions.Add(currentRow);
                    }
                }
            }
            return(transmissions);
        }
        public async Task <IActionResult> Edit(int id, [Bind("TransmissionId,Trasmission")] Transmissions transmissions)
        {
            if (id != transmissions.TransmissionId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(transmissions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TransmissionsExists(transmissions.TransmissionId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(transmissions));
        }
예제 #3
0
 public Client(string apiKey, string apiHost = "https://api.sparkpost.com")
 {
     ApiKey        = apiKey;
     ApiHost       = apiHost;
     Transmissions = new Transmissions(this, new RequestSender(this), new DataMapper(Version));
     Suppressions  = new Suppressions(this, new RequestSender(this), new DataMapper());
 }
        public async Task <IActionResult> Create([Bind("TransmissionId,Trasmission")] Transmissions transmissions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(transmissions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(transmissions));
        }
예제 #5
0
 public void SetTransmissions(IEnumerable <LookupValue> transmissions)
 {
     foreach (var t in transmissions)
     {
         Transmissions.Add(new SelectListItem()
         {
             Value = t.Description.ToString(),
             Text  = t.Description.ToString()
         });
     }
 }
예제 #6
0
 public void SetTransmissions(IEnumerable <TransmissionModel> transmissions)
 {
     foreach (var transmission in transmissions)
     {
         Transmissions.Add(new SelectListItem()
         {
             Value = transmission.Transmission,
             Text  = transmission.Transmission
         });
     }
 }
예제 #7
0
 public Championship(string name, EngineLayouts allowedLayouts, int maxDisplacement, Fuels allowedFuels,
                     bool allowSupercharged, Transmissions allowedTransmissions, Drives allowedDrives, int maxNumberOfSeats, int minWight)
 {
     this.Name = name;
     this.AllowedEngineLayouts      = allowedLayouts;
     this.MaximumEngineDisplacement = maxDisplacement;
     this.AllowedFuels = allowedFuels;
     this.AllowedEngineSupercharged = allowSupercharged;
     this.AllowedTransmissions      = allowedTransmissions;
     this.AllowedDrives             = allowedDrives;
     this.MinimumNumberOfSeats      = maxNumberOfSeats;
     this.MinimumVehicleWeight      = minWight;
 }
예제 #8
0
        public int ProcessData()
        {
            int ret = SetDecryptor(decrypto.dll);

            if (ret != 0)
            {
                return(ret);
            }
            if (decrypto.format.Equals("json"))
            {
                var    output      = new IntPtr();
                var    output_size = 0;
                string sender      = "";
                reader = new JSONLogWriter();
                reader.Open(decrypto.input, "r");
                Transmissions trans = reader.ReadTransmission();
                foreach (LogEvent e in trans.LogEventList)
                {
                    try
                    {
                        if (e.sender == CLIENT)
                        {
                            sender = "client";
                        }
                        else
                        {
                            sender = "server";
                        }
                        Console.WriteLine("sender: {0} packet: {1} length: {2}", sender, e.count, e.data.Length);
                        Decrypt.Decrypt(e.sender, e.data, e.data.Length, e.count, ref output, ref output_size);
                        byte[] decrypted = new byte[output_size];
                        Marshal.Copy(output, decrypted, 0, output_size);
                        Console.WriteLine("\nAfter decrypt: {0}", Encoding.ASCII.GetString(decrypted));
                        Console.WriteLine("--------------------------------------");
                        if (writer != null)
                        {
                            writer.LogTransmission(decrypted, sender, e.count);
                        }
                    }
                    finally
                    {
                        if (output != IntPtr.Zero)
                        {
                            Marshal.FreeCoTaskMem(output);
                        }
                    }
                }
            }

            return(0);
        }
예제 #9
0
        public void EditVechicle(VechicleViewModel vechicle)
        {
            var editVehicle = Inventorys.Include("Mdles").Include("Typs").Include("BodyStyles")
                              .Include("Transmissions").Include("Colors").Include("Interiors")
                              .Include("PurchaseTypes").FirstOrDefault(p => p.Id == vechicle.InventoryId);

            editVehicle.Id           = vechicle.InventoryId;
            editVehicle.Mdles.MakeId = Makes.FirstOrDefault(p => p.MakeName == vechicle.Make).MakeId;
            editVehicle.MdleId       = Models.FirstOrDefault(p => p.ModelName == vechicle.Model).MdleId;

            editVehicle.BodyStyleId    = BodyStyles.FirstOrDefault(p => p.BodyStyleName == vechicle.BodyStyle).BodyStyleId;
            editVehicle.ColorId        = Colors.SingleOrDefault(p => p.ColorName == vechicle.Color).ColorId;
            editVehicle.TypId          = Typs.SingleOrDefault(p => p.TypeName == vechicle.Type).TypId;
            editVehicle.Year           = vechicle.Year;
            editVehicle.TransmissionId = Transmissions.SingleOrDefault(p => p.TransmissionName == vechicle.Transmission).TransmissionId;
            editVehicle.InteriorId     = Interiors.FirstOrDefault(p => p.InteriorName == vechicle.Interior).InteriorId;
            editVehicle.Mileage        = vechicle.Mileage;
            editVehicle.VIN            = vechicle.VIN;
            editVehicle.MSRP           = vechicle.MSRP;
            editVehicle.SalesPrice     = vechicle.SalesPrice;
            editVehicle.Description    = vechicle.Description;

            editVehicle.FeatureVehicle = vechicle.FeatureVehicle;
            if (editVehicle.Picture != null)
            {
                var    oldFile = editVehicle.Picture;
                string path    = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                              Path.GetFileName(oldFile));
                File.Delete(path);
            }

            if (vechicle.File != null && vechicle.File.ContentLength > 0)
            {
                string[] fileName = vechicle.File.FileName.Split('.');
                string   newName  = "inventory-" + editVehicle.Id + "." + fileName.Last();


                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                           Path.GetFileName(newName));

                vechicle.File.SaveAs(path);
                editVehicle.Picture = newName;
            }



            (this).SaveChanges();
        }
예제 #10
0
        private PowerThreadNode GetNextNode(PowerThreadContext context, PowerThreadNode fromNode)
        {
            var transmission = Transmissions.FirstOrDefault(p => p.FromNode.ObjectId == fromNode.ObjectId);

            if (transmission == null)
            {
                return(PowerThreadDefaultNodes.DefaultEndNode);
            }

            foreach (var item in transmission.ConditionBranches)
            {
                if (item.Condition.IsSatisified(context))
                {
                    return(item.ToNode);
                }
            }

            //
            return(PowerThreadDefaultNodes.MissFoundNode);
        }
예제 #11
0
 public Transmission GetTransmissionsById(int id)
 {
     return(Transmissions.Where(i => i.TransmissionId == id).FirstOrDefault());
 }
예제 #12
0
 public Transmission GetTransmission(int id) => Transmissions.Single(t => t.Id == id);
예제 #13
0
 public List <Transmission> GetAllTransmissions() => Transmissions.ToList();
    public void SetTransmission(Transmissions transmission)
    {
        foreach (Wheel w in axles.allWheels)
        {
            w.lockingTorqueImpulse = 0;
            w.drivetrainInertia    = 0;
            w.isPowered            = false;
        }
        if (transmission == Transmissions.FWD)
        {
            foreach (Wheel w in axles.frontAxle.wheels)
            {
                w.isPowered = true;
            }
            poweredWheels           = axles.frontAxle.wheels;
            axles.frontAxle.powered = true;
            axles.rearAxle.powered  = false;
            foreach (Axle axle in axles.otherAxles)
            {
                axle.powered = false;
            }
        }
        else if (transmission == Transmissions.RWD)
        {
            foreach (Wheel w in axles.rearAxle.wheels)
            {
                w.isPowered = true;
            }
            poweredWheels           = axles.rearAxle.wheels;
            axles.frontAxle.powered = false;
            axles.rearAxle.powered  = true;
            foreach (Axle axle in axles.otherAxles)
            {
                axle.powered = false;
            }
        }
        else if (transmission == Transmissions.XWD)
        {
            List <Wheel> wheelsList = new List <Wheel>();
            if (axles.frontAxle.powered == true)
            {
                foreach (Wheel w in axles.frontAxle.wheels)
                {
                    w.isPowered = true;
                    wheelsList.Add(w);
                }
            }
            if (axles.rearAxle.powered == true)
            {
                foreach (Wheel w in axles.rearAxle.wheels)
                {
                    w.isPowered = true;
                    wheelsList.Add(w);
                }
            }
            foreach (Axle axle in axles.otherAxles)
            {
                if (axle.powered == true)
                {
                    foreach (Wheel w in axle.wheels)
                    {
                        w.isPowered = true;
                        wheelsList.Add(w);
                    }
                }
            }
            poweredWheels = wheelsList.ToArray();          //new Wheel[axles.frontAxle.wheels.Length + axles.rearAxle.wheels.Length + OtherAxlesWheels.Length];
            //axles.frontAxle.wheels.CopyTo(poweredWheels, 0);
            //axles.rearAxle.wheels.CopyTo(poweredWheels, axles.frontAxle.wheels.Length);
            //OtherAxlesWheels.CopyTo(poweredWheels, axles.rearAxle.wheels.Length);
        }
        else if (transmission == Transmissions.AWD)
        {
            foreach (Wheel w in axles.allWheels)
            {
                w.isPowered = true;
            }
            poweredWheels           = axles.allWheels;
            axles.frontAxle.powered = true;
            axles.rearAxle.powered  = true;
            foreach (Axle axle in axles.otherAxles)
            {
                axle.powered = true;
            }
        }

        drivetrainFraction = 1f / poweredWheels.Length;
    }
예제 #15
0
	public void SetTransmission(Transmissions transmission){
		foreach(Wheel w in axles.allWheels){
			w.lockingTorqueImpulse=0;
			w.drivetrainInertia=0;
			w.isPowered=false;
		}
		if (transmission==Transmissions.FWD){
			foreach(Wheel w in axles.frontAxle.wheels){
				w.isPowered=true;
			}
			poweredWheels=axles.frontAxle.wheels;
			axles.frontAxle.powered=true;
			axles.rearAxle.powered=false;
			foreach(Axle axle in axles.otherAxles){
				axle.powered=false;
			}
		}
		else if (transmission==Transmissions.RWD){
			foreach(Wheel w in axles.rearAxle.wheels){
				w.isPowered=true;
			}
			poweredWheels=axles.rearAxle.wheels;
			axles.frontAxle.powered=false;
			axles.rearAxle.powered=true;
			foreach(Axle axle in axles.otherAxles){
				axle.powered=false;
			}
		}
		else if (transmission==Transmissions.XWD){
			List<Wheel> wheelsList = new List<Wheel>();
			if (axles.frontAxle.powered==true){
				foreach(Wheel w in axles.frontAxle.wheels){
					w.isPowered=true;
					wheelsList.Add(w);
				}
			}
			if (axles.rearAxle.powered==true){
				foreach(Wheel w in axles.rearAxle.wheels){
					w.isPowered=true;
					wheelsList.Add(w);
				}
			}			
			foreach(Axle axle in axles.otherAxles){
				if (axle.powered==true){
					foreach(Wheel w in axle.wheels){
						w.isPowered=true;
						wheelsList.Add(w);
					}
				}
			}
			poweredWheels=wheelsList.ToArray();//new Wheel[axles.frontAxle.wheels.Length + axles.rearAxle.wheels.Length + OtherAxlesWheels.Length];
			//axles.frontAxle.wheels.CopyTo(poweredWheels, 0);
			//axles.rearAxle.wheels.CopyTo(poweredWheels, axles.frontAxle.wheels.Length);
			//OtherAxlesWheels.CopyTo(poweredWheels, axles.rearAxle.wheels.Length);
		}
		else if (transmission==Transmissions.AWD){
			foreach(Wheel w in axles.allWheels){
				w.isPowered=true;
			}				
			poweredWheels=axles.allWheels;
			axles.frontAxle.powered=true;
			axles.rearAxle.powered=true;
			foreach(Axle axle in axles.otherAxles){
				axle.powered=true;
			}			
		}
		
		drivetrainFraction = 1f/poweredWheels.Length;
	}
예제 #16
0
        /// <summary>
        /// This method adds the default SCS Transmissions to the database
        /// </summary>
        private void AddTransmissionData()
        {
            // == Add Transmission Series
            TransmissionSeries.Add(new TransmissionSeries()
            {
                Name = "SCS Eaton Fuller"
            });
            TransmissionSeries.Add(new TransmissionSeries()
            {
                Name = "SCS Allison 4500"
            });

            #region Add Default Data

            // == Eaton Fuller 10-speed
            var transmission = default(Transmission);
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "10_speed",
                Name              = "Eaton Fuller 10-speed",
                Price             = 8750,
                Unlock            = 0,
                DifferentialRatio = 2.85m
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -18.18m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -3.89m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = 15.42m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 11.52m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 8.55m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 6.28m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 4.67m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 3.3m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 2.46m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 1.83m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 1.34m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 1m
            }
                );

            // == Eaton Fuller 10-speed Retarder
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "10_speed_r",
                Name              = "Eaton Fuller 10-speed Retarder",
                Price             = 10220,
                Unlock            = 2,
                DifferentialRatio = 2.85m,
                Retarder          = 3,
                FileName          = "10_speed_retarder"
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -18.18m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -3.89m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = 15.42m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 11.52m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 8.55m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 6.28m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 4.67m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 3.3m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 2.46m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 1.83m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 1.34m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 1m
            }
                );

            // == Eaton Fuller 13-speed
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "13_speed",
                Name              = "Eaton Fuller 13-speed",
                Price             = 9510,
                Unlock            = 4,
                DifferentialRatio = 3.55m
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -15.06m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -12.85m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = -4.03m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 12.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 8.51m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 6.05m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 4.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 3.2m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 2.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 1.95m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 1.62m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 1.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 12, Ratio = 1.17m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 13, Ratio = 1m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 14, Ratio = 0.86m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 15, Ratio = 0.73m
            }
                );

            // == Eaton Fuller 13-speed Retarder
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "13_speed_r",
                Name              = "Eaton Fuller 13-speed Retarder",
                Price             = 12830,
                Unlock            = 6,
                DifferentialRatio = 3.55m,
                Retarder          = 3,
                FileName          = "13_speed_retarder"
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -15.06m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -12.85m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = -4.03m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 12.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 8.51m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 6.05m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 4.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 3.2m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 2.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 1.95m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 1.62m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 1.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 12, Ratio = 1.17m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 13, Ratio = 1m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 14, Ratio = 0.86m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 15, Ratio = 0.73m
            }
                );

            // == Eaton Fuller 18-speed
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "18_speed",
                Name              = "Eaton Fuller 18-speed",
                Price             = 11120,
                Unlock            = 9,
                DifferentialRatio = 3.25m
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -15.06m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -12.85m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = -4.03m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = -3.43m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 14.40m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 12.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 8.51m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 7.26m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 6.05m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 5.16m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 4.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 3.74m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 12, Ratio = 3.2m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 13, Ratio = 2.73m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 14, Ratio = 2.28m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 15, Ratio = 1.94m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 16, Ratio = 1.62m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 17, Ratio = 1.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 18, Ratio = 1.17m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 19, Ratio = 1.0m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 20, Ratio = 0.86m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 21, Ratio = 0.73m
            }
                );

            // == Eaton Fuller 18-speed Retarder
            transmission = new Transmission()
            {
                SeriesId          = 1,
                UnitName          = "18_speed_r",
                Name              = "Eaton Fuller 18-speed",
                Price             = 14250,
                Unlock            = 12,
                DifferentialRatio = 3.25m,
                Retarder          = 3,
                FileName          = "18_speed_retarder"
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -15.06m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = -12.85m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = -4.03m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = -3.43m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 14.40m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 12.29m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 8.51m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 7, Ratio = 7.26m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 8, Ratio = 6.05m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 9, Ratio = 5.16m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 10, Ratio = 4.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 11, Ratio = 3.74m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 12, Ratio = 3.2m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 13, Ratio = 2.73m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 14, Ratio = 2.28m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 15, Ratio = 1.94m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 16, Ratio = 1.62m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 17, Ratio = 1.38m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 18, Ratio = 1.17m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 19, Ratio = 1.0m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 20, Ratio = 0.86m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 21, Ratio = 0.73m
            }
                );

            // == Allison 4500 6 Speed
            transmission = new Transmission()
            {
                SeriesId          = 2,
                UnitName          = "allison",
                Name              = "Allison 4500 6-speed",
                Price             = 12430,
                Unlock            = 14,
                DifferentialRatio = 3.7m,
                StallTorqueRatio  = 2.42m
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -5.55m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = 4.7m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = 2.21m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 1.53m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 1.0m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 0.76m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 0.67m
            }
                );

            // == Allison 4500 6 Speed Retarder
            transmission = new Transmission()
            {
                SeriesId          = 2,
                UnitName          = "allison_r",
                Name              = "Allison 4500 6-speed Retarder",
                Price             = 15577,
                Unlock            = 18,
                DifferentialRatio = 3.7m,
                StallTorqueRatio  = 2.42m,
                Retarder          = 3,
                FileName          = "allison_retarder"
            };
            Transmissions.Add(transmission);

            // Create Gears
            TransmissionGears.AddRange(
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 0, Ratio = -5.55m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 1, Ratio = 4.7m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 2, Ratio = 2.21m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 3, Ratio = 1.53m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 4, Ratio = 1.0m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 5, Ratio = 0.76m
            },
                new TransmissionGear()
            {
                Transmission = transmission, GearIndex = 6, Ratio = 0.67m
            }
                );

            #endregion
        }
예제 #17
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            var dbhost = Environment.GetEnvironmentVariable("DBHOST");

            if (string.IsNullOrEmpty(dbhost))
            {
                dbhost = "localhost";
            }
            var dbname = Environment.GetEnvironmentVariable("DBNAME");

            if (string.IsNullOrEmpty(dbname))
            {
                dbname = "socomap";
            }
            var dbuser = Environment.GetEnvironmentVariable("DBUSER");

            if (string.IsNullOrEmpty(dbuser))
            {
                dbuser = "******";
            }
            var dbpass = Environment.GetEnvironmentVariable("DBPASS");

            if (string.IsNullOrEmpty(dbpass))
            {
                dbpass = "******";
            }
            var connection = $"Host={dbhost}; Database={dbname}; Username={dbuser}; Password={dbpass};";

            services.AddDbContext <TransmissionContext>(options => options.UseNpgsql(connection, b => b.MigrationsAssembly("Socomap")));

            {
                var optionsBuilder      = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap"));
                var transmissionContext = new TransmissionContext(optionsBuilder.Options);
                var pendingMigrations   = transmissionContext.Database.GetPendingMigrations();
                if (pendingMigrations != null && pendingMigrations.Any())
                {
                    transmissionContext.Database.Migrate();
                }
            }

            services.AddTransient <IInboxAdapter, InboxAdapter>((IServiceProvider serviceProvider) =>
            {
                var optionsBuilder      = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap"));
                var transmissionContext = new TransmissionContext(optionsBuilder.Options);
                var inboxes             = new Inboxes(transmissionContext);
                var transmissions       = new Transmissions(transmissionContext, inboxes);
                return(new InboxAdapter(inboxes, transmissions));
            });
            services.AddTransient <ITransferAdapter, TransferAdapter>((IServiceProvider serviceProvider) =>
            {
                var optionsBuilder      = NpgsqlDbContextOptionsExtensions.UseNpgsql(new DbContextOptionsBuilder <TransmissionContext>(), connection, b => b.MigrationsAssembly("Socomap"));
                var transmissionContext = new TransmissionContext(optionsBuilder.Options);
                var inboxes             = new Inboxes(transmissionContext);
                var transmissions       = new Transmissions(transmissionContext, inboxes);
                return(new TransferAdapter(inboxes, transmissions));
            }
                                                                      );

            // Setup the database.

            // Add framework services.
            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
            .AddJsonOptions(opts =>
            {
                opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                opts.SerializerSettings.Converters.Add(new StringEnumConverter
                {
                    CamelCaseText = true
                });
            });

            services
            .AddSwaggerGen(c =>
            {
                c.SwaggerDoc("0.0.1", new Info
                {
                    Version     = "0.0.1",
                    Title       = "SOCOMAP",
                    Description = "SOCOMAP (ASP.NET Core 2.2)",
                    Contact     = new Contact()
                    {
                        Name  = "Infotech GmbH",
                        Url   = "http://www.infotech.de",
                        Email = "*****@*****.**"
                    },
                    TermsOfService = "http://www.infotech.de"
                });
                c.CustomSchemaIds(type => type.FriendlyId(true));
                c.DescribeAllEnumsAsStrings();
                c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetEntryAssembly().GetName().Name}.xml");
                // Sets the basePath property in the Swagger document generated
                c.DocumentFilter <BasePathFilter>("/v1");

                // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..)
                // Use [ValidateModelState] on Actions to actually validate it in C# as well!
                c.OperationFilter <GeneratePathParamsValidationFilter>();
            });
        }
예제 #18
0
파일: Program.cs 프로젝트: idkwim/UDPDP
        static void Main(string[] args)
        {
            bool show_help                = false;
            DecryptFileProcessor dfp      = null;
            DecryptOptions       decrypto = new DecryptOptions();
            var p = new OptionSet()
            {
                { "d|dll=",
                  "dll to be used to decrypt packets, must export decrypt() and init() functions.",
                  v => decrypto.dll = v },
                { "i|input=",
                  "logfile where raw data was captured.",
                  v => decrypto.input = v },
                { "f|format=",
                  "logfile format for how the data was captured.",
                  v => decrypto.format = v },
                { "o|output=",
                  "Where to store the decrypted output.",
                  v => decrypto.output = v },
                { "of|outputformat=",
                  "Output format (json|asciibin).",
                  v => decrypto.outputformat = v },
                { "h|?|help", "show this message and exit",
                  v => show_help = v != null },
            };

            p.Parse(args);
            if (show_help)
            {
                ShowHelp(p, null);
            }

            if (decrypto.input == null)
            {
                ShowHelp(p, "input is required.");
            }
            else if (decrypto.output == null)
            {
                ShowHelp(p, "output is required.");
            }
            else if (decrypto.format == null)
            {
                ShowHelp(p, "format is required.");
            }

            if (decrypto.dll != null)
            {
                dfp = new DecryptFileProcessor(decrypto);
                dfp.ProcessData();
            }
            else
            {
                IULogWriter logger = null;
                if (decrypto.format.Equals("json"))
                {
                    logger = new JSONLogWriter();
                    logger.Open(decrypto.input, "r");
                    Transmissions trans = logger.ReadTransmission();
                    foreach (LogEvent e in trans.LogEventList)
                    {
                        Console.WriteLine("{0} {1} {2}", e.sender, e.count, Encoding.ASCII.GetString(e.data));
                    }
                }
            }
        }