FromDateTime() 공개 정적인 메소드

public static FromDateTime ( System.DateTime time ) : long
time System.DateTime
리턴 long
예제 #1
0
        void TaskListTaskCollectionRepo.AddNew(ITaskListCore container,
                                               ITaskCore item)
        {
            var command =
                "INSERT INTO Tasks" +
                "(Name, DueDate, CompletionDate, Priority, State, " +
                "Category, ExternalID) " +
                "VALUES (@name, @dueDate, @completionDate, " +
                "@priority, @state, @catId, ''); " +
                "SELECT last_insert_rowid();";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddWithValue("@name", item.Text);
                cmd.Parameters.AddWithValue("@dueDate",
                                            Database.FromDateTime(item.DueDate));
                cmd.Parameters.AddWithValue("@completionDate",
                                            Database.FromDateTime(DateTime.MinValue));
                cmd.Parameters.AddWithValue("@priority", (int)item.Priority);
                cmd.Parameters.AddWithValue("@state", (int)item.State);
                cmd.Parameters.AddWithValue("@catId",
                                            int.Parse(container.Id));
                var id = cmd.ExecuteScalar().ToString();
                item.SetId(id);
            }
        }
예제 #2
0
        DateTime ITaskRepository.UpdateDueDate(ITaskCore task, DateTime date)
        {
            var command = "UPDATE Tasks SET DueDate=@dueDate WHERE ID=@id;";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddWithValue("@dueDate",
                                            Database.FromDateTime(date));
                cmd.Parameters.AddIdParameter(task);
                cmd.ExecuteNonQuery();
            }
            return(date);
        }
예제 #3
0
        void ITaskRepository.Activate(ITaskCore task)
        {
            var command = "UPDATE Tasks SET State=@state, " +
                          "CompletionDate=@completionDate WHERE ID=@id;";

            using (var cmd = new SqliteCommand(database.Connection)) {
                cmd.CommandText = command;
                cmd.Parameters.AddWithValue("@state", (int)TaskState.Active);
                cmd.Parameters.AddWithValue("@completionDate",
                                            Database.FromDateTime(DateTime.MinValue));
                cmd.Parameters.AddIdParameter(task);
                cmd.ExecuteNonQuery();
            }
        }
예제 #4
0
        IEnumerable <ITaskListCore> IBackend.GetAll()
        {
            yield return(allList);

            ITaskListCore taskList;
            var           hasValues = false;

            var command = "SELECT id, name FROM Categories";

            using (var cmd = new SqliteCommand(
                       command, database.Connection)) {
                using (var dataReader = cmd.ExecuteReader()) {
                    while (dataReader.Read())
                    {
                        var id   = dataReader.GetInt32(0).ToString();
                        var name = dataReader.GetString(1);
                        hasValues = true;
                        taskList  = Factory.CreateTaskList(id, name);
                        yield return(taskList);
                    }
                }
            }

            if (!hasValues)
            {
                var workCategory = CreateInitialTaskList("Work");
                yield return(workCategory);

                yield return(CreateInitialTaskList("Personal"));

                yield return(CreateInitialTaskList("Family"));

                yield return(CreateInitialTaskList("Project"));

                var taskName      = "Create some tasks";
                var insertCommand = string.Format(
                    "INSERT INTO Tasks" +
                    "(Name, DueDate, CompletionDate, Priority, State, " +
                    "Category, ExternalID) " +
                    "VALUES ('{0}', '{1}', '{2}', " +
                    "'{3}', '{4}', '{5}', '{6}');",
                    taskName, Database.FromDateTime(DateTime.MinValue),
                    Database.FromDateTime(DateTime.MinValue), 0,
                    (int)TaskState.Active, workCategory.Id, string.Empty);
                using (var cmd = new SqliteCommand(database.Connection)) {
                    cmd.CommandText = insertCommand;
                    cmd.ExecuteNonQuery();
                }
            }
        }