protected void b_delete_Click(object sender, EventArgs e) { lb_updatesuccess.Text = ""; string bid = tb_Bid.Text.Trim(); if (bid != "") { try { string code = bid.Substring(0, 2); string business_id = bid.Substring(2, bid.Length - 2); SCDB odb = new SCDB(); bool success = odb.DeleteBusiness(code, business_id, user); //string filename = xml_BusinessConfig_Path + bid + ".xml"; if (success) { //删除文件 DeleteBFile(bid); FillWebPanel("-1"); ViewState["scModel"] = null; lb_updatesuccess.Text = bid + "删除成功!"; } } catch { lb_updatesuccess.Text = "删除失败!"; } } }
/// <summary> /// 从数据库中读取文件,填充业务种类ddl /// </summary> protected void FillDDLBusinessType() { SCDB scDB = new SCDB(); DataTable dt = scDB.GetSCTypeList(); ddl_SCType.DataSource = dt; ddl_SCType.DataBind(); }
/// <summary> /// 填充gridview /// </summary> /// <param name="code"></param> /// <param name="datatype"></param> protected void fillGVList(string code, string datatype) { SCDB scDB = new SCDB(); DataTable dt = new DataTable(); dt = scDB.GetSCListByCodeType(code, datatype); gvItem.DataSource = dt; gvItem.DataBind(); }
/// <summary> /// 填充gridview /// </summary> /// <param name="code"></param> /// <param name="datatype"></param> protected void fillGVListByBusinessID(string businessid) { SCDB scDB = new SCDB(); DataTable dt = new DataTable(); dt = scDB.GetOptByBusinessID(businessid); gvItem.DataSource = dt; gvItem.DataBind(); }
/// <summary> /// 填充gridview /// </summary> /// <param name="code"></param> /// <param name="datatype"></param> protected void fillGVList() { SCDB scDB = new SCDB(); DataTable dt = new DataTable(); dt = scDB.GetOptListAll(); gvItem.DataSource = dt; gvItem.DataBind(); }
/// <summary> /// 读取数据库,获取当前业务ID(5位) /// 读取数据库中该业务种类的最大值,如果有值,则+1 /// 如果为-1,则该业务ID赋值为10000 /// </summary> /// <param name="code"></param> /// <returns></returns> protected int currentBID(string code) { SCDB scDB = new SCDB(); int bussiness_id = scDB.GetMaxBID(code); if (bussiness_id == -1) { bussiness_id = 10000; } else { bussiness_id = bussiness_id + 1; } return(bussiness_id); }
protected void b_upload_Click(object sender, EventArgs e) { if (fu_serviceconfig.FileName != "") { int index = fu_serviceconfig.FileName.LastIndexOf('.'); if (fu_serviceconfig.FileName.Substring(0, index) == lb_BID.Text) { fu_serviceconfig.SaveAs(xml_BusinessConfig_Path + fu_serviceconfig.FileName); SCXML scXML = new SCXML(); SCModel scModel = scXML.GetSCModel(xml_BusinessConfig_Path, fu_serviceconfig.FileName); bool dbsave = false; SCDB scDB = new SCDB(); //采集数据 if (scModel.DataSourceType == "0") { User user = new Class.User(); dbsave = scDB.InsertSCCollectionModel(scModel, user); } //监控数据 else { dbsave = scDB.InsertSCNotifyModel(scModel, user); } if (dbsave) { Label1.Text = "上传成功!"; } } else { Label1.Text = "文件名须与业务ID一致!"; } } else { Label1.Text = "请选择需上传的业务配置文件!"; } }
/// <summary> /// 保存按钮 /// 真正与数据库进行交互 /// 保存至数据库,事务提交,更改两个表,业务表和环节表 /// 生成XML /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void b_Save_Click(object sender, EventArgs e) { try { scModel = ViewState["scModel"] as SCModel; bool dbsave = false; //采集数据 if (scModel.DataSourceType == "0") { SCCollectionXML sccxml = new SCCollectionXML(); sccxml.CreateXML(scModel, xml_BusinessConfig_Path);// "d:/template/" SCDB scDB = new SCDB(); dbsave = scDB.InsertSCCollectionModel(scModel, user); } //监控数据 else if (scModel.DataSourceType == "1") { SCNotifyXML scnxml = new SCNotifyXML(); scnxml.CreateXML(scModel, xml_BusinessConfig_Path); // "d:/template/" SCDB scDB = new SCDB(); dbsave = scDB.InsertSCNotifyModel(scModel, user); } //外部数据 else { SCOuterXML scoxml = new SCOuterXML(); scoxml.CreateXML(scModel, xml_BusinessConfig_Path); // "d:/template/" SCDB scDB = new SCDB(); dbsave = scDB.InsertSCOuterModel(scModel, user); } //判断是否成功,跳转页面 string filesave = xml_BusinessConfig_Path + scModel.ServiceInfo.ServiceID + ".xml"; if (dbsave && File.Exists(filesave)) { Response.Write("<script language=javascript>alert('业务保存成功!');window.location='/ServiceConfig/SCAdd.aspx'</script>"); } else { Response.Write("<script language=javascript>alert('业务保存失败!');window.location='/ServiceConfig/SCAdd.aspx'</script>"); } //Cache.Remove("businessid"); //Response.Redirect("/ServiceConfig/SCAdd.aspx"); ////Disable Link 环节 //EnabledLinkTB(false); //ResetLinkTB(""); ////Enable ServiceInfo和DataSource 环节 //EnabledSITB(true); } catch (Exception ex) { Server.Transfer("/Error.aspx"); Server.ClearError(); } }
/// <summary> /// 数据库信息提取 /// </summary> /// <param name="code">code</param> /// <param name="business_id">业务id</param> protected void GetSCDetail(string code, string business_id) { //SCModel scModel = new SCModel(); SCDB odb = new SCDB(); DataTable dt_businesstype = new DataTable(); dt_businesstype = odb.GetBTNameByBusinessCode(code); DataTable dt_business = new DataTable(); dt_business = odb.GetSCDetailByBusinessCode(code, business_id); if (dt_business != null && dt_business.Rows.Count == 1) { ServiceInfo si = new ServiceInfo(); si.GetServiceInfoFromDT(dt_business); si.ServiceTypeName = dt_businesstype.Rows[0][1].ToString(); scModel.ServiceInfo = si; scModel.DataSourceType = dt_business.Rows[0][3].ToString(); if (scModel.DataSourceType == "0") { DataSourceCollection dsc = new DataSourceCollection(); dsc.GetDataSourceFromDT(dt_business); scModel.DataSource = dsc; scModel.DataSourceName = "采集"; } else if (scModel.DataSourceType == "1") { DataSourceNotify dsn = new DataSourceNotify(); dsn.GetDataSourceFromDT(dt_business); scModel.DataSource = dsn; scModel.DataSourceName = "监控"; } else { DataSourceOuter dso = new DataSourceOuter(); dso.GetDataSourceFromDT(dt_business); scModel.DataSource = dso; scModel.DataSourceName = "外部"; } } DataTable dt_links = new DataTable(); dt_links = odb.GetSCLinksByServiceID(code, business_id); List <SCLink> scList = new List <SCLink>(); for (int i = 0; i < dt_links.Rows.Count; i++) { SCLink scLink = new SCLink(); scLink.LinkID = dt_links.Rows[i][0].ToString(); scLink.Description = dt_links.Rows[i][1].ToString(); scLink.Order = dt_links.Rows[i][2].ToString(); scLink.TopicLink = dt_links.Rows[i][3].ToString(); scLink.NextLinks = scLink.ChangeToTopicLinkList(); //变成list,以便生成xml scList.Add(scLink); } scModel.SCLinks = scList; //return scModel; }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void b_Save_Click(object sender, EventArgs e) { scModel = ViewState["scModel"] as SCModel; ServiceInfo si = new ServiceInfo(); si.ServiceName = tb_ServiceName.Text.Trim(); si.ServiceID = scModel.ServiceInfo.ServiceID; si.ServiceType = scModel.ServiceInfo.ServiceID.Substring(0, 2); //上游业务ID si.SourceID = tb_SourceID.Text.Trim(); //所属业务群 string servicegroup = ""; string sort = ""; for (int i = 0; i < chkblServiceGroup.Items.Count; i++) { if (chkblServiceGroup.Items[i].Selected) { sort = i.ToString(); if (i < 10) { sort = "0" + sort; } servicegroup = servicegroup + sort + ","; } } if (servicegroup.Length > 0) { servicegroup = servicegroup.Substring(0, servicegroup.LastIndexOf(',')); } si.ServiceGroup = servicegroup; scModel.ServiceInfo = si; //采集类数据源 if (scModel.DataSourceType == "0") { //scModel.DataSourceType = scModel.DataSourceType; DataSourceCollection dsc = new DataSourceCollection(); //dsc.DataSourceType = ddl_Data_Type.SelectedValue; //采集,则存0 dsc.CollectionDescription = tb_DataSourceDescription.Text.Trim(); dsc.StartTimeValue = tb_Des_1.Text.Trim(); dsc.PeriodValue = tb_Des_2.Text.Trim(); dsc.StartTimeDescription = s_StartTime_Tip; //"hh:mm:ss"; dsc.PeriodDescription = s_PeriodTime_Tip; // "second,0s means just once"; scModel.DataSource = dsc; } //监控类数据源 else if (scModel.DataSourceType == "1") { //scModel.DataSourceType = scModel.DataSourceType; DataSourceNotify dsn = new DataSourceNotify(); //dsn.DataSourceType = ddl_Data_Type.SelectedValue;//监控,则存1 dsn.NotifyDescription = tb_DataSourceDescription.Text.Trim(); dsn.PathsValue = tb_Des_1.Text.Trim(); dsn.FilesValue = tb_Des_2.Text.Trim(); dsn.PathDescription = s_FileDir_Tip; //"要监控的文件目录"; dsn.FilesDescription = s_File_Tip; // "需要的数据源文件,可用${yyyyMMddHH}时间通配符"; //20160308 syy 增加多目录,多文件,用;隔开,有空,用null表示; dsn.GetPathFileMateFromString(dsn.PathsValue, dsn.FilesValue, dsn.PathDescription, dsn.FilesDescription); //20160308 syy scModel.DataSource = dsn; } //外部类数据源 else if (scModel.DataSourceType == "2") { DataSourceOuter dso = new DataSourceOuter(); //dsn.DataSourceType = ddl_Data_Type.SelectedValue;//监控,则存1 dso.OuterDescription = tb_DataSourceDescription.Text.Trim(); dso.OuterPathValue = tb_Des_1.Text.Trim(); dso.OuterFileValue = tb_Des_2.Text.Trim(); dso.OuterPathDes = s_FileDir_Tip; //"要监控的文件目录"; dso.OuterFileDes = s_File_Tip; // "需要的数据源文件,可用${yyyyMMddHH}时间通配符"; //20160308 syy 增加多目录,多文件,用;隔开,有空,用null表示; //dso.GetPathFileMateFromString(dso.PathsValue, dso.FilesValue, dso.PathDescription, dso.FilesDescription); //20160308 syy scModel.DataSource = dso; } bool dbsave = false; //采集数据 if (scModel.DataSourceType == "0") { SCDB scDB = new SCDB(); dbsave = scDB.UpdateSCCollectionModel(scModel, user); SCCollectionXML sccxml = new SCCollectionXML(); sccxml.CreateXML(scModel, xml_BusinessConfig_Path);// "d:/template/" } //监控数据 else if (scModel.DataSourceType == "1") { SCDB scDB = new SCDB(); dbsave = scDB.UpdateSCNotifyModel(scModel, user); SCNotifyXML scnxml = new SCNotifyXML(); scnxml.CreateXML(scModel, xml_BusinessConfig_Path); // "d:/template/" } //外部数据 else if (scModel.DataSourceType == "2") { SCDB scDB = new SCDB(); dbsave = scDB.UpdateSCOuterModel(scModel, user); SCOuterXML scnxml = new SCOuterXML(); scnxml.CreateXML(scModel, xml_BusinessConfig_Path); // "d:/template/" } //判断是否成功,跳转页面 string filesave = xml_BusinessConfig_Path + scModel.ServiceInfo.ServiceID + ".xml"; if (dbsave && File.Exists(filesave)) { lb_updatesuccess.Text = "业务更新成功!"; } else { lb_updatesuccess.Text = "业务更新失败!"; } }