public static bool HasMissingPackages()
    {
        bool missing = false;
        var  script  = Path.Combine(NDA_Path, "check_for_missing_packages.py");
        var  args    = new string[] {
            script,
            Path.Combine(NDA_Path, "requirements.txt")
        };

        currActiveProcess = new CustomProcess(PythonInterpreter, args);

        currActiveProcess.OnFinished += (_, e) =>
        {
            //string line;
            if (!currActiveProcess.Output.EndOfStream)
            {
                Debug.Log(currActiveProcess.Output.ReadToEnd());
                //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
            }

            if (!currActiveProcess.Errors.EndOfStream)
            {
                Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
            }
            else
            {
                missing = bool.Parse(currActiveProcess.Output.ReadToEnd());
            }
        };
        currActiveProcess.RunInBG();

        return(missing);
    }
    private static void RunCatchmentAnalysis()
    {
        // Debug.Log("RunCatchmentAnalysis start");
        // Prep
        var script            = Path.Combine(NDA_Path, "catchment_analysis.py");
        var floodReturnPeriod = $"HQ{reachabilityTool.NDAParamPanel.FloodReturnPeriod}";
        var travelTime        = $"{reachabilityTool.traveTimeSlider.value * reachabilityTool.travelTimeScale}";

        /*
         *  0. Python script
         *  1. Temp results path
         *  2. Results path
         *  3. Output file name
         *  4. Flood return period
         *  5. Travel time
         *  6. Selected disruption categories
         *  7. Selected scenario .shp file
         *  8. Field
         *  9. Attribute
         */
        var args = new string[] {
            script,
            NDA_TempResultsPath,
            NDA_ResultsPath,
            reachabilityTool.NDAParamPanel.OutputName,
            floodReturnPeriod,
            travelTime,
            reachabilityTool.NDAParamPanel.Disruptions,
            reachabilityTool.NDAParamPanel.ScenarioPath,
            reachabilityTool.NDAParamPanel.Field,
            reachabilityTool.NDAParamPanel.Attribute
        };

        currActiveProcess = new CustomProcess(PythonInterpreter, args);

        currActiveProcess.OnFinished += (_, e) =>
        {
            //string line;
            if (!currActiveProcess.Output.EndOfStream)
            {
                Debug.Log(currActiveProcess.Output.ReadToEnd());
                //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
            }

            if (!currActiveProcess.Errors.EndOfStream)
            {
                Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
            }
            else
            {
                if (!currActiveProcess.IsCancelled())
                {
                    // Debug.Log("RunCatchmentAnalysis done");
                    isAnalysisCompleted = true;
                }
            }
        };
        currActiveProcess.RunInBG();
    }
    //
    // Private Methods
    //

    private static void RunSetup(string setupFilePath)
    {
        currActiveProcess = new CustomProcess(setupFilePath);

        currActiveProcess.OnFinished += (_, e) =>
        {
            //string line;
            if (!currActiveProcess.Output.EndOfStream)
            {
                Debug.Log(currActiveProcess.Output.ReadToEnd());
                //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
            }

            if (!currActiveProcess.Errors.EndOfStream)
            {
                Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
            }
            else
            {
                if (!currActiveProcess.IsCancelled())
                {
                    File.Delete(setupFilePath);
                    isSetupCompleted = true;
                    // Debug.Log("Setup completed");
                }
            }
        };
        currActiveProcess.RunInBG();
    }
    private static void RunCatchmentOSMData()
    {
        // Debug.Log("RunCatchmentOSMData start");
        // Prep
        var script   = Path.Combine(NDA_Path, "catchment_osm_data.py");
        var bounds   = GetActiveSiteAreaBounds();
        var center   = CalcActiveSiteCenter();
        var path_gdf = Path.Combine(NDA_TempResultsPath, $"osm_all_roads{Path.DirectorySeparatorChar}osm_all_roads_");

        /*
         *  0. Python script
         *  1. Temp results path
         *  2. Site's coordinates
         *  3. Catchment distance
         *  4. Road path
         *  5. City infrastructure .shp file
         *  6. Boundaries
         */
        var args = new string[] {
            script,
            NDA_TempResultsPath,
            $"{center.Latitude},{center.Longitude}",    //"10.807616,106.689010",
            reachabilityTool.NDAParamPanel.Distance,    //"6000",
            path_gdf,
            reachabilityTool.NDAParamPanel.CityInfrastructure,
            $"{bounds.south},{bounds.west},{bounds.north},{bounds.east}"    //"10.7110,106.5749,10.8520,106.8147"
        };

        currActiveProcess = new CustomProcess(PythonInterpreter, args);

        currActiveProcess.OnFinished += (_, e) =>
        {
            //string line;
            if (!currActiveProcess.Output.EndOfStream)
            {
                Debug.Log(currActiveProcess.Output.ReadToEnd());
                //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
            }

            if (!currActiveProcess.Errors.EndOfStream)
            {
                Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
            }
            else
            {
                if (!currActiveProcess.IsCancelled())
                {
                    // Debug.Log("RunCatchmentOSMData done");
                    RunCatchmentExposure();
                }
            }
        };
        currActiveProcess.RunInBG();
    }
示例#5
0
 public static Definitions Get(CustomProcess p, string version, Game.GameType gameType)
 {
     try
     {
         return(new Definitions());
     }
     catch (WebException exc)
     {
         throw new Exception("Could not get definitions for version", exc);
     }
 }
示例#6
0
        void View_ProcessFile(object sender, DataEventArgs <Stream> e)
        {
            string        result;
            CustomProcess process = View.CboProcess.SelectedItem as CustomProcess;

            result = "Process: " + process.Name + "\n";

            result += service.ProcessFile(process, Util.GetPlainTextString(e.Value));

            View.TxtResult.Text = result;
        }
        public IList <CustomProcess> Select(CustomProcess data)
        {
            IList <CustomProcess> datos = new List <CustomProcess>();

            datos = GetHsql(data).List <CustomProcess>();

            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }

            return(datos);
        }
示例#8
0
        public Game(Process process)
        {
            Type    = process.MainModule.ModuleName.Contains("ffxiv_dx11") ? GameType.Dx11 : GameType.Dx9;
            Process = process.GetNhaamaProcess();

            var gameDirectory = new DirectoryInfo(process.MainModule.FileName);

            Version = File.ReadAllText(Path.Combine(gameDirectory.Parent.FullName, "ffxivgame.ver"));

            Definitions = Definitions.Get(Process, Version, Type);

            ActorTable = new ActorTableCollection(this);
        }
    private static void RunCatchmentExposure()
    {
        // Debug.Log("RunCatchmentExposure start");
        // Prep
        var script      = Path.Combine(NDA_Path, "catchment_exposure.py");
        var path_gdf    = Path.Combine(NDA_TempResultsPath, $"osm_all_roads{Path.DirectorySeparatorChar}osm_all_roads_");
        var output_name = $"HQ{reachabilityTool.NDAParamPanel.FloodReturnPeriod}";

        /*
         *  0. Python script
         *  1. Temp results path
         *  2. Road path
         *  3. Disruption type .shp file
         *  4. Output file name
         */
        var args = new string[] {
            "-Wignore",
            script,
            NDA_TempResultsPath,
            path_gdf,
            reachabilityTool.NDAParamPanel.DisruptionTypePath,
            output_name
        };

        currActiveProcess = new CustomProcess(PythonInterpreter, args);

        currActiveProcess.OnFinished += (_, e) =>
        {
            //string line;
            if (!currActiveProcess.Output.EndOfStream)
            {
                Debug.Log(currActiveProcess.Output.ReadToEnd());
                //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
            }

            if (!currActiveProcess.Errors.EndOfStream)
            {
                Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
            }
            else
            {
                if (!currActiveProcess.IsCancelled())
                {
                    // Debug.Log("RunCatchmentExposure done");
                    RunCatchmentAnalysis();
                }
            }
        };
        currActiveProcess.RunInBG();
    }
        public override IQuery GetHsql(Object data)
        {
            StringBuilder sql           = new StringBuilder("select a from CustomProcess a    where  ");
            CustomProcess CustomProcess = (CustomProcess)data;

            if (CustomProcess != null)
            {
                Parms = new List <Object[]>();
                if (CustomProcess.ProcessID != 0)
                {
                    sql.Append(" a.ProcessID = :id     and   ");
                    Parms.Add(new Object[] { "id", CustomProcess.ProcessID });
                }

                if (CustomProcess.ProcessType != null && CustomProcess.ProcessType.DocTypeID != 0)
                {
                    sql.Append(" a.ProcessType.DocTypeID = :ix2     and   ");
                    Parms.Add(new Object[] { "ix2", CustomProcess.ProcessType.DocTypeID });
                }


                if (!String.IsNullOrEmpty(CustomProcess.Name))
                {
                    sql.Append(" a.Name = :nomCode     and   ");
                    Parms.Add(new Object[] { "nomCode", CustomProcess.Name });
                }


                if (CustomProcess.Status != null && CustomProcess.Status.StatusID != 0)
                {
                    sql.Append(" a.Status.StatusID = :id2     and   ");
                    Parms.Add(new Object[] { "id2", CustomProcess.Status.StatusID });
                }


                if (CustomProcess.IsSystem != null)
                {
                    sql.Append(" a.IsSystem = :id11     and   ");
                    Parms.Add(new Object[] { "id11", CustomProcess.IsSystem });
                }
            }
            sql = new StringBuilder(sql.ToString());
            sql.Append(" 1=1 ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
示例#11
0
    private void BuildProject(CustomProcess buildProcess)
    {
        string path = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");

        string[] levels = new string[] { "Assets/Scenes/Main Menu.unity", "Assets/Scenes/Stadt.unity" };

        // Build player.
        BuildPipeline.BuildPlayer(levels, path + "/Westdrive.exe", BuildTarget.StandaloneWindows, BuildOptions.ShowBuiltPlayer);

        buildProcess();


        // Run the game (Process class from System.Diagnostics).
        Process proc = new Process();

        proc.StartInfo.FileName = path + "/Westdrive.exe";
        proc.Start();
    }
示例#12
0
 public void DeleteCustomProcess(CustomProcess data)
 {
     try
     {
         SetService(); SerClient.DeleteCustomProcess(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#13
0
 public PointerPropertyConverter(CustomProcess process)
 {
     _process = process;
 }
 public CustomProcess SelectById(CustomProcess data)
 {
     return((CustomProcess)base.SelectById(data));
 }
 public Boolean Update(CustomProcess data)
 {
     return(base.Update(data));
 }
 public Boolean Delete(CustomProcess data)
 {
     return(base.Delete(data));
 }
 public ProcessModulePropertyConverter(CustomProcess process)
 {
     _process = process;
 }
 public CustomProcess Save(CustomProcess data)
 {
     return((CustomProcess)base.Save(data));
 }
示例#19
0
        public static void ReceiveData(TcpClient client)
        {
            ns = client.GetStream();
            byte[] receivedBytes = new byte[1024];
            int    byte_count;

            try
            {
                while ((byte_count = ns.Read(receivedBytes, 0, receivedBytes.Length)) > 0)
                {
                    string d = Encoding.UTF8.GetString(receivedBytes, 0, byte_count);
                    // MessageDisplayer.Log(d);
                    string[] splitter = d.Split('|');
                    if (d.Contains("authsuccess"))
                    {
                        Perso.Me.username = Form1.username;
                        new Thread(() =>
                        {
                            Form2 frm = new Form2();
                            frm.ShowDialog();
                        }).Start();
                        Form1.todo = "d";
                    }
                    if (d.Contains("authfail"))
                    {
                        MessageBox.Show("Tu t'es trompé / tu ne fait pas partit de l'élite, navré poto");
                    }
                    if (d.Contains("LOG"))
                    {
                        string logid  = splitter[1];
                        string msg    = splitter[2];
                        string secmsg = "";
                        try
                        {
                            secmsg = splitter[3];
                        }
                        catch
                        {
                        }
                        switch (logid)
                        {
                        case "adminconnect":
                            MessageDisplayer.AdminConnect(msg);
                            break;

                        case "SelectSuccess":
                            MessageDisplayer.SelectBool(true, msg, secmsg);
                            break;

                        case "SelectFailed":
                            MessageDisplayer.SelectBool(false, msg, secmsg);
                            MessageBox.Show("L'utilisateur que vous essayez de séléctionner est probablement déconnecté \r\n toute tentative d'envoie de commande sur ce PC sera par conséquent inutile");
                            break;

                        case "ACTIVITY":
                            MessageDisplayer.Log(msg);
                            break;
                        }
                    }
                    if (d.Contains("NewDisk"))
                    {
                        string        reqID   = splitter[0];
                        string        dirName = splitter[1];
                        DiskDirectory dd      = new DiskDirectory(dirName);
                        DiskDirectory.diskDirectories.Add(dd);
                    }
                    if (d.Contains("NewFile"))
                    {
                        string      reqID   = splitter[0];
                        string      dirName = splitter[1];
                        CustomThing dd      = new CustomThing(dirName);
                        CustomThing.customThings.Add(dd);
                        //MessageDisplayer.Log("New Created file " + CustomThing.customThings.Count.ToString());
                    }
                    if (d.Contains("NewFolder"))
                    {
                        string      reqID   = splitter[0];
                        string      dirName = splitter[1];
                        CustomThing dd      = new CustomThing(dirName);
                        CustomThing.customThings.Add(dd);
                        //MessageDisplayer.Log("New Created folder " + CustomThing.customThings.Count.ToString());
                    }
                    if (d.Contains("empty"))
                    {
                        MessageDisplayer.Log("Aucun infecté !");
                    }
                    if (d.Contains("NewProcess"))
                    {
                        string[]      split        = d.Split('|');
                        string        processname  = split[1];
                        string        processid    = split[2];
                        string        processTitle = split[3];
                        bool          todo         = true;
                        CustomProcess cp           = new CustomProcess(processname, processid, processTitle);
                        foreach (CustomProcess cps in CustomProcess.customProcesses)
                        {
                            if (cps.processid == processid)
                            {
                                todo = false;
                            }
                        }
                        if (todo == true)
                        {
                            CustomProcess.customProcesses.Add(cp);
                        }
                    }
                    if (d.Contains("USERS"))
                    {
                        User.users.Clear();
                        string[] global = d.Split(';');  //USERS;dzqd|qdoqzd|zqdpqokz|qzqzdp;
                        string   reqid  = global[0];
                        //MessageDisplayer.LoadUsers();
                        foreach (string s in global)
                        {
                            if (!s.Contains("USERS"))
                            {
                                if (s == "")
                                {
                                }
                                else
                                {
                                    try
                                    {
                                        string[] split   = s.Split('|');
                                        string   poste   = split[0];
                                        string   user    = split[1];
                                        string   isadmin = split[2];
                                        string   ip      = split[3];
                                        User     u       = new User(user, poste, isadmin, ip);
                                        if (!User.users.Contains(u))
                                        {
                                            User.users.Add(u);
                                            MessageDisplayer.UserConnected(user);
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                        // MessageDisplayer.UsersLoaded();
                    }
                }
            }
            catch
            {
                Form1.current = Form1.State.DECONNECTE;
            }
        }
示例#20
0
 public CustomSerializer(CustomProcess process)
 {
     _converters.Add(new ProcessModulePropertyConverter(process));
     _converters.Add(new PointerPropertyConverter(process));
 }
示例#21
0
        public static string GetJson(CustomProcess process)
        {
            var serializer = process.GetSerializer();

            return(serializer.SerializeObject(new Definitions(process), Newtonsoft.Json.Formatting.Indented));
        }
示例#22
0
 public CustomProcess SaveCustomProcess(CustomProcess data)
 {
     try
     {
         SetService(); return SerClient.SaveCustomProcess(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#23
0
 private Definitions(CustomProcess process)
 {
     TerritoryType = new Pointer(process, 0x19D55E8, 0x4C);
     Time          = new Pointer(process, 0x19815F0, 0x10, 0x8, 0x28, 0x80);
     Weather       = new Pointer(process, 0x19579A8, 0x27);
 }
示例#24
0
 internal void PrintDocumentsInBatch(List<Document> documentList, string printer, CustomProcess process )
 {
     try
     {
         SetService();
         SerClient.PrintDocumentsInBatch(documentList, null, printer, process);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#25
0
 internal string ProcessFile(CustomProcess process, string stream)
 {
     try
     {
         SetService();
         return SerClient.ProcessFile(process, stream, App.curUser);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
    //
    // Public Methods
    //

    public static void SetupNDA()
    {
        // Create shell/batch script to setup virtual environment
        string setupFilePath;

#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
        setupFilePath = $"{Paths.Data}" + Path.Combine(NDA, "setup.sh");
#elif (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
        setupFilePath = $"{Paths.Data}" + Path.Combine(NDA, "setup.bat");
#endif

        if (!Directory.Exists(NDA_VirtualEnvPath))
        {
            using (StreamWriter sw = new StreamWriter(setupFilePath))
            {
#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
                sw.WriteLine("#!/bin/bash");
                sw.WriteLine("if [ -x /usr/libexec/path_helper ]; then");
                sw.WriteLine("eval `/usr/libexec/path_helper -s`");
                sw.WriteLine("fi");
#endif
                sw.WriteLine($"cd {Paths.Data + NDA}");
                sw.WriteLine("virtualenv -p python3 venv");
#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
                sw.WriteLine("source venv/bin/activate");
                sw.WriteLine("pip install --upgrade pip");
                sw.WriteLine("pip3 install -r requirements.txt");
#elif (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
                string batContent = @".\venv\Scripts\activate" +
                                    " && python -m pip install --upgrade pip" +
                                    " && pip3 install -r wheelhouse.txt" +
                                    " && pip3 install -r requirements.txt";

                sw.WriteLine(batContent);
#endif
            }

#if (UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX)
            // Make shell script executable
            // Grant file execution permission to all
            currActiveProcess = new CustomProcess("chmod", new string[] { "+x", setupFilePath });

            currActiveProcess.OnFinished += (_, e) =>
            {
                //string line;
                if (!currActiveProcess.Output.EndOfStream)
                {
                    Debug.Log(currActiveProcess.Output.ReadToEnd());
                    //while ((line = currActiveProcess.Output.ReadLine()) != null) Debug.Log(line);
                }

                if (!currActiveProcess.Errors.EndOfStream)
                {
                    Debug.LogError(currActiveProcess.Errors.ReadToEnd());
                    //while ((line = currActiveProcess.Errors.ReadLine()) != null) Debug.LogError(line);
                }
                else
                {
                    RunSetup(setupFilePath);
                }
            };
            currActiveProcess.RunInBG();
#elif (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
            RunSetup(setupFilePath);
#endif
        }
    }
示例#27
0
 public CustomProcess GetCustomProcess(CustomProcess data)
 {
     return(Factory.DaoCustomProcess().Select(data).First());
 }