Exemple #1
0
 public static Boolean TryParse(JObject JSON, out IOTDevice IOTDevice)
 {
     try
     {
         IOTDevice = new IOTDevice(CLI.Parse(JSON["CLI"].Value <String>()),
                                   JSON["SIMNumber"]?.Value <String>().IsNotNullOrEmpty() == true
                                        ? SIM_Id.Parse(JSON["SIMNumber"].Value <String>())
                                        : default,
        public static Boolean TryParseAsavie(JObject JSON, out SIMHardware SIMHardware)
        {
            #region Documentation

            // GetSIMHardwares:
            // {
            //    "CLI":                    "204043729xxxxxx",
            //    "SIMNumber":              "89314404000132xxxxxx",
            //    "Description":            null,
            //    "InventoryRef":           null,
            //    "State":                  3,
            //    "Version":                5,
            //    "ActorStatus":            0,
            //    "ForeignAttributes":      null,
            //    "Tariff":                 null,
            //    "Bundle":                 null,
            //    "Operator":               "vodafone",
            //    "Hints":                  null,
            //    "NetworkStatus":          0,
            //    "Created":                "2018-04-31T10:44:41.7019783Z",
            //    "SOC":                    null,
            //    "InternalSOC":            null,
            //    "PurchaseOrder":          "na",
            //    "Provider":               "westbase",
            //    "ProviderTariff":         "SP01_500MAX#10mb",
            //    "ProviderPrice":          "2.00gbp",
            //    "ProviderStartDate":      "2018-04-31T11:00:00Z"
            // }

            #endregion

            try
            {
                var PurchaseOrder = JSON["PurchaseOrder"]?.Value <String>();
                if (PurchaseOrder == "na")
                {
                    PurchaseOrder = null;
                }

                var ProviderTariff = JSON["ProviderTariff"]?.Value <String>();
                if (ProviderTariff == "na")
                {
                    ProviderTariff = null;
                }

                var ProviderPrice = JSON["ProviderPrice"]?.Value <String>();
                if (ProviderPrice == "na")
                {
                    ProviderPrice = null;
                }


                SIMHardware = new SIMHardware(CLI.Parse(JSON["CLI"].Value <String>()),
                                              JSON["SIMNumber"]?.Value <String>().IsNotNullOrEmpty() == true
                                                   ? SIM_Id.Parse(JSON["SIMNumber"].Value <String>())
                                                   : default,
Exemple #3
0
        public static Boolean TryParseAsavie(JObject JSON, out IOTDevice IOTDevice)
        {
            #region Documentation

            // GetIOTDevices:
            // {
            //    "CLI":                    "204043729927975",
            //    "SIMNumber":              "89314404000132906315",
            //    "SOC":                    null,
            //    "InternalSOC":            "iot",
            //    "Description":            null,
            //    "IPAddress":              "10.20.0.3",
            //    "StartDate":              "2018-06-20T11:13:47.4048154Z",
            //    "EndDate":                "0001-01-01T00:00:00",
            //    "FriendlyName":           "oem-204043729927975",
            //    "Hints":                  null,
            //    "ProvisioningMetaData":   null,
            //    "Status":                 1,
            //    "Version":                5,
            //    "ActorStatus":            0,
            //    "NetworkStatus":          0,
            //    "Enabled":                true,
            //    "LockIMEI":               false,
            //    "IMEI":                   null,
            //    "LastSync":               "2018-06-20T11:13:47.5767265Z",
            //    "LastConnected_Start":    null,
            //    "LastConnected_End":      null,
            //    "LastConnected_MCC":      "",
            //    "LastConnected_MNC":      ""
            // }

            #endregion

            try
            {
                var EndDate       = new DateTime?();
                var EndDateString = JSON["EndDate"]?.Value <String>();
                if (EndDateString.IsNotNullOrEmpty())
                {
                    if (EndDateString == "0001-01-01T00:00:00" ||
                        EndDateString == "01/01/0001 00:00:00")
                    {
                        EndDate = null;
                    }

                    else
                    {
                        EndDate = JSON["EndDate"]?.Value <DateTime>();
                    }
                }

                IOTDevice = new IOTDevice(CLI.Parse(JSON["CLI"].Value <String>()),
                                          JSON["SIMNumber"]?.Value <String>().IsNotNullOrEmpty() == true
                                               ? new SIM_Id?(SIM_Id.Parse(JSON["SIMNumber"].Value <String>()))
                                               : null,
                                          JSON["SOC"]?.Value <String>(),
                                          JSON["InternalSOC"]?.Value <String>(),
                                          JSON["Description"]?.Value <String>(),
                                          JSON["IPAddress"]?.Value <String>().IsNotNullOrEmpty() == true
                                               ? org.GraphDefined.Vanaheimr.Hermod.IPAddress.Parse(JSON["IPAddress"]?.Value <String>())
                                               : null,
                                          JSON["StartDate"]?.Value <DateTime>(),
                                          EndDate,
                                          JSON["FriendlyName"]?.Value <String>(),
                                          JSON["Hints"]?.Value <String>(),
                                          JSON["ProvisioningMetaData"]?.Value <String>(),
                                          JSON["Status"]?.Value <Byte>(),
                                          JSON["Version"]?.Value <Byte>(),
                                          JSON["ActorStatus"]?.Value <Byte>(),
                                          JSON["NetworkStatus"]?.Value <Byte>(),
                                          JSON["Enabled"]?.Value <Boolean>(),
                                          JSON["LockIMEI"]?.Value <Boolean>(),
                                          JSON["IMEI"]?.Value <String>(),
                                          JSON["LastSync"]?.Value <DateTime>(),
                                          JSON["LastConnected_Start"] is JObject
                                               ? new Last_Connected?(new Last_Connected(JSON["LastConnected_Start"].Value <DateTime>(),
                                                                                        EndDate,
                                                                                        JSON["LastConnected_MCC"]?.Value <String>(),
                                                                                        JSON["LastConnected_MNC"]?.Value <String>()))
                                               : null);

                return(true);
            }
            catch (Exception)
            { }

            IOTDevice = null;
            return(false);
        }