Exemplo n.º 1
0
        /// <summary>
        /// code in this section written by Joy
        /// this method fires by the timer before uploading the mail items
        /// </summary>
        /// <param name="ClipboardContent"></param>
        /// <param name="Target"></param>
        /// <param name="Cancel"></param>
        void addinExplorer_beforeMovingToMappedFolder(object ClipboardContent, Microsoft.Office.Interop.Outlook.MAPIFolder Target, bool Cancel)
        {
            if (isTimerUploadRunning == false && isuploadRunning == false)
            {
                try
                {

                    AddfFolderinSessionMapi();

                    IsUrlIsTyped = false;
                    currentFolderSelected = Target.Name;
                    currentFolderSelectedGuid = Target.EntryID;

                    myTargetFolder = Target;
                    if (IsUploadingFormIsOpen == true)
                    {
                        if (Globals.ThisAddIn.frmlistObject != null)
                        {
                            Globals.ThisAddIn.frmlistObject.Invoke(new progressUpdater(()=>
                                 {
                            frmlistObject.progressBar1.Value = frmlistObject.progressBar1.Minimum;
                            frmlistObject.lblPRStatus.Text = "";
                                 }));
                        }

                        //frmMessageWindow objMessage = new frmMessageWindow();
                        //objMessage.DisplayMessage = "Please check the uploading form. Form is still open.";
                        //objMessage.TopLevel = true;
                        //objMessage.TopMost = true;
                        //objMessage.ShowDialog();
                        //objMessage.Dispose();
                        ////EncodingAndDecoding.ShowMessageBox("", "Please check the uploading form. Form is still open.", MessageBoxIcon.Warning);
                        //Cancel = true;
                        //return;

                    }

                    //Check  dropping item is from browser or not

                    if (ClipboardContent.GetType().Name == "String")
                    {
                        //Set active folder as TargetFolder
                        this.Application.ActiveExplorer().SelectFolder(Target);

                        //'Cerate instance
                        frmSPSiteConfigurationObject = new frmSPSiteConfiguration();
                        //Get the drop url

                        frmSPSiteConfigurationObject.URL = Convert.ToString(ClipboardContent);

                        frmSPSiteConfigurationObject.ShowDialog();
                        if (frmSPSiteConfigurationObject.IsConfigureCompleted)
                        {
                            //Save the details in log proeprties object
                            XMLLogProperties xLogProperties = frmSPSiteConfigurationObject.FolderConfigProperties;

                            Outlook.MAPIFolder newFolder = null;
                            bool result = CreateFolderInOutLookSideMenu(xLogProperties.DisplayFolderName, xLogProperties.SiteURL, out newFolder, Target);

                            Cancel = true;
                            if (result == true && newFolder != null)
                            {

                                //Set new folder location
                                xLogProperties.OutlookFolderLocation = newFolder.FolderPath;
                                //Create node in xml file
                                UserLogManagerUtility.CreateXMLFileForStoringUserCredentials(xLogProperties);

                                MAPIFolderWrapper omapi = null;
                                if (string.IsNullOrEmpty(xLogProperties.DocumentLibraryName) == true)
                                {
                                    //Doc name is empty means Folder is not mapped with Doc Lib
                                    omapi = new MAPIFolderWrapper(ref  newFolder, addinExplorer, false);
                                }
                                else
                                {
                                    omapi = new MAPIFolderWrapper(ref newFolder, addinExplorer, true);
                                }
                                omapi.AttachedFolder.WebViewURL = ListWebClass.WebViewUrl(omapi.AttachedFolder.WebViewURL);
                                myFolders.Add(omapi);

                            }

                        }
                        else
                        {
                            frmSPSiteConfigurationObject.Close();
                            Cancel = true;
                        }
                    }
                    else
                    {

                    }
                }
                catch (Exception ex)
                {
                    EncodingAndDecoding.ShowMessageBox("BeforeItemPaste", ex.Message, MessageBoxIcon.Error);
                }
                finally
                {

                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// <c>addinExplorer_BeforeItemPaste</c> Event Handler
        /// Fires when any item is dragged and dropped to an outlook Folder
        /// </summary>
        /// <param name="ClipboardContent"></param>
        /// <param name="Target"></param>
        /// <param name="Cancel"></param>
        void addinExplorer_BeforeItemPaste(ref object ClipboardContent, Microsoft.Office.Interop.Outlook.MAPIFolder Target, ref bool Cancel)
        {
            ///code written by Joy///
              ///checks if any upload is running
            if (isuploadRunning == true||isTimerUploadRunning==true||isMoveRunning==true||isCopyRunninng==true)
            {
                frmMessageWindow objMessage = new frmMessageWindow();
                objMessage.DisplayMessage = "Your uploads are still running.Please wait for sometime.";
                objMessage.TopLevel = true;
                objMessage.TopMost = true;
                objMessage.ShowDialog();
                objMessage.Dispose();
                //EncodingAndDecoding.ShowMessageBox("", "Please check the uploading form. Form is still open.", MessageBoxIcon.Warning);
                Cancel = true;
                return;

            }
            else
            {
                try
                {
                    ///all code in this section written by joy
                    ///retrieves the mail items from the Selection and set the progressbar value to default

                    Outlook.MailItem mailitem;
                    no_of_items_copied = 0;

                    Outlook.Application myApplication = Globals.ThisAddIn.Application;
                    Outlook.Explorer myActiveExplorer = (Outlook.Explorer)myApplication.ActiveExplorer();

                    ///retrieves the mail items from the Selection
                    oselection = myActiveExplorer.Selection;

                    no_of_items_to_be_uploaded = oselection.Count;

                    AddfFolderinSessionMapi();

                    IsUrlIsTyped = false;
                    currentFolderSelected = Target.Name;
                    currentFolderSelectedGuid = Target.EntryID;

                    myTargetFolder = Target;

                    if (IsUploadingFormIsOpen == true)
                    {
                        if (Globals.ThisAddIn.frmlistObject != null)
                        {
                            ///set the progressbar value to default
                            frmlistObject.progressBar1.Value = frmlistObject.progressBar1.Minimum;
                            frmlistObject.lblPRStatus.Text = "";
                        }
                        //frmUploadItemsList frmUplList = new frmUploadItemsList();
                        //frmUplList.progressBar1.Value = frmUplList.progressBar1.Minimum;
                        //frmUplList.lblPRStatus.Text = "";
                        //frmUplList.Refresh();
                        //frmUplList.Visible = false;
                        //frmUplList.Dispose();

                    }

                    //Check  dropping item is from browser or not

                    if (ClipboardContent.GetType().Name == "String")
                    {
                        //Set active folder as TargetFolder
                        this.Application.ActiveExplorer().SelectFolder(Target);

                        //'Cerate instance
                        frmSPSiteConfigurationObject = new frmSPSiteConfiguration();
                        //Get the drop url

                        frmSPSiteConfigurationObject.URL = Convert.ToString(ClipboardContent);

                        frmSPSiteConfigurationObject.ShowDialog();
                        if (frmSPSiteConfigurationObject.IsConfigureCompleted)
                        {
                            //Save the details in log proeprties object
                            XMLLogProperties xLogProperties = frmSPSiteConfigurationObject.FolderConfigProperties;

                            Outlook.MAPIFolder newFolder = null;
                            bool result = CreateFolderInOutLookSideMenu(xLogProperties.DisplayFolderName, xLogProperties.SiteURL, out newFolder, Target);

                            Cancel = true;
                            if (result == true && newFolder != null)
                            {

                                //Set new folder location
                                xLogProperties.OutlookFolderLocation = newFolder.FolderPath;
                                //Create node in xml file
                                UserLogManagerUtility.CreateXMLFileForStoringUserCredentials(xLogProperties);

                                MAPIFolderWrapper omapi = null;
                                if (string.IsNullOrEmpty(xLogProperties.DocumentLibraryName) == true)
                                {
                                    //Doc name is empty means Folder is not mapped with Doc Lib
                                    omapi = new MAPIFolderWrapper(ref  newFolder, addinExplorer, false);
                                }
                                else
                                {
                                    omapi = new MAPIFolderWrapper(ref newFolder, addinExplorer, true);
                                }
                                omapi.AttachedFolder.WebViewURL = ListWebClass.WebViewUrl(omapi.AttachedFolder.WebViewURL);
                                myFolders.Add(omapi);

                            }

                        }
                        else
                        {
                            frmSPSiteConfigurationObject.Close();
                            Cancel = true;
                        }
                    }
                    else
                    {

                    }
                }
                catch (Exception ex)
                {
                    EncodingAndDecoding.ShowMessageBox("BeforeItemPaste", ex.Message, MessageBoxIcon.Error);
                }
                finally
                {

                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// <c>oMailRootFolders_FolderChange</c> Outlook Event
        /// this event is executed when any outlook folder is moved  to another  location or deleted
        /// </summary>
        /// <param name="folder"></param>
        void oMailRootFolders_FolderChange(Microsoft.Office.Interop.Outlook.MAPIFolder folder)
        {
            try
            {
                string f = folder.EntryID.ToString();
                string oldvalue = currentFolderSelected;
                string currentfolder = currentFolderSelectedGuid;
                AddfFolderinSessionMapi();
                MAPIFolderWrapper folderWrapper = myFolders.Find(delegate(MAPIFolderWrapper p) { return p.FolderName == oldvalue; });
                if (folderWrapper != null && !string.IsNullOrEmpty(folder.WebViewURL))
                {
                    if (currentFolderSelectedGuid.Contains(folder.EntryID))
                    {
                        UserLogManagerUtility.UpdateFolderConfigNodeDetails(oldvalue, "DisplayName", folder.Name);
                        MAPIFolderWrapper omapi = null;
                        //Doc name is empty means Folder is not mapped with Doc Lib
                        //omapi = new MAPIFolderWrapper(oChildFolder, addinExplorer, false);
                        if (oldvalue != folder.Name)
                        {
                            omapi = new MAPIFolderWrapper(ref  folder, this.Application.ActiveExplorer(), UserLogManagerUtility.IsDocumentLibrary(folder.Name));
                            try
                            {
                                foreach (MAPIFolderWrapper item in myFolders)
                                {
                                    if (item.FolderName == oldvalue)
                                    {
                                        Boolean result = myFolders.Remove(item);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }

                            omapi.AttachedFolder.WebViewURL = UserLogManagerUtility.GetSPSiteURL(folder.Name);
                            myFolders.Add(omapi);
                        }
                    }

                }

            }
            catch (Exception ex)
            {
            }
            updatefolderlocationin();
        }
Exemplo n.º 4
0
        /// <summary>
        /// <c>ReConnection</c> member function
        /// this function recreates the deleted  folder in outlook 
        /// </summary>
        /// <param name="xLogProperties"></param>
        /// <param name="parentfolder"></param>
        /// <returns></returns>
        public bool ReConnection(XMLLogProperties xLogProperties, Outlook.MAPIFolder parentfolder)
        {
            bool result = false;
            try
            {

                Outlook.MAPIFolder newFolder = null;
                ////////////////////////updated by Joy on 25.07.2012/////////////////
                Outlook.MAPIFolder newBrokenUploadsFolder = null;
                ////////////////////////updated by Joy on 25.07.2012/////////////////
                //outlookObj = new Outlook.Application();
                OutlookObj = Globals.ThisAddIn.Application;

                //Gte MAPI Name space
                outlookNameSpace = OutlookObj.GetNamespace("MAPI");
                Outlook.MAPIFolder olInboxFolder = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

                Outlook.MAPIFolder Target = parentfolder;

                bool created = CreateFolderInOutLookSideMenu(xLogProperties.DisplayFolderName, xLogProperties.SiteURL, out newFolder, Target);

                if (created == true && newFolder != null)
                {

                    //Set new folder location
                    xLogProperties.OutlookFolderLocation = newFolder.FolderPath;
                    //Create node in xml file
                    //  UserLogManagerUtility.CreateXMLFileForStoringUserCredentials(xLogProperties);

                    MAPIFolderWrapper omapi = null;
                    if (string.IsNullOrEmpty(xLogProperties.DocumentLibraryName) == true)
                    {
                        //Doc name is empty means Folder is not mapped with Doc Lib
                        omapi = new MAPIFolderWrapper(ref  newFolder, addinExplorer, false);
                    }
                    else
                    {
                        omapi = new MAPIFolderWrapper(ref newFolder, addinExplorer, true);
                    }

                    newFolders.Add(omapi);

                }

            }
            catch (Exception ex)
            {

            }
            return result;
        }
Exemplo n.º 5
0
        private void CreateDefaultAddEventOnFolders()
        {
            Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            Outlook.MAPIFolder parentFolder = (Outlook.MAPIFolder)myTargetFolder; //oInBox.Parent;
            //Get all the folder information
            XmlNodeList xFolders = UserLogManagerUtility.GetDefaultFoldersDetails(UserStatus.Active);
            if (xFolders != null)
            {
                string folderName = string.Empty, DocLibName = string.Empty;
                if (addinExplorer == null)
                {
                    MessageBox.Show("In Main Forms");
                }

                foreach (XmlNode xNode in xFolders)
                {
                    try
                    {
                        folderName = xNode.ChildNodes[2].InnerText;
                        //Get Doc Lib Name
                        DocLibName = xNode.ChildNodes[3].InnerText;

                        Outlook.MAPIFolder oChildFolder = MAPIFolderWrapper.GetFolder(parentFolder, folderName); // parentFolder.Folders[folderName];

                        if (oChildFolder != null && oChildFolder.Name == folderName)
                        {

                            MAPIFolderWrapper omapi = null;
                            if (string.IsNullOrEmpty(DocLibName) == true)
                            {
                                //Doc name is empty means Folder is not mapped with Doc Lib
                                //omapi = new MAPIFolderWrapper(oChildFolder, addinExplorer, false);
                                omapi = new MAPIFolderWrapper(ref  oChildFolder, this.Application.ActiveExplorer(), false);

                            }
                            else
                            {
                                omapi = new MAPIFolderWrapper(ref  oChildFolder, this.Application.ActiveExplorer(), true);
                                //omapi = new MAPIFolderWrapper(oChildFolder, addinExplorer, true);

                            }

                            //
                            string returl = UserLogManagerUtility.GetSPSiteURL(omapi.AttachedFolder.Name);
                            //string relativepath = UserLogManagerUtility.GetRelativePath(omapi.AttachedFolder.Name);
                            //string rootpath = "";
                            //if (returl.LastIndexOf(relativepath)!=-1)
                            //{
                            //    rootpath = returl.Remove(returl.LastIndexOf(relativepath));
                            //}
                            // string virtualpath = ListWebClass.WebViewUrl(returl);

                            //  omapi.AttachedFolder.WebViewURL = rootpath + "/_layouts/OutlookIntegration/DisplayImage.aspx?Action=OLIssue&ReturnUrl=" + returl;
                            omapi.AttachedFolder.WebViewURL = ListWebClass.WebViewUrl(returl);
                            //
                            myFolders.Add(omapi);

                        }
                        else
                        {
                            //create mapi folder

                            XMLLogProperties xLogProperties = new XMLLogProperties();
                            xLogProperties.UserName = EncodingAndDecoding.Base64Decode(xNode.ChildNodes[0].InnerText);
                            xLogProperties.Password = EncodingAndDecoding.Base64Decode(xNode.ChildNodes[1].InnerText);
                            xLogProperties.DisplayFolderName = folderName;
                            xLogProperties.SiteURL = xNode.ChildNodes[4].InnerText;

                            xLogProperties.UsersStatus = UserStatus.Active;
                            xLogProperties.DocumentLibraryName = xNode.ChildNodes[3].InnerText;
                            xLogProperties.DroppedURLType = "";

                            if (xNode.ChildNodes[5].InnerText == "Manually Specified")
                            {
                                xLogProperties.FolderAuthenticationType = AuthenticationType.Manual;
                            }
                            else
                            {
                                xLogProperties.FolderAuthenticationType = AuthenticationType.Domain;

                            }

                            xLogProperties.SPSiteVersion = SPVersionClass.GetSPVersionFromUrl(xLogProperties.SiteURL, xLogProperties.UserName, xLogProperties.Password, xLogProperties.FolderAuthenticationType);
                            Microsoft.Office.Interop.Outlook.Application outlookObj = Globals.ThisAddIn.Application;
                            //Gte MAPI Name space
                            Microsoft.Office.Interop.Outlook.NameSpace outlookNameSpac = outlookObj.GetNamespace("MAPI");

                            oInBox = outlookNameSpac.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                            parentFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)oInBox.Parent;
                            Microsoft.Office.Interop.Outlook.MAPIFolder f = MAPIFolderWrapper.GetFolder(parentFolder, folderName);
                            frmConnectionProperties frmconnection = new frmConnectionProperties();
                            if (parentFolder.Name.Trim() != folderName.Trim())
                            {
                                if (f.Name.Trim() != parentFolder.Name.Trim())
                                {
                                    if (f != null)
                                    {

                                        f.WebViewURL = frmSPSiteConfigurationObject.URL;
                                        if (f.FolderPath.Contains("\\Deleted Items\\"))
                                        {
                                            try
                                            {
                                                f.Delete();
                                            }
                                            catch (Exception)
                                            {

                                            }
                                            frmconnection.CreateFolder(folderName, xLogProperties);
                                        }
                                    }
                                }
                                else
                                {
                                    frmconnection.CreateFolder(folderName, xLogProperties);
                                }
                            }
                        }
                    }
                    catch (Exception ex) { }
                }

            }
        }