当前位置: 首页>>代码示例>>C#>>正文


C# Task.Save方法代码示例

本文整理汇总了C#中Task.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Task.Save方法的具体用法?C# Task.Save怎么用?C# Task.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task的用法示例。


在下文中一共展示了Task.Save方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomeModule

        public HomeModule()
        {
            Get["/"] = _ => {
            return View["index.cshtml"];
              };
              Get["/categories"] = _ => {
            var allCategories = Category.GetAll();
            return View["categories.cshtml", allCategories];
              };
              Get["/categories/new"] = _ => {
            return View["category_form.cshtml"];
              };
              Post["/categories"] = _ => {
            var newCategory = new Category(Request.Form["category-name"]);
            var allCategories = Category.GetAll();
            return View["categories.cshtml", allCategories];
              };
              Get["/categories/{id}"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            var selectedCategory = Category.Find(parameters.id);
            var categoryTasks = selectedCategory.GetTasks();
            model.Add("category", selectedCategory);
            model.Add("tasks", categoryTasks);
            return View["category.cshtml", model];
              };
              Get["/categories/{id}/tasks/new"] = parameters => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category selectedCategory = Category.Find(parameters.id);
            List<Task> allTasks = selectedCategory.GetTasks();
            model.Add("category", selectedCategory);
            model.Add("tasks", allTasks);
            return View["category_tasks_form.cshtml", model];
              };
              Post["/tasks"] = _ => {
            Dictionary<string, object> model = new Dictionary<string, object>();
            Category selectedCategory = Category.Find(Request.Form["category-id"]);
            List<Task> categoryTasks = selectedCategory.GetTasks();
            string taskDescription = Request.Form["task-description"];
            Task newTask = new Task(taskDescription);
            categoryTasks.Add(newTask);
            model.Add("tasks", categoryTasks);
            model.Add("category", selectedCategory);
            return View["category.cshtml", model];
              };
              Get["/view_all_tasks"] = _ => {
               List<string> allTasks = Task.GetAll();
            return View["view_all_tasks.cshtml", allTasks];
            };
              Post["/task_added"] = _ => {
            Task newTask = new Task (Request.Form["new-task"]);
            newTask.Save();
            return View["task_added.cshtml", newTask];
            };
              Post["/tasks_cleared"] = _ => {
            Task.ClearAll();
            return View["tasks_cleared.cshtml"];

              };
        }
开发者ID:michaeldada,项目名称:todo_list_c-,代码行数:59,代码来源:HomeModule.cs

示例2: createSampleProject

		private void createSampleProject()
		{
			var project = new Project() {Name="Release AR"};
			project.Save();

			var task1 = new Task() {Name = "Create Tag", Project = project};
			var task2 = new Task() { Name = "Upload Zip", Project = project, ScheduledDate = DateTime.Today.AddDays(7)};
 
			task1.Save();
			task2.Save();
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:11,代码来源:TestCases.cs

示例3: HomeModule

        public HomeModule()
        {
            Get["/"] = _ => View["welcome.cshtml"];
              Get["/add_new_car"] = _ => {

              };
              Post["/task_added"] = _ => {
            Task newTask = new Task (Request.Form["new-task"]);
            newTask.Save();
            return View["task_added.cshtml", newTask];
              };
        }
开发者ID:jacksoncafazzo,项目名称:Car-Dealershiip,代码行数:12,代码来源:HomeModule.cs

示例4: HomeModule

        public HomeModule()
        {
            Get["/"] = _ => View["addtask.cshtml"];

              Post["/view_tasks"] = _ => {
            Task newTask = new Task(Request.Form["add-task"]);
            newTask.Save();
            List<Task> theTasks = Task.GetAllTasks();
            return View["viewtask.cshtml", theTasks];
              };
              Post["/tasks_cleared"] = _ => {
            Task.ClearAllTasks();
            return View["addtask.cshtml"];
              };
        }
开发者ID:trashmoldwilliams,项目名称:CSharp-ObjectToDoList,代码行数:15,代码来源:HomeModule.cs

示例5: HomeModule

 public HomeModule()
 {
     Get["/"] = _ => View["add_new_task.cshtml"];
       Get["/view_all_tasks"] = _ => {
     List<string> allTasks = Task.GetAll();
     return View["view_all_tasks.cshtml", allTasks];
       };
       Post["/task_added"] = _ => {
     Task newTask = new Task (Request.Form["new-task"]);
     newTask.Save();
     return View["task_added.cshtml", newTask];
       };
       Post["/tasks_cleared"] = _ => {
     Task.ClearAll();
     return View["tasks_cleared.cshtml"];
       };
 }
开发者ID:jmk22,项目名称:todolist_static_vars_methods,代码行数:17,代码来源:HomeModule.cs

示例6: HomeModule

 public HomeModule()
 {
     Get["/"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["index.cshtml", AllCategories];
       };
       Get["/tasks"] = _ => {
     List<Task> AllTasks = Task.GetAll();
     return View["tasks.cshtml", AllTasks];
       };
       Get["/categories"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["categories.cshtml", AllCategories];
       };
       Get["/categories/new"] = _ => {
     return View["categories_form.cshtml"];
       };
       Post["/categories/new"] = _ => {
     Category newCategory = new Category(Request.Form["category-name"]);
     newCategory.Save();
     return View["success.cshtml"];
       };
       Get["/tasks/new"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["tasks_form.cshtml", AllCategories];
       };
       Post["/tasks/new"] = _ => {
     Task newTask = new Task(Request.Form["task-description"], Request.Form["task-due-date"], Request.Form["category-id"]);
     newTask.Save();
     return View["success.cshtml"];
       };
       Post["/tasks/delete"] = _ => {
     Task.DeleteAll();
     return View["cleared.cshtml"];
       };
       Get["/categories/{id}"] = parameters => {
     Dictionary<string, object> model = new Dictionary<string, object>();
     var SelectedCategory = Category.Find(parameters.id);
     var CategoryTasks = SelectedCategory.GetTasks();
     model.Add("category", SelectedCategory);
     model.Add("tasks", CategoryTasks);
     return View["category.cshtml", model];
       };
 }
开发者ID:CharlesEwel,项目名称:csharpweektwoweekthreeweekendhw,代码行数:44,代码来源:HomeModule.cs

示例7: CreateTask

    public WhartonEWSResponse CreateTask(
        String apiKey,
        String emlUserAddress,
        String strTaskSubject,
        String strTaskStartDate,
        String strTaskDueDate,
        String strTaskImportance,
        String strTaskStatus,
        String strTaskBody
    )
    {
        WhartonEWSResponse rsp = new WhartonEWSResponse();

        Boolean success = true;
        String miscData = "";

        try
        {
            // Initialize EWS service.
            ExchangeService service = getService(emlUserAddress, apiKey);

            //parse task dates
            DateTime realStartDate = DateTime.Parse(strTaskStartDate);
            DateTime realDueDate = DateTime.Parse(strTaskDueDate);

            //parse task importance
            Importance realTskImportance;
            if (strTaskImportance.ToLower() == "high")
                realTskImportance = Importance.High;
            else if (strTaskImportance.ToLower() == "low")
                realTskImportance = Importance.Low;
            else
                realTskImportance = Importance.Normal;

            //parse task status
            TaskStatus realTskStatus;
            if (strTaskStatus.ToLower() == "inprogress")
                realTskStatus = TaskStatus.InProgress;
            else if (strTaskStatus.ToLower() == "completed")
                realTskStatus = TaskStatus.Completed;
            else if (strTaskStatus.ToLower() == "deferred")
                realTskStatus = TaskStatus.Deferred;
            else if (strTaskStatus.ToLower() == "waitingonothers")
                realTskStatus = TaskStatus.WaitingOnOthers;
            else
                realTskStatus = TaskStatus.NotStarted;

            //compose task object
            Task t = new Task(service);
            t.Subject = strTaskSubject;
            t.StartDate = realStartDate;
            t.DueDate = realDueDate;
            t.Importance = realTskImportance;
            t.Status = realTskStatus;
            t.Body = strTaskBody;

            //save to exchange
            t.Save(WellKnownFolderName.Tasks);

            rsp.SimpleData = true;
        }
        catch (Exception e)
        {
            if (!(int.TryParse(e.Message, out rsp.StatusCode)))
            {
                //if the parsing fails, then set a default value of 500
                rsp.StatusCode = 500;
            }
            rsp.Msg = e.Message;

            success = false;
            miscData = "{ \"ErrMsg\":\"" + rsp.Msg + "\" }";
            rsp.StackTrace = e.StackTrace;
            if (e.InnerException != null) { rsp.InnerException = e.InnerException.ToString(); }
        }

        //audit
        addAuditLog(apiKey, emlUserAddress, "CreateTask", success, miscData);

        return rsp;
    }
开发者ID:wharton,项目名称:Envelope,代码行数:81,代码来源:WhartonEWS.cs

示例8: Scalar

 public void Scalar()
 {
     List<Task> Tasks = new List<Task>();
     for (int x = 0; x < 100; ++x)
     {
         Task SubTask = new Task();
         SubTask.Description = "This is a test";
         SubTask.DueDate = new DateTime(1900, 1, 1);
         SubTask.Name = "Sub task 1";
         SubTask.Save();
     }
     Assert.Equal(100, Task.Scalar<int>("COUNT(*)"));
 }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:13,代码来源:ORMTest2.cs

示例9: Paged2

        public void Paged2()
        {
            for (int x = 0; x < 100; ++x)
            {
                Task TempTask = new Task();
                TempTask.Description = "This is a test";
                TempTask.DueDate = new DateTime(1900, 1, 1);
                TempTask.Name = "Test task";
                TempTask.Save();
            }

            IEnumerable<Task> TestObject = Task.PagedCommand("SELECT * FROM Task_ WHERE ID_>@ID", "", 25, 0, new EqualParameter<long>(50, "ID"));
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 51, 75);
            }

            TestObject = Task.PagedCommand("SELECT * FROM Task_ WHERE ID_>@ID", "", 25, 1, new EqualParameter<long>(50, "ID"));
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 76, 100);
            }

            TestObject = Task.PagedCommand("SELECT * FROM Task_ WHERE ID_>@ID", "", 25, 2, new EqualParameter<long>(50, "ID"));
            Assert.Equal(0, TestObject.Count());

            Assert.Equal(2, Task.PageCount("SELECT * FROM Task_ WHERE ID_>@ID", 25, new EqualParameter<long>(50, "ID")));
        }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:30,代码来源:ORMTest2.cs

示例10: Paged

        public void Paged()
        {
            for (int x = 0; x < 100; ++x)
            {
                Task TempTask = new Task();
                TempTask.Description = "This is a test";
                TempTask.DueDate = new DateTime(1900, 1, 1);
                TempTask.Name = "Test task";
                TempTask.Save();
            }

            IEnumerable<Task> TestObject = Task.Paged();
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 1, 25);
            }

            TestObject = Task.Paged(CurrentPage: 1);
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 26, 50);
            }

            TestObject = Task.Paged(CurrentPage: 2);
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 51, 75);
            }

            TestObject = Task.Paged(CurrentPage: 3);
            Assert.Equal(25, TestObject.Count());
            foreach (Task TestTask in TestObject)
            {
                Assert.InRange(TestTask.ID, 76, 100);
            }

            Assert.Equal(4, Task.PageCount());
        }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:41,代码来源:ORMTest2.cs

示例11: Insert

        public void Insert(int ModuleID,string Name,string Description,DateTime? StartDate,DateTime? ExpEndDate,DateTime? ActEndDate,short Status,short? Complexity)
        {
            Task item = new Task();

            item.ModuleID = ModuleID;

            item.Name = Name;

            item.Description = Description;

            item.StartDate = StartDate;

            item.ExpEndDate = ExpEndDate;

            item.ActEndDate = ActEndDate;

            item.Status = Status;

            item.Complexity = Complexity;

            item.Save(UserName);
        }
开发者ID:jrummell,项目名称:projmgt-net,代码行数:22,代码来源:TaskController.cs

示例12: Update

        public void Update(int Id,int ModuleID,string Name,string Description,DateTime? StartDate,DateTime? ExpEndDate,DateTime? ActEndDate,short Status,short? Complexity)
        {
            Task item = new Task();
            item.MarkOld();
            item.IsLoaded = true;

            item.Id = Id;

            item.ModuleID = ModuleID;

            item.Name = Name;

            item.Description = Description;

            item.StartDate = StartDate;

            item.ExpEndDate = ExpEndDate;

            item.ActEndDate = ActEndDate;

            item.Status = Status;

            item.Complexity = Complexity;

            item.Save(UserName);
        }
开发者ID:jrummell,项目名称:projmgt-net,代码行数:26,代码来源:TaskController.cs

示例13: CreateContentListItem

        private static void CreateContentListItem(string parentPath, string name, string type)
        {
            var parent = Node.LoadNode(parentPath);
            var task = new Task(parent)
                           {
                               Name = name
                           };
            
            task.Save();

            var content = Content.Create(task);

            switch (type)
            {
                case "T1":
                    content["#ContentList1Field3"] = testFieldValueForT1;
                    break;
                case "T2":
                    content["#ContentList2Field2"] = testFieldValueForT2;
                    break;
                default:
                    throw new ArgumentException("You have to assign a valid value to the type parameter!"); 
            }

            content.Save();            
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:26,代码来源:TrashTest.cs

示例14: SaveToDb

 //数据持久化
 internal static void SaveToDb(TaskInfo pTaskInfo, Task  pTask,bool pIsNew)
 {
     pTask.TaskId = pTaskInfo.taskId;
      		pTask.TaskName = pTaskInfo.taskName;
      		pTask.EmployeeId = pTaskInfo.employeeId;
      		pTask.WorkSheetId = pTaskInfo.workSheetId;
      		pTask.RecvTime = pTaskInfo.recvTime;
      		pTask.IsFinish = pTaskInfo.isFinish;
      		pTask.FinishTime = pTaskInfo.finishTime;
      		pTask.BeginTime = pTaskInfo.beginTime;
      		pTask.IsMain = pTaskInfo.isMain;
     pTask.IsNew=pIsNew;
     string UserName = SubsonicHelper.GetUserName();
     try
     {
         pTask.Save(UserName);
     }
     catch(Exception ex)
     {
         LogManager.getInstance().getLogger(typeof(TaskInfo)).Error(ex);
         if(ex.Message.Contains("插入重复键"))//违反了唯一键
         {
             throw new AppException("此对象已经存在");//此处等待优化可以从唯一约束中直接取出提示来,如果没有的话,默认为原始的出错提示
         }
         throw new AppException("保存失败");
     }
     pTaskInfo.taskId = pTask.TaskId;
     //如果缓存存在,更新缓存
     if (CachedEntityCommander.IsTypeRegistered(typeof(TaskInfo)))
     {
         ResetCache();
     }
 }
开发者ID:xingfudaiyan,项目名称:OA,代码行数:34,代码来源:TaskInfo.cs


注:本文中的Task.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。