private void editPropertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EUListItem           listItem         = (EUListItem)LibraryContentDataGridView.SelectedRows[0].Tag;
            EUFolder             folder           = SelectedFolder as EUFolder;
            List <EUContentType> contentTypes     = SharePointManager.GetContentTypes(folder.SiteSetting, folder.WebUrl, folder.ListName);
            EUFieldCollection    fields           = SharePointManager.GetFields(folder.SiteSetting, folder.WebUrl, folder.ListName);
            ListItemEditForm     listItemEditForm = new ListItemEditForm();

            listItemEditForm.InitializeForm(folder, listItem);
            listItemEditForm.ShowDialog();
            if (listItemEditForm.DialogResult != DialogResult.OK)
            {
                return;
            }


            Hashtable changedProperties = new Hashtable();

            if (listItemEditForm.FieldInformations.ContentType != null)
            {
                changedProperties.Add("ContentType", listItemEditForm.FieldInformations.ContentType.Name);
            }
            for (int i = 0; i < listItemEditForm.FieldInformations.Count(); i++)
            {
                changedProperties.Add(listItemEditForm.FieldInformations[i].InternalName, listItemEditForm.FieldInformations[i].Value);
            }
            SharePointManager.UpdateListItem(listItem.SiteSetting, listItem.WebURL, listItem.ListName, listItem.ID, changedProperties);
            RefreshViewExt();
        }
        public void UpdatePropertyGrid()
        {
            XmlAttributeCollection attributes = SelectedListItem.Properties;

            if (attributes != null)
            {
                List <EUField> fields = SharePointManager.GetFields(SelectedListItem.SiteSetting, SelectedListItem.WebURL, SelectedListItem.ListName);
                Assembly       ass    = EvaluateExpression(fields, attributes);
                var            r      = ass.CreateInstance("TempClass");
                ListItemPropertyGridGrid.SelectedObject = r;
                ListItemPropertyGridGrid.Tag            = SelectedListItem;
            }
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            EUFolder folder = SelectedFolder as EUFolder;

            if (folder == null)
            {
                return;
            }
            EUFieldCollection fields          = SharePointManager.GetFields(folder.SiteSetting, folder.WebUrl, folder.ListName);
            ListFiltersForm   listFiltersForm = new ListFiltersForm();

            listFiltersForm.InitializeForm(fields, CustomFilters);
            listFiltersForm.ShowDialog();

            if (listFiltersForm.DialogResult == DialogResult.OK)
            {
                CustomFilters = listFiltersForm.CustomFilters;
                RefreshViewExt();
            }
        }
示例#4
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;
            }
        }
示例#5
0
        public void Upload()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new UploadDelegate(Upload));
            }
            else
            {
                ErrorLabel.Visible = false;

                ProgressValueLabel.Text = "Started.";
                ProgressValueLabel.Refresh();
                SetButtonEnabilityOnUploading();
                int            totalRows = EmailsListView.Items.Count;
                List <EUField> fields    = SharePointManager.GetFields(_siteSetting, _webURL, _listName);
                SharePointCopyWS.CopyResult[] myCopyResultArray = null;
                string log      = String.Empty;
                bool   hasError = false;
                if (_isListItemAndAttachmentMode == false)
                {
                    for (int i = 0; i < EmailsListView.Items.Count; i++)
                    {
                        if (backgroundWorker1.CancellationPending == true)
                        {
                            ProgressValueLabel.Text = "Cancelled.";
                            ProgressValueLabel.Refresh();
                            return;
                        }
                        ListViewItem listViewItem = EmailsListView.Items[i];
                        if (listViewItem.Checked == false)
                        {
                            continue;
                        }
                        EUEmailMetaData metaData    = listViewItem.Tag as EUEmailMetaData;
                        string          filename    = listViewItem.SubItems[1].Text;
                        string          newFilename = listViewItem.Text;
                        ProgressValueLabel.Text = newFilename + " is being uploaded...";
                        ProgressValueLabel.Refresh();
                        string filePath      = _sourceFolder + "\\" + filename;
                        byte[] itemByteArray = SharePointManager.ReadByteArrayFromFile(filePath);
                        string sourceDest    = _destinationFolderUrl + "/" + newFilename;

                        string[]   sourceDests = new string[] { sourceDest };
                        EUListItem listItem;
                        SharePointManager.UploadFile(_siteSetting, _listName, _rootFolderPath, _siteURL, _webURL, newFilename, sourceDests, itemByteArray, fields, metaData, _fieldInfoArray, out listItem);

                        /*
                         * foreach (SharePointCopyWS.CopyResult copyResult in myCopyResultArray)
                         * {
                         *  if (copyResult.ErrorCode != Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.CopyErrorCode.Success)
                         *      hasError = true;
                         *  log += "DestinationUrl:" + copyResult.DestinationUrl + Environment.NewLine + "ErrorCode:" + copyResult.ErrorCode.ToString() + Environment.NewLine + "ErrorMessage:" + copyResult.ErrorMessage + Environment.NewLine;
                         * }
                         * LogManager.Log(log, EULogModes.Normal);
                         */
                        SetProgressBar(i, totalRows);
                    }
                }
                else
                {
                    Hashtable emails = new Hashtable();

                    for (int i = 0; i < EmailsListView.Items.Count; i++)
                    {
                        ListViewItem listViewItem = EmailsListView.Items[i];
                        //DataGridViewRow dataGridViewRow = EmailsDataGridView.Rows[i];
                        //bool included = (bool)dataGridViewRow.Cells["Included"].Value;
                        if (listViewItem.Checked == false)
                        {
                            continue;
                        }
                        Microsoft.Office.Interop.Outlook.MailItem emailItem = listViewItem.Tag as Microsoft.Office.Interop.Outlook.MailItem;
                        if (emails[emailItem.EntryID] == null)
                        {
                            emails[emailItem.EntryID] = new List <ListViewItem>();
                        }
                        ((List <ListViewItem>)emails[emailItem.EntryID]).Add(listViewItem);
                    }
                    totalRows = emails.Count;
                    int currentIndex = 0;
                    foreach (object attachmentsObject in emails.Values)
                    {
                        if (backgroundWorker1.CancellationPending == true)
                        {
                            ProgressValueLabel.Text = "Cancelled.";
                            ProgressValueLabel.Refresh();
                            return;
                        }
                        List <ListViewItem> attachments   = (List <ListViewItem>)attachmentsObject;
                        ListViewItem        attachmentRow = attachments[0];
                        Microsoft.Office.Interop.Outlook.MailItem emailItem = attachmentRow.Tag as Microsoft.Office.Interop.Outlook.MailItem;
                        string body = emailItem.Body;
                        int    id   = SharePointManager.CreateListItem(_siteSetting, _rootFolderPath, _webURL, _listName, emailItem.Subject, body);

                        foreach (ListViewItem attachmentRow1 in attachments)
                        {
                            //string filename = attachmentRow1.Cells["Filename"].Value.ToString();
                            //string newFilename = attachmentRow1.Cells["NewFilename"].Value.ToString();
                            string filename    = attachmentRow1.SubItems[0].Text;
                            string newFilename = attachmentRow1.Text;
                            ProgressValueLabel.Text = newFilename + " is being uploaded...";
                            ProgressValueLabel.Refresh();
                            string filePath      = _sourceFolder + "\\" + filename;
                            byte[] itemByteArray = SharePointManager.ReadByteArrayFromFile(filePath);
                            string result        = SharePointManager.AddAttachment(_siteSetting, _webURL, _listName, id, newFilename, itemByteArray);

                            log += "WebURL:" + _webURL + Environment.NewLine + "ListName:" + _listName + Environment.NewLine + "filePath:" + filePath + Environment.NewLine + "newFilename:" + newFilename + Environment.NewLine + "result:" + result + Environment.NewLine;
                            LogManager.Log(log, EULogModes.Normal);
                        }
                        SetProgressBar(currentIndex, totalRows);
                        currentIndex++;
                    }
                }
                CurrentUploadLog = log;
                if (hasError == true)
                {
                    ErrorLabel.Visible = true;
                }
            }
        }
        public void Upload()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new UploadDelegate(Upload));
            }
            else
            {
                ErrorLabel.Visible = false;

                ProgressValueLabel.Text = "Started.";
                ProgressValueLabel.Refresh();
                SetButtonEnabilityOnUploading();
                int            totalRows = EmailsListView.Items.Count;
                List <EUField> fields    = SharePointManager.GetFields(_siteSetting, _webURL, _listName);
                SharePointCopyWS.CopyResult[] myCopyResultArray = null;
                string log      = String.Empty;
                bool   hasError = false;

                for (int i = 0; i < EmailsListView.Items.Count; i++)
                {
                    if (backgroundWorker1.CancellationPending == true)
                    {
                        ProgressValueLabel.Text = "Cancelled.";
                        ProgressValueLabel.Refresh();
                        return;
                    }
                    ListViewItem listViewItem = EmailsListView.Items[i];
                    if (listViewItem.Checked == false)
                    {
                        continue;
                    }
                    EUEmailMetaData metaData    = (EUEmailMetaData)listViewItem.Tag;
                    string          filename    = listViewItem.SubItems[1].Text;
                    string          newFilename = listViewItem.Text;
                    ProgressValueLabel.Text = newFilename + " is being uploaded...";
                    ProgressValueLabel.Refresh();
                    string filePath      = _sourceFolder + "\\" + filename;
                    byte[] itemByteArray = ReadByteArrayFromFile(filePath);
                    string sourceDest    = _destinationFolderUrl + "/" + newFilename;
                    AttachmentLinks += sourceDest.Replace(" ", "%20") + Environment.NewLine;

                    string[]   sourceDests = new string[] { sourceDest };
                    EUListItem listItem;
                    SharePointManager.UploadFile(_siteSetting, _listName, _rootFolderPath, _siteURL, _webURL, newFilename, sourceDests, itemByteArray, fields, metaData, null, out listItem);

                    /*
                     * foreach (SharePointCopyWS.CopyResult copyResult in myCopyResultArray)
                     * {
                     *  if (copyResult.ErrorCode != Sobiens.Office.SharePointOutlookConnector.SharePointCopyWS.CopyErrorCode.Success)
                     *      hasError = true;
                     *  log += "DestinationUrl:" + copyResult.DestinationUrl + Environment.NewLine + "ErrorCode:" + copyResult.ErrorCode.ToString() + Environment.NewLine + "ErrorMessage:" + copyResult.ErrorMessage + Environment.NewLine;
                     * }
                     * LogManager.Log(log, EULogModes.Normal);
                     */
                    SetProgressBar(i, totalRows);
                }
                CurrentUploadLog = log;
                if (hasError == true)
                {
                    ErrorLabel.Visible = true;
                }
                else
                {
                    CurrentMailItem.Body = AttachmentLinks + CurrentMailItem.Body;
                    for (int i = 0; i < EmailsListView.Items.Count; i++)
                    {
                        if (EmailsListView.Items[i].Checked == true)
                        {
                            string filename = EmailsListView.Items[i].SubItems[1].Text;
                            for (int x = CurrentMailItem.Attachments.Count; x > 0; x--)
                            {
                                if (CurrentMailItem.Attachments[x].FileName == filename)
                                {
                                    CurrentMailItem.Attachments[x].Delete();
                                }
                            }
                        }
                    }
                }
            }
        }