コード例 #1
0
ファイル: Image.cs プロジェクト: kimduquan/DMIS
        protected override void OnModifying(object sender, Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnModifying(sender, e);
            if (!e.Cancel)
            {
                var img = sender as Image;
                if (img == null)
                {
                    return;
                }

                if (img.SavingState == ContentSavingState.Finalized)
                {
                    SetDimension(img);
                }
                else
                {
                    //postpone dimension setting because the content is not yet finalized
                    e.CustomData = new Dictionary <string, object>()
                    {
                        { SETDIMENSION_KEYNAME, true }
                    };
                }
            }
        }
コード例 #2
0
ファイル: SurveyItem.cs プロジェクト: kimduquan/DMIS
        protected override void OnCreating(object sender, Storage.Events.CancellableNodeEventArgs e)
        {
            base.OnCreating(sender, e);

            var searchPath = e.SourceNode.Parent.GetType().Name == "Survey" ? e.SourceNode.ParentPath : e.SourceNode.Parent.ParentPath;

            // Count Survey Items
            var surveyItemCount = ContentQuery.Query("+Type:surveyitem +InTree:@0 .AUTOFILTERS:OFF .COUNTONLY", null, searchPath).Count;

            // Get children (SurveyItems) count
            String tempName;

            if (surveyItemCount < 10 && surveyItemCount != 9)
            {
                tempName = "SurveyItem_0" + (surveyItemCount + 1);
            }
            else
            {
                tempName = "SurveyItem_" + (surveyItemCount + 1);
            }

            // If node already exits
            while (Node.Exists(RepositoryPath.Combine(e.SourceNode.Parent.Path, tempName)))
            {
                surveyItemCount++;
                if (surveyItemCount < 10)
                {
                    tempName = "SurveyItem_0" + (surveyItemCount + 1);
                }
                else
                {
                    tempName = "SurveyItem_" + (surveyItemCount + 1);
                }
            }

            e.SourceNode["DisplayName"] = tempName;
            e.SourceNode["Name"]        = tempName.ToLower();
        }
コード例 #3
0
 protected virtual void OnPermissionChanging(object sender, CancellableNodeEventArgs e)
 {
 }
コード例 #4
0
 protected virtual void OnNodeDeletingPhysically(object sender, CancellableNodeEventArgs e)
 {
 }
コード例 #5
0
 protected virtual void OnNodeModifying(object sender, CancellableNodeEventArgs e)
 {
 }
コード例 #6
0
        internal static void FireOnPermissionChanging(CancellableNodeEventHandler Deleting, Node sender, CancellableNodeEventArgs e, List <Type> disabledObservers)
        {
            InvokeCancelEventHandlers(Deleting, sender, e);
            var observers = NodeTypeManager.Current.NodeObservers;

            if (observers == null)
            {
                return;
            }
            if (disabledObservers == null)
            {
                foreach (NodeObserver observer in observers)
                {
                    observer.OnPermissionChanging(sender, e);
                }
            }
            else
            {
                foreach (NodeObserver observer in observers)
                {
                    if (!disabledObservers.Contains(observer.GetType()))
                    {
                        observer.OnPermissionChanging(sender, e);
                    }
                }
            }
        }
コード例 #7
0
        internal static void InvokeCancelEventHandlers(CancellableNodeEventHandler handler, object sender, CancellableNodeEventArgs e)
        {
            if (handler == null)
            {
                return;
            }

            Exception firstException = null;

            Delegate[] list   = (Delegate[])handler.GetInvocationList().Clone();
            bool       cancel = false;

            foreach (CancellableNodeEventHandler del in list)
            {
                try
                {
                    del(sender, e);
                    cancel   = cancel | e.Cancel;
                    e.Cancel = cancel;
                }
                catch (Exception ex)                 //TODO: catch block
                {
                    //LogException(source, ex);
                    if (firstException == null)
                    {
                        firstException = ex;
                    }
                }
            }

            if (firstException != null)
            {
                throw firstException;
            }
        }