Ejemplo n.º 1
0
        public override void ShowEntity()
        {
            currentDblinkDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(this.UserInfo, this.EntityId);
            if (currentDblinkDefine == null)
            {
                return;
            }

            this.txtLinkName.Text    = currentDblinkDefine.LinkName;
            this.cboLinkType.Text    = currentDblinkDefine.LinkType;
            this.chkEnabled.Checked  = BusinessLogic.ConvertIntToBoolean(currentDblinkDefine.Enabled);
            this.txtDescription.Text = currentDblinkDefine.Description;
            this.txtDbLinks.Text     = SecretHelper.AESDecrypt(currentDblinkDefine.LinkData);
        }
Ejemplo n.º 2
0
        public override bool SaveEntity()
        {
            var dbLinkEntity = new CiDbLinkDefineEntity
            {
                LinkName    = this.txtLinkName.Text.Trim(),
                LinkType    = this.cboLinkType.Text.Trim(),
                Enabled     = this.chkEnabled.Checked ? 1 : 0,
                DeleteMark  = 0,
                Description = this.txtDescription.Text.Trim()
            };
            string linkData = txtDbLinks.Text.Trim();

            dbLinkEntity.LinkData = SecretHelper.AESEncrypt(linkData);

            string statusMessage = string.Empty;
            string statusCode    = string.Empty;

            try
            {
                RDIFrameworkService.Instance.DbLinkDefineService.Add(base.UserInfo, dbLinkEntity, out statusCode, out statusMessage);
                if (statusCode == StatusCode.OKAdd.ToString())
                {
                    if (SystemInfo.ShowSuccessMsg)
                    {
                        MessageBoxHelper.ShowSuccessMsg(statusMessage);
                    }
                    return(true);
                }

                MessageBoxHelper.ShowWarningMsg(statusMessage);
                if (statusCode == StatusCode.ErrorNameExist.ToString())
                {
                    this.txtLinkName.SelectAll();
                }
                return(false);
            }
            catch (Exception ex)
            {
                base.ProcessException(ex);
                return(false);
            }
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        /// <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;
            }
        }