Exemple #1
0
        public void IfCanRunCommandWithNoOutputAndEventOutputChangedIsRaised()
        {
            var runSync    = new RunAsync();
            var result     = "";
            var waitHandle = new AutoResetEvent(false);

            runSync.OutputChanged += (x) =>
            {
                result = x;
                waitHandle.Set();
            };
            runSync.Run("write");
            waitHandle.ThrowIfHandleTimesOut(TimeSpan.FromSeconds(5));
            Assert.AreEqual("No output", result);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ExamplePool <ExampleObject> .Init();

            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine($"Chamada {i} => ()");
                RunAsync runAsync = new RunAsync(Execute);
                runAsync.BeginInvoke(null, null);

                Thread.Sleep(1500);
            }

            Console.ReadKey();
        }
Exemple #3
0
        public void IfCanRunWrongCommandAndEventRunFinishedIsRaised()
        {
            var runSync    = new RunAsync();
            var result     = 0;
            var waitHandle = new AutoResetEvent(false);

            runSync.RunFinished += () =>
            {
                result = 1;
                waitHandle.Set();
            };
            runSync.Run("thingdingding");
            waitHandle.ThrowIfHandleTimesOut(TimeSpan.FromSeconds(5));
            Assert.AreEqual(1, result);
        }
Exemple #4
0
        public void IfCanRunCommandAndReturnOutput()
        {
            var runAsync   = new RunAsync();
            var result     = "";
            var waitHandle = new AutoResetEvent(false);

            runAsync.OutputChanged += (x) =>
            {
                result = x;
                waitHandle.Set();
            };
            runAsync.Run("write test");

            waitHandle.ThrowIfHandleTimesOut(TimeSpan.FromSeconds(5));

            Assert.AreEqual("test\r\n", result);
        }
        public static List <string> GetRequestClient(string url, List <string> ActionName, List <string> header, List <string> request, string key)
        {
            GetCacheSortKeyClear(key);

            List <string> resultJson = new List <string>();

            for (int i = 0; i < ActionName.Count(); i++)
            {
                JObject     headerJObject;
                List <Json> headerJson = new List <Json>();
                try
                {
                    headerJObject = JObject.Parse(header[i]);
                    headerJson    = JsonData.Fun(headerJObject);

                    int    requestType = fastpayTools.EndpointTable.Where(s => s.Action == ActionName[i]).Select(a => a.RequestType).FirstOrDefault();
                    string endpoint    = fastpayTools.EndpointTable.Where(s => s.Action == ActionName[i]).Select(a => a.EndPoint).FirstOrDefault();
                    var    guidID      = fastpayTools.EndpointTable.FirstOrDefault(a => a.Action == ActionName[i]).Id;

                    var Response       = JsonConvert.DeserializeObject(RunAsync.Run(key, guidID, url, request[i], headerJson, requestType, endpoint).GetAwaiter().GetResult());
                    var endpointUpdate = fastpayTools.EndpointTable.FirstOrDefault(s => s.Action == ActionName[i]);
                    endpointUpdate.Response = Response.ToString();
                    fastpayTools.SaveChanges();
                    resultJson.Add("Success");
                }
                catch (Exception ex)
                {
                    if (ex.Message == "NotFound")
                    {
                        resultJson.Add("Error");
                        for (int j = i + 1; j < ActionName.Count(); j++)
                        {
                            var guidID = fastpayTools.EndpointTable.FirstOrDefault(a => a.Action == ActionName[j]).Id;
                            resultJson.Add("Error");
                            Request.GetRequestResponseCacheInsert(key, guidID, "NotFound", "NotFound");
                        }
                        return(resultJson);
                    }
                    resultJson.Add("Error");
                }
            }
            return(resultJson);
        }
        public override int GetHashCode()
        {
            int hashcode = 157;

            unchecked {
                hashcode = (hashcode * 397) + SessionHandle.GetHashCode();
                hashcode = (hashcode * 397) + Statement.GetHashCode();
                if (__isset.confOverlay)
                {
                    hashcode = (hashcode * 397) + TCollections.GetHashCode(ConfOverlay);
                }
                if (__isset.runAsync)
                {
                    hashcode = (hashcode * 397) + RunAsync.GetHashCode();
                }
                if (__isset.queryTimeout)
                {
                    hashcode = (hashcode * 397) + QueryTimeout.GetHashCode();
                }
            }
            return(hashcode);
        }
 /// <summary>
 /// Add a new background job
 /// </summary>
 /// <param name="name">The name used to display in the statusbar when executing this item</param>
 /// <param name="work">The function to execute in the background</param>
 public void AddBgWork(String name, RunAsync work)
 {
     m_WorkQueue.Enqueue(new BgWork(name, work));
     TriggerWork();
 }
 /// <summary>
 /// Constructor of Background work
 /// </summary>
 /// <param name="name">a descriptive name for the job</param>
 /// <param name="work">the actual function to call</param>
 public BgWork(String name, RunAsync work)
 {
     m_name = name;
     m_work = work;
 }
Exemple #9
0
        public void IfCanRunCommand()
        {
            var runAsync = new RunAsync();

            runAsync.Run("write test");
        }
 /// <summary>
 /// Add a new background job
 /// </summary>
 /// <param name="name">The name used to display in the statusbar when executing this item</param>
 /// <param name="work">The function to execute in the background</param>
 public void AddBgWork(String name, RunAsync work)
 {
     m_WorkQueue.Enqueue(new BgWork(name, work));
     TriggerWork();
 }
Exemple #11
0
 /// <summary>
 /// Constructor of Background work
 /// </summary>
 /// <param name="name">a descriptive name for the job</param>
 /// <param name="work">the actual function to call</param>
 public BgWork(String name, RunAsync work)
 {
     m_name = name;
     m_work = work;
 }