/// <summary> /// 要素目录新增 /// </summary> /// <param name="element"></param> public void CreateElement(Element element) { DateTime dt = NewData.NewDate(); string uid = NewData.NewGuid(); ElementDAL elementDAL = new ElementDAL(); elementDAL.CreateElement(element, dt, uid); }
/// <summary> /// 新增文本值域选项 /// </summary> /// <param name="elementRange">文本值域选项对象</param> /// <param name="dt">最后修改时间</param> /// <param name="nid">新GUID</param> public void CreateElementRange(ElementRange elementRange) { ///获取当前时间 DateTime dt = NewData.NewDate(); //获取新的GUID string nid = NewData.NewGuid(); ElementRangeDAL elementRangeDAL = new ElementRangeDAL(); elementRangeDAL.CreateElementRange(elementRange, dt, nid); }
/// <summary> /// 新增统计指标 /// </summary> /// <param name="countNorm">统计指标对象</param> /// <param name="dt">最后修改时间</param> /// <param name="nid">新GUID</param> public void CreateCountNorm(CountNorm countNorm) { ///获取当前时间 DateTime dt = NewData.NewDate(); //获取新的GUID string nid = NewData.NewGuid(); CountNormDAL countNormDAL = new CountNormDAL(); countNormDAL.CreateCountNorm(countNorm, dt, nid); }
/// <summary> /// 新增资源目录 /// </summary> /// <param name="resource">资源目录对象</param> /// <param name="dt">最后修改时间</param> /// <param name="nid">新GUID</param> public void CreateResource(Resource resource) { ///获取当前时间 DateTime dt = NewData.NewDate(); //获取新的GUID string nid = NewData.NewGuid(); ResourceDAL resourceDAL = new ResourceDAL(); resourceDAL.CreateResource(resource, dt, nid); }
/// <summary> /// 新增要素分类 /// </summary> /// <param name="elementClassify">要素分类对象</param> /// <param name="dt">最后修改时间</param> /// <param name="nid">新GUID</param> public void CreateElementClassify(ElementClassify elementClassify) { ///获取当前时间 DateTime dt = NewData.NewDate(); //获取新的GUID string nid = NewData.NewGuid(); ElementClassifyDAL elementClassifyDAL = new ElementClassifyDAL(); elementClassifyDAL.CreateElementClassify(elementClassify, dt, nid); }
/// <summary> /// 新增主体权限 /// </summary> /// <param name="mainAuthority">主体权限对象</param> /// <param name="dt">最后修改时间</param> /// <param name="nid">新GUID</param> public void CreateMainAuthority(MainAuthority mainAuthority) { //获取当前时间 DateTime dt = NewData.NewDate(); //获取新的GUID string nid = NewData.NewGuid(); //新增主体权限 MainAuthorityDAL mainAuthorityDAL = new MainAuthorityDAL(); mainAuthorityDAL.CreateMainAuthority(mainAuthority, dt, nid); //新增人员权限 PersonnelAuthorityDAL personnelAuthorityDAL = new PersonnelAuthorityDAL(); personnelAuthorityDAL.CreatePersonnelAuthority(nid); }
public void Drop(IDropInfo dropInfo) { // There is nothing we can do here. if (dropInfo == null) { return; } // Data is populated from external and internal drag & drop. If it is null there is nothing we can do here. if (dropInfo.Data == null) { return; } // Check if target is not group, if yes, then there is nothing we can do here. bool targetIsTreeViewItem = dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.TargetItemCenter) && dropInfo.VisualTargetItem is TreeViewItem; if (targetIsTreeViewItem) { TreeViewItem treeViewItem = (TreeViewItem)dropInfo.VisualTargetItem; ItemVM itemVM = (ItemVM)treeViewItem.DataContext; if (!itemVM.IsGroup) { return; } } // Target is group proced with the other checks... var insertIndex = dropInfo.InsertIndex != dropInfo.UnfilteredInsertIndex ? dropInfo.UnfilteredInsertIndex : dropInfo.InsertIndex; var itemsControl = dropInfo.VisualTarget as ItemsControl; if (itemsControl != null) { var editableItems = itemsControl.Items as IEditableCollectionView; if (editableItems != null) { var newItemPlaceholderPosition = editableItems.NewItemPlaceholderPosition; if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtBeginning && insertIndex == 0) { ++insertIndex; } else if (newItemPlaceholderPosition == NewItemPlaceholderPosition.AtEnd && insertIndex == itemsControl.Items.Count) { --insertIndex; } } } var destinationList = dropInfo.TargetCollection.TryGetList(); var data = ExtractData(dropInfo.Data).OfType <object>().ToList(); // If this is a move for sure it is from the internal Drag & Drop, so delete the source item. DragDropEffects dragDropEffects = GetDragDropEffects(dropInfo); if (dragDropEffects == DragDropEffects.Move) { if (dropInfo.DragInfo != null) { // This is a drag & drop item from treeview its self var sourceList = dropInfo.DragInfo.SourceCollection.TryGetList(); if (sourceList != null) { foreach (var o in data) { var index = sourceList.IndexOf(o); if (index != -1) { sourceList.RemoveAt(index); // so, is the source list the destination list too ? if (destinationList != null && Equals(sourceList, destinationList) && index < insertIndex) { --insertIndex; } } } } } } // Add item if (destinationList != null) { // check for cloning var cloneData = dropInfo.Effects.HasFlag(DragDropEffects.Copy) || dropInfo.Effects.HasFlag(DragDropEffects.Link); foreach (var o in data) { // ---------------------------------------------- // This is a Drag & Drop from the external source // ---------------------------------------------- if (dropInfo.Data is DataObject) { DataObject dataObject = o as DataObject; if (dataObject != null) { // ****************************************************************************************************************************************** // FileDrop. Queries a data object for the presence of data in the System.Windows.DataFormats.FileDrop data format. // ****************************************************************************************************************************************** if (dataObject.ContainsFileDropList() && dataObject.GetDataPresent(DataFormats.FileDrop, true)) { // We can have more than one file dropped. var droppedFilePaths = dataObject.GetFileDropList(); foreach (string droppedFilePath in droppedFilePaths) { string shortcutsDirectoryPath = Helper.GetShortcutsPath(); string guid = NewData.NewGuid(); string name = Path.GetFileName(droppedFilePath); DirectoryInfo directoryInfo = new DirectoryInfo(droppedFilePath); if (directoryInfo.Parent == null) { // This is the root. In that case name is empty so we need to set the name differently. DriveInfo driveInfo = new DriveInfo(droppedFilePath); // Something like this: Local Disk (C:) string volumeLabel = driveInfo.VolumeLabel; if (string.IsNullOrEmpty(volumeLabel)) { volumeLabel = "Drive"; } name = $"{volumeLabel} ({driveInfo.Name.Replace(@"\", "")})"; } ItemVM obj2Insert = null; // Check if the dropped file is a .lnk file. We just copy the .lnk files to the sortcuts folder and use them from there. if (Path.GetExtension(droppedFilePath).Equals(Constants.EXT_LNK, StringComparison.InvariantCultureIgnoreCase)) { // This is a .lnk file. In this case we copy this file to our shortcuts string shortcutLnkFilePath = Path.Combine(shortcutsDirectoryPath, guid + Constants.EXT_LNK); File.Copy(droppedFilePath, shortcutLnkFilePath); obj2Insert = new ItemVM(guid, false, false, name, shortcutLnkFilePath, Constants.EXT_LNK); } // Check if the dropped file is a .url file. We just copy the .url files to the sortcuts folder and use them from there. else if (Path.GetExtension(droppedFilePath).Equals(Constants.EXT_URL, StringComparison.InvariantCultureIgnoreCase)) { // This is a .url file. In this case we copy this file to our shortcuts string shortcutUrlFilePath = Path.Combine(shortcutsDirectoryPath, guid + Constants.EXT_URL); File.Copy(droppedFilePath, shortcutUrlFilePath); obj2Insert = new ItemVM(guid, false, false, name, shortcutUrlFilePath, Constants.EXT_URL); } else { obj2Insert = new ItemVM(guid, false, false, name, droppedFilePath, Constants.EXT_LNK); } destinationList.Insert(insertIndex++, obj2Insert); SaveShortcutSettings(); } } // ****************************************************************************************************************************************** // AbsoluteUri. Queries a data object for the presence of data in the System.Windows.DataFormats.UnicodeText format. // ****************************************************************************************************************************************** else if (dataObject.ContainsText() && dataObject.GetDataPresent(DataFormats.Text, true)) { string dataText = (string)dataObject.GetData(DataFormats.Text, true); Uri uri; bool isAbsoluteUri = Uri.TryCreate(dataText, UriKind.Absolute, out uri); if (isAbsoluteUri) { ItemVM obj2Insert = new ItemVM(NewData.NewGuid(), false, false, uri.AbsoluteUri, uri.AbsoluteUri, Constants.EXT_URL); destinationList.Insert(insertIndex++, obj2Insert); // Save shortcut settings. SaveShortcutSettings(); } } else { // ****************************************************************************************************************************************** // ShellIDListArray. Perhaps data contain virtual files // ****************************************************************************************************************************************** // Returns a list of formats in which the data in this data object is stored, or can be converted to. string[] formats = dataObject.GetFormats(); foreach (string format in formats) { if (format == "Shell IDList Array") { // Virtual file/s been draged. string message = "To create this kind of shortcut please do:\n"; message += "1. Drag to create a desktop shortcut first,\n"; message += "2. Drag the shortcut from desktop to MDSHO,\n"; message += "3. Delete the shortcut from desktop if you want."; Window parent = Helper.GetWindowFromWindowItemVM(this); MessageBox.Show(parent, message, "Information", MessageBoxButton.OK, MessageBoxImage.Information); } } } } } // --------------------------------------------------------------------------- // This is a Drag & Drop from the internal source. Item from treeview its self // --------------------------------------------------------------------------- else { var obj2Insert = o; if (cloneData) { var cloneable = o as ICloneable; if (cloneable != null) { obj2Insert = cloneable.Clone(); } } destinationList.Insert(insertIndex++, obj2Insert); // Save shortcut settings. SaveShortcutSettings(); } } } }