コード例 #1
0
        private static void InsertTask(Data.TaskList taskList, Data.Task task)
        {
            var gtask = new Task();

            gtask.Title     = task.Title;
            gtask.Status    = task.DoneDate.HasValue ? "completed" : "needsAction";
            gtask.Completed = task.DoneDate.HasValue ? System.Xml.XmlConvert.ToString(task.DoneDate.Value, XmlDateTimeSerializationMode.Utc) : null;
            gtask.Due       = task.DueDate.HasValue ? System.Xml.XmlConvert.ToString(task.DueDate.Value, XmlDateTimeSerializationMode.Utc) : null;
            gtask.Notes     = task.Notes;

            var req = Service.Tasks.Insert(gtask, taskList.Id);


            if (task.PreviousId != "")
            {
                req.Previous = TasksReferenceManager.GetGoogleTaskId(taskList.Title, task.PreviousId);
            }
            if (task.ParentId != "")
            {
                req.Parent = TasksReferenceManager.GetGoogleTaskId(taskList.Title, task.ParentId);
            }

            var googleTaskId = req.Fetch().Id;

            TasksReferenceManager.AddNewReference(taskList.Title, task.Id, googleTaskId);
        }
コード例 #2
0
        public void DeleteTask(TodoItem task)
        {
            var ntask = new Google.Apis.Tasks.v1.Data.Task()
            {
                Title = task.Title, Id = task.ID
            };

            this.DeleteTask(ntask);
        }
コード例 #3
0
ファイル: ToDoTaskService.cs プロジェクト: FO2XS/FO2XS
        ///<summary>
        ///Обновляет измененный таск в указанном списке
        ///</summary>
        public static void UpdateToDoTaskInList(Google.Apis.Tasks.v1.Data.Task updatedTask, string idList)
        {
            try
            {
                service.Tasks.Update(updatedTask,
                    idList,
                    updatedTask.Id).Execute();
            }
            catch
            {

            }
        }
コード例 #4
0
ファイル: Taskedit.aspx.cs プロジェクト: szarath/Fincal
        private async void taskedit()
        {
            using (var stream =
                       new FileStream(Server.MapPath("client_secret.json"), FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);;
                credPath = Path.Combine(credPath, ".credentials/tasksupdate-dotnet-quickstart.json");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;
                // Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Google Tasks API service.
            var service = new TasksService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });


            Google.Apis.Tasks.v1.Data.Task task = service.Tasks.Get("@default", taskid).Execute();



            if (Completedcheck.Checked == false)
            {
                task.Status       = "needsAction";
                task.CompletedRaw = null;
                task.Completed    = null;
                completed         = 0;
            }
            else if (Completedcheck.Checked == true)
            {
                task.Status = "completed";
                completed   = 1;
            }
            task.Title = txttaskanme.Value;
            Google.Apis.Tasks.v1.Data.Task result = await service.Tasks.Update(task, "@default", taskid).ExecuteAsync();

            UserData user = (UserData)Session["User"];

            Dataservice.DatamanagementClient findata = new Dataservice.DatamanagementClient();
            findata.Open();

            object[] taskdetails = findata.gettask(taskid, user.getID());

            int getnum = findata.updatetask(txttaskanme.Value.ToString(), completed.ToString(), user.getID(), Leveldrop.Items[Leveldrop.SelectedIndex].Text.ToString(), result.Id.ToString(), (string)taskdetails[0]);

            findata.Close();
        }
コード例 #5
0
ファイル: Taskadd.aspx.cs プロジェクト: szarath/Fincal
        private async void inserttask()
        {
            UserCredential credential;

            /*using (var stream =
             *  new FileStream(Server.MapPath("client_secret.json"), FileMode.Open, FileAccess.Read))
             * {
             *  string credPath = Server.MapPath("/token.json");
             *  credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
             *      GoogleClientSecrets.Load(stream).Secrets,
             *      Scopes,
             *      "user",
             *      CancellationToken.None,
             *      new FileDataStore(credPath, true)).Result;
             *  Console.WriteLine("Credential file saved to: " + credPath);
             * }*/

            using (var stream =
                       new FileStream(Server.MapPath("client_secret.json"), FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);;
                credPath = Path.Combine(credPath, ".credentials/tasksadd-dotnet-quickstart.json");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;
                // Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Google Tasks API service.
            var service = new TasksService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = ApplicationName,
            });

            Google.Apis.Tasks.v1.Data.Task task = new Google.Apis.Tasks.v1.Data.Task {
                Title = txttaskanme.Value
            };

            newtask = await service.Tasks.Insert(task, "@default").ExecuteAsync();

            Dataservice.DatamanagementClient findata = new Dataservice.DatamanagementClient();
            findata.Open();
            UserData currentUser = (UserData)(Session["User"]);

            findata.inserttask(txttaskanme.Value.ToString(), "0", Leveldrop.Items[Leveldrop.SelectedIndex].Value.ToString(), newtask.Id, currentUser.getID());

            findata.Close();
        }
コード例 #6
0
        private static void UpdateTask(Data.TaskList taskList, Data.Task task)
        {
            var googleTaskId = TasksReferenceManager.GetGoogleTaskId(taskList.Title, task.Id);

            if (googleTaskId == "")
            {
                return;
            }

            Task gtask = Service.Tasks.Get(taskList.Id, googleTaskId).Fetch();

            gtask.Title     = task.Title;
            gtask.Status    = task.DoneDate.HasValue ? "completed" : "needsAction";
            gtask.Completed = task.DoneDate.HasValue ? System.Xml.XmlConvert.ToString(task.DoneDate.Value, XmlDateTimeSerializationMode.Utc) : null;
            gtask.Due       = task.DueDate.HasValue ? System.Xml.XmlConvert.ToString(task.DueDate.Value, XmlDateTimeSerializationMode.Utc) : null;
            gtask.Notes     = task.Notes;


            Service.Tasks.Update(gtask, taskList.Id, googleTaskId).Fetch();
        }
コード例 #7
0
        public GoogleTaskSyncData CreateFrom(TaskSyncData syncDataSource)
        {
            var task = new GoogleTask();

            task.Title = syncDataSource.Subject;
            task.Notes = syncDataSource.Body;
            if (syncDataSource.DueTime != null)
            {
                var dueTime          = syncDataSource.DueTime.Value;
                var dueTimeUtcFormat = new DateTime(dueTime.Year, dueTime.Month, dueTime.Day, 0, 0, 0, DateTimeKind.Utc);
                task.Due = Rfc3339DateTime.ToString(dueTimeUtcFormat);
            }

            if (syncDataSource.IsCompleted)
            {
                task.Status = "completed";
            }
            else
            {
                task.Status = "needsAction";
            }

            return(new GoogleTaskSyncData(task));
        }
コード例 #8
0
ファイル: ToDoTaskService.cs プロジェクト: FO2XS/FO2XS
 public void AddNewTaskInList(ToDoTaskList list, string title){
     Google.Apis.Tasks.v1.Data.Task newTask = new Google.Apis.Tasks.v1.Data.Task(){
         Title = title
     };
     service.Tasks.Insert(newTask, list.Id).Execute();
 }