예제 #1
0
        public static Boolean autoGenerateTasks()
        {
            Boolean result = false;

            var aglv = new AutoGenerateListViewModel();

            SQLiteClass.ExecuteSelectTableAutoGenerate(SQLiteClass.dbpath, aglv);

            foreach (ListAutoGenerate entry in aglv.Entries)
            {
                while (true)
                {
                    DateTime theNextDate = new DateTime(2019, 1, 1);
                    switch (entry.Type)
                    {
                    case (long)ListAutoGenerate.TypeName.A_Day_Of_Every_Month:
                        theNextDate = CaluculateTheNextADayOfEveryMonth(entry);
                        break;

                    case (long)ListAutoGenerate.TypeName.A_Weekday_In_Every_Week:
                        theNextDate = CaluculateTheNextAWeekDayOfEveryWeek(entry);
                        break;
                    }
                    if (theNextDate > DateTime.Now)
                    {
                        break;
                    }
                    AutoGenerateTask(SQLiteClass.dbpath, entry, theNextDate);
                    result             = true;
                    entry.Checked_date = theNextDate.ToString("yyyy-MM-dd HH:mm:ss");
                    SQLiteClass.ExecuteUpdateTableAutoGenerate(SQLiteClass.dbpath, entry);
                }
            }
            return(result);
        }
        private void saveOrderOfAutoGelerate(string dbpath, AutoGenerateListViewModel aglv)
        {
            Int64 newOrder = 0;

            foreach (ListAutoGenerate entry in aglv.Entries)
            {
                entry.Order = newOrder;
                SQLiteClass.ExecuteUpdateTableAutoGenerate(dbpath, entry);
                newOrder++;
            }
        }
예제 #3
0
        public static Boolean ExecuteSelectTableAutoGenerate(string dbpath, AutoGenerateListViewModel aglv)
        {
            Boolean ret = false;

            string sql = "SELECT * from autogenerate ORDER BY torder ASC";

            SQLiteConnection con = new SQLiteConnection("Data Source=" + dbpath + ";");

            con.Open();

            SQLiteCommand com = new SQLiteCommand(sql, con);

            try
            {
                SQLiteDataReader sdr = com.ExecuteReader();

                while (sdr.Read() == true)
                {
                    ListAutoGenerate lt = new ListAutoGenerate();
                    lt.Id           = (Int64)sdr["id"];
                    lt.Order        = (Int64)sdr["torder"];
                    lt.Type         = (Int64)sdr["type"];
                    lt.Name         = (string)sdr["name"];
                    lt.Priority     = (string)sdr["priority"];
                    lt.Template     = (Int64)sdr["template"];
                    lt.Number0      = (Int64)sdr["number0"];
                    lt.Number1      = (Int64)sdr["number1"];
                    lt.Due_hour     = (Int64)sdr["due_hour"];
                    lt.Due_minute   = (Int64)sdr["due_minute"];
                    lt.Checked_date = (string)sdr["checked_date"];
                    aglv.Entries.Add(lt);
                }
                sdr.Close();
                ret = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("database table autogenerate select error!\n" + ex.Message);
            }
            finally
            {
                con.Close();
            }
            return(ret);
        }