Example #1
0
 private void btnImportAuthen_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(Resource1.FrmMain_ImportAuthenConfirm, Resource1.FrmMain_Query, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     try
     {
         string path   = System.IO.Path.Combine(Application.StartupPath, "AuthenRecord.txt");
         string remote = @"FlashDisk\RalidPos\AuthenRecord.txt";
         OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI();
         if (rapi.DevicePresent)
         {
             rapi.Connect();
             if (!rapi.Connected)
             {
                 ShowMessage(Resource1.FrmMain_ConnectHandsetFail, Color.Red);
                 return;
             }
             rapi.CopyFileFromDevice(path, remote, true);
             rapi.Disconnect();
             List <string> records = new List <string>();
             using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
             {
                 using (StreamReader reader = new StreamReader(fs))
                 {
                     while (!reader.EndOfStream)
                     {
                         string record = reader.ReadLine();
                         if (!string.IsNullOrEmpty(record))
                         {
                             records.Add(record);
                         }
                     }
                 }
             }
             if (records.Count > 0)
             {
                 SaveAuthensToPark(records);
             }
             else
             {
                 ShowMessage(Resource1.FrmMain_NoAuthenLog, Color.Black);
             }
         }
         else
         {
             ShowMessage(Resource1.FrmMain_FindnotHandet, Color.Red);
         }
     }
     catch (Exception ex)
     {
         ShowMessage(ex.Message, Color.Red);
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
Example #2
0
 private void btnCardEvent_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否需要导入收费记录?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
     {
         return;
     }
     try
     {
         string path   = System.IO.Path.Combine(Application.StartupPath, "Record.txt");
         string remote = @"FlashDisk\RalidPos\Record.txt";
         OpenNETCF.Desktop.Communication.RAPI rapi = new OpenNETCF.Desktop.Communication.RAPI();
         if (rapi.DevicePresent)
         {
             rapi.Connect();
             rapi.CopyFileFromDevice(path, remote, true);
             rapi.Disconnect();
             List <string> records = new List <string>();
             using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
             {
                 using (StreamReader reader = new StreamReader(fs))
                 {
                     while (!reader.EndOfStream)
                     {
                         string record = reader.ReadLine();
                         if (!string.IsNullOrEmpty(record))
                         {
                             records.Add(record);
                         }
                     }
                 }
             }
             if (records.Count > 0)
             {
                 SavePaymentsToPark(records);
             }
         }
     }
     catch (Exception ex)
     {
         ShowMessage(ex.Message, Color.Red);
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }