Example #1
0
        public virtual void OnChangeDocument(FileSystemEventArgs e)
        {
            try
            {
                var file = new FileInfo(e.FullPath);

                if (!IsAcceptExtention(file.Extension) || CheckIgnorePrefix(file.FullName))
                {
                    Engine.Logger?.Debug(ScopeType.Watcher, $"Skip File : {file.FullName}");

                    return;
                }

                var types  = Engine.Option.TypeOf;
                var typeOf = file.Directory.Name;
                if (typeOf == DocumentDefaults.Contents)
                {
                    typeOf = file.Directory.Parent.Name;

                    Engine.Logger?.Debug(ScopeType.Watcher, $"TypeOf: {typeOf} Contents changes");
                }

                var trans = Engine.GetThreadTransaction();

                if (trans != null)
                {
                    if (trans.TypeOfLock.Contains(typeOf.ToLowerInvariant()))
                    {
                        Engine.Logger?.Debug(ScopeType.Watcher, $"{typeOf} is Locked");

                        return;
                    }
                }

                if (types.Count(t => t.TypeOf.ToLowerInvariant() == typeOf.ToLowerInvariant()) > 0)
                {
                    Engine.Logger?.Debug(ScopeType.Watcher, $"OnChangeDocument TypeOf: {typeOf} - File: {file.FullName}");

                    Engine.LoadDocumentType(typeOf);
                }
            }
            catch (Exception ex)
            {
                Engine.Logger?.Error("Watcher OnChangeDocument:", ex);
            }
        }
Example #2
0
        public DocumentWriter(IDocumentEngine engine, string typeOf)
        {
            Ensure.NotNullOrEmpty(typeOf, "TypeOf is empty");

            TypeOf         = typeOf;
            Engine         = engine;
            Meta           = engine.GetTypeMeta(typeOf);
            IsPartialStore = Engine.Option.SupportPartialStorage;

            if (IsPartialStore)
            {
                PartialStoreLimit = Engine.Option.SupportPartialStorageSize;
            }

            Transaction = Engine.GetThreadTransaction();

            if (Transaction == null)
            {
                Transaction = Engine.BeginInternalTransaction();
            }

            Transaction.EnterTypeOfLock(typeOf);
        }