Пример #1
0
        public static bool Save(Model.Template template)
        {
            bool saved = false;

            try {
                template.Update();
                if (template.TemplateId > 0)
                {
                    foreach (var field in template.Fields)
                    {
                        field.TemplateId = template.TemplateId;
                        field.Update();
                        if (field.TemplateFieldId == 0)
                        {
                            return(false);
                        }
                    }
                    saved = true;
                }
            }
            catch {
                saved = false;
            }
            return(saved);
        }
Пример #2
0
 public Import(Model.Template template,
               Func <string> getImporter = null,
               bool logSteps             = false)
 {
     this.Template = template;
     if (getImporter != null)
     {
         this.Template.Importer = getImporter;
     }
     this.LogSteps = logSteps;
 }
Пример #3
0
 public void Execute()
 {
     if (IsValid)
     {
         this.IncomingFile = Construct.Template(Template, File);
         this.IsValid      = this.Template.HasGoodColumnMatch(this.IncomingFile.Fields);
         if (this.IsValid)
         {
             EvaluateFields(this.IncomingFile.Fields);
         }
         else
         {
             this.Messages.Add($"Incoming file does not have the correct,{this.Template.Fields.Count}, column but rather {this.IncomingFile.Fields.Count}.");
         }
     }
 }
Пример #4
0
 public static Model.Template Template(string referenceFile,
                                       bool purgeWorkingOnEveryRun,
                                       string processName, string processGroup,
                                       bool headers            = true,
                                       bool isActive           = true,
                                       string connectionString = null, string loadTransformProcedure = null, string fileNamePattern = null, string onErrorEmail = null)
 {
     Model.Template template = new Model.Template {
         PurgeWorkingOnEveryRun = purgeWorkingOnEveryRun,
         ProcessName            = processName,
         ProjectGroup           = processGroup,
         ConnectionString       = connectionString,
         IsActive = isActive,
         LoadTransformProcedure = loadTransformProcedure,
         FileNamePattern        = fileNamePattern,
         OnErrorEmail           = onErrorEmail
     };
     return(Template(template, referenceFile));
 }
Пример #5
0
        public Validator(string file, Model.Template template)
        {
            this.File     = file;
            this.Template = template;
            var fi = new FileInfo(file);

            //reqo
            if (template.FileNamePattern != "*")
            {
                IsValid = Regex.IsMatch(file, template.FileNamePattern);
            }
            else
            {
                IsValid = true;
            }
            if (!IsValid)
            {
                Messages.Add("Wrong file extension for the import.");
            }
        }
Пример #6
0
        public static Model.Template Template(Model.Template template, string referenceFile)
        {
            var temp      = referenceFile.ToLower();
            var fileInfo  = new FileInfo(referenceFile);
            var extension = fileInfo.Extension.ToLower();

            template.FileNamePattern = $"*{extension}";
            var dataHandler = Data.DataFileHandler.GetHandler(referenceFile);

            if (extension == ".csv")
            {
                template.Delimiter = ",";
            }
            else if (extension == ".txt")
            {
                template.Delimiter = template.Delimiter ?? "\t";
            }
            else if (extension != ".xls" && extension != ".xlsx")
            {
                template.Delimiter = template.Delimiter ?? "\t";
            }
            template.Fields = dataHandler.FieldDefinitions(referenceFile, template);
            return(template);
        }
Пример #7
0
 public Validator(Model.Template template)
 {
     this.Template = template;
 }