Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string id = context.Request.QueryString["id"];
            Guid   gid;

            if (id.IsNullOrEmpty())
            {
                context.Response.Write("");
            }
            FoWoSoft.Platform.Organize borg  = new FoWoSoft.Platform.Organize();
            FoWoSoft.Platform.Users    buser = new FoWoSoft.Platform.Users();
            if (id.StartsWith(FoWoSoft.Platform.Users.PREFIX))
            {
                Guid uid = buser.RemovePrefix1(id).ToGuid();
                context.Response.Write(string.Concat(borg.GetAllParentNames(buser.GetMainStation(uid)), " / ", buser.GetName(uid)));
            }
            else if (id.StartsWith(FoWoSoft.Platform.WorkGroup.PREFIX))
            {
                context.Response.Write(new FoWoSoft.Platform.WorkGroup().GetUsersNames(FoWoSoft.Platform.WorkGroup.RemovePrefix(id).ToGuid(), '、'));
            }
            else if (id.IsGuid(out gid))
            {
                context.Response.Write(borg.GetAllParentNames(gid));
            }
            context.Response.Write("");
        }
Esempio n. 2
0
        public void CreateNewTempTestMeet(FoWoSoft.Data.Model.MeetInfo meetInfot)
        {
            MeetInfoModel meetInfo = meetInfot as MeetInfoModel;
            string        testMeetid;

            meetInfoService.RoomisUpdate(meetInfo, out testMeetid);
            var tempmeet = Common.Tools.MeetInfoToTempTestMeet(meetInfo, testMeetid);

            new FoWoSoft.Platform.TempTestMeet().RoomisAdd(tempmeet);

            var aplicatUser = new FoWoSoft.Platform.Users().GetByAccount(meetInfo.ApplicatId);
            var adminUser   = new FoWoSoft.Platform.Users().GetByAccount(meetInfo.AdminId);
            var task        = new FoWoSoft.Data.Model.WorkFlowTask
            {
                InstanceID = testMeetid,
                Title      = meetInfo.temp2,

                SenderID    = aplicatUser.ID,
                SenderName  = aplicatUser.Name,
                ReceiveID   = adminUser.ID,
                ReceiveName = adminUser.Name
            };

            new FoWoSoft.Platform.WorkFlowTask().RoomisCreate(task);
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                string oldpass = Request.Form["oldpass"];
                string newpass = Request.Form["newpass"];

                FoWoSoft.Platform.Users busers = new FoWoSoft.Platform.Users();
                var user = FoWoSoft.Platform.Users.CurrentUser;
                if (user != null)
                {
                    if (string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), oldpass.Trim()), false) != 0)
                    {
                        FoWoSoft.Platform.Log.Add("修改密码失败", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码失败,旧密码错误!"), FoWoSoft.Platform.Log.Types.用户登录);
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('旧密码错误!');", true);
                    }
                    else
                    {
                        busers.UpdatePassword(newpass.Trim(), user.ID);
                        FoWoSoft.Platform.Log.Add("修改密码成功", string.Concat("用户:", user.Name, "(", user.ID, ")修改密码成功!"), FoWoSoft.Platform.Log.Types.用户登录);
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('密码修改成功!');new RoadUI.Window().close();", true);
                    }
                }
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Account.Attributes.Add("validate_url", "CheckAccount.ashx");
            FoWoSoft.Platform.Organize borganize = new FoWoSoft.Platform.Organize();
            FoWoSoft.Platform.Users    busers    = new FoWoSoft.Platform.Users();

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

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

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

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

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

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

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

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

                FoWoSoft.Platform.Log.Add("添加了人员", userXML, FoWoSoft.Platform.Log.Types.组织机构);
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "alert('添加成功!');parent.frames[0].reLoad('" + id + "');window.location=window.location;", true);
            }
            this.StatusRadios.Text = borganize.GetStatusRadio("Status", "0", "validate=\"radio\"");
        }
Esempio n. 5
0
        public FoWoSoft.Data.Model.Users CreateNewUser(string userid)
        {
            var user = new FoWoSoft.Platform.Users().GetByAccount(userid);

            if (user != null)
            {
                return(user);
            }

            //根据UserId获取从远程用户信息
            var userInfoEdu = new EduWebService().GetUser(userid);

            if (userInfoEdu == null)
            {
                return(null);
            }
            //更新用户信息
            user = new FoWoSoft.Data.Model.Users()
            {
                Account  = userid,
                ID       = Guid.NewGuid(),
                Name     = userInfoEdu.XM,
                Status   = 0,
                Password = "******",
                Sort     = 1,
                Note     = ""
            };

            new FoWoSoft.Platform.Users().Add(user);
            //创建组织关系
            var guidId = new FoWoSoft.Platform.Guid_id().Get(userInfoEdu.BMBH);

            new FoWoSoft.Platform.UsersRelation().Add(new FoWoSoft.Data.Model.UsersRelation()
            {
                OrganizeID = guidId.GuidId,
                UserID     = user.ID,
                Sort       = 1,
                IsMain     = 1
            });
            //更新组织下人员的个数
            new FoWoSoft.Platform.Organize().UpdateChildsLength(guidId.GuidId);
            //创建用户角色
            new FoWoSoft.Platform.UsersRole().Add(new FoWoSoft.Data.Model.UsersRole()
            {
                RoleID    = Guid.Parse("0CF2ABB1-5F90-4FB3-8FA9-B53628B92879"),
                MemberID  = user.ID,
                IsDefault = true
            });
            return(user);
        }
Esempio n. 6
0
        /// <summary>
        /// 每一步的会议审核
        /// </summary>
        /// <param name="eventId"></param>
        /// <param name="apperot"></param>
        /// <returns></returns>
        public static string SendStep(string eventId, string install)
        {
            var tasks        = new FoWoSoft.Platform.WorkFlowTask().GetAll();
            var installTasks = tasks.Where(s => s.InstanceID.ToString().Equals(install, StringComparison.OrdinalIgnoreCase)).OrderByDescending(s => s.Sort).Take(2);

            string[] remarks = new string[] { "待处理", "打开", "中间完成", "退回", "他人已处理", "他人已退回" };
            foreach (var item in installTasks)
            {
                var    approver = new FoWoSoft.Platform.Users().Get(item.ReceiveID).Account;
                var    remark   = (item.Status > -1 && item.Status < 6) ? remarks[item.Status] : "";
                string data     = JsonConvert.SerializeObject(new
                {
                    approver = approver,
                    status   = "PENDING",
                    remarks  = remark
                });
                string address = "api/booking/events/{0}/approval";
                Put_Roomis(eventId, address, data);
            }
            return("1");
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string parentID = Request.QueryString["parentid"];

            if (IsPostBack)
            {
                string   sort                  = Request.Form["sort"] ?? "";
                string[] sortArray             = sort.Split(',');
                FoWoSoft.Platform.Users busers = new FoWoSoft.Platform.Users();
                for (int i = 0; i < sortArray.Length; i++)
                {
                    Guid gid;
                    if (!sortArray[i].IsGuid(out gid))
                    {
                        continue;
                    }
                    busers.UpdateSort(gid, i + 1);
                }
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "ok", "parent.frames[0].reLoad('" + parentID + "');", true);
            }
            Users = new FoWoSoft.Platform.Organize().GetAllUsers(parentID.ToGuid());
        }
Esempio n. 8
0
        public void CreateNewTempTestMeet(FoWoSoft.Data.Model.MeetInfo meetInfot)
        {
            MeetInfoModel meetInfo = meetInfot as MeetInfoModel;
            string        testMeetid;

            meetInfoService.RoomisUpdate(meetInfo, out testMeetid);
            var tempmeet = Common.Tools.MeetInfoToTempTestMeet(meetInfo, testMeetid);

            new FoWoSoft.Platform.TempTestMeet().RoomisAdd(tempmeet);

            var aplicatUser = new FoWoSoft.Platform.Users().GetByAccount(meetInfo.ApplicatId);
            var adminUser   = new FoWoSoft.Platform.Users().GetByAccount(meetInfo.AdminId);
            var task        = new FoWoSoft.Data.Model.WorkFlowTask
            {
                InstanceID = testMeetid,
                Title      = meetInfo.temp2,

                SenderID    = aplicatUser.ID,
                SenderName  = aplicatUser.Name,
                ReceiveID   = adminUser.ID,
                ReceiveName = adminUser.Name
            };

            new FoWoSoft.Platform.WorkFlowTask().RoomisCreate(task);
            //由***部门,***(人名),申请的会议名称为:****会议申请,需要您审核。
            var userInfoEdu = new EduWebService().GetUser(meetInfo.ApplicatId);

            if (userInfoEdu != null)
            {
                // var meetMsgProgress = $"由{userInfoEdu.BMMC}部门,{userInfoEdu.XM}(人名),申请的会议名称为:{meetInfo.temp2},";
                // var msg = $"{meetMsgProgress}会议申请,需要您审核。";
                var msg = string.Format(DuanxinService.DuanxinSendMsg4, userInfoEdu.BMMC, userInfoEdu.XM, meetInfo.temp2);


                //20180110短信发送
                new DuanxinService().smsSend(meetInfo.AdminId, msg);
            }
        }
Esempio n. 9
0
        private void check()
        {
            string isVcodeSessionKey = FoWoSoft.Utility.Keys.SessionKeys.IsValidateCode.ToString();
            string vcodeSessionKey   = FoWoSoft.Utility.Keys.SessionKeys.ValidateCode.ToString();

            string account       = Request.Form["Account"];
            string password      = Request.Form["Password"];
            string force         = Request.Form["Force"];
            string vcode         = Request.Form["VCode"];
            bool   isSessionLost = "1" == Request.QueryString["session"];//是否是超时后再登录

            if (Session[isVcodeSessionKey] != null &&
                "1" == Session[isVcodeSessionKey].ToString() &&
                (Session[vcodeSessionKey] == null ||
                 string.Compare(Session[vcodeSessionKey].ToString(), vcode.Trim(), true) != 0))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "error", "alert('验证码错误!');", true);
            }
            else if (account.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                Session[isVcodeSessionKey] = "1";
                FoWoSoft.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码为空"), FoWoSoft.Platform.Log.Types.用户登录);
                Script = "alert('帐号或密码不能为空!');";
            }
            else
            {
                FoWoSoft.Platform.Users busers = new FoWoSoft.Platform.Users();
                var user = busers.GetByAccount(account.Trim());
                if (user == null || string.Compare(user.Password, busers.GetUserEncryptionPassword(user.ID.ToString(), password.Trim()), false) != 0)
                {
                    Session[isVcodeSessionKey] = "1";
                    FoWoSoft.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号或密码错误"), FoWoSoft.Platform.Log.Types.用户登录);
                    Script = "alert('帐号或密码错误!');";
                }
                else if (user.Status == 1)
                {
                    Session[isVcodeSessionKey] = "1";
                    FoWoSoft.Platform.Log.Add("用户登录失败", string.Concat("用户:", account, "登录失败,帐号已被冻结"), FoWoSoft.Platform.Log.Types.用户登录);
                    Script = "alert('帐号已被冻结!');";
                }
                else
                {
                    FoWoSoft.Platform.OnlineUsers bou = new FoWoSoft.Platform.OnlineUsers();
                    var onUser = bou.Get(user.ID);
                    if (onUser != null && "1" != force)
                    {
                        string ip = onUser.IP;
                        Session.Remove(isVcodeSessionKey);
                        Script = "if(confirm('当前帐号已经在" + ip + "登录,您要强行登录吗?')){$('#Account').val('" + account + "');$('#Password').val('" + password + "');$('#Force').val('1');$('#form1').submit();}";
                    }
                    else
                    {
                        Guid uniqueID = Guid.NewGuid();
                        Session[FoWoSoft.Utility.Keys.SessionKeys.UserID.ToString()]       = user.ID;
                        Session[FoWoSoft.Utility.Keys.SessionKeys.UserUniqueID.ToString()] = uniqueID;
                        bou.Add(user, uniqueID);
                        Session.Remove(isVcodeSessionKey);
                        FoWoSoft.Platform.Log.Add("用户登录成功", string.Concat("用户:", user.Name, "(", user.ID, ")登录成功"), FoWoSoft.Platform.Log.Types.用户登录);
                        if (isSessionLost)
                        {
                            Script = "alert('登录成功!');new RoadUI.Window().close();";
                        }
                        else
                        {
                            Script = "top.location='" + Common.Tools.BaseUrl + "Default.aspx';";
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 每一步的会议审核
        /// </summary>
        /// <param name="eventId"></param>
        /// <param name="apperot"></param>
        /// <returns></returns>
        public string SendStep(string eventId, string instanceid, FoWoSoft.Data.Model.MeetInfo meetInfo)
        {
            var meetMsg = $" 您申请的会议名称:{meetInfo.temp2};会议地址:{meetInfo.MeetName},";

            var userInfoEdu = new EduWebService().GetUser(meetInfo.ApplicatId);

            if (userInfoEdu == null)
            {
                return(null);
            }

            var tasks        = new FoWoSoft.Platform.WorkFlowTask().GetAll();
            var installTasks = tasks.Where(s => s.InstanceID.ToString().Equals(instanceid, StringComparison.OrdinalIgnoreCase) && s.Status == 0);

            string[] remarks = new string[] { "请审核", "打开", "中间完成", "退回", "他人已处理", "他人已退回" };
            var      n       = 0;

            foreach (var item in installTasks)
            {
                var task = tasks.FirstOrDefault(s => s.ID == item.PrevID);
                if (n == 0)//发给审请人
                {
                    if (task != null)
                    {
                        //申请过程:您申请的会议名称:***;会议地址:****,****(部门)申请通过。
                        duanxinService.Sendapplication(instanceid, string.Format(DuanxinService.DuanxinSendMsg1, meetInfo.temp2, meetInfo.MeetName, task.StepName));
                    }
                }
                n++;
                var    approver = new FoWoSoft.Platform.Users().Get(item.ReceiveID).Account;
                var    remark   = (item.Status > -1 && item.Status < 6) ? remarks[item.Status] : "";
                string data     = JsonConvert.SerializeObject(new
                {
                    approver = approver,
                    status   = "PENDING",
                    remarks  = remark
                });
                string address = "api/booking/events/{0}/approval";
                //由*** 部门,***(人名),申请的会议名称为:****会议申请,需要您审核。
                FoWoSoft.Platform.Log.Add1(string.Format("各部门({0})", item.StepName + userInfoEdu.BMMC + userInfoEdu.XM + meetInfo.temp2), data, FoWoSoft.Platform.Log.Types.其它分类);


                //20180110短信发送

                if (item.StepName == "信息办")
                {
                    //由*** 部门,***(人名),申请的会议名称为:****会议申请已通过,请确认并提供相关支持。
                    duanxinService.Sendapplication(instanceid, string.Format(DuanxinService.DuanxinSendMsg6, userInfoEdu.BMMC, userInfoEdu.XM, meetInfo.MeetName, meetInfo.temp2, meetInfo.MeetTimes));
                }
                else if (item.StepName.Contains("各部门"))
                {
                    var prevName = tasks.FirstOrDefault(s => s.ID == item.PrevID).StepName;

                    duanxinService.smsSend(approver, string.Format(DuanxinService.DuanxinSendMsg5, userInfoEdu.BMMC, userInfoEdu.XM, meetInfo.MeetName, meetInfo.temp2, meetInfo.MeetTimes, prevName));
                }
                else
                {
                    duanxinService.smsSend(approver, string.Format(DuanxinService.DuanxinSendMsg4, userInfoEdu.BMMC, userInfoEdu.XM, meetInfo.MeetName, meetInfo.temp2, meetInfo.MeetTimes));
                }

                Put_Roomis(eventId, address, data);
            }

            return("1");
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            isoneself = "1" == Request.QueryString["isoneself"];
            if (isoneself)
            {
                this.S_UserID.Disabled = true;
                this.S_UserID.Value    = FoWoSoft.Platform.Users.PREFIX + FoWoSoft.Platform.Users.CurrentUserID.ToString();
            }
            FoWoSoft.Platform.WorkFlowDelegation bworkFlowDelegation = new FoWoSoft.Platform.WorkFlowDelegation();
            FoWoSoft.Platform.Organize           borganize           = new FoWoSoft.Platform.Organize();
            FoWoSoft.Platform.Users    busers    = new FoWoSoft.Platform.Users();
            FoWoSoft.Platform.WorkFlow bworkFlow = new FoWoSoft.Platform.WorkFlow();

            string startTime = string.Empty;
            string endTime   = string.Empty;
            string suserid   = string.Empty;
            string Query1    = string.Format("&appid={0}&tabid={1}&isoneself={2}", Request.QueryString["appid"],
                                             Request.QueryString["tabid"], Request.QueryString["isoneself"]);

            if (IsPostBack)
            {
                if (!Request.Form["DeleteBut"].IsNullOrEmpty())
                {
                    string ids = Request.Form["checkbox_app"];
                    foreach (string id in ids.Split(','))
                    {
                        Guid bid;
                        if (!id.IsGuid(out bid))
                        {
                            continue;
                        }
                        var comment = bworkFlowDelegation.Get(bid);
                        if (comment != null)
                        {
                            bworkFlowDelegation.Delete(bid);
                            FoWoSoft.Platform.Log.Add("删除了流程意见", comment.Serialize(), FoWoSoft.Platform.Log.Types.流程相关);
                        }
                    }
                    bworkFlowDelegation.RefreshCache();
                }
                startTime = Request.Form["S_StartTime"];
                endTime   = Request.Form["S_EndTime"];
                suserid   = Request.Form["S_UserID"];
            }
            else
            {
                startTime = Request.QueryString["S_StartTime"];
                endTime   = Request.QueryString["S_EndTime"];
                suserid   = Request.QueryString["S_UserID"];
            }
            Query1 += "&S_StartTime=" + startTime + "&S_EndTime=" + endTime + "&S_UserID=" + suserid;
            string pager;
            bool   isOneSelf = "1" == Request.QueryString["isoneself"];

            if (isOneSelf)
            {
                workFlowDelegationList = bworkFlowDelegation.GetPagerData(out pager, Query1, FoWoSoft.Platform.Users.CurrentUserID.ToString(), startTime, endTime);
            }
            else
            {
                workFlowDelegationList = bworkFlowDelegation.GetPagerData(out pager, Query1, FoWoSoft.Platform.Users.RemovePrefix(suserid), startTime, endTime);
            }
            this.Pager.Text = pager;
        }
Esempio n. 12
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());
        }
Esempio n. 13
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\"");
        }