Пример #1
0
        public async Task <ResultHolder <int> > IsConnectionAlive(int blind_test_id, string connectionId)
        {
            ResultHolder <int> r = new ResultHolder <int>();

            try
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    var ret = await connection.QueryAsync <int>("dbo.spIsConnectionAlive", new { BlindTestId = blind_test_id, ConnectionId = connectionId }, null, null, CommandType.StoredProcedure);

                    if (ret.Count() > 0)
                    {
                        r.Result = ret.FirstOrDefault();
                    }
                    else
                    {
                        r.Error = "Feilet i å få resultatet fra SQL-proc som registrerer deltakere!";
                    }
                }
            }
            catch (Exception ex)
            {
                r.Error = ex.Message;
            }
            return(r);
        }
Пример #2
0
        private static void SheetImport(Tk5ListMetaData metaInfos, DataTable dataTable, ISheet sheet,
            ResultHolder resultHolder)
        {
            if (sheet != null)
            {
                // resultHolder.SheetName = metaInfos.Table.TableDesc;
                Dictionary<string, Tk5FieldInfoEx> dicOfInfo = new Dictionary<string, Tk5FieldInfoEx>();
                foreach (Tk5FieldInfoEx info in metaInfos.Table.TableList)
                {
                    dicOfInfo.Add(info.DisplayName, info);
                }

                IRow headerRow = sheet.GetRow(0);
                for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
                {
                    IRow row = sheet.GetRow(i);
                    DataRow dataRow = dataTable.NewRow();
                    for (int j = row.FirstCellNum; j < row.LastCellNum; j++)
                    {
                        string columnName = headerRow.GetCell(j).ToString();
                        string strValue = row.GetCell(j).ToString();
                        ImportResult imResult = TablePadding(dataRow, columnName, dicOfInfo, strValue, i);
                        if (imResult != null)
                        {
                            resultHolder.Add(imResult);
                        }
                    }
                    dataTable.Rows.Add(dataRow);
                }
            }
        }
Пример #3
0
        public static DataSet ExcelImport(string strFileName, Tk5ListMetaData metaInfos, ResultHolder resultHolder)
        {
            DataSet dataSet = new DataSet();
            DataTable dataTable = DataSetUtil.CreateDataTable(metaInfos.Table.TableName, metaInfos.Table.TableList);
            string sheetName = metaInfos.Table.TableDesc;
            HSSFWorkbook hssfworkbook = null;
            XSSFWorkbook xssfworkbook = null;
            ISheet sheet = null;

            string fileExt = Path.GetExtension(strFileName);
            using (FileStream file = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
            {
                if (fileExt == ".xls")
                    hssfworkbook = new HSSFWorkbook(file);
                else if (fileExt == ".xlsx")
                    xssfworkbook = new XSSFWorkbook(file);
            }

            if (hssfworkbook != null)
            {
                sheet = hssfworkbook.GetSheet(sheetName);
            }
            else if (xssfworkbook != null)
            {
                sheet = xssfworkbook.GetSheet(sheetName);
            }

            SheetImport(metaInfos, dataTable, sheet, resultHolder);
            dataSet.Tables.Add(dataTable);
            return dataSet;
        }
Пример #4
0
        public void When_some_of_scheduled_jobs_fail_System_still_executes_others()
        {
            var successTasks = new[] { 0.5, 1.5, 2.5 };
            var failTasks    = new[] { 1.0, 2.0 };

            foreach (var task in successTasks)
            {
                var text        = task.ToString(CultureInfo.InvariantCulture);
                var testCommand = new SuccessCommand(text);
                _scheduler.Tell(new ScheduleCommand(testCommand, new ScheduleKey(Guid.Empty, text, text), CreateOptions(task, Timeout)));
            }
            foreach (var failTask in failTasks)
            {
                var text            = failTask.ToString(CultureInfo.InvariantCulture);
                var failTaskCommand = new FailCommand();
                _scheduler.Tell(new ScheduleCommand(failTaskCommand, new ScheduleKey(Guid.Empty, text, text), CreateOptions(failTask, Timeout)));
            }

            var successTaskIds = successTasks.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();
            var failTaskIds    = failTasks.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

            Throttle.Assert(() =>
            {
                ResultHolder.Contains(successTaskIds);
                Assert.True(failTaskIds.All(x => ResultHolder.Get(x) == null));
            }, minTimeout: TimeSpan.FromSeconds(3));
        }
Пример #5
0
        public void When_tasks_get_deleted_after_scheduling_System_will_not_execute_them()
        {
            var successTasks  = new[] { 0.5, 1.5, 2.5 };
            var tasksToRemove = new[] { 1.0, 2.0 };

            foreach (var task in successTasks.Concat(tasksToRemove))
            {
                var text        = task.ToString(CultureInfo.InvariantCulture);
                var testMessage = new SuccessCommand(text);
                _scheduler.Tell(new ScheduleCommand(testMessage, new ScheduleKey(Guid.Empty, text, text), CreateOptions(task, Timeout)));
            }

            var successTaskIds       = successTasks.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();
            var tasksToRemoveTaskIds = tasksToRemove.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

            foreach (var taskId in tasksToRemoveTaskIds)
            {
                _scheduler.Tell(new Unschedule(new ScheduleKey(Guid.Empty, taskId, taskId)));
            }

            Throttle.Assert(() =>
            {
                ResultHolder.Contains(successTaskIds);
                Assert.True(tasksToRemoveTaskIds.All(x => ResultHolder.Get(x) == null));
            }, minTimeout: TimeSpan.FromSeconds(4));
        }
Пример #6
0
    private void SetWinner(ResultHolder resultHolder)
    {
        winner = resultHolder.result.winAmount;
        winner = winner / 100f; //Convert winner from cents to dollars

        //    text.text = "" + resultHolder.player.balance;
    }
Пример #7
0
        public async Task ApplyVotes(string blind_test_id, string brand_name, string abv, string override_mode)
        {
            string error = "";

            abv = (abv ?? "").Replace(",", ".");
            int rounds = 0;
            int b_id   = 0;

            if (int.TryParse(blind_test_id, out int id) && float.TryParse(abv, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out float f_abv) && int.TryParse(override_mode, out int o_mode))
            {
                b_id = id;
                ResultHolder <int> ret = await PollController.Instance.ApplyVotes(id, brand_name, f_abv, o_mode);

                error = ret.Error;
                if (string.IsNullOrEmpty(ret.Error))
                {
                    rounds = await PollController.Instance.GetNumberOfRounds(id);

                    await Clients.Others.votesAreApplied(new { Result = "Success", Error = "", BlindTestId = b_id, Rounds = rounds });
                }
            }
            else
            {
                error = "Kunne ikke registrere denne runden - en eller flere av parametrene lot seg ikke konvertere!";
            }
            await Clients.Caller.pollApplyVotesResponse(new { Result = string.IsNullOrEmpty(error) ? "Success" : "Failure", Error = error, BlindTestId = b_id, Rounds = rounds });
        }
Пример #8
0
        public async Task <ResultHolder <int> > AddParticipant(int blind_test_id, string username, string connectionId, string connectionId_client)
        {
            ResultHolder <BlindTest> bt = await GetBlindTest(blind_test_id);

            ResultHolder <int> r = new ResultHolder <int>();

            if (string.IsNullOrEmpty(bt.Error))
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    var ret = await connection.QueryAsync <ResultHolder <int> >("dbo.spAddParticipant"
                                                                                , new { BlindTestId = blind_test_id, UserName = username, ConnectionId = connectionId, ConnectionIdClient = connectionId_client }
                                                                                , null, null, CommandType.StoredProcedure);

                    if (ret.Count() > 0)
                    {
                        r = ret.FirstOrDefault();
                    }
                    else
                    {
                        r.Error = "Feilet i å få resultatet fra SQL-proc som registrerer deltakere!";
                    }
                }
            }
            else
            {
                r.Error = "Blindtest (Id = " + blind_test_id.ToString() + ") eksisterer ikke - kan ikke registrere bruker!";
            }
            return(r);
        }
Пример #9
0
        public async Task <ResultHolder <string> > GetScoreBoard(int blind_test_id)
        {
            ResultHolder <string> r = new ResultHolder <string>();

            try
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    var ret = await connection.QueryAsync <Score>("dbo.spScoreBoard"
                                                                  , new { BlindTestId = blind_test_id }
                                                                  , null, null, CommandType.StoredProcedure);

                    if (ret.Count() > 0)
                    {
                        r.Result = Score.Parse((List <Score>)ret);
                    }
                    else
                    {
                        throw new Exception("Fant ikke noe resultat for denne blindtesten");
                    }
                }
            }
            catch (Exception ex)
            {
                r.Error = ex.Message;
            }
            return(r);
        }
Пример #10
0
        public void Then(
            Delegate fulfilledHandler, Delegate errorHandler = null, Delegate progressHandler = null)
        {
            var req = new XMLHttpRequest();

            req.OnReadyStateChange = () => {
                if (req.ReadyState != AjaxReadyState.Done)
                {
                    return;
                }

                if (req.Status >= 200 && req.Status < 400)
                {
                    Logger.Debug(GetType(), "upload success");
                    fulfilledHandler?.Call(null, ResultHolder <XMLHttpRequest> .CreateSuccess(req));
                    return;
                }

                Logger.Debug(GetType(), "upload error");
                fulfilledHandler?.Call(
                    null, ResultHolder <XMLHttpRequest> .CreateFailure(req.ResponseText, null, req));
            };
            req.Open(_method, _url, true);

            req.SetRequestHeader("Cache-Control", "no-cache");
            req.SetRequestHeader("Pragma", "no-cache");

            var tzOffset = Script.Eval <string>("new Date().getTimezoneOffset() + \"\"");

            req.SetRequestHeader(Philadelphia.Common.Model.Magics.TimeZoneOffsetFieldName, tzOffset);

            try {
                var tzCode = Script.Eval <object>("Intl.DateTimeFormat().resolvedOptions().timeZone");
                if (Script.IsDefined(tzCode))
                {
                    req.SetRequestHeader(Philadelphia.Common.Model.Magics.TimeZoneCodeFieldName, tzCode.ToString());
                }
            } catch (Exception) {
                //most likely it is unsupported
                Logger.Error(GetType(), "could not determine timeZone");
            }

            if (CsrfToken != null)
            {
                req.SetRequestHeader(Philadelphia.Common.Model.Magics.CsrfTokenFieldName, CsrfToken);
            }

            if (_frmData != null)
            {
                req.Send(_frmData);
            }
            else
            {
                req.Send(_dataToPost);
            }
        }
Пример #11
0
        public async Task <ResultHolder <BlindTest> > GetBlindTest(int blind_test_id)
        {
            ResultHolder <BlindTest> r = new ResultHolder <BlindTest>();

            try
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    //var ret = await connection.QueryAsync<BlindTest>("SELECT * FROM dbo.BlindTest Where Id=@Id", new { Id = blind_test_id });

                    var ret = await connection.QueryAsync <BlindTest>(
                        @"SELECT a.*, b.Rounds, IsRoundActive = CONVERT(bit, IIF(c.Antall <> 0, 1, 0))
                  FROM dbo.BlindTest AS a
                  CROSS APPLY (SELECT Rounds = COUNT(distinct RoundNo) from [dbo].[Round] WHERE BlindTestId=@bt_Id) AS b
                  CROSS APPLY (SELECT Antall = COUNT(*) from [dbo].[CurrentRound] WHERE BlindTestId=@bt_Id) AS c
                  Where a.Id=@bt_Id", new { bt_Id = blind_test_id });

                    if (ret.Count() > 0)
                    {
                        r.Result = ret.FirstOrDefault();
                    }
                    else
                    {
                        r.Error = "Fant ikke blindtest (Id = " + blind_test_id.ToString() + ")";
                    }

                    //var cv = await connection.QueryAsync<CurrentVote>(
                    //   @"SELECT a.ParticipantId, ParticipantName = b.[Name], ImageIndex = IIF(c.img_id < 10, '0', '') + CONVERT(nvarchar(10), c.img_id)
                    //     FROM dbo.CurrentRound as a
                    //     INNER JOIN dbo.Participant as b on a.ParticipantId = b.Id
                    //     CROSS APPLY(SELECT img_id = a.ParticipantId % 10) AS c
                    //     WHERE a.BlindTestId=@bt_Id", new { bt_Id = blind_test_id });
                    var cv = await connection.QueryAsync <CurrentVote>(
                        @"SELECT a.ParticipantId, ParticipantName = b.[Name], b.ImageIndex
                    FROM dbo.CurrentRound as a
                    INNER JOIN dbo.Participant as b on a.ParticipantId = b.Id
                    CROSS APPLY(SELECT img_id = a.ParticipantId % 10) AS c
                    WHERE a.BlindTestId=@bt_Id", new { bt_Id = blind_test_id });

                    if (cv.Count() > 0)
                    {
                        foreach (var item in cv)
                        {
                            r.Result.CurrentVotes.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                r.Error = ex.Message;
            }
            return(r);
        }
Пример #12
0
        public override async Task <IEnumerable <T> > ParseRowsAsync(DbDataReader reader, IEnumerable <IDataTransformer> dataTransformers, CancellationToken token)
        {
            var results = new ResultHolder();

            foreach (var t in ParseRows(reader, token, rf => rf.ParseRowsAsync(reader, dataTransformers, token)))
            {
                results.AddResults(t.Item1.ItemType, await t.Item2);
            }

            return(BuildHierarchy(results));
        }
Пример #13
0
 public ResultHolder Merge(ResultHolder other)
 {
     return(new ResultHolder()
     {
         AddTime = this.AddTime + other.AddTime,
         GetTime = this.GetTime + other.GetTime,
         ForeachTime = this.ForeachTime + other.ForeachTime,
         RemoveTime = this.RemoveTime + other.RemoveTime,
         TotalTime = this.TotalTime + other.TotalTime
     });
 }
Пример #14
0
    private void OnEnable()
    {
        foreach (Result result in XMLController.instance.resultContainer.Results)
        {
            ResultHolder resultHolder = Instantiate(RoundPrefab, transform).GetComponent <ResultHolder>();

            resultHolder.PlayerName.text = result.PlayerName;
            resultHolder.EnemyName.text  = result.EnemyName;
            resultHolder.Result.text     = result.result;
            resultHolder.SpendTime.text  = result.SpendTime.ToString();
        }
    }
Пример #15
0
        private void On_RepairFinished()
        {
            var item = InputHolder.CurrentItem;

            InputHolder.SetItem(null);
            ResultHolder.SetItem(item);

            foreach (var reqItem in RequiredItems)
            {
                m_Inventory.RemoveItems(reqItem.Name, reqItem.Needs);
            }
        }
Пример #16
0
        public async Task RequestResult(string blind_test_id)
        {
            if (int.TryParse(blind_test_id, out int bt_id))
            {
                ResultHolder <string> ret = await PollController.Instance.GetResult(bt_id);

                await Clients.Caller.requestResultResponse(new { ret.Result, ret.Error });
            }
            else
            {
                await Clients.Caller.requestResultResponse(new { Result = "", Error = "Sendt inn blindtest-ID var ikke numerisk" });
            }
        }
Пример #17
0
        IEnumerator FillRows(Vector3 origin, Vector3 offset)
        {
            var  acc = origin;
            bool filled;

            do
            {
                acc += offset;
                var filledResult = new ResultHolder <bool>();
                yield return(FillRow(acc, filledResult));

                filled = filledResult.Value;
            } while (filled);
        }
Пример #18
0
        public void When_there_are_several_scheduled_jobs_System_executes_all_of_them()
        {
            var tasks = new[] { 0.5, 0.6, 0.7, 0.8, 1 };

            foreach (var task in tasks)
            {
                var text        = task.ToString(CultureInfo.InvariantCulture);
                var testMessage = new SuccessCommand(text);
                _scheduler.Tell(new ScheduleCommand(testMessage, new ScheduleKey(Guid.Empty, text, text), CreateOptions(task, Timeout)));
            }

            var taskIds = tasks.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

            Throttle.Assert(() => ResultHolder.Contains(taskIds));
        }
Пример #19
0
        //public Task<BlindTest> GetNewBlindTest(string test_name, out string error)
        //{
        //   error = "";
        //   int id = _tests.Count > 0 ? (_tests.Keys.Max() + 1) : 1;
        //   BlindTest test = new BlindTest { Id = id };
        //   test.Name = test_name ?? test.Name;
        //   _tests.Add(id, test);
        //   return Task.FromResult(test);
        //}

        public async Task <ResultHolder <int> > GetNewBlindTest(string test_name)
        {
            int       id   = _tests.Count > 0 ? (_tests.Keys.Max() + 1) : 1;
            BlindTest test = new BlindTest {
                Id = id
            };

            test.Name = test_name ?? test.Name;
            _tests.Add(id, test);
            //IntResult r = new IntResult { Code = id, Error = "" };
            ResultHolder <int> r = new ResultHolder <int> {
                Result = id, Error = ""
            };

            return(r);
        }
Пример #20
0
        //public bool IsConnectionAlive(int blind_test_id, string connectionId, out int participant_id, out string username)
        //{
        //   participant_id = -1;
        //   username = "";
        //   if (_tests.ContainsKey(blind_test_id))
        //   {
        //      return _tests[blind_test_id].IsConnectionAlive(connectionId, out participant_id, out username);
        //   }
        //   return false;
        //}

        public async Task <ResultHolder <int> > IsConnectionAlive(int blind_test_id, string connectionId)
        {
            ResultHolder <int> r  = new ResultHolder <int>();
            int    participant_id = -1;
            string username       = "";

            if (_tests.ContainsKey(blind_test_id))
            {
                if (_tests[blind_test_id].IsConnectionAlive(connectionId, out participant_id, out username))
                {
                    // Bruker ikke username lenger - er kun med fordi jeg ikke har endret signaturen til BlindTest::IsConnectionAlive
                    r.Result = participant_id;
                }
            }
            return(r);
        }
Пример #21
0
        private static void TestMapConcurrent(IMap <int, int> map, int nrThreads, StreamWriter writer)
        {
            var threads = new List <Thread>();
            var results = new List <ResultHolder>();

            for (int i = 0; i < nrThreads; i++)
            {
                var from   = 0 + (i * 1000);
                var to     = 1000 + (i * 1000);
                var thread = new Thread(() =>
                {
                    var res = ExecuteTest(map, from, to);

                    lock (results)
                    {
                        results.Add(res);
                    }
                });

                threads.Add(thread);
            }

            foreach (var thread in threads)
            {
                thread.Start();
            }

            foreach (var thread in threads)
            {
                thread.Join();
            }

            var result = new ResultHolder();

            foreach (var res in results)
            {
                result = result.Merge(res);
            }

            writer.WriteLine("Count: " + map.Count);
            writer.WriteLine("Add milisecs: " + result.AddTime);
            writer.WriteLine("Get milisecs: " + result.GetTime);
            writer.WriteLine("Foreach: " + result.ForeachTime);
            writer.WriteLine("Remove milisecs: " + result.RemoveTime);
            writer.WriteLine("Time: " + result.TotalTime);
            writer.WriteLine();
        }
Пример #22
0
        private void Raise_GivenRegisteredHandler_ThenHandlerIsCalledOnRaisedEvent()
        {
            // Arrange
            var resultHolder = new ResultHolder();

            _kernel.Bind <IResultHolder>().ToConstant(resultHolder);
            _kernel.Bind <IDomainEventHandler <MyDomainEvent> >().To <MyHandler>().InThreadScope();
            var sut = new DomainEvents(_kernel);

            // Act
            sut.Raise(new MyDomainEvent {
                Id = ExpectedDomainEventId
            });

            // Assert
            Assert.Equal(ExpectedDomainEventId, resultHolder.ResultingValue);
        }
Пример #23
0
        public async Task GetBlindTest(string id)
        {
            BlindTest bt    = null;
            string    error = "";

            // Regelen blir at hvis vi mottar noe annet enn et nummer så startes en ny blindtest
            if (!int.TryParse(id, out int blind_test_id))
            {
                // Start en ny blindtest
                ResultHolder <int> ret = await PollController.Instance.GetNewBlindTest(id);

                if (string.IsNullOrEmpty(ret.Error))
                {
                    ResultHolder <BlindTest> r = await PollController.Instance.GetBlindTest(ret.Result);

                    if (string.IsNullOrEmpty(r.Error))
                    {
                        bt = r.Result;
                    }
                    else
                    {
                        error = r.Error;
                    }
                }
                else
                {
                    error = ret.Error;
                }
            }
            else
            {
                // Prøv å finn en eksisterende blindtest
                ResultHolder <BlindTest> r = await PollController.Instance.GetBlindTest(blind_test_id);

                if (string.IsNullOrEmpty(r.Error))
                {
                    bt = r.Result;
                }
                else
                {
                    error = r.Error;
                }
            }
            await Clients.Caller.pollGetBlindTestResponse(new { Result = string.IsNullOrEmpty(error) ? "Success" : "Failure", Error = error, Instance = bt });
        }
Пример #24
0
        public async Task WhenMessageIsPosted_TargetApplicationProcessesItOnce()
        {
            var subscriber = Resolver.Get <IQueueSubscriber>();

            subscriber.Subscribe <TestHandler, TestMessage>();
            var publisher = Resolver.Get <IQueuePublisher>();
            var listener  = Resolver.Get <QueueListener>();
            await listener.Start("test", CancellationToken.None);

            var testMessage = CreateMessage();

            publisher.Publish(testMessage);
            Throttle.Assert(
                () => ResultHolder.Contains(testMessage.Id) && ResultHolder.Count == 1,
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(6)
                );
        }
Пример #25
0
        public async Task WhenMessageWithSlightlyDifferentStructureButWithSameTopicIsPosted_ItCanbeProcessed()
        {
            var subscriber = Resolver.Get <IQueueSubscriber>();

            subscriber.Subscribe <SlightlyDifferentTestHandler, SlightlyDifferentTestMessage>();
            var publisher = Resolver.Get <IQueuePublisher>();
            var listener  = Resolver.Get <QueueListener>();
            await listener.Start("test", CancellationToken.None);

            var testMessage = CreateMessage();

            publisher.Publish(testMessage);
            Throttle.Assert(
                () => ResultHolder.Contains(testMessage.Id) && ResultHolder.Count == 1,
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(6)
                );
        }
Пример #26
0
        public async Task WhenNMessagesAreSentAsync_TheyAreHandledSimultaneously(int messagesCount)
        {
            var subscriber = Resolver.Get <IQueueSubscriber>();

            subscriber.Subscribe <TimeConsumingHandler, TestMessage>();
            var publisher = Resolver.Get <IQueuePublisher>();
            var listener  = Resolver.Get <QueueListener>();
            await listener.Start("test", CancellationToken.None);

            var testMessages = Enumerable.Range(0, messagesCount).Select(x => CreateMessage()).ToArray();
            await Task.WhenAll(testMessages.Select(testMessage => publisher.PublishAsync(testMessage)));

            Throttle.Assert(
                () => ResultHolder.Contains(testMessages.Select(x => x.Id).ToArray()) && ResultHolder.Count == testMessages.Length,
                TimeSpan.FromSeconds(4),
                TimeSpan.FromSeconds(5)
                );
        }
Пример #27
0
        public async Task WhenMessageSendWithoutSubscribers_ThenMessageShouldBeSentAfterSubscribing()
        {
            var publisher   = Resolver.Get <IQueuePublisher>();
            var testMessage = CreateMessage();

            publisher.Publish(testMessage);
            var subscriber = Resolver.Get <IQueueSubscriber>();

            subscriber.Subscribe <TimeConsumingHandler, TestMessage>();
            var listener = Resolver.Get <QueueListener>();
            await listener.Start("test", CancellationToken.None);

            Throttle.Assert(
                () => ResultHolder.Contains(testMessage.Id) && ResultHolder.Count == 1,
                TimeSpan.FromSeconds(4),
                TimeSpan.FromSeconds(5)
                );
        }
    public static void runner()
    {
        // need to run the test in a domain so that we can deal with unhandled exceptions
        var ad         = AppDomain.CreateDomain("Inner Domain");
        var helperType = typeof(TaskAwaiterOnCompletedHelper);
        var helper     = (TaskAwaiterOnCompletedHelper)ad.CreateInstanceAndUnwrap(helperType.Assembly.ToString(), helperType.FullName);
        var holder     = new ResultHolder();

        helper.TheTest(holder);
        // HACK: If everything went well, a thread is running in the other domain and is blocked in OnUnhandled
        // waiting for AllDone().  Don't send it.  Instead just exit without waiting.  If we send AllDone, the
        // process will terminate with a 255.  Don't try to unload the domain either, since the other thread
        // will never finish.
        //
        //helper.AllDone();
        //AppDomain.Unload (ad);
        Environment.Exit(holder.Result);
    }
Пример #29
0
        public void When_scheduler_is_restarted_Then_scheduled_jobs_still_get_executed()
        {
            var tasks = new[] { 0.5, 1, 1.5, 2, 2.5 };

            foreach (var task in tasks)
            {
                var text        = task.ToString(CultureInfo.InvariantCulture);
                var testMessage = new SuccessCommand(text);
                _scheduler.Tell(new ScheduleCommand(testMessage, new ScheduleKey(Guid.Empty, text, text), CreateOptions(task, Timeout)));
            }

            _quartzScheduler.Shutdown(false);
            CreateScheduler();

            var taskIds = tasks.Select(x => x.ToString(CultureInfo.InvariantCulture)).ToArray();

            Throttle.Assert(() => ResultHolder.Contains(taskIds));
        }
        public OutputData DoAction(IInputData input)
        {
            NPOIRead.CreateExcelTemplate(fMetaData);

            string strName = @"D:\ImportTest.xls";
            ResultHolder rh = new ResultHolder();
            DataSet dSet = null;
            try
            {
                dSet = NPOIRead.ExcelImport(strName, fMetaData, rh);
            }
            catch
            { 
            }

            return OutputData.Create(dSet);

        }
Пример #31
0
        public async Task <ResultHolder <int> > GetNewBlindTest(string test_name)
        {
            ResultHolder <int> r = new ResultHolder <int>();

            try
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    var ret = await connection.QueryAsync <int>("dbo.spGetNewBlindTest", new { BlindTestName = test_name }, null, null, CommandType.StoredProcedure);

                    r.Result = ret.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                r.Error = ex.Message;
            }
            return(r);
        }
Пример #32
0
        public async Task <ResultHolder <string> > RemoveConnection(string connectionId)
        {
            ResultHolder <string> r = new ResultHolder <string>();

            try
            {
                using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Help.Helper.CnnVal("syse_db")))
                {
                    var ret = await connection.QueryAsync <string>("dbo.spRemoveConnection", new { ConnectionId = connectionId }, null, null, CommandType.StoredProcedure);

                    r.Result = ret.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                r.Error = ex.Message;
            }
            return(r);
        }
Пример #33
0
        IEnumerator FillRow(Vector3 origin, ResultHolder <bool> result = null)
        {
            var points = new HashSet <Vector2>();

            yield return(FillContactsPointsAtSide(origin, Vector3.forward, points));

            yield return(FillContactsPointsAtSide(origin, Vector3.back, points));

            yield return(FillContactsPointsAtSide(origin, Vector3.left, points));

            yield return(FillContactsPointsAtSide(origin, Vector3.right, points));

            var createResult = TryCreateRow(points, origin);

            if (result != null)
            {
                result.Value = createResult;
            }
        }