private static void LoadTokenGatewayConfigurations(GXXmlReader reader, List <GXTokenGatewayConfiguration> list)
 {
     list.Clear();
     if (reader.IsStartElement("TokenGatewayConfigurations", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             GXTokenGatewayConfiguration it = new GXTokenGatewayConfiguration();
             it.CreditReference = reader.ReadElementContentAsString("Credit");
             it.TokenProportion = (byte)reader.ReadElementContentAsInt("Token");
             list.Add(it);
         }
         reader.ReadEndElement("TokenGatewayConfigurations");
     }
 }
        void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
        {
            switch (e.Index)
            {
            case 1:
                LogicalName = GXCommon.ToLogicalName(e.Value);
                break;

            case 2:
                if (e.Value != null)
                {
                    List <object> arr;
                    if (e.Value is List <object> )
                    {
                        arr = (List <object>)e.Value;
                    }
                    else
                    {
                        arr = new List <object>((object[])e.Value);
                    }
                    PaymentMode   = (PaymentMode)Convert.ToByte(arr[0]);
                    AccountStatus = (AccountStatus)Convert.ToByte(arr[1]);
                }
                else
                {
                    AccountStatus = AccountStatus.NewInactiveAccount;
                    PaymentMode   = PaymentMode.Credit;
                }
                break;

            case 3:
                CurrentCreditInUse = (byte)e.Value;
                break;

            case 4:
                CurrentCreditStatus = (AccountCreditStatus)Convert.ToByte(e.Value);
                break;

            case 5:
                AvailableCredit = (int)e.Value;
                break;

            case 6:
                AmountToClear = (int)e.Value;
                break;

            case 7:
                ClearanceThreshold = (int)e.Value;
                break;

            case 8:
                AggregatedDebt = (int)e.Value;
                break;

            case 9:
                CreditReferences.Clear();
                if (e.Value != null)
                {
                    foreach (object it in (IEnumerable <object>)e.Value)
                    {
                        CreditReferences.Add(GXCommon.ToLogicalName(it));
                    }
                }
                break;

            case 10:
                ChargeReferences.Clear();
                if (e.Value != null)
                {
                    foreach (object it in (IEnumerable <object>)e.Value)
                    {
                        ChargeReferences.Add(GXCommon.ToLogicalName(it));
                    }
                }
                break;

            case 11:
                CreditChargeConfigurations.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);
                        }
                        GXCreditChargeConfiguration item = new GXCreditChargeConfiguration();
                        item.CreditReference         = GXCommon.ToLogicalName(it[0]);
                        item.ChargeReference         = GXCommon.ToLogicalName(it[1]);
                        item.CollectionConfiguration = (CreditCollectionConfiguration)Convert.ToByte(it[2]);
                        CreditChargeConfigurations.Add(item);
                    }
                }
                break;

            case 12:
                TokenGatewayConfigurations.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);
                        }
                        GXTokenGatewayConfiguration item = new GXTokenGatewayConfiguration();
                        item.CreditReference = GXCommon.ToLogicalName(it[0]);
                        item.TokenProportion = (byte)it[1];
                        TokenGatewayConfigurations.Add(item);
                    }
                }
                break;

            case 13:
                if (e.Value == null)
                {
                    AccountActivationTime = new GXDateTime(DateTime.MinValue);
                }
                else
                {
                    if (e.Value is byte[])
                    {
                        e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
                    }
                    else if (e.Value is string)
                    {
                        e.Value = new GXDateTime((string)e.Value);
                    }
                    if (e.Value is GXDateTime)
                    {
                        AccountActivationTime = (GXDateTime)e.Value;
                    }
                }
                break;

            case 14:
                if (e.Value == null)
                {
                    AccountClosureTime = new GXDateTime(DateTime.MinValue);
                }
                else
                {
                    if (e.Value is byte[])
                    {
                        e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
                    }
                    else if (e.Value is string)
                    {
                        e.Value = new GXDateTime((string)e.Value);
                    }
                    if (e.Value is GXDateTime)
                    {
                        AccountClosureTime = (GXDateTime)e.Value;
                    }
                }
                break;

            case 15:
                if (e.Value != null)
                {
                    List <object> tmp;
                    if (e.Value is List <object> )
                    {
                        tmp = (List <object>)e.Value;
                    }
                    else
                    {
                        tmp = new List <object>((object[])e.Value);
                    }
                    Currency.Name  = (string)tmp[0];
                    Currency.Scale = (sbyte)tmp[1];
                    Currency.Unit  = (Currency)Convert.ToByte(tmp[2]);
                }
                else
                {
                    Currency.Name  = null;
                    Currency.Scale = 0;
                    Currency.Unit  = 0;
                }
                break;

            case 16:
                LowCreditThreshold = (int)e.Value;
                break;

            case 17:
                NextCreditAvailableThreshold = (int)e.Value;
                break;

            case 18:
                MaxProvision = (UInt16)e.Value;
                break;

            case 19:
                MaxProvisionPeriod = (int)e.Value;
                break;

            default:
                e.Error = ErrorCode.ReadWriteDenied;
                break;
            }
        }
Exemple #3
0
        void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
        {
            switch (e.Index)
            {
            case 1:
                LogicalName = GXCommon.ToLogicalName(e.Value);
                break;

            case 2:
                AccountStatus = (AccountStatus)((object[])e.Value)[0];
                PaymentMode   = (PaymentMode)((object[])e.Value)[1];
                break;

            case 3:
                CurrentCreditInUse = (byte)e.Value;
                break;

            case 4:
                if ((string)e.Value == "")
                {
                    CurrentCreditStatus = (AccountCreditStatus)0;
                }
                else
                {
                    GXByteBuffer bb = new GXByteBuffer();
                    GXCommon.SetBitString(bb, e.Value);
                    CurrentCreditStatus = (AccountCreditStatus)bb.GetUInt8(1);
                }
                break;

            case 5:
                AvailableCredit = (int)e.Value;
                break;

            case 6:
                AmountToClear = (int)e.Value;
                break;

            case 7:
                ClearanceThreshold = (int)e.Value;
                break;

            case 8:
                AggregatedDebt = (int)e.Value;
                break;

            case 9:
                CreditReferences.Clear();
                if (e.Value != null)
                {
                    foreach (object it in (object[])e.Value)
                    {
                        CreditReferences.Add(GXCommon.ToLogicalName(it));
                    }
                }
                break;

            case 10:
                ChargeReferences.Clear();
                if (e.Value != null)
                {
                    foreach (object it in (object[])e.Value)
                    {
                        ChargeReferences.Add(GXCommon.ToLogicalName(it));
                    }
                }
                break;

            case 11:
                CreditChargeConfigurations.Clear();
                if (e.Value != null)
                {
                    foreach (object[] it in (object[])e.Value)
                    {
                        GXCreditChargeConfiguration item = new GXCreditChargeConfiguration();
                        item.CreditReference = GXCommon.ToLogicalName(it[0]);
                        item.ChargeReference = GXCommon.ToLogicalName(it[1]);
                        if ((string)it[2] == "")
                        {
                            item.CollectionConfiguration = 0;
                        }
                        else
                        {
                            GXByteBuffer tmp2 = new GXByteBuffer();
                            GXCommon.SetBitString(tmp2, it[2]);
                            item.CollectionConfiguration = (CreditCollectionConfiguration)tmp2.GetUInt8(1);
                        }
                        CreditChargeConfigurations.Add(item);
                    }
                }
                break;

            case 12:
                TokenGatewayConfigurations.Clear();
                if (e.Value != null)
                {
                    foreach (object[] it in (object[])e.Value)
                    {
                        GXTokenGatewayConfiguration item = new GXTokenGatewayConfiguration();
                        item.CreditReference = GXCommon.ToLogicalName(it[0]);
                        item.TokenProportion = (byte)it[1];
                        TokenGatewayConfigurations.Add(item);
                    }
                }
                break;

            case 13:
                if (e.Value == null)
                {
                    AccountActivationTime = new GXDateTime(DateTime.MinValue);
                }
                else
                {
                    if (e.Value is byte[])
                    {
                        e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
                    }
                    else if (e.Value is string)
                    {
                        e.Value = new GXDateTime((string)e.Value);
                    }
                    if (e.Value is GXDateTime)
                    {
                        AccountActivationTime = (GXDateTime)e.Value;
                    }
                }
                break;

            case 14:
                if (e.Value == null)
                {
                    AccountClosureTime = new GXDateTime(DateTime.MinValue);
                }
                else
                {
                    if (e.Value is byte[])
                    {
                        e.Value = GXDLMSClient.ChangeType((byte[])e.Value, DataType.DateTime, settings.UseUtc2NormalTime);
                    }
                    else if (e.Value is string)
                    {
                        e.Value = new GXDateTime((string)e.Value);
                    }
                    if (e.Value is GXDateTime)
                    {
                        AccountClosureTime = (GXDateTime)e.Value;
                    }
                }
                break;

            case 15:
                object[] tmp = (object[])e.Value;
                Currency.Name  = (string)tmp[0];
                Currency.Scale = (sbyte)tmp[1];
                Currency.Unit  = (Currency)tmp[2];
                break;

            case 16:
                LowCreditThreshold = (int)e.Value;
                break;

            case 17:
                NextCreditAvailableThreshold = (int)e.Value;
                break;

            case 18:
                MaxProvision = (UInt16)e.Value;
                break;

            case 19:
                MaxProvisionPeriod = (int)e.Value;
                break;

            default:
                e.Error = ErrorCode.ReadWriteDenied;
                break;
            }
        }