Esempio n. 1
0
 private void SharePointExplorerPane_Load(object sender, EventArgs e)
 {
     try
     {
         if (EUSettingsManager.GetInstance().Settings == null)
         {
             MessageBox.Show("You need to configure settings first.");
             SettingsForm settingsControl = new SettingsForm();
             settingsControl.ShowDialog();
         }
         this.SPFoldersTreeView.Initialize(Application);
         this.sharePointListViewControl.Initialize(Application);
         List <EUTreeNode> euNodes = EUSettingsManager.GetInstance().LoadSPTreeview();
         if (euNodes == null)
         {
             SPFoldersTreeView.ClearAllNodes();
         }
         else
         {
             SPFoldersTreeView.FillNodes(euNodes);
             SPFoldersTreeView.ExpandNodes(euNodes);
         }
         socActionBar1.Application = Application;
     }
     catch (System.Exception ex)
     {
         LogManager.Log("An error occured:" + ex.Message, EULogModes.Normal);
         MessageBox.Show("An error occured:" + ex.Message);
     }
 }
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     if (Settings == null)
     {
         Settings = EUSettingsManager.GetInstance().Settings;
     }
     if (Settings == null)
     {
         Settings = new EUSettings();
         return;
     }
     if (Settings.SaveAsWord == true)
     {
         WordPlusAttachmentsRadioButton.Checked = true;
     }
     else
     {
         EmailRadioButton.Checked = true;
     }
     UploadAutomaticallyCheckBox.Checked = Settings.UploadAutomatically;
     DetailedLogCheckBox.Checked         = Settings.DetailedLogMode;
     LoadListSettings();
     LoadSites();
     if (SelectedListSetting == null)
     {
         EmailMappingControl.BindEmailMapping(Settings.DefaultListSetting);
     }
     else
     {
         EmailMappingControl.BindEmailMapping(SelectedListSetting);
         EmailMappingSettingsComboBox.SelectedItem = SelectedListSetting;
         SettingsTabControl.SelectedTab            = ListSettingTabPage;
     }
 }
        public void SetSelectedListSetting(string webURL, string rootFolderPath, string listName)
        {
            Settings = EUSettingsManager.GetInstance().Settings;
            if (Settings == null)
            {
                Settings = new EUSettings();
            }
            EUListSetting listSetting = null;

            foreach (EUListSetting tempListSetting in Settings.ListSettings)
            {
                if (tempListSetting.RootFolderPath == rootFolderPath)
                {
                    listSetting = tempListSetting;
                }
            }
            if (listSetting == null)
            {
                listSetting = new EUListSetting();
                listSetting.RootFolderPath = rootFolderPath;
                listSetting.WebURL         = webURL;
                listSetting.ListName       = listName;
                Settings.ListSettings.Add(listSetting);
            }
            EmailMappingControl.BindEmailMapping(listSetting);
            SelectedListSetting = listSetting;
        }
 private void OkButton_Click(object sender, EventArgs e)
 {
     Settings.UploadAutomatically = UploadAutomaticallyCheckBox.Checked;
     Settings.SaveAsWord          = WordPlusAttachmentsRadioButton.Checked;
     Settings.DetailedLogMode     = DetailedLogCheckBox.Checked;
     EUSettingsManager.GetInstance().Settings = Settings;
     EUSettingsManager.GetInstance().SaveSettings();
     DialogResult = DialogResult.OK;
 }
Esempio n. 5
0
        private void AttachmentsToSPButton_Click(object sender, RibbonControlEventArgs e)
        {
            Inspector inspector = this.Context as Inspector;

            if (inspector == null)
            {
                throw new System.Exception("This is not an inspector window.");
            }
            Outlook.MailItem mailItem = inspector.CurrentItem as Outlook.MailItem;
            if (mailItem == null)
            {
                throw new System.Exception("This is not a mail item.");
            }

            if (EUSettingsManager.GetInstance().Settings.EmailAttachmentFolderUrl == String.Empty)
            {
                MessageBox.Show("Please set attachments folder first.");
                return;
            }
            string sourceFolder = EUSettingsManager.GetInstance().CreateATempFolder();
            List <EUEmailUploadFile> emailUploadFiles = new List <EUEmailUploadFile>();

            foreach (Attachment attachment in mailItem.Attachments)
            {
                string fileName                 = attachment.FileName;
                string extensionName            = String.Empty;
                string filenameWithoutExtension = String.Empty;
                if (fileName.LastIndexOf(".") > -1)
                {
                    extensionName            = fileName.Substring(fileName.LastIndexOf(".") + 1);
                    filenameWithoutExtension = fileName.Substring(0, fileName.LastIndexOf("."));
                }
                else
                {
                    filenameWithoutExtension = fileName;
                }
                string filePath = SharePointManager.GetUnuqieFileName(sourceFolder, filenameWithoutExtension, extensionName, out fileName);
                attachment.SaveAsFile(filePath);
                emailUploadFiles.Add(new EUEmailUploadFile(filePath, mailItem, null, false));
            }
//            string siteURL = SharePointManager.GetSiteURL(
            UploadAttachmentsProgressForm uploadAttachmentsProgressForm = new UploadAttachmentsProgressForm();
            EUSiteSetting siteSetting = EUSettingsManager.GetInstance().GetSiteSetting(EUSettingsManager.GetInstance().Settings.EmailAttachmentRootWebUrl);
            string        siteURL     = SharePointManager.GetSiteURL(siteSetting.Url, siteSetting);

            uploadAttachmentsProgressForm.Initialize(EUSettingsManager.GetInstance().Settings.EmailAttachmentWebUrl + "/" + EUSettingsManager.GetInstance().Settings.EmailAttachmentFolderUrl.TrimStart(new char[] { '/' }), sourceFolder, siteSetting, EUSettingsManager.GetInstance().Settings.EmailAttachmentRootFolderUrl, siteURL, EUSettingsManager.GetInstance().Settings.EmailAttachmentWebUrl, EUSettingsManager.GetInstance().Settings.EmailAttachmentListName, emailUploadFiles, mailItem);
            uploadAttachmentsProgressForm.ShowDialog();
//            SetSaveAttachmentsToSharePointButton();
        }
        public void InitializeForm(EUFolder folder, EUListItem listItem)
        {
            Folder   = folder;
            ListItem = listItem;

            ListSetting = EUSettingsManager.GetInstance().GetListSetting(folder.WebUrl.TrimEnd(new char[] { '/' }) + "/" + folder.FolderPath.TrimStart(new char[] { '/' }));

            List <EUContentType> contentTypes = SharePointManager.GetContentTypes(folder.SiteSetting, folder.WebUrl, folder.ListName);

            foreach (EUContentType contentType in contentTypes)
            {
                if (contentType.Name.ToLower() != "folder")
                {
                    ContentTypeComboBox.Items.Add(contentType);
                }
            }
            if (ContentTypeComboBox.Items.Count > 0)
            {
                if (listItem != null)
                {
                    for (int i = 0; i < ContentTypeComboBox.Items.Count; i++)
                    {
                        if (listItem.ContentTypeName == ((EUContentType)ContentTypeComboBox.Items[i]).Name)
                        {
                            ContentTypeComboBox.SelectedIndex = i;
                        }
                    }
                }
                if (ContentTypeComboBox.SelectedIndex < 0)
                {
                    ContentTypeComboBox.SelectedIndex = 0;
                }
            }
            EUContentType selectedContentType = (EUContentType)ContentTypeComboBox.SelectedItem;

            if (ContentTypeComboBox.Items.Count == 1)
            {
                SelectedContentTypeLabel.Text     = selectedContentType.Name;
                SelectedContentTypeLabel.Location = new Point(200, SelectedContentTypeLabel.Location.Y);
                ContentTypeComboBox.Visible       = false;
            }
            else
            {
                SelectedContentTypeLabel.Visible = false;
            }
        }
Esempio n. 7
0
 public void ClearAllNodes()
 {
     SPFoldersTreeView.Nodes.Clear();
     if (EUSettingsManager.GetInstance().Settings == null || EUSettingsManager.GetInstance().Settings.SiteSettings == null)
     {
         return;
     }
     foreach (EUSiteSetting siteSetting in EUSettingsManager.GetInstance().Settings.SiteSettings)
     {
         IOutlookConnector connector  = OutlookConnector.GetConnector(siteSetting);
         ISPCFolder        rootFolder = connector.GetRootFolder(siteSetting);
         TreeNode          rootNode   = new TreeNode(siteSetting.ToString());
         rootNode.Tag = rootFolder;
         SPFoldersTreeView.Nodes.Add(rootNode);
         SetTreeNodeImage(rootNode);
         AddLoadingNode(rootNode);
     }
 }
        public static void LogException(string methodName, Exception ex, string additionalMessage)
        {
//            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            string       log         = "An exception occured on Method:" + methodName + Environment.NewLine + " Exception:" + ex.Message + (additionalMessage != ""?Environment.NewLine + " Additional message:":"");
            string       logFilePath = EUSettingsManager.GetInstance().CreateALogFile();
            StreamWriter sw          = new StreamWriter(logFilePath, true);

            try
            {
                sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "  " + log);
            }
            catch (Exception)
            {
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
        public static void Log(string log, EULogModes logMode)
        {
            string       logFilePath = EUSettingsManager.GetInstance().CreateALogFile();
            StreamWriter sw          = new StreamWriter(logFilePath, true);

            try
            {
                if (EUSettingsManager.GetInstance().Settings.DetailedLogMode == true || logMode == EULogModes.Normal)
                {
                    sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "  " + log);
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
Esempio n. 10
0
        private void setAsEmailAttachmentFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SPFoldersTreeView.SelectedNode == null)
            {
                MessageBox.Show("Please select a folder first.");
            }
            object spObject = SPFoldersTreeView.SelectedNode.Tag;

            if (spObject as EUFolder != null || spObject as EUList != null)
            {
                EUFolder folder = (EUFolder)spObject;
                EUSettingsManager.GetInstance().Settings.EmailAttachmentRootFolderUrl = folder.RootFolderPath;
                EUSettingsManager.GetInstance().Settings.EmailAttachmentRootWebUrl = folder.SiteSetting.Url;
                EUSettingsManager.GetInstance().Settings.EmailAttachmentFolderUrl = folder.FolderPath;
                EUSettingsManager.GetInstance().Settings.EmailAttachmentWebUrl = folder.WebUrl;
                EUSettingsManager.GetInstance().Settings.EmailAttachmentListName = folder.ListName;
                EUSettingsManager.GetInstance().SaveSettings();
                MessageBox.Show("You have successfuly saved your email attachment folder.");
            }
            else
            {
                MessageBox.Show("Please select a SharePoint folder first.");
            }
        }
Esempio n. 11
0
 public void DeleteState()
 {
     EUSettingsManager.GetInstance().ClearSharePointTreeViewState();
 }
Esempio n. 12
0
 public void SaveState()
 {
     EUSettingsManager.GetInstance().SaveSharePointTreeViewState(SPFoldersTreeView);
 }
 private void ShowLogsButton_Click(object sender, EventArgs e)
 {
     Process.Start("IExplore.exe", EUSettingsManager.GetInstance().GetLogFolder());
 }