void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { if (e.Value is string) { LogicalName = e.Value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString(); } } else if (e.Index == 2) { List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>(); if (e.Value != null) { foreach (Object[] it in (Object[])e.Value) { GXDLMSObjectDefinition item = new GXDLMSObjectDefinition(); item.ObjectType = (ObjectType)Convert.ToInt32(it[0]); item.LogicalName = GXDLMSObject.ToLogicalName((byte[])it[1]); items.Add(item); } } RegisterAssignment = items.ToArray(); } else if (e.Index == 3) { MaskList.Clear(); if (e.Value != null) { foreach (Object[] it in (Object[])e.Value) { List <byte> index_list = new List <byte>(); foreach (byte b in (Object[])it[1]) { index_list.Add(b); } MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray())); } } } else if (e.Index == 4) { if (e.Value == null) { ActiveMask = null; } else { ActiveMask = (byte[])e.Value; } } else { e.Error = ErrorCode.ReadWriteDenied; } }
void IGXDLMSBase.Load(GXXmlReader reader) { List <GXDLMSObjectDefinition> list = new List <GXDLMSObjectDefinition>(); if (reader.IsStartElement("RegisterAssignment", true)) { while (reader.IsStartElement("Item", true)) { GXDLMSObjectDefinition it = new GXDLMSObjectDefinition(); it.ObjectType = (ObjectType)reader.ReadElementContentAsInt("ObjectType"); it.LogicalName = reader.ReadElementContentAsString("LN"); list.Add(it); } reader.ReadEndElement("RegisterAssignment"); } RegisterAssignment = list.ToArray(); MaskList.Clear(); if (reader.IsStartElement("MaskList", true)) { while (reader.IsStartElement("Item", true)) { byte[] mask = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Mask")); byte[] i = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("Index")); MaskList.Add(new KeyValuePair <byte[], byte[]>(mask, i)); } reader.ReadEndElement("MaskList"); } ActiveMask = GXDLMSTranslator.HexToBytes(reader.ReadElementContentAsString("ActiveMask")); }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, int index, object value) { if (index == 1) { if (value is string) { LogicalName = value.ToString(); } else { LogicalName = GXDLMSClient.ChangeType((byte[])value, DataType.OctetString).ToString(); } } else if (index == 2) { List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>(); if (value != null) { foreach (Object[] it in (Object[])value) { GXDLMSObjectDefinition item = new GXDLMSObjectDefinition(); item.ClassId = (ObjectType)Convert.ToInt32(it[0]); item.LogicalName = GXDLMSObject.ToLogicalName((byte[])it[1]); items.Add(item); } } RegisterAssignment = items.ToArray(); } else if (index == 3) { MaskList.Clear(); if (value != null) { foreach (Object[] it in (Object[])value) { List <byte> index_list = new List <byte>(); foreach (byte b in (Object[])it[1]) { index_list.Add(b); } MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray())); } } } else if (index == 4) { if (value == null) { ActiveMask = null; } else { ActiveMask = (byte[])value; } } else { throw new ArgumentException("SetValue failed. Invalid attribute index."); } }
public MainVM() { sync = SynchronizationContext.Current; rand = new Random(); CharMaskList.CollectionChanged += (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (CharMaskModel item in e.NewItems) { item.VM = this; } } //OnPropertyChanged(nameof(CharMaskList)); }; MaskList.CollectionChanged += (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (MaskModel item in e.NewItems) { item.VM = this; } } //OnPropertyChanged(nameof(MaskList)); }; //KeyList.CollectionChanged += (s, e) => OnPropertyChanged(nameof(KeyList)); MaskList.Add(new MaskModel { Mask = "%%-$$$$-$$$$-@@" }); CharMaskList.Add(new CharMaskModel { Char = '$', Chars = "1234567890" }); CharMaskList.Add(new CharMaskModel { Char = '@', Chars = "qwertyuiopasdfghjklzxcvbnm" }); CharMaskList.Add(new CharMaskModel { Char = '%', Chars = "QWERTYUIOPASDFGHJKLZXCVBNM" }); }
byte[] IGXDLMSBase.Invoke(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>(); if (RegisterAssignment != null) { items.AddRange(RegisterAssignment); } GXDLMSObjectDefinition item = new GXDLMSObjectDefinition(); item.ObjectType = (ObjectType)Convert.ToInt32(((GXStructure)e.Parameters)[0]); item.LogicalName = GXCommon.ToLogicalName((byte[])((GXStructure)e.Parameters)[1]); items.Add(item); RegisterAssignment = items.ToArray(); } else if (e.Index == 2) { int index = GetMaskIndex((byte[])((GXStructure)e.Parameters)[0]); List <byte> index_list = new List <byte>(); foreach (byte b in (IEnumerable <object>)((GXStructure)e.Parameters)[1]) { index_list.Add(b); } if (index == -1) { MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])((GXStructure)e.Parameters)[0], index_list.ToArray())); } else { MaskList.RemoveAt(index); MaskList.Insert(index, new KeyValuePair <byte[], byte[]>((byte[])((GXStructure)e.Parameters)[0], index_list.ToArray())); } } else if (e.Index == 3) { int index = GetMaskIndex((byte[])e.Parameters); if (index != -1) { MaskList.RemoveAt(index); } } else { e.Error = ErrorCode.ReadWriteDenied; } return(null); }
public void FillMaskList() { try { MaskList.Clear(); string lType = Database.Tables[CurrentTable.TableId].Columns[CurrentColumn.ColumnId].Type; if (lType.Equals("int")) { MaskList.Add("Hash"); MaskList.Add("Random Value"); MaskList.Add("RangedValue"); MaskList.Add("Offset"); MaskList.Add("Shuffle"); } else if (lType.Equals("varchar") || lType.Equals("nvarchar") || lType.Equals("varchar2") || lType.Equals("text")) { MaskList.Add("Random String Part"); // MaskList.Add("Replace String Part"); MaskList.Add("Substitution"); } else if (lType.Equals("date") || lType.Equals("datetime") || lType.Equals("datetime2")) { MaskList.Add("Hash date"); } else if (lType.Equals("bit")) { MaskList.Add("Random Value"); } else if (lType.Equals("float") || lType.Equals("double")) { MaskList.Add("Hash"); } } catch { } }
void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e) { if (e.Index == 1) { LogicalName = GXCommon.ToLogicalName(e.Value); } else if (e.Index == 2) { List <GXDLMSObjectDefinition> items = new List <GXDLMSObjectDefinition>(); if (e.Value != null) { foreach (object tmp in (IEnumerable <object>)e.Value) { List <object> it; if (tmp is List <object> ) { it = (List <object>)tmp; } else { it = new List <object>((object[])tmp); } GXDLMSObjectDefinition item = new GXDLMSObjectDefinition(); item.ObjectType = (ObjectType)Convert.ToInt32(it[0]); item.LogicalName = GXCommon.ToLogicalName((byte[])it[1]); items.Add(item); } } RegisterAssignment = items.ToArray(); } else if (e.Index == 3) { MaskList.Clear(); if (e.Value != null) { foreach (object tmp in (IEnumerable <object>)e.Value) { List <object> it; if (tmp is List <object> ) { it = (List <object>)tmp; } else { it = new List <object>((object[])tmp); } List <byte> index_list = new List <byte>(); foreach (byte b in (IEnumerable <object>)it[1]) { index_list.Add(b); } MaskList.Add(new KeyValuePair <byte[], byte[]>((byte[])it[0], index_list.ToArray())); } } } else if (e.Index == 4) { if (e.Value == null) { ActiveMask = null; } else { ActiveMask = (byte[])e.Value; } } else { e.Error = ErrorCode.ReadWriteDenied; } }