//**** Create Folder Button protected async void btnPanel2Yes_Click(object sender, EventArgs e) { //*** Check First if Folder Exist/ Fitsh foreach (GridViewRow row in grdVWFilesFolderList.Rows) { if (((Label)row.FindControl("lblFileName")).Text.ToLower() == txtFolderName.Text.ToLower() && bool.Parse(((Label)row.FindControl("lblisFolder")).Text.ToLower())) { //*** Folder Already Exist lblDropBoxMsg.Text = "Folder already exists with same name"; //*** Show Error with grid divDropBoxAlert.Visible = true; divFileGrid.Visible = true; //*** Exit from function return; } } //*** Construct Parent Folder Path String string strFolderpath = ""; if ((List <string>)Session["FolderPath"] != null) { foreach (var item in (List <string>)Session["FolderPath"]) { strFolderpath += "/" + item; } } strFolderpath += "/" + txtFolderName.Text; //*** Create Folder Function bool fnResult = await DropBoxConnector.CreateFolder(Application["dropBoxClientObj"], strFolderpath); if (!fnResult) //*** If error { lblDropBoxMsg.Text = DropBoxConnector.MsgError; //*** Show Error divDropBoxAlert.Visible = true; } else { //*** Success & Rebind Data Grid Again & Initialize txtFolderName.Text = ""; DropBoxGridDataBind(((List <string>)Session["FolderPath"])); } }
//**** Create Folder Button protected async void btnPanel2Yes_Click(object sender, EventArgs e) { //*** Check First if Folder Exist/ Fitsh foreach (GridViewRow row in grdVWDropBoxFilesFolderList.Rows) { if (((Label)row.FindControl("lblFileName")).Text.ToLower() == txtFolderName.Text.ToLower() && bool.Parse(((Label)row.FindControl("lblisFolder")).Text.ToLower())) { //*** Folder Already Exist lblDropBoxMsg.Text = "Folder already exists with same name"; //*** Show Error with grid divDropBoxAlert.Visible = true; DivDropBoxFileGrid.Visible = true; //*** Exit from function return; } } //*** Construct Parent Folder Path String string strFolderpath = ""; string strFolderName = ""; if ((List <string>)Session["FolderPath"] != null) { foreach (var item in (List <string>)Session["FolderPath"]) { strFolderpath += "/" + item; strFolderName = item; } } strFolderpath += "/" + txtFolderName.Text; //*** Create Folder Function bool fnResult = await DropBoxConnector.CreateFolder(Application["dropBoxClientObj"], strFolderpath); if (!fnResult) //*** If error { lblDropBoxMsg.Text = DropBoxConnector.MsgError; //*** Show Error divDropBoxAlert.Visible = true; } else { //**************************************************************** //**** Exact Online Part //**************************************************************** if (divExactOnlineFileGrid.Visible) //**** If Exact Online Grid Shown { //*** Create Folder on Exact Online also //**** Construct Exact Online Class ExactOnlineConnector objExactOnlineConnector = new ExactOnlineConnector(System.Configuration.ConfigurationManager.AppSettings["exactOnlineClientId"], System.Configuration.ConfigurationManager.AppSettings["exactOnlineClientSecret"], System.Configuration.ConfigurationManager.AppSettings["exactOnlineEndPoint"], new Uri(HttpContext.Current.Session["exactOnlineReturnBackURL"].ToString()), Session["ExactOnlineReturnCode"].ToString()); if (Application["ExactOnlineAccessToken"] != null) { objExactOnlineConnector.AccessToken = Application["ExactOnlineAccessToken"].ToString(); } string strFolderGUID = objExactOnlineConnector.CreateDocumentFolder(txtFolderName.Text, Session["CurrentExactFolderGUID"].ToString()); if (strFolderGUID == "") { //*** If Error returned lblExactOnlineMsg.Text = objExactOnlineConnector.MsgError; //*** Show Error divExactOnlineAlert.Visible = true; } else //*** Add Entry To DB { FilesDocumentsEntities objFilesDocumentsEntities = new FilesDocumentsEntities(); DropBoxExactOnline objRecord = new DropBoxExactOnline(); objRecord.DropBoxPath = strFolderpath; objRecord.ExactOnlineGUID = strFolderGUID; objRecord.isFile = 0; objFilesDocumentsEntities.DropBoxExactOnlines.Add(objRecord); objFilesDocumentsEntities.SaveChanges(); } } //*************************************************************************** //*** Success & Rebind Data Grid Again & Initialize txtFolderName.Text = ""; DropBoxGridDataBind(((List <string>)Session["FolderPath"])); } }