Exemplo n.º 1
0
        /// <summary>
        /// 透过DataConnect生成PersistBroker
        /// </summary>
        /// <returns></returns>
        public IPersistBroker GetPersistBroker(RptViewDataConnect dataConnect)
        {
            if (dataConnect == null)
            {
                return(null);
            }
            IPersistBroker persistBroker = null;
            string         strPassword   = BenQGuru.eMES.Common.Helper.EncryptionHelper.DESDecryption(dataConnect.Password);

            if (dataConnect.ServerType == DatabaseType.SQLServer)
            {
                string           strConn = string.Format("Data Source={0};User ID={1};Password={2};Initial Catalog={3};", dataConnect.ServiceName, dataConnect.UserName, strPassword, dataConnect.DefaultDatabase);
                SqlPersistBroker sql     = new SqlPersistBroker(strConn);
                _connection   = sql.Connection;
                persistBroker = new BenQGuru.eMES.Common.PersistBroker.SqlPersistBroker(strConn);
            }
            else if (dataConnect.ServerType == DatabaseType.Oracle)
            {
                string             strConn = string.Format("Provider=OraOLEDB.Oracle;Data Source={0};User ID={1};Password={2};Persist Security Info=True;", dataConnect.ServiceName, dataConnect.UserName, strPassword);
                OLEDBPersistBroker ole     = new OLEDBPersistBroker(strConn);
                _connection   = ole.Connection;
                persistBroker = new BenQGuru.eMES.Common.PersistBroker.OLEDBPersistBroker(strConn);
            }
            return(persistBroker);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 检查数据库连接是否能连接
        /// </summary>
        /// <param name="dataConnect"></param>
        /// <returns></returns>
        public bool CheckDataConnect(RptViewDataConnect dataConnect)
        {
            IPersistBroker persistBroker = this.GetPersistBroker(dataConnect);

            if (persistBroker == null)
            {
                return(false);
            }
            try
            {
                _connection.Open();
                _connection.Close();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        protected override object GetEditObject()
        {
            if (_facade == null)
            {
                _facade = new ReportViewFacade(base.DataProvider);
            }
            RptViewDataConnect rptviewdataconnect = this._facade.CreateNewRptViewDataConnect();

            rptviewdataconnect.ConnectName     = FormatHelper.CleanString(this.txtNameEdit.Text);
            rptviewdataconnect.Description     = FormatHelper.CleanString(this.txtDescriptEdit.Text, 100);
            rptviewdataconnect.ServerType      = this.drpDBTypeEdit.SelectedValue;// FormatHelper.TOTimeInt(this.timeShiftEndTimeEdit.Text);
            rptviewdataconnect.ServiceName     = FormatHelper.CleanString(this.txtDBNameEdit.Text);
            rptviewdataconnect.DefaultDatabase = FormatHelper.CleanString(this.txtDBDefaultNameEdit.Text);
            rptviewdataconnect.UserName        = FormatHelper.CleanString(this.txtconnectusername.Text);
            if (this.chknopassword.Checked)
            {
                rptviewdataconnect.Password = EncryptionHelper.DESEncryption("");
            }
            else
            {
                if (this.cmdSave.Disabled)
                {
                    rptviewdataconnect.Password = EncryptionHelper.DESEncryption(FormatHelper.CleanString(txtpassword.Text));
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtpassword.Text))
                    {
                        rptviewdataconnect.Password = EncryptionHelper.DESEncryption(FormatHelper.CleanString(txtpassword.Text));
                    }
                    else
                    {
                        rptviewdataconnect.Password = ((RptViewDataConnect)_facade.GetRptViewDataConnect(Convert.ToDecimal(this.datasourceid.Value))).Password;
                    }
                }
            }
            rptviewdataconnect.MaintainUser = this.GetUserCode();
            return(rptviewdataconnect);
        }