internal static string GetSpecificationTestInstance(string specification) { string testInstance = string.Empty; try { // determine which specification type has been requested SpecificationType specType = Specification.GetSpecificationType(specification); if (specType == SpecificationType.Unknown) { throw new Exception("unrecognised specification type: " + specification); } // get the sample testInstance = Specification.GetSpecificationInstance(specType); } catch (Exception ex) { Log.Write("ERROR: " + ex.ToString(), LogLevel.ExceptionOnly); throw; } return(testInstance); }
public async Task <AmfModel> Load(SpecificationType type, string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentException("filePath"); } filePath = FixPath(filePath); var rawresult = await GetDynamicStructureAsync(type, filePath).ConfigureAwait(false); var ret = rawresult as IDictionary <string, object>; var error = ret["error"]; if (error != null) { var errObj = error as IDictionary <string, object>; var msg = errObj["message"] + Environment.NewLine + errObj["stack"]; throw new FormatException(msg); } var model = ret["model"] as IDictionary <string, object>; var webApi = WebApiMapper.Map(model); var shapes = ShapeMapper.Map(ret["shapes"] as object[]); return(new AmfModel(webApi, shapes)); }
public IHttpActionResult UpdateSpecificationType(UpdateSpecificationTypeRequestDto requestDto) { SpecificationType specificationType = _specificationTypeMapper.ToSpecificationType(requestDto); _specificationTypeService.UpdateSpecificationType(specificationType); return(new StatusCodeResult(HttpStatusCode.NoContent, this)); }
public IHttpActionResult InsertSpecificationType(InsertSpecificationTypeRequestDto requestDto) { SpecificationType specificationType = _specificationTypeMapper.ToSpecificationType(requestDto); specificationType.Id = _specificationTypeService.InsertSpecificationType(specificationType); return(Created($"specificationType/{specificationType.Id}", _specificationTypeMapper.ToDto(specificationType))); }
public DataTable GetList(SpecificationType sType) { string SpName = "UP_pdProductSpecification_GetList"; DbCommand Command = dbr.GetStoredProcCommand(SpName); dbr.AddInParameter(Command, "@type", DbType.Int16, (int)sType); return dbr.ExecuteDataSet(Command).Tables[0]; }
protected Specification(SpecificationType tag, bool required, int min, int max, Maybe<object> defaultValue, System.Type conversionType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; }
public void VerifyThatSettingAnIncorrectSpecTypeThrowsException() { var specificationType = new SpecificationType(); var relationGroup = new RelationGroup(); Assert.That(() => relationGroup.SpecType = specificationType, Throws.TypeOf <ArgumentException>() .With.Message.EqualTo("specType must of type RelationGroupType")); }
/// <summary> /// Add speficiation to filter query /// </summary> /// <param name="specificationType">Type</param> /// <param name="specification">Specification</param> public void AddSpecification(SpecificationType specificationType, ISpecification <TEntity> specification) { if (_specificationType.Count == 0) { throw new Exception("Please, to add first Specification to QueryRepository, use AddSpecification(ISpecification<T> specification)"); } _specificationType.Add(specificationType); _specifications.Add(specification); }
public SpecificationTypeResponseDto ToDto(SpecificationType specificationType) { return(new SpecificationTypeResponseDto() { Id = specificationType.Id, Type = specificationType.Type, IsRequiredForCar = specificationType.IsRequiredForCar }); }
protected Specification(SpecificationType tag, bool required, int min, int max, Maybe <object> defaultValue, System.Type conversionType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; }
public DataTable GetList(SpecificationType sType) { string SpName = "UP_pdProductSpecification_GetList"; DbCommand Command = dbr.GetStoredProcCommand(SpName); dbr.AddInParameter(Command, "@type", DbType.Int16, (int)sType); return(dbr.ExecuteDataSet(Command).Tables[0]); }
public async Task <AmfModel> Load(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentException("filePath"); } SpecificationType type = await DetectType(filePath); return(await Load(type, filePath)); }
protected Specification(SpecificationType tag, bool required, Maybe<int> min, Maybe<int> max, Maybe<object> defaultValue, Type conversionType, TargetType targetType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; this.targetType = targetType; }
protected Specification(SpecificationType tag, bool required, Maybe <int> min, Maybe <int> max, Maybe <object> defaultValue, Type conversionType, TargetType targetType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; this.targetType = targetType; }
public void Add(SpecificationTypeDTO obj) { SpecificationType newSpecType = new SpecificationType { IsInTableValue = obj.IsInTableValue, SpecificationName = obj.SpecificationName }; uof.SpecificationTypes.Create(newSpecType); uof.SaveChanges(); }
/// <summary> /// Create and return Validation Test Object of the passed-in Type. /// </summary> /// <param name="specType">Specification Type</param> /// <returns>Instance of the passed class that implements the IValidationTest Interface</returns> /// <remarks>Implements Abstract Factory Pattern</remarks> public static IValidationTest Create(SpecificationType specType) { IValidationTest testInstance = null; switch (specType) { case SpecificationType.GP2GP: testInstance = new Gp2Gp(); break; case SpecificationType.ePrescribing: testInstance = new ePrescription(); break; case SpecificationType.eDischargeSummary: testInstance = new eDischargeSummary(); break; case SpecificationType.PharmacyHealthSummary: testInstance = new PharmacyHealthSummary(); break; case SpecificationType.CdaTemplates: testInstance = new CdaTemplates(); break; case SpecificationType.InterRaiCommunityHealth: testInstance = new InterRaiCommunityHealth(); break; case SpecificationType.InterRaiHomeCare: testInstance = new InterRaiHomeCare(); break; case SpecificationType.InterRaiLongTermCareFacility: testInstance = new InterRaiLongTermCareFacility(); break; case SpecificationType.InterRaiContact: testInstance = new InterRaiContact(); break; case SpecificationType.GP2GPV2: testInstance = new Gp2Gpv2(); break; default: testInstance = null; break; } return(testInstance); }
public void UpdateSpecificationType(SpecificationType specificationType) { _context.SpecificationTypes.Attach(specificationType); _context.Entry(specificationType).State = EntityState.Modified; foreach (Specification specification in specificationType.Specifications) { _context.Specifications.Attach(specification); } _context.SaveChanges(); }
public Specification(string name, string value, SpecificationType type, string unitOfMeasure, string id, string groupId, string groupName, string label) { Name = name; Value = value; Type = type; UnitOfMeasure = unitOfMeasure; Id = id; GroupId = groupId; GroupName = groupName; Label = label; }
public SpecificationType FindSpecificationType(int id) { SpecificationType findSpecificationType = _repository.FindSpecificationType(id); if (findSpecificationType != null) { return(findSpecificationType); } else { throw new ArgumentException($"SpecificationType with Id: {id} was not found"); } }
public SpecificationType FindSpecificationType(string type) { SpecificationType findSpecificationType = _repository.FindSpecificationType(type); if (findSpecificationType != null) { return(findSpecificationType); } else { throw new ArgumentException($"SpecificationType with Type: '{type}' was not found"); } }
/// <summary> /// create a <see cref="SpecificationType"/> with attribute definitions /// </summary> private void CreateSpecificationType() { var reqIfContent = this.reqIF.CoreContent.SingleOrDefault(); var specificationType = new SpecificationType(); specificationType.LongName = "Specification Type"; specificationType.Identifier = "specificationtype"; specificationType.LastChange = DateTime.Parse("2015-12-01"); this.CreateAndAddAttributeDefinitionsToSpecType(specificationType, reqIfContent); reqIfContent.SpecTypes.Add(specificationType); }
public void DeleteSpecificationType(int id) { SpecificationType specificationTypeFromDb = _context.SpecificationTypes.Find(id); if (specificationTypeFromDb != null) { _context.SpecificationTypes.Remove(specificationTypeFromDb); _context.SaveChanges(); } else { throw new ArgumentException("specificationType was not found!"); } }
public void Verify_that_When_Identifier_is_null_WriteXml_throws_exception() { var stream = new MemoryStream(); var writer = XmlWriter.Create(stream, this.settings); var specificationType = new SpecificationType(); var specification = new Specification(); specification.Type = specificationType; Assert.That(() => specification.WriteXml(writer), Throws.TypeOf <SerializationException>() .With.Message.Contains("The Identifier property of an Identifiable may not be null")); }
public int InsertSpecificationType(SpecificationType specificationType) { hasRequiredProps(specificationType, false); SpecificationType findSpecificationType = _repository.FindSpecificationType(specificationType.Type); if (findSpecificationType == null) { _repository.InsertSpecificationType(specificationType); return((_repository.FindSpecificationType(specificationType.Type)).Id); } else { throw new ArgumentException($"Specification type: {specificationType.Type} already exists"); } }
private void UpdateSpecificationValues(TypeInfo model, SpecificationType specEnum) { var newSpec = model.SpecificationValueInfo.Where(s => s.Specification == specEnum); var values = DbFactory.Default.Get <SpecificationValueInfo>() .Where(s => s.TypeId == model.Id && s.Specification == specEnum) .ToList(); var deleteSpec = values.Except(newSpec, new SpecValueComparer()); DbFactory.Default.Del(deleteSpec); var addSpec = newSpec.Except(values, new SpecValueComparer()); DbFactory.Default.Add(addSpec); }
private static void hasRequiredProps(SpecificationType specificationType, bool isIdRequired) { if (isIdRequired) { if (specificationType.Id.Equals(null)) { throw new ArgumentException("SpecificationType Id attribute can not be null"); } } if (specificationType.Type.Equals(null)) { throw new ArgumentException("SpecificationType Type attribute can not be null"); } }
protected Specification(SpecificationType tag, bool required, Maybe<int> min, Maybe<int> max, Maybe<object> defaultValue, string helpText, string metaValue, IEnumerable<string> enumValues, Type conversionType, TargetType targetType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; this.targetType = targetType; this.helpText = helpText; this.metaValue = metaValue; this.enumValues = enumValues; }
protected Specification(SpecificationType tag, bool required, Maybe <int> min, Maybe <int> max, Maybe <object> defaultValue, string helpText, string metaValue, IEnumerable <string> enumValues, Type conversionType, TargetType targetType) { this.tag = tag; this.required = required; this.min = min; this.max = max; this.defaultValue = defaultValue; this.conversionType = conversionType; this.targetType = targetType; this.helpText = helpText; this.metaValue = metaValue; this.enumValues = enumValues; }
static internal SpecificationType GetSpecificationType(string specification) { SpecificationType specType = SpecificationType.Unknown; if (specification == Gp2Gp.GetDescription()) { specType = SpecificationType.GP2GP; } else if (specification == ePrescription.GetDescription()) { specType = SpecificationType.ePrescribing; } else if (specification == eDischargeSummary.GetDescription()) { specType = SpecificationType.eDischargeSummary; } else if (specification == CdaTemplates.GetDescription()) { specType = SpecificationType.CdaTemplates; } else if (specification == PharmacyHealthSummary.GetDescription()) { specType = SpecificationType.PharmacyHealthSummary; } else if (specification == InterRaiCommunityHealth.GetDescription()) { specType = SpecificationType.InterRaiCommunityHealth; } else if (specification == InterRaiHomeCare.GetDescription()) { specType = SpecificationType.InterRaiHomeCare; } else if (specification == InterRaiLongTermCareFacility.GetDescription()) { specType = SpecificationType.InterRaiLongTermCareFacility; } else if (specification == InterRaiContact.GetDescription()) { specType = SpecificationType.InterRaiContact; } else if (specification == Gp2Gpv2.GetDescription()) { specType = SpecificationType.GP2GPV2; } return(specType); }
public void VerifyThatTheSpecTypeCanBeSetOrGet() { var specificationType = new SpecificationType(); var specification = new Specification(); specification.Type = specificationType; var specElementWithAttributes = (SpecElementWithAttributes)specification; Assert.AreEqual(specificationType, specElementWithAttributes.SpecType); var otherspecificationType = new SpecificationType(); specElementWithAttributes.SpecType = otherspecificationType; Assert.AreEqual(otherspecificationType, specification.SpecType); }
public static async Task <object> GetDynamicStructureAsync(SpecificationType specType, string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentException("filePath"); } var func = Edge.Func(@" return function (input, callback) { var parser = require('parser') parser.parse(input.type, input.file, function(model) { return callback(null, model); }); } "); var type = Enum.GetName(typeof(SpecificationType), specType).ToLowerInvariant(); var input = new { type = type, file = filePath }; var rawresult = await func(input); return(rawresult); }
public void UpdateCar(Product product) { CheckRequiredSpecificationTypes(product.Specifications); foreach (Specification productSpecification in product.Specifications) { SpecificationType findSpecificationType = _specificationTypeRepository.FindSpecificationType(productSpecification.SpecificationTypeId); int index = product.Specifications.FindIndex(specification => specification.Id == productSpecification.Id); product.Specifications[index].SpecificationType = findSpecificationType; } List <Category> categories = new List <Category>(); Category car = _categoryRepository.FindCategory("Cars"); categories.Add(car); _carRepository.UpdateCar(product); }
/// <summary> /// Load workstation and server specifications from disk. /// </summary> /// <param name="storage">Choose whether to load workstation or server specs</param> /// <param name="specificationType">Choose which specification type to load (CPU, RAM, disk, etc)</param> /// <returns>List of strings from configuration storage</returns> public static List<string> GetSpecifications(SpecificationSource storage, SpecificationType specificationType) { List<string> configs = new List<string>(); string storagePath = string.Empty; storagePath = AppUtilities.GetStoragePathFromStorageAndSpecification(storage, specificationType); if (File.Exists(storagePath)) { using (FileStream fs = new FileStream(storagePath, FileMode.Open)) using (StreamReader sr = new StreamReader(fs)) { while (sr.Peek() != -1) { configs.Add(sr.ReadLine()); } } } return configs; }
private void UpdateSpecificationValues(ProductTypeInfo model, SpecificationType specEnum) { var newSpec = model.SpecificationValueInfo.Where(s => s.Specification == specEnum); var actual = Context.SpecificationValueInfo .Where(s => s.TypeId.Equals(model.Id) && s.Specification == specEnum).AsEnumerable(); var deleteSpec = actual.Except(newSpec, new SpecValueComparer()); foreach (var specV in deleteSpec.ToList()) { Context.SpecificationValueInfo.Remove(specV); } var addSpec = newSpec.Except(actual, new SpecValueComparer()); foreach (var specV in addSpec.ToList()) { Context.SpecificationValueInfo.Add(specV); } }
/// <summary> /// Returns the <see cref="SpecificationType"/> corresponding to a <see cref="RequirementsSpecification"/> /// </summary> /// <param name="requirementsSpecification">The <see cref="RequirementsSpecification"/></param> /// <param name="appliedRules">The applied <see cref="ParameterizedCategoryRule"/></param> /// <param name="parameterTypeMap">The map of <see cref="ParameterType"/> to <see cref="DatatypeDefinition"/></param> /// <returns>the <see cref="SpecObjectType"/></returns> public SpecificationType ToReqIfSpecificationType(RequirementsSpecification requirementsSpecification, IReadOnlyCollection <ParameterizedCategoryRule> appliedRules, IReadOnlyDictionary <ParameterType, DatatypeDefinition> parameterTypeMap) { if (requirementsSpecification == null) { throw new ArgumentNullException("requirementsSpecification"); } var specificationType = new SpecificationType { Identifier = Guid.NewGuid().ToString(), LongName = appliedRules.Any() ? string.Join(", ", appliedRules.Select(r => r.ShortName)) : requirementsSpecification.ClassKind.ToString(), LastChange = DateTime.UtcNow, Description = appliedRules.Any() ? string.Join(", ", appliedRules.Select(r => r.Name)) : requirementsSpecification.ClassKind.ToString() }; this.AddCommonAttributeDefinition(specificationType); var isDeprecatedAttributeDefinition = new AttributeDefinitionBoolean() { LongName = IsDeprecatedAttributeDefName, LastChange = DateTime.Now, Description = "The IsDeprecated Attribute Definition", Identifier = Guid.NewGuid().ToString(), Type = this.BooleanDatatypeDefinition }; specificationType.SpecAttributes.Add(isDeprecatedAttributeDefinition); // set the attribute-definition var parameterTypes = appliedRules.SelectMany(r => r.ParameterType).Distinct(); foreach (var parameterType in parameterTypes) { var attibuteDef = this.ToReqIfAttributeDefinition(parameterType, parameterTypeMap); specificationType.SpecAttributes.Add(attibuteDef); } return(specificationType); }
/// <summary> /// Get the path to the storage /// </summary> /// <param name="storageType">Type of storage</param> /// <param name="specificationType">Type of specification</param> /// <returns>The path to the specification profile</returns> public static string GetStoragePathFromStorageAndSpecification(SpecificationSource storageType, SpecificationType specificationType) { string path = GetAppPath(); if (storageType == SpecificationSource.LocalMachine) { path = Path.Combine(path, storageType.ToString()); path = Path.Combine(path, Environment.MachineName); EnsureDirectory(new DirectoryInfo(path)); path = Path.Combine(path, specificationType.ToString() + ".txt"); } if (storageType == SpecificationSource.PilotWorkstationMinimum | storageType == SpecificationSource.PilotAppServerMinimum | storageType == SpecificationSource.AppointmentsAppServerMinimum | storageType == SpecificationSource.AppointmentsWorkstationMinimum) { path = Path.Combine(path, storageType.ToString()); EnsureDirectory(new DirectoryInfo(path)); path = Path.Combine(path, specificationType.ToString() + ".txt"); } return path; }
public override void ProcessElementStartNode(string name) { switch (name) { case specificationTypeNodeName: identifiableElementUnderConstruction = new SpecificationType(); break; case specObjectTypeNodeName: identifiableElementUnderConstruction = new SpecObjectType(); break; case specRelationTypeNodeName: identifiableElementUnderConstruction = new SpecRelationType(); break; case relationGroupTypeNodeName: identifiableElementUnderConstruction = new RelationGroupType(); break; default: throw new ParserFailureException(unexpectedElementNodeErrorText + name + "'."); } }
/// <summary> /// Write information gathered to the data store /// </summary> /// <param name="storageType">Storage profile</param> /// <param name="specificationType">Category of specification</param> /// <param name="data">Data to write</param> public static void Write(SpecificationSource storageType, SpecificationType specificationType, string data) { string storagePath = string.Empty; storagePath = AppUtilities.GetStoragePathFromStorageAndSpecification(storageType, specificationType); using (FileStream fs = new FileStream(storagePath, FileMode.Append)) using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(data); sw.Flush(); } }
public DataTable GetList(SpecificationType sType) { return dal.GetList(sType); }