Exemple #1
0
        /// <summary>
        /// 批量置删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响的行数</returns>
        public int SetDeleted(UserInfo userInfo, string[] ids)
        {
            int returnValue = 0;

            if (ids == null || ids.Length <= 0)
            {
                return(returnValue);
            }

            var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.OrganizeService_SetDeleted);

            ServiceUtil.ProcessRDIWriteDbWithTran(userInfo, parameter, dbProvider =>
            {
                var manager = new PiOrganizeManager(dbProvider, userInfo);
                for (int pos = 0; pos < ids.Length; pos++)
                {
                    //逻辑删除组织机构
                    returnValue += manager.SetDeleted(ids[pos]);
                    //同步处理用户表组织机构相关数据
                    var userManager = new PiUserManager(dbProvider, userInfo);
                    var parameters  = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldCompanyId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldCompanyId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldSubCompanyId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldDepartmentId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldDepartmentName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldDepartmentId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldSubDepartmentId, ids[pos]), parameters);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupId, null),
                        new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupName, null)
                    };
                    userManager.SetProperty(new KeyValuePair <string, object>(PiUserTable.FieldWorkgroupId, ids[pos]), parameters);
                    //同步处理员工表组织机构相关数据
                    var staffOrganizeManager = new PiStaffOrganizeManager(dbProvider, userInfo);
                    parameters = new List <KeyValuePair <string, object> >
                    {
                        new KeyValuePair <string, object>(PiStaffOrganizeTable.FieldOrganizeId, ids[pos])
                    };
                    staffOrganizeManager.SetDeleted(parameters, true);
                }
            });
            return(returnValue);
        }