示例#1
0
        protected override void OnSaving()
        {
            this.DataKey  = TheDate.ToString("yyyyMMdd");
            this.TheYear  = TheDate.Year;
            this.TheMonth = TheDate.Month;
            this.TheDay   = TheDate.Day;

            this.WeekDay = TheDate.DayOfWeek;

            this.Quarter    = (季度)((TheDate.Month - 1) / 3);
            this.WeekOfYear = myCI.Calendar.GetWeekOfYear(TheDate, System.Globalization.CalendarWeekRule.FirstDay,
                                                          DayOfWeek.Monday);

            this.DayOfYear  = myCI.Calendar.GetDayOfYear(TheDate);
            this.SemiYearly = TheMonth > 7
                ? 半年.半年
                : 半年.半年;
            var t = this.TheDay;

            if (t > 30)
            {
                t = 30;
            }
            this.PeriodOfTenDays = (月旬)((t - 1) / 10);
            base.OnSaving();
        }
示例#2
0
    static void Main(string[] args)
    {
        Console.WriteLine();
        ConsoleColor original = Console.ForegroundColor;
        TheDate      W;

        W = new TheDate();
        Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@");
        Console.Write("W.ccyy   為  ");
        Console.ForegroundColor = ConsoleColor.Red;
        // fix #1 觀察下一行會印出什麼?
        Console.WriteLine(W.ccyy);
        Console.ForegroundColor = original;
        Console.WriteLine("########################");
        Console.Write("W.mm     為  ");
        Console.ForegroundColor = ConsoleColor.Red;
        // fix #2 觀察下一行會印出什麼?
        Console.WriteLine(W.mm);
        Console.ForegroundColor = original;
        Console.WriteLine("????????????????????????");
        Console.Write("W.dd     為  ");
        Console.ForegroundColor = ConsoleColor.Red;
        // fix #3 觀察下一行會印出什麼?
        Console.WriteLine(W.dd);
        Console.ForegroundColor = original;
        Console.WriteLine("$$$$$$$$$$$$$$$$$$$$$$$$");
        Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine();
        Console.WriteLine(); Console.WriteLine();
    }
示例#3
0
        public static void BSEParser(string InputPath)
        {
            if (File.Exists(InputPath))
            {
                //InputPath = @"D:\Desktop\StockData\BSE-Equity\20170925.csv";
                string OutputPath = Path.GetDirectoryName(InputPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(InputPath) + "_output.csv";
                using (var sr = new StreamReader(InputPath))
                {
                    using (var sw = new StreamWriter(OutputFile))
                    {
                        var      reader = new CsvReader((IParser)sr);
                        var      writer = new CsvWriter((ISerializer)sw);
                        DateTime TheDate;
                        if (DateTime.TryParseExact(Path.GetFileNameWithoutExtension(InputFile), "yyyyMdd", null, System.Globalization.DateTimeStyles.AssumeLocal, out TheDate))
                        {
                            reader.Configuration.HeaderValidated   = null;
                            reader.Configuration.MissingFieldFound = null;
                            //CSVReader will now read the whole file into an enumerable
                            IEnumerable records = reader.GetRecords <BSEHeaders>().Where(i => i.SC_TYPE == "Q").ToList();

                            //Write the entire contents of the CSV file into another
                            //writer.WriteRecords(records);


                            //Now we will write the data into the same output file but will do it
                            //Using two methods.  The first is writing the entire record.  The second
                            //method writes individual fields.  Note you must call NextRecord method after
                            //using Writefield to terminate the record.

                            //Note that WriteRecords will write a header record for you automatically.  If you
                            //are not using the WriteRecords method and you want to a header, you must call the
                            //Writeheader method like the following:
                            //
                            writer.WriteHeader <BSEHeaders>();
                            writer.NextRecord();
                            //
                            //Do not use WriteHeader as WriteRecords will have done that already.
                            string DateString = TheDate.ToString("yyyyMMdd");
                            foreach (BSEHeaders record in records)
                            {
                                //write record field by field
                                writer.WriteField(record.SC_CODE);
                                writer.WriteField(record.SC_NAME);
                                //writer.WriteField(record.SC_TYPE);
                                record.DATE = DateString;
                                writer.WriteField(record.DATE);
                                writer.WriteField(record.OPEN);
                                writer.WriteField(record.HIGH);
                                writer.WriteField(record.LOW);
                                writer.WriteField(record.CLOSE);
                                writer.WriteField(record.NO_OF_SHRS);
                                //ensure you write end of record when you are using WriteField method
                                writer.NextRecord();
                            }
                        }
                    }
                }
            }
        }
示例#4
0
文件: Program.cs 项目: YaHengKe/-
    static void Main(string[] args)
    {
        ConsoleColor original = Console.ForegroundColor;

        {
            TheDate W = null;
            Console.WriteLine();
            // fix #0 觀察下一行是在做什麼?
            W = new TheDate();
            Console.WriteLine("W = new TheDate();");
            Console.WriteLine("##################################");
            Console.Write("W.ccyy   為  ");
            Console.ForegroundColor = ConsoleColor.Red;
            // fix #1 觀察下一行會印出什麼?
            Console.WriteLine(W.ccyy);
            Console.ForegroundColor = original;
            Console.Write("W.mm     為  ");
            Console.ForegroundColor = ConsoleColor.Red;
            // fix #2 觀察下一行會印出什麼?
            Console.WriteLine(W.mm);
            Console.ForegroundColor = original;
            Console.Write("W.dd     為  ");
            Console.ForegroundColor = ConsoleColor.Red;
            // fix #3 觀察下一行會印出什麼?
            Console.WriteLine(W.dd);
            Console.ForegroundColor = original;
        }
        Console.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
        {
            TheDate W;
            // fix #4 觀察下一行是在做什麼?
            W = new TheDate(2015, 8, 2);
            Console.WriteLine("W = new TheDate(2015, 8, 2);");
            Console.WriteLine("??????????????????????????????????");
            Console.Write("W.ccyy   為  ");
            Console.ForegroundColor = ConsoleColor.Green;
            // fix #5 觀察下一行會印出什麼?
            Console.WriteLine(W.ccyy);
            Console.ForegroundColor = original;
            Console.Write("W.mm     為  ");
            Console.ForegroundColor = ConsoleColor.Green;
            // fix #6 觀察下一行會印出什麼?
            Console.WriteLine(W.mm);
            Console.ForegroundColor = original;
            Console.Write("W.dd     為  ");
            Console.ForegroundColor = ConsoleColor.Green;
            // fix #7 觀察下一行會印出什麼?
            Console.WriteLine(W.dd);
            Console.ForegroundColor = original;
        }
        Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine();
        Console.WriteLine(); Console.WriteLine();
    }
示例#5
0
    static void Main(string[] args)
    {
        Console.WriteLine();
        TheDate W;

        // fix #2 觀察下一行會如何?
        W = new TheDate();
        Console.WriteLine("###################################");
        // fix #3 觀察下三行會印出什麼?
        Console.WriteLine("W.ccyy 為 " + W.ccyy);
        Console.WriteLine("W.mm   為 " + W.mm);
        Console.WriteLine("W.dd   為 " + W.dd);
        TheDate t;

        // fix #4 觀察下一行會如何?
        t = new TheDate(1999, 9, 28);
        Console.WriteLine("???????????????????????????????????");
        // fix #5 觀察下三行會印出什麼?
        Console.WriteLine("t.ccyy   為 " + t.ccyy);
        Console.WriteLine("t.mm     為 " + t.mm);
        Console.WriteLine("t.dd     為 " + t.dd);
        Console.WriteLine("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
        Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine();
    }