Ejemplo n.º 1
0
        public EUEmailUploadFile(string filePath, Microsoft.Office.Interop.Outlook.MailItem mailItem, EUFieldInformations fieldInformations, bool isListItemAndAttachment, SaveFormatOverride saveFormatOverride)  // JOEL JEFFERY 20110710 - added safeFormatOverride
        {
            FilePath = filePath;
            MetaData = new EUEmailMetaData(mailItem);
            // JOEL JEFFERY 20110711 -- mailItem == null? surely not?
            if (mailItem == null)
            {
                //Subject = mailItem.Subject;
                //EntryID = mailItem.EntryID;
                //Body = mailItem.Body;
            }
            else
            {
                // JOEL JEFFERY 20110711 -- moved here
                Subject = mailItem.Subject;
                EntryID = mailItem.EntryID;
                Body    = mailItem.Body;
                SentOn  = mailItem.SentOn;
                IsEmail = true;
            }
            //MailItem = mailItem;
            UniqueID                = Guid.NewGuid();
            FieldInformations       = fieldInformations;
            IsListItemAndAttachment = isListItemAndAttachment;

            // JOEL JEFFERY 20110710
            SaveFormatOverride = saveFormatOverride;
        }
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (IsLoaded == false)
            {
                MessageBox.Show("Please wait controls are being loaded...");
                return;
            }
            if (IsValid == true)
            {
                EUFieldInformations fieldInformations = new EUFieldInformations();
                fieldInformations.ContentType = (EUContentType)ContentTypeComboBox.SelectedItem;
                foreach (EditItemControl editItemControl in EditItemControls)
                {
                    EUFieldInformation fieldInfo = new EUFieldInformation();
                    fieldInfo.Id           = editItemControl.Field.ID;
                    fieldInfo.InternalName = editItemControl.Field.Name;
                    fieldInfo.DisplayName  = editItemControl.Field.DisplayName;
                    fieldInfo.Value        = editItemControl.Value;
                    fieldInfo.EmailField   = editItemControl.EmailMappingField;
                    switch (editItemControl.Field.Type)
                    {
                    case EUFieldTypes.Note:
                        fieldInfo.Type = Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.FieldType.Note;
                        break;

                    case EUFieldTypes.Text:
                        fieldInfo.Type  = Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.FieldType.Text;
                        fieldInfo.Value = (editItemControl.Value.Length > editItemControl.Field.MaxLength ? editItemControl.Value.Substring(0, editItemControl.Field.MaxLength) : editItemControl.Value);
                        break;

                    case EUFieldTypes.DateTime:
                        fieldInfo.Type = Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.FieldType.DateTime;
                        break;

                    case EUFieldTypes.Lookup:
                        fieldInfo.Type = Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.FieldType.Lookup;
                        break;

                    case EUFieldTypes.Choice:
                        fieldInfo.Type = Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.FieldType.Choice;
                        break;
                    }
                    fieldInformations.Add(fieldInfo);
                }
                FieldInformations = fieldInformations;
                this.DialogResult = DialogResult.OK;
            }
        }
Ejemplo n.º 3
0
        public void Initialize(ISPCFolder folder, string sourceFolder, List <EUEmailUploadFile> emailUploadFiles, bool isListItemAndAttachmentMode, EUFieldInformations fieldInfoArray)
        {
            // string rootFolderPath, string destinationFolderUrl, string sourceFolder, string webURL, string listName,
            EUFolder _folder = folder as EUFolder;

            _destinationFolderUrl = _folder.WebUrl.TrimEnd(new char[] { '/' }) + "/" + _folder.FolderPath.TrimStart(new char[] { '/' });
            _sourceFolder         = sourceFolder;
            _rootFolderPath       = _folder.RootFolderPath;
            _siteSetting          = _folder.SiteSetting;
            _siteURL  = _folder.SiteUrl;
            _webURL   = _folder.WebUrl;
            _listName = _folder.ListName;
            _isListItemAndAttachmentMode = isListItemAndAttachmentMode;
            _fieldInfoArray            = fieldInfoArray;
            DestinationValueLabel.Text = _destinationFolderUrl;

            foreach (EUEmailUploadFile emailUploadFile in emailUploadFiles)
            {
                string groupID    = String.Empty;
                string groupTitle = String.Empty;
                if (emailUploadFile.IsEmail == false)
                {
                    groupID    = new FileInfo(emailUploadFile.FilePath).Name;
                    groupTitle = groupID;
                }
                else
                {
                    groupID    = emailUploadFile.EntryID;
                    groupTitle = emailUploadFile.MetaData.Subject;
                }

                ListViewGroup listViewGroup = EmailsListView.Groups[groupID];
                if (listViewGroup == null)
                {
                    EmailsListView.Groups.Add(groupID, groupTitle);
                }
            }
            foreach (EUEmailUploadFile emailUploadFile in emailUploadFiles)
            {
                InsertEmailUploadFile(emailUploadFile);
                foreach (EUEmailUploadFile emailUploadFile1 in emailUploadFile.Attachments)
                {
                    InsertEmailUploadFile(emailUploadFile1);
                }
            }
        }
 public void UploadFiles(ISPCFolder folder, List <EUEmailUploadFile> uploadFiles, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
 {
     throw new Exception("Not implemented");
 }
Ejemplo n.º 5
0
 public EUEmailUploadFile(string filePath, Microsoft.Office.Interop.Outlook.MailItem mailItem, EUFieldInformations fieldInformations, bool isListItemAndAttachment)
     : this(filePath, mailItem, null, false, SaveFormatOverride.None)
 {
 }
Ejemplo n.º 6
0
        public static void UploadEmail(SharePointListViewControl listviewControl, ISPCFolder dragedFolder, DragEventArgs e, List <EUEmailUploadFile> emailUploadFiles, bool isListItemAndAttachmentMode)
        {
            try
            {
                EUFieldInformations fieldInformations = null;
                EUFieldCollection   fields            = null;

                UploadProgressForm uploadProgressForm = new UploadProgressForm();
                if (EUSettingsManager.GetInstance().Settings == null)
                {
                    MessageBox.Show("You need to configure settings first.");
                    SettingsForm settingsControl = new SettingsForm();
                    settingsControl.ShowDialog();
                    return;
                }

                if (dragedFolder as EUFolder != null)
                {
                    EUFolder             dragedSPFolder = dragedFolder as EUFolder;
                    List <EUContentType> contentTypes   = SharePointManager.GetContentTypes(dragedSPFolder.SiteSetting, dragedSPFolder.WebUrl, dragedSPFolder.ListName);
                    fields = SharePointManager.GetFields(dragedSPFolder.SiteSetting, dragedSPFolder.WebUrl, dragedSPFolder.ListName);
                    ListItemEditForm listItemEditForm = new ListItemEditForm();
                    listItemEditForm.InitializeForm(dragedSPFolder, null);
                    listItemEditForm.ShowDialog();

                    if (listItemEditForm.DialogResult != DialogResult.OK)
                    {
                        return;
                    }
                    foreach (EUEmailUploadFile emailUploadFile in emailUploadFiles)
                    {
                        emailUploadFile.FieldInformations = listItemEditForm.FieldInformations;
                    }
                }

                string sourceFolder = EUSettingsManager.GetInstance().CreateATempFolder();

                if (EUSettingsManager.GetInstance().Settings.UploadAutomatically == true || dragedFolder as FSFolder != null || dragedFolder as GFolder != null)
                {
                    if (listviewControl != null)
                    {
                        for (int i = 0; i < emailUploadFiles.Count; i++)
                        {
                            EUEmailUploadFile emailUploadFile = emailUploadFiles[i];
                            listviewControl.LibraryContentDataGridView.Rows.Insert(i, 1);
                            listviewControl.LibraryContentDataGridView.Rows[i].Tag = emailUploadFile.UniqueID.ToString();
                            if (dragedFolder as EUFolder != null)
                            {
                                listviewControl.LibraryContentDataGridView.Rows[i].Cells["ExtensionImageColumn"].Value = Sobiens.Office.SharePointOutlookConnector.Properties.Resources.ajax_loader;
                            }
                            string title = emailUploadFile.FilePath.Split('\\')[emailUploadFile.FilePath.Split('\\').Length - 1];
                            listviewControl.LibraryContentDataGridView.Rows[i].Cells["TitleColumn"].Value = title;
                        }
                    }
                    // JOEL JEFFERY 20110712 Hook up the UploadFailed event
                    // JON SILVER JULY 2011 Hook up the UploadSucceeded event
                    if (!addedEventHandler)
                    {
                        OutlookConnector.GetConnector(dragedFolder.SiteSetting).UploadFailed    += new EventHandler(EUEmailManager_UploadFailed);
                        OutlookConnector.GetConnector(dragedFolder.SiteSetting).UploadSucceeded += new EventHandler(EUEmailManager_UploadSucceeded);
                        addedEventHandler = true;
                    }

                    OutlookConnector.GetConnector(dragedFolder.SiteSetting).UploadFiles(dragedFolder, emailUploadFiles, fields, fieldInformations, listviewControl);
                }
                else
                {
                    uploadProgressForm.Initialize(dragedFolder, sourceFolder, emailUploadFiles, isListItemAndAttachmentMode, fieldInformations);
                    uploadProgressForm.ShowDialog();
                }
            }
            catch (System.Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogManager.LogAndShowException(methodName, ex);
                throw ex;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Copies or moves the email to folder.
        /// </summary>
        /// <param name="format">The format.</param>
        private void CopyOrMoveEmailToFolder(SaveFormatOverride format) // JOEL JEFFERY 20110708 added SaveFormatOverride format
        {
            if (DragDropTargetNode == null)
            {
                return;
            }

            EUFolder dragedFolder = DragDropTargetNode.Tag as EUFolder;

            if (dragedFolder == null)
            {
                return;
            }

            SharePointListViewControl sharePointListViewControl = GetCurrentSharePointExplorerPane().sharePointListViewControl;

            if (sharePointListViewControl.SelectedFolder == null || sharePointListViewControl.SelectedFolder.UniqueIdentifier != dragedFolder.UniqueIdentifier || sharePointListViewControl.SelectedFolder.Title != dragedFolder.Title)
            {
                sharePointListViewControl = null;
            }

            emailItems = new List <MailItem>();

            if (DragDropArgs.Data.GetDataPresent("RenPrivateSourceFolder") == false) // if it's not a folder???
            {
                // JON SILVER SAYS... I've never been able to get this bit to fire... therefore under exactly what circumstances would e.Data.GetDataPresent("RenPrivateSourceFolder") == false ??
                emailItems.Add(Application.ActiveExplorer().Selection[1] as Outlook.MailItem);
            }
            else
            {
                // JON SILVER SAYS... we always seem to end up here regardless of what's dropped
                for (int i = 0; i < Application.ActiveExplorer().Selection.Count; i++)
                {
                    Outlook.MailItem item = Application.ActiveExplorer().Selection[i + 1] as Outlook.MailItem;
                    emailItems.Add(item);
                }
            }

            bool isListItemAndAttachmentMode      = false;
            EUFieldInformations fieldInformations = null;
            EUFieldCollection   fields            = null;

            if (dragedFolder as EUFolder != null && ((EUFolder)dragedFolder).IsDocumentLibrary == false)
            {
                if (((EUFolder)dragedFolder).EnableAttachments == false)
                {
                    MessageBox.Show("In order to upload email, you need to enable attachment feature in this list.");
                    return;
                }
                isListItemAndAttachmentMode = true;
            }

            List <EUEmailUploadFile> emailUploadFiles = CommonManager.GetEmailUploadFiles(emailItems, DragDropArgs, isListItemAndAttachmentMode, format);

            // JON SILVER JUNE 2011
            if (!addedEventHandler)
            {
                EUEmailManager.UploadFailed    += new EventHandler(SharePointOutlookConnector_UploadFailed);
                EUEmailManager.UploadSucceeded += new EventHandler(SharePointOutlookConnector_UploadSucceeded);
                addedEventHandler = true;
            }

            // JOEL JEFFERY 20110712
            try
            {
                // JON SILVER JUNE 2011
                EUEmailManager.UploadEmail(sharePointListViewControl, dragedFolder, DragDropArgs, emailUploadFiles, isListItemAndAttachmentMode);
            }
            catch (System.Exception ex)
            {
                if (UploadFailed != null)
                {
                    UploadFailed(this, new EventArgs());
                }
                throw ex;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Ensures the folder exists.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="destinationFolderUrl">The destination folder URL.</param>
        /// <param name="emailUploadFile">The email upload file.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="fieldInformations">The field informations.</param>
        /// <param name="sharePointListViewControl">The share point list view control.</param>
        /// <returns>The url of the new folder.</returns>
        private string ensureFolderExists(EUFolder folder, string destinationFolderUrl, EUEmailUploadFile emailUploadFile, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
        {
            string newFolderName     = SharePointManager.MakeFileNameSafe(emailUploadFile.Subject + (emailUploadFile.SentOn.HasValue ? emailUploadFile.SentOn.Value.ToString(" yyyyddMM") : ""));
            string newDestinationUrl = destinationFolderUrl + "/" + newFolderName;

            if (!SharePointManager.CheckFolderExists(folder.SiteSetting, newDestinationUrl, folder.ListName, folder.FolderPath, newFolderName))
            {
                SharePointManager.CreateListFolder(folder.SiteSetting, folder.FolderPath, folder.WebUrl, folder.ListName, newFolderName);
            }
            // JOEL JEFFERY 20110712 - what the hell was I thinking?
            //folder.FolderPath = folder.FolderPath += "/" + newFolderName;
            return(newDestinationUrl);
        }
Ejemplo n.º 9
0
        public void QueueUploadItems(EUFolder folder, string destinationFolderUrl, List <EUEmailUploadFile> uploadFiles, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
        {
            List <EUUploadItem> uploadItems = new List <EUUploadItem>();

            foreach (EUEmailUploadFile emailUploadFile in uploadFiles)
            {
                if (emailUploadFile.SaveFormatOverride == SaveFormatOverride.Word)
                {
                    destinationFolderUrl = ensureFolderExists(folder, destinationFolderUrl, emailUploadFile, fields, fieldInformations, sharePointListViewControl);
                }
                EUUploadItem uploadItem = new EUUploadItem(folder, destinationFolderUrl, emailUploadFile, fields, fieldInformations, sharePointListViewControl);
                uploadItems.Add(uploadItem);
            }
            ThreadPool.QueueUserWorkItem(new WaitCallback(UploadItems), uploadItems);
            bool test;
        }
Ejemplo n.º 10
0
        public void UploadFiles(ISPCFolder folder, List <EUEmailUploadFile> uploadFiles, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
        {
            EUFolder _folder = folder as EUFolder;
            string   destinationFolderUrl = _folder.WebUrl.TrimEnd(new char[] { '/' }) + "/" + _folder.FolderPath.TrimStart(new char[] { '/' });

            BackgroundThreadManager.GetInstance().QueueUploadItems(_folder, destinationFolderUrl, uploadFiles, fields, fieldInformations, sharePointListViewControl);

            /*
             * List<EUField> fields = SharePointManager.GetFields(_folder.SiteSetting, _folder.WebUrl, _folder.ListName);
             * foreach (EUEmailUploadFile uploadFile in uploadFiles)
             * {
             *  string copySource = new FileInfo(uploadFile.FilePath).Name;
             *  string[] copyDest = new string[1] { destinationFolderUrl + "/" + copySource };
             *  byte[] itemByteArray = SharePointManager.ReadByteArrayFromFile(uploadFile.FilePath);
             *
             *  EUUploadItem uploadItem = new EUUploadItem(_folder.SiteSetting, _folder.ListName, _folder.RootFolderPath, _folder.WebUrl, copySource, copyDest, itemByteArray, fields, uploadFile.MailItem, fieldInformations);
             *  BackgroundThreadManager.GetInstance().QueueUploadItems(uploadItem);
             * }
             */
        }
        public void UploadFiles(ISPCFolder folder, List <EUEmailUploadFile> uploadFiles, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
        {
            GFolder _folder = folder as GFolder;

            foreach (EUEmailUploadFile emailUploadFile in uploadFiles)
            {
                GMailManager.GetInstance().UploadFile(folder.SiteSetting, emailUploadFile.FilePath, folder.UniqueIdentifier);
            }
        }
        public void UploadFiles(ISPCFolder folder, List <EUEmailUploadFile> uploadFiles, List <EUField> fields, EUFieldInformations fieldInformations, SharePointListViewControl sharePointListViewControl)
        {
            FSFolder _folder = (FSFolder)folder;

            foreach (EUEmailUploadFile uploadFile in uploadFiles)
            {
                string copySource = new FileInfo(uploadFile.FilePath).Name;
                File.Copy(uploadFile.FilePath, _folder.Path + "\\" + copySource);
            }
        }