private void OkButton_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            ErrorLabel.Visible = false;

            string            newFileName = FileNameTextBox.Text;
            IOutlookConnector connector   = OutlookConnector.GetConnector(SelectedFolder.SiteSetting);

            if (connector.CheckFileExistency(SelectedFolder, SelectedListItem, newFileName) == true)
            {
                errorProvider1.SetError(FileNameTextBox, "There is a file with the same name already!");
                ErrorLabel.Visible = true;
                return;
            }
            connector.CopyFile(SelectedFolder, SelectedListItem, newFileName);
            this.DialogResult = DialogResult.OK;
        }
예제 #2
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());
            }
        }