Beispiel #1
0
        public static void NpgsqlDBImportCategory(ModelCategory mCategory)
        {
            string conn_str = "Server=localhost;Port=5432;User ID=xiao;Database=note;Password=xiao;Enlist=true";

            using (NpgsqlConnection conn = new NpgsqlConnection(conn_str))
            {
                //PostgreSQLへ接続
                conn.Open();

                int cid  = GetLastId("category", 40000000, conn);
                int chid = GetLastId("category_item", 41000000, conn);

                for (int i = mCategory.Items.Count - 1; i >= 0; i--)
                {
                    var item = mCategory.Items[i];
                    var root = InsertCategoryChild(conn, item.Category, 0, 0, ref chid);

                    string cmd_str = string.Format("insert into category (id, name, start_date, end_date, input_date, item_id) values " +
                                                   "('{0}', '{1}', '{2}', '{3}', '{4}', '{5}');",
                                                   ++cid, QuoConv(item.Name), QuoConv(item.Date.ToString("yyyy-MM-dd")), "9999-12-31",
                                                   QuoConv(item.Date.ToString("yyyy-MM-dd")), root);
                    NpgsqlCommand cmd  = new NpgsqlCommand(cmd_str, conn);
                    var           rtn1 = cmd.ExecuteNonQuery();

                    Console.WriteLine("Insert success! {0}", item.Name);
                }

                Console.WriteLine("Insert Complete!");
                conn.Close();
            }
        }
Beispiel #2
0
        private void InitialCategory()
        {
            mCategory = new ModelCategory();
            mCategory.Read();
            hisCategoryList = new List <ViewCategoryObject>();
            BindCategoryList();
            newCategoryItems = new List <CategoryItem>();
            BindCategoryItem();

            dateTimePickerCategory.Value = DateTime.Today;
        }
 public Category ReadCategory(DateTime curDate, ModelCategory mCategory)
 {
     EndTime = DateTime.MaxValue;
     foreach (var itr in mCategory.Items)
     {
         if (itr.Name == "Collection" && itr.Date > curDate)
         {
             EndTime = itr.Date;
         }
         else if (itr.Name == "Collection" && itr.Date <= curDate)
         {
             Category  = new Category(itr.Category);
             StartTime = itr.Date;
             break;
         }
     }
     if (Category == null)
     {
         Category = new Category("Collection");
         //throw new Exception("No Timetable is found in \"Category.xml\".");
     }
     return(Category);
 }
Beispiel #4
0
 //Timetable Read
 public TimetableItem ReadTimetable(DateTime curDate, ModelCategory mCategory)
 {
     EndTime = DateTime.MaxValue;
     foreach (var itr in mCategory.Items)
     {
         if (itr.Name == "Event" && itr.Date > curDate)
         {
             EndTime = itr.Date;
         }
         else if (itr.Name == "Event" && itr.Date <= curDate)
         {
             Timetable = new TimetableItem(itr.Category);
             StartTime = itr.Date;
             break;
         }
     }
     if (Timetable == null)
     {
         Timetable = new TimetableItem("Event");
         //throw new Exception("No Timetable is found in \"Category.xml\".");
     }
     return(Timetable);
 }
Beispiel #5
0
 private void InitializeCategory()
 {
     mCategory = new ModelCategory();
     mCategory.Read();
 }