Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CMICT.CSP.Model.BS_DATASOURCE GetModel(Guid SourceID)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from BS_DATASOURCE ");
            strSql.Append(" where SourceID=@SourceID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SourceID", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = SourceID;

            CMICT.CSP.Model.BS_DATASOURCE model = new CMICT.CSP.Model.BS_DATASOURCE();
            DataSet ds = dbhelper.ExecuteDataSet(CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CMICT.CSP.Model.BS_DATASOURCE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BS_DATASOURCE(");
            strSql.Append("SourceID,SourceName,SourceDesc,BigCategory,SmallCategory,SourceIP,UserName,Password,DBName,ObjectType,ObjectName,SourceCNName,SourceStatus,Created,Modified,Author,Editor)");
            strSql.Append(" values (");
            strSql.Append("@SourceID,@SourceName,@SourceDesc,@BigCategory,@SmallCategory,@SourceIP,@UserName,@Password,@DBName,@ObjectType,@ObjectName,@SourceCNName,@SourceStatus,@Created,@Modified,@Author,@Editor)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SourceID",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@SourceName",    SqlDbType.NVarChar,          50),
                new SqlParameter("@SourceDesc",    SqlDbType.NVarChar,         200),
                new SqlParameter("@BigCategory",   SqlDbType.NVarChar,          50),
                new SqlParameter("@SmallCategory", SqlDbType.NVarChar,         200),
                new SqlParameter("@SourceIP",      SqlDbType.NVarChar,          50),
                new SqlParameter("@UserName",      SqlDbType.NVarChar,          50),
                new SqlParameter("@Password",      SqlDbType.NVarChar,          50),
                new SqlParameter("@DBName",        SqlDbType.NVarChar,          50),
                new SqlParameter("@ObjectType",    SqlDbType.NVarChar,          50),
                new SqlParameter("@ObjectName",    SqlDbType.NVarChar,          50),
                new SqlParameter("@SourceCNName",  SqlDbType.NVarChar,         200),
                new SqlParameter("@SourceStatus",  SqlDbType.NVarChar,          50),
                new SqlParameter("@Created",       SqlDbType.DateTime),
                new SqlParameter("@Modified",      SqlDbType.DateTime),
                new SqlParameter("@Author",        SqlDbType.NVarChar,          50),
                new SqlParameter("@Editor",        SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = Guid.NewGuid();
            parameters[1].Value  = model.SourceName;
            parameters[2].Value  = model.SourceDesc;
            parameters[3].Value  = model.BigCategory;
            parameters[4].Value  = model.SmallCategory;
            parameters[5].Value  = model.SourceIP;
            parameters[6].Value  = model.UserName;
            parameters[7].Value  = model.Password;
            parameters[8].Value  = model.DBName;
            parameters[9].Value  = model.ObjectType;
            parameters[10].Value = model.ObjectName;
            parameters[11].Value = model.SourceCNName;
            parameters[12].Value = model.SourceStatus;
            parameters[13].Value = model.Created;
            parameters[14].Value = model.Modified;
            parameters[15].Value = model.Author;
            parameters[16].Value = model.Editor;

            int rows = dbhelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 private void ShowInfo(Guid SourceID)
 {
     CMICT.CSP.BLL.BS_DATASOURCEBLL bll   = new CMICT.CSP.BLL.BS_DATASOURCEBLL();
     CMICT.CSP.Model.BS_DATASOURCE  model = bll.GetModel(SourceID);
     if (model != null)
     {
         this.txtSourceName.Value = model.SourceName;
         this.txtSourceIP.Value   = model.SourceIP;
         this.txtUserName.Value   = model.UserName;
         this.txtPwd.Text         = model.Password;
         this.txtSourceDesc.Value = model.SourceDesc;
         this.txtPwd.Attributes.Add("value", model.Password);
         string SourceIP   = txtSourceIP.Value.Trim();
         string UserName   = txtUserName.Value.Trim();
         string Pwd        = txtPwd.Text.Trim();
         string DBName     = model.DBName;
         string ObjectType = model.ObjectType;
         this.hidSourceStatus.Value  = model.SourceStatus;
         ddlObjectType.SelectedValue = model.ObjectType;
         if (model.SourceStatus.Trim() == "ENABLE")
         {
             string temnames = GetTemplateInfoBySourceID(SourceID.ToString());
             hidtemnames.Value = temnames;
         }
         try
         {
             string tipcontent = string.Empty;
             TestConn(out tipcontent, 1);
             ddlDBName.SelectedValue = model.DBName;
             BindObjectName();
             ddlObjectName.SelectedValue = model.ObjectName;
             ddlCATEGORY.SelectedValue   = model.BigCategory;
             txtCATEGORY.Text            = model.BigCategory;
             BindSmallCategory(model.BigCategory);
             ddlsmallcategory.SelectedValue = model.SmallCategory;
             txtsmallcategory.Text          = model.SmallCategory;
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuc", "executeconnectsur();", true);
         }
         catch
         {
             ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuc", "layer.alert('数据源连接不上!无法修改!');", true);
         }
         this.txtDBName.Text     = model.DBName;
         this.txtObjectType.Text = model.ObjectType;
         this.txtObjectName.Text = model.ObjectName;
         hidauthor.Value         = model.Author;
         hidcreated.Value        = model.Created.ToString();
     }
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CMICT.CSP.Model.BS_DATASOURCE GetModel(string temid)
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from BS_DATASOURCE ");
            strSql.Append("  where SourceID=(select SourceID from BS_TEMPLATE_MAIN where TemplateID='" + temid + "')");

            CMICT.CSP.Model.BS_DATASOURCE model = new CMICT.CSP.Model.BS_DATASOURCE();
            DataSet ds = dbhelper.ExecuteDataSet(CommandType.Text, strSql.ToString(), null);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        protected void ShowInfo(string sourceID)
        {
            BindBigCategory();
            if (!string.IsNullOrEmpty(sourceID))
            {
                BS_DATASOURCEBLL bll = new BS_DATASOURCEBLL();
                CMICT.CSP.Model.BS_DATASOURCE model = bll.GetModel(Guid.Parse(sourceID));
                if (model != null)
                {
                    hidOperType.Value = "edit";

                    ddlCATEGORY.SelectedValue = model.BigCategory;
                    BindSmallCategory(model.BigCategory);
                    ddlsmallcategory.SelectedValue = model.SmallCategory;
                    BindDataSource(model.BigCategory, model.SmallCategory);
                    ddlSourceName.SelectedValue = model.SourceID.ToString();
                    txtCATEGORY.Text            = model.BigCategory;
                    txtsmallcategory.Text       = model.SmallCategory;
                    txtSourceName.Text          = model.SourceName;
                }
            }
        }
Пример #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CMICT.CSP.Model.BS_DATASOURCE DataRowToModel(DataRow row)
 {
     CMICT.CSP.Model.BS_DATASOURCE model = new CMICT.CSP.Model.BS_DATASOURCE();
     if (row != null)
     {
         if (row["SourceID"] != null && row["SourceID"].ToString() != "")
         {
             model.SourceID = new Guid(row["SourceID"].ToString());
         }
         if (row["SourceName"] != null)
         {
             model.SourceName = row["SourceName"].ToString();
         }
         if (row["SourceDesc"] != null)
         {
             model.SourceDesc = row["SourceDesc"].ToString();
         }
         if (row["BigCategory"] != null)
         {
             model.BigCategory = row["BigCategory"].ToString();
         }
         if (row["SmallCategory"] != null)
         {
             model.SmallCategory = row["SmallCategory"].ToString();
         }
         if (row["SourceIP"] != null)
         {
             model.SourceIP = row["SourceIP"].ToString();
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["DBName"] != null)
         {
             model.DBName = row["DBName"].ToString();
         }
         if (row["ObjectType"] != null)
         {
             model.ObjectType = row["ObjectType"].ToString();
         }
         if (row["ObjectName"] != null)
         {
             model.ObjectName = row["ObjectName"].ToString();
         }
         if (row["SourceCNName"] != null)
         {
             model.SourceCNName = row["SourceCNName"].ToString();
         }
         if (row["SourceStatus"] != null)
         {
             model.SourceStatus = row["SourceStatus"].ToString();
         }
         if (row["Created"] != null && row["Created"].ToString() != "")
         {
             model.Created = DateTime.Parse(row["Created"].ToString());
         }
         if (row["Modified"] != null && row["Modified"].ToString() != "")
         {
             model.Modified = DateTime.Parse(row["Modified"].ToString());
         }
         if (row["Author"] != null)
         {
             model.Author = row["Author"].ToString();
         }
         if (row["Editor"] != null)
         {
             model.Editor = row["Editor"].ToString();
         }
     }
     return(model);
 }
Пример #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CMICT.CSP.Model.BS_DATASOURCE model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BS_DATASOURCE set ");
            strSql.Append("SourceID=@SourceID,");
            strSql.Append("SourceName=@SourceName,");
            strSql.Append("SourceDesc=@SourceDesc,");
            strSql.Append("BigCategory=@BigCategory,");
            strSql.Append("SmallCategory=@SmallCategory,");
            strSql.Append("SourceIP=@SourceIP,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Password=@Password,");
            strSql.Append("DBName=@DBName,");
            strSql.Append("ObjectType=@ObjectType,");
            strSql.Append("ObjectName=@ObjectName,");
            strSql.Append("SourceCNName=@SourceCNName,");
            strSql.Append("SourceStatus=@SourceStatus,");
            strSql.Append("Created=@Created,");
            strSql.Append("Modified=@Modified,");
            strSql.Append("Author=@Author,");
            strSql.Append("Editor=@Editor");
            strSql.Append(" where SourceID=@SourceID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SourceID",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@SourceName",    SqlDbType.NVarChar,          50),
                new SqlParameter("@SourceDesc",    SqlDbType.NVarChar,         200),
                new SqlParameter("@BigCategory",   SqlDbType.NVarChar,          50),
                new SqlParameter("@SmallCategory", SqlDbType.NVarChar,         200),
                new SqlParameter("@SourceIP",      SqlDbType.NVarChar,          50),
                new SqlParameter("@UserName",      SqlDbType.NVarChar,          50),
                new SqlParameter("@Password",      SqlDbType.NVarChar,          50),
                new SqlParameter("@DBName",        SqlDbType.NVarChar,          50),
                new SqlParameter("@ObjectType",    SqlDbType.NVarChar,          50),
                new SqlParameter("@ObjectName",    SqlDbType.NVarChar,          50),
                new SqlParameter("@SourceCNName",  SqlDbType.NVarChar,         200),
                new SqlParameter("@SourceStatus",  SqlDbType.NVarChar,          50),
                new SqlParameter("@Created",       SqlDbType.DateTime),
                new SqlParameter("@Modified",      SqlDbType.DateTime),
                new SqlParameter("@Author",        SqlDbType.NVarChar,          50),
                new SqlParameter("@Editor",        SqlDbType.NVarChar, 50)
            };
            parameters[0].Value  = model.SourceID;
            parameters[1].Value  = model.SourceName;
            parameters[2].Value  = model.SourceDesc;
            parameters[3].Value  = model.BigCategory;
            parameters[4].Value  = model.SmallCategory;
            parameters[5].Value  = model.SourceIP;
            parameters[6].Value  = model.UserName;
            parameters[7].Value  = model.Password;
            parameters[8].Value  = model.DBName;
            parameters[9].Value  = model.ObjectType;
            parameters[10].Value = model.ObjectName;
            parameters[11].Value = model.SourceCNName;
            parameters[12].Value = model.SourceStatus;
            parameters[13].Value = model.Created;
            parameters[14].Value = model.Modified;
            parameters[15].Value = model.Author;
            parameters[16].Value = model.Editor;

            int rows = dbhelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string tipcontent = string.Empty;
                if (!TestConn(out tipcontent))//如果连接失败
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "saveconntest", "layer.alert('连接测试失败" + tipcontent + "!',8);executeconnectsur();", true);
                    return;
                }
                string   SourceName   = this.txtSourceName.Value.Trim();
                string   SourceDesc   = this.txtSourceDesc.Value.Trim();
                string   SourceIP     = this.txtSourceIP.Value.Trim();
                string   UserName     = this.txtUserName.Value.Trim();
                string   Password     = this.txtPwd.Text.Trim();
                string   DBName       = this.txtDBName.Text.Trim();
                string   ObjectType   = this.txtObjectType.Text.Trim();
                string   ObjectName   = this.txtObjectName.Text.Trim();
                string   SourceStatus = "FREE";
                DateTime Created      = DateTime.Now;
                DateTime Modified     = DateTime.Now;
                string   Author       = GetCurrentUserLoginId();
                string   Editor       = GetCurrentUserLoginId();
                CMICT.CSP.BLL.BS_DATASOURCEBLL bll = new CMICT.CSP.BLL.BS_DATASOURCEBLL();
                string rsourceid = string.Empty;
                if (hidOperType.Value == "edit")
                {
                    rsourceid = Page.Request.QueryString["sourceID"];
                }
                if (bll.GetExists(SourceName, rsourceid))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourcenameexist", "layer.alert('已经存在此数据源名称:" + SourceName + "!请重新填写!',8);executeconnectsur();", true);
                    return;
                }

                CMICT.CSP.Model.BS_DATASOURCE model = new CMICT.CSP.Model.BS_DATASOURCE();
                model.SourceName    = SourceName;
                model.SourceDesc    = SourceDesc;
                model.SourceIP      = SourceIP;
                model.UserName      = UserName;
                model.Password      = Password;
                model.DBName        = DBName;
                model.ObjectType    = ObjectType;
                model.ObjectName    = ObjectName;
                model.SourceStatus  = SourceStatus;
                model.Created       = Created;
                model.Modified      = Modified;
                model.Author        = Author;
                model.Editor        = Editor;
                model.BigCategory   = txtCATEGORY.Text;
                model.SmallCategory = txtsmallcategory.Text;
                model.SourceCNName  = "";

                if (hidOperType.Value == "add")
                {
                    if (bll.Add(model))
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsuca", "layer.alert('数据源新增成功!',9);", true);
                        Page.Response.Redirect("DataSourceManage.aspx");
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connerrora", "layer.alert('数据源新增失败!',8);", true);
                    }
                }
                else//修改
                {
                    Guid SourceID = Guid.Parse(Page.Request.QueryString["sourceID"]);
                    CMICT.CSP.Model.BS_DATASOURCE oldmodel = bll.GetModel(SourceID);
                    model.SourceID     = SourceID;
                    model.Author       = hidauthor.Value;
                    model.Created      = DateTime.Parse(hidcreated.Value);
                    model.SourceStatus = hidSourceStatus.Value.Trim();
                    if (bll.Update(model))
                    {
                        //更新数据源后清空相应模板的配置信息
                        if (model.DBName != oldmodel.DBName || model.SourceIP != oldmodel.SourceIP || model.UserName != oldmodel.UserName || model.Password != oldmodel.Password || model.ObjectType != oldmodel.ObjectType || model.ObjectName != oldmodel.ObjectName)
                        {
                            ConnectionConfigComponent ccc = new ConnectionConfigComponent();
                            DataTable dstable             = ccc.GetTemplateIDBySourceID(SourceID);
                            if (dstable != null && dstable.Rows.Count > 0)
                            {
                                DisplayConfigComponent  dcbll = new DisplayConfigComponent();
                                QueryConfigComponent    qcbll = new QueryConfigComponent();
                                BusinessSearchComponent bsbll = new BusinessSearchComponent();
                                //删除通信配置
                                CommunicationConfigComponent cccbll = new CommunicationConfigComponent();
                                foreach (DataRow dr in dstable.Rows)
                                {
                                    dcbll.UpdateStatusByTemplateID(dr["TemplateID"].ToString(), "DRAFT");
                                    dcbll.DeleteTemInfoByTemplateID(dr["TemplateID"].ToString());
                                    qcbll.DeleteTemInfoByTemplateID(dr["TemplateID"].ToString());
                                    //取出所有与此模板有通信关联的源模板信息
                                    DataTable SourceTemList = cccbll.GetCommunicationBySourceTemplateID(dr["TemplateID"].ToString());
                                    cccbll.DeleteCommunicationByTemplateID(dr["TemplateID"].ToString());
                                    bsbll.RefreshTemplateByGuid(dr["TemplateID"].ToString());
                                    if (SourceTemList != null && SourceTemList.Rows.Count > 0)
                                    {
                                        foreach (DataRow drr in SourceTemList.Rows)
                                        {
                                            if (!string.IsNullOrEmpty(Convert.ToString(drr["TargetTemplateID"])))
                                            {
                                                bsbll.RefreshTemplateByGuid(Convert.ToString(drr["TargetTemplateID"]));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connsucad", "layer.alert('数据源修改成功!');", true);
                        Page.Response.Redirect("DataSourceManage.aspx");
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "connerrorae", "layer.alert('数据源修改失败!');", true);
                    }
                }
            }
            catch (Exception ee)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "saveerror", "layer.alert('" + ee.Message + "');", true);
            }
        }