Beispiel #1
0
        /// <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();
            }
        }
Beispiel #2
0
        /// <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 = "业务更新失败!";
            }
        }