Esempio n. 1
0
        /// <summary>
        /// 添加一个用户到在线用户表
        /// </summary>
        public bool Add(RoadFlow.Data.Model.UsersModel user, Guid uniqueID)
        {
            if (user == null)
            {
                return(false);
            }
            var  onList = GetAll();
            bool isadd  = false;
            var  onUser = onList.Find(p => p.ID == user.ID);

            if (onUser == null)
            {
                isadd  = true;
                onUser = new RoadFlow.Data.Model.OnlineUsers();
                var station = new UsersRelation().GetMainByUserID(user.ID);
                if (station != null)
                {
                    onUser.OrgName = new Organize().GetAllParentNames(station.OrganizeID);
                }
            }
            onUser.ID         = user.ID;
            onUser.ClientInfo = string.Concat("操作系统:", RoadFlow.Utility.Tools.GetOSName(), "  浏览器:", RoadFlow.Utility.Tools.GetBrowse());
            onUser.IP         = RoadFlow.Utility.Tools.GetIPAddress();
            onUser.LastPage   = "";
            onUser.LoginTime  = DateTime.Now;
            onUser.UniqueID   = uniqueID;
            onUser.UserName   = user.Name;
            if (isadd)
            {
                onList.Add(onUser);
            }
            set(onList);
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 将DataRedar转换为List
        /// </summary>
        private List <RoadFlow.Data.Model.UsersModel> DataReaderToList(SqlDataReader dataReader)
        {
            List <RoadFlow.Data.Model.UsersModel> List = new List <RoadFlow.Data.Model.UsersModel>();

            RoadFlow.Data.Model.UsersModel model = null;
            while (dataReader.Read())
            {
                model          = new RoadFlow.Data.Model.UsersModel();
                model.ID       = dataReader.GetGuid(0);
                model.Name     = dataReader.GetString(1);
                model.Account  = dataReader.GetString(2);
                model.Password = dataReader.GetString(3);
                model.Status   = dataReader.GetInt32(4);
                model.Sort     = dataReader.GetInt32(5);
                if (!dataReader.IsDBNull(6))
                {
                    model.Tell = dataReader.GetString(6);
                }
                if (!dataReader.IsDBNull(7))
                {
                    model.Note = dataReader.GetString(7);
                }
                List.Add(model);
            }
            return(List);
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            string pager = string.Empty;
            //DataTable dt = sms.GetDataPage(out pager, "", pageSize, 1);
            string    query = string.Format("&appid={0}&tabid={1}&flag={2}", Request.QueryString["appid"], Request.QueryString["tabid"], Request.QueryString["flag"]);
            DataTable dt    = sms.GetDataPage(out pager, query, pageSize, RoadFlow.Utility.Tools.GetPageNumber());

            ViewBag.Pager = pager;
            List <RoadFlow.Data.Model.SMSModel> list = dt.ToList <RoadFlow.Data.Model.SMSModel>();
            List <RoadFlow.Data.Model.SMSModel> view = new List <RoadFlow.Data.Model.SMSModel>();

            foreach (var item in list)
            {
                RoadFlow.Platform.UsersBLL user     = new RoadFlow.Platform.UsersBLL();
                RoadFlow.Platform.Organize organize = new RoadFlow.Platform.Organize();

                //把sendTo里的id取出来,然后清空sendTo
                string[] sendTo = item.SendTo.Split(',');
                item.SendTo = string.Empty;

                foreach (var id in sendTo)
                {
                    if (id.Contains("u_"))  //个人
                    {
                        string newId = id.Remove(0, 2);
                        if (newId.IsGuid())
                        {
                            RoadFlow.Data.Model.UsersModel u = user.Get(Guid.Parse(newId));
                            if (u != null)
                            {
                                item.SendTo += "," + u.Name;
                            }
                            else
                            {
                                item.SendTo = ",用户已删除";
                            }
                        }
                    }
                    else    //选中的是组织
                    {
                        if (id.IsGuid())
                        {
                            RoadFlow.Data.Model.Organize o = organize.Get(Guid.Parse(id));
                            if (o != null)
                            {
                                item.SendTo += "," + o.Name;
                            }
                            else
                            {
                                item.SendTo = ",组织机构已删除";
                            }
                        }
                    }
                }
                item.SendTo = item.SendTo.Remove(0, 1);//去掉第一个多余的",".
                view.Add(item);
            }
            return(View(view));
        }
Esempio n. 4
0
        /// <summary>
        /// 更新记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.Users实体类</param>
        public int Update(RoadFlow.Data.Model.UsersModel model)
        {
            string sql = @"UPDATE Users SET 
				Name=@Name,Account=@Account,Password=@Password,Status=@Status,Sort=@Sort,Tell=@Tell,Note=@Note
				WHERE ID=@ID"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@Name", SqlDbType.NVarChar, 100)
                {
                    Value = model.Name
                },
                new SqlParameter("@Account", SqlDbType.VarChar, 255)
                {
                    Value = model.Account
                },
                new SqlParameter("@Password", SqlDbType.VarChar, 500)
                {
                    Value = model.Password
                },
                new SqlParameter("@Status", SqlDbType.Int, -1)
                {
                    Value = model.Status
                },
                new SqlParameter("@Sort", SqlDbType.Int, -1)
                {
                    Value = model.Sort
                },
                model.Tell == null ? new SqlParameter("@Tell", SqlDbType.NVarChar, 20)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Tell", SqlDbType.NVarChar, 20)
                {
                    Value = model.Tell
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.NVarChar, -1)
                {
                    Value = model.Note
                },
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
Esempio n. 5
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">RoadFlow.Data.Model.Users实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(RoadFlow.Data.Model.UsersModel model)
        {
            string sql = @"INSERT INTO Users
				(ID,Name,Account,Password,Status,Sort,Tell,Note) 
				VALUES(@ID,@Name,@Account,@Password,@Status,@Sort,@Tell,@Note)"                ;

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@ID", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.ID
                },
                new SqlParameter("@Name", SqlDbType.NVarChar, 100)
                {
                    Value = model.Name
                },
                new SqlParameter("@Account", SqlDbType.VarChar, 255)
                {
                    Value = model.Account
                },
                new SqlParameter("@Password", SqlDbType.VarChar, 500)
                {
                    Value = model.Password
                },
                new SqlParameter("@Status", SqlDbType.Int, -1)
                {
                    Value = model.Status
                },
                new SqlParameter("@Sort", SqlDbType.Int, -1)
                {
                    Value = model.Sort
                },
                model.Tell == null ? new SqlParameter("@Tell", SqlDbType.NVarChar, 20)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Tell", SqlDbType.NVarChar, 20)
                {
                    Value = model.Tell
                },
                model.Note == null ? new SqlParameter("@Note", SqlDbType.NVarChar, -1)
                {
                    Value = DBNull.Value
                } : new SqlParameter("@Note", SqlDbType.NVarChar, -1)
                {
                    Value = model.Note
                }
            };
            return(dbHelper.Execute(sql, parameters));
        }
Esempio n. 6
0
        public ActionResult Send(RoadFlow.Data.Model.SMSModel model)
        {
            if (ModelState.IsValid)
            {
                model.SendUser     = RoadFlow.Platform.UsersBLL.CurrentUserID;
                model.SendUserName = RoadFlow.Platform.UsersBLL.CurrentUserName;
                if (sms.Add(model) > 0)  //保存成功,调用第三方发送短信
                {
                    RoadFlow.Platform.UsersBLL user     = new RoadFlow.Platform.UsersBLL();
                    RoadFlow.Platform.Organize organize = new RoadFlow.Platform.Organize();

                    List <string> tels   = new List <string>();
                    string[]      sendTo = model.SendTo.Split(',');

                    foreach (var item in sendTo)
                    {
                        if (item.Contains("u_"))  //个人
                        {
                            string newId = item.Remove(0, 2);
                            if (newId.IsGuid())
                            {
                                RoadFlow.Data.Model.UsersModel u = user.Get(Guid.Parse(newId));
                                if (u != null && !u.Tell.IsNullOrEmpty())
                                {
                                    tels.Add(u.Tell);
                                }
                            }
                        }
                        else    //选中的是组织
                        {
                            if (item.IsGuid())
                            {
                                RoadFlow.Data.Model.Organize o = organize.Get(Guid.Parse(item));
                                if (o != null)
                                {
                                    List <RoadFlow.Data.Model.UsersModel> list = organize.GetAllUsers(Guid.Parse(item));
                                    foreach (var u in list)  //遍历组织里所有User
                                    {
                                        if (!u.Tell.IsNullOrEmpty())
                                        {
                                            tels.Add(u.Tell);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    foreach (var tel in tels)  //遍历所有手机号,发送短信
                    {
                        SMSMessage message = new SMSMessage {
                            Mobile  = tel,
                            Content = "【青羊楼宇】" + model.Content
                        };
                        new SMS().SendSMS(message);
                    }
                    ViewBag.Success = true;
                }
            }

            return(View(model));
        }
Esempio n. 7
0
 /// <summary>
 /// 记录日志
 /// </summary>
 /// <param name="err"></param>
 public static void Add(string title, string contents, Types type = Types.其它分类, string oldXML = "", string newXML = "", RoadFlow.Data.Model.UsersModel user = null)
 {
     if (user == null)
     {
         user = Platform.UsersBLL.CurrentUser;
     }
     RoadFlow.Data.Model.Log log = new RoadFlow.Data.Model.Log();
     log.Contents  = contents;
     log.ID        = Guid.NewGuid();
     log.IPAddress = RoadFlow.Utility.Tools.GetIPAddress();
     log.Others    = string.Format("操作系统:{0} 浏览器:{1}", RoadFlow.Utility.Tools.GetOSName(), RoadFlow.Utility.Tools.GetBrowse());
     log.Title     = title;
     log.OldXml    = oldXML.IsNullOrEmpty() ? null : oldXML;
     log.NewXml    = newXML.IsNullOrEmpty() ? null : newXML;
     log.Type      = type.ToString();
     log.URL       = System.Web.HttpContext.Current.Request.Url.ToString();
     if (user != null)
     {
         log.UserID   = user.ID;
         log.UserName = user.Name;
     }
     log.WriteTime = DateTime.Now;
     Add(log);
 }
Esempio n. 8
0
        public ActionResult User(FormCollection collection)
        {
            RoadFlow.Platform.Organize      borganize     = new RoadFlow.Platform.Organize();
            RoadFlow.Platform.UsersBLL      busers        = new RoadFlow.Platform.UsersBLL();
            RoadFlow.Platform.UsersRelation buserRelation = new RoadFlow.Platform.UsersRelation();
            RoadFlow.Data.Model.UsersModel  user          = null;
            RoadFlow.Data.Model.Organize    organize      = null;
            string id       = Request.QueryString["id"];
            string parentID = Request.QueryString["parentid"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string tell    = string.Empty;
            string note    = string.Empty;

            string parentString = string.Empty;

            Guid userID, organizeID;

            if (id.IsGuid(out userID))
            {
                user = busers.Get(userID);
                if (user != null)
                {
                    name    = user.Name;
                    account = user.Account;
                    status  = user.Status.ToString();
                    tell    = user.Tell;
                    note    = user.Note;

                    //所在组织字符串
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    var userRelations            = buserRelation.GetAllByUserID(user.ID).OrderByDescending(p => p.IsMain);
                    foreach (var userRelation in userRelations)
                    {
                        sb.Append("<div style='margin:3px 0;'>");
                        sb.Append(borganize.GetAllParentNames(userRelation.OrganizeID, true));
                        if (userRelation.IsMain == 0)
                        {
                            sb.Append("<span style='color:#999'> [兼职]</span>");
                        }
                        sb.Append("</div>");
                    }
                    ViewBag.ParentString = sb.ToString();
                    var roles = new RoadFlow.Platform.UsersRole().GetByUserIDFromCache(userID);
                    RoadFlow.Platform.Role    brole  = new RoadFlow.Platform.Role();
                    System.Text.StringBuilder rolesb = new System.Text.StringBuilder();
                    foreach (var role in roles)
                    {
                        var role1 = brole.Get(role.RoleID);
                        if (role1 == null)
                        {
                            continue;
                        }
                        rolesb.Append(role1.Name);
                        rolesb.Append(",");
                    }
                    ViewBag.RoleString = rolesb.ToString().TrimEnd(',');
                }
            }
            if (parentID.IsGuid(out organizeID))
            {
                organize = borganize.Get(organizeID);
            }

            if (collection != null)
            {
                //保存
                if (!Request.Form["Save"].IsNullOrEmpty() && user != null)
                {
                    name    = Request.Form["Name"];
                    account = Request.Form["Account"];
                    status  = Request.Form["Status"];
                    tell    = Request.Form["Tell"];
                    note    = Request.Form["Note"];

                    string oldXML = user.Serialize();

                    user.Name    = name.Trim();
                    user.Account = account.Trim();
                    user.Status  = status.Convert <int>(1);
                    user.Tell    = tell.Trim();
                    user.Note    = note.IsNullOrEmpty() ? null : note.Trim();

                    busers.Update(user);
                    RoadFlow.Platform.Log.Add("修改了用户", "", RoadFlow.Platform.Log.Types.组织机构, oldXML, user.Serialize());
                    ViewBag.Script = "alert('保存成功!');parent.frames[0].reLoad('" + parentID + "');";
                }

                //删除用户
                if (!Request.Form["DeleteBut"].IsNullOrEmpty() && user != null && organize != null)
                {
                    using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                    {
                        var urs = buserRelation.GetAllByUserID(user.ID);
                        busers.Delete(user.ID);

                        buserRelation.DeleteByUserID(user.ID);

                        new RoadFlow.Platform.UsersInfo().Delete(user.ID);
                        new RoadFlow.Platform.UsersRole().DeleteByUserID(user.ID);

                        //更新父级[ChildsLength]字段
                        foreach (var ur in urs)
                        {
                            borganize.UpdateChildsLength(ur.OrganizeID);
                        }

                        scope.Complete();
                    }

                    string refreshID = parentID;
                    string url       = string.Empty;
                    var    users     = borganize.GetAllUsers(refreshID.Convert <Guid>());
                    if (users.Count > 0)
                    {
                        url = "User?id=" + users.Last().ID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + parentID;
                    }
                    else
                    {
                        refreshID = organize.ParentID == Guid.Empty ? organize.ID.ToString() : organize.ParentID.ToString();
                        url       = "Body?id=" + parentID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + organize.ParentID;
                    }
                    RoadFlow.Platform.Log.Add("删除了用户", user.Serialize(), RoadFlow.Platform.Log.Types.组织机构);
                    ViewBag.Script = "alert('删除成功');parent.frames[0].reLoad('" + refreshID + "');window.location='" + url + "'";
                    new RoadFlow.Platform.AppLibraryBLL().ClearUseMemberCache();
                }

                //初始化密码
                if (!Request.Form["InitPass"].IsNullOrEmpty() && user != null)
                {
                    string initpass = busers.GetInitPassword();
                    busers.InitPassword(user.ID);
                    RoadFlow.Platform.Log.Add("初始化了用户密码", user.Serialize(), RoadFlow.Platform.Log.Types.组织机构);
                    ViewBag.Script = "alert('密码已初始化为:" + initpass + "');";
                }

                //调动
                if (!Request.Form["Move1"].IsNullOrEmpty() && user != null)
                {
                    string moveto          = Request.Form["movetostation"];
                    string movetostationjz = Request.Form["movetostationjz"];
                    Guid   moveToID;
                    if (moveto.IsGuid(out moveToID))
                    {
                        using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                        {
                            var us = buserRelation.GetAllByUserID(user.ID);
                            if ("1" != movetostationjz)
                            {
                                buserRelation.DeleteByUserID(user.ID);
                            }

                            RoadFlow.Data.Model.UsersRelation ur = new RoadFlow.Data.Model.UsersRelation();
                            ur.UserID     = user.ID;
                            ur.OrganizeID = moveToID;
                            ur.IsMain     = "1" == movetostationjz ? 0 : 1;
                            ur.Sort       = buserRelation.GetMaxSort(moveToID);
                            buserRelation.Add(ur);

                            foreach (var u in us)
                            {
                                borganize.UpdateChildsLength(u.OrganizeID);
                            }

                            borganize.UpdateChildsLength(organizeID);
                            borganize.UpdateChildsLength(moveToID);

                            scope.Complete();
                            ViewBag.Script = "alert('调动成功!');parent.frames[0].reLoad('" + parentID + "');parent.frames[0].reLoad('" + moveto + "')";
                        }

                        RoadFlow.Platform.Log.Add(("1" == movetostationjz ? "兼职" : "全职") + "调动了人员的岗位", "将人员调往岗位(" + moveto + ")", RoadFlow.Platform.Log.Types.组织机构);
                        new RoadFlow.Platform.AppLibraryBLL().ClearUseMemberCache();
                    }
                }
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", status, "validate=\"radio\"");
            return(View(user));
        }
Esempio n. 9
0
        public ActionResult UserAdd(FormCollection collection)
        {
            RoadFlow.Platform.Organize borganize = new RoadFlow.Platform.Organize();
            RoadFlow.Platform.UsersBLL busers    = new RoadFlow.Platform.UsersBLL();

            string id = Request.QueryString["id"];

            string name    = string.Empty;
            string account = string.Empty;
            string status  = string.Empty;
            string tell    = string.Empty;
            string note    = string.Empty;
            Guid   parentID;

            if (collection != null && id.IsGuid(out parentID))
            {
                name    = Request.Form["Name"];
                account = Request.Form["Account"];
                status  = Request.Form["Status"];
                tell    = Request.Form["Tell"];
                note    = Request.Form["Note"];

                Guid   userID  = Guid.NewGuid();
                string userXML = string.Empty;
                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    //添加人员
                    RoadFlow.Data.Model.UsersModel user = new RoadFlow.Data.Model.UsersModel();
                    user.Account  = account.Trim();
                    user.Name     = name.Trim();
                    user.Tell     = tell.Trim();
                    user.Note     = note.IsNullOrEmpty() ? null : note;
                    user.Password = busers.GetUserEncryptionPassword(userID.ToString(), busers.GetInitPassword());
                    user.Sort     = 1;
                    user.Status   = status.IsInt() ? status.Convert <int>() : 0;
                    user.ID       = userID;
                    busers.Add(user);

                    //添加关系
                    RoadFlow.Data.Model.UsersRelation userRelation = new RoadFlow.Data.Model.UsersRelation();
                    userRelation.IsMain     = 1;
                    userRelation.OrganizeID = parentID;
                    userRelation.Sort       = new RoadFlow.Platform.UsersRelation().GetMaxSort(parentID);
                    userRelation.UserID     = userID;
                    new RoadFlow.Platform.UsersRelation().Add(userRelation);

                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(parentID);

                    //更新角色
                    new RoadFlow.Platform.UsersRole().UpdateByUserID(userID);

                    userXML = user.Serialize();
                    scope.Complete();
                }

                RoadFlow.Platform.Log.Add("添加了人员", userXML, RoadFlow.Platform.Log.Types.组织机构);
                ViewBag.Script = "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;";
            }
            ViewBag.StatusRadios = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
            return(View());
        }