public static SelectList GetState() { List<object> sl = new List<object>(); sl.Add(new { Id = "未审核", Text = "未审核" }); sl.Add(new { Id = "已审核", Text = "已审核" }); return new SelectList(sl, "Id", "Text"); }
private static void Main() { // Generate random data to test functionality List<IShape> shapes = new List<IShape>(); for (int i = 0; i < 12; i++) { if (i < 4) { // Make Triangle IShape shape = GetShape(typeof(Triangle)); shapes.Add((Triangle)shape); } else if (i < 8) { // Make Rectangle IShape shape = GetShape(typeof(Rectangle)); shapes.Add((Rectangle)shape); } else { // Make Circle IShape shape = GetShape(typeof(Circle)); shapes.Add((Circle)shape); } } // Print result shapes.ForEach(x => Console.WriteLine(x)); }
public Uri[] GetProxyParticlesAddresses() { var uris = new List<Uri>(); if (_left != null) uris.Add(_left.Item2.Address); if (_right != null) uris.Add(_right.Item2.Address); return uris.ToArray(); }
public IEnumerable<WeatherInfo> GrabWeatherInfos(List<string> cityNames) { var weatherInfos = new List<WeatherInfo>(); foreach (var cityName in cityNames) { string city = cityName; var weatherInfo = _cache.ContainsKey(city) ? _cache[city] : _weatherInfoRepository.Get(p => p.CityName == city); if ((weatherInfo == null) || (_dateTimeProvider.UtcNow() - weatherInfo.LastUpdated) > TimeSpan.FromHours(4)) { var aggregatedWeatherInfo = _weatherWeatherServiceAggregator.Aggregate(city); if (weatherInfo != null) { aggregatedWeatherInfo.Id = weatherInfo.Id; _weatherInfoRepository.Update(aggregatedWeatherInfo); _cache[city] = aggregatedWeatherInfo; } else { _weatherInfoRepository.Save(aggregatedWeatherInfo); _cache[city] = aggregatedWeatherInfo; } weatherInfos.Add(aggregatedWeatherInfo); } else { weatherInfos.Add(weatherInfo); } } return weatherInfos; }
private static List<IAnimal> GenerateAnimals() { List<IAnimal> animals = new List<IAnimal>(); for (int i = 0; i < 20; i++) { string name = GenerateRandom.Text(GenerateRandom.Number(5, 15)); int age = GenerateRandom.Number(5, 35); if (i < 5) { Tomcat tomcat = new Tomcat(age, name); animals.Add(tomcat); } else if (i > 5 && i < 10) { Kitten kitten = new Kitten(age, name); animals.Add(kitten); } else if (i > 10 && i < 15) { Dog dog = new Dog(age, name); animals.Add(dog); } else { Frog frog = new Frog(age, name); animals.Add(frog); } } return animals; }
public static byte[] Descomprimir_Pixel(byte[] datos, byte depth) { if (depth % 8 != 0) throw new NotImplementedException("Profundidad no soportada: " + depth.ToString()); List<byte> des = new List<byte>(); for (int pos = 0; pos < datos.Length; ) { if (datos[pos] >= 0x80) { int rep = datos[pos] - 0x80 + 1; pos++; for (; rep > 0; rep--) for (int d = 0; d < (depth / 8); d++) des.Add(datos[pos]); } else { int rep = datos[pos] + 1; pos++; for (; rep > 0; rep--) for (int d = 0; d < (depth/8); d++, pos++) des.Add(datos[pos]); } pos++; } return des.ToArray(); }
static ContactsController() { contacts = new List<Contact>(); contacts.Add(new Contact{Id = "001",Name = "zhangsan",PhoneNo = "1231231",EmailAddress = "*****@*****.**",Address = "江苏苏州"}); contacts.Add(new Contact(){Id = "002",Name = "lisi",PhoneNo = "14322222222",EmailAddress = "*****@*****.**",Address = "jiangsu xuzhou"}); }
public IList<IPickListRule> GetRulesForPickList() { List<IPickListRule> testRules = new List<IPickListRule>(); testRules.Add(new SpouseRule(mFamily)); testRules.Add(new ChristmasPastRule(mArchive, mYearsBack)); return testRules; }
void SetPropertiesBytes() { var binProperties = new List<BinProperty>(); binProperties.Add(new BinProperty() { No = 0, Value = PumpStation.Delay }); binProperties.Add(new BinProperty() { No = 1, Value = PumpStation.Hold }); binProperties.Add(new BinProperty() { No = 2, Value = (ushort)PumpStation.DelayRegime }); foreach (var binProperty in binProperties) { Parameters.Add(binProperty.No); Parameters.AddRange(BitConverter.GetBytes(binProperty.Value)); Parameters.Add(0); } }
public void InvestMoney() { int numberOfInvestments = numberOfMembers; //The index doing the investing: for(int i=0 ;i < numberOfMembers; i++){ var investor = this.Members[i]; List<double> partitions = new List<double>(); //Generate N random numbers for (int j = 0; j < numberOfInvestments -1 ; j++) { partitions.Add(rand.NextDouble()); } partitions.Add(1); //Sort the numbers partitions.Sort(); //Each partition corresponds to the investment amount in order //The index getting the investment double totalPercentInvested = 0; double totalMoneyInvested = 0; for (int j = 0; j < numberOfInvestments; j++) { double percentToInvest = (partitions[j] - totalPercentInvested); var investee = this.Members[j]; investee.TakeInvestment(investor, percentToInvest * investor.GetAssets()); totalMoneyInvested += percentToInvest * investor.GetAssets() ; totalPercentInvested += percentToInvest; } //Debug.Print("Total percent invested: " + totalPercentInvested.ToString()); //Debug.Print("Total monies invested: " + totalMoneyInvested.ToString()); } }
public PartialViewResult FilterProducts(ProductFilterModel model) { List<Product> p = new WCFProduct().GetProducts().ToList(); List<ProductModel> products = new List<ProductModel>(); foreach (Product pr in p) { ProductModel pm = new ProductModel(); pm.ID = pr.ID; pm.Features = pr.Features; pm.DateListed = pr.Date_Listed; pm.Name = pr.Name; pm.Image = pr.Image; pm.Price = (double)pr.Price; pm.StockAmount = pr.Stock_Amount; pm.AverageRate = new WCFProductClient().GetProductAverageRating(pr.ID); if (model.CategoryName != null) { if (pr.Category != null && pr.Category.Contains(model.CategoryName)) { products.Add(pm); } } else if (model.ProductName != null) { if (pm.Name.Contains(model.ProductName)) { products.Add(pm); } } else if (model.smallestPrice != 0 && model.greatestPrice != 0 && model.smallestPrice != null && model.greatestPrice != null) { if (pm.Price >= model.smallestPrice && pm.Price <= model.greatestPrice) { products.Add(pm); } } else { products.Add(pm); } if (model.sortByPrice == true) { if (model.sortDescending == true) { products = products.OrderByDescending(temP => temP.Price).ToList(); } else { products = products.OrderBy(temP => temP.Price).ToList(); } } } return PartialView("_Filters", products); }
/// <summary> /// 获取路径下所有邮件 /// </summary> /// <param name="sSourcePath">路径</param> /// <returns>返回邮寄路径集合</returns> public List<string> FindFile(string sSourcePath) { List<String> list = new List<string>(); //遍历文件夹 DirectoryInfo theFolder = new DirectoryInfo(sSourcePath); FileInfo[] thefileInfo = theFolder.GetFiles("*.*", SearchOption.TopDirectoryOnly); //遍历文件 foreach (FileInfo NextFile in thefileInfo) { list.Add(NextFile.FullName); } //遍历子文件夹 DirectoryInfo[] dirInfo = theFolder.GetDirectories(); foreach (DirectoryInfo NextFolder in dirInfo) { //list.Add(NextFolder.ToString()); FileInfo[] fileInfo = NextFolder.GetFiles("*.emal", SearchOption.AllDirectories); foreach (FileInfo NextFile in fileInfo) //遍历文件 list.Add(NextFile.FullName); } return list; }
/// <summary> /// Reset alert collection for Guest /// </summary> /// <param name="message">The message.</param> /// <param name="eventType">Instance of NotificationEventType</param> public static void RetrievePerson(NotificationEvent message, NotificationEventType eventType) { List<PersonType> personTypeList = new List<PersonType>(); if (message != null && message.PersonTypeId == CommonConstants.GuestTypeId) { personTypeList.Add(PersonType.Guest); } else if (message != null && message.PersonTypeId == CommonConstants.CrewmemberTypeId) { personTypeList.Add(PersonType.Crewmember); } else if (message != null && message.PersonTypeId == CommonConstants.VisitorTypeId) { personTypeList.Add(PersonType.Visitor); } if (eventType == NotificationEventType.Reservation) { RetrieveGuestForReservation(message, eventType, personTypeList); } else { RetrieveGuest(message, eventType, personTypeList); } }
/** * 添加客户信息到数据库中 * @param List<Object> list:添加到数据库中的数据集 * @return int 值为Constant.OK:执行成功,值为Constant.ERROR为执行出错 * @author Rick **/ public int addCustomerInfo(ref List<Object> list) { Customer customer = (Customer)list[0]; Countfeeinfo countfeeinfo = (Countfeeinfo)list[1]; PriceRate priceRate = null; //在CustomerInfo表中新增signFlag项 string customerSql = "insert into CustomerInfo values('" + customer.getCustomerNo() + "', '" + customer.getCustomerName() + "', '" + customer.getIdentificationCard() + "',, '" + customer.getCustomerAddress() + "', " + customer.getLine() + ", " + customer.getArea() + ", '" + customer.getInvoiceType() + "', '" + customer.getElectriCharacterName() + "', '" + customer.getVoltageFlag() + "', '" + customer.getAmmeterType() + "', '" + customer.getAmmeterNo() + "', '" + customer.getBankCode() + "', '" + customer.getBankName() + "', '" + customer.getBankAccount() + "', '" + customer.getSignFlag() + "', '" + customer.getTradeCode() + "', '" + customer.getValueAddTaxNo() + "', " + customer.getOrganFlag() + ", " + customer.getEspecialFlag() + "," + customer.getLowProtectFlag() + "," + customer.getTranslossOrBaseprice() + ", getdate(), null, " + customer.getCustomerPosition() + ",'" + customer.getPhoneNum() + "')"; string countfeeSql = "insert into CountFeeInfo values('" + countfeeinfo.getCustomerNo() + "', " + countfeeinfo.getTransformerNo() + ", " + countfeeinfo.getAmmeterMulti() + ", null, " + countfeeinfo.getLineLoseRate() + ", 0, getDate(), " + countfeeinfo.getDiscountRate() + ")"; List<string> sqlList = new List<string>(); sqlList.Add(customerSql); sqlList.Add(countfeeSql); int nums = list.Count; while (nums > 2) { priceRate = (PriceRate)list[nums - 1]; string priceSql = "insert into PriceRate values('" + priceRate.PriceName + "'," + priceRate.PriceNo + ", " + priceRate.Rate + ", getdate())"; sqlList.Add(priceSql); nums = nums - 1; } try { SQLUtl.ExecuteSqlTran(sqlList); return Constant.OK; } catch (Exception) { return Constant.ERROR; } }
private List<CalendarItem> MergeItems(List<CalendarItem> newItems, List<CalendarItem> fromRepo) { var result = new List<CalendarItem>(); var newModels = newItems.Except(fromRepo, new CalendarItemEqualityComparer()).ToList(); var updatet = fromRepo.Except(newModels,new CalendarItemEqualityComparer()).ToList(); updatet.ForEach(x => { var model = newItems.FirstOrDefault(y => y.Id == x.Id); if (model != null) { model.SyncStatus.CalenadCalendarItemStatus = IsModified(model, x) ? CalendarItemStatus.Updated : CalendarItemStatus.Unmodified; result.Add(model); } }); var deleted = fromRepo.Where(x => x.Start.Date >= DateTime.Now.Date).Except(newItems).Except(updatet); newModels.ForEach(x => x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.New); deleted.ForEach(x => { x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.Deleted; result.Add(x); }); result.AddRange(newModels); return result.OrderBy(x => x.Start).ToList(); }
/// <summary> /// Show top 5 players. /// </summary> public override void Execute() { ScoreBoard.Instance.LoadTopPlayers(Globals.BestScoresPath); var topPlayers = ScoreBoard.Instance.ScoreBoardTable.TopPlayers; var topPlayersToList = new List<string>(); topPlayersToList.Add(Messages.BestScores); for (int i = 0; i < topPlayers.Count; i++) { if (topPlayers[i] != null && topPlayers[i].Name != Globals.NoPlayer) { topPlayersToList.Add(string.Format("{0}. {1} ---> {2}", i + 1, topPlayers[i].Name, topPlayers[i].Score)); } else { if (i == 0) { topPlayersToList.Add("No Scores"); } break; } } topPlayersToList.Add(Messages.PressAnyKeyMessage); this.UI.Print(topPlayersToList); this.UI.ReadKey(); }
public ErrorResult Delete(int RoleId, int ActionId) { string sql = "delete from Sys_RoleTemplate where RoleId=@RoleId and ActionId=@ActionId"; List<SqlParam> pars = new List<SqlParam>(); pars.Add(new SqlParam("RoleId", RoleId)); pars.Add(new SqlParam("ActionId", ActionId)); return new Helper().Delete(sql, pars); }
public ErrorResult Delete(int userId, int roleId) { string sql = "delete from Sys_UserRole where UserId=@UserId and RoleId=@RoleId"; List<SqlParam> pars = new List<SqlParam>(); pars.Add(new SqlParam("UserId", userId)); pars.Add(new SqlParam("RoleId", roleId)); return new Helper().Delete(sql, pars); }
public List<SysTemplateViewModel> GetViewlListByType(int Type, int ParentId) { string sql = "select a.*,(select Template from Sys_Template where Id=a.ParentId) as ParentName from Sys_Template a where Type=@Type and ParentId=@ParentId"; List<SqlParam> pars = new List<SqlParam>(); pars.Add(new SqlParam("Type", Type)); pars.Add(new SqlParam("ParentId", ParentId)); return new Helper().ExecuteList<SysTemplateViewModel>(sql, pars); }
public ActionResult AddGroup(Web_UserGroup model) { ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm); try { string t = Request["FunctionId"].ToString();//获取选中的分类ID格式为("1,2,3”)不包含括号。 List<Int32> idlist = new List<int>(); if (!string.IsNullOrEmpty(t)) { if (t.Contains(",")) { foreach (var each in t.Split(',').ToList()) { idlist.Add(Convert.ToInt32(each)); } } else { idlist.Add(Convert.ToInt32(t)); } } IEnumerable<Web_Sys_Function> selectedFuncs = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm).Where(p => idlist.Contains(p.ID)); if (model.Group_ID == 0) //New { model.Web_Sys_Functions = selectedFuncs.ToList(); //model.Web_Sys_Functions = new List<Web_Sys_Function>(); //selectedFuncs.ToList().ForEach(f => model.Web_Sys_Functions.Add(f)); groupBLL.AddNew(model, dbParm); } else //Edit { List<Web_Sys_Function> originalFuncs = groupBLL.Get(model.Group_ID, dbParm).Web_Sys_Functions; model.Web_Sys_Functions = originalFuncs; //要删除的function var dlist = originalFuncs.Where(p => !selectedFuncs.Contains(p)).ToList(); //要添加的function var alist = selectedFuncs.Where(p => !originalFuncs.Contains(p)).ToList(); foreach (var item in dlist) { model.Web_Sys_Functions.Remove(item); } foreach (var item in alist) { model.Web_Sys_Functions.Add(item); } groupBLL.Update(model, dbParm); } ViewBag.ALLFunctions = new Web_Sys_FunctionBLL().GetAllFunctions(dbParm); return null; //return View(); } catch (Exception ex) { var y = ex.InnerException; return View(model); } }
private static string[] GetProgramTypes(string types) { var list = new List<string>(); if (types.Contains("one-to-one", true)) list.Add("1"); if (types.Contains("group", true)) list.Add("2"); //if (types.Contains("peer to peer")) list.Add(""); if (types.Contains("e-mentoring", true)) list.Add("5"); return list.ToArray(); }
public object Get (DtoHash req) { Tuple<Status, string> tuple = Scheduler.GetStatus (req.id); List<string> list = new List<string> (); list.Add (tuple.Item1.ToString ()); list.Add(tuple.Item2); return new DtoHashStatusResponse (list); }
public RegistrationModel() { List<bool> myList = new List<bool>(); myList.Add(true); myList.Add(false); roles = new List<Role>(new UserAccountClient().GetAllRoles()); townList = new SelectList(new UserAccountClient().GetAllTowns(), "ID", "Name"); }
public MonitoringUSB(Device usbDevice) { USBDevice = usbDevice; MonitoringPanels = new List<MonitoringPanel>(); MonitoringNonPanels = new List<MonitoringNonPanel>(); if (!usbDevice.IsParentMonitoringDisabled) { switch (usbDevice.Driver.DriverType) { case DriverType.MS_1: case DriverType.MS_2: foreach (var channelChild in usbDevice.Children) { foreach (var panelDevice in channelChild.Children) { if (!panelDevice.IsParentMonitoringDisabled) { switch (panelDevice.Driver.DriverType) { case DriverType.Rubezh_2AM: case DriverType.Rubezh_2OP: case DriverType.Rubezh_4A: case DriverType.BUNS: case DriverType.Rubezh_P: MonitoringPanels.Add(new MonitoringPanel(panelDevice)); break; case DriverType.IndicationBlock: case DriverType.PDU: case DriverType.PDU_PT: //case DriverType.UOO_TL: case DriverType.MS_3: case DriverType.MS_4: MonitoringNonPanels.Add(new MonitoringNonPanel(panelDevice)); break; } } } } break; case DriverType.USB_Rubezh_2AM: case DriverType.USB_Rubezh_2OP: case DriverType.USB_Rubezh_4A: case DriverType.USB_Rubezh_P: case DriverType.USB_BUNS: MonitoringPanels.Add(new MonitoringPanel(usbDevice)); break; } } USBManager.NewResponse += new Action<Device, Response>(UsbRunner_NewResponse); USBManager.UsbRemoved += new Action(monitoringPanel_ConnectionChanged); //foreach (var monitoringPanel in MonitoringPanels) //{ // monitoringPanel.ConnectionChanged += new Action(monitoringPanel_ConnectionChanged); //} }
public void Initialize() { IsNowPlaying = false; Sounds = new SortableObservableCollection<SoundViewModel>(); var stateClasses = new List<Tuple<XStateClass, SoundType>>(); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Fire1)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire2, SoundType.Fire2)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Attention, SoundType.Attention)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Alarm)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Failure, SoundType.Failure)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Off, SoundType.Off)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOn, SoundType.TurningOn)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOff, SoundType.StopStart)); stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.AutoOff, SoundType.AutoOff)); foreach (var stateClass in stateClasses) { var newSound = new Sound() { StateClass = stateClass.Item1, Type = stateClass.Item2 }; var sound = ClientManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.Type == stateClass.Item2); if (sound == null) ClientManager.SystemConfiguration.Sounds.Add(newSound); else newSound = sound; Sounds.Add(new SoundViewModel(newSound)); } Sounds.Sort(x => EnumHelper.GetEnumDescription(x.SoundType)); SelectedSound = Sounds.FirstOrDefault(); if (ClientManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.SoundType == x.Type)) > 0) ServiceFactory.SaveService.SoundsChanged = true; }
public List<PieResponse> GetAllExercisesForGraph(string graphType) { var returnData = new List<PieResponse>(); DataAccess.DataAccess da = new DataAccess.DataAccess(); var returnList = da.GetExerciseCollection(); var totalCount = returnList.Count; var nalCount = returnList.Where(x => x.type == "n/a").ToList<Exercise>().Count; totalCount = totalCount - nalCount; //todo: tv move this list to database List<string> mylist = new List<string>(); mylist.Add("chest"); mylist.Add("back"); mylist.Add("tricep"); mylist.Add("cardio"); mylist.Add("legs"); mylist.Add("bicep"); mylist.Add("abs"); mylist.Add("Shoulders"); mylist.Add("n/a"); var val = 0; foreach (var prop in mylist) { if (!prop.Equals("n/a")) { val = returnList.Where(x => x.type == prop).ToList<Exercise>().Count; var stringValue = (Convert.ToDecimal(val) / Convert.ToDecimal(totalCount))* 100; returnData.Add(new PieResponse(prop, stringValue)); } } return returnData; }
/// <summary>Uses Ruffini's rule</summary> public PolynomialEq EliminateRootNoRemainder(double root) { List<double> tempList = new List<double>(coefficients.Count); List<double> newCoef = new List<double>(coefficients.Count); //last guy is the remainder newCoef.Add(coefficients[0]); for (int i = 1; i < coefficients.Count - 1; i++) { tempList.Add( newCoef.Last()* root); newCoef.Add(coefficients[i] + tempList.Last()); } return new PolynomialEq(newCoef.ToArray()); }
public Solution WorstCase() { depthCounter++; List<int> localDropHeights = new List<int>(); int worstCaseToReturn = int.MinValue; if (hashedSolutions.ContainsKey(state())) { var drop = hashedSolutions[state()]; localDropHeights.AddRange(drop.DropHeights); worstCaseToReturn = drop.WorstCase; } if (N == 1) { worstCaseToReturn = 0; } if (N == 2) { worstCaseToReturn = 2; localDropHeights.Add(1); } if (M == 1) { worstCaseToReturn = N + 1; for (int i = 1; i < N + 1; i++) localDropHeights.Add(i); } if (worstCaseToReturn == int.MinValue) { int bestWorstCaseDrops = int.MaxValue; int bestWorstCaseFloor = 0; for (int dropFloor = 1; dropFloor < N / 2 + 1; dropFloor++) { var breakScenario = new CurrentState(M - 1, dropFloor).WorstCase(); int breakScenarioTrials = breakScenario.WorstCase + 2; var surviveScenario = new CurrentState(M, N - dropFloor).WorstCase(); int surviveScenarioTrials = breakScenario.WorstCase + 1; int temp = 0; if (breakScenarioTrials < surviveScenarioTrials) { temp = surviveScenarioTrials; localDropHeights.AddRange(surviveScenario.DropHeights); } else { temp = breakScenarioTrials; localDropHeights.AddRange(breakScenario.DropHeights); } if (temp < bestWorstCaseDrops) { bestWorstCaseDrops = temp; bestWorstCaseFloor = dropFloor; } } localDropHeights.Add(bestWorstCaseFloor); hashedSolutions.Add(state(), new Solution(bestWorstCaseDrops, localDropHeights)); worstCaseToReturn = bestWorstCaseDrops; } if (depthCounter-- == 1) GlobalDropHeights.AddRange(localDropHeights); if (worstCaseToReturn == int.MinValue || worstCaseToReturn == int.MaxValue) throw new Exception(); return new Solution(worstCaseToReturn, localDropHeights); }
private static void Main() { List<ICustomer> customers = new List<ICustomer>(); customers.Add(new Individual(1, "Ivan Ivanov", "Address", "123123123", "Bulgaria", "Sofia", "1231231231")); customers.Add(new Company(2, "Ivan Ivanov Company", "Address Company", "123123123", "Bulgaria", "Sofia", "123123123")); Console.WriteLine("Customers:"); customers.ForEach(x => Console.WriteLine(x)); List<IAccount> accounts = new List<IAccount>(); // Individuals accounts.Add(new Loan(1, customers[0], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); accounts.Add(new Mortgage(2, customers[0], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); accounts.Add(new Deposit(3, customers[0], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); //// Company accounts.Add(new Loan(4, customers[1], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); accounts.Add(new Mortgage(5, customers[1], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); accounts.Add(new Deposit(6, customers[1], DateTime.Now.AddDays(GenerateRandom.Number(1, 365) * -1))); Console.WriteLine("\nInitial accounts"); accounts.ForEach(x => Console.WriteLine(x)); // Set some random money and interest rate SeedMoney(accounts); // Bank Bank bank = new Bank("Big Bank", "Bank address"); AddAccountsToBank(bank, accounts); // Calculate interest rate foreach (var account in bank.Accounts) { Console.WriteLine("Balance: {0}, Interrest Rate: {1}, Calculate Interest: {2}", account.Balance, account.InterestRate, account.CalculateInterest()); } // Deposit foreach (var account in bank.Accounts) { account.Deposit(GenerateRandom.Number(100, 1000)); } ShowBank(bank); Console.WriteLine("\nDraw:"); foreach (var account in bank.Accounts) { account.Draw(GenerateRandom.Number(100, 1000)); } ShowBank(bank); }
public static void SendControlCommandMRO(XBase xBase, byte code, byte code2) { var bytes = new List<byte>(); var databaseNo = xBase.GKDescriptorNo; bytes.AddRange(BytesHelper.ShortToBytes(databaseNo)); bytes.Add(code); bytes.Add(code2); if (xBase.GkDatabaseParent != null) { WatcherManager.Send(OnCompleted, xBase.GkDatabaseParent, 3, 13, 0, bytes); } }