Beispiel #1
0
        private static void SaveDocRoleCtrl(List <string> editRoleList, string strCrUsrId, string strDocId)
        {
            List <Model.DocRoleCtrl> docRoleCtrls = new List <Model.DocRoleCtrl>();

            Model.DocRoleCtrl docAdminRoleCtrl = new Model.DocRoleCtrl
            {
                Crdt     = DateTime.Now,
                Updt     = DateTime.Now,
                CrUsrId  = strCrUsrId,
                UpUsrId  = strCrUsrId,
                CtrlType = 1,
                DocId    = strDocId,
                RoleId   = "4be2ec6a-5ca6-4a73-8975-892189b72137"
            };
            docRoleCtrls.Add(docAdminRoleCtrl);
            if (editRoleList != null && editRoleList.Count > 0)
            {
                foreach (var item in editRoleList)
                {
                    Model.DocRoleCtrl docRoleCtrl = new Model.DocRoleCtrl
                    {
                        Crdt     = DateTime.Now,
                        Updt     = DateTime.Now,
                        CrUsrId  = strCrUsrId,
                        UpUsrId  = strCrUsrId,
                        CtrlType = 1,
                        DocId    = strDocId,
                        RoleId   = item
                    };
                    docRoleCtrls.Add(docRoleCtrl);
                }
            }
            if (docRoleCtrls.Count > 0)
            {
                DocRoleCtrl.Add(docRoleCtrls);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Model.HelpDoc helpDocModel, bool isDefault,
                                  List <string> viewRoleList, List <string> editRoleList)
        {
            var  roleList  = UsrRole.GetModel(helpDocModel.upUsrId).ToList();
            bool checkRole = false;

            //检查文档修改人是否有权限更新
            foreach (var item in roleList)
            {
                if (DocRoleCtrl.Get(helpDocModel.docId, item.roleId).Count > 0)
                {
                    checkRole = true;
                    break;
                }
            }
            if (!checkRole)
            {
                return(false);
            }
            using (TransactionScope ts = new TransactionScope())
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update helpdoc set ");
                strSql.Append("docTypeId=?docTypeId,");
                strSql.Append("docTitle=?docTitle,");
                strSql.Append("docContent=?docContent,");
                strSql.Append("docFullText=?docFullText,");
                strSql.Append("docNum=?docNum,");
                strSql.Append("docDeptId=?docDeptId,");
                strSql.Append("docState=?docState,");
                strSql.Append("updt=?updt,");
                strSql.Append("updt=?updt,");
                strSql.Append("docAttachment=?docAttachment");
                strSql.Append(" where docId=?docId");

                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("?docTypeId", helpDocModel.docTypeId);
                parameters.Add("?docTitle", helpDocModel.docTitle);
                parameters.Add("?docContent", helpDocModel.docContent);
                parameters.Add("?docFullText", helpDocModel.docFullText);
                parameters.Add("?docNum", helpDocModel.docNum);
                parameters.Add("?docDeptId", helpDocModel.docDeptId);
                parameters.Add("?docState", helpDocModel.docState);
                parameters.Add("?updt", helpDocModel.updt);
                parameters.Add("?upUsrId", helpDocModel.upUsrId);
                parameters.Add("?docId", helpDocModel.docId);
                parameters.Add("?docAttachment", helpDocModel.docAttachment);

                //有编辑权限即有查看权限
                foreach (var item in editRoleList)
                {
                    if (!viewRoleList.Contains(item))
                    {
                        viewRoleList.Add(item);
                    }
                }

                SaveDocRole(viewRoleList, helpDocModel.crUsrId, helpDocModel.docId, isDefault);

                SaveDocRoleCtrl(editRoleList, helpDocModel.crUsrId, helpDocModel.docId);

                int rows = mysql.ExcuteNonQuery <Model.HelpDoc>(DapperMySQLHelper.ConnectionString, strSql.ToString(), parameters, false);
                ts.Complete();
                return(rows > 0);
            }
        }