Ejemplo n.º 1
0
        public CreateModel()
        {
            const string path  = @"..\车辆基本信息表.csv";
            var          lists = FileService.ReadFromFile(path);

            Details = InitializeService.InitializeCarDetail(lists);
        }
Ejemplo n.º 2
0
        public async Task OnPostAsync()
        {
            const string path = @"..\车辆基本信息表.csv";

            CarDetails = new List <CarDetail>();
            var lists = FileService.ReadFromFile(path);

            CarDetails = InitializeService.InitializeCarDetail(lists);
            if (!string.IsNullOrEmpty(SearchString))
            {
                switch (SearchOption)
                {
                case "Name":
                    CarDetails = CarDetails.Where(t => t.Name.Contains(SearchString)).ToList();
                    break;

                case "CarType":
                    CarDetails = CarDetails.Where(t => t.CarType.Contains(SearchString)).ToList();
                    break;

                case "PlateId":
                    CarDetails = CarDetails.Where(t => t.CarPlateId.Contains(SearchString)).ToList();
                    break;

                default:
                    CarDetails = CarDetails.Where(t => t.Name.Contains(SearchString)).ToList();
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public IndexModel()
        {
            const string path = @"..\车辆基本信息表.csv";

            CarDetails = new List <CarDetail>();
            var lists = FileService.ReadFromFile(path);

            CarDetails = InitializeService.InitializeCarDetail(lists);
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
0
        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());
            }
        }