//protected override async Task ExecuteAsync(CancellationToken stoppingToken) //{ // string[] features = { "ASP.NET Core", "Blazor", "C#", "Dapper", "EF Core", "Facebook", "Google", "Microsoft" }; // while (!stoppingToken.IsCancellationRequested) // { // using (var context = new ApplicationDbContext()) // { // FeatureModel model = new FeatureModel { Title = features[DateTime.Now.Minute % 8], Created = DateTime.Now }; // context.Features.Add(model); // context.SaveChanges(); // } // _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); // await Task.Delay(60_000, stoppingToken); // } //} protected override async Task ExecuteAsync(CancellationToken stoppingToken) { //[1] 데이터베이스 연결 문자열 읽어오기 var builder = new ConfigurationBuilder(); builder.AddJsonFile("appsettings.json", optional: false); var configuration = builder.Build(); string connectionString = configuration.GetSection("ConnectionString").Value; //[2] 컨텍스트 개체 생성 var option = new DbContextOptionsBuilder <ApplicationDbContext>(); option.UseSqlServer(connectionString); var ctx = new ApplicationDbContext(option.Options); //[3] 샘플로 60초에 한번씩 문자열 데이터 입력 string[] features = { "ASP.NET Core", "Blazor", "C#", "Dapper", "EF Core", "Facebook", "Google", "Microsoft" }; while (!stoppingToken.IsCancellationRequested) { FeatureModel model = new FeatureModel { Title = features[DateTime.Now.Minute % 8], Created = DateTime.Now }; ctx.Features.Add(model); ctx.SaveChanges(); _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(60_000, stoppingToken); } }
// GET: Admin/Feature public ActionResult Index(int?Page) { int pageIndex = Protector.Int(Page, 1); // nếu page = 0 thì gán page = 1 int pageSize = ConstantsHandler.PAGE_50; var model = new FeatureModel(); var list = _featureService.GetAll(model, pageIndex, pageSize); long lCount = list.Count; #region Paging if (lCount > 0) { ViewData["Stt"] = (pageIndex - 1) * pageSize + 1; if (Paging.GetUrl(this.Request.Url.PathAndQuery) == this.Request.Url.AbsolutePath) { ViewData["Page"] = Paging.PagingAdmin(this.Request.Url.AbsolutePath, lCount, pageSize, pageIndex, 1); } else { ViewData["Page"] = Paging.PagingAdmin(Paging.GetUrl(this.Request.Url.PathAndQuery), lCount, pageSize, pageIndex, 2); } } #endregion ViewBag.Count = list.Count; return(View(list.List)); }
public async Task GetNearestSiteAsync_Success() { // Arrange var helper = new TestHelper(); var options = Options.Create(new GeocoderOptions() { Key = "test" }); var mockRequestClient = new Mock <IHttpRequestClient>(); var features = new FeatureModel() { Type = "Feature" }; var response = new HttpResponseMessage(HttpStatusCode.OK); var clientFactory = helper.CreateHttpClientFactory(response); mockRequestClient.Setup(m => m.Client).Returns(clientFactory.CreateClient()); mockRequestClient.Setup(m => m.GetAsync <FeatureModel>(It.IsAny <string>())).ReturnsAsync(features); var service = helper.Create <GeocoderService>(options, mockRequestClient.Object); var parameters = new NearestParameters() { Point = "123,456" }; // Act var result = await service.GetNearestSiteAsync(parameters); // Assert var url = "https://geocoder.api.gov.bc.ca/sites/nearest.json?point=123,456&excludeUnits=false&onlyCivic=false&outputSRS=4326&locationDescriptor=any&setBack=0&brief=false"; result.Should().NotBeNull(); mockRequestClient.Verify(m => m.GetAsync <FeatureModel>(url), Times.Once()); result.Should().Be(features); }
public HttpStatusCode Update(FeatureModel objModel) { using (var transaction = _context.Database.BeginTransaction()) { try { if (objModel != null) { string uploadImgName = ""; if (objModel.Img != null) { var uploadFolder = Path.Combine(_hosting.WebRootPath, "images"); uploadImgName = Guid.NewGuid() + "_" + objModel.Img.FileName; var uploadImgPath = Path.Combine(uploadFolder, uploadImgName); objModel.Img.CopyTo(new FileStream(uploadImgPath, FileMode.Create)); objModel.ImgUrl = uploadImgName; } var objEntity = _mapper.Map <FeatureEntity>(objModel); _context.Update(objEntity); _context.SaveChanges(); transaction.Commit(); return(HttpStatusCode.OK); } return(HttpStatusCode.BadRequest); } catch (Exception ex) { transaction.Rollback(); return(HttpStatusCode.InternalServerError); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision) { if (decision is SingleDecision) { throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. "); } featureModel.update(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex); SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex); if (instanceModel == null) { initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName); } FeatureVector fv = instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision); if (singleDecision.continueWithNextDecision() && decisionIndex + 1 < decision.numberOfDecisions()) { if (nextDecisionModel == null) { initNextDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols); } nextDecisionModel.predictExtract(featureModel, decision); } return(fv); }
public void ToDeploymentModel_WithRecursiveDependenciesInSingleMicroservice_Returns_Correctly() { var aFeature = new Feature(new FeatureIdentifier("a"), "a", new[] { new Property(new PropertyIdentifier("p1"), "p1"), new Property(new PropertyIdentifier("p2"), "p2") } ); var bFeature = new Feature(new FeatureIdentifier("b"), "b", new[] { new Property(new PropertyIdentifier("p3"), "p3"), new Property(new PropertyIdentifier("p4"), "p4") } ); var cFeature = new Feature(new FeatureIdentifier("c"), "c", new[] { new Property(new PropertyIdentifier("p5"), "p5"), new Property(new PropertyIdentifier("p6"), "p6"), new Property(new PropertyIdentifier("p7"), "p7") } ); var featureModel = new FeatureModel(new[] { aFeature, bFeature, cFeature }, new[] { new PropertyRelation(new PropertyIdentifier("p6"), new PropertyIdentifier("p4")), new PropertyRelation(new PropertyIdentifier("p4"), new PropertyIdentifier("p2")) }); var genes = new[] { new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")), new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("b")), new DeploymentGene(new FeatureIdentifier("c"), new MicroserviceIdentifier("c")) }; var sot = new DeploymentChromosome(featureModel, genes); var deploymentModel = new DeploymentModel(featureModel, new[] { new Microservice(new[] { new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p1"), new PropertyIdentifier("p2") }), }), new Microservice(new [] { new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p2") }, true), new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p3"), new PropertyIdentifier("p4") }) }), new Microservice(new [] { new FeatureInstance(cFeature, new[] { new PropertyIdentifier("p5"), new PropertyIdentifier("p6"), new PropertyIdentifier("p7") }), new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p4") }, true), new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p2") }, true) }), }); Assert.AreEqual(deploymentModel, sot.ToDeploymentModel()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision) { if (decision is SingleDecision) { throw new GuideException("A branched decision model expect more than one decisions. "); } featureModel.update(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex); SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex); if (instanceModel == null) { initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName); } FeatureVector fv = instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision); if (decisionIndex + 1 < decision.numberOfDecisions()) { if (singleDecision.continueWithNextDecision()) { DecisionModel child = children[singleDecision.DecisionCode]; if (child == null) { child = initChildDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols + (branchedDecisionSymbols.Length == 0?"":"_") + singleDecision.DecisionSymbol); children[singleDecision.DecisionCode] = child; } child.predictExtract(featureModel, decision); } } return(fv); }
/// <summary> /// Validation ClosingDate each WorkModel /// </summary> /// <param name="isCreateWork">Validate in Create or Edit process</param> /// <param name="project">Project to validate</param> /// <param name="feature">Feature to validate</param> /// <param name="story">Story to validate</param> /// <param name="task">Task to validate</param> /// <returns>Result of validation</returns> private bool ValidateClosingDate(bool isCreateWork, ProjectModel project, FeatureModel feature, StoryModel story = null, TaskModel task = null) { var validateProject = project != null; if (!validateProject) { return(false); } var isVerifyFeature = feature != null && story == null && task == null; var isVerifyStory = feature != null && story != null && task == null; var isVerifyTask = feature != null && story != null && task != null; var errorTitleCategory = isCreateWork ? "สร้าง" : "แก้ไข"; var workCategory = isVerifyFeature ? "งานหลัก" : isVerifyStory ? "งานรอง" : "งานย่อย"; var value = isVerifyFeature ? feature as WorkModel : isVerifyStory ? story as WorkModel : task as WorkModel; var isValidClosingDate = isCreateWork ? value.ClosingDate.Date >= DateTime.Now.Date : value.ClosingDate.Date >= value.CreateDate.Date; if (!isValidClosingDate) { var postErrorMessage = isCreateWork ? "วันที่ปัจจุบัน" : "วันที่สร้าง"; ViewBag.ErrorTitle = $"ไม่สามารถ{errorTitleCategory}{workCategory}ได้"; ViewBag.ErrorMessage = $"เนื่องจาก: วันที่คาดการณ์งานต้องเสร็จสิ้นของ{workCategory} น้อยกว่า{postErrorMessage}"; return(false); } var isValidClosingDateWithProject = value.ClosingDate.Date <= project.ClosingDate.Date; if (!isValidClosingDateWithProject) { ViewBag.ErrorTitle = $"ไม่สามารถ{errorTitleCategory}{workCategory}ได้"; ViewBag.ErrorMessage = $"เนื่องจาก: วันที่คาดการณ์งานต้องเสร็จสิ้นของ{workCategory} มากกว่าวันที่เสร็จสิ้นของโปรเจค"; return(false); } if (isVerifyStory) { var isValidClosingDateWithFeature = value.ClosingDate.Date <= feature.ClosingDate.Date; if (!isValidClosingDateWithFeature) { ViewBag.ErrorTitle = $"ไม่สามารถ{errorTitleCategory}{workCategory}ได้"; ViewBag.ErrorMessage = $"เนื่องจาก: วันที่คาดการณ์งานต้องเสร็จสิ้นของ{workCategory} มากกว่าวันที่เสร็จสิ้นของงานหลัก"; return(false); } } if (isVerifyTask) { var isValidClosingDateWithStory = value.ClosingDate.Date <= story.ClosingDate.Date; if (!isValidClosingDateWithStory) { ViewBag.ErrorTitle = $"ไม่สามารถ{errorTitleCategory}{workCategory}ได้"; ViewBag.ErrorMessage = $"เนื่องจาก: วันที่คาดการณ์งานต้องเสร็จสิ้นของ{workCategory} มากกว่าวันที่เสร็จสิ้นของงานรอง"; return(false); } } return(true); }
public MessageModel Update(FeatureModel model) { var msg = new MessageModel(); try { if (model.Id <= 0) { msg.result = false; msg.message = "Id Incorrect !"; return(msg); } msg = ValidateFeature(model); if (msg.result.Equals(false)) { return(msg); } var mapperEntity = Mapper.Map <FeatureModel, FeatureEntity>(model); var msgEntity = _featureRepository.Update(mapperEntity); msg = Mapper.Map <MessageEntity, MessageModel>(msgEntity); } catch (Exception ex) { Logger.ErrorLog(ConstantsHandler.ForderLogName.ServiceBranch, "Update : ", ex.ToString()); } return(msg); }
public int SaveFeature(FeatureModel feature) { using (IDbConnection conn = _factory.CreateConnection()) { conn.Open(); Dictionary <string, object> parameters = new Dictionary <string, object>(); if (feature.Id > 0) { parameters.Add("@name", feature.Name); parameters.Add("@description", feature.Description); parameters.Add("@toggle", feature.Toggle); conn.ExecuteNonQuery("INSERT INTO Feature (Name, Description, Toggle) VALUES (@name, @description, @toggle)", CommandType.Text, parameters); } else { parameters.Add("@id", feature.Id); parameters.Add("@name", feature.Name); parameters.Add("@description", feature.Description); parameters.Add("@toggle", feature.Toggle); conn.ExecuteNonQuery("UPDATE Feature SET Name = @name, @description = Description Toggle = @toogle WHERE Id = @id", CommandType.Text, parameters); } return(0); } }
public IActionResult CreateFeature(FeatureModel model) { ViewBag.IsLogin = !string.IsNullOrEmpty(cache.GetString("user")); if (ViewBag.IsLogin) { ViewBag.User = JsonConvert.DeserializeObject <AccountModel>(cache.GetString("user")); } else { return(RedirectToAction("Login", "Account")); } if (ModelState.IsValid) { var project = projectSvc.GetProject(model.Project_id); var isValid = ValidateClosingDate(true, project, model); if (!isValid) { PrepareDataForDisplay(model.Project_id); return(View(model)); } model.ClosingDate = model.ClosingDate.AddDays(1); if (!string.IsNullOrEmpty(model.BeAssignedMember_id)) { model.AssginByMember_id = model.CreateByMember_id; } featureSvc.CreateFeature(model); return(RedirectToAction("Index", "Project", new { projectid = model.Project_id })); } return(View(model)); }
public IEnumerator <TestCaseData> GetEnumerator() { var features = new[] { new Feature(new FeatureIdentifier("a"), "a", new[] { new Property(new PropertyIdentifier("p1"), "p1"), }), new Feature(new FeatureIdentifier("b"), "b", new[] { new Property(new PropertyIdentifier("p2"), "p2"), }) }; var relations = new[] { new PropertyRelation(new PropertyIdentifier("p1"), new PropertyIdentifier("p2")), }; var featureModel = new FeatureModel(features, relations); var identicalFeatureModel = new FeatureModel(features.ToArray(), relations.ToArray()); var otherRelations = new FeatureModel(features, Enumerable.Empty <PropertyRelation>()); var moreFeatureList = features.ToList(); moreFeatureList.Add(new Feature(new FeatureIdentifier("c"), "c", new [] { new Property(new PropertyIdentifier("p3"), "p3") })); var moreFeatures = new FeatureModel(moreFeatureList, relations); yield return(new TestCaseData(featureModel, featureModel).Returns(true)); yield return(new TestCaseData(featureModel, identicalFeatureModel).Returns(true)); yield return(new TestCaseData(featureModel, new FeatureModel(features.Reverse(), relations.Reverse())).Returns(true)); yield return(new TestCaseData(featureModel, otherRelations).Returns(false)); yield return(new TestCaseData(featureModel, moreFeatures).Returns(false)); yield return(new TestCaseData(featureModel, null).Returns(false)); yield return(new TestCaseData(featureModel, 3).Returns(false)); }
public void Constructor_WithInvalidRelations_ThrowsException() { Assert.Throws <ArgumentException>(() => { var featureModel = new FeatureModel(_features, new [] { new PropertyRelation(new PropertyIdentifier("b"), new PropertyIdentifier("c")), }); }); }
// GET: Feature public async Task <ActionResult> Index() { try { var results = new FeatureModel(); //Call API Provider controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var list = await APIProvider.Authorize_Get <List <FeatureViewModel> >(_userSession.BearerToken, controllerName, APIConstant.API_Resource_CMS, ARS.Get); var model = new FeatureViewModel(); results.lstFeatureViewModel = list; results.FeatureViewModel = model; return(View(results)); } catch (HttpException ex) { Logger.LogError(ex); int statusCode = ex.GetHttpCode(); if (statusCode == 401) { TempData["Alert"] = ApplicationGenerator.RenderResult(FuntionType.Department, APIConstant.ACTION_ACCESS); return(new HttpUnauthorizedResult()); } throw ex; } }
public ResponseModel GetCitysByType(string t = "CN") { if (_handle == null) { _handle = new MapHandle(); } ResponseModel responseModel = new ResponseModel(); try { responseModel.description = "请求数据成功!"; responseModel.success = true; DataTable dt = _handle.GetCitysByType(t); if (dt != null) { List <CityModel> lsCity = dt.DataTableToList <CityModel>(); FeatureModel features = new FeatureModel(); features.displayFieldName = "city"; features.primaryFieldName = "code"; features.features = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(lsCity));//(Contact[])ls.ToArray(); responseModel.response = features; } } catch (Exception ex) { responseModel.description = ex.Message.ToString(); responseModel.success = false; responseModel.response = JsonConvert.DeserializeObject("{}"); } return(responseModel); }
public void Cross_WithMultipleGene_Returns_Correctly() { var featureModel = new FeatureModel(Enumerable.Empty <Feature>(), Enumerable.Empty <PropertyRelation>()); var chromosome = new DeploymentChromosome(featureModel, new[] { new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")), new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("b")), new DeploymentGene(new FeatureIdentifier("c"), new MicroserviceIdentifier("c")), }); var randomProvider = A.Fake <IRandomProvider>(); A.CallTo(() => randomProvider.GetRandom(0, 0)).WithAnyArguments().ReturnsNextFromSequence(0, 1, 0, 1); var sot = new MergeMicroserviceCrossover(randomProvider); var result = sot.Cross(new[] { chromosome, chromosome }).ToArray(); var expected = new DeploymentChromosome(featureModel, new[] { new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")), new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("a")), new DeploymentGene(new FeatureIdentifier("c"), new MicroserviceIdentifier("c")), }); CollectionAssert.AreEqual(new[] { expected, expected }, result); }
public void ToDeploymentModel_WithoutDependencies_Returns_Correctly() { var aFeature = new Feature(new FeatureIdentifier("a"), "a", new[] { new Property(new PropertyIdentifier("p1"), "p1") } ); var bFeature = new Feature(new FeatureIdentifier("b"), "b", new[] { new Property(new PropertyIdentifier("p2"), "p2") } ); var featureModel = new FeatureModel(new[] { aFeature, bFeature }, Enumerable.Empty <PropertyRelation>()); var genes = new[] { new DeploymentGene(new FeatureIdentifier("a"), new MicroserviceIdentifier("a")), new DeploymentGene(new FeatureIdentifier("b"), new MicroserviceIdentifier("b")) }; var sot = new DeploymentChromosome(featureModel, genes); var deploymentModel = new DeploymentModel(featureModel, new[] { new Microservice(new[] { new FeatureInstance(aFeature, new[] { new PropertyIdentifier("p1") }) }), new Microservice(new[] { new FeatureInstance(bFeature, new[] { new PropertyIdentifier("p2") }) }), }); Assert.AreEqual(deploymentModel, sot.ToDeploymentModel()); }
private IEnumerable <FeatureModel> Union(IEnumerable <Feature> items) { var query = from cate in FeatureTypeHelper.Items.Where(t => t.FeatureType != FeatureType.None) join item in items on cate.Name equals item.ActId into features from feature in features.DefaultIfEmpty() select new { category = cate, feature = feature }; var data = query.Select(t => { var m = new FeatureModel { flag = 0, code = t.category.Name, name = t.category.Summary }; if (null != t.feature) { m.flag = 1; m.id = t.feature.Id; } return(m); }); return(data); }
private static object GetDerivedValue(FeatureModel feature) { if (feature.Value == null) { return(null); } switch (feature.DataType) { case 0: return(bool.Parse(feature.Value)); case 1: return(int.Parse(feature.Value)); case 2: return(DateTime.Parse(feature.Value)); case 3: return(feature.Value); case 4: return(decimal.Parse(feature.Value)); default: return(null); } }
public async Task Should_post_feature_data() { var contract = new FeatureModelResponseContract { Id = 1, Name = "isButtonPurple", IsActive = true }; var model = new FeatureModel { Name = "isButtonPurple", IsActive = true }; _featureAppService.Add(model).Returns(new FeatureModelResponse(1, "isButtonPurple", true)); var response = await _featureController.Post(model); response.Should().NotBeNull(); var okResult = response.Should().BeOfType <OkObjectResult>().Subject; var applicationResponseModel = okResult.Value.Should().BeAssignableTo <FeatureModelResponse>().Subject; contract.Should().BeEquivalentTo(applicationResponseModel); }
public HttpStatusCode Save(FeatureModel objModel) { if (objModel != null) { try { string uploadImgName = ""; if (objModel.Img != null) { var uploadFolder = Path.Combine(_hosting.WebRootPath, "images"); uploadImgName = Guid.NewGuid() + "_" + objModel.Img.FileName; var uploadImgPath = Path.Combine(uploadFolder, uploadImgName); objModel.Img.CopyTo(new FileStream(uploadImgPath, FileMode.Create)); objModel.ImgUrl = uploadImgName; } var objEntity = _mapper.Map <FeatureEntity>(objModel); _context.Features.Add(objEntity); _context.SaveChanges(); return(HttpStatusCode.OK); } catch { return(HttpStatusCode.InternalServerError); } } return(HttpStatusCode.BadRequest); }
public void EditFeature(FeatureModel model) { var status = statusCollection.Find(it => it.StatusName == model.StatusName).FirstOrDefault(); if (status != null && status.IsWorkDone) { model.WorkDoneDate = DateTime.Now; } else { model.WorkDoneDate = null; } featureCollection.FindOneAndUpdate( Builders <FeatureModel> .Filter.Eq(it => it._id, model._id), Builders <FeatureModel> .Update .Set(it => it.Name, model.Name) .Set(it => it.Description, model.Description) .Set(it => it.WorkReport, model.WorkReport) .Set(it => it.AssginByMember_id, model.AssginByMember_id) .Set(it => it.BeAssignedMember_id, model.BeAssignedMember_id) .Set(it => it.StatusName, model.StatusName) .Set(it => it.WorkDoneDate, model.WorkDoneDate) .Set(it => it.ClosingDate, DateTime.SpecifyKind(model.ClosingDate, DateTimeKind.Local)) ); assignSvc.UpdateAssignment(model._id, model.BeAssignedMember_id, model.StatusName, WorkType.Feature); }
private void AddToCache(FeatureModel feature) { var featureJson = JsonSerializer.Serialize <FeatureModel>(feature); var encodedFeature = Encoding.UTF8.GetBytes(featureJson); _cache.Set(feature.Name, encodedFeature); }
public async Task <IActionResult> EditFeature(FeatureModel request) { if (ModelState.IsValid) { var result = await _WorkSVC.UpdateFeature(request, User); if (!result) { ViewBag.ErrorMessage = "ไม่สามารถแก้ไขข้อมูลงานหลักได้ กรุณาตรวจสอบข้อมูล"; var qry = await _membershipSVC.GetMemberships(request.Project_id); ViewBag.AssignmentList = qry.Select(it => it.MemberUserName); return(View(request)); } return(RedirectToAction(nameof(Detail), new { id = request.Project_id })); } else { ViewBag.ErrorMessage = "ไม่สามารถแก้ไขข้อมูลงานหลักได้ กรุณาตรวจสอบข้อมูล"; var qry = await _membershipSVC.GetMemberships(request.Project_id); ViewBag.AssignmentList = qry.Select(it => it.MemberUserName); return(View(request)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean predictFromKBestList(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException public virtual bool predictFromKBestList(FeatureModel featureModel, GuideDecision decision) { if (decision is SingleDecision) { throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. "); } bool success = false; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex); SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex); // TODO develop different strategies for resolving which kBestlist that should be used if (nextDecisionModel != null && singleDecision.continueWithNextDecision()) { success = nextDecisionModel.predictFromKBestList(featureModel, decision); } if (!success) { success = singleDecision.updateFromKBestList(); if (success && singleDecision.continueWithNextDecision() && decisionIndex + 1 < decision.numberOfDecisions()) { if (nextDecisionModel == null) { initNextDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols); } nextDecisionModel.predict(featureModel, decision); } } return(success); }
/// <summary> /// Adds child Confeaturator nodes to a given node. /// </summary> /// <param name="node">The node to which children should be added.</param> private void AddChildFeatureModelNodes(FeatureModelTreeNode node) { FeatureModelElement fmElement = node.FeatureModelElement; foreach (FeatureModelElement childFMElement in fmElement.SubFeatureModelElements) { node.Nodes.Add(CreateFeatureModelTreeNode(childFMElement)); } // cross-feature model logic Feature feature = fmElement as Feature; if (feature != null) { if (feature.IsReference && !addedFeatures.Contains(feature.Name)) { FeatureModel definitionFeatureModel = Util.LoadFeatureModel(DTEHelper.GetFullProjectItemPath(feature.DefinitionFeatureModelFile)); Feature definitionFeature = definitionFeatureModel.GetFeature(feature.Name); if (definitionFeature != null) { foreach (FeatureModelElement childFMElement in definitionFeature.SubFeatureModelElements) { node.Nodes.Add(CreateFeatureModelTreeNode(childFMElement)); } } } addedFeatures.Add(feature.Name); } }
/// <summary> /// Parse feature section key/value collection except Enabled and Options keys from the configuration and populate feature model. /// </summary> private static void ParseFeatureItems(string feature, FeatureModel featureModel, IEnumerable <KeyValuePair <string, string> > featureItems) { featureModel.Items = new Dictionary <string, string>(); foreach (var featureItem in featureItems) { if (featureItem.Value == null) { continue; } var itemKey = featureItem.Key.Replace($"{feature}:", string.Empty); if (itemKey.Contains(":")) { continue; } if (itemKey == "Enabled") { bool.TryParse(featureItem.Value, out var enabled); featureModel.Enabled = enabled; } else { featureModel.Items.Add(itemKey, featureItem.Value); } } }
public async Task <bool> UpdateFeature(FeatureModel request, ClaimsPrincipal User) { var isDataValid = request != null && !string.IsNullOrEmpty(request._id) && !string.IsNullOrEmpty(request.WorkName) && User != null; if (!isDataValid) { return(false); } var Username = _UserManager.GetUserName(User); var member_collection = database.GetCollection <MembershipModel>(mongoDB.MembershipCollection); var beMember = await member_collection.FindAsync(it => it.MemberUserName == Username && it.Project_id == request.Project_id); var member = beMember.FirstOrDefault(); if (member == null) { return(false); } request.AssignBy = member.MemberUserName; var feature_collection = database.GetCollection <FeatureModel>(mongoDB.FeatureCollection); await feature_collection.ReplaceOneAsync(it => it._id == request._id, request); return(true); }
public ResponseModel GetListAll(int instate = -1) { if (_handle == null) { _handle = new TourismHandle(); } ResponseModel responseModel = new ResponseModel(); try { responseModel.description = "请求数据成功!"; responseModel.success = true; DataTable dt = _handle.GetSource(instate); if (dt != null) { List <TourismModel> lsTourism = dt.DataTableToList <TourismModel>(); FeatureModel features = new FeatureModel(); features.displayFieldName = "name"; features.primaryFieldName = "id"; features.features = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(lsTourism));//(Contact[])ls.ToArray(); responseModel.response = features; } } catch (Exception ex) { responseModel.description = ex.Message.ToString(); responseModel.success = false; responseModel.response = JsonConvert.DeserializeObject("{}"); } return(responseModel); }
public ResponseModel GetItemDescription(int m = -1, int c = -1) { if (_handle == null) { _handle = new CurrencyHandle(); } ResponseModel responseModel = new ResponseModel(); try { responseModel.description = "请求数据成功!"; responseModel.success = true; DataTable dt = _handle.GetDescriptionById(m, c); if (dt != null) { List <DescriptionModel> lsDescription = dt.DataTableToList <DescriptionModel>(); FeatureModel features = new FeatureModel(); features.displayFieldName = "name"; features.primaryFieldName = "id"; features.features = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(lsDescription));//(Contact[])ls.ToArray(); responseModel.response = features; } } catch (Exception ex) { responseModel.description = ex.Message.ToString(); responseModel.success = false; responseModel.response = JsonConvert.DeserializeObject("{}"); } return(responseModel); }