public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (obj.GetType() != GetType()) { return(false); } var otherSpec = obj as CompositeSpecification <TEntity>; // Assuming here that there are no duplicate specifications in composites (see "Reduce" method) if (Specifications.Count() != otherSpec.Specifications.Count()) { return(false); } return(Specifications.All(s1 => otherSpec.Specifications.Any(s2 => s2 == s1))); }
public HttpResponseMessage Create(HttpRequestMessage request, SpecificationsVM specificationVM) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState.Keys.SelectMany(k => ModelState[k].Errors).Select(m => m.ErrorMessage).ToArray()); } else { if (_specificationsRepository.SpecificationExists(specificationVM.Name)) { ModelState.AddModelError("Invalid user", "Email or Name already exists"); response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState.Keys.SelectMany(k => ModelState[k].Errors).Select(m => m.ErrorMessage).ToArray()); } else { Specifications newSpecification = new Specifications(); newSpecification = AutoMapper.Map <SpecificationsVM, Specifications>(specificationVM); _specificationsRepository.Insert(newSpecification); _specificationsRepository.Commit(); // Update view model specificationVM = AutoMapper.Map <Specifications, SpecificationsVM>(newSpecification); response = request.CreateResponse <SpecificationsVM>(HttpStatusCode.Created, specificationVM); } } return response; })); }
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit) { GridViewRow gVR = e.Row; String featId = ((Label)gVR.Cells[0].FindControl("Label_Hidden_Feat")).Text; Dictionary <String, Specifications> specDict = BackEndObjects.Features.getSpecforFeatureDB(featId); String fromSpecName = ((Label)gVR.Cells[0].FindControl("Label_From_Spec")).Text; String toSpecName = ((Label)gVR.Cells[0].FindControl("Label_ToSpec")).Text; foreach (KeyValuePair <String, Specifications> kvp in specDict) { Specifications specObj = kvp.Value; ListItem ltSpec = new ListItem(); ltSpec.Text = specObj.getSpecName(); ltSpec.Value = specObj.getSpecId(); ((DropDownList)gVR.Cells[0].FindControl("DropDownList_From_Spec_Edit")).Items.Add(ltSpec); ((DropDownList)gVR.Cells[0].FindControl("DropDownList_To_Spec_Edit")).Items.Add(ltSpec); if (specObj.getSpecName().Equals(fromSpecName)) { ((DropDownList)gVR.Cells[0].FindControl("DropDownList_From_Spec_Edit")).SelectedValue = specObj.getSpecId(); } if (specObj.getSpecName().Equals(toSpecName)) { ((DropDownList)gVR.Cells[0].FindControl("DropDownList_To_Spec_Edit")).SelectedValue = specObj.getSpecId(); } } } }
/// <summary> /// Initializes the object with a url. /// </summary> public DotNetOpcServerWrapper(Guid clsid) { m_clsid = clsid; m_progId = ConfigUtils.ProgIDFromCLSID(clsid); m_codebase = ConfigUtils.GetExecutablePath(clsid); m_specifications = GetSpecifications(clsid); }
public static string ToString(Specifications Specification) { string result; switch (Specification) { case Specifications.CM_60: result = "0001"; break; case Specifications.CM_90: result = "0002"; break; case Specifications.CM_120: result = "0003"; break; case Specifications.CM_150: result = "0004"; break; default: result = "0001"; break; } return(result); }
public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } // Kick if it has votes var spec = Specifications.GetBlindsWithNoVotes() .AndAlso(x => x.Id == id); var blind = blindRepository.Find(spec); if (blind == null) { // TODO better error?? return(NotFound()); } // Kick if its not theirs var userId = this.userManager.GetUserId(User); if (blind.CreatedByUserId != userId) { return(Unauthorized()); } Blind = mapper.Map <BlindDto>(blind); if (Blind == null) { return(NotFound()); } return(Page()); }
/// <summary> /// 保存商品规格 /// </summary> /// <param name="VatInvoiceProof"></param> /// <returns></returns> public ResultDTO SaveSpecificationsExt(Jinher.AMP.BTP.Deploy.SpecificationsDTO model) { ResultDTO dto = null; try { ContextSession contextSession = ContextFactory.CurrentThreadContext; Specifications entity = new Specifications(); entity = CommonUtil.ReadObjectExchange(entity, model); entity.EntityState = EntityState.Added; contextSession.SaveObject(entity); contextSession.SaveChanges(); dto = new ResultDTO { ResultCode = 0, Message = "保存成功", isSuccess = true }; } catch (Exception ex) { LogHelper.Error(string.Format("保存异常。Specifications:{0}", ex.Message)); dto = new ResultDTO { ResultCode = 1, Message = ex.Message, isSuccess = false }; } return(dto); }
public FormData GetFormData(int id) { FormData formData = null; try { string query = $"SELECT * FROM ShippingAddress WHERE FormId=@id"; ShippingAddress shippingAddress = _dbFactory.GetData <ShippingAddress>(_connection, new CommandDefinition(query, new { id = id })).FirstOrDefault(); query = $"SELECT * FROM BillingAddress WHERE FormId=@id"; BillingAddress billingAddress = _dbFactory.GetData <BillingAddress>(_connection, new CommandDefinition(query, new { id = id })).FirstOrDefault(); query = $"SELECT * FROM OrderDetails WHERE FormId=@id"; OrderDetails orderDetails = _dbFactory.GetData <OrderDetails>(_connection, new CommandDefinition(query, new { id = id })).FirstOrDefault(); query = $"SELECT * FROM Specifications WHERE FormId=@id"; Specifications specifications = _dbFactory.GetData <Specifications>(_connection, new CommandDefinition(query, new { id = id })).FirstOrDefault(); formData = new FormData(); formData.Specifications = specifications; formData.ShippingAddress = shippingAddress; formData.BillingAddress = billingAddress; formData.OrderDetails = orderDetails; formData.Id = id; } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } return(formData); }
private async Task <IActionResult> IsSpecificationReadyForPublish(string specificationId, ApprovalMode expectedApprovalMode) { ApiResponse <ApiSpecificationSummary> specificationIdResponse = await Specifications.GetSpecificationSummaryById(specificationId); ApiSpecificationSummary specificationSummary = specificationIdResponse.Content; if (specificationSummary == null) { return(new NotFoundResult()); } if (!specificationSummary.IsSelectedForFunding) { return(new PreconditionFailedResult($"Specification with id : {specificationId} has not been selected for funding")); } IDictionary <string, FundingConfiguration> fundingConfigurations = await _fundingConfigurationService.GetFundingConfigurations(specificationSummary); if (fundingConfigurations.Values.Any(_ => _.ApprovalMode != expectedApprovalMode)) { return(new PreconditionFailedResult($"Specification with id : {specificationId} has funding configurations which does not match required approval mode={expectedApprovalMode}")); } return(new OkObjectResult(null)); }
protected void GivenTheApiResponseDetailsForTheSuppliedId(SpecificationSummary specificationSummary, HttpStatusCode statusCode = HttpStatusCode.OK) { Specifications.GetSpecificationSummaryById(SpecificationId) .Returns(new ApiResponse <SpecificationSummary>(statusCode, specificationSummary)); }
public void Should_create_line_with_all_properties_witho_one_full_specification() { var expected = new object[] { "PartnerPartNumber", new object[] { new object[] { SpecificationType.Full, "Label", "Value", "UnitOfMeasure", "Id", "GroupId", "GroupName" } } }; var specifications = new Specifications { PartnerPartNumber = (string)expected[(int)CasSpecificationsColumnEnum.PartnerPartNumber], Items = ((object[])expected[(int)CasSpecificationsColumnEnum.Items]) .Select(x => { var option = (object[])x; return(new Specification { Type = (SpecificationType)option[(int)CasSpecificationColumnEnum.Type], Label = (string)option[(int)CasSpecificationColumnEnum.Label], Value = (string)option[(int)CasSpecificationColumnEnum.Value], UnitOfMeasure = (string)option[(int)CasSpecificationColumnEnum.UnitOfMeasure], Id = (string)option[(int)CasSpecificationColumnEnum.Id], GroupId = (string)option[(int)CasSpecificationColumnEnum.GroupId], GroupName = (string)option[(int)CasSpecificationColumnEnum.GroupName] }); }) .ToList() }; var writer = new CsvSpecificationsGenerator( new DefaultObjectPool <StringBuilder>(new StringBuilderPooledObjectPolicy())); writer.TryGenerateLine(specifications, out var data); data.Should().Be($"{string.Join("\t", expected.Select(x => x.ToDebugString()))}{Environment.NewLine}"); }
public string GetPrice() { decimal minPrice = Specifications.ElementAt(0).Price; decimal maxPirce = 0; foreach (Specification specification in Specifications) { if (specification.Price < minPrice) { minPrice = specification.Price; } else if (specification.Price > maxPirce) { maxPirce = specification.Price; } } if (minPrice == maxPirce) { return(minPrice.ToString()); } else { return(minPrice + "-" + maxPirce); } }
/// <summary> /// Finds the OPC specifications supported by the .NET server. /// </summary> private static Specifications GetSpecifications(Guid clsid) { if (clsid == Guid.Empty) { return(Specifications.None); } Specifications specifications = Specifications.None; foreach (Guid _CATID in Utils.GetImplementedCategories(clsid)) { if (_CATID == typeof(OpcRcw.Da.CATID_OPCDAServer20).GUID) { specifications |= Specifications.DA2; } if (_CATID == typeof(OpcRcw.Da.CATID_OPCDAServer30).GUID) { specifications |= Specifications.DA3; } if (_CATID == typeof(OpcRcw.Ae.CATID_OPCAEServer10).GUID) { specifications |= Specifications.AE; } if (_CATID == typeof(OpcRcw.Hda.CATID_OPCHDAServer10).GUID) { specifications |= Specifications.HDA; } } return(specifications); }
public override bool IsSatisfiedBy(T candidate) { // True if odd number of results are true var results = Specifications.Select(spec => spec.IsSatisfiedBy(candidate)); return((results.Count(r => r) & 1) == 1); }
/// <summary> /// Finds the OPC specifications supported by the .NET server. /// </summary> private Specifications GetSpecifications(System.Type systemType) { if (systemType == null) { return(Specifications.None); } Specifications specifications = Specifications.None; foreach (System.Type interfaces in systemType.GetInterfaces()) { if (interfaces.GUID == typeof(OpcRcw.Da.IOPCItemProperties).GUID) { specifications |= Specifications.DA2; } if (interfaces.GUID == typeof(OpcRcw.Da.IOPCBrowse).GUID) { specifications |= Specifications.DA3; } if (interfaces.GUID == typeof(OpcRcw.Ae.IOPCEventServer).GUID) { specifications |= Specifications.AE; } if (interfaces.GUID == typeof(OpcRcw.Hda.IOPCHDA_Server).GUID) { specifications |= Specifications.HDA; } } return(specifications); }
private void SetSpecifications(MaintenanceObject entity, IRepository repository) { var specificationsMap = entity.Specifications.ToDictionary(x => x.Specification.Id); Specifications.ToList().ForEach(x => { //Если характеристика уже существует if (specificationsMap.ContainsKey(x.SpecificationId)) { //если значения нет, то удаляем характеристику if (String.IsNullOrEmpty(x.Value?.ToString())) { entity.RemoveSpecification(specificationsMap[x.SpecificationId]); } else { specificationsMap[x.SpecificationId].Value = x.Value.ToString(); } } else { if (!String.IsNullOrEmpty(x.Value?.ToString())) { entity.AddSpecification(new ObjectSpecification( repository.Get <Specification>(x.SpecificationId), x.Value.ToString() )); } } }); }
public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } var now = this.clockService.UtcNow; var spec = Specifications .GetClosedBlinds(now) .AndAlso(x => x.Id == id); spec.FetchStrategy = Strategies .IncludeItemsAndVotes() .Include(x => x.BlindItems.First().BlindVotes.First().CreatedByUser); var blind = blindRepository.Find(spec); if (blind == null) { // TODO better error?? return(NotFound()); } if (!blind.BlindItems.Any(x => x.BlindVotes.Any())) { // TODO better error?? return(NotFound()); } Blind = mapper.Map <BlindDto>(blind); BlindItemScore = mapper.Map <List <BlindItemScoresDto> >(blind.BlindItems).OrderByDescending(x => x.TotalScore).ToList(); return(Page()); }
public HttpResponseMessage Delete(HttpRequestMessage request, SpecificationsVM specificationVM) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState.Keys.SelectMany(k => ModelState[k].Errors) .Select(m => m.ErrorMessage).ToArray()); } else { specificationVM.IsDeleted = true; Specifications _specification = _specificationsRepository.GetSingleBySpecificationsID(specificationVM.ID); _specification.UpdateSpecifications(specificationVM); _specificationsRepository.Commit(); response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }
public void SpecificationsToLower() { if (Specifications == null) { Specifications = new List <string>(); } Specifications = Specifications.Select(l => l.ToLower()); }
public override int GetHashCode() { var hashes = Specifications.Select(s => s?.GetHashCode() ?? 0) .OrderBy(h => h).ToList(); hashes.Add(GetType().GetHashCode()); return(CombineHashCodes(hashes)); }
public ActionResult DeleteConfirmed(int id) { Specifications specifications = db.Specifications.Find(id); db.Specifications.Remove(specifications); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void UpdateSpecifications(this Specifications specifications, SpecificationsVM specificationsVm) { specifications.Name = specificationsVm.Name; specifications.Description = specificationsVm.Description; specifications.ModifiedBy = specificationsVm.ModifiedBy; specifications.ModifiedOn = specificationsVm.ModifiedOn; specifications.IsDeleted = specificationsVm.IsDeleted; }
public string GetPicture() { if (Specifications.Count == 0) { return(null); } return(Specifications.ElementAt(0).Picture); }
public override void Build(Nala instance) { base.Build(instance); method.Invoke(instance, null); for (var position = 0; position < Specifications.Count(); position++) { Specifications[position].Build(instance); } }
protected override void AfterGetData() { Specifications.Clear(); Specifications.AddRange(_specifications); _specifications.PropertyChanged += (sender, args) => { SaveCommand.RaiseCanExecuteChanged(); }; }
public async Task <IActionResult> CreateRefreshFundingJob(string specificationId, Reference user, string correlationId) { ValidationResult validationResult = SpecificationIdValidator.Validate(specificationId); if (!validationResult.IsValid) { return(validationResult.AsBadRequest()); } ApiResponse <ApiSpecificationSummary> specificationIdResponse = await ResiliencePolicy.ExecuteAsync(() => Specifications.GetSpecificationSummaryById(specificationId)); ApiSpecificationSummary specificationSummary = specificationIdResponse.Content; if (specificationSummary == null) { return(new NotFoundResult()); } SpecificationFundingStatus chooseCheck = await _specificationFundingStatusService.CheckChooseForFundingStatus(specificationSummary); if (chooseCheck == SpecificationFundingStatus.SharesAlreadyChosenFundingStream) { return(new ConflictResult()); } IDictionary <string, Provider> scopedProviders = await _providerService.GetScopedProvidersForSpecification(specificationSummary.Id, specificationSummary.ProviderVersionId); // Check prerequisites for this specification to be chosen/refreshed IPrerequisiteChecker prerequisiteChecker = _prerequisiteCheckerLocator.GetPreReqChecker(PrerequisiteCheckerType.Refresh); try { await prerequisiteChecker.PerformChecks( specificationSummary, null, Array.Empty <PublishedProvider>(), scopedProviders?.Values); } catch (JobPrereqFailedException ex) { return(new BadRequestObjectResult(new [] { $"Prerequisite check for refresh failed {ex.Message}" }.ToModelStateDictionary())); } ApiJob refreshFundingJob = await _refreshFundingJobs.CreateJob(specificationId, user, correlationId); Guard.ArgumentNotNull(refreshFundingJob, nameof(refreshFundingJob), "Failed to create RefreshFundingJob"); JobCreationResponse jobCreationResponse = new JobCreationResponse() { JobId = refreshFundingJob.Id, }; return(new OkObjectResult(jobCreationResponse)); }
/// <summary> /// Parameter mutation /// </summary> private void Mutation(Specifications baseStat) { baseStat.Photosensitivity = Stat.Photosensitivity + Random.Range(_randZoneMin, _randZoneMax); baseStat.Speed = Stat.Speed + Random.Range(_randZoneMin, _randZoneMax); baseStat.RotationAngle = Stat.RotationAngle + Random.Range(_randZoneMin, _randZoneMax); baseStat.Energy = 50; baseStat.HP = 100; baseStat.Web = new NeiralNet.NeuralNetwork(Stat.Web, true); }
public bool ExistForm(string id) { Specifications res = new Specifications(); res.AndAlso("ID", id, QueryMethod.Equal); T obj = entities.Set <T>().Where(res.GetExpression <T>()).FirstOrDefault(); return(obj != null); }
public virtual T GetEntityByID <T>(string ID) where T : class, new() { var spec = new Specifications(); spec.AndAlso("ID", ID, QueryMethod.Equal); var result = this.entities.Set <T>().FirstOrDefault(spec.GetExpression <T>()); return(result); }
public Unit AddSpecification(Specification spec) { if (Specifications == null) { Specifications = new List <Specification>(); } Specifications.Add(spec); return(this); }
public void DoRegister(object sender, EventArgs e) { var dbFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var fileName = "VehicleFind.db"; var dbFullPath = Path.Combine(dbFolder, fileName); try { using (var db = new DatabaseContext(dbFullPath)) { Models model = new Models() { Name = name.Text, Range = range.Text, }; var modelId = db.Models.Add(model); db.SaveChanges(); Specifications specifications = new Specifications() { Name = "0-100", Value = zeroToOneHundred.Text, ModelId = modelId.Entity.Id }; Specifications specifications1 = new Specifications() { Name = "Power", Value = power.Text, ModelId = modelId.Entity.Id }; Specifications specifications2 = new Specifications() { Name = "Price", Value = price.Text, ModelId = modelId.Entity.Id }; List <Specifications> specificationList = new List <Specifications>() { specifications, specifications1, specifications2 }; db.Specifications.AddRange(specifications); db.SaveChanges(); Toast.MakeText(this, "Model has been saved!", ToastLength.Long).Show(); StartActivity(typeof(LoginActivity)); } } catch (Exception ex) { } }
/// <summary> /// Get an a concrete implementation of IDependency based on details in spec /// </summary> /// <param name="spec"> /// The spec. /// </param> /// <returns> /// A concrete type adhering to IDependency /// </returns> public static IDependency Build(Specifications.DependencySpecification spec) { // By default, the local machine string server = "."; if (spec.DatabaseSpecification.LocationSpecification != null) { server = spec.DatabaseSpecification.LocationSpecification.Location; } var source = spec.SourceDatabaseName; var destination = spec.DatabaseSpecification.DestinationName; if (spec.LinqDataContextType != null) { var dependency = typeof(LinqDatabaseDependency<>).MakeGenericType(spec.LinqDataContextType); return (IDependency)Activator.CreateInstance(dependency, server, source, destination, new List<string>()); } else { return new DatabaseDependency(server, source, destination, new List<string>()); } }
public MachineContextTest(Specifications.Model.Context context) : base(context.Name, Reflector.Wrap(context.Type)) { this.Kind = TestKinds.Fixture; this.context = context; }
/// <summary> /// Sets private members to default values. /// </summary> private void Initialize() { m_clsid = Guid.Empty; m_progId = null; m_codebase = null; m_systemType = null; m_specifications = Specifications.None; }