Ejemplo n.º 1
0
        private static IDataLoader CreateTablesLoader <DLParams, Producer>(FileStream stream, string fileSetName, bool sourceOrder, TableOverwriteMode overwriteMode)
            where DLParams : DataLoaderParams
            where Producer : EntityProducer
        {
            var serializer = new XmlSerializer(typeof(DLParams));
            var p          = (DLParams)serializer.Deserialize(stream);

            p.TableMetadataEntity.EntityKind = p.TableMetadataEntity.EntitySet + "Item";
            if (p.ProcessorParams != null)
            {
                p.ProcessorParams.EntityKind = p.TableMetadataEntity.EntityKind;
                p.ProcessorParams.EntitySet  = p.TableMetadataEntity.EntitySet;
            }

            if (sourceOrder && p.ProcessorParams != null && !String.IsNullOrEmpty(p.ProcessorParams.PartitionKeyPropertyName) &&
                p.ProcessorParams.PartitionKeyPropertyName.ToLower() != DataLoaderConstants.ValueUniqueAutoGen)
            {
                throw new ApplicationException("PartitionKey must be empty or equal to 'New.Guid' in .cfg when use sourceOrder");
            }

            if (overwriteMode == TableOverwriteMode.Update && p.ProcessorParams != null &&
                (String.IsNullOrEmpty(p.ProcessorParams.PartitionKeyPropertyName) ||
                 p.ProcessorParams.PartitionKeyPropertyName.ToLower() == DataLoaderConstants.ValueUniqueAutoGen ||
                 String.IsNullOrEmpty(p.ProcessorParams.PartitionKeyPropertyName) ||
                 p.ProcessorParams.PartitionKeyPropertyName.ToLower() == DataLoaderConstants.ValueUniqueAutoGen))
            {
                throw new ApplicationException("PartitionKey and RowKey must be provided in .cfg for /mode=update");
            }

            EntityProducer producer = null;

            if (!p.TableMetadataEntity.IsEmpty)
            {
                producer = (Producer)Activator.CreateInstance(typeof(Producer),
                                                              fileSetName,
                                                              p.TableMetadataEntity.EntitySet,
                                                              p.TableMetadataEntity.EntityKind,
                                                              p.ProducerParams,
                                                              sourceOrder);
            }

            var processor = new TableEntityProcessor(p.ProcessorParams, overwriteMode);

            return(new TableDataLoader(p, producer, processor, overwriteMode));
        }
Ejemplo n.º 2
0
        private static IDataLoader CreateConsoleLoader <DLParams, Producer>(FileStream stream, string fileSetName, bool sourceOrder)
            where DLParams : DataLoaderParams
            where Producer : EntityProducer
        {
            var serializer = new XmlSerializer(typeof(DLParams));
            var p          = (DLParams)serializer.Deserialize(stream);

            p.TableMetadataEntity.EntityKind = p.TableMetadataEntity.EntitySet + "Item";
            EntityProducer producer = null;

            if (!p.TableMetadataEntity.IsEmpty)
            {
                producer = (Producer)Activator.CreateInstance(typeof(Producer),
                                                              fileSetName,
                                                              p.TableMetadataEntity.EntitySet,
                                                              p.TableMetadataEntity.EntityKind,
                                                              p.ProducerParams,
                                                              sourceOrder);
            }
            var processor = new CoutEntityProcessor();
            var loader    = new DataLoader(p, producer, processor);

            return(loader);
        }
Ejemplo n.º 3
0
 public TableDataLoader(DataLoaderParams parameters, EntityProducer producer, EntityProcessor processor,
                        TableOverwriteMode overwriteMode)
     : base(parameters, producer, processor)
 {
     this.overwriteMode = overwriteMode;
 }
Ejemplo n.º 4
0
 public DataLoader(DataLoaderParams parameters, EntityProducer producer, EntityProcessor processor)
 {
     Params    = parameters;
     Producer  = producer;
     Processor = processor;
 }
Ejemplo n.º 5
0
 public TableDataLoader(DataLoaderParams parameters, EntityProducer producer, EntityProcessor processor,
                        TableOverwriteMode overwriteMode)
     : base(parameters, producer, processor)
 {
     this.overwriteMode = overwriteMode;
 }
Ejemplo n.º 6
0
 public DataLoader(DataLoaderParams parameters, EntityProducer producer, EntityProcessor processor)
 {
     Params = parameters;
     Producer = producer;
     Processor = processor;
 }