Exemplo n.º 1
0
        public ActionResult WorkGroupAdd(FormCollection collection)
        {
            BizProcess.Platform.WorkGroup bwg = new BizProcess.Platform.WorkGroup();
            string name    = string.Empty;
            string members = string.Empty;
            string note    = string.Empty;

            if (collection != null)
            {
                name    = Request.Form["Name"];
                members = Request.Form["Members"];
                note    = Request.Form["Note"];

                BizProcess.Data.Model.WorkGroup wg = new BizProcess.Data.Model.WorkGroup();
                wg.ID      = Guid.NewGuid();
                wg.Name    = name.Trim();
                wg.Members = members;
                if (!note.IsNullOrEmpty())
                {
                    wg.Note = note;
                }
                bwg.Add(wg);
                string query = Request.Url.Query;
                BizProcess.Platform.Log.Add("添加了工作组", wg.Serialize(), BizProcess.Platform.Log.Types.组织机构);
                ViewBag.Script = "parent.frames[0].treecng('1');alert('添加成功!');window.location = 'WorkGroup' + '" + query + "';";
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult WorkGroup(FormCollection collection)
        {
            string id = Request.QueryString["id"];
            Guid   wid;

            BizProcess.Platform.WorkGroup   bwg = new BizProcess.Platform.WorkGroup();
            BizProcess.Data.Model.WorkGroup wg  = null;
            string name    = string.Empty;
            string members = string.Empty;
            string note    = string.Empty;
            string users   = string.Empty;

            if (!id.IsGuid(out wid) || wid == Guid.Empty)
            {
                Response.End();
            }

            wg = bwg.Get(wid);
            if (wg != null)
            {
                name    = wg.Name;
                members = wg.Members;
                note    = wg.Note;
                users   = bwg.GetUsersNames(wg.Members, '、');
            }

            if (!Request.Form["Save"].IsNullOrEmpty() && collection != null && wg != null)
            {
                string oldxml = wg.Serialize();
                name       = Request.Form["Name"];
                members    = Request.Form["Members"];
                note       = Request.Form["Note"];
                wg.Name    = name.Trim();
                wg.Members = members;
                if (!note.IsNullOrEmpty())
                {
                    wg.Note = note;
                }

                bwg.Update(wg);
                users = bwg.GetUsersNames(wg.Members, '、');
                string query = Request.Url.Query;
                BizProcess.Platform.Log.Add("修改了工作组", "修改了工作组", BizProcess.Platform.Log.Types.组织机构, oldxml, wg.Serialize());

                ViewBag.Script = "alert('保存成功!');";
            }

            //删除
            if (!Request.Form["DeleteBut"].IsNullOrEmpty() && collection != null && wg != null)
            {
                string oldxml = wg.Serialize();
                bwg.Delete(wg.ID);
                string query = Request.Url.Query;
                BizProcess.Platform.Log.Add("删除了工作组", oldxml, BizProcess.Platform.Log.Types.组织机构);
                ViewBag.Script = "parent.frames[0].treecng('1');alert('删除成功!');window.location = 'Empty' + '" + query + "';";
            }
            return(View(wg));
        }
Exemplo n.º 3
0
        public string Tree1()
        {
            string rootid   = Request.QueryString["rootid"];
            string showtype = Request.QueryString["showtype"];

            BizProcess.Platform.Organize BOrganize = new BizProcess.Platform.Organize();
            System.Text.StringBuilder    json      = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)//显示工作组
            {
                BizProcess.Platform.WorkGroup BWorkGroup = new BizProcess.Platform.WorkGroup();
                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}\",", Url.Content("~/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("]");
                Response.Write(json.ToString());
                Response.End();
            }


            Guid rootID;

            BizProcess.Data.Model.Organize root;
            if (rootid.IsGuid(out rootID))
            {
                root = BOrganize.Get(rootID);
            }
            else
            {
                root = BOrganize.GetRoot();
            }

            List <BizProcess.Data.Model.Users> users = new List <BizProcess.Data.Model.Users>();

            BizProcess.Platform.Users busers = new BizProcess.Platform.Users();
            users = busers.GetAllByOrganizeID(root.ID);

            json.Append("{");
            json.AppendFormat("\"id\":\"{0}\",", root.ID);
            json.AppendFormat("\"parentID\":\"{0}\",", root.ParentID);
            json.AppendFormat("\"title\":\"{0}\",", root.Name);
            json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/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\":[");

            var orgs  = BOrganize.GetChilds(root.ID);
            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 BizProcess.Platform.UsersRelation().GetAllByOrganizeID(root.ID);
                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}\",", root.ID);
                    json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                    json.AppendFormat("\"ico\":\"{0}\",", "");
                    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(",");
                    }
                }
            }


            json.Append("]");
            json.Append("}");
            json.Append("]");

            return(json.ToString());
        }
Exemplo n.º 4
0
        public string TreeRefresh()
        {
            string id       = Request.QueryString["refreshid"];
            string showtype = Request.QueryString["showtype"];

            System.Text.StringBuilder json = new System.Text.StringBuilder("[", 1000);

            if ("1" == showtype)//显示工作组
            {
                BizProcess.Platform.WorkGroup BWorkGroup = new BizProcess.Platform.WorkGroup();
                var workGroups = BWorkGroup.GetAll();

                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("}");
                Response.Write(json.ToString());
                Response.End();
            }


            Guid orgID;

            if (!id.IsGuid(out orgID))
            {
                json.Append("]");
                Response.Write(json.ToString());
            }

            BizProcess.Platform.Organize BOrganize = new BizProcess.Platform.Organize();
            var childOrgs = BOrganize.GetChilds(orgID);

            int count = childOrgs.Count;
            int i     = 0;

            foreach (var org in childOrgs)
            {
                json.Append("{");
                json.AppendFormat("\"id\":\"{0}\",", org.ID);
                json.AppendFormat("\"parentID\":\"{0}\",", id);
                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)
                {
                    json.Append(",");
                }
            }

            var userRelations = new BizProcess.Platform.UsersRelation().GetAllByOrganizeID(orgID);
            var users         = new BizProcess.Platform.Users().GetAllByOrganizeID(orgID);
            int count1        = users.Count;

            if (count1 > 0 && count > 0)
            {
                json.Append(",");
            }
            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}\",", id);
                json.AppendFormat("\"title\":\"{0}{1}\",", user.Name, ur != null && ur.IsMain == 0 ? "<span style='color:#999;'>[兼职]</span>" : "");
                json.AppendFormat("\"ico\":\"{0}\",", Url.Content("~/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(",");
                }
            }
            json.Append("]");
            return(json.ToString());
        }