Ejemplo n.º 1
0
        /// <summary>
        /// 同意/拒绝加入小组
        /// 同步更新小组中的成员数量
        /// </summary>
        /// <param name="groupId"></param>
        /// <param name="userId"></param>
        /// <param name="status">
        /// <para>0:同意</para>
        /// <para>1:拒绝</para>
        /// </param>
        /// <returns></returns>
        public bool AgreeJoinGroup(int userId, int status, IEnumerable <int> groupId)
        {
            if (groupId == null || groupId.Count() == 0)
            {
                groupId = _dataAccess.FetchListBySql <int>("select GroupId from Int_GroupMember where Status = 1 and UserId = " + userId);
            }
            if (groupId.Count() == 0)
            {
                return(false);
            }
            var doflag = false;

            if (status == 0)
            {
                var list = new List <KeyValuePair <string, string> >();
                list.Add(new KeyValuePair <string, string>("Status", "0"));
                list.Add(new KeyValuePair <string, string>("JoinTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                doflag = _dataAccess.UpdateFields("Int_GroupMember", list, string.Format(" GroupId in ({0}) and UserId = {1} and Status = 1", groupId.GetString(), userId)) > 0;
                if (doflag)
                {
                    string sql = string.Format(@"update Int_Group set MemberCount = ( select count(0) from Int_GroupMember where groupId = Int_Group.groupId and Status = 0 and IsDelete = 0 ) where GroupId in ({0})", groupId.GetString());
                    _dataAccess.ExecuteSql(sql);
                }
            }
            else
            {
                doflag = _dataAccess.UpdateField("Int_GroupMember", "Status", "2", string.Format(" GroupId in ({0}) and UserId = {1} and Status = 1", groupId.GetString(), userId)) > 0;
            }
            return(doflag);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除资源包
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public bool DeleteResourcePackage(string ids)
        {
            var item = new KeyValuePair <string, string>("Status", "-1");

            return(_dataAccess.UpdateFields("Res_ResourcePackage", new List <KeyValuePair <string, string> > {
                item
            }, string.Format(" Id in ({0})", ids)) > 0);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新阅读进度
        /// </summary>
        /// <param name="recordId"></param>
        public void UpdateProcess(int progress, int currentPage, int recordId)
        {
            var list = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("Progress", progress.ToString()));
            list.Add(new KeyValuePair <string, string>("CurrentPage", currentPage.ToString()));
            _dataAccess.UpdateFields("KL_ReadRecord", list, " where recordId = " + recordId);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 批量修改课程体系
 /// </summary>
 /// <param name="courseIds">课程Id</param>
 /// <param name="categoryId">课程体系Id</param>
 /// <returns></returns>
 public int BatchChangeSystem(int[] courseIds, int categoryId)
 {
     BusinessCache.SystemCache.Instance.ClearCourses();
     return(_dataAccess.UpdateFields("Res_Course", new List <KeyValuePair <string, string> >()
     {
         new KeyValuePair <string, string>("CategoryId", categoryId.ToString(CultureInfo.InvariantCulture)),
         new KeyValuePair <string, string>("LastUpdateTime", DateTime.Now.ToString("G"))
     }, " CourseId IN (" + courseIds.GetString() + ")"));
 }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool FreezeUser(int[] userId)
        {
            if (userId.Length == 0)
            {
                return(false);
            }
            var users = _dataAccess.GetListBySql <SysUser>("select Freezed,UserId from Sys_Users where UserId in (" + userId.GetString() + ") and Status = 0");
            var tmp1  = users.Where(p => p.Freezed).Select(p => p.UserId);
            var tmp2  = users.Where(p => !p.Freezed).Select(p => p.UserId);
            var list  = new List <KeyValuePair <string, string> >();

            list.Add(new KeyValuePair <string, string>("Freezed", "0"));
            list.Add(new KeyValuePair <string, string>("LoginFailure", "0"));
            _dataAccess.UpdateFields("Sys_Users", list, "UserId in (" + tmp1.GetString() + ")");
            _dataAccess.UpdateField("Sys_Users", "Freezed", "1", "UserId in (" + tmp2.GetString() + ")");
            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加审批流程
        /// </summary>
        /// <param name="model"></param>
        /// <param name="currentUserId"></param>
        /// <param name="currentTenantId"></param>
        /// <returns></returns>
        public int AddApproveWay(ApproveWay model, int currentUserId, int currentTenantId)
        {
            List <ApproveStep> approveStepListOut;
            List <ApproveDept> approveDeptListOut;
            bool canUpdateOut;
            var  wayId = GetApproveWay(model.DeptId, model.WayType, out approveStepListOut, out approveDeptListOut,
                                       out canUpdateOut);

            if (wayId.WayId != 0)
            {
                if (canUpdateOut)
                {
                    DeleteApproveWay(wayId.WayId, currentUserId);
                }
                else
                {
                    return(0);
                }
            }

            //设置必要属性,添加实例
            model.CreateUser     = currentUserId;
            model.CreateTime     = DateTime.Now;
            model.LastUpdateUser = currentUserId;
            model.LastUpdateTime = DateTime.Now;
            model.IsDelete       = 0;
            var id = _dataAccess.AddEntity(model);

            //添加步骤
            model.ApproveStepList.ForEach(p => p.WayId = id);
            foreach (var approveStep in model.ApproveStepList)
            {
                _dataAccess.AddEntity(approveStep);
            }

            //添加部门
            foreach (var approveDept in model.ApproveDeptList)
            {
                //找到部门以前的流程
                var approvedepts =
                    _dataAccess.GetList <ApproveDept>("Ap_ApproveDept.DeptId=" + approveDept.DeptId +
                                                      " and Ap_ApproveWay.WayType=" + model.WayType +
                                                      " and Ap_ApproveDept.IsDelete=0 and Ap_ApproveWay.IsDelete=0");
                if (approvedepts.Count > 1)
                {
                    throw new Exception(RetechWing.LanguageResources.Other.MultipleApprovalProcess);
                }
                var originalApprovedept = approvedepts.FirstOrDefault();
                //没找到
                if (originalApprovedept == null)
                {
                    approveDept.WayId          = id;
                    approveDept.CreateUser     = currentUserId;
                    approveDept.CreateTime     = DateTime.Now;
                    approveDept.LastUpdateUser = currentUserId;
                    approveDept.LastUpdateTime = DateTime.Now;
                    approveDept.IsDelete       = 0;
                    _dataAccess.AddEntity(approveDept);

                    //使那些挂起的申请(暂时没有审批流程的)重新能够审批,收到站内信
                    foreach (
                        var record in
                        _dataAccess.GetList <ApproveRecord>(
                            "Ap_ApproveRecord.WayId=0 and Ap_ApproveRecord.ObjectDeptId=" +
                            approveDept.DeptId + " and Ap_ApproveRecord.WayType=" + model.WayType))
                    {
                        var receiver = GetMessageReceiver(model.ApproveStepList[0].ApproverType,
                                                          model.ApproveStepList[0].ApproverId,
                                                          record.ObjectUserId);

                        if (model.WayType == 1)
                        {
                            try
                            {
                                var    apply     = _dataAccess.Get <PromotionApply>(record.ObjectId);
                                var    t         = _dataAccess.Get <SysUser>(apply.UserId);
                                string sendtitle = string.Format("审批通知-{0}申请的{1}晋升路径中的{2}岗位", apply.UserRealName,
                                                                 apply.PromotionName, apply.PostName);
                                string sendmessage =
                                    string.Format(
                                        "你好,{0}申请的{1}晋升路径中的{2}岗位,已经提交了!请<a href=\"/[urllanguage]{3}\">进入</a>审批!",
                                        apply.UserRealName, apply.PromotionName, apply.PostName,
                                        "/Approve/ApprovePromotion?keep=1");
                                SysSendMessage.SendMessage(sendtitle, sendmessage, receiver, 99, t.TenantId);
                            }
                            catch
                            {
                            }
                        }
                    }

                    //使那些挂起的申请(暂时没有审批流程的)重新能够审批
                    _dataAccess.UpdateFields("Ap_ApproveRecord", new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("CurrentStepId",
                                                          model.ApproveStepList[0].StepId.ToString(
                                                              CultureInfo.InvariantCulture)),
                        new KeyValuePair <string, string>("CurrentStepOrderNum",
                                                          model.ApproveStepList[0].OrderNum.ToString(
                                                              CultureInfo.InvariantCulture)),
                        new KeyValuePair <string, string>("WayId", id.ToString(CultureInfo.InvariantCulture))
                    }, "Ap_ApproveRecord.WayId=0 and Ap_ApproveRecord.ObjectDeptId=" +
                                             approveDept.DeptId + " and Ap_ApproveRecord.WayType=" + model.WayType);
                }
                //找到并且,当前部门级别 > 老部门级别
                else if (compareDeptLevel(currentTenantId, model.DeptId, originalApprovedept.ApproveWay_DeptId))
                {
                    //如果老流程是部门自己新建的
                    if (originalApprovedept.DeptId == originalApprovedept.ApproveWay_DeptId)
                    {
                        //删除老流程 original_approvedept.WayId
                        DeleteApproveWay(originalApprovedept.WayId, model.CreateUser);
                    }

                    //修改部门跟新流程的关联
                    originalApprovedept.IsDelete       = 0;
                    originalApprovedept.WayId          = id;
                    originalApprovedept.LastUpdateTime = DateTime.Now;
                    originalApprovedept.LastUpdateUser = model.CreateUser;
                    _dataAccess.UpdateEntity(originalApprovedept);
                }
            }
            return(id);
        }