Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id   = RequestData.Get <string>("id", String.Empty);
            type = RequestData.Get <string>("type", String.Empty).ToLower();

            switch (RequestAction)
            {
            case RequestActionEnum.Custom:
                if (RequestActionString == "addgrpuser" || RequestActionString == "delgrpuser")
                {
                    IList <string> userIDs = RequestData.GetList <string>("UserIDs");

                    if (!String.IsNullOrEmpty(id))
                    {
                        using (new SessionScope())
                        {
                            SysGroup grp = SysGroup.Find(id);

                            if (RequestActionString == "addgrpuser")
                            {
                                grp.AddUsers(userIDs);
                            }
                            else if (RequestActionString == "delgrpuser")
                            {
                                grp.RemoveUsers(userIDs);
                            }
                        }
                    }
                }
                break;
            }

            if (type == "group" && !String.IsNullOrEmpty(id))
            {
                using (new Castle.ActiveRecord.SessionScope())
                {
                    ICriterion cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID = ?)", id, NHibernateUtil.String);

                    users = SysUserRule.FindAll(SearchCriterion, cirt);
                }
            }
            else
            {
                users = SysUserRule.FindAll(SearchCriterion);
            }

            this.PageState.Add("UsrList", users);
        }
Exemplo n.º 2
0
        private void InputDatas(DataTable dt)
        {
            foreach (DataRow row in dt.Rows)
            {
                if (row[2] != null && row[2].ToString().Trim() != "")
                {
                    string workNo = "";
                    try
                    {
                        if (SysUser.FindAllByProperties("WorkNo", row[1].ToString()).Length == 0)
                        {
                            SysUser sysUser = new SysUser();
                            sysUser.WorkNo    = row[1].ToString();
                            sysUser.Name      = row[2].ToString();
                            sysUser.LoginName = row[3].ToString();
                            sysUser.Email     = row[5].ToString();
                            sysUser.Remark    = row[6].ToString();
                            sysUser.Status    = 1;
                            sysUser.Save();
                            if (SysGroup.FindAllByProperties("Name", row[4].ToString()).Length > 0)
                            {
                                using (new SessionScope())
                                {
                                    SysGroup grp = SysGroup.FindAllByProperties("Name", row[4].ToString())[0];

                                    IList <string> userIDs = new List <string>();
                                    userIDs.Add(sysUser.UserID);
                                    grp.AddUsers(userIDs);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void InputDatas(DataTable dt)
        {
            foreach (DataRow row in dt.Rows)
            {
                if (row[2] != null && row[2].ToString().Trim() != "")
                {
                    string workNo = "";
                    try
                    {
                        if (SysUser.FindAllByProperties("WorkNo", row[1].ToString().Trim()).Length == 0)
                        {
                            SysUser sysUser = new SysUser();
                            sysUser.WorkNo = row[1].ToString().Trim();
                            sysUser.Name   = row[2].ToString().Trim();
                            if (row[3].ToString().Trim() == "")
                            {
                                sysUser.LoginName = GetPingyin(row[2].ToString().Trim());
                            }
                            else
                            {
                                sysUser.LoginName = row[3].ToString();
                            }
                            sysUser.Email      = row[5].ToString();
                            sysUser.Remark     = row[6].ToString();
                            sysUser.Status     = 1;
                            sysUser.CreateDate = DateTime.Now;
                            sysUser.Save();
                            if (SysGroup.FindAllByProperties("Name", row[4].ToString().Trim()).Length > 0)
                            {
                                using (new SessionScope())
                                {
                                    SysGroup grp = SysGroup.FindAllByProperties("Name", row[4].ToString().Trim())[0];

                                    IList <string> userIDs = new List <string>();
                                    userIDs.Add(sysUser.UserID);
                                    grp.AddUsers(userIDs);
                                }
                            }
                        }
                        else
                        {
                            if (SysGroup.FindAllByProperties("Name", row[4].ToString().Trim()).Length > 0)
                            {
                                SysUser sysUser = SysUser.FindAllByProperties("WorkNo", row[1].ToString().Trim())[0];
                                using (new SessionScope())
                                {
                                    if (sysUser.RetrieveAllGroup().Where(en => en.Type == 2 && en.Name != row[4].ToString()).Count() == 0)
                                    {
                                        if (sysUser.RetrieveAllGroup().Where(en => en.Type == 2).Count() > 0)
                                        {
                                            foreach (SysGroup gp in sysUser.RetrieveAllGroup().Where(en => en.Type == 2))
                                            {
                                                gp.User.Remove(sysUser);
                                            }
                                        }
                                        SysGroup       grp     = SysGroup.FindAllByProperties("Name", row[4].ToString().Trim())[0];
                                        IList <string> userIDs = new List <string>();
                                        userIDs.Add(sysUser.UserID);
                                        grp.AddUsers(userIDs);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        continue;
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id   = RequestData.Get <string>("id", String.Empty);
            type = RequestData.Get <string>("type", String.Empty).ToLower();

            switch (RequestAction)
            {
            case RequestActionEnum.Custom:
                if (RequestActionString == "addgrpuser" || RequestActionString == "delgrpuser")
                {
                    IList <string> userIDs = RequestData.GetList <string>("UserIDs");

                    if (!String.IsNullOrEmpty(id))
                    {
                        using (new SessionScope())
                        {
                            SysGroup grp = SysGroup.Find(id);

                            if (RequestActionString == "addgrpuser")
                            {
                                grp.AddUsers(userIDs);
                                //更新到岗级
                                //if (grp.Type == 3)
                                //{
                                //    PRJ_PostDuty pd = PRJ_PostDuty.FindFirstByProperties(new string[]{"Post",grp.Name});
                                //   // pd.EmployeeId=userIDs
                                //    SysUser[] usrsToAdd = SysUser.FindAllByPrimaryKeys(userIDs.ToArray());
                                //    string names = "";
                                //    string ids = "";
                                //    foreach (SysUser sy in usrsToAdd)
                                //    {
                                //        ids += sy.UserID+",";
                                //        names += sy.Name+",";
                                //    }
                                //    pd.EmployeeId = pd.EmployeeId+","+ids.Substring(0, ids.Length - 1);
                                //    pd.EmployeeName = pd.EmployeeName+","+names.Substring(0, names.Length - 1);
                                //    pd.Update();
                                //}
                            }
                            else if (RequestActionString == "delgrpuser")
                            {
                                grp.RemoveUsers(userIDs);
                            }
                        }
                    }
                }
                break;
            }

            if (type == "group" && !String.IsNullOrEmpty(id))
            {
                using (new Castle.ActiveRecord.SessionScope())
                {
                    ICriterion cirt = Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%?%' ))", id, NHibernateUtil.String);

                    //string SQL = @"SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%{0}%'";
                    //SQL = string.Format(SQL, id);
                    //users =  .FindAll(SearchCriterion, cirt);

                    this.PageState.Add("UsrList", SysUser.FindAll(SearchCriterion, Expression.Sql("UserID IN (SELECT UserID FROM SysUserGroup WHERE GroupID in (select GroupID from SysGroup where Path like '%" + id + "%' or GroupID like '%" + id + "%'  ))")));
                }
            }
            else
            {
                users = SysUserRule.FindAll(SearchCriterion);
                this.PageState.Add("UsrList", users);
            }
        }
Exemplo n.º 5
0
        private void InputDatasV2(DataTable dt)
        {
            //DataHelper.ExecSql("delete from SysUser where LoginName<>'admin'");
            foreach (DataRow row in dt.Rows)
            {
                if (row[2] != null && row[2].ToString().Trim() != "")
                {
                    string workNo = row[1].ToString().Trim();;
                    try
                    {
                        if (!SysGroup.Exists(Expression.Eq(SysGroup.Prop_Name, row[4].ToString())))
                        {
                            continue;
                        }
                        using (new SessionScope())
                        {
                            if (row[4].ToString().Trim() == "昆山飞力仓储服务有限公司")
                            {
                                string dept = row[4].ToString();
                            }
                            SysGroup group = SysGroup.FindAllByProperties("Name", row[4].ToString())[0];
                            SysGroup Fact  = null;
                            if (row[6].ToString().Trim() != "")
                            {
                                if (group.ChildGroups.Count(tt => tt.Name == row[6].ToString()) == 0)
                                {
                                    SysGroup group1 = new SysGroup();
                                    group1.Name      = row[6].ToString();
                                    group1.Code      = row[7].ToString();
                                    group1.SortIndex = int.Parse(row[7].ToString());
                                    group1.Type      = 2;
                                    group1.Status    = 1;
                                    group1.CreateAsChild(group);
                                    Fact = group1;
                                    if (row[6].ToString().Trim() != row[8].ToString().Trim())
                                    {
                                        SysGroup group2 = new SysGroup();
                                        group2.Name      = row[8].ToString();
                                        group2.Code      = row[9].ToString();
                                        group2.SortIndex = int.Parse(row[9].ToString());
                                        group2.Type      = 2;
                                        group2.Status    = 1;
                                        group2.Save();
                                        group2.CreateAsChild(group1);
                                        Fact = group2;
                                    }
                                }
                                else
                                {
                                    Fact = group.ChildGroups.FirstOrDefault(ent => ent.Name == row[6].ToString());
                                    if (row[6].ToString().Trim() != row[8].ToString().Trim())
                                    {
                                        if (Fact.ChildGroups.Count(tt => tt.Name == row[8].ToString()) == 0)
                                        {
                                            SysGroup group2 = new SysGroup();
                                            group2.Name      = row[8].ToString();
                                            group2.Code      = row[9].ToString();
                                            group2.SortIndex = int.Parse(row[9].ToString());
                                            group2.Type      = 2;
                                            group2.Status    = 1;
                                            group2.Save();
                                            group2.CreateAsChild(Fact);
                                            Fact = group2;
                                        }
                                        else
                                        {
                                            Fact = Fact.ChildGroups.FirstOrDefault(ent => ent.Name == row[8].ToString());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Fact = group;
                            }
                            SysUser sysUser = new SysUser();
                            sysUser.WorkNo = row[1].ToString().Trim();
                            sysUser.Name   = row[2].ToString().Trim();
                            if (row[3].ToString().Trim() == "")
                            {
                                sysUser.LoginName = GetPingyin(row[2].ToString().Trim());
                            }
                            else
                            {
                                sysUser.LoginName = row[3].ToString();
                            }
                            sysUser.Status     = 1;
                            sysUser.CreateDate = DateTime.Now;
                            sysUser.Save();
                            IList <string> userIDs = new List <string>();
                            userIDs.Add(sysUser.UserID);
                            Fact.AddUsers(userIDs);
                        }
                    }
                    catch (Exception)
                    {
                        workNumbers += workNo + ";";
                        continue;
                        //throw e;
                    }

                    /*if (SysUser.FindAllByProperties("WorkNo", row[1].ToString().Trim()).Length == 0)
                     * {
                     *  SysUser sysUser = new SysUser();
                     *  sysUser.WorkNo = row[1].ToString().Trim();
                     *  sysUser.Name = row[2].ToString().Trim();
                     *  if (row[3].ToString().Trim() == "")
                     *  {
                     *      sysUser.LoginName = GetPingyin(row[2].ToString().Trim());
                     *  }
                     *  else
                     *  {
                     *      sysUser.LoginName = row[3].ToString();
                     *  }
                     *  sysUser.Email = row[5].ToString();
                     *  sysUser.Remark = row[6].ToString();
                     *  sysUser.Status = 1;
                     *  sysUser.CreateDate = DateTime.Now;
                     *  sysUser.Save();
                     *  if (SysGroup.FindAllByProperties("Name", row[4].ToString().Trim()).Length > 0)
                     *  {
                     *      using (new SessionScope())
                     *      {
                     *          SysGroup grp = SysGroup.FindAllByProperties("Name", row[4].ToString().Trim())[0];
                     *
                     *          IList<string> userIDs = new List<string>();
                     *          userIDs.Add(sysUser.UserID);
                     *          grp.AddUsers(userIDs);
                     *      }
                     *  }
                     *  else
                     *  {
                     *
                     *  }
                     * }
                     * else
                     * {
                     *  if (SysGroup.FindAllByProperties("Name", row[4].ToString().Trim()).Length > 0)
                     *  {
                     *      SysUser sysUser = SysUser.FindAllByProperties("WorkNo", row[1].ToString().Trim())[0];
                     *      using (new SessionScope())
                     *      {
                     *          if (sysUser.RetrieveAllGroup().Where(en => en.Type == 2 && en.Name != row[4].ToString()).Count() == 0)
                     *          {
                     *              if (sysUser.RetrieveAllGroup().Where(en => en.Type == 2).Count() > 0)
                     *              {
                     *                  foreach (SysGroup gp in sysUser.RetrieveAllGroup().Where(en => en.Type == 2))
                     *                      gp.User.Remove(sysUser);
                     *              }
                     *              SysGroup grp = SysGroup.FindAllByProperties("Name", row[4].ToString().Trim())[0];
                     *              IList<string> userIDs = new List<string>();
                     *              userIDs.Add(sysUser.UserID);
                     *              grp.AddUsers(userIDs);
                     *          }
                     *      }
                     *  }
                     * }*/
                }
            }
        }