1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164:
| namespace CreateNewFolder { class Plugin : Nscale.Imaf.UI.Plugin.ResourceCommandPluginBase { #region Fields public static RoutedUICommand CreateNewProjectFolderCommand = new RoutedUICommand("Create a new projekt folder", "CreateNewProjectFolderCommand", typeof(Plugin)); PluginUICommandDescriptor CreateNewProjectFolderDescriptor;
private RepositoryFolder parent; private bool executePermission = false;
IList<CustomPermissionDefinition> customPermissions = new List<CustomPermissionDefinition>();
ConfigurationData data = new ConfigurationData(); #endregion
#region Properties
public override string Name { get { return "CreateNewProjectFolderCommand"; } }
public override string Description { get { return "This plugin creates a new projectfolder"; } }
public override string Vendor { get { return "Techno"; } }
public override IEnumerable<ICommand> HandledCommands { get { yield return CreateNewProjectFolderCommand; } }
#endregion
#region Methods
public override void Initialize() { base.Initialize();
if (Session.Instance.IsDisconnecting) return;
data = null; string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Configuration.xml";
if (File.Exists(path)) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ConfigurationData));
TextReader reader = new StreamReader(path); try { data = (ConfigurationData)serializer.Deserialize(reader); } finally { reader.Close(); } } else data = new ConfigurationData("ok_Vater", "ok_Kinder", String.Empty, new List<string>() { "ec_1", "ec_2" }, new List<string>());
if (Session.Instance.IsConnected) { var connector = Session.Instance.GetALConnector(); try { IList<string> groupIDs = connector.ACSession.SessionGroupIds; IList<PrincipalEntity> groupEntities = connector.GetPrincipalEntities(groupIDs, true); List<string> groupNames = groupEntities.Select(group => ((Group)group).Name).ToList<string>();
foreach (string groupName in groupNames) { if (data.ExecutePermissions.Contains(groupName)) executePermission = true; } } finally { connector.Release(); } } }
void CreateNewakte_Initialize() { if (Session.Instance.CurrentDocumentAreaName == null) return;
var alCon = Session.Instance.GetALConnector(); try { RepositoryFolder root = RepositoryFolder.GetDocumentAreaRootFolder(Session.Instance.CurrentDocumentAreaName, false);
string nql = "Where objectclass='" + data.ParentFolderObjectclass + "'"; if (data.ParentFolderDisplayname != String.Empty) nql += " and displayname='" + data.ParentFolderDisplayname + "'";
Resources result = alCon.GetRepositoryResources(nql, false, root, "", false); if (result.Count > 0) { parent = result[0] as RepositoryFolder; } } catch (Exception exc) { } finally { alCon.Release(); } }
void NewakteButton_Click(object sender, RoutedEventArgs e) { if (parent == null && Session.Instance.IsConnected) CreateNewakte_Initialize();
if (parent != null) { Dictionary<string, object> properties = new Dictionary<string, object>(); properties.Add("displayname", "Akte in Erstellung " + DateTime.Now.ToShortTimeString()); RepositoryFolder newFolder = parent.CreateFolder(data.NewFolderObjectclass, properties, false);
Application.Current.Dispatcher.BeginInvoke((Action)delegate { System.Windows.Window w = UISession.Instance.InvokeProperties(UISession.Instance.GetActiveWindow(), newFolder, false); }); } else ModalDialog.MessageBox(ResizeMode.NoResize, MessageBoxIcon.Error, "Fehler beim Erstellen!", "Es konnte kein 'Akten'-Ordner gefunden werden.\nBitte melden Sie sich neu im Cockpit an oder melden Sie sich bei Ihrem Administrator", null, new List<DialogButtonDescription>() { new DialogButtonDescription(null, DialogButtons.Ok, Visibility.Visible, true) }, "", UISession.Instance.GetActiveWindow()); }
public override void ExtendUIObject(object uiObject, string objectResourceKey, string settingContext, System.Windows.Window parentWindow) { if (objectResourceKey == "ndt_MainWindowToolBar" && executePermission && data.DocumentAreas.Contains(Session.Instance.CurrentDocumentAreaName)) { MainMenuButtonControl btn = new MainMenuButtonControl(); btn.NewakteButton.Click += new RoutedEventHandler(NewakteButton_Click); btn.NewakteButton.ToolTip = "Neue Akte erstellen";
ToolBarTray tray = uiObject as ToolBarTray; ToolBar toolbar = tray.ToolBars[0]; toolbar.Items.Add(btn); } } #endregion } } |