/// <summary> /// 授权人信息查询 /// </summary> /// <param name="proxyApprovalId"></param> /// <returns></returns> public string GetAuthorizedUserList(string proxyApprovalId) { CasProxyApprovalEntity entity = GetById <CasProxyApprovalEntity>(proxyApprovalId); DataTable dataTable = new DataTable(); dataTable.Columns.Add("id", typeof(String)); dataTable.Columns.Add("name", typeof(String)); DataRow drUser = dataTable.NewRow(); var usersql = new StringBuilder(); usersql.AppendFormat(" SELECT USER_ID as id,(ENGLISH_NAME+'-'+ CHINESE_NAME) as name FROM CAS_USER WHERE USER_ID={0}", Utils.ToSQLStr(entity == null ? "" : entity.AuthorizedUserId).Trim()); var valueString = DataAccess.SelectDataSet(usersql.ToString()); if (valueString.Tables[0].Rows.Count > 0) { drUser["id"] = valueString.Tables[0].Rows[0]["id"]; drUser["name"] = valueString.Tables[0].Rows[0]["name"]; dataTable.Rows.Add(drUser); } JavaScriptSerializer jss = new JavaScriptSerializer(); System.Collections.ArrayList dic = new System.Collections.ArrayList(); foreach (DataRow dr in dataTable.Rows) { System.Collections.Generic.Dictionary <string, object> drow = new System.Collections.Generic.Dictionary <string, object>(); foreach (DataColumn dc in dataTable.Columns) { drow.Add(dc.ColumnName, dr[dc.ColumnName]); } dic.Add(drow); } //序列化 return(jss.Serialize(dic)); }
public ActionResult Edit(CasProxyApprovalEntity entity, string id = "") { if (WebCaching.IsAdmin != "True") { entity.AuthorizedUserId = CurrentUser.CasUserEntity.UserId; } string strError = ""; if (!IsPost) { if (!string.IsNullOrEmpty(id)) { entity = BusinessDataService.ProxyApprovalService.GetById <CasProxyApprovalEntity>(id); ViewBag.AuthorizedUserName = SystemService.UserService.GetById <CasUserEntity>(entity.AuthorizedUserId).EnglishName; } else { entity = new CasProxyApprovalEntity(); entity.AuthorizedUserId = WebCaching.UserId; ViewBag.AuthorizedUserName = SystemService.UserService.GetById <CasUserEntity>(entity.AuthorizedUserId).EnglishName; } } else { if (BusinessDataService.ProxyApprovalService.Save(entity, ref strError)) { return(Json(AjaxResult.Success())); } else { strError = "Update failed"; return(Json(AjaxResult.Success(strError))); } } ViewBag.strError = strError; ViewBag.IsAdmin = WebCaching.IsAdmin; return(View(entity)); }
public bool Save(CasProxyApprovalEntity entity, ref string strError) { if (!string.IsNullOrEmpty(entity.ProxyApprovalId)) { List <string> agentUserIds = entity.AgentUserId.Split(',').ToList(); using (DataAccessBroker broker = DataAccessFactory.Instance()) { try { broker.BeginTransaction(); Delete <CasProxyApprovalEntity>(new List <string> { entity.ProxyApprovalId }, broker); foreach (string agentUserId in agentUserIds) { CasProxyApprovalEntity casProxyApprovalEntity = new CasProxyApprovalEntity(); casProxyApprovalEntity.ProxyApprovalId = Guid.NewGuid().ToString(); casProxyApprovalEntity.AgentUserId = agentUserId; casProxyApprovalEntity.AuthorizedUserId = entity.AuthorizedUserId; casProxyApprovalEntity.BeginTime = entity.BeginTime; casProxyApprovalEntity.EndTime = entity.EndTime; casProxyApprovalEntity.IsDeleted = false; casProxyApprovalEntity.CreateTime = DateTime.Now; casProxyApprovalEntity.CreatedBy = WebCaching.UserId; casProxyApprovalEntity.LastModifiedTime = DateTime.Now; casProxyApprovalEntity.LastModifiedBy = WebCaching.UserId; casProxyApprovalEntity.TerminationTime = null;// entity.EndTime; Insert(casProxyApprovalEntity, broker); } broker.Commit(); return(true); } catch (Exception ex) { broker.RollBack(); return(false); } } } else { List <string> agentUserIds = entity.AgentUserId.Split(',').ToList(); using (DataAccessBroker broker = DataAccessFactory.Instance()) { try { broker.BeginTransaction(); foreach (string agentUserId in agentUserIds) { CasProxyApprovalEntity casProxyApprovalEntity = new CasProxyApprovalEntity(); casProxyApprovalEntity.ProxyApprovalId = Guid.NewGuid().ToString(); casProxyApprovalEntity.AgentUserId = agentUserId; casProxyApprovalEntity.AuthorizedUserId = entity.AuthorizedUserId; casProxyApprovalEntity.BeginTime = entity.BeginTime; casProxyApprovalEntity.EndTime = entity.EndTime; casProxyApprovalEntity.IsDeleted = false; casProxyApprovalEntity.CreateTime = DateTime.Now; casProxyApprovalEntity.CreatedBy = WebCaching.UserId; casProxyApprovalEntity.LastModifiedTime = DateTime.Now; casProxyApprovalEntity.LastModifiedBy = WebCaching.UserId; casProxyApprovalEntity.TerminationTime = null;//entity.EndTime; Insert(casProxyApprovalEntity, broker); } broker.Commit(); return(true); } catch (Exception ex) { broker.RollBack(); return(false); } } } }