Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <modify>
 /// Author  date        Comment
 /// Anhhn   9/6/2015    Tao moi
 /// </modify>
 public void InitializeControllAction()
 {
     List<SysAction> lstAction = new List<SysAction>();
     //Account
     List<ActionDefine> lstActionDefine = InitializerAction.getActionDefine();
     SysAction action;
     string[] actionCustom;
     string[] actionParam;
     string[] actionCustomDesc;
     string[] actionCustomMenu;
     string controllerDesc = string.Empty;
     string[] lstActionType = ActionType.GroupAll.Split('|');
     string[] lstActionTypeDesc = ActionTypeDesc.GroupAll.Split('|');
     string[] lstActionTypeMenu = ActionTypeMenu.GroupAll.Split('|');
     foreach (ActionDefine item in lstActionDefine)
     {
         action = new SysAction();
         //if (!string.IsNullOrWhiteSpace(item.Component))
         //    action. = item.Component;
         if (!string.IsNullOrWhiteSpace(item.AreaName))
             action.Area = item.AreaName.ToLower();
         else action.Area = "";
         if (!string.IsNullOrWhiteSpace(item.ControllerName))
             action.Controller = item.ControllerName.ToLower();
         if (!string.IsNullOrWhiteSpace(item.ControllerDes))
             controllerDesc = item.ControllerDes;
         if (!string.IsNullOrWhiteSpace(item.ActionIgnore))
         {
             for (int i = 0; i < lstActionType.Length; i++ )
             {
                 if (!item.ActionIgnore.Contains(lstActionType[i]))
                     lstAction.Add(buildAction(action, lstActionType[i], lstActionTypeDesc[i] + " " + controllerDesc, lstActionTypeMenu[i], ""));
             }
         }
         else
         {
             for (int i = 0; i < lstActionType.Length; i++)
             {
                 lstAction.Add(buildAction(action, lstActionType[i], lstActionTypeDesc[i] + " " + controllerDesc, lstActionTypeMenu[i], ""));
             }
         }
         if (!string.IsNullOrWhiteSpace(item.ActionCustom))
         {
             actionCustom = item.ActionCustom.Split('|');
             int countCustom = actionCustom.Length;
             if (!string.IsNullOrWhiteSpace(item.ActionParam))
                 actionParam = item.ActionParam.Split('|');
             else
                 actionParam = newStringArray(countCustom);
             if (!string.IsNullOrWhiteSpace(item.ActionCustomDes))
                 actionCustomDesc = item.ActionCustomDes.Split('|');
             else
                 actionCustomDesc = newStringArray(countCustom);
             if (!string.IsNullOrWhiteSpace(item.ActionCustomMenu))
                 actionCustomMenu = item.ActionCustomMenu.Split('|');
             else
                 actionCustomMenu = newStringArray(countCustom);
             for (int i = 0; i < countCustom; i++)
                 lstAction.Add(buildAction(action, actionCustom[i], actionCustomDesc[i], actionCustomMenu[i], actionParam[i]));
         }
     }
     ISysActionBussiness AcBsc = new SysActionBussiness();
     try{
         AcBsc.UpdateActions(lstAction);
     }
     catch (Exception e)
     {
         Exception ex = new Exception("ID = 1", e);
         ErrorSignal.FromCurrentContext().Raise(ex);
     }
 }
Example #2
0
 /// <summary>
 /// Tao Action
 /// </summary>
 /// <param name="controller"></param>
 /// <param name="action"></param>
 /// <param name="code"></param>
 /// <param name="area"></param>
 /// <param name="desc"></param>
 /// <param name="pram"></param>
 /// <returns></returns>
 private SysAction buildAction(SysAction actionDefine, string action, string desc,string isMenu, string pram)
 {
     SysAction sAction = new SysAction();
     sAction.Controller = actionDefine.Controller;
     sAction.Area = actionDefine.Area;
     sAction.Action = action;
     sAction.Description = desc;
     sAction.Params = pram.ToLower();
     string area = string.IsNullOrWhiteSpace(actionDefine.Area) ? "" : actionDefine.Area.ToLower() + "_";
     sAction.Code = area + actionDefine.Controller.ToLower() + "_" + action.ToLower();
     sAction.IsMenu = isMenu == "1"? true : false;
     return sAction;
 }