public ProxiaMessageHandler(string rootPath, FilenameFormat filenameFormat, bool clearStoredParam, Logger logger, ProxiaMessageError ifError)  //WG ifError need be init before NextMessage();
        {
            FilenameFormat = filenameFormat;
            _rootPath      = rootPath;
            IfError        = ifError;
            _logger        = logger;

            _state = new FileReadingState(Properties.Settings.Default.RegistryPath, FilenameFormat, clearStoredParam);

            NextMessage();
        }
示例#2
0
            public static string Create(InvoiceSummary invoice)
            {
                //TODO: key should be the registered date?
                var fmt = new FilenameFormat
                {
                    InvoiceDate    = invoice.InvoiceDate ?? DateTime.MinValue,
                    Supplier       = invoice.Supplier,
                    Id             = invoice.Id,
                    RegisteredDate = invoice.CreatedDate ?? DateTime.MinValue,
                    State          = invoice.TaskState,
                };

                return(fmt.ToString());
            }
示例#3
0
 public FilenameProvider(FilenameFormat filenameFormat, string outputDir, string extension)
 {
     usedFilenames       = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
     this.filenameFormat = filenameFormat;
     this.outputDir      = outputDir;
     if (!extension.StartsWith("."))
     {
         this.extension = "." + extension;
     }
     else
     {
         this.extension = extension;
     }
 }
示例#4
0
            public static string Create(InvoiceFull invoice)
            {
                var registeredDate = invoice.TaskAssignments.Min(ta => ta.Task.Task.CreatedTimestamp.FromMediusDate());
                //TODO: key should be the registered date?
                var fmt = new FilenameFormat
                {
                    InvoiceDate    = invoice.Invoice.InvoiceDate.FromMediusDate() ?? DateTime.MinValue,
                    Supplier       = invoice.Invoice.Supplier.Name,
                    Id             = invoice.Invoice.Id,
                    RegisteredDate = registeredDate ?? DateTime.MinValue,
                    State          = invoice.FirstTask?.Task?.State
                };

                return(fmt.ToString());
            }
        public FileReadingState(string registryPath, FilenameFormat filenameFormat, bool clearStoredParam)
        {
            _keyname        = registryPath;
            _filenameFormat = filenameFormat;

            _typeString      = string.Empty;
            _timestampString = string.Empty;

            _regex = _filenameFormat == FilenameFormat.Long
              ? @"^.*\\([^\\0-9]+)([0-9]{17})\.(?:txt|TXT)$"  //WG Corection regex pattern
              : @"^.*\\([^\\0-9]+)([0-9]{14})\.(?:txt|TXT)$";

            _supportedTypes = DocumentBase.GetDeutchNames();

            if (clearStoredParam)
            {
                CurrentFilePath = string.Empty; //set change CurrentLine
            }
            else
            {
                _currentLine    = Registry.GetValue(_keyname, nameof(CurrentLine), 0) as int? ?? 0;
                CurrentFilePath = Registry.GetValue(_keyname, nameof(CurrentFilePath), string.Empty) as string ?? string.Empty; //Important order, set canchange CurrentLine
            }
        }