public void SetUnitTestNextTime(Guid accountId, SetUnitTestNextTimeRequestData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            if (data.UnitTestId == null)
            {
                throw new ParameterRequiredException("UnitTestId");
            }
            var cache = new AccountCache(accountId);

            using (var unitTest = cache.UnitTests.Write(data.UnitTestId.Value))
            {
                if (data.NextTime == null)
                {
                    unitTest.NextDate = DateTime.Now;
                }
                else
                {
                    unitTest.NextDate = data.NextTime.Value;
                }
                unitTest.BeginSave();
            }
        }
Beispiel #2
0
        public SetUnitTestNextTimeResponse SetUnitTestNextTime(Guid accountId, SetUnitTestNextTimeRequestData data)
        {
            var request = GetRequest <SetUnitTestNextTimeRequest>(accountId);

            request.Data = data;
            var dispatcher = DispatcherHelper.GetDispatcherService();

            return(dispatcher.SetUnitTestNextTime(request));
        }
        public void SaveCommonSettings()
        {
            var dispatcher = FullRequestContext.Current.Controller.GetDispatcherClient();

            // получим юнит-тест
            if (Id == null)
            {
                var unitTestResponse = dispatcher.GetOrCreateUnitTest(
                    User.AccountId,
                    new GetOrCreateUnitTestRequestData()
                {
                    ComponentId    = ComponentId,
                    SystemName     = "GUID_" + Guid.NewGuid(),
                    DisplayName    = CheckName,
                    UnitTestTypeId = UnitTestTypeId
                });

                unitTestResponse.Check();

                GetUnitTest(unitTestResponse.Data.Id);
            }
            else
            {
                GetUnitTest(Id.Value);
            }

            var isSystem = SystemUnitTestTypes.IsSystem(UnitTest.TypeId);

            // обновим данные юнит-теста
            var updateResponse = dispatcher.UpdateUnitTest(
                User.AccountId,
                new UpdateUnitTestRequestData()
            {
                ComponentId   = ComponentId,
                DisplayName   = CheckName,
                PeriodSeconds = Period != null ? Period.Value.TotalSeconds : (double?)null,
                ActualTime    = !isSystem ? TimeSpanHelper.GetSeconds(ActualTime) : null,
                ErrorColor    = ErrorColor.GetSelectedUnitTestResultStatuses().FirstOrDefault(),
                NoSignalColor = !isSystem ? NoSignalColor.GetSelectedColors().FirstOrDefault() : Core.Common.ObjectColor.Gray,
                UnitTestId    = UnitTest.Id,
                SimpleMode    = false
            });

            updateResponse.Check();

            var setNextTime = new SetUnitTestNextTimeRequestData()
            {
                UnitTestId = UnitTest.Id
            };

            dispatcher.SetUnitTestNextTime(User.AccountId, setNextTime).Check();

            GetUnitTest(UnitTest.Id);
        }