コード例 #1
0
        public static bool IsCodeCeptArmReady()
        {
            //TIP: Sync with asynch
            Task <bool> task = Task.Run <bool>(async() => await BotHttpClient.IsCodeCeptArmReady());

            return(task.Result);
        }
コード例 #2
0
        /// <summary>
        /// batfilename with .bat
        /// </summary>
        /// <param name="BatFileName"></param>
        public static Process RunBatFile(string BatFileName, Dictionary <string, string> replaceList = null, bool IsBlocking = false)
        {
            var dir = LogApplication.Agent.GetCurrentDir();

            dir = dir.Replace("file:\\", string.Empty);
            //string drive = Path.GetPathRoot(dir);
            //string driveLetter = drive.First().ToString();
            // var param = string.Format("cd /{0} {1}\\Bat\\exe", driveLetter, dir);



            var batFolder   = string.Format("{0}\\Bat", dir); //@"D:\_ROBOtFRAMeWORK\CodeceptsJs\Project1\";
            var batPath     = Path.Combine(batFolder, BatFileName);
            var batTemplate = File.ReadAllText(batPath);



            //  batTemplate = batTemplate.Replace("##Home##", param);


            if (replaceList != null)
            {
                foreach (var pair in replaceList)
                {
                    batTemplate = batTemplate.Replace(pair.Key, pair.Value);
                }
            }
            var dirBatFolder = string.Format("{0}\\Bat\\exe", dir);  //@"D:\_ROBOtFRAMeWORK\CodeceptsJs\Project1\";
            var dirBatPath   = Path.Combine(dirBatFolder, BatFileName);

            try
            {
                if (File.Exists(dirBatPath))
                {
                    File.Delete(dirBatPath);
                }

                File.WriteAllText(dirBatPath, batTemplate);
            }
            catch (Exception err)
            {
                BotHttpClient.Log(err.Message, true);
                // throw;
            }



            //step# 2 run bat file
            if (IsBlocking)
            {
                return(null);
            }
            else
            {
                return(ExecuteCommandSilently(dirBatPath));
            }
        }
コード例 #3
0
        public async static Task <bool> UpdateView(UpdateMainViewCmdParam cmd)
        {
            var container = new UpdateMainViewCmdParam();

            container.Payload = cmd;

            await BotHttpClient.PostToArmAPI(container);

            return(true);
        }
コード例 #4
0
        public async static Task <bool> UpdateMe()
        {
            var response = await BotHttpClient.TaskHttpGetToArmAPI("UpdateMe");

            var responseContent = await response.Content.ReadAsStringAsync();

            var main = JsonConvert.DeserializeObject <GlobalMain>(responseContent);


            GlobalMain.StateAKA = main.StataAKA_DTO;
            GlobalMain.Message  = main.Message_DTO;


            return(true);
        }
コード例 #5
0
        public static async Task <bool> IsCodeCeptArmReady()
        {
            bool result = false;

            var response = await BotHttpClient.TaskHttpGetToArmAPI("IsCodeCeptReady");

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var hello = response.Content.ReadAsStringAsync().Result;
                BotHttpClient.WriteDevBotResponse("IsCodeCeptArmReady: \n" + hello);
                result = Convert.ToBoolean(hello);
            }
            else
            {
                result = false;
            }

            return(result);
        }
コード例 #6
0
        //must be 1 reference only
        public static async Task CreateOutputWF()
        {
            //STEP_.RESULT #99 CreateOutputWF
            var stringContent = File.ReadAllText(FileEndPointManager.InputWFFilePath);

            var cmd     = ReadInputWFCmdJsonFile();
            var payload = cmd; //(RunWFCmdParam)cmd.Payload;

            var result = FileEndPointManager.ReadMyGrabValueFile();

            var @event = new DevNoteIntegrationEvent
            {
                GuidId          = cmd.GuidId,
                EventParameters = cmd.EventParameters,
                EventName       = cmd.EventName,
                OuputResponse   = result,
                RetryCount      = payload.RetryCount,
                ErrorCode       = payload.ErrorCode
            };

            stringContent = JsonConvert.SerializeObject(@event);



            // var stringContent = JsonConvert.SerializeObject(cmd); //new StringContent(JsonConvert.SerializeObject(cmd), Encoding.UTF8, "application/json");
            var file = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFOutput);



            //_HACK safe to delete
            #region ---TEST ONLY: Compiler will  automatically erase this in RELEASE mode and it will not run if Global.GlobalTestMode is not set to TestMode.Simulation
#if OVERRIDE || DEBUG
            //System.Diagnostics.Debug.WriteLine("HACK-TEST -");
            //await BotHttpClient.Log("FileEndPointManager.MyWaitOneDirectory:" + FileEndPointManager.MyWaitOneDirectory);
            //await BotHttpClient.Log("OuputResponse:" + result);
#endif
            #endregion //////////////END TEST



            await BotHttpClient.Log("OuputValue:" + result);



            File.WriteAllText(file, stringContent);

            if (!string.IsNullOrEmpty(cmd.EventFilePath))
            {
                try
                {
                    if (File.Exists(cmd.EventFilePath))
                    {
                        File.Delete(cmd.EventFilePath);
                    }
                }
                catch (Exception err)
                {
                    await BotHttpClient.Log(err.Message, true);
                }
            }

            //STEP_.RESULT #6 save to OUTCOME
            var fName = Path.GetFileName(cmd.EventFilePath);
            fName = fName.Replace(EnumFiles.WFInput, EnumFiles.WFOutput);

            file = Path.Combine(FileEndPointManager.MyOutcomeFolder, fName);
            File.WriteAllText(file, stringContent);

            await BotHttpClient.Log("EventOutputStatus: " + Environment.NewLine + stringContent);


            //var fileIn = Path.Combine(FileEndPointManager.MyWaitOneDirectory, EnumFiles.WFInput);
            //if (File.Exists(fileIn))
            //    File.Delete(fileIn);
            ClearInputWF();

            //delete Eventfile
            if (!string.IsNullOrEmpty(cmd.EventFilePath))
            {
                try
                {
                    if (File.Exists(cmd.EventFilePath))
                    {
                        File.Delete(cmd.EventFilePath);
                    }
                }
                catch (Exception err)
                {
                    await BotHttpClient.Log(err.Message, true);
                }
            }
        }
コード例 #7
0
        public static void ExecuteWaitCommand(string command, string workingFolder, EnumProcess proc, bool IsCreateNoWindow = false)
        {
            int ExitCode;
            ProcessStartInfo ProcessInfo;
            Process          process;

            ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
            ProcessInfo.CreateNoWindow   = IsCreateNoWindow;
            ProcessInfo.UseShellExecute  = false;
            ProcessInfo.WorkingDirectory = workingFolder;

            // *** Redirect the output ***

            //  ProcessInfo.RedirectStandardError = true;
            //  ProcessInfo.RedirectStandardOutput = true;

            ProcessInfo.RedirectStandardError  = false;
            ProcessInfo.RedirectStandardOutput = false;

            process = Process.Start(ProcessInfo);

            switch (proc)
            {
            case EnumProcess.NonGlobal:
                break;

            case EnumProcess.Designer:
                GlobalDef.CurrentDesigner.Process = process;
                break;

            case EnumProcess.Player:
                GlobalDef.ProcessPlayer = process;
                break;

            case EnumProcess.Receiver:
                GlobalDef.ProcessReceiver = process;
                break;

            case EnumProcess.Sender:
                GlobalDef.ProcessSender = process;
                break;

            default:
                break;
            }


            process.WaitForExit();

            // *** Read the streams ***
            //  string output = process.StandardOutput.ReadToEnd();
            //  string error = process.StandardError.ReadToEnd();

            ExitCode = process.ExitCode;

            if (ExitCode > 0)
            {
                BotHttpClient.Log("ERROR on " + proc.ToString(), true);
            }

            // MessageBox.Show("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
            // MessageBox.Show("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
            //  MessageBox.Show("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
            process.Close();

            process = null;

            switch (proc)
            {
            case EnumProcess.NonGlobal:
                break;

            case EnumProcess.Designer:
                GlobalDef.CurrentDesigner.Process = process;
                break;

            case EnumProcess.Player:
                GlobalDef.ProcessPlayer = process;
                break;

            case EnumProcess.Receiver:
                GlobalDef.ProcessReceiver = process;
                break;

            case EnumProcess.Sender:
                GlobalDef.ProcessSender = process;
                break;

            default:
                break;
            }


            #region EXAMPLE
            //// This will get the current WORKING directory (i.e. \bin\Debug)
            //string workingDirectory = Environment.CurrentDirectory;
            //// This will get the current PROJECT directory
            //string projectDirectory = Directory.GetParent(workingDirectory).Parent.FullName;
            //string commandToExecute = Path.Combine(projectDirectory, "TestSetup", "WreckersTestSetupQA.bat");
            //string workingFolder = Path.GetDirectoryName(commandToExecute);
            //commandToExecute = QuotesAround(commandToExecute);
            //ExecuteCommand(commandToExecute, workingFolder);

            #endregion
        }