Exemplo n.º 1
0
        private void SampleRenderingStatus_(Dictionary <RunningRender, RenderRequest> runningRenders, List <string> ids, List <RenderStatusResults> renderStatusResultsList)
        {
            logger_.Verbose("enter - renderStatusResultsList size: {0}", renderStatusResultsList.Count);

            for (int i = renderStatusResultsList.Count - 1; i >= 0; i--)
            {
                RenderStatusResults renderStatusResults = renderStatusResultsList[i];
                if (renderStatusResults == null)
                {
                    continue;
                }

                RenderStatus renderStatus     = renderStatusResults.Status;
                bool         isRenderedStatus = renderStatus == RenderStatus.Rendered;
                bool         isErrorStatus    = renderStatus == RenderStatus.Error;
                logger_.Verbose("renderStatusResults - {0}", renderStatusResults);
                if (isRenderedStatus || isErrorStatus)
                {
                    string removedId = ids[i];
                    ids.RemoveAt(i);

                    foreach (KeyValuePair <RunningRender, RenderRequest> kvp in runningRenders)
                    {
                        RunningRender renderedRender = kvp.Key;
                        RenderRequest renderRequest  = kvp.Value;
                        if (renderedRender.RenderId.Equals(removedId, StringComparison.OrdinalIgnoreCase))
                        {
                            VisualGridTask task = runningRenders[renderedRender].Task;

                            for (int k = openTasks_.Count - 1; k >= 0; k--)
                            {
                                VisualGridTask openTask = openTasks_[k];
                                if (openTask.RunningTest == task.RunningTest)
                                {
                                    if (isRenderedStatus)
                                    {
                                        logger_.Verbose("setting openTask {0} render result: {1} to url {2}", openTask, renderStatusResults, result_.Url);
                                        openTask.SetRenderResult(renderStatusResults);
                                    }
                                    else
                                    {
                                        logger_.Verbose("setting openTask {0} render error: {1} to url {2}", openTask, removedId, result_.Url);
                                        openTask.SetRenderError(removedId, renderStatusResults.Error, renderRequest);
                                    }
                                    openTasks_.RemoveAt(k);
                                }
                            }

                            logger_.Verbose("setting task {0} render result: {1} to url {2}", task, renderStatusResults, result_.Url);
                            task.SetRenderResult(renderStatusResults);
                            break;
                        }
                    }
                }
            }
            logger_.Verbose("exit");
        }
Exemplo n.º 2
0
        private void PollRenderingStatus_(Dictionary <RunningRender, RenderRequest> runningRenders)
        {
            logger_.Verbose("enter");
            List <string> ids       = GetRenderIds_(runningRenders.Keys);
            Stopwatch     stopwatch = Stopwatch.StartNew();

            do
            {
                List <RenderStatusResults> renderStatusResultsList = null;
                try
                {
                    renderStatusResultsList = connector_.RenderStatusById(ids.ToArray());
                }
                catch (Exception e)
                {
                    logger_.Log("Error (3): " + e);
                    continue;
                }
                if (renderStatusResultsList == null || renderStatusResultsList.Count == 0)
                {
                    logger_.Verbose("No reason to sample. (ids.Count: {0})", ids.Count);
                    Thread.Sleep(500);
                    continue;
                }
                if (renderStatusResultsList[0] == null)
                {
                    logger_.Verbose("First element is null. Total number of elements: {0}. Continuing.", renderStatusResultsList.Count);
                    Thread.Sleep(500);
                    continue;
                }
                SampleRenderingStatus_(runningRenders, ids, renderStatusResultsList);

                if (ids.Count > 0)
                {
                    Thread.Sleep(1500);
                }

                logger_.Verbose("ids.Count: {0} ; runtime: {1}", ids.Count, stopwatch.Elapsed);
            } while (ids.Count > 0 && stopwatch.Elapsed < pollTimeout_);

            foreach (string id in ids)
            {
                foreach (KeyValuePair <RunningRender, RenderRequest> kvp in runningRenders)
                {
                    RunningRender renderedRender = kvp.Key;
                    RenderRequest renderRequest  = kvp.Value;
                    if (renderedRender.RenderId.Equals(id, StringComparison.OrdinalIgnoreCase))
                    {
                        VisualGridTask task = runningRenders[renderedRender].Task;
                        logger_.Verbose("removing failed render id: {0}", id);
                        task.SetRenderError(id, "too long rendering(rendering exceeded 150 sec)", renderRequest);
                        break;
                    }
                }
            }

            ICheckSettingsInternal rcInternal = (ICheckSettingsInternal)settings_;

            logger_.Verbose("marking task as complete: {0}", rcInternal.GetName());
            IsTaskComplete = true;
            NotifySuccessAllListeners_();
            logger_.Verbose("exit");
        }