示例#1
0
        //*** Upload File Button
        protected async void Uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)
        {
            //*** Construct Parent Folder + File Path String
            string strUploadedFilePath = "";

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

            //*** Upload File to DropBox Function
            bool blnUploadResult = await DropBoxConnector.Upload(Application["dropBoxClientObj"], strUploadedFilePath, args[0].OpenStream());

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

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

                //*** Exit from function
                return;
            }
            else   //**** Success
            {
                //*** Rebind Data Grid Again
                DropBoxGridDataBind(((List <string>)Session["FolderPath"]));
            }
        }
示例#2
0
        //*** Upload File Button
        protected async void Uploader1_UploadCompleted(object sender, UploaderEventArgs[] args)
        {
            //*** Construct Parent Folder + File Path String
            string strUploadedFilePath = "";
            string strFolderName       = "";
            string DocumentGUID        = "";

            if ((List <string>)Session["FolderPath"] != null)
            {
                foreach (var item in (List <string>)Session["FolderPath"])
                {
                    strUploadedFilePath += "/" + item;
                    strFolderName        = item;
                }
            }
            strUploadedFilePath += "/" + args[0].FileName;

            //*** Upload File to DropBox Function
            bool blnUploadResult = await DropBoxConnector.Upload(Application["dropBoxClientObj"], strUploadedFilePath, args[0].OpenStream());

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

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

                //*** Exit from function
                return;
            }
            else   //**** Success
            {
                //****************************************************************
                //**** 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();
                    }

                    DocumentGUID = objExactOnlineConnector.CreateDocumentWithAttachment(args[0].FileName, Session["CurrentExactFolderGUID"].ToString(), Common.ConvertStreamtoByteArr(args[0].OpenStream()));
                    if (DocumentGUID == "")
                    {
                        //*** If Error returned
                        lblExactOnlineMsg.Text = objExactOnlineConnector.MsgError;

                        //*** Show Error
                        divExactOnlineAlert.Visible = true;
                    }
                    else
                    {
                        //*** Add Entity to DB
                        FilesDocumentsEntities objFilesDocumentsEntities = new FilesDocumentsEntities();

                        //*** Check First if File Already exisit into DB
                        DropBoxExactOnline objRecord = objFilesDocumentsEntities.DropBoxExactOnlines.Where(i => i.DropBoxPath == strUploadedFilePath).FirstOrDefault();
                        if (objRecord != null)
                        {
                            //**** Update DB
                            objRecord.DropBoxPath     = strUploadedFilePath;
                            objRecord.ExactOnlineGUID = DocumentGUID;
                            objRecord.isFile          = 1;

                            objFilesDocumentsEntities.SaveChanges();
                        }
                        else
                        {
                            //*** add to DB
                            DropBoxExactOnline objRecordNew = new DropBoxExactOnline();
                            objRecordNew.DropBoxPath     = strUploadedFilePath;
                            objRecordNew.ExactOnlineGUID = DocumentGUID;
                            objRecordNew.isFile          = 1;

                            objFilesDocumentsEntities.DropBoxExactOnlines.Add(objRecordNew);
                            objFilesDocumentsEntities.SaveChanges();
                        }
                    }
                }
                //***************************************************************************

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