Example #1
0
        private int SaveAttributes(MapAttributesModel model)
        {
            using (var dbContext = new DatabaseContext())
            {
                var mapAttributes = new MapAttributes();
                mapAttributes.name     = model.Name;
                mapAttributes.imei     = model.IMEI;
                mapAttributes.imsi     = model.IMSI;
                mapAttributes.ue_label = model.Ue_Label;
                mapAttributes.ue_name  = model.Ue_Name;
                mapAttributes.class_id = model.ClassId;
                dbContext.MapAttributes.Add(mapAttributes);
                dbContext.SaveChanges();

                return(mapAttributes.attributeid);
            }
        }
Example #2
0
        public MapAttributesModel ParseAttributes()
        {
            var returnValue = new MapAttributesModel();

            string[] Alllines = File.ReadAllLines(this.filePath);
            foreach (string line in Alllines)
            {
                string[] lineParts  = line.Split(',');
                string   lineHeader = lineParts[0];

                if (lineHeader == "#EI")
                {
                    // Entry 0 = #EI -> entry 3 = IMEI
                    returnValue.IMEI = lineParts[3];
                }

                if (lineHeader == "#SI")
                {
                    // Entry 0 = #SI -> entry 3 = IMSI
                    returnValue.IMSI = lineParts[3];
                }

                if (lineHeader == "#DN")
                {
                    // Entry 0 = #DN -> entry 3 = device name
                    returnValue.Ue_Name = lineParts[3];
                }

                if (lineHeader == "#DL")
                {
                    // Entry 0 = #DL -> entry 3 = device label
                    returnValue.Ue_Label = lineParts[3];
                }

                if (!string.IsNullOrEmpty(returnValue.IMEI) && !string.IsNullOrEmpty(returnValue.IMSI) && !string.IsNullOrEmpty(returnValue.Ue_Name) &&
                    !string.IsNullOrEmpty(returnValue.Ue_Label))
                {
                    break;
                }
            }

            return(returnValue);
        }