public FileResult DownloadTabConfig(string TabIds, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { throw new Exception("系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"); } TabIds = TabIds.Replace("@", ","); TabIds = CPAppContext.FormatSqlPara(TabIds); List <int> col = new List <int>(); TabIds.Split(',').ToList().ForEach(t => { if (string.IsNullOrEmpty(t) == false) { col.Add(int.Parse(t)); } }); string sXml = CPTabEngine.Instance().GetTabConfigXml(col); byte[] byteArray = System.Text.Encoding.Default.GetBytes(sXml); return(File(byteArray, "application/x-msdownload", "标签页配置.CPXml")); }
//http://localhost:9000/CPSite/api/GridEngine/SynGridFieldInfo?GridId=1&CurUserId=1&CurUserIden=E0A04F94-90D5-4C2A-8C9D-836813F73DC4 public CPWebApiBaseReturnEntity SynGridFieldInfo(int GridId, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { re.Result = CPGridEngine.Instance(CurUserId).SyncFieldInfo(GridId); if (re.Result == false) { re.ErrorMsg = "从数据库同步字段信息时出错了!"; } } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); } return(re); }
public CPWebApiBaseReturnEntity ImportGridInnerFunc(int GridId, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { CPGridEngine.Instance(CurUserId).ImportInnerFunc(GridId); re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
//http://localhost:9000/CPSite/api/FormEngine/InitFormDefaultView?FormId=1&CurUserId=1&CurUserIden=E0A04F94-90D5-4C2A-8C9D-836813F73DC4 public CPWebApiBaseReturnEntity InitFormDefaultViewForEditor(int FormId, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { re.Result = CPFormTemplate.Instance(CurUserId).InitFormDefaultViewForEditor(FormId); if (re.Result == false) { re.ErrorMsg = "自动初始化一个默认视图时出错!"; } return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity UpdateTreeDataParent(int TreeDataSourceId, string SourcePKValue, string TargetPKValue, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { string errorMsg = ""; re.Result = CPTreeEngine.Instance().UpdateTreeDataParent(TreeDataSourceId, SourcePKValue, TargetPKValue, ref errorMsg); if (re.Result == false) { re.ErrorMsg = errorMsg; } return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity UpdateUserPwd(string OldPwd, string NewPwd) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); try { string userId = CPExpressionHelper.Instance.RunCompile("${CPUser.UserId()}"); COOrgans organs = COOrgans.Instance(); COUser user = organs.GetUserById(int.Parse(userId), false, false); OldPwd = organs.UserPwdEncrypt(OldPwd); if (user.UserPwd.Equals(OldPwd, StringComparison.CurrentCultureIgnoreCase) == false) { re.Result = false; re.ErrorMsg = "原密码输入不对,请重新输入!"; return(re); } user.UserPwd = organs.UserPwdEncrypt(NewPwd); re.Result = organs.UpdateUser(user); return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity SynTabConfig(int TargetSysId, bool IsCreateNew, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { var files = Request.Form.Files; foreach (var file in files) { // var filename = ContentDispositionHeaderValue // .Parse(file.ContentDisposition) // .FileName // .Trim('"'); //// filename = _FilePath + $@"\{filename}"; // size += file.Length; byte[] bData = null; using (var fileStream = file.OpenReadStream()) using (var ms = new MemoryStream()) { fileStream.CopyTo(ms); bData = ms.ToArray(); //var fileBytes = ms.ToArray(); //string s = Convert.ToBase64String(fileBytes); //// act on the Base64 data } if (bData != null) { if (IsCreateNew) { re.Result = CPTabEngine.Instance().InitTabFromConfigXml(TargetSysId, bData); } else { re.Result = CPTabEngine.Instance().SyncTabFromConfigXml(TargetSysId, bData); } } } re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity SetRoleModuleIdsToSession(int RoleId, int SysId, int CurUserId, string CurUserIden) { base.SetHeader(); CurUserIden = CPAppContext.FormatSqlPara(CurUserIden); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { List <CPPortalModule> col = CPModuleEngine.Instance(CurUserId).GetModulesWithRight(new List <int>() { RoleId }, SysId); string ids = ""; col.ForEach(t => { if (string.IsNullOrEmpty(ids)) { ids = t.Id.ToString(); } else { ids += "," + t.Id.ToString(); } }); CPAppContext.GetHttpContext().Session.SetString("CurUserModuleRightInRole", ids); re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity SetDepDeleteState(int DepId, int CurUserId, string CurUserIden) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { re.Result = COOrgans.Instance().SetDepDeleteState(DepId); return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity SetRoleModuleRight([FromBody] SetRoleModuleRightInput input) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { List <CPPortalModuleRight> col = new List <CPPortalModuleRight>(); string[] sArray = input.ModuleIds.Split(','); sArray.ToList().ForEach(t => { if (string.IsNullOrEmpty(t)) { return; } CPPortalModuleRight item = new CPPortalModuleRight(); item.RoleId = input.RoleId; item.ModuleId = int.Parse(t); col.Add(item); }); re.Result = CPModuleEngine.Instance(input.CurUserId).InitRoleModuleRight(input.RoleId, col); return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity DeleteGridData(int CurUserId, string CurUserIden, string GridCode, string DataPks) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); try { if (this.CheckUserIden(CurUserId, CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } CPGrid grid = CPGridEngine.Instance(CurUserId).GetGrid(GridCode, false, false); DbHelper dbHelper = new DbHelper(grid.DbIns, CPAppContext.CurDbType()); StringBuilder sb = new StringBuilder(); string[] dataPKValueArray = DataPks.Split('@'); if (string.IsNullOrEmpty(grid.DelDataSql)) { string[] pkArray = grid.PKFieldName.Split(','); for (int m = 0; m < dataPKValueArray.Length; m++) { string strSql = ""; strSql = "DELETE FROM " + grid.MainTableName + " WHERE "; string[] vArray = dataPKValueArray[m].Split(','); for (int i = 0; i < pkArray.Length; i++) { if (i == 0) { strSql += pkArray[i] + "='" + vArray[i] + "'"; } else { strSql += " AND " + pkArray[i] + "='" + vArray[i] + "'"; } } sb.Append(strSql); } } else { //自己配置了查询条件 string strSql = grid.DelDataSql; DataPks = "'" + DataPks.Replace("@", "','") + "'"; strSql = strSql.Replace("{@PKValues@}", DataPks); strSql = CPExpressionHelper.Instance.RunCompile(strSql); sb.Append(strSql); } if (sb.Length > 0) { dbHelper.ExecuteNonQuery(sb.ToString()); } re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity UpdateGridData([FromBody] UpdateGridDataInput input) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { CPGrid grid = CPGridEngine.Instance(input.CurUserId).GetGrid(input.GridCode, false, false); DbHelper dbHelper = new DbHelper(grid.DbIns, CPAppContext.CurDbType()); StringBuilder sb = new StringBuilder(); string[] pkArray = grid.PKFieldName.Split(','); input.Items.ForEach(t => { string strSql = ""; strSql = "UPDATE " + grid.MainTableName + " SET "; for (int i = 0; i < t.FieldNamCol.Count; i++) { string sValue = t.FieldValueCol[i]; if (string.IsNullOrEmpty(sValue) == false) { sValue = sValue.Replace("'", "''"); } else { sValue = ""; } if (i == 0) { strSql += t.FieldNamCol[i] + "='" + sValue + "'"; } else { strSql += "," + t.FieldNamCol[i] + "='" + sValue + "'"; } } string[] dataPKArray = t.DataPK.Split(','); for (int i = 0; i < pkArray.Length; i++) { if (i == 0) { strSql += " WHERE " + pkArray[i] + "='" + dataPKArray[i] + "'"; } else { strSql += " AND " + pkArray[i] + "='" + dataPKArray[i] + "'"; } } if (sb.Length > 0) { sb.Append(";"); } sb.Append(strSql); }); if (sb.Length > 0) { dbHelper.ExecuteNonQuery(sb.ToString()); } re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }
public CPWebApiBaseReturnEntity UpdateFormInitData([FromBody] UpdateFormInitDataInput input) { base.SetHeader(); CPWebApiBaseReturnEntity re = new CPWebApiBaseReturnEntity(); if (this.CheckUserIden(input.CurUserId, input.CurUserIden) == false) { re.Result = false; re.ErrorMsg = "系统检测到非法获取数据,请传入正确的用户会话Key与用户Id参数!"; return(re); } try { DbHelper dbHelper = new DbHelper("CPCommonIns", CPAppContext.CurDbType()); StringBuilder sb = new StringBuilder(); sb.Append("DELETE FROM Form_FieldInitValue WHERE FormId=" + input.FormId + " AND GroupID=" + input.GroupId); input.Items.ForEach(t => { string strSql = ""; strSql = "INSERT INTO Form_FieldInitValue"; string fieldNames = ""; string fieldValues = ""; bool needAdd = true; for (int i = 0; i < t.FieldNamCol.Count; i++) { if (t.FieldNamCol[i].Equals("InitInfo", StringComparison.CurrentCultureIgnoreCase)) { if (string.IsNullOrEmpty(t.FieldValueCol[i].Trim())) { needAdd = false; break; } } string sValue = t.FieldValueCol[i]; if (string.IsNullOrEmpty(sValue) == false) { sValue = sValue.Replace("'", "''"); } else { sValue = ""; } if (i == 0) { fieldNames += t.FieldNamCol[i]; fieldValues += "'" + sValue + "'"; } else { fieldNames += "," + t.FieldNamCol[i]; fieldValues += ",'" + sValue + "'"; } } if (needAdd == false) { return; } fieldNames += ",GroupID,FieldId,FormId"; fieldValues += "," + input.GroupId + "," + t.DataPK + "," + input.FormId; strSql += "(" + fieldNames + ") values (" + fieldValues + ")"; if (sb.Length > 0) { sb.Append(";"); } sb.Append(strSql); }); if (sb.Length > 0) { dbHelper.ExecuteNonQuery(sb.ToString()); } re.Result = true; return(re); } catch (Exception ex) { re.Result = false; re.ErrorMsg = ex.Message.ToString(); return(re); } }