public static TaskMessages OfEquivalentTask(this IEnumerable<TaskMessage> taskMessages, RemoteTask task)
 {
     var equivalentTasks = from tm in taskMessages
         where Equals(tm.Task, task)
         select tm;
     return new TaskMessages(task, "equal", equivalentTasks.ToList());
 }
 public TaskState(RemoteTask task, TaskState parentState, string message = "Internal Error (xunit runner): No status reported", TaskResult result = TaskResult.Inconclusive)
 {
     Task = task;
     Message = message;
     Result = result;
     ParentState = parentState;
 }
Exemplo n.º 3
0
        public override bool Equals(RemoteTask other)
        {
            if (other == null) return false;

            return ReferenceEquals(this, other) ||
                Equals(other as LoadContextAssemblyTask);
        }
Exemplo n.º 4
0
        private IStorEvilJob GetJob(RemoteTask remoteTask, IScenario scenario)
        {
            InPlaceStoryRunner handler = BuildInPlaceRunner(remoteTask);
            IStoryProvider provider = new SingleScenarioStoryProvider(scenario);

            return new StorEvilJob(provider, handler);
        }
        public void TaskStarting(RemoteTask remoteTask)
        {
            Assert.NotNull(remoteTask);

            tasks.Push(remoteTask);
            TaskStartingCalls.Add(remoteTask);
        }
Exemplo n.º 6
0
        private InPlaceStoryRunner BuildInPlaceRunner(RemoteTask remoteTask)
        {
            _listener = new ResharperResultListener(_server, remoteTask);
            IScenarioPreprocessor preprocessor = new ScenarioPreprocessor();

            return new InPlaceStoryRunner(_listener, preprocessor, new ScenarioInterpreter(new InterpreterForTypeFactory(new ExtensionMethodHandler())), new IncludeAllFilter(), _factory );
        }
Exemplo n.º 7
0
        public string GetFullMethodName(RemoteTask task)
        {
            var typeName = task.GetProperty<string>("TypeName");
            var shortName = task.GetProperty<string>("ShortName");

            return string.Format("{0}.{1}", typeName, shortName);
        }
        public RemoteTaskWrapper(RemoteTask remoteTask, IRemoteTaskServer server)
        {
            RemoteTask = remoteTask;
            this.server = server;

            result = TaskResult.Inconclusive;
        }
 private static void AssertTaskFinishedCalled(FakeRemoteTaskServer.TaskFinishedParameters taskFinishedCall,
                                              RemoteTask remoteTask, string message, TaskResult result)
 {
     Assert.Equal(remoteTask, taskFinishedCall.RemoteTask);
     Assert.Equal(message, taskFinishedCall.Message);
     Assert.Equal(result, taskFinishedCall.Result);
 }
 public static TaskMessages OfTask(this IEnumerable<TaskMessage> taskMessages, RemoteTask task)
 {
     var sameTasks = from tm in taskMessages
         where Equals(tm.Task, task) && tm.Task.Id == task.Id
         select tm;
     return new TaskMessages(task, "same", sameTasks.ToList());
 }
Exemplo n.º 11
0
 public TaskMessages(RemoteTask task, string taskMatchStyle, IList<TaskMessage> taskMessages)
 {
     this.task = task;
     this.taskMatchStyle = taskMatchStyle;
     messages = taskMessages.Select(tm => tm.Message).ToList();
     serverActions = taskMessages.Select(tm => tm.ServerAction).ToList();
 }
        public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Dictionary<RemoteTask, IUnitTestElement> tasks)
        {
            var caseTask = remoteTask as TestCaseTask;
            if (caseTask != null)
                return GetDynamicCaseElement(tasks, caseTask);

            return null;
        }
Exemplo n.º 13
0
        private TaskMessage(RemoteTask task, ServerAction serverAction, params object[] parameters)
        {
            Assert.NotNull(task);

            Task = task;
            ServerAction = serverAction;
            Message = ServerMessage.Format(serverAction, parameters);
        }
        public bool TaskStarting(RemoteTask remoteTask)
        {
            Assert.NotNull(remoteTask);

            tasks.Push(remoteTask);
            TaskStartingCalls.Add(remoteTask);

            return true;
        }
Exemplo n.º 15
0
 public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Dictionary<string, IUnitTestElement> elements)
 {
     return GetDynamicElement(
       remoteTask,
       absoluteId =>
       {
     IUnitTestElement element;
     return elements.TryGetValue(absoluteId, out element) ? (ITestElement) element : null;
       });
 }
Exemplo n.º 16
0
 public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Dictionary<RemoteTask, IUnitTestElement> elements)
 {
     return GetDynamicElement(
       remoteTask,
       absoluteId =>
       {
     var task = new ComparableTask(absoluteId);
     IUnitTestElement element;
     return elements.TryGetValue(task, out element) ? element.To<IUnitTestElementEx>() : null;
       });
 }
Exemplo n.º 17
0
        public void TaskFinished(RemoteTask remoteTask, string message, TaskResult result, TimeSpan duration)
        {
            Debug.Assert(result != TaskResult.Inconclusive);

            clientController.TaskFinished(remoteTask);
            if (result == TaskResult.Skipped)
                server.TaskExplain(remoteTask, message);
            if (duration >= TimeSpan.Zero)
                server.TaskDuration(remoteTask, duration);
            server.TaskFinished(remoteTask, message, result);
        }
        public bool TaskProgress(RemoteTask remoteTask, string message)
        {
            Assert.NotNull(remoteTask);
            Assert.Same(tasks.Peek(), remoteTask);

            if (!TaskProgressCalls.ContainsKey(remoteTask))
                TaskProgressCalls.Add(remoteTask, new List<string>());
            TaskProgressCalls[remoteTask].Add(message);

            return true;
        }
Exemplo n.º 19
0
        public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Dictionary<string, IUnitTestElement> taskIdsToElements)
        {
            var theoryTask = remoteTask as XunitTestTheoryTask;
            if (theoryTask != null)
                return GetDynamicTheoryElement(taskIdsToElements, theoryTask);

            var methodTask = remoteTask as XunitTestMethodTask;
            if (methodTask != null)
                return GetDynamicMethodElement(taskIdsToElements, methodTask);

            return null;
        }
Exemplo n.º 20
0
        public string GetFullMethodName(RemoteTask task)
        {
            var typeName = task.GetProperty<string>("TypeName");

            string methodName;

            try
            {
                methodName = task.GetProperty<string>("MethodName");
            }
            catch (Exception)
            {
                methodName = task.GetProperty<string>("ShortName");
            }

            return string.Format("{0}.{1}", typeName, methodName);
        }
Exemplo n.º 21
0
        public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Func<string, ITestElement> elementProvider)
        {
            var dynamicTask = (DynamicTask) remoteTask;
              var parentElement = elementProvider(dynamicTask.ParentGuid);
              Trace.Assert(parentElement != null, "parentElement != null");

              var elementTypeFullName = typeof(ChildTestElement).FullName;
              var project = parentElement.GetProject().AssertNotNull();
              var entity = new TestEntitySurrogate(dynamicTask.Identity, project, new string[0], dynamicTask.Text);

              var elementFactory = project.GetComponent<ITestElementFactory>();
              var element = elementFactory.GetOrCreateTestElement(elementTypeFullName, entity, parentElement);

              // TODO: parameter for elementFactory instead?
              element.State = UnitTestElementState.Dynamic;

              return element;
        }
Exemplo n.º 22
0
            public void Accept(RemoteTask remoteTask, IDictionary <string, string> attributes, XmlReader reader, IRemoteChannel remoteChannel)
            {
                attributes.Remove("path");
                try
                {
                    var attributesString = string.Empty;
                    if (attributes != null)
                    {
                        attributesString = " " + attributes.Select(pair => pair.Key + "=\"" + pair.Value + "\"").Join(" ");
                    }
                    var xmldoc = new XmlDocument();
                    xmldoc.LoadXml(string.Format(remoteTask != null ? "<{0}{1}><task/></{0}>" : "<{0}{1}/>", PacketName, attributesString));
                    var task = (XmlElement)xmldoc.DocumentElement.FirstChild;
                    remoteTask.ToXml(task);
                    string xml;
                    bool   state;
#pragma warning disable 665
                    while (!string.IsNullOrEmpty(xml = (state = reader.IsStartElement()) ? reader.ReadOuterXml() : reader.ReadString()))
#pragma warning restore 665
                    {
                        if (state)
                        {
                            var doc = new XmlDocument();
                            doc.LoadXml(xml);
                            var message = doc.DocumentElement;
                            if (message != null)
                            {
                                xmldoc.DocumentElement.AppendChild(xmldoc.ImportNode(message, true));
                            }
                        }
                        else
                        {
                            xmldoc.DocumentElement.AppendChild(xmldoc.CreateTextNode(xml));
                        }
                    }

                    listener.Output.WriteLine(xmldoc.OuterXml);
                }
                catch
                {
                    // Ignore
                }
            }
Exemplo n.º 23
0
        //[TestMethod]
        public void TestRenderOnFreezerJsEventWithSingleWebPageHard()
        {
            var rootDirectoryPath = FreezerTestPathSolver.GetDirectory("WebPages");

            var hostname = "127.0.0.1";
            int port     = 25345; // This port is hardcoded. Can be changed if busy

            using (new ExclusiveBlock("TestRenderOnFreezerJsEventWithSingleWebPageHard"))
            {
                RunnerCore.SetupHostAsync(hostname, port, null, "TestRenderOnFreezerJsEventWithSingleWebPageHard");

                using (var httpListener = new StaticHttpServer(rootDirectoryPath))
                {
                    var url = $"{_httpServer.BoundURL}/Global/verylongpage.html";
                    //var url = "http://dragonball.wikia.com/wiki/Frieza";

                    var hostableLocalProcess = new CaptureHostMock()
                    {
                        Hostname = hostname,
                        Port     = port
                    };

                    var trigger = new WindowLoadTrigger(); // new FreezerJsEventTrigger();
                    var zone    = CaptureZone.FullPage;

                    using (IWorker runnerHost = new RemoteWorker(hostableLocalProcess))
                    {
                        var remoteTask = new RemoteTask()
                        {
                            BrowserSize = new Size(800, 600),
                            Url         = url,
                        };

                        remoteTask.SetTrigger(trigger);
                        remoteTask.SetCaptureZone(zone);

                        var taskResult = runnerHost.PerformTask(remoteTask);

                        File.WriteAllBytes($@"BmpResults/out-{nameof(TestRenderOnFreezerJsEventWithSingleWebPageHard)}.png", taskResult.PayLoad);
                    }
                }
            }
        }
Exemplo n.º 24
0
        public IUnitTestElement GetDynamicElement(RemoteTask remoteTask, Func <string, ITestElement> elementProvider)
        {
            var dynamicTask   = (DynamicTask)remoteTask;
            var parentElement = elementProvider(dynamicTask.ParentGuid);

            Trace.Assert(parentElement != null, "parentElement != null");

            var elementTypeFullName = typeof(ChildTestElement).FullName;
            var project             = parentElement.GetProject().AssertNotNull();
            var entity = new TestEntitySurrogate(dynamicTask.Identity, project, new string[0], dynamicTask.Text);

            var elementFactory = project.GetComponent <ITestElementFactory>();
            var element        = elementFactory.GetOrCreateTestElement(elementTypeFullName, entity, parentElement);

            // TODO: parameter for elementFactory instead?
            element.State = UnitTestElementState.Dynamic;

            return(element);
        }
        /// <summary>Returns whether the given Concurrent Incident can be safely merged with the user's values.</summary>
        /// <param name="moddedTask">The concurrent requirement.</param>
        private bool save_CheckIfConcurrencyCanBeMerged(RemoteTask moddedTask)
        {
            bool retValue = false;

            try
            {
                //Get current values..
                RemoteTask userTask = this.save_GetFromFields();

                retValue = userTask.CanBeMergedWith(this._Task, moddedTask);
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "save_CheckIfConcurrencyCanBeMerged()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
                retValue = false;
            }
            return(retValue);
        }
Exemplo n.º 26
0
        public async Task <Dictionary <PluginInstance, bool> > OnLoggerConfigUpdatedAsync()
        {
            try
            {
                var plugins     = new List <PluginInstance>(RunningPluginMap.Values);
                var remoteTasks = plugins.AsParallel().Select(p => p.Plugin.OnMessage(PluginMessage.OnLoggerConfigUpdated));

                // ReSharper disable once ConstantConditionalAccessQualifier
                var results = (await RemoteTask.WhenAll(remoteTasks).ConfigureAwait(false))?.Cast <bool>()?.ToList();

                if (results == null)
                {
                    return(null);
                }

                if (results.Count != plugins.Count)
                {
                    throw new InvalidOperationException($"results.Count is {results.Count} while plugins.Count is {plugins.Count}");
                }

                Dictionary <PluginInstance, bool> pluginCallSuccessMap = new Dictionary <PluginInstance, bool>();

                for (int i = 0; i < results.Count; i++)
                {
                    pluginCallSuccessMap[plugins[i]] = results[i];
                }

                return(pluginCallSuccessMap);
            }
            catch (RemotingException ex)
            {
                LogTo.Warning(ex, "Remoting exception thrown in OnLoggerConfigUpdated");

                return(null);
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "Exception thrown in OnLoggerConfigUpdated");

                return(null);
            }
        }
Exemplo n.º 27
0
        public static RemoteTask MergeWithConcurrency(RemoteTask userSaved, RemoteTask original, RemoteTask serverModded)
        {
            //If the field was not changed by the user (reqUserSaved == reqOriginal), then use the reqConcurrent. (Assuming that the
            // reqConcurrent has a possible updated value.
            //Otherwise, use the reqUserSaved value.
            RemoteTask retTask = new RemoteTask();

            try
            {
                retTask.ActualEffort = ((userSaved.ActualEffort == original.ActualEffort) ? serverModded.ActualEffort : userSaved.ActualEffort);
                retTask.CreationDate = original.CreationDate;
                retTask.CreatorId    = ((userSaved.CreatorId == original.CreatorId) ? serverModded.CreatorId : userSaved.CreatorId);
                string strDescUser = StaticFuncs.StripTagsCharArray(userSaved.Description);
                string strDescOrig = StaticFuncs.StripTagsCharArray(original.Description);
                retTask.Description     = ((strDescOrig.TrimEquals(strDescOrig)) ? serverModded.Description : userSaved.Description);
                retTask.EndDate         = ((userSaved.EndDate == original.EndDate) ? serverModded.EndDate : userSaved.EndDate);
                retTask.EstimatedEffort = ((userSaved.EstimatedEffort == original.EstimatedEffort) ? serverModded.EstimatedEffort : userSaved.EstimatedEffort);
                retTask.LastUpdateDate  = serverModded.LastUpdateDate;
                retTask.Name            = ((userSaved.Name.TrimEquals(original.Name)) ? serverModded.Name : userSaved.Name);
                retTask.OwnerId         = ((userSaved.OwnerId == original.OwnerId) ? serverModded.OwnerId : userSaved.OwnerId);
                retTask.ProjectId       = original.ProjectId;
                retTask.ReleaseId       = ((userSaved.ReleaseId == original.ReleaseId) ? serverModded.ReleaseId : userSaved.ReleaseId);
                retTask.RemainingEffort = ((userSaved.RemainingEffort == original.RemainingEffort) ? serverModded.RemainingEffort : userSaved.RemainingEffort);
                retTask.RequirementId   = ((userSaved.RequirementId == original.RequirementId) ? serverModded.RequirementId : userSaved.RequirementId);
                retTask.StartDate       = ((userSaved.StartDate == original.StartDate) ? serverModded.StartDate : userSaved.StartDate);
                retTask.TaskId          = original.TaskId;
                retTask.TaskPriorityId  = ((userSaved.TaskPriorityId == original.TaskPriorityId) ? serverModded.TaskPriorityId : userSaved.TaskPriorityId);
                retTask.TaskStatusId    = ((userSaved.TaskStatusId == original.TaskStatusId) ? serverModded.TaskStatusId : userSaved.TaskStatusId);

                //Custom Properties
                retTask.CustomProperties = MergeCustomFieldsWithConcurrency(userSaved, original, serverModded);
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "MergeWithConcurrency()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
                retTask = null;
            }

            //Return our new requirement.
            return(retTask);
        }
Exemplo n.º 28
0
        public TaskResult Execute(RemoteTask remoteTask)
        {
            try
            {
                var scenario = ((RunScenarioTask) remoteTask).GetScenario();
                var job = GetJob(remoteTask, scenario);

                job.Run();

                return _listener.Result;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                _server.TaskOutput(remoteTask, "Exception!\r\n", TaskOutputType.STDOUT);
                _server.TaskOutput(remoteTask, ex.ToString(), TaskOutputType.STDOUT);

                return TaskResult.Exception;
            }
        }
Exemplo n.º 29
0
        private void ReportResult(RemoteTask task, State state, ExceptionDescriptor exception, string desc)
        {
            if (exception == null)
            {
                _server.TaskFinished(task, string.Empty, state.ToTaskResult());
            }
            else
            {
                _server.TaskOutput(task, "MUUHU", TaskOutputType.STDERR);
                _server.TaskOutput(task, "MUUHU", TaskOutputType.DEBUGTRACE);
                _server.TaskOutput(task, "\u2713", TaskOutputType.STDOUT);
                _server.TaskOutput(task, "\u2717", TaskOutputType.STDOUT);
                _server.TaskException(task, new[] { exception.ToTaskException(desc) });

                _server.TaskOutput(task, "xxxxxxxxxxxxxxxxxxxxxxxxxx", TaskOutputType.STDOUT);
                _server.TaskException(task, new[] { exception.ToTaskException(desc) });

                _server.TaskFinished(task, exception.Type.Name, state.ToTaskResult());
            }
        }
Exemplo n.º 30
0
        private LastCompilationInfo m_LastCompilation = null; // for caching results/compilations

        /// <summary>
        /// Runs the script asynchronously
        /// </summary>
        /// <param name="factory">Factory method to create an IScriptGlobals instance in the current (= the script's) AppDomain</param>
        /// <param name="parameters">Full list of IParameterValues to be passed to the script</param>
        /// <param name="scriptCode">Code of the script</param>
        /// <param name="Options">Options for script execution, compilation or invocation</param>
        /// <param name="submission">Returns an instance of the compiler-generated wrapped script class (e.g. an instance of Submission#0)</param>
        /// <returns>A RemoteTask, so the caller (which could reside in a different AppDomain) can unwrap the results asynchronously</returns>
        public RemoteTask <object> RunAsync(Func <AppDomain, IScriptGlobals> factory, IParameterValue[] parameters, string scriptCode, ScriptingOptions Options)
        {
            string         debug_code_file_path = (Debugger.IsAttached) ? Path.Combine(Path.GetTempPath(), "ExcelScript.DebuggedCode.csx") : null;
            IScriptGlobals globalsInstance      = null;

            try
            {
                scriptCode = RewriteCode(scriptCode, parameters, debug_code_file_path);

                if (debug_code_file_path != null)
                {
                    // todo: might cause problems in multi threaded scenarios / whenever we're running through the .RunAsync() function in parallel.
                    // possibly create varying or even fully random file paths - though though that might need some cleanup logic
                    string line_directive = (debug_code_file_path == null) ? String.Empty : "#line 1 \"" + debug_code_file_path + "\"" + Environment.NewLine;
                    File.WriteAllText(debug_code_file_path, scriptCode);
                    scriptCode = line_directive + scriptCode;
                }

                IMethodSymbol entryPoint;
                var           assembly = GetOrCreateScriptAssembly(parameters.Select(x => x.Parameter).ToArray(), scriptCode, Options, debug_code_file_path, out entryPoint);

                globalsInstance = CreateGlobals(factory, parameters);
                var entryMethod = GetEntryMethod(assembly, entryPoint); // the <factory> method

                var result = RemoteTask.ServerStart <object>(cts => InvokeFactoryAsync(entryMethod, globalsInstance));
                return(result);
            }
            finally
            {
                if (!String.IsNullOrEmpty(debug_code_file_path) && File.Exists(debug_code_file_path))
                {
                    File.Delete(debug_code_file_path);
                }

                IDisposable globalsDisposable = globalsInstance as IDisposable;
                if (globalsDisposable != null)
                {
                    globalsDisposable.Dispose();
                }
            }
        }
Exemplo n.º 31
0
        private RunScenarioOutlineTask FindOutline(RemoteTask remoteTask)
        {
            if (!(remoteTask is RunScenarioTask))
            {
                return(null);
            }

            var id = ((RunScenarioTask)remoteTask).GetScenario().Id;

            foreach (var scenarioTask in _scenarioTasks)
            {
                if (scenarioTask is RunScenarioOutlineTask)
                {
                    if (((RunScenarioOutlineTask)scenarioTask).HasChildWithId(id))
                    {
                        return(scenarioTask as RunScenarioOutlineTask);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 32
0
        public TaskResult Execute(RemoteTask remoteTask)
        {
            try
            {
                var scenario = ((RunScenarioTask) remoteTask).GetScenario();
                var job = GetJob(remoteTask, scenario);

                job.Run();

                
                return _listener.Result;
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
                _server.TaskOutput(remoteTask, "Exception!\r\n", TaskOutputType.STDOUT);
                _server.TaskOutput(remoteTask, ex.ToString(), TaskOutputType.STDOUT);

                return TaskResult.Exception;
            }
        }
Exemplo n.º 33
0
        public void RemoteTask_WithNoResultSet_InvokesTimeoutHandler()
        {
            // Arrange
            var handlerCalled        = false;
            var wait                 = new ManualResetEvent(false);
            var taskCompletionSource = new TaskCompletionSource <object>();
            var timeout              = TimeSpan.FromMilliseconds(5);

            Func <Exception> onTimeout = () =>
            {
                handlerCalled = true;
                wait.Set();
                return(new TimeoutException());
            };

            // Act
            var remoteTask = new RemoteTask <object>(taskCompletionSource, timeout, onTimeout);

            wait.WaitOne(TimeSpan.FromMilliseconds(100));

            // Assert
            Assert.That(handlerCalled, Is.True);
        }
Exemplo n.º 34
0
        private void PublishTaskResult(RemoteTask task, FeatureResult result)
        {
            var    taskResult        = GetFeatureTaskResult(result);
            string taskResultMessage = "";

            if (taskResult == TaskResult.Skipped)
            {
                taskResultMessage = "Skipped";
            }
            if (taskResult == TaskResult.Inconclusive)
            {
                taskResultMessage = "Pending";
                server.TaskExplain(task, "See pending step(s) for more information");
            }
            if (taskResult == TaskResult.Error)
            {
                var failure = result.ScenarioResults.First(_ => _.Result is Failed).Result as Failed;
                taskResultMessage = failure.Exception.Message;
                var te = new TaskException(failure.Exception);
                server.TaskException(task, new[] { te });
            }
            server.TaskFinished(task, taskResultMessage, taskResult);
        }
Exemplo n.º 35
0
        public async Task Execute(IJobExecutionContext context)
        {
            const string projectId = "sunkang-iot-monitor-service";
            const string topicId   = "test";

            // add task to cache
            RemoteTask newRemoteTask = new RemoteTask()
            {
                id = Guid.NewGuid(), name = $"task-{DateTime.Now.ToString("mssfff")}", completed = false
            };

            _remoteTasksCache.AddOrUpdate(newRemoteTask);

            // Manual test on the same Topic
            // Add PubSub Client integration - Publish messages with ordering key
            var messagesWithOrderingKey = new List <(string, string, MapField <string, string>)>()
            {
                ("OrderingKey", JsonConvert.SerializeObject(newRemoteTask).ToString(), new MapField <string, string> {
                    { "type", "Response" }
                }),
            };
            await _googleCloudPubSubClient.PublishOrderedMessagesAsync(projectId, topicId, messagesWithOrderingKey);
        }
Exemplo n.º 36
0
 //сбор данных задачи для исполнения команд
 private void LoadConfiguration(RemoteTask task)
 {
     //  Logging("STARTED");
     foreach (Favorite fav in task.Favorites)
     {
         List <string> commands = new List <string>();
         //проходим по списку команд, выявляем соответствие используемой команды и категории избранного
         //в сортированном списке по ордеру
         foreach (Command command in task.Commands.OrderBy(c => c.Order))
         {
             foreach (Category category in command.Categories)
             {
                 if (fav.Category.CategoryName == category.CategoryName)
                 {
                     commands.Add(command.Name);
                 }
             }
         }
         //устанавливаем соединение
         FavoriteConnect connect = new FavoriteConnect();
         connect.commands = commands;
         connect.favorite = fav;
         connect.task     = task;
         try
         {
             Connection(connect);
         }
         catch (Exception ex)
         {
             //записать в логи!!!
             Logging(string.Format("TASK {0} failed!!! Exception: {1}!!!", taskId, ex.Message));
         }
     }
     //************************************************************
     //создаем событие и уведомляем о том, что все задачи выполнены
     taskCompleted();
 }
Exemplo n.º 37
0
 /*
  * The entity framework DbContext and ObjectContext classes are NOT thread-safe. So you should not use them over multiple threads.
  * Although it seems like you're only passing entities to other threads, it's easy to go wrong at this, when lazy loading is involved.
  * This means that under the covers the entity will callback to the context to get some more data.
  * So instead, I would advice to convert the list of entities to a list of special immutable data structures that only need the data that is needed for the calculation.
  * Those immutable structures should not have to call back into the context and should not be able to change.
  * When you do this, it will be safe to pass them on to other threads to do the calculation.
  */
 private void LoadConfiguration(RemoteTask task)
 {
     ProgressInit();
     try
     {
         foreach (Favorite fav in task.Favorites)
         {
             current++;
             ProgressStep(fav.Address);
             List <string> commands = new List <string>();
             //проходим по списку команд, выявляем соответствие используемой команды и категории избранного
             foreach (Command command in task.Commands.OrderBy(c => c.Order))
             {
                 foreach (Category category in command.Categories)
                 {
                     if (fav.Category.CategoryName == category.CategoryName)
                     {
                         commands.Add(command.Name);
                     }
                 }
             }
             //устанавливаем соединение
             FavoriteConnect connect = new FavoriteConnect();
             connect.commands = commands;
             connect.favorite = fav;
             connect.task     = task;
             Connection(connect);
         }
         MessageBox.Show("Task is complete!", "Task Progress", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ProgressFinish();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 38
0
        public RemoteTask <IParseResult> ParseAsync(string scriptCode, ScriptingOptions Options, Func <MethodInfo[], MethodInfo> EntryMethodSelector, Func <MethodInfo, IParameter[]> EntryMethodParameterFactory)
        {
            MethodInfo entryMethod;
            Assembly   assembly = GetOrCreateScriptAssembly(new IParameter[0], scriptCode, scriptCode, Options, null, out entryMethod);

            Type submissionType = entryMethod.DeclaringType;  // eg typeof(Submission#0)

            MethodInfo[] entryMethodCandidates = GetEntryMethodCandidatesFrom(submissionType);

            MethodInfo parsedEntryMethod = EntryMethodSelector(entryMethodCandidates);

            if (parsedEntryMethod == null)
            {
                throw new InvalidOperationException("No entry method function when parsing script");
            }

            IParameter[] parsedParameters = EntryMethodParameterFactory(parsedEntryMethod);

            string refactoredCode = RefactorCodeToCallEntryMethod(scriptCode, parsedEntryMethod, parsedParameters);

            var result = new ParseResult(refactoredCode, parsedParameters, parsedEntryMethod.Name);

            return(RemoteTask.ServerStart <IParseResult>(cts => Task.FromResult <IParseResult>(result)));
        }
Exemplo n.º 39
0
 public void start()
 {
     try
     {
         channel = new TcpChannel();
         ChannelServices.RegisterChannel(channel, false);
         server = (RemoteTask)Activator.GetObject(typeof(RemoteTask), "tcp://localhost:8080/ShellSort");
         Console.Write("Лабораторная работа №2 \n Автор: Ануфриев И.С. \n гр. 13-В-1 \n ShellSort \n");
         server.CreateNewClient();
         ID = server.getID() - 1;
         server.ShellSort(ID);
         for (int i = 0; i < server.massive.GetLength(1); i++)
         {
             Console.Write(server.massive[ID, i] + " ");
         }
         Console.ReadKey();
     }
     catch (SystemException)
     {
         Console.WriteLine("Соединение было потеряно, завершение работы.\n"
                           + "Нажмите для продолжения...");
         Console.ReadKey();
     }
 }
Exemplo n.º 40
0
 public bool CreateDynamicElement(RemoteTask remoteTask)
 {
     Add(TaskMessage.CreateDynamicElement(remoteTask));
     return(true);
 }
Exemplo n.º 41
0
 public bool TaskExplain(RemoteTask remoteTask, string explanation)
 {
     Add(TaskMessage.TaskExplain(remoteTask, explanation));
     return(true);
 }
Exemplo n.º 42
0
 public bool TaskFinished(RemoteTask remoteTask, string message, TaskResult result)
 {
     Add(TaskMessage.TaskFinished(remoteTask, message, result));
     return(true);
 }
Exemplo n.º 43
0
 public bool IsAssemblyTask(RemoteTask task)
 {
     return task is MsTestTestAssemblyTask;
 }
Exemplo n.º 44
0
 public static IEnumerable <TaskMessage> ForEqualTask(this IEnumerable <TaskMessage> taskMessages, RemoteTask task)
 {
     return(taskMessages.Where(m => Equals(m.Task, task)));
 }
Exemplo n.º 45
0
 public bool IsMethodTask(RemoteTask task)
 {
     return(task.GetType().FullName == "XunitContrib.Runner.ReSharper.RemoteRunner.XunitTestMethodTask");
 }
Exemplo n.º 46
0
 private NUnitTestFixtureTask GetTask(RemoteTask task)
 {
     return (NUnitTestFixtureTask)task;
 }
Exemplo n.º 47
0
 public bool IsClassTask(RemoteTask task)
 {
     return task is NUnitTestFixtureTask;
 }
Exemplo n.º 48
0
        public string GetFullClassName(RemoteTask task)
        {
            var classTask = GetTask(task);

            return classTask.TypeName;
        }
Exemplo n.º 49
0
        //добавить задачу
        private void TaskAdd()
        {
            currentTask             = new RemoteTask();
            currentTask.TaskName    = textBoxName.Text.Trim();
            currentTask.Description = textBoxDesc.Text.Trim();
            currentTask.Date        = DateTime.UtcNow;

            HashSet <Favorite> favs = new HashSet <Favorite>();

            //если устройства выбраны по устройствам
            if (byFavorite)
            {
                foreach (var item in checkedListBoxFavorites.CheckedItems)
                {
                    string favorite = item.ToString();
                    var    queryFav = (from c in context.Favorites
                                       where c.Hostname == favorite
                                       select c).FirstOrDefault();

                    if (queryFav != null)
                    {
                        favs.Add(queryFav);
                    }
                }
            }
            //по категориям устройств
            else
            {
                foreach (var item in checkedListBoxFavorites.CheckedItems)
                {
                    string category      = item.ToString();
                    var    queryCategory = (from c in context.Categories
                                            where c.CategoryName == category
                                            select c).FirstOrDefault();

                    if (queryCategory != null)
                    {
                        foreach (Favorite fav in queryCategory.Favorites)
                        {
                            favs.Add(fav);
                        }
                    }
                }
            }
            currentTask.Favorites = favs;
            HashSet <Command> commands = new HashSet <Command>();

            foreach (var item in checkedListBoxCommands.CheckedItems)
            {
                string command      = item.ToString();
                var    queryCommand = (from c in context.Commands
                                       where c.Name == command
                                       select c).FirstOrDefault();

                if (queryCommand != null)
                {
                    commands.Add(queryCommand);
                }
            }
            currentTask.Commands = commands;
            context.RemoteTasks.Add(currentTask);
            context.SaveChanges();
        }
Exemplo n.º 50
0
 public override bool Equals(RemoteTask other)
 {
     return(Equals(other as NBehaveAssemblyTask));
 }
Exemplo n.º 51
0
 public override bool Equals(RemoteTask other)
 {
     return(Equals(other as NBehaveExampleParentTask));
 }
 public PerContextRunListener(IRemoteTaskServer server, RemoteTask contextNode)
 {
   _server = server;
   _contextTask = contextNode;
 }
Exemplo n.º 53
0
 public static TaskMessageAssertion AssertEqualTask(this IEnumerable <TaskMessage> taskMessages, RemoteTask task)
 {
     return(new TaskMessageAssertion(task, "equal", taskMessages.ForEqualTask(task).ToList()));
 }
Exemplo n.º 54
0
 public bool TaskError(RemoteTask remoteTask, string message)
 {
     Add(TaskMessage.TaskError(remoteTask, message));
     return(true);
 }
Exemplo n.º 55
0
        public string GetAssemblyLocation(RemoteTask task)
        {
            var assemblyTask = GetTask(task);

            return assemblyTask.AssemblyLocation;
        }
Exemplo n.º 56
0
 public bool TaskException(RemoteTask remoteTask, TaskException[] exceptions)
 {
     Add(TaskMessage.TaskException(remoteTask, exceptions));
     return(true);
 }
Exemplo n.º 57
0
 private MsTestTestAssemblyTask GetTask(RemoteTask task)
 {
     return (MsTestTestAssemblyTask)task;
 }
Exemplo n.º 58
0
 public bool TaskOutput(RemoteTask remoteTask, string text, TaskOutputType outputType)
 {
     Add(TaskMessage.TaskOutput(remoteTask, text, outputType));
     return(true);
 }
Exemplo n.º 59
0
 public override bool Equals(RemoteTask other)
 {
     return(Equals(other as FacadeTaskWrapper));
 }
Exemplo n.º 60
0
 public bool IsMethodTask(RemoteTask task)
 {
     return task.GetType().FullName == "XunitContrib.Runner.ReSharper.RemoteRunner.XunitTestMethodTask";
 }