public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; var configs = scope.ServiceProvider.GetRequiredService <IConfiguration>(); InitializeService.InitializeAsync(services).Wait(); ConfigureService.SetConfigis(configs); } host.Run(); }
public StatisticModel() { const string path = @"..\车辆基本信息表.csv"; CarDetails = new List <CarDetail>(); var lists = FileService.ReadFromFile(path); CarDetails = InitializeService.InitializeCarDetail(lists); sta = new List <CarStatic>(); Dictionary <string, CarStatic> dic = new Dictionary <string, CarStatic>(); foreach (var item in CarDetails) { if (dic.ContainsKey(item.CarType)) { ++dic[item.CarType].Total; if (item.State == "y") { ++dic[item.CarType].rent; } else { ++dic[item.CarType].free; } } else { int onrent = item.State == "y" ? 1 : 0; dic.Add(item.CarType, new CarStatic { Type = item.CarType, Total = 1, rent = onrent, free = 1 - onrent }); } } foreach (var item in dic) { sta.Add(item.Value); } }
/// <summary> /// Handles the Startup event of the Application control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="StartupEventArgs"/> instance containing the event data.</param> private void Application_Startup(object sender, StartupEventArgs e) { InitializeService.InitializeConnectionStrings(true); if (e.Args.Length > 0) { try { ManageSchedulers.StartScheduler(e.Args); } catch (System.Exception exception) { Logger.LogMessage(exception.Message, "StartUp", LogType.Error, exception); } CloseApp(); } else { Current.DispatcherUnhandledException += AppDispatcherUnhandledException; var homeView = new Home(); homeView.Show(); homeView.Closed += HomeView_Closed; } }
public ReservationEdit(Reservation reservation) { InitializeComponent(); InitializeComboBox_Clients(); InitializeComboxBox_Arrangement(); InitializeComboxBox_StartLocation(); InitializeComboxBox_EndLocation(); InitializeAvailbaleCars(); InitializeService.InitializeSelection(FromTime); InitializeService.InitializeSelection(UntilTime); this.Title = this.Title.ToString().Replace("{id}", reservation.ID + ""); Type = reservation.Arrangement; From = reservation.ReservationDate; Until = reservation.ReservedUntil; RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); client = manager.GetClient(reservation.ClientID); reservationCars = manager.GetReservationCars(reservation.ID); Client.SelectedIndex = manager.GetAllClients().IndexOf(client); Arrangement.SelectedIndex = Arrangement.Items.IndexOf(char.ToUpper(reservation.Arrangement.ToString().ToLower()[0]) + reservation.Arrangement.ToString().ToLower().Substring(1)); StartLocation.SelectedIndex = StartLocation.Items.IndexOf(char.ToUpper(reservation.StartLocation.ToLower()[0]) + reservation.StartLocation.ToLower().Substring(1)); EndLocation.SelectedIndex = EndLocation.Items.IndexOf(char.ToUpper(reservation.EndLocation.ToLower()[0]) + reservation.EndLocation.ToLower().Substring(1)); FromTime.SelectedIndex = FromTime.Items.IndexOf(reservation.ReservationDate.ToString("HH:00")); UntilTime.SelectedIndex = UntilTime.Items.IndexOf(reservation.ReservedUntil.ToString("HH:00")); if (reservation.ReservationEnded > DateTime.MinValue) { ReturnedDate.SelectedDate = reservation.ReservationEnded.Date; ReturnedTime.SelectedIndex = ReturnedTime.Items.IndexOf(reservation.ReservationEnded.ToString("HH:00")); } FromDate.SelectedDate = reservation.ReservationDate.Date; UntilDate.SelectedDate = reservation.ReservedUntil.Date; }
public async Task OnPostAsync() { const string path = @"..\车辆基本信息表.csv"; CarDetails = new List <CarDetail>(); var lists = FileService.ReadFromFile(path); CarDetails = InitializeService.InitializeCarDetail(lists); sta = new List <CarStatic>(); Dictionary <string, CarStatic> dic = new Dictionary <string, CarStatic>(); foreach (var item in CarDetails) { if (dic.ContainsKey(item.CarType)) { ++dic[item.CarType].Total; if (item.State == "y") { ++dic[item.CarType].rent; } else { ++dic[item.CarType].free; } } else { int onrent = item.State == "y" ? 1 : 0; dic.Add(item.CarType, new CarStatic { Type = item.CarType, Total = 1, rent = onrent, free = 1 - onrent }); } } foreach (var item in dic) { sta.Add(item.Value); } switch (SearchOption) { case "TotalInfo": break; case "BarChart": try { DataTable ChartData = new DataTable(); ChartData.Columns.Add("Programming Language", typeof(System.String)); ChartData.Columns.Add("Users", typeof(int)); foreach (var item in sta) { ChartData.Rows.Add(item.Type, item.Total); } // Create static source with this data table StaticSource source = new StaticSource(ChartData); // Create instance of DataModel class DataModel model = new DataModel(); // Add DataSource to the DataModel model.DataSources.Add(source); // Instantiate Column Chart Charts.ColumnChart column = new Charts.ColumnChart("first_chart"); // Set Chart's width and height column.Width.Pixel(700); column.Height.Pixel(400); // Set DataModel instance as the data source of the chart column.Data.Source = model; // Set Chart Title column.Caption.Text = "All type of the cars"; // Set chart sub title column.SubCaption.Text = "2020.06"; // hide chart Legend column.Legend.Show = false; // set XAxis Text column.XAxis.Text = "CarType"; // Set YAxis title column.YAxis.Text = "Total"; // set chart theme column.ThemeName = FusionChartsTheme.ThemeName.FUSION; // set chart rendering json ChartJson = column.Render(); }catch { } break; default: break; } }
public async Task OnPostSaveFileAsync() { string filepath = @"..\AGenerateFile.csv"; const string path = @"..\车辆基本信息表.csv"; CarDetails = new List <CarDetail>(); var lists = FileService.ReadFromFile(path); CarDetails = InitializeService.InitializeCarDetail(lists); sta = new List <CarStatic>(); Dictionary <string, CarStatic> dic = new Dictionary <string, CarStatic>(); foreach (var item in CarDetails) { if (dic.ContainsKey(item.CarType)) { ++dic[item.CarType].Total; if (item.State == "y") { ++dic[item.CarType].rent; } else { ++dic[item.CarType].free; } } else { int onrent = item.State == "y" ? 1 : 0; dic.Add(item.CarType, new CarStatic { Type = item.CarType, Total = 1, rent = onrent, free = 1 - onrent }); } } foreach (var item in dic) { sta.Add(item.Value); } try { // Create the file, or overwrite if the file exists. using (FileStream fs = System.IO.File.Create(filepath)) { string str = ""; foreach (var item in sta) { str = str + item.ToString() + "\n"; } byte[] info = new UTF8Encoding(true).GetBytes(str); // Add some information to the file. fs.Write(info, 0, info.Length); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
protected void Application_Start(object sender, EventArgs e) { InitializeService.Initialize(); }
public CreateModel() { var lists = FileService.ReadFromFile(path); bookIngInfos = InitializeService.InitializeBookingInfo(lists); }
/// <summary> /// This method is used to start the scheduler based on given argument number /// </summary> /// <param name="argument"></param> public static void StartScheduler(string[] argument) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; NativeMethods.HideWindow(true, argument[0]); if (!int.TryParse(argument[0], out int result)) { return; } SetLogFileName(result); DateTime startTime = DateTime.Now; Logger.LogMessage(string.Format(Constants.DefaultCulture, "SchedulerStarted \n {0:s}", DateTime.Now), "StartScheduler", LogType.Debug); switch (result) { case 1: new MessageReceiveService().ReceiveRecords(); break; case 2: new MessageSendService().GetIds(); new SchedulersViewModel(SchedulerType.PushData).RunScheduler(); break; case 3: new MessageSendService().SyncRecords(); break; case 4: new ResponseReceiveService().PullResponse(); break; case 5: // Cleanup log files and message queue database CleanUpService.CleanUpData(); break; case 6: // Creating Database new InitializeService().InitializeModule(true); break; case 7: new SchedulersViewModel().CreateAllSchedulers(DialogLocator.MainAssemblyPath + ".exe"); break; case 8: InitializeService.PrintScript(); break; case 9: if (argument.Length < 2) { string filePath = CategoryService.ExportCategories(null); Console.WriteLine(string.Format(Constants.DefaultCulture, @"File exported to {0}", filePath)); } else { string filePath = CategoryService.ExportCategories(argument[1]); Console.WriteLine(string.Format(Constants.DefaultCulture, @"File exported to {0}", filePath)); } break; case 10: if (argument.Length < 2) { bool status = CategoryService.ImportCategories(""); Console.WriteLine(string.Format(Constants.DefaultCulture, @"File import status : {0}", status)); } else { bool status = CategoryService.ImportCategories(argument[1]); Console.WriteLine(string.Format(Constants.DefaultCulture, @"File import status : {0}", status)); } break; case 11: new ImportService().ImportData(); break; case 12: new ImportService().ExportData(); break; default: Logger.LogMessage("Invalid command Argument" + argument, "StartScheduler", LogType.Warning); break; } Logger.LogMessage(string.Format(Constants.DefaultCulture, "SchedulerCompleted \n {0:s} \n RunTime : {1:dd\\-hh\\:mm\\:ss}", DateTime.Now, DateTime.Now.Subtract(startTime)), "StartScheduler", LogType.Debug); }
protected void Application_Start(object sender, EventArgs e) { // Code that runs on application startup InitializeService.Initialize(); }
protected override void OnSleep() { InitializeService initialize = new InitializeService(); initialize.Initialize(); }