public void DataTransformation_ParseKeyUsage_InvalidKeyUsage_SpecialCharacterDollar_ThrowArgumentException() { DataTransformation dataTransformation = new DataTransformation(); string keyUsageString = "$"; KeyUsage actualKeyUsage = dataTransformation.ParseKeyUsage(keyUsageString); }
public void DataTransformation_ParseKeyUsage_InvalidKeyUsage_6point5_ThrowArgumentException() { DataTransformation dataTransformation = new DataTransformation(); string keyUsageString = "6.5"; KeyUsage actualKeyUsage = dataTransformation.ParseKeyUsage(keyUsageString); }
public void DataTransformation_ParseKeyUsage_InvalidKeyUsage_Empty_ThrowArgumentNullException() { DataTransformation dataTransformation = new DataTransformation(); string keyUsageString = string.Empty; KeyUsage actualKeyUsage = dataTransformation.ParseKeyUsage(keyUsageString); }
public PkiConfigurationAdcsTemplateController(AdcsTemplateLogic templateLogic) { //this.configurationRepository = configurationRepository; //this.runtimeConfigurationState = runtimeConfigurationState; //this.adcsTemplateLogic = new AdcsTemplateLogic(configurationRepository, null); this.adcsTemplateLogic = templateLogic; this.http = new HttpResponseHandler(this); this.dataTransform = new DataTransformation(); }
/// <summary> /// Gets an unsigned data type from the buffer with the specified order and transformation. /// </summary> /// <param name="type"></param> /// <param name="order"></param> /// <param name="transformation"></param> /// <returns></returns> public ulong GetUnsigned(DataType type, DataOrder order, DataTransformation transformation) { ulong longValue = Get(type, order, transformation); if (type == DataType.LONG) { throw new Exception("due to java restrictions, longs must be read as signed types"); } return(longValue & 0xFFFFFFFFFFFFFFFFL); }
public void DataTransformation_ParseKeyUsage_ValidTwoFlags_ServerAuthenticationClientAuthentication_IntAsString_Success() { DataTransformation dataTransformation = new DataTransformation(); KeyUsage expectedKeyUsage = KeyUsage.ServerAuthentication | KeyUsage.ClientAuthentication; string keyUsageString = "3"; KeyUsage actualKeyUsage = dataTransformation.ParseKeyUsage(keyUsageString); Assert.AreEqual(expectedKeyUsage, actualKeyUsage); }
public string SaveTransformation(DataTransformation dataType) { var serialized = ServiceStack.Text.TypeSerializer.SerializeToString(dataType); var compressed = LZ4Sharp.LZ4.Compress(serialized.ToBytes()); var mutator = DataBase.CreateMutator(); var column = mutator.NewColumn("DAT", compressed); mutator.InsertColumn("JobConfig", dataType.Id.ToByteArray(), column, ConsistencyLevel.ONE); return(""); }
public ActionResult Create() { var job = new DataTransformation { Id = Guid.NewGuid(), TransformationType = TransformationType.Mapper, Code = Properties.Resources.NewMapper }; this.EditorViewBag(); return(this.View(job)); }
public string SaveTransformation(DataTransformation collection) { var checker = new TransformationChecker(); var error = checker.CheckTransformation(collection); if (!string.IsNullOrEmpty(error)) { return(error); } return(Context.Container.Resolve <ITransformationDalc>().SaveTransformation(collection)); }
public ActionResult Create(DataTransformation collection) { try { Context.Container.Resolve <ITransformationDalc>().SaveTransformation(collection); return(this.RedirectToAction("Index")); } catch (Exception ex) { this.ErrorMessage = ex.Message; return(this.View("Create", collection)); } }
/** * Puts the bytes into the buffer with the specified transformation. * @param transformation The transformation. * @param bytes The byte array. * @throws IllegalStateException if the builder is not in byte access mode. */ public void PutBytes(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.None) { PutBytes(bytes); } else { foreach (byte b in bytes) { Put(MessageType.Byte, transformation, b); } } }
/** * Puts the specified byte array into the buffer in reverse with the * specified transformation. * @param transformation The transformation. * @param bytes The byte array. * @throws IllegalStateException if the builder is not in byte access mode. */ public void PutBytesReverse(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.None) { PutBytesReverse(bytes); } else { for (int i = bytes.Length - 1; i >= 0; i--) { Put(MessageType.Byte, transformation, bytes[i]); } } }
/// <summary> /// Puts the specified byte array into the buffer in reverse with the specified transformation. /// </summary> /// <param name="transformation"></param> /// <param name="bytes"></param> public void PutBytesReverse(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.NONE) { PutBytesReverse(bytes); } else { for (int index = bytes.Length - 1; index >= 0; index--) { Put(DataType.BYTE, transformation, bytes[index]); } } }
/** * Gets bytes in reverse with the specified transformation. * * @param transformation The transformation. * @param bytes The target byte array. * @throws IllegalStateException If this reader is not in byte access mode. */ public void GetBytesReverse(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.None) { GetBytesReverse(bytes); } else { for (int i = bytes.Length - 1; i >= 0; i--) { bytes[i] = (byte)GetSigned(MessageType.Byte, transformation); } } }
/// <summary> /// Puts the bytes into the buffer with the specified transformation. /// </summary> /// <param name="transformation"></param> /// <param name="bytes"></param> public void PutBytes(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.NONE) { PutBytes(bytes); } else { foreach (byte b in bytes) { Put(DataType.BYTE, transformation, b); } } }
/** * Gets a signed data type from the buffer with the specified order and transformation. * * @param type The data type. * @param order The byte order. * @param transformation The data transformation. * @return The value. * @throws IllegalStateException If this reader is not in byte access mode. * @throws IllegalArgumentException If the combination is invalid. */ public long GetSigned(MessageType type, DataOrder order, DataTransformation transformation) { long longValue = Get(type, order, transformation); if (type != MessageType.Long) { int max = (int)(Math.Pow(2, (int)type * 8 - 1) - 1); if (longValue > max) { longValue -= (max + 1) * 2; } } return(longValue); }
/// <summary> /// Gets bytes with the specified transformation. /// </summary> /// <param name="transformation"></param> /// <param name="bytes"></param> public void GetBytes(DataTransformation transformation, byte[] bytes) { if (transformation == DataTransformation.NONE) { GetBytesReverse(bytes); } else { for (int index = 0; index < bytes.Length; index++) { bytes[index] = (byte)GetSigned(DataType.BYTE, transformation); } } }
/// <summary> /// Gets a signed data type from the buffer with the specified order and transformation. /// </summary> /// <param name="type"></param> /// <param name="order"></param> /// <param name="transformation"></param> /// <returns></returns> public ulong GetSigned(DataType type, DataOrder order, DataTransformation transformation) { ulong longValue = Get(type, order, transformation); if (type != DataType.LONG) { uint max = (uint)(int)(Math.Pow(2, (int)type * 8 - 1) - 1); if (longValue > max) { longValue -= (max + 1) * 2; } } return(longValue); }
private void button2_Click(object sender, EventArgs e) { DataTransformation dt = new DataTransformation(); List <double> array_to_normalize = new List <double>(); foreach (string itm in lstNotNormalized.Items) { array_to_normalize.Add(Convert.ToDouble(itm)); } foreach (double itm in dt.ZScore(array_to_normalize.ToArray())) { lstNormalized.Items.Add(itm.ToString()); } }
public static void createDataInTridion(ICoreServiceFrameworkContext coreService, string SchemaId, List <Lead> leadFromSF) { try { foreach (var item in leadFromSF) { string serializeXml = ""; bool bln = DataTransformation.Serialize <Lead>(item, ref serializeXml); string xml = serializeXml; string tcmuri = TridionComponent.GenerateComponent(coreService, xml, SetPublication.Publication(ConfigurationManager.AppSettings["FolderLocation"].ToString(), SchemaId), EnumType.SchemaType.Component, ConfigurationManager.AppSettings["FolderLocation"].ToString(), item.FName.Text + " " + item.LName.Text, item.FName.Text + " " + item.LName.Text); } } catch (Exception ex) { throw; } }
public MappingProfile() { CreateMap <ClassifiedsView, Classified>() .ForMember(destination => destination.userdata, map => map.MapFrom(source => DataTransformation.ToUserJson(source.userdata))) .ForMember(destination => destination.details, map => map.MapFrom(source => DataTransformation.ToDetailsJson(source.details))) .ForMember(destination => destination.timeinfo, map => map.MapFrom(source => DataTransformation.ToTimeJson(source.timeinfo))); CreateMap <Classified, ClassifiedsView>() .ForMember(destination => destination.timeinfo, map => map.MapFrom(source => JsonConvert.DeserializeObject <Time>(source.timeinfo))) .ForMember(destination => destination.details, map => map.MapFrom(source => JsonConvert.DeserializeObject <ClassifiedDetails>(source.details))) .ForMember(destination => destination.userdata, map => map.MapFrom(source => JsonConvert.DeserializeObject <User>(source.userdata))); }
internal string TryInstanciate <T>(Assembly assembly, DataTransformation transformation) where T : class { T returnObject = null; var error = TryCreateInstance(assembly, transformation.Name, out returnObject); if (string.IsNullOrEmpty(error)) { string serialized = null; error = TrySerialize(returnObject, out serialized); if (string.IsNullOrEmpty(error)) { JobData deserialized = null; error = TryDeserialize(serialized, out deserialized); } } return(error); }
public string CheckTransformation(DataTransformation transformation) { Assembly assembly = null; if (transformation.SourceTypeId == default(Guid)) { return("Source type not defined"); } var error = TryCompile(transformation, out assembly); if (string.IsNullOrEmpty(error)) { error = transformation.TransformationType == Client.Contracts.Enumerators.TransformationType.Mapper ? TryInstanciate <Mapper>(assembly, transformation) : TryInstanciate <Reducer>(assembly, transformation); } return(error); }
public ActionResult Edit(DataTransformation collection) { try { // check if datatype is ok var service = new DataUtils(); var error = service.SaveTransformation(collection); if (!string.IsNullOrEmpty(error)) { this.ErrorMessage = error; return(this.View("Create", collection)); } return(this.RedirectToAction("Index")); } catch (Exception ex) { this.ErrorMessage = ex.Message; return(this.View("Create", collection)); } }
public static List <Lead> getLeadList(ICoreServiceFrameworkContext coreService) { SchemaFieldsData schemaFieldData = coreService.Client.ReadSchemaFields(ConfigurationManager.AppSettings["SchemaID"].ToString(), true, new ReadOptions()); UsingItemsFilterData f = new UsingItemsFilterData { ItemTypes = new[] { ItemType.Component } }; IdentifiableObjectData[] items = coreService.Client.GetList(ConfigurationManager.AppSettings["SchemaID"].ToString(), f); List <Lead> newLeadList = new List <Lead>(); XmlDocument Xdoc = new XmlDocument(); foreach (var item in items) { Lead _lead = new Lead(); ComponentData component = (ComponentData)coreService.Client.Read(item.Id, new ReadOptions()); Xdoc.LoadXml(component.Content); _lead = DataTransformation.Deserialize <Lead>(Xdoc); newLeadList.Add(_lead); //Do something } return(newLeadList); }
private string RegisterWordMapper() { try { var code = File.ReadAllText(this.BasePath + "/content/WordMapper.cs"); var wordMapper = new DataTransformation() { Name = "WordMapper", Id = new Guid("2C293902-7B39-4053-8446-C2951DAFE8E5"), Code = code, TransformationType = Client.Contracts.Enumerators.TransformationType.Mapper, Dependency = null, SourceTypeId = new Guid("57D03CD6-5A57-4DDD-8498-FE7926206612"), TargetTypeId = new Guid("7D4BFF0D-5830-421E-8B02-873A83C22CFB"), }; return(new DataUtils().SaveTransformation(wordMapper)); } catch (Exception ex) { return(ex.Message); } }
private string RegisterWordCountReducer() { try { var code = File.ReadAllText(this.BasePath + "/content/WordReducer.cs"); var wordMapper = new DataTransformation() { Name = "WordReducer", Id = new Guid("2C293902-7B39-4053-8446-C2951DAFE8E8"), Code = code, TransformationType = Client.Contracts.Enumerators.TransformationType.Reducer, Dependency = null, SourceTypeId = new Guid("7D4BFF0D-5830-421E-8B02-873A83C22CFB"), TargetTypeId = new Guid("5627AFB9-1961-4E2A-BA45-01EB514E1602"), }; return(new DataUtils().SaveTransformation(wordMapper)); } catch (Exception ex) { return(ex.Message); } }
internal string TryCompile(DataTransformation transformation, out Assembly assembly) { //check if datatypes exists var source = Context.Container.Resolve <IDataTypeDalc>().GetDataType(transformation.SourceTypeId); var target = transformation.TargetTypeId.HasValue ? Context.Container.Resolve <IDataTypeDalc>().GetDataType(transformation.TargetTypeId.Value) : null; if (source == null) { assembly = null; return("Source data type not found"); } if (target == null && transformation.TargetTypeId.HasValue) { assembly = null; return("Target data type not found"); } var contracts = Assembly.Load("Lesula.Client.Contracts"); var core = Assembly.Load("Lesula.Core"); var cassandra = Assembly.Load("Lesula.Cassandra"); var files = new List <string>() { transformation.Code }; if (source != null) { files.Add(source.Code); } if (target != null) { files.Add(target.Code); } var errors = new List <string>(); // see if code compiles assembly = Context.Container.Resolve <IAssemblyGenerator>().CreateAssembly( "Test", files, new List <string> { "mscorlib", "System", "System.Core", contracts.Location, core.Location, cassandra.Location }, out errors); if (errors != null && errors.Count != 0) { return(string.Join("<br/>", errors)); } else { // check if type exists if (assembly.ExportedTypes.FirstOrDefault(t => t.Name == transformation.Name) == null) { return("Transformation '" + transformation.Name + "' not found in compiled code"); } } return(""); }
/** * Reads a standard data type from the buffer with the specified order and transformation. * * @param type The data type. * @param order The data order. * @param transformation The data transformation. * @return The value. * @throws IllegalStateException If this reader is not in byte access mode. * @throws IllegalArgumentException If the combination is invalid. */ private long Get(MessageType type, DataOrder order, DataTransformation transformation) { CheckByteAccess(); long longValue = 0; int length = (int)type; if (order == DataOrder.Big) { for (int i = length - 1; i >= 0; i--) { if (i == 0 && transformation != DataTransformation.None) { if (transformation == DataTransformation.Add) { longValue |= _buffer.ReadByte() - 128 & 0xFFL; } else if (transformation == DataTransformation.Negate) { longValue |= -_buffer.ReadByte() & 0xFFL; } else if (transformation == DataTransformation.Subtract) { longValue |= 128 - _buffer.ReadByte() & 0xFFL; } else { throw new ArgumentException("Unknown transformation."); } } else { longValue |= (_buffer.ReadByte() & 0xFFL) << i * 8; } } } else if (order == DataOrder.Little) { for (int i = 0; i < length; i++) { if (i == 0 && transformation != DataTransformation.None) { if (transformation == DataTransformation.Add) { longValue |= _buffer.ReadByte() - 128 & 0xFFL; } else if (transformation == DataTransformation.Negate) { longValue |= -_buffer.ReadByte() & 0xFFL; } else if (transformation == DataTransformation.Subtract) { longValue |= 128 - _buffer.ReadByte() & 0xFFL; } else { throw new ArgumentException("Unknown transformation."); } } else { longValue |= (_buffer.ReadByte() & 0xFFL) << i * 8; } } } else if (order == DataOrder.Middle) { if (transformation != DataTransformation.None) { throw new ArgumentException("Middle endian cannot be transformed."); } if (type != MessageType.Int) { throw new ArgumentException("Middle endian can only be used with an integer."); } longValue |= (_buffer.ReadByte() & 0xFF) << 8; longValue |= _buffer.ReadByte() & 0xFF; longValue |= (_buffer.ReadByte() & 0xFF) << 24; longValue |= (_buffer.ReadByte() & 0xFF) << 16; } else if (order == DataOrder.InversedMiddle) { if (transformation != DataTransformation.None) { throw new ArgumentException("Inversed middle endian cannot be transformed."); } if (type != MessageType.Int) { throw new ArgumentException("Inversed middle endian can only be used with an integer."); } longValue |= (_buffer.ReadByte() & 0xFF) << 16; longValue |= (_buffer.ReadByte() & 0xFF) << 24; longValue |= _buffer.ReadByte() & 0xFF; longValue |= (_buffer.ReadByte() & 0xFF) << 8; } else { throw new ArgumentException("Unknown order."); } return(longValue); }
/** * Gets an unsigned data type from the buffer with the specified transformation. * * @param type The data type. * @param transformation The data transformation. * @return The value. * @throws IllegalStateException If this reader is not in byte access mode. * @throws IllegalArgumentException If the combination is invalid. */ public ulong GetUnsigned(MessageType type, DataTransformation transformation) { return(GetUnsigned(type, DataOrder.Big, transformation)); }