Beispiel #1
0
        /// <summary>
        /// Процедура-обработчик
        /// </summary>
        static void ThreadProcess(Object stateInfo)
        {
            StateInfo s = (StateInfo)stateInfo;

            try
            {
                List <CertInfo> certinfo = new List <CertInfo>();
                certinfo = CertInfo.CertificateInfo(s.filename, "sign");
                s.locker.WaitOne();
                Thread.Sleep(5);
                using (StreamWriter writer = new StreamWriter(s.wpath + "data.csv", true, Encoding.Default))
                {
                    foreach (var e in certinfo)
                    {
                        Console.WriteLine("{0} {1}", e.CNuc, e.CertHash);
                        writer.WriteLine(e.CNuc + "|" + e.INN + "|" + e.KPP + "|" + e.OGRN + "|" + e.SNILS + "|" + e.CertHash + "|" + e.SerialNumber + "|" + e.DateSince + "|" + e.DateExpiration + "|" +
                                         e.CNholder + "|" + e.CNuser + "|" + e.Department + "|" + e.Dolgnost + "|" + e.EmailHolder + "|" + e.region + "|" + e.City + "|" + e.Street + "|" + e.sign);
                        writer.Flush();
                    }
                }
                Console.WriteLine("Thread is done!");
                s.locker.ReleaseMutex();
            }
            catch { Console.WriteLine("Something wrong!"); }
            finally { if (Interlocked.Decrement(ref numberOfThreads) == 0)
                      {
                          _doneEvent.Set();
                      }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Процедура-обработчик
 /// </summary>
 /// <param name="file">имя файла</param>
 /// <param name="mut">мьютекс</param>
 /// <param name="workpath">рабочая директория программы</param>
 public static void ThreadProcess(string file, Mutex mut, string workpath)
 {
     try
     {
         List <CertInfo> certinfo = new List <CertInfo>();
         certinfo = CertInfo.CertificateInfo(file, "sign");
         mut.WaitOne();
         Thread.Sleep(50);
         using (StreamWriter writer = new StreamWriter(workpath + "data.csv", true, Encoding.Default))
         {
             foreach (var e in certinfo)
             {
                 Console.WriteLine("{0} {1}", e.CNuc, e.CertHash);
                 writer.WriteLine(e.CNuc + "|" + e.INN + "|" + e.KPP + "|" + e.OGRN + "|" + e.SNILS + "|" + e.CertHash + "|" + e.SerialNumber + "|" + e.DateSince + "|" + e.DateExpiration + "|" +
                                  e.CNholder + "|" + e.CNuser + "|" + e.Department + "|" + e.Dolgnost + "|" + e.EmailHolder + "|" + e.region + "|" + e.City + "|" + e.Street + "|" + e.sign);
                 writer.Flush();
             }
         }
         Console.WriteLine("Thread is done!");
         mut.ReleaseMutex();
     }
     catch { Console.WriteLine("Something wrong!"); }
 }