Esempio n. 1
0
        //*** Delete Button
        protected async void lnkbtnDelete_Click(object sender, ImageClickEventArgs e)
        {
            //*** Construct Parent Folder Path String
            string strParentFolderpath = "";

            if ((List <string>)Session["FolderPath"] != null)
            {
                foreach (var item in (List <string>)Session["FolderPath"])
                {
                    strParentFolderpath += "/" + item;
                }
            }

            //*** Loop on Items to see who is checked to delete
            foreach (GridViewRow row in grdVWFilesFolderList.Rows)
            {
                if (((CheckBox)row.FindControl("chkItem")).Checked)
                {
                    string strPath = strParentFolderpath + "/" + ((Label)row.FindControl("lblFileName")).Text;

                    //*** Create Folder Function
                    bool fnResult = await DropBoxConnector.DeleteFileOrFolder(Application["dropBoxClientObj"], strPath);

                    if (!fnResult)    //*** If error
                    {
                        lblDropBoxMsg.Text = DropBoxConnector.MsgError;

                        //*** Show Error
                        divDropBoxAlert.Visible = true;

                        //*** Exit loop function
                        break;
                    }
                }
            }

            //*** Rebind Data Grid Again
            DropBoxGridDataBind(((List <string>)Session["FolderPath"]));
        }
Esempio n. 2
0
        //*** Delete Button
        protected async void lnkbtnDelete_Click(object sender, ImageClickEventArgs e)
        {
            //*** Construct Parent Folder Path String
            string strParentFolderpath = "";
            string strFolderName       = "";
            bool   isFolder            = false;

            if ((List <string>)Session["FolderPath"] != null)
            {
                foreach (var item in (List <string>)Session["FolderPath"])
                {
                    strParentFolderpath += "/" + item;
                }
            }

            //*** Loop on Items to see who is checked to delete
            foreach (GridViewRow row in grdVWDropBoxFilesFolderList.Rows)
            {
                if (((CheckBox)row.FindControl("chkItem")).Checked)
                {
                    //*** Check if file or Folder
                    isFolder = bool.Parse(((Label)row.FindControl("lblisFolder")).Text);

                    string strPath = strParentFolderpath + "/" + ((Label)row.FindControl("lblFileName")).Text;
                    strFolderName = ((Label)row.FindControl("lblFileName")).Text;

                    //*** Create Folder Function
                    bool fnResult = await DropBoxConnector.DeleteFileOrFolder(Application["dropBoxClientObj"], strPath);

                    if (!fnResult)    //*** If error
                    {
                        lblDropBoxMsg.Text = DropBoxConnector.MsgError;

                        //*** Show Error
                        divDropBoxAlert.Visible = true;

                        //*** Exit loop function
                        break;
                    }

                    //****************************************************************
                    //**** Exact Online Part
                    //****************************************************************
                    string strFileFolderGUID = "";
                    if (divExactOnlineFileGrid.Visible)     //**** If Exact Online Grid Shown
                    {
                        //*** 1. Get Folder Guid (If not root)
                        if (strFolderName != "")
                        {
                            //*** Fitch Grid to get GUID
                            foreach (GridViewRow itemRow in grdVWExactOnlineFilesFolderList.Rows)
                            {
                                if (isFolder)   //**** If Folder
                                {
                                    //*** Check if name & Is Folcder
                                    if (bool.Parse(((Label)itemRow.FindControl("lblisFolder")).Text) && ((Label)itemRow.FindControl("lblFileName")).Text.ToLower() == strFolderName.ToLower())
                                    {
                                        strFileFolderGUID = ((Label)itemRow.FindControl("lblFolderID")).Text;
                                        break;
                                    }
                                }
                                else
                                {
                                    //*** Check if name & Is File
                                    if (!bool.Parse(((Label)itemRow.FindControl("lblisFolder")).Text) && ((Label)itemRow.FindControl("lblFileName")).Text.ToLower() == strFolderName.ToLower())
                                    {
                                        strFileFolderGUID = ((Label)itemRow.FindControl("lblFolderID")).Text;
                                        break;
                                    }
                                }
                            }
                        }

                        if (strFileFolderGUID != "")
                        {
                            //*** 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();
                            }

                            if (isFolder)        //*** This is Folder
                            {
                                //*** Call Delete Folder
                                if (!objExactOnlineConnector.DeleteDocumentFolder(strFileFolderGUID))
                                {
                                    //*** If Error returned
                                    lblExactOnlineMsg.Text = objExactOnlineConnector.MsgError;

                                    //*** Show Error
                                    divExactOnlineAlert.Visible = true;
                                }
                            }
                            else  //**** If File
                            {
                                //**** Call Delete Document
                                if (!objExactOnlineConnector.DeleteDocument(strFileFolderGUID))
                                {
                                    //*** If Error returned
                                    lblExactOnlineMsg.Text = objExactOnlineConnector.MsgError;

                                    //*** Show Error
                                    divExactOnlineAlert.Visible = true;
                                }
                            }
                        }
                    }
                    //***************************************************************************

                    //*** Then Delete Records from DB
                    FilesDocumentsEntities objFilesDocumentsEntities = new FilesDocumentsEntities();

                    //*** Check First if File Already exisit into DB
                    DropBoxExactOnline objRecord = objFilesDocumentsEntities.DropBoxExactOnlines.Where(i => i.DropBoxPath == strPath).FirstOrDefault();
                    if (objRecord != null)
                    {
                        objFilesDocumentsEntities.DropBoxExactOnlines.Remove(objRecord);
                        objFilesDocumentsEntities.SaveChanges();
                    }
                }
            }

            //*** Rebind Data Grid Again
            DropBoxGridDataBind(((List <string>)Session["FolderPath"]));
        }