}         // ctor

        public PpsTagItemModel(PpsObject ppsObject, PpsObjectTagBase tag)
        {
            this.ppsObject = ppsObject;
            this.tag       = tag;

            this.currentClass = tag.Class;
        }         // ctor
        public PpsTagItemModel(PpsObject ppsObject, PpsObjectTagClass newClass)
        {
            this.ppsObject = ppsObject;
            this.tag       = null;

            this.currentClass = newClass;
        }         // ctor
        }         // 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
예제 #4
0
        public FileInfo GetLocalTempFileInfo(PpsObject obj)
        {
            // create temp directory
            var tempDirectory = new DirectoryInfo(Path.Combine(LocalPath.FullName, "tmp"));

            if (!tempDirectory.Exists)
            {
                tempDirectory.Create();
            }

            // build filename
            if (obj.TryGetProperty <string>(PpsObjectBlobData.FileNameTag, out var fileName))
            {
                fileName = obj.Guid.ToString("N") + "_" + fileName;
            }
            else
            {
                fileName = obj.Guid.ToString("N") + MimeTypeMapping.GetExtensionFromMimeType(obj.MimeType);
            }

            return(new FileInfo(Path.Combine(tempDirectory.FullName, fileName)));
        }         // func GetLocalTempFileInfo
        /// <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
예제 #6
0
 public Task <PpsObjectDataSet> PullRevisionAsync(PpsObject obj, long revId)
 => obj.PullRevisionAsync <PpsObjectDataSet>(revId);