예제 #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
파일: Validator.cs 프로젝트: DNCarroll/bxl
 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
파일: Validator.cs 프로젝트: DNCarroll/bxl
        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
파일: Validator.cs 프로젝트: DNCarroll/bxl
 public Validator(Model.Template template)
 {
     this.Template = template;
 }