Ejemplo n.º 1
0
        /// <summary>
        /// <c>UpdateFolderConfigrationDetails</c> member function
        /// Method to assign properties to new configration folder
        /// </summary>
        private void UpdateFolderConfigrationDetails(bool checkFolderExists)
        {
            try
            {
                //Check the credentials are have the prmissions or not
                bool isValidCredentials = IsPassedCredentialHasAccess();
                if (isValidCredentials == true)
                {
                    URL = HttpUtility.UrlDecode(txtURL.Text);
                    xLogProperties.SiteURL = URL;
                    //version

                    Boolean isFolderExisted = false;
                    if (checkFolderExists == true)
                    {
                        //Check given folder name already existed or not
                        if (ThisAddIn.IsUrlIsTyped == true)
                        {
                            if (URL.Contains("/Forms/") == true)
                            {
                                string sTemp = URL.Substring(0, URL.IndexOf("/Forms/"));
                                xLogProperties.DocumentLibraryName = sTemp.Substring(sTemp.LastIndexOf("/") + 1);
                                xLogProperties.DroppedURLType = "/" + xLogProperties.DocumentLibraryName + "/Forms/";
                            }
                            else
                            {
                                xLogProperties.DocumentLibraryName = string.Empty;
                                xLogProperties.DroppedURLType = string.Empty;

                            }
                        }
                        else
                        {
                            isFolderExisted = UserLogManagerUtility.IsFolderExisted(txtDisplayName.Text.TrimEnd());
                        }

                    }
                    else
                    {

                        if (URL.Contains("/Forms/") == true)
                        {
                            string sTemp = URL.Substring(0, URL.IndexOf("/Forms/"));
                            xLogProperties.DocumentLibraryName = sTemp.Substring(sTemp.LastIndexOf("/") + 1);
                            xLogProperties.DroppedURLType = "/" + xLogProperties.DocumentLibraryName + "/Forms/";
                        }
                        else
                        {
                            xLogProperties.DocumentLibraryName = string.Empty;
                            xLogProperties.DroppedURLType = string.Empty;

                        }

                    }
                    if (isFolderExisted == false)
                    {

                        IsConfigureCompleted = true;
                        xLogProperties.DisplayFolderName = txtDisplayName.Text;
                        if (rbtnUseDomainCredentials.Checked)
                        {
                            //domain credentials
                            xLogProperties.FolderAuthenticationType = AuthenticationType.Domain;

                        }
                        else
                        {
                            //for manual credentials

                            xLogProperties.FolderAuthenticationType = AuthenticationType.Manual;

                        }
                        xLogProperties.UserName = txtUserName.Text.Trim();
                        xLogProperties.Password = txtPassword.Text.Trim();
                        xLogProperties.SPSiteVersion = SPVersionClass.GetSPVersionFromUrl(URL, xLogProperties.UserName, xLogProperties.Password, xLogProperties.FolderAuthenticationType);

                        if (ThisAddIn.IsUrlIsTyped == true)
                        {
                            ThisAddIn tad = new ThisAddIn();
                            tad.NewConnection(xLogProperties);
                            ThisAddIn.IsUrlIsTyped = false;
                        }

                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Display name is already existed. Please provide another name", "ITOPIA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception ex)
            {
                EncodingAndDecoding.ShowMessageBox("Button OK", ex.Message, MessageBoxIcon.Error);

            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <c>CreateFolder</c> member function
        /// create folder  with provided  folder name and its properties
        /// </summary>
        /// <param name="foldername"></param>
        /// <param name="xMLLogProperties"></param>
        public void CreateFolder(string foldername, XMLLogProperties xMLLogProperties)
        {
            try
            {
                string path = UserLogManagerUtility.GetFolderOutLookLocation(foldername);

                path = path.Remove(0, 2);
                string[] folderpath = path.Split('\\');

                Microsoft.Office.Interop.Outlook.Application outlookObj = Globals.ThisAddIn.Application;
                addinExplorer = outlookObj.ActiveExplorer();

                Microsoft.Office.Interop.Outlook.NameSpace outlookNameSpace = outlookObj.GetNamespace("MAPI");
                Microsoft.Office.Interop.Outlook.MAPIFolder oInBox = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
                Microsoft.Office.Interop.Outlook.MAPIFolder parentFolder = (Microsoft.Office.Interop.Outlook.MAPIFolder)oInBox.Parent;
                foreach (Outlook.Folder item in addinExplorer.Session.Folders)
                {
                    if (item.Name.Trim() == folderpath[0])
                    {
                        parentFolder = item;
                    }
                }
                //Gte MAPI Name space

                for (int i = 1; i < folderpath.Length; i++)
                {

                    Microsoft.Office.Interop.Outlook.MAPIFolder f = MAPIFolderWrapper.GetChildFolder(parentFolder, folderpath[i]);
                    if (f != null)
                    {

                        parentFolder = f;
                    }
                    else
                    {

                        if (i < folderpath.Length - 1)
                        {
                            Outlook.MAPIFolder newfolder;
                            newfolder = parentFolder.Folders.Add(folderpath[i], Type.Missing);
                            parentFolder = newfolder;
                        }
                        else
                        {
                            ThisAddIn tad = new ThisAddIn();

                            tad.ReConnection(xMLLogProperties, parentFolder);
                        }
                    }

                }

            }
            catch (Exception ex)
            {

            }
        }