public int ReadThreadData() { RscStore store = new RscStore(); store.CreateFolderPath(AppLogic.csSecretsFolder); string sPath = AppLogic.csSecretsFolder + "\\" + "client_secret.json"; bool bNotExists = false; string sJSon = store.ReadTextFile(sPath, "", out bNotExists); if (bNotExists) { return(-2); } string sErr = ""; RscJSonItem json = RscJSon.FromResponseContetn(sJSon, out sErr); if (sErr.Length > 0) { //Try to get values needed... //return -3; } m_sUserIDlast = store.ReadTextFile(AppLogic.csSecretsFolder + "\\" + "UserIDlast.txt", ""); if (m_sUserIDlast.Length == 0) { return(-3); } // // // //if( gAuth == null ) //{ RscGoogleAuth gAuth = new RscGoogleAuth(json, RscGoogleScopes.UserinfoEmail + " " + RscGoogleScopes.UserinfoProfile + " " + RscGoogleScopes.Gmail, null); //webBrowser1 ); gAuth.Authenticated += new EventHandler(m_gAuth_Authenticated); gAuth.AuthenticationFailed += new EventHandler(m_gAuth_AuthenticationFailed); gAuth.ShowAuthPage += new EventHandler(m_gAuth_ShowAuthPage); gAuth.ResponseReceived += new Ressive.GoogleApi.RscGoogleAuth.ResponseReceived_EventHandler(m_gAuth_ResponseReceived); //bool bNotExists; gAuth.AuthResult = LoadAuthResult(out bNotExists); if (bNotExists) { return(-4); } //} // // // string sUriResource = ""; string sBaseUrl = GoogleUtils.GoogleRequestBaseUrl(GoogleRequest.GMail_Threads, out sUriResource, "me", ""); if (sBaseUrl.Length == 0) { return(-5); } /* * Object oRes = null; * var taskHlp = Task.Run(async () => { oRes = await m_gAuth.SendRequestTask( sBaseUrl, sUriResource ); }); * taskHlp.Wait(); * * if( oRes == null ) * return -6; * else * return oRes.ToString().Length; */ //Task<Object> tsk = gAuth.SendRequestTask( sBaseUrl, sUriResource ); //tsk.Wait(); /* * int iRet = 0; * var taskHlp = Task.Run(async () => { iRet = await SendRequestTask( gAuth, sBaseUrl, sUriResource ); }); * taskHlp.Wait(); */ /* * Task<Object> tsk = gAuth.SendRequestTask( sBaseUrl, sUriResource ); * for(;;) * { * if( tsk.IsCompleted ) * break; * * //System.Threading.Tasks.Task.Delay(100).Wait(); * * MessageBox.Show( "Not complete..." ); * } */ try { gAuth.SendRequest(sBaseUrl, sUriResource); } catch (Exception) { return(-6); } return(0); }
private void DoExpCol(object sender) { Button btn = (Button)sender; TreeLbItem ti = (TreeLbItem)btn.Tag; if (ti.gr == GoogleRequest.None && (!ti.HasResponse)) { return; //Nothing to load... } if (ti.Expanded) { ti.Collapse(); } else { if (ti.HasResponse) { ti.Expand(); } else { if (m_tiLoading != null) { MessageBox.Show("Load in progress!\n\nPlease wait..."); return; } string id = ""; if (ti.Parameters != null) { id = ti.Parameters.GetPropertyValue("id"); } string sUriResource = ""; string sBaseUrl = GoogleUtils.GoogleRequestBaseUrl(ti.gr, out sUriResource, "me", id); if (sBaseUrl.Length == 0) { MessageBox.Show("No Request Url found!"); return; } bool bLoadedFromFile = false; if (m_sUserIDlast.Length > 0) { string sPath = csSecretsFolder + "\\" + m_sUserIDlast; RscStore store = new RscStore(); store.CreateFolderPath(sPath); string sFn = Uri2FileName(sBaseUrl + sUriResource); bool bTmp; string sJSon = store.ReadTextFile(sPath + "\\" + sFn + ".json", "", out bTmp); if (sJSon.Length > 0) { DoLoad(ti, sJSon, sBaseUrl + sUriResource, "", false); m_btnCleanUp.Visibility = Rsc.Visible; bLoadedFromFile = true; } } if (!bLoadedFromFile) { m_tiLoading = ti; m_tiLoading.Loading = true; //VERY SLOW!!! //m_aTI.Refresh(); m_gAuth.SendRequest(sBaseUrl, sUriResource); } } } }
private void DoExpColItem(TreeLbItem ti) { if (ti.gr == GoogleRequest.None && (!ti.HasResponse)) { if (ti.Expanded) { ti.Collapse(); } else if (!ti.IsLeaf && !ti.IsDetailsOnly) { if (ti.sID == csVerUp) { if (m_tiLoading != null) { MessageBox.Show("Load in progress!\n\nPlease wait..."); return; } m_tiLoading = ti; m_tiLoading.Loading = true; m_AppFrame.StartTimer(csVerUp, LayoutRoot, 1, 0, false); } else if (ti.sID == csMoreItems) { int iStartIndex = Int32.Parse(ti.sHistoryID); string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast; ShowSavedThreadData(sPath, iStartIndex, ti); } else { ti.Expand(); } } return; //Nothing to load... } if (ti.Expanded) { ti.Collapse(); } else { if (ti.HasResponse) { ti.Expand(); } else { if (m_tiLoading != null) { MessageBox.Show("Load in progress!\n\nPlease wait..."); return; } string id = ""; if (ti.Parameters != null) { id = ti.Parameters.GetPropertyValue("id"); } string sUriResource = ""; string sBaseUrl = GoogleUtils.GoogleRequestBaseUrl(ti.gr, out sUriResource, "me", id); if (sBaseUrl.Length == 0) { MessageBox.Show("No Request Url found!"); return; } bool bLoadedFromFile = false; if (m_sUserIDlast.Length > 0) { if (ti.gr != GoogleRequest.GMail_Threads) { string sPath = AppLogic.csSecretsFolder + "\\" + m_sUserIDlast; RscStore store = new RscStore(); store.CreateFolderPath(sPath); string sFn = Uri2FileName(sBaseUrl + sUriResource); bool bTmp; string sJSon = store.ReadTextFile(sPath + "\\" + sFn + ".json", "", out bTmp); if (sJSon.Length > 0) { bool bTmp2; DoLoad(ti, sJSon, sBaseUrl + sUriResource, "", false, out bTmp2); m_btnCleanUp.Visibility = Rsc.Visible; bLoadedFromFile = true; } } } if (!bLoadedFromFile) { if (ti.gr == GoogleRequest.GMail_Threads) { m_tiSum = null; m_aTI.RemoveAll(ti); } m_tiLoading = ti; m_tiLoading.Loading = true; //VERY SLOW!!! //m_aTI.Refresh(); m_gAuth.SendRequest(sBaseUrl, sUriResource); } } } }