예제 #1
0
        public ExcelReader(ConsoleWatch watch, string folderPath, string extensionPattern)
        {
            this.watch            = watch;
            this.watch.ProgramId  = this.GetType().Name;
            this.folderPath       = folderPath;
            this.extensionPattern = extensionPattern;

            this.filePaths  = new List <string>();
            this.ExcelSheet = new ExcelSheet <Transaction>();
        }
        public static async Task AsyncFileUpdated(Context context)
        {
            //using (await Global.FileOperationAsyncLock.LockAsync())
            {
                string fileData;
                try
                {
                    long maxFileSize = Global.MaxFileSizeMB * (1024 * 1024);
                    fileData = await FileExtensions.ReadAllTextAsync(Extensions.GetLongPath(context.Event.FullName), context.Token, maxFileSize : maxFileSize, retryCount : Global.RetryCountOnSrcFileOpenError);

                    if (fileData == null)
                    {
                        await ConsoleWatch.AddMessage(ConsoleColor.Red, $"Error synchronising updates from file {context.Event.FullName}", context);
                    }
                }
                catch (FileNotFoundException)   //file was removed by the time queue processing got to it
                {
                    return;
                }


                var originalData = fileData;


                if (context.Event.FullName.EndsWith(".cs"))
                {
                    foreach (var replacement in CS_Replacements)
                    {
                        fileData = fileData.Replace(replacement.Item1, replacement.Item2);
                    }

                    fileData = CS_FuncTaskReplaceRegex.Replace(fileData, CS_FuncTaskReplaceRegexReplacement);
                    fileData = CS_AsyncLockReplaceRegex.Replace(fileData, CS_AsyncLockReplaceRegexReplacement);
                    fileData = CS_TaskReplaceRegex.Replace(fileData, CS_TaskReplaceRegexReplacement);
                    fileData = CS_TaskDelayReplaceRegex.Replace(fileData, CS_TaskDelayReplaceRegexReplacement);
                }
                else if (context.Event.FullName.EndsWith(".py"))
                {
                    foreach (var replacement in PY_Replacements)
                    {
                        fileData = fileData.Replace(replacement.Item1, replacement.Item2);
                    }

                    fileData = PY_AwaitReplaceRegex.Replace(fileData, PY_AwaitReplaceRegexReplacement);
                    fileData = PY_AsyncReplaceRegex.Replace(fileData, PY_AsyncRegexReplacement);
                }
                else
                {
                    throw new NotImplementedException("Unknown file extension");
                }


                await ConsoleWatch.SaveFileModifications(fileData, originalData, context);
            } //using (await Global.FileOperationAsyncLock.LockAsync())
        }     //public static async Task AsyncFileUpdated(string fullName, Context context)
예제 #3
0
 public ExcelWriter()
 {
     this.watch = new ConsoleWatch(NAME);
 }
예제 #4
0
 public ExcelWriter(ConsoleWatch watch, ExcelCOMs excelCOMs)
 {
     this.watch           = watch;
     this.watch.ProgramId = this.GetType().Name;
     this.excelCOMs       = excelCOMs;
 }
예제 #5
0
 public ExcelReader()
 {
     this.watch = new ConsoleWatch(NAME);
 }
예제 #6
0
 public MergedExcelFileReader()
 {
     this.ExcelSheet = new ExcelSheet <TransactionExtended>();
     this.watch      = new ConsoleWatch(this.GetType().Name);
 }
예제 #7
0
 void StartTimer()
 {
     this.watch = new ConsoleWatch(this.GetType().Name);
     this.watch.StartAll();
 }
예제 #8
0
 public ExcelWriter(ConsoleWatch watch)
 {
     this.watch           = watch;
     this.watch.ProgramId = this.GetType().Name;
 }
예제 #9
0
 public ExcelReader(bool isReadFromTheBeginning)
 {
     this.IsReadFromTheBeginning = isReadFromTheBeginning;
     this.watch = new ConsoleWatch(NAME);
 }