示例#1
0
        public void Run()
        {
            Console.WriteLine("OAST - Projekt 2!\n Wpisz swój super wybór");
            int Choice = 0;

            while (true)
            {
                Console.WriteLine("1. Wykonaj optymalizację");
                Console.WriteLine("2. Zakończ proces");
                Choice = Convert.ToInt32(Console.ReadLine());
                if (Choice != 1 && Choice != 2)
                {
                    Console.WriteLine("Złą opcja");
                    continue;
                }
                else if (Choice == 2)
                {
                    Console.WriteLine("Zamykanie programu");
                    break;
                }
                else
                {
                    FillDataToAlgorithm();
                    Graph graph = Pars.ReadConfigFiles(FileChooser());

                    Result DAPResult = Algorithm.RunAlgorithm(graph, StartingPopulation, ProbabilityCrossOver, ProbabilityOfMutation, TimeGeneratorSeed, Condition, ConditionValue, Result.ResultType.DAP);
                    Pars.WriteResultToFile(DAPResult);

                    Result DDAPResult = Algorithm.RunAlgorithm(graph, StartingPopulation, ProbabilityCrossOver, ProbabilityOfMutation, TimeGeneratorSeed, Condition, ConditionValue, Result.ResultType.DDAP);
                    Pars.WriteResultToFile(DDAPResult);
                }
            }
        }
示例#2
0
        public LexExpr(string s)
        {
            var ss = s.Split(new[] { '!', '(', ',', ')' }, StringSplitOptions.RemoveEmptyEntries);

            Type     = ss[0];
            Code     = ss[1];
            DataType = ss[2].ToDataType();
            for (int i = 3; i < ss.Length; i++)
            {
                Pars.Add(ss[i]);
            }
        }
示例#3
0
        private void buttonEqual_MouseDown(object sender, MouseEventArgs e)
        {
            if (SplitersOperation.Contains(expression.Text.Last()))
            {
                expression.Font = new Font(expression.Font.FontFamily, 16.25f);
                expression.Text = "Неверный формат";
                DisableButtons();
                ErrorState = true;
            }
            else
            {
                ToComputeExprsion = PrepareStringToCompute(expression.Text);
                Console.WriteLine(ToComputeExprsion);
                Pars.Exp = ToComputeExprsion;
                try {
                    string temp = Pars.Compute();

                    if (temp.Contains("∞"))
                    {
                        expression.Font = new Font(expression.Font.FontFamily, 16.25f);
                        expression.Text = "Деление на ноль";
                        DisableButtons();
                        ErrorState = true;
                    }
                    else
                    {
                        Evalueted       = true;
                        temp            = Math.Round(double.Parse(temp), 10).ToString();
                        expression.Text = temp.Replace(',', '.');
                        switch (e.Button)
                        {
                        case MouseButtons.Right:
                            Memory.Text = expression.Text;
                            break;

                        case MouseButtons.Middle:
                            Clipboard.SetText(expression.Text);
                            break;
                        }
                    }
                }
                catch (Exception A) {
                    expression.Font = new Font(expression.Font.FontFamily, 16.25f);
                    expression.Text = A.Message;
                    DisableButtons();
                    ErrorState = true;
                }
            }
        }
示例#4
0
        private void loadParsControls()
        {
            Pars pars = configset.Pars;

            if (pars.ParList.Count > 0)
            {
                for (int i = 0; i < pars.ParList.Count; i++)
                {
                    Par    par    = pars.ParList[i];
                    parSet parset = new parSet();
                    parset.SetValue(par);
                    ParsSetControlAdd(parset);
                }
            }
        }
示例#5
0
 static void Main(string[] args)
 {
     Console.WriteLine("\nКомпилятор языка О");
     if (args.Length == 0)
     {
         Location.Path = null;
     }
     else
     {
         Location.Path = args[0];
     }
     Init();         // Инициализация
     Pars.Compile(); // Компиляция
     OVM.Run();      // Выполнение
     Done();         // Завершение
 }
示例#6
0
        private int FileChooser()
        {
            int theChoosenOne = 0;

            while (theChoosenOne <= 0 || theChoosenOne > Pars.Files.Count)
            {
                Console.WriteLine("Wybierz sieć do optymalizacji?");
                Pars.PrintFiles();
                try
                {
                    theChoosenOne = Convert.ToInt32(Console.ReadLine());
                }
                catch
                {
                    Console.WriteLine("Błąd - wybierz jeszcze raz");
                    theChoosenOne = 0;
                }
            }
            return(theChoosenOne - 1);
        }
示例#7
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);
            }
        }