Example #1
0
        public MainUI(DualDifferentReturn <TasksService, PlusService> services)
        {
            InitializeComponent();

            try
            {
                TasksService tasksService = services.returnValue1;
                PlusService  plusService  = services.returnValue2;

                var    me    = plusService.People.Get("me").Execute();
                string email = me.Emails.FirstOrDefault().Value;
                string name  = me.DisplayName;

                MainUI_lblAccountInfo.Content = name + " (" + email + ")";

                TasklistsResource.ListRequest tasklistRequest = tasksService.Tasklists.List();
                IList <TaskList> taskLists = tasklistRequest.Execute().Items;

                if (taskLists != null && taskLists.Count > 0)
                {
                    eTasklists = new List <ETasklist>();
                    foreach (TaskList taskList in taskLists)
                    {
                        TasksResource.ListRequest taskRequest = tasksService.Tasks.List(taskList.Id);
                        IList <Task> tasks = taskRequest.Execute().Items;

                        ETasklist eTasklist = new ETasklist(taskList, tasks);
                        eTasklists.Add(eTasklist);
                    }

                    listTasks(eTasklists);
                }
                else
                {
                    Console.WriteLine("No task lists found.");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString() + " " + e.StackTrace);
            }

            this.BringIntoView();
            this.Activate();
        }
Example #2
0
        public IList <Task> GetTasks()
        {
            UserCredential credential;

            using (var stream =
                       new FileStream(@"C:\Users\kneel.LJ\Desktop\credentials.json", FileMode.Open, FileAccess.Read))
            {
                // The file token.json stores the user's access and refresh tokens, and is created
                // automatically when the authorization flow completes for the first time.
                string credPath = "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);
            }

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

            // Define parameters of request.
            TasklistsResource.ListRequest listRequest = service.Tasklists.List();
            listRequest.MaxResults = 10;

            // List task lists.
            IList <TaskList> taskLists = listRequest.Execute().Items;

            Console.WriteLine("Tasks:");

            IList <Task> tasks2 = new List <Task>();

            if (taskLists != null && taskLists.Count > 0)
            {
                foreach (var taskList in taskLists)
                {
                    //  Console.WriteLine("{0} ({1})", taskList.Title, taskList.Id);
                    // Define parameters of request.
                    TasksResource.ListRequest taskListRequest = service.Tasks.List(taskList.Id);
                    taskListRequest.MaxResults = 40;
                    var tasks = taskListRequest.Execute().Items;
                    foreach (var task in tasks)
                    {
                        //  Console.WriteLine("{0} ({1})", task.Title, task.Notes);
                        tasks2.Add(task);
                    }
                }
            }
            else
            {
                Console.WriteLine("No task lists found.");
            }

            //return taskLists;
            return(tasks2);
        }
Example #3
0
        private void Taskget()
        {
            string[] Scopes          = { TasksService.Scope.TasksReadonly };
            string   ApplicationName = "Google Tasks API .NET Quickstart";

            object[] storedtask = null;
            // string htmldata = "<div class='row'>";
            string taskcolor  = "white";
            string complete   = " <div class='row'>";
            string incomplete = "<div class='row'>";

            UserCredential credential;



            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/tasks-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,
            });



            // Define parameters of request.


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



            TasksResource.ListRequest request = service.Tasks.List("@default");
            request.MaxResults = 20;
            Google.Apis.Tasks.v1.Data.Tasks tasks = request.Execute();

            if (tasks.Items != null)
            {
                foreach (Google.Apis.Tasks.v1.Data.Task task in tasks.Items)
                {
                    string title = task.Title;
                    string id    = task.Id;

                    if (task.Status.ToString() == "completed")
                    {
                        if (findata.checktasks(id, user.getID()) == id)
                        {
                            storedtask = findata.gettask(id, user.getID());
                            if ((string)storedtask[1] == title)
                            {
                            }
                            else
                            {
                                findata.updatetask(task.Title, "1", user.getID().ToString(), (string)storedtask[4], task.Id, (string)storedtask[0]);
                            }
                            complete += "<a href=\"Taskedit.aspx?id=" + task.Id + "\">";
                            complete += "<div class=\"col s12 m3 l3\">";
                            complete += "<div class=\"card horizontal hoverable " + colorchoice(Convert.ToInt32((string)storedtask[4])) + "\">";
                            //   htmldata += "<div class=\"card horizontal hoverable blue\">";
                            complete += "<div class=\"card-stacked\">";
                            complete += "<div class=\"card-content black-text\">";
                            complete += "<span class=\"card-title bold trunctext\">" + task.Title.ToString();
                            complete += "</span>";
                            complete += "</div>";
                            complete += "</div>";
                            complete += "</div>";
                            complete += "</div>";
                            complete += "</a>";
                        }
                        else
                        {
                            findata.inserttask(task.Title, "1", "1", task.Id, user.getID());
                            complete += "<a href=\"Taskedit.aspx?id=" + task.Id + "\">";
                            complete += "<div class=\"col s12 m3 l3\">";
                            //     complete += "<div class=\"card horizontal hoverable " + colorchoice(Convert.ToInt32((string)storedtask[4])) + " href=\"Taskedit" + "?id=" + task.Id + "\">";
                            complete += "<div class=\"card horizontal hoverable green\">";
                            complete += "<div class=\"card-stacked\">";
                            complete += "<div class=\"card-content black-text\">";
                            complete += "<span class=\"card-title bold trunctext\">" + task.Title.ToString();
                            complete += "</span>";

                            complete += "</div>";
                            complete += "</div>";
                            complete += "</div>";
                            complete += "</div>";
                            complete += "</a>";
                        }
                    }
                    else
                    {
                        if (findata.checktasks(id, user.getID()) == id)
                        {
                            storedtask = findata.gettask(id, user.getID());
                            if ((string)storedtask[1] == title)
                            {
                            }
                            else
                            {
                                findata.updatetask(task.Title, "1", user.getID().ToString(), (string)storedtask[4], task.Id, (string)storedtask[0]);
                            }


                            incomplete += "<a href=\"Taskedit.aspx?id=" + task.Id + "\">";
                            incomplete += "<div class=\"col s12 m3 l3\">";
                            incomplete += "<div class=\"card  hoverable " + colorchoice(Convert.ToInt32((string)storedtask[4])) + "\">";
                            //htmldata += "<div class=\"card horizontal hoverable blue\">";
                            incomplete += "<div class=\"card-stacked\">";
                            incomplete += "<div class=\"card-content black-text\">";
                            incomplete += "<span class=\"card-title bold trunctext\">" + task.Title.ToString();
                            incomplete += "</span>";

                            incomplete += "</div>";
                            incomplete += "</div>";
                            incomplete += "</div>";
                            incomplete += "</div>";
                            incomplete += "</a>";
                        }
                        else
                        {
                            findata.inserttask(task.Title, "0", "1", task.Id, user.getID());
                            incomplete += "<a href=\"Taskedit.aspx?id=" + task.Id + "\">";
                            incomplete += "<div class=\"col s12 m3 l3\">";
                            // incomplete += "<div class=\"card horizontal hoverable " + colorchoice(Convert.ToInt32((string)storedtask[4])) + " href=\"Taskedit" + "?id=" + task.Id + "\">";
                            incomplete += "<div class=\"card  hoverable green\">";
                            incomplete += "<div class=\"card-stacked\">";
                            incomplete += "<div class=\"card-content black-text\">";
                            incomplete += "<span class=\"card-title trunctext\">" + task.Title.ToString();
                            incomplete += "</span>";

                            incomplete += "</div>";
                            incomplete += "</div>";
                            incomplete += "</div>";
                            incomplete += "</div>";

                            incomplete += "</a>";
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("No task lists found.");
            }


            // List task lists.

            //Console.Read();
            incomplete += "</div>";
            complete   += "</div>";
            taskinprogress.InnerHtml = incomplete;
            completedtask.InnerHtml  = complete;
            findata.Close();
        }