public KhachHangAppService(IRepository <KhachHang, long> khachHangRepository,
                                   IRepository <User, long> userRepository,
                                   UserRegistrationManager userRegistrationManager,
                                   LogInManager logInManager,
                                   IPasswordHasher <User> passwordHasher,
                                   IRepository <DanhMucTinhThanh> tinhThanhRepository,
                                   IRepository <DanhMucQuanHuyen> quanHuyenRepository,
                                   IGlobalCache globalCache,

                                   IAppFolders appFolders,
                                   IKhachHangExcelImporter khachHangExcelImporter
                                   )
        {
            _khachHangRepository     = khachHangRepository;
            _userRepository          = userRepository;
            _userRegistrationManager = userRegistrationManager;
            _logInManager            = logInManager;
            _passwordHasher          = passwordHasher;
            _tinhThanhRepository     = tinhThanhRepository;
            _quanHuyenRepository     = quanHuyenRepository;
            _globalCache             = globalCache;

            _appFolders             = appFolders;
            _khachHangExcelImporter = khachHangExcelImporter;
        }
Ejemplo n.º 2
0
        protected OutputProvider(OrchestratorConfig config, IGlobalCache globalCache)
        {
            _config      = config;
            _globalCache = globalCache;

            if (config.OutputFields == null)
            {
                _fieldsToUse = null; //this will be overwritten based on actual set of fields used (SetFieldsToUse method)
            }
            else //Output fields specified in config, they will drive output
            {                                                //this list of field names will not be overwritten
                _fieldsToUse = config.OutputFields.ListOfSingleElements(0)?.ToList();
                Debug.Assert(_fieldsToUse.IsNonEmptyList()); //if specified, the list must be complete
                //TODO: Error message instead of the above Assert (part of "config scrubber")
            }

            _outputToWriter = _config.AsyncOutput ? _config.AsyncOutputConsumer == OrchestratorConfig.DefaultAsyncOutputConsumer && (_config.OutputWriters != null || _config.OutputFileNames != null)
                                               : _config.OutputConsumer == OrchestratorConfig.DefaultOutputConsumer && (_config.OutputWriters != null || _config.OutputFileNames != null);

            _initErrorOccurred = new Lazy <bool>(() => !InitOutput());

            _targets      = new ConcurrentDictionary <int, LineCounts>();
            _lastTargetNo = 1;

            _atOutputStart = new SingleUseBool();
        } //ctor
Ejemplo n.º 3
0
        /// <summary>
        /// Factory method that returns a concrete instance of the derived class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        /// <param name="x12Delimiters"></param>
        /// <returns></returns>
        internal static OutputProvider CreateProvider(OrchestratorConfig config, IGlobalCache globalCache, X12Delimiters x12Delimiters)
        {
            switch (config.OutputDataKind)
            {
            case KindOfTextData.Raw:
                return(new RawOutputProvider(config, globalCache));

            case KindOfTextData.Keyword:
                return(new KwOutputProvider(config, globalCache));

            case KindOfTextData.Delimited:
                return(new DelimitedOutputProvider(config, globalCache));

            case KindOfTextData.Flat:
                return(new FlatOutputProvider(config, globalCache));

            case KindOfTextData.Arbitrary:
                return(new ArbitraryOutputProvider(config, globalCache));

            case KindOfTextData.X12:
                return(new X12OutputProvider(config, globalCache, x12Delimiters));

            case KindOfTextData.XML:
                var allItemTypes = ItemType.Void | ItemType.Bool | ItemType.DateTime | ItemType.Decimal | ItemType.Int | ItemType.String;
                return(new XrecordOutputProvider(allItemTypes, config, globalCache));

            case KindOfTextData.JSON:
            case KindOfTextData.UnboundJSON:
                return(new XrecordOutputProvider(ItemType.DateTime, config, globalCache));

            default:
                //TODO: Message - fatal error, undetermined type of output data
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Factory method that returns a concrete instance of the derived class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        /// <param name="typeDefinitions"></param>
        /// <param name="x12DelimitersForOutput"></param>
        /// <returns></returns>
        internal static IntakeProvider CreateProvider(OrchestratorConfig config, IGlobalCache globalCache, TypeDefinitions typeDefinitions, X12Delimiters x12DelimitersForOutput)
        {
            switch (config.InputDataKind)
            {
            case KindOfTextData.Raw:
                return(new RawIntakeProvider(config, globalCache, typeDefinitions));

            case KindOfTextData.Keyword:
                return(new KwIntakeProvider(config, globalCache, typeDefinitions));

            case KindOfTextData.Delimited:
                return(new DelimitedIntakeProvider(config, globalCache, typeDefinitions));

            case KindOfTextData.Flat:
                return(new FlatIntakeProvider(config, globalCache, typeDefinitions));

            case KindOfTextData.Arbitrary:
                return(new ArbitraryIntakeProvider(config, globalCache, typeDefinitions));

            case KindOfTextData.X12:
                return(new X12IntakeProvider(config, globalCache, typeDefinitions, x12DelimitersForOutput));

            case KindOfTextData.XML:
            case KindOfTextData.JSON:
            case KindOfTextData.UnboundJSON:
                return(new XrecordIntakeProvider(config, globalCache, typeDefinitions));

            default:
                //TODO: Message - fatal error, undetermined type of intake data
                return(null);
            }
        }
Ejemplo n.º 5
0
 internal ErrorEventArgs(string origin, string context, Exception exception, IGlobalCache globalCache) : base()
 {
     Origin      = origin;
     Context     = context;
     Exception   = exception;
     GlobalCache = globalCache;
 }
Ejemplo n.º 6
0
        internal readonly Func <Phase, int, PhaseStatus> _processingStatusSupplier; // internal to allow ReadOnlyCluster ctor (& record specific transform providers) use the same processingStatusSupplier

        //Note that KeyValCluster is constructed eagerly (recList will be consumed upon object creation)

        internal KeyValCluster(IEnumerable <IRecord> recList,
                               int clstrNo,
                               int startRecNo,
                               int startSourceNo,
                               IGlobalCache globalCache,
                               IDictionary <string, object> propertyBin,
                               TypeDefinitions typeDefinitions,
                               OrchestratorConfig config,
                               Func <Phase, int, PhaseStatus> processingStatusSupplier)
        {
            this.ClstrNo       = clstrNo;
            this.StartRecNo    = startRecNo;
            this.StartSourceNo = startSourceNo;
            //Note that StartSourceNo should match the 1st record, but to facilitate cloning, etc. it was decided to expose it
            // separately as ctor parm as opposed to reading it like this:  this.StartSourceNo = recList.Any() ? recList.First().SourceNo : 0;
            this._recordColl               = new RecordCollection(recList);
            this.GlobalCache               = globalCache;
            this._typeDefinitions          = typeDefinitions;
            this._config                   = config;
            this._processingStatusSupplier = processingStatusSupplier;

            //Make sure all records have the ClstrNo matching the cluster they belong to:
            this._recordColl.ForEach(r => (r as KeyValRecord)?.SetClstrNo(clstrNo));

            PropertyBin = (_config.PropertyBinEntities & PropertyBinAttachedTo.Clusters) == PropertyBinAttachedTo.Clusters
               ? propertyBin ?? new Dictionary <string, object>() //"reuse" PB in case of cloning, creation of ReadOnlyCluster wrapper, etc.
               : null;                                            //null if Clusters flag not set in PropertyBinEntities
        } //ctor
Ejemplo n.º 7
0
 public SysopGlobal(IAccountRepository accountRepository, IAccountKeyRepository accountKeyRepository, IGlobalCache globalCache, IMessagingCenter messagingCenter)
 {
     _accountRepository    = accountRepository;
     _accountKeyRepository = accountKeyRepository;
     _globalCache          = globalCache;
     _messagingCenter      = messagingCenter;
 }
Ejemplo n.º 8
0
 internal PhaseEventArgs(Phase phase, int clstrCnt, int recCnt, int transfmrNo, IGlobalCache globalCache) : base()
 {
     Phase       = phase;
     ClstrCnt    = clstrCnt;
     RecCnt      = recCnt;
     TransfmrNo  = transfmrNo;
     GlobalCache = globalCache;
 }
 public UploadController(IAppFolders appFolders,
                         IRepository <CongViec, long> congViecRepository,
                         IGlobalCache globalCache)
 {
     _appFolders         = appFolders;
     _congViecRepository = congViecRepository;
     _globalCache        = globalCache;
 }
Ejemplo n.º 10
0
 private Tuple <ExternalLine, int> _inLine(IGlobalCache gc)
 {
     if (_inPtr >= _inLines.Count)
     {
         return(null);
     }
     return(_inLines[_inPtr++]);
 }
Ejemplo n.º 11
0
        public StorageProvider(IApplicationSettings applicationSettings, IGlobalCache globalCache)
        {
            var cloudStorageAccount = CloudStorageAccount.Parse(applicationSettings.GetConnectionString(ConnectionStringKeys.AzureStorage));

            CloudTableClient = cloudStorageAccount.CreateCloudTableClient();
            CloudFileClient  = cloudStorageAccount.CreateCloudFileClient();

            GlobalCache = globalCache;
        }
        public SoBaoHanhAppService(IRepository <SoBaoHanh> soBaoHanhRepository,
                                   IGlobalCache globalCache
                                   ) : base(soBaoHanhRepository)
        {
            LocalizationSourceName = NewCMConsts.LocalizationSourceName;

            _soBaoHanhRepository = soBaoHanhRepository;
            _globalCache         = globalCache;
        }
Ejemplo n.º 13
0
 internal ProcessResult(CompletionStatus completionStatus, int rowsRead, int clustersRead, int clustersWritten, int rowsWritten, IGlobalCache globalCache)
 {
     CompletionStatus = completionStatus;
     RowsRead         = rowsRead;
     ClustersRead     = clustersRead;
     ClustersWritten  = clustersWritten;
     RowsWritten      = rowsWritten;
     GlobalCache      = globalCache;
 }
Ejemplo n.º 14
0
 public MenuRoutines(IResourceManager resourceManager, IAccountRepository accountRepository, AppSettings configuration, IGlobalCache globalCache, IAccountKeyRepository accountKeyRepository, PointerDictionary <SessionBase> channelDictionary)
 {
     _resourceManager      = resourceManager;
     _accountRepository    = accountRepository;
     _accountKeyRepository = accountKeyRepository;
     _configuration        = configuration;
     _globalCache          = globalCache;
     _channelDictionary    = channelDictionary;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Ctor intended to be called by the CreateProvider method of the base class
 /// </summary>
 /// <param name="config"></param>
 /// <param name="globalCache"></param>
 /// <param name="typeDefinitions"></param>
 /// <param name="x12DelimitersForOuput"></param>
 internal X12IntakeProvider(OrchestratorConfig config, IGlobalCache globalCache, TypeDefinitions typeDefinitions, X12Delimiters x12DelimitersForOuput)
     : base(config, globalCache, typeDefinitions, sNo => sNo == 0 ? "Segment" : string.Format("Elem{0:000}", sNo)) //in case of X12, fields are named: Segment, Elem001, Elem002,...
 {
     _x12DelimitersForOutput = x12DelimitersForOuput;
     _x12FieldDelimiter      = config.DefaultX12FieldDelimiter;
     if (_x12FieldDelimiter == default(char))
     {
         _x12FieldDelimiter = '*';
     }
 }
Ejemplo n.º 16
0
        private readonly List <int> _fieldWidths; //fixed field widths

        /// <summary>
        /// Ctor intended to be called by the CreateProvider method of the base class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        /// <param name="typeDefinitions"></param>
        internal FlatIntakeProvider(OrchestratorConfig config, IGlobalCache globalCache, TypeDefinitions typeDefinitions) : base(config, globalCache, typeDefinitions)
        {
            //In case field widths only are configured (no field names) and no names in the header row, allow assignment of default names:
            if (FieldsNamesFromConfig.IsEmptyList() && !_config.HeadersInFirstInputRow)
            {
                IncludeFieldsEnMasse(FieldsNamesFromConfig);
            }

            _fieldWidths = config.InputFields.ListOfSingleElements(1)
                           .ToListOfInts((config.DefaultInputFieldWidth == 0) ? 10 : config.DefaultInputFieldWidth)      //in case of undefined default width, 10 will be used
                           .ToList();
        }
Ejemplo n.º 17
0
        public GlobalCacheRepository(IEntityManagerProvider entityManagerProvider, IGlobalCache globalCache)
            : base(entityManagerProvider)
        {
            _globalCache = globalCache;
            entityManagerProvider.ManagerCreated += new EventHandler <EntityManagerCreatedEventArgs>(OnManagerCreated)
                                                    .MakeWeak(eh => entityManagerProvider.ManagerCreated -= eh);

            if (globalCache != null)
            {
                DefaultQueryStrategy = QueryStrategy.CacheOnly;
            }
        }
Ejemplo n.º 18
0
        private protected ExportedModuleBase(ILogger logger, AppSettings configuration, IFileUtility fileUtility, IGlobalCache globalCache, MbbsModule module, PointerDictionary <SessionBase> channelDictionary)
        {
            _logger        = logger;
            _configuration = configuration;
            _fileFinder    = fileUtility;
            _globalCache   = globalCache;

            Module            = module;
            ChannelDictionary = channelDictionary;

            FilePointerDictionary = new PointerDictionary <FileStream>(1, int.MaxValue);
            McvPointerDictionary  = new PointerDictionary <McvFile>();
        }
Ejemplo n.º 19
0
        private IReadOnlyList <int> _fieldWidths; //fixed field widths

        /// <summary>
        /// Ctor intended to be called by the CreateProvider method of the base class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        internal FlatOutputProvider(OrchestratorConfig config, IGlobalCache globalCache) : base(config, globalCache)
        {
            if (config.OutputFields == null)
            {
                _fieldWidths = null; //this will be overwritten based on actual set of fields used (SetFieldsToUse method)
            }
            else
            {                                                                                                             //this list of widths will not be overwritten
                _fieldWidths = config.OutputFields.ListOfSingleElements(1)
                               .ToListOfInts((config.DefaultOutputFieldWidth == 0) ? 10 : config.DefaultOutputFieldWidth) //in case of undefined default width, 10 will be used
                               .ToList();
            }
        } //ctor
Ejemplo n.º 20
0
        private protected static readonly byte[] NEW_LINE          = { (byte)'\r', (byte)'\n' }; //Just easier to read

        private protected ExportedModuleBase(MbbsModule module, PointerDictionary <SessionBase> channelDictionary)
        {
            _logger        = ServiceResolver.GetService <ILogger>();
            _configuration = ServiceResolver.GetService <IConfiguration>();
            _fileFinder    = ServiceResolver.GetService <IFileUtility>();
            _globalCache   = ServiceResolver.GetService <IGlobalCache>();

            Module            = module;
            ChannelDictionary = channelDictionary;

            FilePointerDictionary       = new PointerDictionary <FileStream>(1, int.MaxValue);
            McvPointerDictionary        = new PointerDictionary <McvFile>();
            BtrievePointerDictionaryNew = new Dictionary <IntPtr16, BtrieveFileProcessor>();
        }
 /// <summary>
 /// Verifies if passed global cache instance is the same as the one used before (i.e. held in _cacheInstance).
 /// </summary>
 /// <param name="instance">Instance to compare against the one held in _cacheInstanc.</param>
 /// <returns>True if passed instance is either null or not null and the same as stored in _cacheInstance; false otherwise.</returns>
 private bool VerifyInstance(IGlobalCache instance)
 {
     _callCount++;
     //Note that if _cacheInstance is null, then it assigns instance to it (and returns true)
     if (instance == null)
     {
         return(true);
     }
     if (_cacheInstance == null)
     {
         _cacheInstance = instance;                      //not thread-safe
     }
     return(_cacheInstance == instance);
 }
Ejemplo n.º 22
0
 public ResourceMgtUnitOfWork(
     [Import(RequiredCreationPolicy = CreationPolicy.NonShared)] IEntityManagerProvider <TempHireEntities>
     entityManagerProvider,
     [Import(AllowDefault = true)] IGlobalCache globalCache = null)
     : base(entityManagerProvider)
 {
     AddressTypes            = new GlobalCacheRepository <AddressType>(entityManagerProvider, globalCache);
     States                  = new GlobalCacheRepository <State>(entityManagerProvider, globalCache);
     PhoneNumberTypes        = new GlobalCacheRepository <PhoneNumberType>(entityManagerProvider, globalCache);
     RateTypes               = new GlobalCacheRepository <RateType>(entityManagerProvider, globalCache);
     StaffingResourceFactory = new StaffingResourceFactory(entityManagerProvider, AddressTypes, PhoneNumberTypes);
     StaffingResources       = new StaffingResourceRepository(entityManagerProvider);
     Search                  = new StaffingResourceSearchService(StaffingResources);
 }
        /// <summary>
        /// Helper function to replace the value held in global cache in a thread-safe manner.
        /// </summary>
        /// <typeparam name="TIn">Type of the old value held in global cache.</typeparam>
        /// <typeparam name="TOut">Type of the new (replacement) value held in global cache.</typeparam>
        /// <param name="gc">Reference to global cache.</param>
        /// <param name="key">Key of the value held in global cache.</param>
        /// <param name="formula">Formula to calculate the new value based on the old value.</param>
        /// <param name="delay">Time lapse between retries.</param>
        /// <returns></returns>
        private int ReplaceVal <TIn, TOut>(IGlobalCache gc, string key, Func <TIn, TOut> formula, int delay)
        {
            int  retVal = 0;
            TIn  oldVal;
            TOut newVal;

            do
            {
                oldVal = (TIn)gc[key];
                newVal = formula(oldVal);
                retVal++;
                Thread.Sleep(delay);
            }while (!gc.TryReplace(key, newVal, oldVal));
            return(retVal);
        }
Ejemplo n.º 24
0
        public LoginViewModel(IAuthenticationService authenticationService, IDialogManager dialogManager,
                              [Import(AllowDefault = true)] IGlobalCache globalCache)
        {
            Busy = new BusyWatcher();
            _authenticationService = authenticationService;
            _dialogManager = dialogManager;
            _globalCache = globalCache;
// ReSharper disable DoNotCallOverridableMethodsInConstructor
            DisplayName = "";
// ReSharper restore DoNotCallOverridableMethodsInConstructor

#if DEBUG
            _username = "******";
            _password = "******";
#endif
        }
Ejemplo n.º 25
0
        public LoginViewModel(IAuthenticationService authenticationService, IDialogManager dialogManager,
                              [Import(AllowDefault = true)] IGlobalCache globalCache)
        {
            Busy = new BusyWatcher();
            _authenticationService = authenticationService;
            _dialogManager         = dialogManager;
            _globalCache           = globalCache;
// ReSharper disable DoNotCallOverridableMethodsInConstructor
            DisplayName = "";
// ReSharper restore DoNotCallOverridableMethodsInConstructor

#if DEBUG
            _username = "******";
            _password = "******";
#endif
        }
Ejemplo n.º 26
0
 public LookupTableAppService(IGlobalCache globalCache,
                              IRepository <User, long> userRepository,
                              IRepository <Role> roleRepository,
                              IRepository <UserRole, long> userRoleRepository,
                              IRepository <TramDichVu> tramDichVuRepository,
                              IRepository <DanhMucNhomDichVu> danhMucNhomDichVuRepository,
                              IRepository <DanhMucDichVu> danhMucDichVuRepository,
                              IRepository <KhachHang, long> khachHangDichVuRepository,
                              IRepository <DanhMucHangMuc> danhMucHangMucRepository)
 {
     _globalCache                 = globalCache;
     _userRepository              = userRepository;
     _roleRepository              = roleRepository;
     _userRoleRepository          = userRoleRepository;
     _tramDichVuRepository        = tramDichVuRepository;
     _danhMucNhomDichVuRepository = danhMucNhomDichVuRepository;
     _danhMucDichVuRepository     = danhMucDichVuRepository;
     _khachHangDichVuRepository   = khachHangDichVuRepository;
     _danhMucHangMucRepository    = danhMucHangMucRepository;
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Ctor intended to be called by the CreateProvider method of the base class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        /// <param name="typeDefinitions"></param>
        internal DelimitedIntakeProvider(OrchestratorConfig config, IGlobalCache globalCache, TypeDefinitions typeDefinitions) : base(config, globalCache, typeDefinitions)
        {
            // This pattern matches all delimited tokens from intake line
            // Tokens can be unquoted (no separators/quotes) or quoted (separators and quoted quotes OK).
            // Note that part of a quoted field after the closing quote is ignored.
            // The same pattern is used for header line (if applicable) as well as all data lines.

            var sep = _config.InputFieldSeparator;

            _delimitedSplitRegex = new Regex("(?<=" + sep + "|^)(?:[\\s-[" + sep + "]]*)([^\"" + sep + "]+|\"(?:[^\"]|\"\")*\")?", RegexOptions.Compiled);

            //Examples of tokenPattern"
            // Comma-delimited:   @"(?<=,|^)(?:[\s-[,]]*)([^"",]+|""(?:[^""]|"""")*"")?"    (note that for comma-delimited [\\s-[,]] is an "overkill" as it's the same as [\\s], i.e. \\s )
            // Tab-delimited:     "(?<=\\t|^)(?:[\\s-[\\t]]*)([^\"\\t]+|\"(?:[^\"]|\"\")*\")?"
            //Explanation (based on comma-delimited):
            // (?<=,|^)       - positive lookbehind: must be preceded by either separator or start of line
            // (?:[\s-[,]]*)  - do not capture (i.e. ignore) any whitespace (except for separator - note that separator may be whitespace, such as tab, in which case this exception is relevant)
            // ( .. | .. )?   - either of these ..'s below - this group 1 of the regex is to be picked by TokenizeLineUsingRegex
            // [^",]+         - anything but quote or separator (one or more)
            // "(?:[^"]|"")*" - quoted string (may contain dual quotes inside)
        }
Ejemplo n.º 28
0
        public MbbsHost(ILogger logger, IGlobalCache globalCache, IFileUtility fileUtility, IEnumerable <IHostRoutine> mbbsRoutines, IConfiguration configuration, IEnumerable <IGlobalRoutine> globalRoutines)
        {
            _logger         = logger;
            _globalCache    = globalCache;
            _fileUtility    = fileUtility;
            _mbbsRoutines   = mbbsRoutines;
            _configuration  = configuration;
            _globalRoutines = globalRoutines;

            _logger.Info("Constructing MBBSEmu Host...");

            _channelDictionary = new PointerDictionary <SessionBase>();
            _modules           = new Dictionary <string, MbbsModule>();
            _exportedFunctions = new Dictionary <string, IExportedModule>();
            _realTimeStopwatch = Stopwatch.StartNew();
            _incomingSessions  = new Queue <SessionBase>();
            _cleanupTime       = ParseCleanupTime();
            _timer             = new Timer(unused => _performCleanup = true, this, NowUntil(_cleanupTime), TimeSpan.FromDays(1));

            _logger.Info("Constructed MBBSEmu Host!");
        }
        /// <summary>
        /// Ctor intended to be called by the CreateProvider method of the base class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        internal ArbitraryOutputProvider(OrchestratorConfig config, IGlobalCache globalCache) : base(config, globalCache)
        {
            //Parse ArbitraryOutputDefs to define _outputDefs and _outputKeys
            _outputDefs = new List <string>(); //output tokens with _magicToken instead of {..}
            _outputKeys = new List <string>(); //key to substitute the _magicToken (or null if no substitution)
            //Regex below matches entire row that contains a token surrounded by braces. Groups:
            //  ${1} - part before the first unescaped brace, i.e. {
            //  ${2} - part inside the first unescaped brace (aka token, i.e. the fields to be substituted)
            //  ${3} - part after the first closing brace, i.e. } that follows the first unescaped { (may contain additional braces { and/or })
            //Note that braces themselves are not captured in either group
            var regex = new Regex("^(.*?(?<!\\\\)){([^}]*)}(.*)$"); //note a negative lookbehind to NOT match \{ as an opening brace (\\\\ stands for a single \) (!)

            if (_config.ArbitraryOutputDefs != null)
            {
                foreach (var def in _config.ArbitraryOutputDefs)
                {
                    if (def != null) //null elements (if any) are ignored
                    {
                        var    match = regex.Match(def);
                        string outDef; //def with magic token instead of a key to substitute
                        string outKey; //key (of the value) to substitute the magic token
                        if (match.Success)
                        {
                            outDef = match.Groups[1].Value + _magicToken + match.Groups[3].Value;
                            outKey = match.Groups[2].Value;
                        }
                        else //no match means no token to substitute (void item)
                        {
                            outDef = def;
                            outKey = null;
                        }
                        outDef = outDef.Replace("\\{", "{").Replace("\\}", "}"); //replace escaped braces by literal braces
                        _outputDefs.Add(outDef);
                        _outputKeys.Add(outKey);
                    }
                }
            }
            _voidItem = new VoidKeyValItem("irrelevant"); //key doesn't matter here
        }
 public CongViecAppService(
     IRepository <CongViec, long> congViecRepository,
     IRepository <CongViecHangMuc, long> congViecHangMucRepository,
     IRepository <DanhMucNhomDichVu> nhomDichVuRepository,
     IRepository <DanhMucDichVu> dichVuRepository,
     IRepository <TramDichVu> tramDichVuRepository,
     IRepository <User, long> nhanVienRepository,
     IRepository <DanhMucTinhThanh> tinhThanhRepository,
     IRepository <DanhMucQuanHuyen> quanHuyenRepository,
     IRepository <DanhMucHangMuc> hangMucRepository,
     IGlobalCache globalCache)
 {
     _congViecRepository        = congViecRepository;
     _congViecHangMucRepository = congViecHangMucRepository;
     _nhomDichVuRepository      = nhomDichVuRepository;
     _dichVuRepository          = dichVuRepository;
     _tramDichVuRepository      = tramDichVuRepository;
     _nhanVienRepository        = nhanVienRepository;
     _tinhThanhRepository       = tinhThanhRepository;
     _quanHuyenRepository       = quanHuyenRepository;
     _hangMucRepository         = hangMucRepository;
     _globalCache = globalCache;
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Ctor intended to be called by the CreateProvider method of the base class
        /// </summary>
        /// <param name="config"></param>
        /// <param name="globalCache"></param>
        /// <param name="typeDefinitions"></param>
        internal KwIntakeProvider(OrchestratorConfig config, IGlobalCache globalCache, TypeDefinitions typeDefinitions) : base(config, globalCache, typeDefinitions)
        {
            //Keyword token is in a form of key=value (value may be quoted, no spaces allowed except in quoted value)
            //Examples: @NUM=123              (Key:NUM, Val:123)
            //          @pNAME =  "Mary Ann"  (Key:NAME, Val:Mary Ann) - if quoted whitespace in front of quote will be trimmed

            var sep = _config.InputFieldSeparator;

            _keywordSplitRegex = new Regex("(?<=" + sep + "|^)(?:[\\s-[" + sep + "]]*)([^" + sep + "=\\s]+(=(?:[\\s-[" + sep + "]]*)([^\"" + sep + "]+|\"(?:[^\"]|\"\")*\"|))?)", RegexOptions.Compiled);

            //Examples:
            //var tokenPattern = @"(?<=,|^)(?:[\s-[,]]*)([^,=\s]+(=(?:[\s-[,]]*)([^"",]+|""(?:[^""]|"""")*""|))?)";  //comma-delimited
            //var tokenPattern = "(?<=\\||^)(?:[\\s-[\\|]]*)([^\\|=\\s]+(=(?:[\\s-[\\|]]*)([^\"\\|]+|\"(?:[^\"]|\"\")*\"|))?)";  //pipe-delimited
            //var tokenPattern = "(?<=\\t|^)(?:[\\s-[\\t]]*)([^\\t=\\s]+(=(?:[\\s-[\\t]]*)([^\"\\t]+|\"(?:[^\"]|\"\")*\"|))?)";  //tab-delimited
            //Explanation (based on tab-delimited):
            // (?<=\t|^)           - positive lookbehind: must be preceded by either separator or start of line
            // (?:[\s-[\t]]*)      - do not capture (i.e. ignore) any whitespace (except for separator, in this case tab) at the beginning of the token
            // ( .... )            - group 1 of this regex (extends to the very end of the pattern) to be picked by TokenizeLineUsingRegex (hence 2nd parm below is 1)
            // [^\t=\s]+           - one or more any characters but separator, equal sign ory whitespace (will constitute a key)
            // (=...( .. | .. |))? - equal sign (optionally followed by ... i.e. whitespace to be ignored) followed by either of the ..'s below (will constitute a value) or equal sign alone; the entire thing incl. equal sign is optional
            // (?:[\s-[\t]]*)      - do not capture (i.e. ignore) any whitespace (except for separator, in this case tab) immediately following the equal sign
            // [^"\t]+             - anything but quote or separator (one or more)
            // "(?:[^"]|"")*"      - quoted string (may contain dual quotes inside)
        }
 public FolketingetServiceCached(IFolketingetConfig settings, IGlobalCache cache) : base(settings)
 {
     _cache = cache;
 }