Esempio n. 1
0
        private void loadDbInit()
        {
            Db db = configset.Db;

            List <Control> dbCtlsList = new List <Control>();

            //设置数据主目录
            impdataFolder impdatafolder = new impdataFolder();

            impdatafolder.SetValue(db);
            DbInitControlAdd(impdatafolder);

            //设置普通用户初始化

            if (db.DbUserList.Count > 0)
            {
                for (int i = 0; i < db.DbUserList.Count; i++)
                {
                    DbUser    dbuser    = db.DbUserList[i];
                    dmpChoose dmpchoose = new dmpChoose();
                    dmpchoose.SetValue(dbuser);
                    DbInitControlAdd(dmpchoose);
                    dbCtlsList.Add(dmpchoose);
                }
            }


            //设置sde用户初始化
            if (db.DbSdeUserList.Count > 0)
            {
                for (int i = 0; i < db.DbSdeUserList.Count; i++)
                {
                    DbSdeUser dbsdeuser = db.DbSdeUserList[i];
                    gdbChoose gdbchoose = new gdbChoose();
                    gdbchoose.SetValue(dbsdeuser);
                    DbInitControlAdd(gdbchoose);
                    dbCtlsList.Add(gdbchoose);
                }

                sdeCoordinateSystemSet sdecss = new sdeCoordinateSystemSet();
                sdecss.CS_TYPE = db.CS_TYPE;
                sdecss.WKID    = db.WKID;
                sdecss.Prjpath = db.Prjpath;
                DbInitControlAdd(sdecss);
                dbCtlsList.Add(sdecss);
            }

            dbInit dbinit = new dbInit();

            dbinit.dbControlList = dbCtlsList;
            dbinit.SetButtons(db);
            dbinit.ConfigName = configName;
            DbInitControlAdd(dbinit);
        }
Esempio n. 2
0
        private void btnSaveConfig_Click(object sender, EventArgs e)
        {
            if (allControl.Count > 0)
            {
                #region  序
                Control    mfctl = allControl.Find((Control ctl) => (ctl is mainFolder));
                Apps       apps  = new Apps();
                mainFolder mf    = mfctl as mainFolder;
                apps.Name  = mf.Name;
                apps.Label = mf.Label;
                apps.Path  = mf.FolderPath;


                //-- 服务
                List <ServiceApp> serviceapps = new List <ServiceApp>();
                List <Control>    servicesctl = allControl.FindAll((Control ctl) => (ctl is serviceSet));
                if (servicesctl != null && servicesctl.Count > 0)
                {
                    foreach (Control ctl in servicesctl)
                    {
                        serviceSet serviceset = ctl as serviceSet;
                        ServiceApp serviceapp = new ServiceApp();
                        serviceapp.Name         = serviceset.Name;
                        serviceapp.Label        = serviceset.Label;
                        serviceapp.Path         = serviceset.FolderPath;
                        serviceapp.ConfigFolder = serviceset.ConfigFolder;
                        serviceapp.Ip           = serviceset.Ip;
                        serviceapp.Port         = serviceset.Port;

                        ServiceApp oldServiceapp = configset.Apps.ServiceAppList.Find((ServiceApp sa) => sa.Name == serviceset.Name);
                        serviceapp.Relativepath = oldServiceapp.Relativepath;
                        serviceapp.Servicename  = oldServiceapp.Servicename;
                        serviceapp.Installbat   = oldServiceapp.Installbat;
                        serviceapp.Removebat    = oldServiceapp.Removebat;
                        serviceapps.Add(serviceapp);
                    }
                }
                apps.ServiceAppList = serviceapps;
                //-- 网站
                List <WebApp>  webapps    = new List <WebApp>();
                List <Control> webappsctl = allControl.FindAll((Control ctl) => (ctl is webSiteSet));
                if (webappsctl != null && webappsctl.Count > 0)
                {
                    foreach (Control ctl in webappsctl)
                    {
                        webSiteSet websiteset = ctl as webSiteSet;
                        WebApp     webapp     = new WebApp();
                        webapp.Name         = websiteset.Name;
                        webapp.Label        = websiteset.Label;
                        webapp.Path         = websiteset.FolderPath;
                        webapp.ConfigFolder = websiteset.ConfigFolder;
                        webapp.SiteName     = websiteset.SiteName;
                        webapp.Ip           = websiteset.Ip;
                        webapp.Port         = websiteset.Port;
                        webapp.X86bit       = websiteset.X86bit;

                        WebApp oldWebapp = configset.Apps.WebAppList.Find((WebApp sa) => sa.Name == websiteset.Name);
                        webapp.Relativepath = oldWebapp.Relativepath;

                        webapp.VirtualDirList = websiteset.VirtualDirList;

                        webapps.Add(webapp);
                    }
                }
                apps.WebAppList = webapps;

                //--程序
                List <App>     appList = new List <App>();
                List <Control> appsctl = allControl.FindAll((Control ctl) => (ctl is appFolder));
                if (appsctl != null && appsctl.Count > 0)
                {
                    foreach (Control ctl in appsctl)
                    {
                        appFolder appfolder = ctl as appFolder;
                        App       app       = new App();
                        app.Name         = appfolder.Name;
                        app.Label        = appfolder.Label;
                        app.Path         = appfolder.FolderPath;
                        app.ConfigFolder = appfolder.ConfigFolder;

                        App oldApp = configset.Apps.AppList.Find((App sa) => sa.Name == appfolder.Name);
                        app.Relativepath = oldApp.Relativepath;

                        appList.Add(app);
                    }
                }
                apps.AppList = appList;

                //--ftp站点
                List <Ftp>     ftpList = new List <Ftp>();
                List <Control> ftpsctl = allControl.FindAll((Control ctl) => (ctl is ftpSiteSet));
                if (ftpsctl != null && ftpsctl.Count > 0)
                {
                    foreach (Control ctl in ftpsctl)
                    {
                        ftpSiteSet ftpsiteset = ctl as ftpSiteSet;
                        Ftp        ftp        = new Ftp();
                        ftp.Name     = ftpsiteset.Name;
                        ftp.Label    = ftpsiteset.Label;
                        ftp.Path     = ftpsiteset.FolderPath;
                        ftp.Ip       = ftpsiteset.Ip;
                        ftp.User     = ftpsiteset.User;
                        ftp.Password = ftpsiteset.Password;

                        Ftp oldFtp = configset.Apps.FtpList.Find((Ftp sa) => sa.Name == ftpsiteset.Name);
                        ftp.Relativepath = oldFtp.Relativepath;

                        ftpList.Add(ftp);
                    }
                }
                apps.FtpList = ftpList;

                //--共享目录
                List <Gxml>    gxmlList = new List <Gxml>();
                List <Control> gxmlsctl = allControl.FindAll((Control ctl) => (ctl is gxmlSet));
                if (gxmlsctl != null && gxmlsctl.Count > 0)
                {
                    foreach (Control ctl in gxmlsctl)
                    {
                        gxmlSet gxmlset = ctl as gxmlSet;
                        Gxml    gxml    = new Gxml();
                        gxml.Name     = gxmlset.Name;
                        gxml.Label    = gxmlset.Label;
                        gxml.Path     = gxmlset.FolderPath;
                        gxml.Ip       = gxmlset.Ip;
                        gxml.User     = gxmlset.User;
                        gxml.Password = gxmlset.Password;

                        Gxml oldGxml = configset.Apps.GxmlList.Find((Gxml sa) => sa.Name == gxmlset.Name);
                        gxml.Relativepath = oldGxml.Relativepath;

                        gxmlList.Add(gxml);
                    }
                }
                apps.GxmlList = gxmlList;
                #endregion


                #region 数据
                Control       datasourcectl = allControl.Find((Control ctl) => (ctl is dbSet));
                Control       dataimpctl    = allControl.Find((Control ctl) => (ctl is impdataFolder));
                dbSet         dbset         = datasourcectl as dbSet;
                impdataFolder impdatafolder = dataimpctl as impdataFolder;
                Db            db            = new Db();
                db.Name            = dbset.Name;
                db.Label           = impdatafolder.Label;
                db.Ip              = dbset.Ip;
                db.Datasource      = dbset.Datasource;
                db.Datafolder_type = dbset.DataFolder_type;
                db.Datafolder      = dbset.DataFolder;
                db.Relativepath    = configset.Db.Relativepath;

                Control scs = allControl.Find((Control ctl) => (ctl is sdeCoordinateSystemSet));
                if (scs != null)
                {
                    db.CS_TYPE = ((sdeCoordinateSystemSet)scs).CS_TYPE;
                    db.WKID    = ((sdeCoordinateSystemSet)scs).WKID;
                    db.Prjpath = ((sdeCoordinateSystemSet)scs).Prjpath;
                }
                else
                {
                    db.CS_TYPE = "";
                    db.WKID    = "";
                    db.Prjpath = "";
                }

                db.Impfolder = impdatafolder.FolderPath;

                //-- system用户
                Control         systemuserctl   = allControl.Find((Control ctl) => (ctl is dbSystemuserSet));
                dbSystemuserSet dbsystemuserset = systemuserctl as dbSystemuserSet;
                DbSystemUser    dbsystemuser    = new DbSystemUser();
                dbsystemuser.Name     = dbsystemuserset.Name;
                dbsystemuser.Label    = dbsystemuserset.Label;
                dbsystemuser.User     = dbsystemuserset.User;
                dbsystemuser.Password = dbsystemuserset.Password;

                db.DbSystemUser = dbsystemuser;
                //-- 普通用户
                List <DbUser>  dbuserList = new List <DbUser>();
                List <Control> dbusersctl = allControl.FindAll((Control ctl) => (ctl is dbUserSet));
                if (dbusersctl != null && dbusersctl.Count > 0)
                {
                    foreach (Control ctl in dbusersctl)
                    {
                        dbUserSet dbuserset = ctl as dbUserSet;
                        DbUser    dbuser    = new DbUser();
                        dbuser.Name       = dbuserset.Name;
                        dbuser.Label      = dbuserset.Label;
                        dbuser.Tablespace = dbuserset.Tablespace;
                        dbuser.User       = dbuserset.User;
                        dbuser.Password   = dbuserset.Password;

                        Control   dmpchoosectl = allControl.Find((Control cc) => (cc is dmpChoose) && ((cc as dmpChoose).Name == dbuserset.Name));
                        dmpChoose dmpchoose    = dmpchoosectl as dmpChoose;
                        dbuser.Dmpfile = dmpchoose.FilePath;

                        DbUser oldDbuser = configset.Db.DbUserList.Find((DbUser sa) => sa.Name == dbuserset.Name);
                        dbuser.Relativepath = oldDbuser.Relativepath;

                        dbuserList.Add(dbuser);
                    }
                }
                db.DbUserList = dbuserList;
                //-- sde 用户
                List <DbSdeUser> dbsdeuserList = new List <DbSdeUser>();
                List <Control>   dbsdeusersctl = allControl.FindAll((Control ctl) => (ctl is dbSdeUserSet));
                if (dbsdeusersctl != null && dbsdeusersctl.Count > 0)
                {
                    foreach (Control ctl in dbsdeusersctl)
                    {
                        dbSdeUserSet dbsdeuserset = ctl as dbSdeUserSet;
                        DbSdeUser    dbsdeuser    = new DbSdeUser();
                        dbsdeuser.Name       = dbsdeuserset.Name;
                        dbsdeuser.Label      = dbsdeuserset.Label;
                        dbsdeuser.Tablespace = dbsdeuserset.Tablespace;
                        dbsdeuser.User       = dbsdeuserset.User;
                        dbsdeuser.Password   = dbsdeuserset.Password;
                        Control   gdbchoosectl = allControl.Find((Control cc) => (cc is gdbChoose) && ((cc as gdbChoose).Name == dbsdeuserset.Name));
                        gdbChoose gdbchoose    = gdbchoosectl as gdbChoose;
                        dbsdeuser.Gdbfile = gdbchoose.FolderPath;

                        DbSdeUser oldDbsdeuser = configset.Db.DbSdeUserList.Find((DbSdeUser sa) => sa.Name == dbsdeuserset.Name);
                        dbsdeuser.Relativepath = oldDbsdeuser.Relativepath;

                        dbsdeuserList.Add(dbsdeuser);
                    }
                }
                db.DbSdeUserList = dbsdeuserList;
                #endregion
                #region 参数
                Pars           pars    = new Pars();
                List <Par>     parList = new List <Par>();
                List <Control> parsctl = allControl.FindAll((Control ctl) => (ctl is parSet));
                if (parsctl != null && parsctl.Count > 0)
                {
                    foreach (Control ctl in parsctl)
                    {
                        parSet parset = ctl as parSet;
                        Par    par    = new Par();
                        par.Key   = parset.Key;
                        par.Label = parset.Label;
                        par.Value = parset.Value;

                        parList.Add(par);
                    }
                }
                pars.ParList = parList;
                #endregion

                #region 工具
                Definebtns definebtns = new Definebtns();


                List <Btn>     btnList = new List <Btn>();
                List <Control> btnsctl = allControl.FindAll((Control ctl) => (ctl is btnSet));
                if (btnsctl != null && btnsctl.Count > 0)
                {
                    foreach (Control ctl in btnsctl)
                    {
                        btnSet btnset = ctl as btnSet;
                        Btn    btn    = new Btn();
                        btn = btnset.btn;
                        btnList.Add(btn);
                    }
                }

                definebtns.BtnList = btnList;



                #endregion


                #region 备份
                Backup           backup              = new Backup();
                Control          backupfolderctl     = allControl.Find((Control ctl) => (ctl is backupFolder));
                backupFolder     backupfolder        = backupfolderctl as backupFolder;
                Control          backupcontentsetctl = allControl.Find((Control ctl) => (ctl is backupContentSet));
                backupContentSet backupcontentset    = backupcontentsetctl as backupContentSet;
                Control          backupsetctl        = allControl.Find((Control ctl) => (ctl is backupSet));
                backupSet        backupset           = backupsetctl as backupSet;

                backup.Name           = backupfolder.Name;
                backup.Label          = backupfolder.Label;
                backup.Content        = backupcontentset.BackupContent;
                backup.Path           = backupfolder.BackupFolderPath;
                backup.Type           = backupset.Type;
                backup.Type_daytime   = backupset.Type_daytime;
                backup.Type_week      = backupset.Type_week;
                backup.Type_weektime  = backupset.Type_weektime;
                backup.Type_month     = backupset.Type_month;
                backup.Type_monthtime = backupset.Type_monthtime;


                #endregion


                //保存成Set
                configset.Apps       = apps;
                configset.Db         = db;
                configset.Pars       = pars;
                configset.Definebtns = definebtns;
                configset.Backup     = backup;
                saveConfig();

                setMessage.MessageShow("", "保存成功!", this.btnSaveConfig);
            }
        }