} // proc InitializeData /// <summary></summary> /// <param name="commit"></param> /// <returns></returns> public override async Task <bool> UnloadAsync(bool?commit = default(bool?)) { if (data != null && data.IsDirty) { await CommitEditAsync(); } dataAccess?.Dispose(); dataAccess = null; data = null; obj = null; return(await base.UnloadAsync(commit)); } // func UnloadAsync
/// <summary></summary> /// <param name="arguments"></param> /// <returns></returns> protected override async Task LoadInternAsync(LuaTable arguments) { async Task CreateNewObjectAsync() { // load schema var documentType = (string)arguments.GetMemberValue("createNew"); if (documentType == null) { throw new ArgumentException("No 'object' or 'createNew' set."); } // get the object info for the type var objectInfo = Shell.ObjectInfos[documentType]; if (objectInfo.CreateServerSiteOnly || String.IsNullOrEmpty(objectInfo.DocumentUri)) { throw new ArgumentNullException("object", "Parameter 'object' is missing."); } // create the new object entry obj = await Shell.CreateNewObjectAsync(objectInfo); } // proc CreateNewObject // get the object reference for the document obj = (PpsObject)arguments.GetMemberValue("Object"); // new document or load one using (var transaction = await Shell.MasterData.CreateTransactionAsync(PpsMasterDataTransactionLevel.Write)) { if (obj == null) // no object given { await CreateNewObjectAsync(); } data = await obj.GetDataAsync <PpsObjectDataSet>(); // register events, owner, and in the openDocuments dictionary dataAccess = await data.AccessAsync(arguments); dataAccess.DisableUI = new Func <IDisposable>(() => DisableUI("Verarbeite Daten...", -1)); dataAccess.DataChanged += (sender, e) => OnDataChanged(); transaction.Commit(); } // get the pane to view, if it is not given if (!arguments.ContainsKey("pane")) { // try to get the uri from the pane list var info = Shell.GetObjectInfo(obj.Typ); var paneUri = info["defaultPane"] as string; if (!String.IsNullOrEmpty(paneUri)) { arguments.SetMemberValue("Pane", paneUri); } else { // read the schema meta data paneUri = data.DataSetDefinition.Meta.GetProperty <string>(PpsDataSetMetaData.DefaultPaneUri, null); if (!String.IsNullOrEmpty(paneUri)) { arguments.SetMemberValue("Pane", paneUri); } } } // Load mask await base.LoadInternAsync(arguments); InitializeData(); } // proc LoadInternAsync