コード例 #1
0
 protected bool BindObjectName()
 {
     try
     {
         bool   result     = false;
         string SourceIP   = txtSourceIP.Value.Trim();
         string UserName   = txtUserName.Value.Trim();
         string Pwd        = txtPwd.Text.Trim();
         string DBName     = ddlDBName.SelectedValue;
         string ObjectType = ddlObjectType.SelectedValue;
         if (!string.IsNullOrEmpty(ObjectType) && !string.IsNullOrEmpty(DBName))
         {
             ddlObjectName.Items.Clear();
             ConnectionConfigComponent ccc = new ConnectionConfigComponent(SourceIP, UserName, Pwd, DBName);
             DataTable dt = ccc.GetDataListByDataType(ObjectType);
             ddlObjectName.DataSource     = dt;
             ddlObjectName.DataTextField  = "namedesc";
             ddlObjectName.DataValueField = "name";
             ddlObjectName.DataBind();
             ddlObjectName.Items.Insert(0, new ListItem("请选择", ""));
             result = true;
         }
         return(result);
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
        protected bool BindDbName(int contype = 0)
        {
            string SourceIP = txtSourceIP.Value.Trim();
            string UserName = txtUserName.Value.Trim();
            string Pwd      = txtPwd.Text.Trim();
            bool   result   = false;
            ConnectionConfigComponent ccc = new ConnectionConfigComponent(SourceIP, UserName, Pwd);

            if (ccc.CheckConnect())//如果连接成功
            {
                //绑定数据源下所有数据库
                DataTable dbtable = ccc.GetAllDBOnDataSource();
                ddlDBName.DataSource     = dbtable;
                ddlDBName.DataTextField  = "namedesc";
                ddlDBName.DataValueField = "name";
                ddlDBName.DataBind();
                ddlDBName.Items.Insert(0, new ListItem("请选择", ""));
                txtDBName.Text      = "";
                txtSourceName.Value = "";
                //ddlObjectType.SelectedValue = "";
                //txtObjectType.Text = "";
                ddlObjectName.Items.Clear();
                ddlObjectName.Items.Insert(0, new ListItem("请选择", ""));
                txtObjectName.Text        = "";
                ddlCATEGORY.SelectedValue = "";
                txtCATEGORY.Text          = "";
                ddlsmallcategory.Items.Clear();
                ddlsmallcategory.Items.Insert(0, new ListItem("请选择", ""));
                txtsmallcategory.Text = "";
                txtSourceDesc.Value   = "";
                result = true;
            }
            return(result);
        }
コード例 #3
0
        //测试是否连接通过
        protected bool TestConn(out string alertstr, int ctype = 0)
        {
            alertstr = "";
            string SourceIP = txtSourceIP.Value.Trim();
            string UserName = txtUserName.Value.Trim();
            string Pwd      = txtPwd.Text.Trim();
            string DbName   = txtDBName.Text.Trim();
            bool   result   = false;
            ConnectionConfigComponent ccc = new ConnectionConfigComponent(SourceIP, UserName, Pwd);

            if (ccc.CheckConnect())//如果连接成功
            {
                DataTable dbtable = null;
                if (ctype == 1)
                {
                    dbtable = ccc.GetAllDBOnDataSource();
                    //绑定数据源下所有数据库
                    ddlDBName.DataSource     = dbtable;
                    ddlDBName.DataTextField  = "namedesc";
                    ddlDBName.DataValueField = "name";
                    ddlDBName.DataBind();
                    ddlDBName.Items.Insert(0, new ListItem("请选择", ""));
                }
                else//检查数据库与库中内容是否存在
                {
                    dbtable = ccc.GetAllDBOnDataSource(DbName);
                    if (dbtable != null && dbtable.Rows.Count > 0)
                    {
                        string ObjectType = ddlObjectType.SelectedValue;
                        string objname    = ddlObjectName.SelectedValue;
                        ConnectionConfigComponent ccctestobj = new ConnectionConfigComponent(SourceIP, UserName, Pwd, DbName);
                        DataTable dt = ccctestobj.GetDataListByDataType(ObjectType, objname);
                        if (dt != null && dt.Rows.Count > 0)//首先检查对象名是否存在
                        {
                            string checkresult = ccctestobj.CheckCanExecute(ObjectType, objname).Trim();
                            if (string.IsNullOrEmpty(checkresult))
                            {
                                result = true;
                            }
                            else
                            {
                                alertstr = ":" + checkresult.Replace("'", "").Replace("\"", "");
                            }
                        }
                    }
                }
            }

            return(result);
        }
コード例 #4
0
        public string CheckSourceName(HttpContext context)
        {
            string result     = "false";
            string SourceName = context.Server.UrlDecode(context.Request["SourceName"]);
            string SourceID   = context.Request["SourceID"];

            if (!string.IsNullOrEmpty(SourceName))
            {
                ConnectionConfigComponent tc = new ConnectionConfigComponent();
                if (tc.GetSourceNameIsExists(SourceName, SourceID))
                {
                    result = "true";
                }
            }
            return(result);
        }
コード例 #5
0
        //数据源ip智能匹配
        protected void MatchSourceIP()
        {
            StringBuilder             matchvar = new StringBuilder();
            ConnectionConfigComponent ccc      = new ConnectionConfigComponent();
            DataTable dt = ccc.GetDataSourceIpList();

            if (dt != null && dt.Rows.Count > 0)
            {
                matchvar.Append("strlist_ip=[");
                string listc = string.Empty;
                foreach (DataRow dr in dt.Rows)
                {
                    listc += "'" + dr["sourceip"].ToString() + "',";
                }
                listc = listc.TrimEnd(',');
                matchvar.Append(listc.ToString() + "];");
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "matchip", matchvar.ToString(), true);
            }
        }
コード例 #6
0
 //删除
 protected void lbtndel_Click(object sender, EventArgs e)
 {
     try
     {
         string TemplateID = hidtemplateid.Value.Trim();
         string SourceID   = hidsourceid.Value.Trim();
         if (!string.IsNullOrEmpty(TemplateID))
         {
             //删除通信配置
             CommunicationConfigComponent cccbll = new CommunicationConfigComponent();
             cccbll.DeleteCommunicationByTemplateID(TemplateID);
             if (tmbll.DelTemplateInfo(TemplateID))
             {
                 hidtemplateid.Value = "";
                 if (!string.IsNullOrEmpty(SourceID))
                 {
                     //删除后查询原数据源是否还有被其它模板引用,没有则更新状态为空闲
                     ConnectionConfigComponent ccc = new ConnectionConfigComponent();
                     DataTable dstable             = ccc.GetTemplateIDBySourceID(Guid.Parse(SourceID));
                     if (dstable == null || dstable.Rows.Count == 0)
                     {
                         DataSourceConfigComponent dbll = new DataSourceConfigComponent();
                         dbll.UpdateSourceStatusBySourceID(hidsourceid.Value.Trim());
                     }
                 }
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sdel", "layer.alert('模板删除成功!',9);", true);
                 BindTemplateList();
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sdel", "layer.alert('模板删除失败!',8);", true);
             }
         }
     }
     catch (Exception ee)
     {
         BaseComponent.Error(ee.Message);
     }
 }
コード例 #7
0
        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            string edit = string.Empty;

            if (!string.IsNullOrEmpty(Page.Request.QueryString["type"]))
            {
                edit = "&type=edit";
            }
            try
            {
                string TemplateID = Page.Request.QueryString["templateID"];
                string SourceID   = ddlSourceName.SelectedValue;
                if (hidsourceid.Value.Trim() != SourceID.Trim())//修改数据源后删除显示与查询配置信息
                {
                    if (!string.IsNullOrEmpty(TemplateID))
                    {
                        if (dbll.OperConfigDataSource(TemplateID, SourceID))
                        {
                            if (!string.IsNullOrEmpty(hidsourceid.Value.Trim()))
                            {
                                //更新后查询原数据源是否还有被其它模板引用,没有则更新状态为草稿
                                ConnectionConfigComponent ccc = new ConnectionConfigComponent();
                                DataTable dstable             = ccc.GetTemplateIDBySourceID(Guid.Parse(hidsourceid.Value.Trim()));
                                if (dstable == null || dstable.Rows.Count == 0)
                                {
                                    dbll.UpdateSourceStatusBySourceID(hidsourceid.Value.Trim());
                                }
                            }
                            DisplayConfigComponent dcbll = new DisplayConfigComponent();
                            dcbll.DeleteTemInfoByTemplateID(TemplateID);
                            dcbll.UpdateStatusByTemplateID(TemplateID, "DRAFT");

                            QueryConfigComponent qcbll = new QueryConfigComponent();
                            qcbll.DeleteTemInfoByTemplateID(TemplateID);
                            CommunicationConfigComponent cccbll = new CommunicationConfigComponent();
                            //取出所有与此模板有通信关联的源模板信息
                            DataTable SourceTemList = cccbll.GetCommunicationBySourceTemplateID(TemplateID);
                            //删除通信配置
                            cccbll.DeleteCommunicationByTemplateID(TemplateID);
                            //刷新模板缓存
                            BusinessSearchComponent bsbll = new BusinessSearchComponent();
                            //bsbll.RefreshTemplateByGuid(TemplateID);
                            bsbll.RemoveTemplateByGuid(TemplateID);
                            if (SourceTemList != null && SourceTemList.Rows.Count > 0)
                            {
                                foreach (DataRow dr in SourceTemList.Rows)
                                {
                                    if (!string.IsNullOrEmpty(Convert.ToString(dr["TargetTemplateID"])))
                                    {
                                        bsbll.RemoveTemplateByGuid(Convert.ToString(dr["TargetTemplateID"]));
                                    }
                                }
                            }

                            Page.Response.Redirect("DisplayConfig.aspx?templateID=" + TemplateID + "&sourceID=" + SourceID + edit + "");
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourceerror", "layer.alert('数据源配置失败!',8);", true);
                        }
                    }
                }
                else
                {
                    Page.Response.Redirect("DisplayConfig.aspx?templateID=" + TemplateID + "&sourceID=" + SourceID + edit + "");
                }
            }
            catch (Exception ex)
            {
                BaseComponent.Error("DataSourceConfig-lbtnSave_Click:" + ex.Message);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "sourceerrorex", "layer.alert('数据源配置失败!',8);", true);
            }
        }
コード例 #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);
            }
        }