Пример #1
0
        public ActionResult GetMenus()
        {
            var icons = new[]
            {
                "fa-th", "fa-desktop", "fa-table", "fa-bar-chart-o", "fa-pencil-square-o", "fa-picture-o", "fa-calendar",
                "fa-credit-card","fa-laptop", "fa-hdd-o", "fa-tasks"," fa-list-alt"
            };

            //var userRoleIds = IdentityContract.UserRoleMaps
            //    .Where(p => p.User.UserName == User.Identity.Name).Select(p => p.Role.Id).Distinct().ToList();

            //var functions = SecurityContract.FunctionRoleMaps
            //    .Where(p => userRoleIds.Contains(p.Role.Id))
            //    .Where(p => !p.Function.IsLocked && !p.Function.IsCustom && !p.Function.IsAjax && p.Function.PlatformToken == PlatformToken.Mvc && p.Function.Controller != "Home")
            //    .Select(p => p.Function).Distinct().OrderBy(p => p.OrderNo).ToList();
            var functions =
                SecurityContract.Functions.Where(p => !p.IsLocked && !p.IsCustom && !p.IsAjax && p.PlatformToken == PlatformToken.Mvc && p.Controller != "Home")
                    .OrderBy(p => p.OrderNo)
                    .ToList();

            int i = 0;
            var menus = functions.Where(p => p.IsController).Select(p =>
            {
                return new TreeNode()
                {
                    Id = p.Id,
                    Text = p.Name,
                    IconCls = icons[i++ % icons.Count()],
                    Url = Url.Action(p.Action, p.Controller, new { area = p.Area }),
                    Children =
                        functions.Where(
                            m => m.Controller == p.Controller && m.Area == p.Area && !m.IsController && m.IsMenu)
                            .Select(m =>
                            {
                                string url = Url.Action(m.Action, m.Controller, new { area = m.Area });
                                if (url == "/") url = "";
                                return new TreeNode()
                                {
                                    Id = m.Id,
                                    Text = m.Name,
                                    IconCls = "",
                                    Url = url,
                                };
                            }).ToList()
                };
            }).ToList();
            return Json(menus);
        }
Пример #2
0
		protected override void OnValidating(C.CancelEventArgs e) {
			if (this.record)
				events.Enqueue(String.Format("{0}:{1}:OnValidating", this, this.Name));
			base.OnValidating (e);
		}
Пример #3
0
 protected virtual void OnPropertyChanged(SCM.PropertyChangedEventArgs e)
 {
     if (this.PropertyChanged == null)
     {
         return;
     }
     this.PropertyChanged((object)this, e);
 }
Пример #4
0
        private static string ParseBoolean(string value)
        {
            const string code0 = "code 0"; // except value that we consider as true (1)
            var valueInLower = value.ToLower();
            var falseKeywords = new[] { "0", "-1", "desactivated", "deactivated", "disabled", "error", "failed", "false", "fail", "none", "not", "no", "time out", "timeout", "out", "unsuccess", "unexpected", "unable", "warning" };

            return falseKeywords.Where(valueInLower.Contains).Any(keyword => !valueInLower.Contains(code0)) ? "0" : "1";
        }
Пример #5
0
 protected virtual void OnCurrentChanging(SCM.CurrentChangingEventArgs args)
 {
     if (args == null)
     {
         throw new ArgumentNullException("args");
     }
     if (this.CurrentChangedMonitor.Busy)
     {
         if (!args.IsCancelable)
         {
             return;
         }
         args.Cancel = true;
     }
     else
     {
         if (this.CurrentChanging == null)
         {
             return;
         }
         this.CurrentChanging((object)this, args);
     }
 }
Пример #6
0
        /// <summary>
        /// Gets the throw clause.
        /// </summary>
        /// <returns>return catch...throw statement</returns>
        internal static CodeCatchClause[] GetThrowClause()
        {
            var catchStatmanents = new CodeStatementCollection();
            catchStatmanents.Add(new CodeThrowExceptionStatement(new CodeVariableReferenceExpression("ex")));
            var catchClause = new CodeCatchClause(
                                                    "ex",
                                                    new CodeTypeReference(typeof(Exception)),
                                                    catchStatmanents.ToArray());

            var catchClauses = new[] { catchClause };
            return catchClauses;
        }
Пример #7
0
        /// <summary>
        /// Return catch statements
        /// </summary>
        /// <returns>CodeCatchClause statements</returns>
        internal static CodeCatchClause[] GetCatchClause()
        {
            var catchStatmanents = new CodeStatement[2];

            catchStatmanents[0] = new CodeAssignStatement(
                new CodeVariableReferenceExpression("exception"),
                new CodeVariableReferenceExpression("ex"));

            catchStatmanents[1] = GetReturnFalse();
            var catchClause = new CodeCatchClause(
                                                    "ex",
                                                    new CodeTypeReference(typeof(Exception)),
                                                    catchStatmanents);

            var catchClauses = new[] { catchClause };
            return catchClauses;
        }
Пример #8
0
 private void OnPropertyChanged(object sender, SCM.PropertyChangedEventArgs args)
 {
     SCM.PropertyChangedEventHandler propertyChangedEventHandler = this.PropertyChanged;
     if (propertyChangedEventHandler != null)
     {
         propertyChangedEventHandler(this, args);
     }
 }
Пример #9
0
 private void OnCurrentChanging(object sender, SCM.CurrentChangingEventArgs args)
 {
     SCM.CurrentChangingEventHandler currentChangingEventHandler = this.CurrentChanging;
     if (currentChangingEventHandler != null)
     {
         currentChangingEventHandler(this, args);
     }
 }