Inheritance: IDeviceImportContext
Beispiel #1
0
        public static DeviceImportContext BeginImport(DiscoDataContext Database, string Filename, bool HasHeader, Stream FileContent)
        {
            if (FileContent == null)
                throw new ArgumentNullException("FileContent");

            if (string.IsNullOrWhiteSpace(Filename))
                Filename = "<None Specified>";

            DeviceImportContext context;
            List<Tuple<string, DeviceImportFieldTypes>> header;
            List<string[]> rawData;

            using (TextReader csvTextReader = new StreamReader(FileContent))
            {
                using (CsvReader csvReader = new CsvReader(csvTextReader, HasHeader))
                {
                    csvReader.DefaultParseErrorAction = ParseErrorAction.ThrowException;
                    csvReader.MissingFieldAction = MissingFieldAction.ReplaceByNull;

                    rawData = csvReader.ToList();
                    header = csvReader.GetFieldHeaders().Select(h => Tuple.Create(h, DeviceImportFieldTypes.IgnoreColumn)).ToList();
                }
            }

            context = new DeviceImportContext(Filename, header, rawData);

            context.GuessHeaderTypes(Database);

            return context;
        }
        public static ScheduledTaskStatus ScheduleNow(DeviceImportContext Context)
        {
            if (Context == null)
                throw new ArgumentNullException("Context");

            // Build Data Map
            var task = new DeviceImportApplyTask();
            JobDataMap taskData = new JobDataMap() { { JobDataMapContext, Context } };

            // Schedule Task
            return task.ScheduleTask(taskData);
        }
Beispiel #3
0
 internal static void Import_StoreContext(DeviceImportContext Context)
 {
     string key = string.Format(ImportSessionCacheKey, Context.SessionId);
     HttpRuntime.Cache.Insert(key, Context, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
 }
 public abstract int? GuessHeader(DiscoDataContext Database, DeviceImportContext Context);
 public abstract bool Parse(DiscoDataContext Database, IDeviceImportCache Cache, DeviceImportContext Context, int RecordIndex, string DeviceSerialNumber, Device ExistingDevice, Dictionary<DeviceImportFieldTypes, string> Values, string Value);