コード例 #1
0
ファイル: FMSbaseObj.cs プロジェクト: EricPCHsieh/CCIFMS
 private void PrcessExistingFiles()
 {
   List<FileInfo> fsList;
   try
   {
     fsList = CommUtil.GetProcessFiles(this.InputUNC);
     if (fsList.Count >= 0)
     {
       foreach (var f in fsList)
       {
         if (!_processingFileList.Contains(f.FullName))
         {
           _processingFileList.Add(f.FullName);
           CreateProcessThread(f.FullName);
         }
       }
     }
   }
   catch (Exception ex)
   {
     Loghelper.Write(LogLevel.Error, ex.Message);
   }
   finally
   {
     fsList = null;
   }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: EricPCHsieh/CCIFMS
        private void LoadAppSetting()
        {
            var _inputreadertrytimes = 0;

            if (!int.TryParse(ConfigurationManager.AppSettings["InputReaderTryTime"], out _inputreadertrytimes))
            {
                CommUtil.ShowWarning(CommUtil.MSG_001);
                _inputreadertrytimes = 15;
            }
            var _inputreadertryinterval = 0;

            if (!int.TryParse(ConfigurationManager.AppSettings["InputReaderTryInterval"], out _inputreadertryinterval))
            {
                CommUtil.ShowWarning(CommUtil.MSG_002);
                _inputreadertryinterval = 100;
            }
            CommUtil.InputFileTryTimes    = _inputreadertrytimes;
            CommUtil.InputFileTryInterval = _inputreadertryinterval;
        }
コード例 #3
0
ファイル: FMSbaseObj.cs プロジェクト: EricPCHsieh/CCIFMS
 private void DoProcessFile(string processFN)
 {
   Add2ProcessFileList(processFN);
   int _tickstart = Environment.TickCount;
   int _processTimeofReadfile = -1;
   int _processTimeofProcedure = -1;
   int _processTimeofOutput = -1;
   int _processTime = -1;
   int _tryTimes = 1;
   string _errormsg = "";
   if (processFN != "")
   {
     try
     {
       _tryTimes = CommUtil.InputFileTryTimes;
       // check file lock
       CommUtil.CheckFileLock(processFN, ref _tryTimes);
       // read file content
       var textLines = ReadFilelines(processFN);
       // remove file right after read content
       if (File.Exists(processFN))
       {
         File.Delete(processFN);
       }
       else
       {
         throw new Exception("File does not exist before try to delete");
       }
       _processTimeofReadfile = Environment.TickCount - _tickstart;
       _tickstart = Environment.TickCount;
       // get SN#
       var _snnumber = GetSNNumber(processFN);
       //process file content and get output values
       string[] outputValues = GetOutputValues(_snnumber, textLines);
       _processTimeofProcedure = Environment.TickCount - _tickstart;
       _tickstart = Environment.TickCount;
       // get output file name from output parameter "COMMAND1" 1st segment
       var outputFN = outputValues[0].Split(';')[0];
       // remove filename from returned parameters
       outputValues[0] = outputValues[0].Substring(outputValues[0].IndexOf(';') + 1);
       // connect outputvalues into one string
       var _outputvalues_s = String.Join("", outputValues);
       outputValues = new string[] { _outputvalues_s };
       // output to file
       if (outputFN != "")
       {
         if (CommUtil.WritetoFile(Path.Combine(this.OutputUNC, outputFN + ".sf"), outputValues))
         {
           // remove file
           //File.Delete(processFN);
         }
       }
       else
       {
         textLines = null;
         outputValues = null;
         throw new Exception("Output FileName is Empty!!");
       }
       textLines = null;
       outputValues = null;
       _processTimeofOutput = Environment.TickCount - _tickstart;
     }
     catch (Exception ex)
     {
       _errormsg = ":Error:" + ex.Message;
     }
   }
   _processTime = _processTimeofReadfile + _processTimeofProcedure + _processTimeofOutput;
   #region write log
   if (Loghelper.IfneedTestLog)
   {
     Loghelper.SetThreadContext(this.Id, processFN, _tryTimes, _processTimeofOutput, _processTimeofProcedure, _processTimeofOutput);  
   }
   string _log = String.Format("{0}{1}:{2}|{3}|{4}|{5}|{6}", processFN, _errormsg, _tryTimes, _processTimeofReadfile, _processTimeofProcedure, _processTimeofOutput, _processTime);
   var _loglevel = (_errormsg != "") ? LogLevel.Error : ((_tryTimes > 1) ? LogLevel.Warning : LogLevel.Info);
   Loghelper.Write(_loglevel, _log);
   #endregion
   // ** remove file from ProcessingFileList
   RemoveFromProcessFileList(processFN);
   //return null;
 }