Beispiel #1
0
        // JOEL JEFFERY 20110710
        /// <summary>
        /// Checks the folder exists.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="newFolderName">New name of the folder.</param>
        /// <returns></returns>
        public bool CheckFolderExists(ISPCFolder folder, string newFolderName)
        {
            //            EUListItem listItem = (EUListItem)item;
            EUFolder listFolder = (EUFolder)folder;

            return(SharePointManager.CheckFolderExists(listFolder.SiteSetting, listFolder.WebUrl, listFolder.ListName, listFolder.FolderPath, newFolderName));
        }
        private void checkOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EUListItem listItem = (EUListItem)LibraryContentDataGridView.SelectedRows[0].Tag;

            SharePointManager.CheckOutFile(listItem.SiteSetting, listItem.WebURL, listItem.URL);
            this.RefreshViewExt();
        }
        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();
        }
Beispiel #4
0
        private void LoadLists(TreeNode node, string webUrl, EUSiteSetting siteSetting)
        {
            SPFoldersTreeView.BeginUpdate();
            List <EUList> lists = SharePointManager.GetLists(webUrl, siteSetting);

            foreach (EUList list in lists)
            {
                if (
                    (list.ServerTemplate == 101 || list.ServerTemplate == 100 || list.BaseType == 1) && //or BaseType == 1 - JOEL JEFFERY 20110708
                    list.Hidden == false
                    )
                {
                    TreeNode listNode = node.Nodes.Add(list.Title);
                    listNode.Tag = list;
                    SetTreeNodeImage(listNode);
                    AddLoadingNode(listNode);

                    //                    TreeNode rootFolderNode = listNode.Nodes.Add(list.RootFolder.Title);
                    //                    rootFolderNode.Tag = list.RootFolder;
                    //                    SetTreeNodeImage(rootFolderNode);
                    //                    AddLoadingNode(rootFolderNode);
                    if (list.ServerTemplate == 101)
                    {
                    }
                }
            }
            SPFoldersTreeView.EndUpdate();
        }
Beispiel #5
0
        private void rollbackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EUListItemVersion        version  = (EUListItemVersion)ListItemVersionsDataGridView.SelectedRows[0].Tag;
            List <EUListItemVersion> versions = SharePointManager.RestoreVersion(version.SiteSetting, version.WebURL, version.URL, version.Version);

            LoadVersions(versions);
        }
        private void ChangeView(ISPCView selectedView)
        {
            SortedFieldName  = String.Empty;
            IsAsc            = true;
            CurrentPageIndex = 0;
            ListItemCollectionPositionNexts = new NameValueCollection();
            ListItemCollectionPositionNexts.Add("0", String.Empty);
            string listItemCollectionPositionNext = String.Empty;
            int    itemCount;
            string currentListItemCollectionPositionNext = ListItemCollectionPositionNexts[(CurrentPageIndex).ToString()];

            List <ISPCItem> items = OutlookConnector.GetConnector(selectedView.SiteSetting).GetListItems(SelectedFolder, selectedView, SortedFieldName, IsAsc, CurrentPageIndex, currentListItemCollectionPositionNext, CustomFilters, out listItemCollectionPositionNext, out itemCount);

            EUView view = selectedView as EUView;

            if (view != null)
            {
                SelectedView = SharePointManager.GetView(view.WebURL, view.ListName, view.Name, view.SiteSetting);
            }
            else
            {
                SelectedView = selectedView;
            }

            object[] args = new object[4] {
                SelectedView, items, listItemCollectionPositionNext, itemCount
            };
            this.Invoke(new UpdateContentDataGridViewHandler(UpdateContentDataGridView), args);
        }
Beispiel #7
0
        public List <ISPCFolder> GetSubFolders(ISPCFolder folder)
        {
            List <ISPCFolder> subFolders = new List <ISPCFolder>();

            if (folder as EUWeb != null)
            {
                EUWeb        web  = (EUWeb)folder;
                List <EUWeb> webs = SharePointManager.GetWebs(web.Url, web.SiteSetting);
                foreach (EUWeb _web in webs)
                {
                    subFolders.Add(_web);
                }
                List <EUList> lists = SharePointManager.GetLists(web.Url, web.SiteSetting);
                foreach (EUList list in lists)
                {
                    if (
                        (list.ServerTemplate == 101 || list.ServerTemplate == 100 || list.BaseType == 1) && //or BaseType == 1 - JOEL JEFFERY 20110708
                        list.Hidden == false
                        )
                    {
                        subFolders.Add(list);
                    }
                }
            }
            else if (folder as EUFolder != null)
            {
                EUFolder _folder = (EUFolder)folder;
                IEnumerable <EUFolder> folders = SharePointManager.GetFolders(_folder);
                foreach (EUFolder __folder in folders)
                {
                    subFolders.Add(__folder);
                }
            }
            return(subFolders);
        }
Beispiel #8
0
        public bool CheckFileExistency(ISPCFolder folder, ISPCItem item, string newFileName)
        {
//            EUListItem listItem = (EUListItem)item;
            EUFolder listFolder = (EUFolder)folder;

            return(SharePointManager.CheckFileExistency(listFolder.SiteSetting, listFolder.WebUrl, listFolder.ListName, listFolder.FolderPath, null, newFileName));
        }
 public static string UpdateAlert(EUSiteSetting siteSetting, string webUrl, EUAlert alert)
 {
     SobiensAlertsWS.AlertsWebService ws = new Sobiens.Office.SharePointOutlookConnector.SobiensAlertsWS.AlertsWebService();
     ws.Credentials = SharePointManager.GetCredential(siteSetting);
     ws.Url         = webUrl + "/_layouts/AlertsWebSebService.asmx";
     return(ws.UpdateAlert(alert.ID, alert.Title, alert.ListID, alert.AlertTime, alert.EventType, alert.AlertFrequency, alert.GetFilterXML()));
 }
        public dynamic GetAllFoldersTreeFromConfig()
        {
            SyncConfiguration config = GetConfiguration();
            var sharePointManager    = config.GetSharePointManager();
            var result = SharePointManager.GetAllFoldersTreeFromConfig(config);

            return(result);
        }
 public static SharePointAlertsWS.DeleteFailure[] DeleteAlert(EUSiteSetting siteSetting, string webUrl, string alertID)
 {
     SharePointAlertsWS.Alerts ws = new Sobiens.Office.SharePointOutlookConnector.SharePointAlertsWS.Alerts();
     ws.Credentials = SharePointManager.GetCredential(siteSetting);
     ws.Url         = webUrl + "/_vti_bin/alerts.asmx";
     SharePointAlertsWS.DeleteFailure[] failures = ws.DeleteAlerts(new string[] { alertID });
     return(failures);
 }
        public static List <EUAlert> GetAlerts(EUSiteSetting siteSetting, string webUrl)
        {
            SobiensAlertsWS.AlertsWebService ws = new Sobiens.Office.SharePointOutlookConnector.SobiensAlertsWS.AlertsWebService();
            ws.Credentials = SharePointManager.GetCredential(siteSetting);
            ws.Url         = webUrl + "/_layouts/AlertsWebSebService.asmx";
            XmlElement element = ws.GetMyAlerts();

            return(AlertManager.NodeToSobiensAlerts(element));
        }
        private void ListItemPropertyGridGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            Hashtable changedProperties = new Hashtable();

            changedProperties.Add(e.ChangedItem.Label, e.ChangedItem.Value.ToString());
            EUListItem listItem = (EUListItem)ListItemPropertyGridGrid.Tag;

            SharePointManager.UpdateListItem(listItem.SiteSetting, listItem.WebURL, listItem.ListName, listItem.ID, changedProperties);
        }
        private void undoCheckOutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EUListItem   listItem = (EUListItem)LibraryContentDataGridView.SelectedRows[0].Tag;
            DialogResult result   = MessageBox.Show("Are you sure you would like to undo " + listItem.Title + "?", "", MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }
            SharePointManager.UndoCheckOutFile(listItem.SiteSetting, listItem.WebURL, listItem.URL);
            RefreshViewExt();
        }
Beispiel #15
0
        public void CopyFile(ISPCFolder folder, ISPCItem item, string newFileName)
        {
            EUListItem listItem   = (EUListItem)item;
            EUFolder   listFolder = (EUFolder)folder;

            string folderPath = listFolder.WebUrl + "/" + listFolder.FolderPath;
            string webUrl     = listFolder.WebUrl;
            string listName   = listFolder.ListName;

            SharePointCopyWS.CopyResult[] myCopyResultArray = null;
            SharePointManager.CopyFile(listFolder.SiteSetting, webUrl, listItem.URL, folderPath + "/" + newFileName, out myCopyResultArray);
        }
Beispiel #16
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);
        }
        public void Initialize()
        {
            List <EUList> lists = SharePointManager.GetLists(webUrl, siteSetting);

            foreach (EUList list in lists)
            {
                ListsComboBox.Items.Add(list);
            }
            if (ListsComboBox.Items.Count > -1)
            {
                ListsComboBox.SelectedIndex = 0;
            }
        }
        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;
            }
        }
Beispiel #19
0
        private void LoadWebs(TreeNode node, string webUrl, EUSiteSetting siteSetting)
        {
            SPFoldersTreeView.BeginUpdate();
            List <EUWeb> webs = SharePointManager.GetWebs(webUrl, siteSetting);

            foreach (EUWeb web in webs)
            {
                TreeNode webNode = node.Nodes.Add(web.Title);
                webNode.Tag = web;
                SetTreeNodeImage(webNode);
                AddLoadingNode(webNode);
            }
            SPFoldersTreeView.EndUpdate();
        }
Beispiel #20
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 static bool CheckSobiensAlertServiceEnability(EUSiteSetting siteSetting, string webUrl)
        {
            SobiensAlertsWS.AlertsWebService ws = new Sobiens.Office.SharePointOutlookConnector.SobiensAlertsWS.AlertsWebService();
            ws.Credentials = SharePointManager.GetCredential(siteSetting);
            ws.Url         = webUrl + "/_layouts/AlertsWebSebService.asmx";
            bool serviceExistency = false;

            try
            {
                serviceExistency = ws.CheckServiceExistency();
            }
            catch (Exception ex)
            {
            }
            return(serviceExistency);
        }
        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;
            }
        }
        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();
            }
        }
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            var configuration     = new ConfigurationSettings();
            var storageService    = new StorageService(configuration, log);
            var tokenCacheService = new TokenCacheService(configuration, storageService);
            var tokenManager      = new TokenManager(configuration, tokenCacheService, log);
            var scopes            = new string[] {
                $"api://{configuration["ClientId"]}/access_as_user"
            };

            var siteCollection = new SiteCollection()
            {
                Url                  = $"https://{configuration["SharePointTenantPrefix"]}.sharepoint.com/sites/rztest123",
                Owner                = $"{configuration["Username"]}",
                Title                = "Test123",
                Template             = "STS#0",
                StorageMaximumLevel  = 100,
                UserCodeMaximumLevel = 300
            };

            var uri = await tokenManager.GetAuthUriAsync(scopes);

            //var authCode = await tokenRetriever.GetAuthCodeByMsalUriAsync(uri);
            var authenticationHeaderValue = req.Headers.Authorization;
            var authResult = await tokenManager.GetAccessTokenFromCodeAsync(authenticationHeaderValue.Parameter, scopes);

            var sharepointManager = new SharePointManager(configuration, tokenManager, authResult.AccessToken);
            var results           = await sharepointManager.CreateSiteCollectionAsync(siteCollection);

            var httpContent = new StringContent(JsonConvert.SerializeObject(results));

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = httpContent,
            });
        }
        private void GenerateEditForm(EUFolder folder, EUListItem listItem, string contentTypeID)
        {
            List <EUField> editableFields = SharePointManager.GetContentType(folder.SiteSetting, folder.WebUrl, folder.ListName, contentTypeID).Fields.GetEditableFields();

            for (int i = EditControlsPanel.Controls.Count - 1; i > -1; i--)
            {
                if (EditControlsPanel.Controls[i].Tag is EUField)
                {
                    EditControlsPanel.Controls.RemoveAt(i);
                }
            }

            int height = 30;

            EditItemControls = new List <EditItemControl>();
            for (int i = 0; i < editableFields.Count; i++)
            {
                EUField         field       = editableFields[i];
                EditItemControl editControl = GetEditItemControl(field, folder, listItem);

                Label fieldNameLabel = new Label();
                fieldNameLabel.Text     = field.DisplayName;
                fieldNameLabel.Location = new Point(10, height);
                fieldNameLabel.Tag      = field;
                toolTip1.SetToolTip(fieldNameLabel, field.Description);
                EditControlsPanel.Controls.Add(fieldNameLabel);

                editControl.Location = new Point(200, height);
                editControl.Width    = 400;
                editControl.Tag      = field;
                toolTip1.SetToolTip(editControl, field.Description);
                EditControlsPanel.Controls.Add(editControl);
                height = height + editControl.Height + 5;
                EditItemControls.Add(editControl);
            }
        }
        private void OKButton_Click(object sender, EventArgs e)
        {
            EUCheckinTypes checkinType;

            if (DraftRadioButton.Checked == true)
            {
                checkinType = EUCheckinTypes.MinorCheckIn;
            }
            else if (PublishRadioButton.Checked == true)
            {
                checkinType = EUCheckinTypes.MajorCheckIn;
            }
            else
            {
                checkinType = EUCheckinTypes.OverwriteCheckIn;
            }

            SharePointManager.CheckInFile(SelectedItem.SiteSetting, SelectedItem.WebURL, SelectedItem.URL, CommentsTextBox.Text, checkinType);
            if (YesRadioButton.Checked == true)
            {
                SharePointManager.CheckOutFile(SelectedItem.SiteSetting, SelectedItem.WebURL, SelectedItem.URL);
            }
            DialogResult = DialogResult.OK;
        }
Beispiel #27
0
        public void UploadItems(object _uploadItems)
        {
            bool uploadSucceeded = false;
            List <EUUploadItem>    uploadItems = (List <EUUploadItem>)_uploadItems;
            FileExistDialogResults lastFileExistDialogResults = FileExistDialogResults.NotSelected;
            bool doThisForNextConflicts = false;

            foreach (EUUploadItem uploadItem in uploadItems)
            {
                string   newDestinationUrl = uploadItem.DestinationFolderUrl + "/";
                string   copySource        = new FileInfo(uploadItem.EmailUploadFile.FilePath).Name;
                string[] copyDest          = new string[1] {
                    uploadItem.DestinationFolderUrl + "/" + copySource
                };
                byte[] itemByteArray = SharePointManager.ReadByteArrayFromFile(uploadItem.EmailUploadFile.FilePath);

                EUListItem listItem;

                string            newFileName = copySource;
                IOutlookConnector connector   = OutlookConnector.GetConnector(uploadItem.Folder.SiteSetting);

                if (
                    (doThisForNextConflicts == true && lastFileExistDialogResults == FileExistDialogResults.Skip)
                    ||
                    lastFileExistDialogResults == FileExistDialogResults.Cancel)
                {
                    uploadItem.SharePointListViewControl.DeleteUploadItemInvoke(uploadItem.EmailUploadFile.UniqueID);
                    continue;
                }

                bool isCurrentFileUploadCanceled = false;
                if (
                    (doThisForNextConflicts == false)
                    ||
                    (doThisForNextConflicts == true && lastFileExistDialogResults == FileExistDialogResults.Copy)
                    )
                {
                    while (connector.CheckFileExistency(uploadItem.Folder, null, newFileName) == true)
                    {
                        FileExistConfirmationForm fileExistConfirmationForm = new FileExistConfirmationForm(copyDest[0]);
                        fileExistConfirmationForm.ShowDialog();
                        lastFileExistDialogResults = fileExistConfirmationForm.FileExistDialogResult;
                        doThisForNextConflicts     = fileExistConfirmationForm.DoThisForNextConflicts;

                        newFileName = fileExistConfirmationForm.NewFileName;
                        if (lastFileExistDialogResults == FileExistDialogResults.Skip || lastFileExistDialogResults == FileExistDialogResults.Cancel)
                        {
                            uploadItem.SharePointListViewControl.DeleteUploadItemInvoke(uploadItem.EmailUploadFile.UniqueID);
                            isCurrentFileUploadCanceled = true;
                            break;
                        }
                        if (lastFileExistDialogResults == FileExistDialogResults.CopyAndReplace)
                        {
                            break;
                        }
                        string newCopyDest = copyDest[0].Substring(0, copyDest[0].LastIndexOf("/")) + "/" + newFileName;
                        copyDest = new string[] { newCopyDest };
                    }
                }
                if (isCurrentFileUploadCanceled == true)
                {
                    continue;
                }

                if (uploadItem.EmailUploadFile.IsListItemAndAttachment == false)
                {
                    uint?result = SharePointManager.UploadFile(uploadItem.Folder.SiteSetting, uploadItem.Folder.ListName, uploadItem.Folder.RootFolderPath, uploadItem.Folder.SiteUrl, uploadItem.Folder.WebUrl, copySource, copyDest, itemByteArray, uploadItem.Fields, uploadItem.EmailUploadFile.MetaData, uploadItem.EmailUploadFile.FieldInformations, out listItem);
                    if (uploadItem.SharePointListViewControl != null && listItem != null)   // JON SILVER JULY 2011 - Is this success???
                    {
                        uploadItem.SharePointListViewControl.NotifyUploadItemInvoke(uploadItem.EmailUploadFile.UniqueID, listItem);
                    }
                    // JON SILVER JULY 2011
                    if (result.HasValue && listItem != null)
                    {
                        uploadSucceeded = true;
                    }
                }
                else
                {
                    int?result = SharePointManager.UploadListItemWithAttachment(uploadItem);
                    uploadSucceeded = result.HasValue;
                }
            }

            // JON SILVER JULY 2011 - RAISE UPLOAD SUCCESS SO WE CAN DELETE IF WE ARE MOVING
            if (!uploadSucceeded && UploadFailed != null) //why is UploadFailed null sometimes? JJ
            {
                UploadFailed(this, new EventArgs());
            }
            else if (UploadSucceeded != null)
            {
                UploadSucceeded(this, new EventArgs());
            }
        }
Beispiel #28
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;
            }
        }
Beispiel #29
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     ChoiceItems = SharePointManager.GetListItems(RootFolder.SiteSetting, Field.ShowField, RootFolder.WebUrl, Field.List.ToString());
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            TreeViewFolders.Items.Add(new TreeViewItem()
            {
                Header = "Please wait... Loading folders"
            });

            if (_configuration.SelectedFolders != null)
            {
                RadioSelected.IsChecked = true;
            }

            Task.Run(() =>
            {
                try
                {
                    var allFolders = SharePointManager.GetAllFoldersFromConfig(_configuration);

                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var rootTreeItem = new FolderViewModel()
                        {
                            Name = _configuration.DocumentLibrary, Folder = "\\"
                        };

                        foreach (var folder in allFolders)
                        {
                            var split = folder.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

                            var treeItem    = new FolderViewModel();
                            treeItem.Name   = split[split.Length - 1];
                            treeItem.Folder = (folder.TrimStart('/').Replace("/", "\\") + "\\").ToLowerInvariant();

                            if (split.Length == 1)
                            {
                                rootTreeItem.AddChildren(treeItem);
                            }
                            else
                            {
                                var splitFolder = string.Empty;
                                for (var i = 0; i < split.Length - 1; i++)
                                {
                                    splitFolder += split[i] + "\\";
                                }

                                FolderViewModel parent = FindTreeViewItemByFolder(rootTreeItem.Children, splitFolder);
                                // should never happen
                                if (parent == null)
                                {
                                    parent = rootTreeItem;
                                }

                                parent.AddChildren(treeItem);
                            }
                        }

                        TreeViewFolders.Items.Clear();
                        TreeViewFolders.Items.Add(rootTreeItem);

                        if (_configuration.SelectedFolders == null)
                        {
                            return;
                        }

                        foreach (var item in _configuration.SelectedFolders)
                        {
                            var fvm = FindTreeViewItemByFolder(rootTreeItem.Children, item);
                            if (fvm == null)
                            {
                                continue;
                            }

                            fvm.IsChecked = true;
                        }
                    }));
                }
                catch (Exception ex)
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var err1TreeItem = new TreeViewItem()
                        {
                            Header = "Error getting list of folders"
                        };
                        var err2TreeItem = new TreeViewItem()
                        {
                            Header = ex.Message
                        };
                        TreeViewFolders.Items.Clear();
                        TreeViewFolders.Items.Add(err1TreeItem);
                        TreeViewFolders.Items.Add(err2TreeItem);

                        Logger.Log("Error getting folder list: {0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace);
                    }));
                }
            });
        }