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(); }