Пример #1
0
        public MessageEntity Update(FeatureEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var data = _uow.Db.SingleOrDefault <FeatureEntity>("SELECT * FROM Feature WHERE Id=@0", entity.Id);
                    if (data != null && data.Id == entity.Id)
                    {
                        entity.CreatedBy   = data.CreatedBy;
                        entity.CreatedDate = data.CreatedDate;
                        _uow.Db.Update(entity);
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;
                        msgEntity.result  = true;
                        msgEntity.code    = 0;
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoGroupPage, "Update : ", ex.ToString());
            }

            return(msgEntity);
        }
Пример #2
0
        public FeatureListEntity GetAll(FeatureEntity entity, long pageIndex, long pageSize)
        {
            var list = new FeatureListEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var query = PetaPoco.Sql.Builder.Append(@"SELECT * FROM Feature");
                    query.Append("ORDER BY ModifiedDate DESC");
                    var result = _uow.Db.Page <FeatureEntity>(pageIndex, pageSize, query);
                    if (result != null && result.TotalItems > 0)
                    {
                        list.List      = result.Items;                     // danh sách data trả về
                        list.PageTotal = result.TotalPages;                // tổng số Pages
                        list.PageIndex = result.CurrentPage;               // Page hiện tại của data duoc trả về
                        list.Count     = Protector.Int(result.TotalItems); //  count data
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoFeature, "GetAll : ", ex.ToString());
            }
            return(list);
        }
Пример #3
0
        public async Task <string> Handle(AddFeatureRequest request, CancellationToken cancellationToken)
        {
            var product = await _storeDbContext
                          .Products
                          .Where(p => p.Name == request.ProductName)
                          .SingleOrDefaultAsync(cancellationToken);

            if (product != null)
            {
                var existingFeature = await _storeDbContext
                                      .Features
                                      .Where(f => f.Name == request.Name && f.ProductEntityId == product.Id)
                                      .SingleOrDefaultAsync(cancellationToken);

                if (existingFeature == null)
                {
                    var feature = new FeatureEntity(product.Id, request.Name, request.Archived, request.Description);
                    _storeDbContext.Add(feature);

                    await _storeDbContext.SaveChangesAsync(cancellationToken);

                    return(feature.Name);
                }
                else
                {
                    Log.FeatureNameAlreadyExist(_logger, request.Name);
                    throw new InvalidOperationException($"A feature with the same name already exist on the store.");
                }
            }
            else
            {
                Log.ProductNotExist(_logger, request.ProductName);
                throw new InvalidOperationException($"The product with id {request.ProductName} does not exist in the store.");
            }
        }
        private DetailsConfigurationResponse CreateResponse(FeatureEntity featureEntity, string currentDeploymentName, string defaultDeploymentName)
        {
            var status = featureEntity
                         .FeatureStates
                         .Where(r => r.DeploymentEntity.Name == currentDeploymentName)
                         .SingleOrDefault();

            var feature = new DetailsConfigurationResponse
            {
                FeatureName = featureEntity.Name,
                Enabled     = status?.Enabled ?? false
            };

            foreach (var toggleConfiguration in featureEntity.Toggles)
            {
                var type       = toggleConfiguration.Type;
                var parameters = new Dictionary <string, object>();

                var groupingParameters = toggleConfiguration.Parameters
                                         .GroupBy(g => g.DeploymentName);

                var defaultDeploymentParameters = groupingParameters
                                                  .Where(g => g.Key == defaultDeploymentName)
                                                  .SingleOrDefault();

                if (defaultDeploymentParameters != null
                    &&
                    defaultDeploymentParameters.Any())
                {
                    foreach (var item in defaultDeploymentParameters)
                    {
                        parameters.Add(item.Name, item.Value);
                    }
                }

                if (currentDeploymentName != defaultDeploymentName)
                {
                    var selectedDeploymentParameters = groupingParameters
                                                       .Where(g => g.Key == currentDeploymentName)
                                                       .SingleOrDefault();

                    if (selectedDeploymentParameters != null
                        &&
                        selectedDeploymentParameters.Any())
                    {
                        foreach (var item in selectedDeploymentParameters)
                        {
                            if (parameters.ContainsKey(item.Name))
                            {
                                parameters[item.Name] = item.Value;
                            }
                        }
                    }
                }

                feature.Toggles.TryAdd(type, parameters);
            }

            return(feature);
        }
        void AddData(StoreDbContext dbContext)
        {
            if (!dbContext.Products.Any())
            {
                var product = new ProductEntity("default", "description");
                dbContext.Products.Add(product);

                dbContext.SaveChanges();

                var appFeature = new FeatureEntity(product.Id, "app-feature", enabled: true);

                var toggle = new ToggleEntity(appFeature.Id, "Esquio.Toggles.XToggle");

                var stringparameter = new ParameterEntity(toggle.Id, "strparam", "value1");
                toggle.Parameters.Add(stringparameter);

                var intparameter = new ParameterEntity(toggle.Id, "intparam", "1");
                toggle.Parameters.Add(intparameter);

                appFeature.Toggles.Add(toggle);

                dbContext.Features.Add(appFeature);

                dbContext.SaveChanges();
            }
        }
        private Feature ConvertToFeatureModel(FeatureEntity featureEntity)
        {
            var feature = new Feature(featureEntity.Name);

            if (featureEntity.Enabled)
            {
                feature.Enabled();
            }
            else
            {
                feature.Disabled();
            }

            foreach (var toggleConfiguration in featureEntity.Toggles)
            {
                var toggle = new Toggle(toggleConfiguration.Type);

                toggle.AddParameters(toggleConfiguration
                                     .Parameters
                                     .Select(p => new Parameter(p.Name, p.Value)));

                feature.AddToggle(toggle);
            }

            return(feature);
        }
        public void FeatureAvailabilityMix()
        {
            var Source_A = new SourceEntity();

            Source_A.AddSourceItem(800, 1000, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability);
            var Source_B = new SourceEntity();

            Source_B.AddSourceItem(90, 100, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability);
            var Indicators = new List <IndicatorEntity>()
            {
                new IndicatorEntity()
                {
                    Id     = 1,
                    Source = Source_A
                },
                new IndicatorEntity()
                {
                    Id     = 2,
                    Source = Source_B
                }
            };
            var entity = new FeatureEntity()
            {
                Id         = 1,
                Name       = "test",
                Indicators = Indicators
            };

            var result = entity.Measure();

            Assert.Equal(0.85m, result.Availability);
        }
        public void FeatureDateAvailabilityAggregateSuccess()
        {
            var sourceEntity = new SourceEntity()
            {
            };

            sourceEntity.AddSourceItem(800, 1000, OwlveyCalendar.January201903, DateTime.Now, "test", SourceGroupEnum.Availability);

            var entity = new FeatureEntity()
            {
                Id         = 1,
                Name       = "test",
                Indicators = new List <IndicatorEntity>()
                {
                    new IndicatorEntity()
                    {
                        Id     = 1,
                        Source = sourceEntity
                    }
                }
            };

            var result = entity.Measure();

            Assert.Equal(0.8m, result.Availability);
        }
Пример #9
0
        public MessageEntity Create(FeatureEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    int Id = Protector.Int(_uow.Db.Insert(entity));
                    if (Id > 0)
                    {
                        msgEntity.code    = 0;
                        msgEntity.result  = true;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;

                        _uow.Commit();
                    }
                    else
                    {
                        msgEntity.code    = -2;
                        msgEntity.result  = false;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_ERR;
                    }
                }
            }
            catch (Exception ex)
            {
                msgEntity.code    = -1;
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoFeature, "Create : ", ex.ToString());
            }
            return(msgEntity);
        }
Пример #10
0
 //更新所有拖期系统需求列表写入
 private void UpdateOneRowForAnadonFeatures(int currentRow, FeatureEntity feature, bool child)
 {
     sheet.Cells[currentRow, "B"] = (child == true) ? "'  " + feature.Id : "" + feature.Id;
     sheet.Cells[currentRow, "C"] = feature.KeyApplicationName;
     sheet.Cells[currentRow, "E"] = feature.ModulesName;
     sheet.Cells[currentRow, "G"] = feature.ModulesName;
     sheet.Cells[currentRow, "I"] = (child == true) ? "  " + feature.Title : feature.Title;
     sheet.Cells[currentRow, "M"] = feature.NeedRequireDevelop;
     sheet.Cells[currentRow, "N"] = feature.State;
     sheet.Cells[currentRow, "O"] = DateTime.Parse(feature.TargetDate).AddHours(8).ToString("yyyy-MM-dd");
     if (String.IsNullOrEmpty(feature.PlanRequireFinishDate) == false)
     {
         sheet.Cells[currentRow, "P"] = DateTime.Parse(feature.PlanRequireFinishDate).AddHours(8).ToString("yyyy-MM-dd");
     }
     if (String.IsNullOrEmpty(feature.RequireFinishedDate) == false)
     {
         sheet.Cells[currentRow, "Q"] = DateTime.Parse(feature.RequireFinishedDate).AddHours(8).ToString("yyyy-MM-dd");
     }
     if (String.IsNullOrEmpty(feature.ClosedDate) == false)
     {
         sheet.Cells[currentRow, "R"] = DateTime.Parse(feature.ClosedDate).AddHours(8).ToString("yyyy-MM-dd");
     }
     sheet.Cells[currentRow, "S"] = Utility.GetPersonName(feature.AssignedTo);
     sheet.Cells[currentRow, "T"] = "";
 }
Пример #11
0
 public virtual void Read(FeatureEntity entity)
 {
     this.Id          = entity.Id.Value;
     this.Name        = entity.Name;
     this.Avatar      = entity.Avatar;
     this.Description = entity.Description;
     this.ProductId   = entity.ProductId;
 }
Пример #12
0
 public void Load(string organization, string product, FeatureEntity feature)
 {
     this.Organization = organization;
     this.Product      = product;
     this.Name         = feature.Name;
     this.Avatar       = feature.Avatar;
     this.Description  = feature.Description;
 }
Пример #13
0
        public void CheckTodaysWordcount(FeatureEntity userFeature)
        {
            if (userFeature.TodaysWords < Constants.MinimumWordCount)
            {
                userFeature.StreakLevel = 0;
            }

            userFeature.TodaysWords = 0;
        }
Пример #14
0
        public ExportExcelFeatureRp(FeatureEntity feature)
        {
            this.FeatureId = feature.Id.Value;
            this.Name      = feature.Name;
            var measure = feature.Measure();

            this.Availability = measure.Availability;
            this.Latency      = measure.Latency;
            this.Experience   = measure.Experience;
        }
Пример #15
0
        public ExportExcelJourneyDetailRp(JourneyMapEntity map)
        {
            JourneyEntity journey = map.Journey;
            FeatureEntity feature = map.Feature;

            this.JourneyId       = journey.Id.Value;
            this.FeatureId       = feature.Id.Value;
            this.Journey         = journey.Name;
            this.Feature         = feature.Name;
            this.AvailabilitySLO = journey.AvailabilitySlo;
            this.JourneyQuality  = journey.Measure().Availability;
        }
Пример #16
0
        public ExportExcelFeatureDetailRp(IndicatorEntity indicator)
        {
            FeatureEntity feature = indicator.Feature;

            this.FeatureId = feature.Id.Value;
            this.SourceId  = indicator.SourceId;
            this.Feature   = feature.Name;
            this.Source    = indicator.Source.Name;
            var measure = indicator.Source.Measure();

            this.Availability = measure.Availability;
            this.Experience   = measure.Experience;
            this.Latency      = measure.Latency;
        }
Пример #17
0
 /// <summary>
 /// Takes the specified permission.
 /// </summary>
 /// <param name="permission">The permission.</param>
 /// <returns></returns>
 private object[] Take(FeatureEntity permission)
 {
     return(new object[]
     {
         "@FeatureID", permission.FeatureID,
         "@Code", permission.Code,
         "@Name", permission.Name,
         "@ParentID", permission.ParentID,
         "@MenuItemCode", permission.MenuItemCode,
         "@Description", permission.Description,
         "@IsActive", permission.IsActive,
         "@FormMasterName", permission.FormMasterName,
         "@FormDetailName", permission.FormDetailName
     });
 }
Пример #18
0
            public static IndicatorEntity GenerateSourceItems(ProductEntity product, FeatureEntity feature)
            {
                var source = TestDataFactory.BuildSource(product);

                var indicator = IndicatorEntity.Factory.Create(feature, source, DateTime.Now, Guid.NewGuid().ToString());

                var sourceItem = SourceEntity.Factory.CreateItem(source, OwlveyCalendar.StartJanuary2019,
                                                                 900, 1200, DateTime.Now, "test", SourceGroupEnum.Availability);

                var sourceItemA = SourceEntity.Factory.CreateItem(source,
                                                                  OwlveyCalendar.EndJanuary2019, 900, 1200, DateTime.Now, "test", SourceGroupEnum.Availability);

                source.SourceItems.Add(sourceItem);
                source.SourceItems.Add(sourceItemA);

                indicator.Source = source;

                return(indicator);
            }
Пример #19
0
        public FeatureEntity GetById(int id)
        {
            var entity = new FeatureEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    entity = _uow.Db.SingleOrDefault <FeatureEntity>("SELECT * FROM Feature WHERE Id=@0", id);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoFeature, "GetById : ", ex.ToString());
            }

            return(entity);
        }
Пример #20
0
        public void AddWords(FeatureEntity userFeature, SocketMessage msg)
        {
            var wordCountBefore = userFeature.TodaysWords;

            var wordCount = Helper.MessageReplace(msg.Content).CountWords();

            if (wordCount <= 0)
            {
                return;
            }

            userFeature.TotalWords  += wordCount;
            userFeature.TodaysWords += wordCount;
            if (userFeature.TodaysWords >= Constants.MinimumWordCount && wordCountBefore < Constants.MinimumWordCount)
            {
                userFeature.StreakLevel++;
                if (msg is SocketUserMessage userMsg)
                {
                    userMsg.AddReactionAsync(Constants.Fire);
                }
            }
        }
Пример #21
0
 public ToggleEntityBuilder WithFeature(FeatureEntity feature)
 {
     _featureId = feature.Id;
     return(this);
 }
Пример #22
0
        public ProductEntityBuilder WithFeature(FeatureEntity featureEntity)
        {
            _features.Add(featureEntity);

            return(this);
        }
Пример #23
0
 public FeatureDailyAvailabilityAggregate(FeatureEntity entity,
                                          DatePeriodValue period)
 {
     this.Period  = period;
     this.Feature = entity;
 }
Пример #24
0
 bool IsRolledout(FeatureEntity feature)
 {
     return(feature.Toggles.Count == 1 &&
            feature.Toggles.Single().Type.Equals(nameof(Esquio.Toggles.OnToggle), StringComparison.InvariantCulture));
 }
Пример #25
0
 bool IsRolledback(FeatureEntity feature)
 {
     return(feature.Toggles.Count == 1 &&
            feature.Toggles.Single().Type.Equals(typeof(Esquio.Toggles.OffToggle).FullName, StringComparison.InvariantCulture));
 }
Пример #26
0
 public override void Read(FeatureEntity Entity)
 {
     base.Read(Entity);
 }
Пример #27
0
        /// <summary>
        /// Inserts the feature.
        /// </summary>
        /// <param name="feature">The feature.</param>
        /// <returns></returns>
        public string InsertFeature(FeatureEntity feature)
        {
            const string procedures = @"uspInsert_Feature  ";

            return(Db.Insert(procedures, true, Take(feature)));
        }
Пример #28
0
 public int GetStreakLevel(FeatureEntity userFeature)
 {
     return(userFeature.StreakLevel);
 }
Пример #29
0
 public int GetWordsTotal(FeatureEntity userFeature)
 {
     return(userFeature.TotalWords);
 }
Пример #30
0
 public int GetWordsToday(FeatureEntity userFeature)
 {
     return(userFeature.TodaysWords);
 }