Exemple #1
0
        private void NewFileUploadMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedFolder == null)
            {
                MessageBox.Show("Please select a folder first!");
                return;
            }

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = true;

            // Set filter for file extension and default file extension
            //dlg.DefaultExt = ".png";
            //dlg.Filter = "JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";
            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                List <IItem> emailItems = new List <IItem>();

                ISiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(SelectedFolder.SiteSettingID);

                List <UploadItem> uploadItems = ApplicationContext.Current.GetUploadItems(SelectedFolder.GetWebUrl(), siteSetting, SelectedFolder, dlg.FileNames);
                if (uploadItems == null)
                {
                    return;
                }

                WorkItem workItem = new WorkItem(Languages.Translate("Uploading emails"));
                workItem.CallbackFunction = new WorkRequestDelegate(UploadEmails_Callback);
                workItem.CallbackData     = new object[] { siteSetting, SelectedFolder, uploadItems, this.ConnectorExplorer, true };
                workItem.WorkItemType     = WorkItem.WorkItemTypeEnum.NonCriticalWorkItem;
                BackgroundManager.GetInstance().AddWorkItem(workItem);
            }
        }
Exemple #2
0
        void dragMgr_ProcessDrop(object sender, DragEventArgs e)//, ProcessDropEventArgs<DataRowView> e)
        {
            if (e.Effects == DragDropEffects.None)
            {
                return;
            }

            if (e.Data.GetDataPresent("System.Data.DataRowView", false) == true && this.dragMgr.IndexUnderDragCursor != -1)//JD.
            {
                ListView  list  = (ListView)e.Source;
                DataTable items = ((DataView)list.ItemsSource).Table;

                DataRowView item = e.Data.GetData(typeof(DataRowView)) as DataRowView;

                OC_Datarow dropUnder = (OC_Datarow)(items.Rows[this.dragMgr.IndexUnderDragCursor]);

                bool isFolder = (dropUnder.Tag as Folder != null);

                if (isFolder)
                {
                    ISiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(SelectedFolder.SiteSettingID);

                    Folder     folder         = dropUnder.Tag as Folder;
                    OC_Datarow dataSourceItem = (OC_Datarow)(item).Row;
                    IItem      itemToMove     = dataSourceItem.Tag as IItem;

                    if (ItemsManager.moveItem(siteSetting, itemToMove, folder))
                    {
                        reloadItemList();
                    }
                }
            }
            else
            {
                if (SelectedFolder == null)
                {
                    return;
                }
                List <IItem> emailItems = new List <IItem>();

                if (SelectedFolder.CanUpload() == false)
                {
                    MessageBox.Show(Languages.Translate("In order to upload email, you need to enable attachment feature in this list."));
                    return;
                }

                ISiteSetting      siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(SelectedFolder.SiteSettingID);
                List <UploadItem> uploadItems = ApplicationContext.Current.GetUploadItems(SelectedFolder.GetWebUrl(), siteSetting, SelectedFolder, e, getFieldMappings);
                if (uploadItems == null)
                {
                    return;
                }

                WorkItem workItem = new WorkItem(Languages.Translate("Uploading emails"));
                workItem.CallbackFunction = new WorkRequestDelegate(UploadEmails_Callback);
                workItem.CallbackData     = new object[] { siteSetting, SelectedFolder, uploadItems, this.ConnectorExplorer, true };
                workItem.WorkItemType     = WorkItem.WorkItemTypeEnum.NonCriticalWorkItem;
                BackgroundManager.GetInstance().AddWorkItem(workItem);
            }
        }