private static SysPathRule[] InnerGetRules()
        {
            List <SysPathRule>        list;
            List <SysPathRuleItem>    list2;
            Dictionary <int, SysPath> dictionary;
            SysPathRule current;

            using (BizDataContext context = new BizDataContext(true))
            {
                dictionary = context.FetchAll <SysPath>().ToDictionary <SysPath, int>(t => t.PathId);
                list       = context.FetchAll <SysPathRule>();
                list2      = context.FetchAll <SysPathRuleItem>();
            }
            using (List <SysPathRule> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    current      = enumerator.Current;
                    current.Path = dictionary[current.PathId].Path.ToLower();
                }
            }
            Dictionary <int, SysPathRule> dictionary2 = list.ToDictionary <SysPathRule, int, SysPathRule>(p => p.PathRuleId, p => p);
            Dictionary <int, IGrouping <int, SysPathRuleItem> > dictionary3 = (from p in list2 group p by p.PathRuleId).ToDictionary <IGrouping <int, SysPathRuleItem>, int, IGrouping <int, SysPathRuleItem> >(p => p.Key, p => p);

            foreach (KeyValuePair <int, IGrouping <int, SysPathRuleItem> > pair in dictionary3)
            {
                current = dictionary2[pair.Key];
                foreach (SysPathRuleItem item in pair.Value)
                {
                    if (item.ItemType == PathRuleMasterType.Role)
                    {
                        current.Roles.Add(item.ObjectId);
                    }
                    else
                    {
                        current.Users.Add(item.ObjectId);
                    }
                }
            }
            dictionary2.Clear();
            dictionary2 = null;
            dictionary3.Clear();
            dictionary3 = null;
            dictionary.Clear();
            dictionary = null;
            list2.Clear();
            list2 = null;
            return((from p in list
                    orderby p.RuleIndex
                    select p).ToArray <SysPathRule>());
        }
        public static void SetDefaultValue(TagBuilder UserName, TagBuilder HidUserId, TagBuilder selectedIDHf, string selectValue)
        {
            string        str     = string.Empty;
            StringBuilder builder = new StringBuilder(100);

            if (!string.IsNullOrEmpty(selectValue))
            {
                string[] strArray = selectValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                using (BizDataContext context = new BizDataContext(true))
                {
                    var source = (from u in context.FetchAll <T_User>()
                                  join suid in strArray on u.User_ID.ToString() equals suid
                                  select new { User_ID = u.User_ID, User_Name = u.User_Name }).ToList();
                    List <string> values = new List <string>();
                    if ((source != null) && (source.Count > 0))
                    {
                        foreach (string str2 in strArray)
                        {
                            int    id   = str2.ToInt();
                            string item = source.FirstOrDefault(a => (a.User_ID == id)).User_Name;
                            values.Add(item);
                            builder.Append(str2 + "," + item + ";");
                        }
                        str = string.Join(",", values);
                    }
                }
                UserName.MergeAttribute("value", str);
                HidUserId.MergeAttribute("value", selectValue);
                selectedIDHf.MergeAttribute("value", builder.ToString().TrimEnd(new char[] { ';' }));
            }
        }
 protected void btnChangeSystemLevelCode_Click(object sender, EventArgs e)
 {
     using (BizDataContext context = new BizDataContext())
     {
         StringBuilder sbSQL = new StringBuilder();
         //将父部门字段值调整过来并先处理好顶级部门的层级码
         sbSQL.AppendLine("update T_Department set SystemLevelCode = Convert(nvarchar(50),Department_ID)+'-' where Parent_ID is null");
         context.ExecuteNonQuery(sbSQL.ToString());
         var AllDepts    = context.FetchAll <T_Department>();
         var Depts       = AllDepts.Where(p => !(p.Parent_ID == null)).ToList();
         var DealedDepts = AllDepts.Where(p => p.Parent_ID == null).ToList();
         while (Depts.Count > 0)
         {
             for (int i = Depts.Count - 1; i >= 0; i--)
             {
                 var Child      = Depts[i];
                 var FindParent = DealedDepts.FirstOrDefault(p => p.Department_ID == Child.Parent_ID);
                 if (FindParent != null)
                 {
                     //当前未处理的这个是某个已处理的子部门,则处理当前这个,并把它从未处理中移走,加到已处理中。
                     Child.SystemLevelCode = FindParent.SystemLevelCode + Child.Department_ID + "-";
                     context.Update(Child);
                     Depts.Remove(Child);
                     DealedDepts.Add(Child);
                 }
             }
         }
     }
     this.AjaxAlert("调整成功!");
 }
        //string GetEntityName(long entityId,BizDataContext context)
        //{
        //    string res = string.Empty;
        //    SysEntity se= context.FindById<SysEntity>(entityId);
        //    if (se != null)
        //    {
        //        res = se.DisplayText;
        //    }
        //    return res;
        //}

        private void BindGrid()
        {
            using (BizDataContext context = new BizDataContext())
            {
                var list   = context.FetchAll <SysProcessRemindTemplate>();
                var result = list.Select(p => new
                {
                    p.TemplateId,
                    p.TemplateName,
                    p.TemplateType,
                    p.UseTimeType,
                    ProcessEntityName  = this.EntityCache.FindById <SysEntity>(p.ProcessEntityId).EntityName,  //GetEntityName(p.ProcessEntityId.Value,context),
                    ActivityEntityName = this.EntityCache.FindById <SysEntity>(p.ActivityEntityId).EntityName, //GetEntityName(p.ActivityEntityId.Value,context),
                    p.State
                }).ToList().Select(p => new
                {
                    p.TemplateId,
                    p.TemplateName,
                    TemplateType = EnumHelper.GetDescription(typeof(TemplateType), p.TemplateType.Value),
                    UseTimeType  = EnumHelper.GetDescription(typeof(UseTimeType), p.UseTimeType.Value),
                    p.ProcessEntityName,
                    p.ActivityEntityName,
                    State = p.State == 1 ? "启用" : "禁用",
                }).ToList();
                this.gcProcessTemplateQuery.DataSource = result;
                this.gcProcessTemplateQuery.DataBind();
            }
        }
 /// <summary>
 /// 查询所有提醒模板
 /// </summary>
 /// <returns></returns>
 public IEnumerable <WfRemindTemplate> GetRemindTemplateList()
 {
     using (BizDataContext context = new BizDataContext())
     {
         return(context.FetchAll <SysProcessRemindTemplate>().ConvertTo <WfRemindTemplate>());
     }
 }
Beispiel #6
0
        private void LoadDropDown()
        {
            try
            {
                using (BizDataContext context = new BizDataContext())
                {
                    var processList = context.Where <SysProcess>(p =>
                                                                 p.ProcessStatus == (int)ProcessState.StartUsed &&
                                                                 p.ProcessCategory != (int)ProcessCategory.FormApprove //2013-9-13 zhumin 排除表单流程
                                                                 );

                    cbProcess.DataTextField  = "ProcessName";
                    cbProcess.DataValueField = "ProcessType";
                    cbProcess.DataSource     = processList;
                    cbProcess.DataBind();

                    cbStartUser.DataTextField  = "User_Name";
                    cbStartUser.DataValueField = "User_ID";
                    cbStartUser.DataSource     = context.FetchAll <T_User>();
                    cbStartUser.DataBind();

                    cbStartUser.SetValue(this.LoginUserID.ToString());
                }
            }
            catch (ApplicationException ex)
            {
                this.AjaxAlert(ex.Message);
            }
        }
Beispiel #7
0
        public static List <T> ICommonEntity <T>() where T : class, new()
        {
            List <T> list = null;

            using (BizDataContext context = new BizDataContext(true))
            {
                string key = typeof(T).ToString();
                if (HttpRuntime.Cache[key] == null)
                {
                    list = context.FetchAll <T>();
                    HttpRuntime.Cache.Add(key, list, null, DateTime.Now.AddSeconds(30.0), TimeSpan.Zero, CacheItemPriority.Normal, null);
                    return(list);
                }
                return((List <T>)HttpRuntime.Cache[key]);
            }
        }
        private void BingDataToRoleId(string roleId)
        {
            //如果传入ID号有误,则变成下拉菜单来处理
            bool nextSetp = true;

            if (!string.IsNullOrEmpty(roleId))
            {
                this.RoleId = Convert.ToInt32(roleId);
                using (BizDataContext context = new BizDataContext())
                {
                    var query = context.FindById <T_Role>(this.RoleId);
                    if (query != null)
                    {
                        lblRoleName.Text += query.Role_Name;

                        this.ddlRoleList.Visible = false;
                        nextSetp = false;
                    }
                }
            }

            if (nextSetp)
            {
                using (BizDataContext Context = new BizDataContext())
                {
                    var roleList = Context.FetchAll <T_Role>();
                    this.ddlRoleList.DataSource     = roleList;
                    this.ddlRoleList.DataValueField = "Role_ID";
                    this.ddlRoleList.DataTextField  = "Role_Name";
                    this.ddlRoleList.DataBind();

                    this.RoleId = Convert.ToInt32(this.ddlRoleList.SelectedValue);

                    this.ddlRoleList.Visible = true;
                }
            }
        }
        private static MvcHtmlString GetSelectUserHtml(HtmlHelper html, string name, List <ITreeData> data, string GetLeafURL, string CallBackMethod, UserStyle userStyle, OpenNoteEnum openNote, ValidateOptions validateOptions, string value)
        {
            BizDataContext       context;
            List <string>        keyList    = new List <string>();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            StringBuilder        builder    = new StringBuilder();
            TagBuilder           builder2   = new TagBuilder("div");

            builder2.GenerateId(name);
            builder2.AddCssClass("treeDiv");
            TagBuilder builder3 = GetTagBuilder("ul", name, "ztree");

            builder3.MergeAttribute("style", "display : none;");
            builder2.InnerHtml = builder2.InnerHtml + builder3;
            TagBuilder builder4 = GetTagBuilder("div", name, "dataHF");

            builder4.MergeAttribute("style", "display:none;");
            if ((data != null) && (data.Count > 0))
            {
                data = DealWithNoteOpenState(data, openNote);
                builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(data);
            }
            else
            {
                using (context = new BizDataContext(true))
                {
                    ParameterExpression expression;
                    // List<ITreeData> list2 = DealWithNoteOpenState(context.Set<T_Department>().
                    //    Select<T_Department, TreeData>(Expression.Lambda<Func<T_Department, TreeData>>(Expression.MemberInit(Expression.New((ConstructorInfo) methodof(TreeData..ctor), new Expression[0]), new MemberBinding[] { Expression.Bind((MethodInfo) methodof(TreeData.set_id), Expression.Property(expression = Expression.Parameter(typeof(T_Department), "u"), (MethodInfo) methodof(T_Department.get_Department_ID))), Expression.Bind((MethodInfo) methodof(TreeData.set_name), Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Department_Name))), Expression.Bind((MethodInfo) methodof(TreeData.set_open), Expression.Constant(false, typeof(bool))), Expression.Bind((MethodInfo) methodof(TreeData.set_pId), Expression.Coalesce(Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Parent_ID)), Expression.Constant(-1, typeof(int)))) }), new ParameterExpression[] { expression })).ToList<ITreeData>(), openNote);
                    //builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(list2);
                }
            }
            builder2.InnerHtml = builder2.InnerHtml + builder4;
            TagBuilder builder5 = GetTagBuilder("input", name, "resultInput");

            if (userStyle == UserStyle.Normal)
            {
                builder5.MergeAttribute("style", "float: left;");
            }
            else
            {
                builder5.MergeAttribute("style", "float: left;display:none");
            }
            builder5.MergeAttribute("type", "text");
            if (validateOptions != null)
            {
                builder5.MergeAttribute("data-bvalidator", ValidateCommon.GetValidateAttr(validateOptions));
                if (!string.IsNullOrEmpty(validateOptions.ErrorMsg))
                {
                    builder5.MergeAttribute("data-bvalidator-msg", validateOptions.ErrorMsg);
                }
            }
            builder5.MergeAttribute("readonly", "true");
            TagBuilder builder6 = GetTagBuilder("input", name, "resultHf");

            builder6.MergeAttribute("type", "hidden");
            builder2.InnerHtml = builder2.InnerHtml + builder5;
            builder2.InnerHtml = builder2.InnerHtml + builder6;
            TagBuilder builder7 = GetTagBuilder("input", name, "treeButton");

            builder7.MergeAttribute("type", "button");
            builder7.MergeAttribute("value", "选择");
            builder7.MergeAttribute("treeName", name);
            builder2.InnerHtml = builder2.InnerHtml + builder7;
            TagBuilder builder8 = GetTagBuilder("input", name, "selectedIDHf");

            builder8.MergeAttribute("type", "hidden");
            string str = string.Empty;

            if (!string.IsNullOrEmpty(value))
            {
                string[] strArray = value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                using (context = new BizDataContext(true))
                {
                    IEnumerable <string> values = from u in context.FetchAll <T_User>()
                                                  join suid in strArray on u.User_ID.ToString() equals suid
                                                  select u.User_Name;

                    str = string.Join(",", values);
                }
                builder8.MergeAttribute("value", value);
            }
            builder2.InnerHtml = builder2.InnerHtml + builder8;
            TagBuilder builder9 = GetTagBuilder("input", name, "selectedNameHF");

            builder9.MergeAttribute("type", "hidden");
            builder9.MergeAttribute("value", str);
            builder2.InnerHtml = builder2.InnerHtml + builder9;
            TagBuilder builder10 = GetTagBuilder("input", name, "configDataHF");

            builder10.MergeAttribute("type", "hidden");
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("GetLeafURL", GetLeafURL);
            dictionary.Add("CallBackMethod", CallBackMethod);
            builder10.MergeAttribute("value", serializer.Serialize(dictionary));
            builder2.InnerHtml = builder2.InnerHtml + builder10;
            builder.AppendLine(builder2.ToString());
            builder.AppendLine(CtrlScripts.RenderScript(html, keyList));
            return(MvcHtmlString.Create(builder.ToString()));
        }
Beispiel #10
0
        private static T_Configuration GetConfiguration(string Key)
        {
            if ((configurationList == null) || (DateTime.Now.Ticks > dt))
            {
                using (BizDataContext context = new BizDataContext(true))
                {
                    Interlocked.Exchange <List <T_Configuration> >(ref configurationList, context.FetchAll <T_Configuration>());
                    Interlocked.Exchange(ref dt, DateTime.Now.AddSeconds(30.0).Ticks);
                }
            }
            T_Configuration configuration = configurationList.FirstOrDefault <T_Configuration>(p => p.Configuration_Key == Key);

            if (configuration == null)
            {
                throw new ApplicationException(string.Format("未找到{0}配置项", Key));
            }
            return(configuration);
        }