Exemple #1
0
        /// <summary>
        /// 用户所在部门信息
        /// </summary>
        /// <returns></returns>
        public List <FoWoSoft.Data.Model.Organize> GetOrganize(Guid userID)
        {
            var users        = GetAllByUserID(userID);
            var organizes    = new List <FoWoSoft.Data.Model.Organize>();
            var organizeExec = new FoWoSoft.Platform.Organize();

            foreach (var item in users)
            {
                organizes.Add(organizeExec.Get(item.OrganizeID));
            }
            return(organizes);
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FoWoSoft.Platform.Organize   borganize = new FoWoSoft.Platform.Organize();
            FoWoSoft.Data.Model.Organize org       = null;
            string id     = Request.QueryString["id"];
            string name   = string.Empty;
            string type   = string.Empty;
            string status = string.Empty;
            string note   = string.Empty;

            Guid orgID;

            if (id.IsGuid(out orgID))
            {
                org = borganize.Get(orgID);
            }

            if (IsPostBack && org != null)
            {
                name   = Request.Form["Name"];
                type   = Request.Form["Type"];
                status = Request.Form["Status"];
                note   = Request.Form["note"];

                FoWoSoft.Data.Model.Organize org1 = new FoWoSoft.Data.Model.Organize();
                Guid org1ID = Guid.NewGuid();
                org1.ID       = org1ID;
                org1.Name     = name.Trim();
                org1.Note     = note.IsNullOrEmpty() ? null : note.Trim();
                org1.Number   = org.Number + "," + org1ID.ToString().ToLower();
                org1.ParentID = org.ID;
                org1.Sort     = borganize.GetMaxSort(org.ID);
                org1.Status   = status.IsInt() ? status.ToInt() : 0;
                org1.Type     = type.ToInt();
                org1.Depth    = org.Depth + 1;

                using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                {
                    borganize.Add(org1);
                    //更新父级[ChildsLength]字段
                    borganize.UpdateChildsLength(org.ID);
                    scope.Complete();
                }

                FoWoSoft.Platform.Log.Add("添加了组织机构", org1.Serialize(), FoWoSoft.Platform.Log.Types.组织机构);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;", true);
            }

            this.TypeRadios.Text   = borganize.GetTypeRadio("Type", type, "validate=\"radio\"");
            this.StatusRadios.Text = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FoWoSoft.Data.Model.Organize org       = null;
            FoWoSoft.Platform.Organize   borganize = new FoWoSoft.Platform.Organize();
            string id = Request.QueryString["id"];

            if (id.IsGuid())
            {
                org = borganize.Get(id.ToGuid());
            }

            if (IsPostBack)
            {
                //保存
                if (!Request.Form["Save"].IsNullOrEmpty() && org != null)
                {
                    string name         = Request.Form["Name"];
                    string type         = Request.Form["Type"];
                    string status       = Request.Form["Status"];
                    string chargeLeader = Request.Form["ChargeLeader"];
                    string leader       = Request.Form["Leader"];
                    string note         = Request.Form["note"];
                    string oldXML       = org.Serialize();
                    org.Name         = name.Trim();
                    org.Type         = type.ToInt(1);
                    org.Status       = status.ToInt(0);
                    org.ChargeLeader = chargeLeader;
                    org.Leader       = leader;
                    org.Note         = note.IsNullOrEmpty() ? null : note.Trim();

                    borganize.Update(org);
                    FoWoSoft.Platform.Log.Add("修改了组织机构", "", FoWoSoft.Platform.Log.Types.组织机构, oldXML, org.Serialize());
                    string rid = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');parent.frames[0].reLoad('" + rid + "');", true);
                }

                //移动
                if (!Request.Form["Move1"].IsNullOrEmpty() && org != null)
                {
                    string toOrgID = Request.Form["deptmove"];
                    Guid   toID;
                    if (toOrgID.IsGuid(out toID) && borganize.Move(org.ID, toID))
                    {
                        FoWoSoft.Platform.Log.Add("移动了组织机构", "将机构:" + org.ID + "移动到了:" + toID, FoWoSoft.Platform.Log.Types.组织机构);
                        string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('移动成功!');parent.frames[0].reLoad('" + refreshID + "');parent.frames[0].reLoad('" + toOrgID + "')", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('移动失败!');", true);
                    }
                }

                //删除
                if (!Request.Form["Delete"].IsNullOrEmpty())
                {
                    int i = borganize.DeleteAndAllChilds(org.ID);
                    FoWoSoft.Platform.Log.Add("删除了组织机构及其所有下级共" + i.ToString() + "项", org.Serialize(), FoWoSoft.Platform.Log.Types.组织机构);
                    string refreshID = org.ParentID == Guid.Empty ? org.ID.ToString() : org.ParentID.ToString();
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('共删除了" + i.ToString() + "项!');parent.frames[0].reLoad('" + refreshID + "');", true);
                }
            }



            if (org != null)
            {
                this.Name.Value         = org.Name;
                this.TypeRadios.Text    = borganize.GetTypeRadio("Type", org.Type.ToString(), "validate=\"radio\"");
                this.StatusRadios.Text  = borganize.GetStatusRadio("Status", org.Status.ToString(), "validate=\"radio\"");
                this.ChargeLeader.Value = org.ChargeLeader;
                this.Leader.Value       = org.Leader;
                this.Note.Value         = org.Note;
            }
            else
            {
                this.TypeRadios.Text   = borganize.GetTypeRadio("Type", "", "validate=\"radio\"");
                this.StatusRadios.Text = borganize.GetStatusRadio("Status", "", "validate=\"radio\"");
            }
        }
Exemple #4
0
        //重建组织时用
        public void AddOrganize(DataSet ds)
        {
            FoWoSoft.Platform.Guid_id guidIdService = new FoWoSoft.Platform.Guid_id();
            var dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var dr = dt.Rows[i];
                #region 部门编号转换成GUID
                string id = dr["BMBH"].ToString();

                var  guidId = guidIdService.Get(id);
                Guid org1ID;
                if (guidId == null)
                {
                    org1ID = GetGuid(id);

                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["BMBH"] = org1ID;
                #endregion
                var orgrion = borganize.Get(org1ID);
                if (orgrion != null)
                {
                    continue;
                }
                #region 转上级编号为GUID
                id     = dr["SJBM"].ToString();
                guidId = guidIdService.Get(id);
                if (guidId == null)
                {
                    org1ID = GetGuid(id);
                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["SJBM"] = org1ID;
                #endregion

                #region 插入组织结构
                FoWoSoft.Data.Model.Organize org = new FoWoSoft.Data.Model.Organize();

                org.ID       = Guid.Parse(dr["BMBH"].ToString());
                org.Name     = dr["BMMC"].ToString();
                org.Note     = null;
                org.Number   = ""; // org.Number + "," + org1ID.ToString().ToLower();
                org.ParentID = Guid.Parse(dr["SJBM"].ToString());
                org.Sort     = 0;  // borganize.GetMaxSort(org.ID);
                org.Status   = 0;
                org.Type     = 0;  // type.ToInt();
                org.Depth    = 0;  // org.Depth + 1;

                //using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                //  {

                borganize.Add(org);
                //更新父级[ChildsLength]字段
                //borganize.UpdateChildsLength(org.ID);
                // scope.Complete();
                // }
                #endregion
            }
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string rootid   = context.Request.QueryString["rootid"] ?? "";
            string showtype = context.Request.QueryString["showtype"] ?? "";

            FoWoSoft.Platform.Organize  BOrganize  = new FoWoSoft.Platform.Organize();
            FoWoSoft.Platform.Users     busers     = new FoWoSoft.Platform.Users();
            FoWoSoft.Platform.WorkGroup BWorkGroup = new FoWoSoft.Platform.WorkGroup();
            System.Text.StringBuilder   json       = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)
            {
                #region 显示工作组

                var workGroups = BWorkGroup.GetAll();
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", Guid.Empty);
                json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                json.AppendFormat("\"title\":\"{0}\",", "工作组");
                json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/group.gif");
                json.AppendFormat("\"link\":\"{0}\",", "");
                json.AppendFormat("\"type\":\"{0}\",", 5);
                json.AppendFormat("\"hasChilds\":\"{0}\",", workGroups.Count);
                json.Append("\"childs\":[");

                int countwg = workGroups.Count;
                int iwg     = 0;
                foreach (var wg in workGroups)
                {
                    json.Append("{");
                    json.AppendFormat("\"id\":\"{0}\",", wg.ID);
                    json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                    json.AppendFormat("\"title\":\"{0}\",", wg.Name);
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    json.AppendFormat("\"link\":\"{0}\",", "");
                    json.AppendFormat("\"type\":\"{0}\",", 5);
                    json.AppendFormat("\"hasChilds\":\"{0}\",", 0);
                    json.Append("\"childs\":[");
                    json.Append("]");
                    json.Append("}");
                    if (iwg++ < countwg - 1)
                    {
                        json.Append(",");
                    }
                }

                json.Append("]");
                json.Append("}");
                json.Append("]");
                context.Response.Write(json.ToString());
                context.Response.End();
                #endregion
            }
            if (rootid.IsNullOrEmpty())
            {
                rootid = BOrganize.GetRoot().ID.ToString();
            }
            string[] rootIDArray = rootid.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            int      m           = 0;
            foreach (string rootID in rootIDArray)
            {
                List <FoWoSoft.Data.Model.Users> users = new List <FoWoSoft.Data.Model.Users>();
                Guid rootGuid = Guid.Empty;
                if (rootID.IsGuid(out rootGuid))
                {
                    var root = BOrganize.Get(rootGuid);
                    if (root != null)
                    {
                        users = busers.GetAllByOrganizeID(rootGuid);
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", rootIDArray.Length == 1 ? Common.Tools.BaseUrl + "/images/ico/icon_site.gif" : "");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", root.Type);
                        json.AppendFormat("\"hasChilds\":\"{0}\",", root.ChildsLength == 0 && users.Count == 0 ? "0" : "1");
                        json.Append("\"childs\":[");
                    }
                }
                else if (rootID.StartsWith(FoWoSoft.Platform.Users.PREFIX))
                {
                    var root = busers.Get(busers.RemovePrefix1(rootID).ToGuid());
                    if (root != null)
                    {
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/contact_grey.png");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", "4");
                        json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                        json.Append("\"childs\":[");
                    }
                }
                else if (rootID.StartsWith(FoWoSoft.Platform.WorkGroup.PREFIX))
                {
                    var root = BWorkGroup.Get(BWorkGroup.RemovePrefix1(rootID).ToGuid());
                    if (root != null)
                    {
                        users = BOrganize.GetAllUsers(rootID);
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", root.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", Guid.Empty);
                        json.AppendFormat("\"title\":\"{0}\",", root.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", "");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", "5");
                        json.AppendFormat("\"hasChilds\":\"{0}\",", users.Count > 0 ? "1" : "0");
                        json.Append("\"childs\":[");
                    }
                }

                #region 只有一个根时显示二级
                if (rootIDArray.Length == 1)
                {
                    List <FoWoSoft.Data.Model.Organize> orgs = rootID.IsGuid() ? BOrganize.GetChilds(rootGuid)
                        : new List <FoWoSoft.Data.Model.Organize>();
                    int count = orgs.Count;
                    int i     = 0;
                    foreach (var org in orgs)
                    {
                        json.Append("{");
                        json.AppendFormat("\"id\":\"{0}\",", org.ID);
                        json.AppendFormat("\"parentID\":\"{0}\",", org.ParentID);
                        json.AppendFormat("\"title\":\"{0}\",", org.Name);
                        json.AppendFormat("\"ico\":\"{0}\",", "");
                        json.AppendFormat("\"link\":\"{0}\",", "");
                        json.AppendFormat("\"type\":\"{0}\",", org.Type);
                        json.AppendFormat("\"hasChilds\":\"{0}\",", org.ChildsLength);
                        json.Append("\"childs\":[");
                        json.Append("]");
                        json.Append("}");
                        if (i++ < count - 1 || users.Count > 0)
                        {
                            json.Append(",");
                        }
                    }

                    if (users.Count > 0)
                    {
                        var userRelations = new FoWoSoft.Platform.UsersRelation().GetAllByOrganizeID(rootGuid);
                        int count1        = users.Count;
                        int j             = 0;
                        foreach (var user in users)
                        {
                            var ur = userRelations.Find(p => p.UserID == user.ID);
                            json.Append("{");
                            json.AppendFormat("\"id\":\"{0}\",", user.ID);
                            json.AppendFormat("\"parentID\":\"{0}\",", rootGuid);
                            json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                            json.AppendFormat("\"ico\":\"{0}\",", Common.Tools.BaseUrl + "/images/ico/contact_grey.png");
                            json.AppendFormat("\"link\":\"{0}\",", "");
                            json.AppendFormat("\"type\":\"{0}\",", "4");
                            json.AppendFormat("\"hasChilds\":\"{0}\",", "0");
                            json.Append("\"childs\":[");
                            json.Append("]");
                            json.Append("}");
                            if (j++ < count1 - 1)
                            {
                                json.Append(",");
                            }
                        }
                    }
                }
                #endregion

                json.Append("]");
                json.Append("}");
                if (m++ < rootIDArray.Length - 1)
                {
                    json.Append(",");
                }
            }
            json.Append("]");

            context.Response.Write(json.ToString());
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            FoWoSoft.Platform.Organize      borganize     = new FoWoSoft.Platform.Organize();
            FoWoSoft.Platform.Users         busers        = new FoWoSoft.Platform.Users();
            FoWoSoft.Platform.UsersRelation buserRelation = new FoWoSoft.Platform.UsersRelation();
            FoWoSoft.Data.Model.Users       user          = null;
            FoWoSoft.Data.Model.Organize    organize      = null;
            string id       = Request.QueryString["id"];
            string parentID = Request.QueryString["parentid"];

            string parentString = string.Empty;

            this.Account.Attributes.Add("validate_url", "CheckAccount.ashx?id=" + id);
            Guid userID, organizeID;

            if (id.IsGuid(out userID))
            {
                user = busers.Get(userID);
                if (user != null)
                {
                    //所在组织字符串
                    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>");
                    }
                    this.ParentString.Text = sb.ToString();
                    var roles = new FoWoSoft.Platform.UsersRole().GetByUserIDFromCache(userID);
                    FoWoSoft.Platform.Role    brole  = new FoWoSoft.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(",");
                    }
                    this.RoleString.Text = rolesb.ToString().TrimEnd(',');
                }
            }
            if (parentID.IsGuid(out organizeID))
            {
                organize = borganize.Get(organizeID);
            }

            if (IsPostBack)
            {
                #region 保存
                if (!Request.Form["Save"].IsNullOrEmpty() && user != null)
                {
                    string name    = Request.Form["Name"];
                    string account = Request.Form["Account"];
                    string status  = Request.Form["Status"];
                    string note    = Request.Form["Note"];

                    string oldXML = user.Serialize();

                    user.Name    = name.Trim();
                    user.Account = account.Trim();
                    user.Status  = status.ToInt(1);
                    user.Note    = note.IsNullOrEmpty() ? null : note.Trim();

                    busers.Update(user);
                    FoWoSoft.Platform.Log.Add("修改了用户", "", FoWoSoft.Platform.Log.Types.组织机构, oldXML, user.Serialize());
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('保存成功!');parent.frames[0].reLoad('" + parentID + "');", true);
                }
                #endregion

                #region  除用户
                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 FoWoSoft.Platform.UsersInfo().Delete(user.ID);
                        new FoWoSoft.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.ToGuid());
                    if (users.Count > 0)
                    {
                        url = "User.aspx?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.aspx?id=" + parentID + "&appid=" + Request.QueryString["appid"] + "&tabid=" + Request.QueryString["tabid"] + "&parentid=" + organize.ParentID;
                    }
                    FoWoSoft.Platform.Log.Add("删除了用户", user.Serialize(), FoWoSoft.Platform.Log.Types.组织机构);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('删除成功');parent.frames[0].reLoad('" + refreshID + "');window.location='" + url + "'", true);
                    new FoWoSoft.Platform.AppLibrary().ClearUseMemberCache();
                }
                #endregion

                #region 初始化密码
                if (!Request.Form["InitPass"].IsNullOrEmpty() && user != null)
                {
                    string initpass = busers.GetInitPassword();
                    busers.InitPassword(user.ID);
                    FoWoSoft.Platform.Log.Add("初始化了用户密码", user.Serialize(), FoWoSoft.Platform.Log.Types.组织机构);
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('密码已初始化为:" + initpass + "');", true);
                }
                #endregion

                #region 调动
                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);
                            }

                            FoWoSoft.Data.Model.UsersRelation ur = new FoWoSoft.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();
                            Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('调动成功!');parent.frames[0].reLoad('" + parentID + "');parent.frames[0].reLoad('" + moveto + "')", true);
                        }

                        FoWoSoft.Platform.Log.Add(("1" == movetostationjz ? "兼职" : "全职") + "调动了人员的岗位", "将人员调往岗位(" + moveto + ")", FoWoSoft.Platform.Log.Types.组织机构);
                        new FoWoSoft.Platform.AppLibrary().ClearUseMemberCache();
                    }
                }
                #endregion
            }
            if (user != null)
            {
                this.Name.Value    = user.Name;
                this.Account.Value = user.Account;
                this.Note.Value    = user.Note;
            }
            this.StatusRadios.Text = borganize.GetStatusRadio("Status", user != null ? user.Status.ToString() : "", "validate=\"radio\"");
        }