/// <summary> /// 加载窗体 /// </summary> public override void FormOnLoad() { BindCategory(); this.entity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(UserInfo, this.entity.Id.ToString()); // 显示内容 this.ShowEntity(); this.Text = "编辑查询引擎定义 - " + entity.FullName; }
private void GetPreviewData() { Cursor holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; var recordCount = 0; QueryEngineDefineEntity queryEngineDefineEntity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(this.UserInfo, this.EntityId); CiDbLinkDefineEntity dblinkEntity = null; IDbProvider dbProvider = null; if (queryEngineDefineEntity != null && !string.IsNullOrEmpty(queryEngineDefineEntity.DataBaseLinkName)) { dblinkEntity = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(this.UserInfo, queryEngineDefineEntity.DataBaseLinkName); } if (dblinkEntity != null) { var DbDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntityByLinkName(this.UserInfo, dblinkEntity.LinkName); dbProvider = DbDefine != null?DbFactoryProvider.GetProvider((CurrentDbType)Enum.Parse(typeof(CurrentDbType), DbDefine.LinkType, true), SecretHelper.AESDecrypt(DbDefine.LinkData)) : DbFactoryProvider.GetProvider(SystemInfo.BusinessDbType, SystemInfo.BusinessDbConnectionString); var dtDynamicJsonDt = dbProvider.GetDTByPage(out recordCount, queryEngineDefineEntity.QueryString, ucPagerEx1.PageIndex, ucPagerEx1.PageSize, string.Empty, queryEngineDefineEntity.OrderByField); ucPagerEx1.RecordCount = recordCount; ucPagerEx1.InitPageInfo(); this.dgvListSample.AutoGenerateColumns = true; this.dgvListSample.DataSource = dtDynamicJsonDt.DefaultView; } else { ucPagerEx1.RecordCount = 0; ucPagerEx1.InitPageInfo(); this.dgvListSample.AutoGenerateColumns = true; this.dgvListSample.DataSource = null; } this.Cursor = holdCursor; }
/// <summary> /// 读取屏幕中输入的数据 /// </summary> /// <returns>操作权限项实体</returns> private QueryEngineDefineEntity GetEntity() { if (this.entity == null) { this.entity = new QueryEngineDefineEntity(); } this.entity.SortCode = 0; this.entity.QueryEngineId = BusinessLogic.ConvertToString(txtQueryEngineId.SelectedValue) ?? null; this.entity.Code = this.txtCode.Text; this.entity.FullName = this.txtFullName.Text; this.entity.DataBaseLinkName = BusinessLogic.ConvertToString(this.cboDataBaseLinkName.SelectedValue); this.entity.DataSourceType = BusinessLogic.ConvertToInt(this.cboDataSourceType.SelectedValue); this.entity.DataSourceName = this.txtDataSourceName.Text; this.entity.QueryStringKey = this.txtQueryStringKey.Text; this.entity.QueryString = this.txtQueryString.Text; this.entity.SelectedField = this.txtSelectedField.Text; this.entity.OrderByField = this.txtOrderByField.Text; this.entity.AllowEdit = this.chkAllowEdit.Checked ? 1 : 0; this.entity.Enabled = this.chkEnabled.Checked ? 1 : 0; this.entity.AllowDelete = this.chkAllowDelete.Checked ? 1 : 0; this.entity.DeleteMark = 0; this.entity.Description = this.txtDescription.Text; return(this.entity); }
private void SubmitForm(HttpContext context) { try { int IsOk = 1; var key = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("key")); var json = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("json")); string Message = key == "" ? "新增成功。" : "修改成功。"; RDIFramework.Utilities.UserInfo curUser = Utils.UserInfo; QueryEngineDefineEntity entity = JsonHelper.JSONToObject <QueryEngineDefineEntity>(json); if (string.IsNullOrEmpty(key)) { //增加 entity.CreateBy = curUser.RealName; entity.CreateUserId = curUser.Id; string statusCode, statusMessage, returnKey; returnKey = RDIFrameworkService.Instance.QueryEngineService.AddQueryEngineDefine(curUser, entity, out statusCode, out statusMessage); context.Response.Write(statusCode == RDIFramework.Utilities.StatusCode.OKAdd.ToString() ? new JsonMessage { Success = true, Data = returnKey, Message = statusMessage }.ToString() : new JsonMessage { Success = false, Data = "0", Message = statusMessage }.ToString()); } else { var updateEntity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(curUser, key); if (updateEntity != null) { updateEntity.QueryEngineId = entity.QueryEngineId; updateEntity.Code = entity.Code; updateEntity.FullName = entity.FullName; updateEntity.DataBaseLinkName = entity.DataBaseLinkName; updateEntity.DataSourceType = entity.DataSourceType; updateEntity.DataSourceName = entity.DataSourceName; updateEntity.QueryStringKey = entity.QueryStringKey; updateEntity.QueryString = entity.QueryString; updateEntity.SelectedField = entity.SelectedField; updateEntity.OrderByField = entity.OrderByField; updateEntity.Enabled = entity.Enabled; updateEntity.AllowEdit = entity.AllowEdit; updateEntity.AllowDelete = entity.AllowDelete; updateEntity.Description = entity.Description; } if (curUser != null) { updateEntity.ModifiedBy = curUser.RealName; updateEntity.ModifiedUserId = curUser.Id; } string statusCode; string statusMessage; RDIFrameworkService.Instance.QueryEngineService.UpdateQueryEngineDefine(curUser, updateEntity, out statusCode, out statusMessage); context.Response.Write(statusCode == RDIFramework.Utilities.StatusCode.OKUpdate.ToString() ? new JsonMessage { Success = true, Data = IsOk.ToString(), Message = statusMessage }.ToString() : new JsonMessage { Success = false, Data = "0", Message = statusMessage }.ToString()); } } catch (Exception ex) { context.Response.Write(new JsonMessage { Success = false, Data = "0", Message = "操作失败:" + ex.Message }.ToString()); } }
/// <summary> /// 按查询引擎主键列表得到对应的查询引擎定义列表 /// </summary> private void GetDynamicJsonByQueryEngineDefineId(HttpContext context) { try { var queryEngineDefineId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("queryEngineDefineId")); int pageSize = Convert.ToInt32(WebCommon.StringHelper.GetRequestObject("pageSize")); int pageIndex = Convert.ToInt32(WebCommon.StringHelper.GetRequestObject("pageNumber")); //排序字段 string sortName = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("sort")); //排序方式 string sortType = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("order")); var where = ""; var filters = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("filter")); if (!string.IsNullOrEmpty(filters)) { string grouptype; var list = SearchFilter.GetSearchList(filters, out grouptype); where = SearchFilter.ToSql(list, grouptype); } var _pageindex = pageIndex > 0 ? pageIndex : 1; var _pagesize = pageSize > 0 ? pageSize : 10; var recordCount = 0; UserInfo vUser = Utils.UserInfo; QueryEngineDefineEntity queryEngineDefineEntity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(vUser, queryEngineDefineId); CiDbLinkDefineEntity dblinkEntity = null; IDbProvider dbProvider = null; if (queryEngineDefineEntity != null && !string.IsNullOrEmpty(queryEngineDefineEntity.DataBaseLinkName)) { dblinkEntity = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(vUser, queryEngineDefineEntity.DataBaseLinkName); } if (dblinkEntity != null) { var DbDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntityByLinkName(vUser, dblinkEntity.LinkName); dbProvider = DbDefine != null?DbFactoryProvider.GetProvider((CurrentDbType)Enum.Parse(typeof(CurrentDbType), DbDefine.LinkType, true), SecretHelper.AESDecrypt(DbDefine.LinkData)) : DbFactoryProvider.GetProvider(SystemInfo.BusinessDbType, SystemInfo.BusinessDbConnectionString); } var dtDynamicJsonDt = dbProvider.GetDTByPage(out recordCount, queryEngineDefineEntity.QueryString, _pageindex, _pagesize, string.Empty, queryEngineDefineEntity.OrderByField); var JsonData = new { page = _pageindex, total = recordCount, rows = dtDynamicJsonDt }; string returnJson = Newtonsoft.Json.JsonConvert.SerializeObject(JsonData); //{ "columns":"[[ {"field":"field1","title":"title1"},{...} ]]",data:[{page:"pageIndex",total:"totalNum",rows:[{name1:value,name2:value},{...}]}]} returnJson = "{\"columns\":" + CreateDataGridColumnModel(dtDynamicJsonDt) + ",\"data\":[" + returnJson + "]}"; //TODO:待处理,处理异常情况(如:数据库连接失败等),前端应该提示 context.Response.Write(returnJson); } catch (Exception ex) { throw ex; } }