Beispiel #1
0
        private void OnSearchTextChanged()
        {
            using (MainWindow.Instance.PreventScintillaFocus())
            {
                App.Logger.TraceExt("NotesViewHierarchical",
                                    "OnSearchTextChanged",
                                    Tuple.Create("SearchText", SearchText));

                _filterData.Clear();
                if (AllNotes != null)
                {
                    ResyncDisplayItems(AllNotes);
                }
                SelectedFolder?.TriggerAllSubNotesChanged();

                if (SelectedFolderPath != null && !SelectedFolder.IsSpecialNode_AllNotes && !SelectedFolder.AllSubNotes.Any() && DisplayItems.AllNotesViewWrapper != null)
                {
                    App.Logger.TraceExt("NotesViewHierarchical",
                                        "OnSearchTextChanged (2)",
                                        Tuple.Create("SelectedFolderPath", SelectedFolderPath?.Formatted));

                    SelectedFolder = DisplayItems.AllNotesViewWrapper;
                }
            }
        }
Beispiel #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);
            }
        }
Beispiel #3
0
        private void OnSaveFolderChanges()
        {
            if (SelectedFolder == null)
            {
                return;
            }

            if ((SelectedFolder.ID == 2) ||
                (SelectedFolder.ID == 3) ||
                (SelectedFolder.ID == 4) ||
                (SelectedFolder.ID == 5) ||
                (SelectedFolder.ParentFolderID == 3) ||
                (SelectedFolder.ParentFolderID == 4) ||
                (SelectedFolder.ParentFolderID == 5))
            {
                UIMessager.ShowMessage("Операции с системными папками запрещены");
                return;
            }

            if (SelectedFolder.IsValid)
            {
                if (SelectedFolder.Push())
                {
                    UIMessager.ShowMessage(new LogicResponse(true, "data_saved").Message);
                    RefreshView();
                }
                else
                {
                    UIMessager.ShowMessage(new LogicResponse(false).Message);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// method to compress files
        /// </summary>
        public async void Compress()
        {
            // Retrieve files to compress


            // Created new file to store compressed files
            //This will create a file under the selected folder in the name “Compressed.zip”
            StorageFile zipFile = await SelectedFolder.CreateFileAsync("Compressed.zip", CreationCollisionOption.ReplaceExisting);

            // Create stream to compress files in memory (ZipArchive can't stream to an IRandomAccessStream, see
            // http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/62541424-ba7d-43d3-9585-1fe53dc7d9e2
            // for details on this issue)
            using (MemoryStream zipMemoryStream = new MemoryStream())
            {
                InProgress = true;
                // Create zip archive
                using (ZipArchive zipArchive = new ZipArchive(zipMemoryStream, ZipArchiveMode.Create))
                {
                    // For each file to compress...
                    foreach (StorageFile fileToCompress in filesToCompress)
                    {
                        BasicProperties fileProp = await fileToCompress.GetBasicPropertiesAsync();

                        if (fileProp.Size > 0)
                        {
                            //Read the contents of the file
                            byte[] buffer = WindowsRuntimeBufferExtensions.ToArray(await FileIO.ReadBufferAsync(fileToCompress));

                            string fileEntry = fileToCompress.Path.Replace(zipFile.Path.Replace(zipFile.Name, string.Empty), string.Empty);
                            // Create a zip archive entry
                            ZipArchiveEntry entry = zipArchive.CreateEntry(fileEntry, CompressionLevelSelected);

                            // And write the contents to it
                            using (Stream entryStream = entry.Open())
                            {
                                await entryStream.WriteAsync(buffer, 0, buffer.Length);
                            }
                        }
                    }
                }

                using (IRandomAccessStream zipStream = await zipFile.OpenAsync(FileAccessMode.ReadWrite))
                {
                    // Write compressed data from memory to file
                    using (Stream outstream = zipStream.AsStreamForWrite())
                    {
                        byte[] buffer = zipMemoryStream.ToArray();
                        outstream.Write(buffer, 0, buffer.Length);
                        outstream.Flush();
                    }
                }

                InProgress    = false;
                StatusMessage = "Files Zipped...";
            }
        }
Beispiel #5
0
        private void OnSelectedFolderChanged()
        {
            App.Logger.TraceExt("NotesViewHierarchical",
                                "OnSelectedFolderChanged",
                                Tuple.Create("SelectedNote", SelectedNote?.Title),
                                Tuple.Create("SelectedFolder", SelectedFolder?.Header));

            if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
            {
                var n         = SelectedFolder.AllSubNotes.FirstOrDefault();
                var oldfolder = SelectedFolder.GetInternalPath();
                new Thread(() =>
                {
                    Thread.Sleep(50);
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (SelectedFolder == null)
                        {
                            return;
                        }
                        if (!SelectedFolder.GetInternalPath().EqualsWithCase(oldfolder))
                        {
                            App.Logger.Debug("NotesViewHierarchical", "Prevent invalidated SelectedFolderChanged event to execute", $"'{SelectedFolder.GetInternalPath()}' <> '{oldfolder}'");
                            return;
                        }

                        if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderChanged (1) [thread]",
                                                Tuple.Create("SelectedNote", n?.Title));

                            SelectedNote = n;
                        }
                    }));
                }).Start();
            }

            var p = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();

            if (!p.EqualsIgnoreCase(SelectedFolderPath))
            {
                App.Logger.TraceExt("NotesViewHierarchical",
                                    "OnSelectedFolderChanged (2)",
                                    Tuple.Create("SelectedFolderPath", p.Formatted));

                SelectedFolderPath = p;
            }

            if (_isNotesInitialized)
            {
                _hierarchyCache.UpdateAndRequestSave(RepositoryAccountID, SelectedFolderPath, SelectedNote?.UniqueName);
            }
        }
Beispiel #6
0
        private void FileListView_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection items = FileListView.SelectedItems;
            _SelectedFiles = new string[items.Count];
            string separator = ExplorerHandler.PathSeparator.ToString();

            for (int x = 0; x < items.Count; x++)
            {
                _SelectedFiles[x] = SelectedFolder + (SelectedFolder.EndsWith(separator) ? "" : separator) + items[x].Text;
            }
        }
Beispiel #7
0
        private void urlShortcutToDesktop(string linkName, string linkUrl)
        {
            string deskDir = FileHelper.GetRootPath() + @"\" + SelectedFolder.Replace('|', '\\');

            using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
            {
                writer.WriteLine("[InternetShortcut]");
                writer.WriteLine("URL=" + linkUrl);
                writer.Flush();
            }
        }
Beispiel #8
0
        private void OnRepoChanged(DependencyPropertyChangedEventArgs args)
        {
            App.Logger.Trace("NotesViewHierarchical", "OnRepoChanged()");

            DisplayItems.ClearPermanents();

            if (AllNotes != null)
            {
                ResyncDisplayItems(AllNotes);
            }

            SelectedFolder?.TriggerAllSubNotesChanged();
        }
Beispiel #9
0
        private void ProcessIdleServerEvents()
        {
            while (true)
            {
                string tmp;
                if (!_idleEvents.TryDequeue(out tmp))
                {
                    if (_idleState == IdleState.On)
                    {
                        // instead of an instant retry: wait for a signal that will be emitted after a new value was put into the queue
                        _idleEventsResetEvent.WaitOne();
                        continue;
                    }
                    return;
                }


                Match match = Expressions.IdleResponseRex.Match(tmp);

                if (!match.Success)
                {
                    continue;
                }

                if (match.Groups[2].Value == "EXISTS")
                {
                    SelectedFolder.Status(new[] { FolderStatusFields.UIdNext });

                    if (_lastIdleUId != SelectedFolder.UidNext)
                    {
                        var msgs =
                            SelectedFolder.Search(string.Format("UID {0}:{1}", _lastIdleUId, SelectedFolder.UidNext));
                        var args = new IdleEventArgs
                        {
                            Folder   = SelectedFolder,
                            Messages = msgs
                        };
                        if (OnNewMessagesArrived != null)
                        {
                            OnNewMessagesArrived(SelectedFolder, args);
                        }
                        SelectedFolder.RaiseNewMessagesArrived(args);
                        _lastIdleUId = SelectedFolder.UidNext;
                    }
                }
            }
        }
        public List <Model.File> PickFolderAndFiles()
        {
            Owner = Application.Current.MainWindow;
            if (ShowDialog().GetValueOrDefault())
            {
                if (!string.IsNullOrEmpty(SelectedFolder))
                {
                    if (!SelectedFolder.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()))
                    {
                        SelectedFolder += System.IO.Path.DirectorySeparatorChar;
                    }

                    var searchOption = SearchOption.TopDirectoryOnly;
                    if (IncludeSubfolders)
                    {
                        searchOption = SearchOption.AllDirectories;
                    }

                    var files = new List <BlobTransferUtility.Model.File>();
                    try
                    {
                        foreach (var file in Directory.GetFiles(SelectedFolder, "*", searchOption))
                        {
                            var fileInfo = new FileInfo(file);
                            files.Add(new Model.File()
                            {
                                Name             = file.Substring(SelectedFolder.Length),
                                FullFilePath     = file,
                                SizeInBytes      = fileInfo.Length,
                                RelativeToFolder = SelectedFolder,
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        var stringBuilder = new StringBuilder();
                        stringBuilder.AppendFormat("{1:yyyy-MM-dd HH:mm:ss} Error!{0}", Environment.NewLine, DateTime.Now);
                        stringBuilder.AppendFormat("    Listing directories and files{0}", Environment.NewLine);
                        stringBuilder.AppendFormat("    Exception: {1}{0}{0}", Environment.NewLine, e.ToString().Replace(Environment.NewLine, Environment.NewLine + "    "));
                        OnOnError(stringBuilder.ToString());
                    }
                    return(files);
                }
                return(null);
            }
            return(null);
        }
Beispiel #11
0
        private void OnSettingsChanged(DependencyPropertyChangedEventArgs args)
        {
            App.Logger.Trace("NotesViewHierachical", "OnSettingsChanged()");

            DisplayItems.ClearPermanents();

            if (AllNotes != null)
            {
                ResyncDisplayItems(AllNotes);
            }

            if (args.NewValue != null && args.OldValue == null)
            {
                NotesViewFolderHeight = new GridLength(((AppSettings)args.NewValue).NotesViewFolderHeight);
            }

            SelectedFolder?.TriggerAllSubNotesChanged();
        }
Beispiel #12
0
        private void OnSelectedFolderChanged()
        {
            App.Logger.TraceExt("NotesViewHierachical",
                                "OnSelectedFolderChanged",
                                Tuple.Create("SelectedNote", SelectedNote?.Title),
                                Tuple.Create("SelectedFolder", SelectedFolder?.Header));

            if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
            {
                var n = SelectedFolder.AllSubNotes.FirstOrDefault();
                new Thread(() =>
                {
                    Thread.Sleep(50);
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (SelectedFolder != null && (SelectedNote == null || !SelectedFolder.AllSubNotes.Contains(SelectedNote)) && SelectedFolder.AllSubNotes.Any())
                        {
                            App.Logger.TraceExt("NotesViewHierachical",
                                                "OnSelectedFolderChanged (1) [thread]",
                                                Tuple.Create("SelectedNote", n?.Title));

                            SelectedNote = n;
                        }
                    }));
                }).Start();
            }

            var p = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();

            if (!p.EqualsIgnoreCase(SelectedFolderPath))
            {
                App.Logger.TraceExt("NotesViewHierachical",
                                    "OnSelectedFolderChanged (2)",
                                    Tuple.Create("SelectedFolderPath", p.Formatted));

                SelectedFolderPath = p;
            }
        }
Beispiel #13
0
        private void OnSelectedFolderPathChanged()
        {
            App.Logger.TraceExt("NotesViewHierarchical",
                                "OnSelectedFolderPathChanged",
                                Tuple.Create("SelectedFolderPath", SelectedFolderPath?.Formatted));

            if (SelectedFolderPath == null)
            {
                return;
            }
            if (DisplayItems == null)
            {
                return;
            }

            var f = DisplayItems.Find(SelectedFolderPath, true);

            if (f != null)
            {
                if (!f.IsSelected)
                {
                    App.Logger.TraceExt("NotesViewHierarchical",
                                        "OnSelectedFolderPathChanged (1)",
                                        Tuple.Create("f.IsSelected", "true"));

                    f.IsSelected = true;
                }
            }
            else
            {
                if (AllNotes == null && !SelectedFolderPath.IsRoot() && !SelectedFolderPath.EqualsIgnoreCase(SelectedFolder?.GetInternalPath()))
                {
                    App.Logger.TraceExt("NotesViewHierarchical", "OnSelectedFolderPathChanged (2)",
                                        Tuple.Create("SelectedFolder", SelectedFolder?.Header));

                    _initFolderPath    = SelectedFolderPath;
                    SelectedFolderPath = SelectedFolder?.GetInternalPath() ?? DirectoryPath.Root();
                }
                else
                {
                    if (DisplayItems.AllNotesViewWrapper != null)
                    {
                        if (!DisplayItems.AllNotesViewWrapper.IsSelected)
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderPathChanged (3)",
                                                Tuple.Create("DisplayItems.AllNotesWrapper.IsSelected", "true"));

                            DisplayItems.AllNotesViewWrapper.IsSelected = true;
                        }
                    }
                    else
                    {
                        var fod = DisplayItems.SubFolder.FirstOrDefault(p => !p.IsSpecialNode);
                        if (fod != null && !fod.IsSelected)
                        {
                            App.Logger.TraceExt("NotesViewHierarchical",
                                                "OnSelectedFolderPathChanged (4)",
                                                Tuple.Create("DisplayItems.SubFolder.FirstOrDefault().IsSelected", "true"));

                            fod.IsSelected = true;
                        }
                    }
                }
            }

            if (_isNotesInitialized)
            {
                _hierarchyCache.UpdateAndRequestSave(RepositoryAccountID, SelectedFolderPath, SelectedNote?.UniqueName);
            }
        }
Beispiel #14
0
 public DirectoryPath GetNewNotesPath()
 {
     return(SelectedFolder?.GetNewNotePath() ?? DirectoryPath.Root());
 }
Beispiel #15
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);
            }
        }
Beispiel #16
0
 protected virtual void OnSelectedFolder(EventArgs e)
 {
     SelectedFolder?.Invoke(this, e);
     Invalidate();
 }
Beispiel #17
0
        public bool SaveNewItem()
        {
            string folderName = SelectedFolder;

            string[] aplitedFolder = new string[0];
            if ((folderName.IndexOf(WidgetName) + WidgetName.Length + 1) < folderName.Length)
            {
                aplitedFolder = folderName.Substring(folderName.IndexOf(WidgetName) + WidgetName.Length + 1).Split('|');
            }
            string hiricalFolder = "";

            foreach (string index in aplitedFolder)
            {
                hiricalFolder += ConstValue.XMLFolderNS;
            }
            XmlDocument  xd = new XmlDocument();
            StreamReader sr = new StreamReader(System.Environment.CurrentDirectory + ConstValue.XMLFileName, System.Text.Encoding.GetEncoding("utf-8"));

            xd.Load(sr);
            XmlNode currentNode;

            if (hiricalFolder != "")
            {
                currentNode = xd.SelectSingleNode("/Brienz" + ConstValue.XMLFolderNS + ConstValue.XMLFolderNS + "[@" + ConstValue.XMLFileAttribute_FolderName + "='" + WidgetName + "']" + hiricalFolder + "[@" + ConstValue.XMLFileAttribute_FolderName + "='" + aplitedFolder[aplitedFolder.Length - 1] + "']");
            }
            else
            {
                currentNode = xd.SelectSingleNode("/Brienz" + ConstValue.XMLFolderNS + ConstValue.XMLFolderNS + "[@" + ConstValue.XMLFileAttribute_FolderName + "='" + WidgetName + "']" + "[@" + ConstValue.XMLFileAttribute_FolderName + "='" + WidgetName + "']");
            }
            bool result = false;

            switch (SeletedTab)
            {
            case "Link":


                XmlDocument DomainDoc = new XmlDocument();
                urlShortcutToDesktop(LinkTab_Name, LinkTab_URL);
                result = true;
                break;

            case "File":
                if (IsCheckWord)
                {
                    string     deskDir = FileHelper.GetRootPath() + @"\" + SelectedFolder.Replace('|', '\\') + @"\" + FileName + ".doc";
                    FileStream fs      = File.Create(deskDir);
                    fs.Close();
                    Process.Start(deskDir);
                }
                else if (IsCheckExcel)
                {
                    string     deskDir = FileHelper.GetRootPath() + @"\" + SelectedFolder.Replace('|', '\\') + @"\" + FileName + ".xls";
                    FileStream fs      = File.Create(deskDir);
                    fs.Close();
                    Process.Start(deskDir);
                }
                else if (IsCheckTxt)
                {
                    string     deskDir = FileHelper.GetRootPath() + @"\" + SelectedFolder.Replace('|', '\\') + @"\" + FileName + ".txt";
                    FileStream fs      = File.Create(deskDir);
                    fs.Close();
                    Process.Start(deskDir);
                }
                else if (IsCheckZip)
                {
                }
                result = true;
                break;

            case "GOGO":
                result = true;
                break;
            }
            return(result);
        }