private void ConnectTest_Click(object sender, EventArgs e) { try { rapi = new RAPI(); rapi.Connect(); if (rapi.DevicePresent) { MessageBox.Show("Соединение с КПК установлено"); } while (!rapi.DevicePresent) { MessageBox.Show("Пожалуйста подсоедините КПК используя ActiveSync.", "No Device Present"); rapi.Connect(); } } catch (Exception ex) { MessageBox.Show("Ошибка подключения" + " - " + ex.Message, "Connection Error"); Application.Exit(); } }
public void D_ConnectDevice() { if (!rapi.Connected) { rapi.Connect(); } }
RAPI m_objRAPI; //= new RAPI(); private void StartTheThread() { try { try { m_objRAPI.Connect(); if (m_objRAPI.DevicePresent) { if (PublicClass.currentInstrument == "Impaq-Benstone") { m_objRAPI.CopyFileToDevice(PathToUpLoad, @"\Storage Card\ImpaqElite" + CValues.SCONSTDCD + PublicClass.routename + CValues.SCONSTDBF, true); } else { m_objRAPI.CopyFileToDevice(PathToUpLoad, @"\Storage Card\FieldpaqII" + CValues.SCONSTDCD + PublicClass.routename + CValues.SCONSTDBF, true); } } } catch (Exception ex) { } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message, ex.StackTrace); } }
public static void GetFileFormDevice(String SourcePath, String DestinationPath, bool Overwrite) { if (rapi.DevicePresent) { if (!rapi.Connected) { rapi.Connect(); } FileAttributes attr = File.GetAttributes(DestinationPath); if ((attr & FileAttributes.Directory).Equals(FileAttributes.Directory)) //DestinationPath is a directory { DestinationPath = Path.Combine(DestinationPath, Path.GetFileName(SourcePath)); } rapi.CopyFileFromDevice(DestinationPath, SourcePath, Overwrite); if (rapi != null && rapi.Connected) { rapi.Disconnect(); } } }
private void buttonTest_Click(object sender, EventArgs e) { try { String progPath = Environment.CurrentDirectory + @"\test.txt"; //String mobileDBPath = @"\Programme\test.txt"; String mobileDBPath = @"Speicherkarte\test.txt"; rapi.Connect(); rapi.CopyFileToDevice(progPath, mobileDBPath, true); rapi.CopyFileFromDevice(progPath, mobileDBPath, true); rapi.Disconnect(); MessageBox.Show("Rapi Connection Succesfull"); } catch (Exception f) { MessageBox.Show(f.Message); MessageBox.Show(f.InnerException.ToString()); MessageBox.Show("Rapi Connection Error"); } }
public void InitializeRAPI() { m_RAPI = new RAPI(); m_RAPI.RAPIConnected += new RAPIConnectedHandler(RAPI_Connected); m_RAPI.RAPIDisconnected += new RAPIConnectedHandler(RAPI_Disconnected); //Init rapi if the device is present if (m_RAPI.DevicePresent) { m_RAPI.Connect(); } else { RAPI_Disconnected(); } m_ActiveSync = m_RAPI.ActiveSync; m_ActiveSync.Disconnect += new DisconnectHandler(ActiveSync_Disconnect); m_ActiveSync.Active += new ActiveHandler(ActiveSync_Active); }
public static void Copy(String path) { RAPI r = new RAPI(); try { if (r.DevicePresent) { r.Connect(); Consoler("Copying database to PDA. Wait..."); r.CopyFileToDevice(path, path2device, true); FileDeleter(pathbase); } else { Consoler("No Device Connected"); Log("No Device Connected", logpath); } } catch (Exception e) { if (e.Message == "Could not create remote file ") { path2device = "\\Sd Card\\BelmostPDA.sdf"; } try { Consoler("Copying database to PDA. Wait..."); r.CopyFileToDevice(path, path2device, true); FileDeleter(pathbase); } catch (Exception ex) { Consoler(ex.Message); Log(ex.Message, logpath); } } }
private void GetInfo() { lbPrsntDataBss.Items.Clear(); objConnToDvc.Connect(); try { if (objConnToDvc.DevicePresent) { FileList objAllFiles = Direct; foreach (FileInformation FileInfoMtn in objAllFiles) { lbPrsntDataBss.Items.Add(FileInfoMtn.FileName.ToString()); } } else { MessageBox.Show("Device Not Connected", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { ErrorLogFile(ex); } }
public frmupdownload() { InitializeComponent(); m_objRAPI = new RAPI(); if (m_objRAPI.DevicePresent) { m_objRAPI.Connect(); if (PublicClass.currentInstrument == "Impaq-Benstone" || PublicClass.currentInstrument == "FieldPaq2") { //serialKey = GetSrialKeyForImpaq(); GetSrialKeyForImpaq(); if (PublicClass.InstrumentSerial == SerialKeyForImpaq) { check = "true"; if (PublicClass.currentInstrument == "Impaq-Benstone") { pictureBox2.Image = ImageResources.elite2; } else { pictureBox2.Image = ImageResources.fieldpaqnew; } } else { check = "false"; } } } else { if (PublicClass.currentInstrument == "Impaq-Benstone") { //GetSrialKeyForImpaq(); if (PublicClass.InstrumentSerial == SerialKeyForImpaq) { check = "true"; if (PublicClass.currentInstrument == "Impaq-Benstone") { pictureBox2.Image = ImageResources.elite2; } else { pictureBox2.Image = ImageResources.fieldpaqnew; } } else { check = "true"; } } if (PublicClass.currentInstrument == "SKF/DI") { ConnectwithINST(); if (DiStatus == true) { check = "true"; pictureBox2.Image = ImageResources.fieldpac; } else { check = "true"; } } else if (PublicClass.currentInstrument == "Kohtect-C911") { ConnectwithC911(); if (DiStatus == true) { check = "true"; pictureBox2.Image = ImageResources.kohtect; /////////////////////////This code is for verify serial key from database and instrumet///////////////////////////////// //bool keyCheck = checkSerialKeyForInstrument(PublicClass.currentInstrument); //if (keyCheck == true) //{ // check = "true"; // pictureBox2.Image = ImageResources.kohtect; //} //else //{ // check = "false"; // //MessageBox.Show("You are connected unautherized Instrument..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // return; //} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } else { //check = "false"; //MessageBox.Show("Please connect Instrument..","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); return; //check = "true"; //PublicClass.checkpathstatus.Add("C:"); //PublicClass.checkpathstatus.Add("D:"); } } else { check = "true"; } } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { myRapi = new RAPI(); bool HasDevice = true; if (!myRapi.DevicePresent) { if (XtraMessageBox.Show("Please Connect Device. Or\n Load Previous File.(Y/N)", "Conformation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } HasDevice = false; } if (HasDevice) { myRapi.Connect(); if (File.Exists(Application.StartupPath + "\\dbFile\\LocalDb.xml")) { if (myRapi.DeviceFileExists("\\Application\\MMPPL\\LocalDb.xml")) { File.Delete(Application.StartupPath + "\\dbFile\\LocalDb.xml"); myRapi.CopyFileFromDevice(Application.StartupPath + "\\dbFile\\LocalDb.xml", "\\Application\\MMPPL\\LocalDb.xml"); myRapi.DeleteDeviceFile("\\Application\\MMPPL\\LocalDb.xml"); } else { MessageBox.Show("No Scan Data Found"); return; } } else { if (myRapi.DeviceFileExists("\\Application\\MMPPL\\LocalDb.xml")) { myRapi.CopyFileFromDevice(Application.StartupPath + "\\dbFile\\LocalDb.xml", "\\Application\\MMPPL\\LocalDb.xml"); myRapi.DeleteDeviceFile("\\Application\\MMPPL\\LocalDb.xml"); } else { MessageBox.Show("No Scan Data Found"); return; } } } if (File.Exists(Application.StartupPath + "\\dbFile\\LocalDb.xml")) { bbiSave.PerformClick(); DataSet ds = new DataSet(); ds.ReadXml(Application.StartupPath + "\\dbFile\\LocalDb.xml"); string SRNO = "("; foreach (DataRow dtr in ds.Tables["DeliveryChallan"].DefaultView.ToTable().Rows) { char[] cr = { '~' }; String[] str = dtr["BARCODE"].ToString().Split(cr); SRNO = SRNO + "'" + str[1].ToString() + "',"; } SRNO = SRNO.TrimEnd(','); SRNO = SRNO + ")"; Dispatch.DispatchCall.UpdateLabelByDispatch(MMPPL.Dispatch.CurrObject.DptId, SRNO, Convert.ToDouble(txtLessWeight.Value)); tmrLine.Start(); } else { MessageBox.Show("No Scan Data Found"); } if (HasDevice) { myRapi.Disconnect(); myRapi.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ConnectDevice() { myrapi.RAPIConnected += new RAPIConnectedHandler(myrapi_RAPIConnected); myrapi.RAPIDisconnected += new RAPIConnectedHandler(myrapi_RAPIDisconnected); myrapi.Connect(false, -1); }
public override void Run() { /// алгоритм /// Disconnect от КПК базы /// на основании ConnectionSettings скопировать /// базу с винчейстера на КПК /// event в самом конце (Max = 1 Pos = 1) /// Running не обрабатывается /// /// Дополнение: если ToPDA == true то копирование идет не на КПК а из КПК DataBasePDA.Disconnect(); RAPI rapi = new RAPI(); if (!ToPDA) { try { if (rapi.DevicePresent) { rapi.Connect(); } rapi.CopyFileToDevice(ConnectionSettings.GetSettings().PDAConnectionString, ConnectionSettings.GetSettings().PDAConString, true); Loging.Loging.WriteLog("Coping to PDA complete", false, true); File.Delete(ConnectionSettings.GetSettings().PDAConnectionString); } catch (Exception e) { Loging.Loging.WriteLog("Coping to PDA failed: " + e.Message, false, true); } } else { try { if (rapi.DevicePresent) { rapi.Connect(); } rapi.CopyFileFromDevice(ConnectionSettings.GetSettings().PDAConnectionString, ConnectionSettings.GetSettings().PDAConString, true); Loging.Loging.WriteLog("Coping from PDA complete", false, true); } catch (Exception e) { if (e.Message == "Could not open remote file ") { if (ConnectionSettings.GetSettings().PDAConString == "\\Storage Card\\BelmostPDA.sdf") { ConnectionSettings.GetSettings().PDAConString = "\\Sd Card\\BelmostPDA.sdf"; } else { ConnectionSettings.GetSettings().PDAConString = "\\Storage Card\\BelmostPDA.sdf"; } try { rapi.CopyFileFromDevice(ConnectionSettings.GetSettings().PDAConnectionString, ConnectionSettings.GetSettings().PDAConString, true); Loging.Loging.WriteLog("Coping from PDA complete", false, true); } catch (Exception ex) { Loging.Loging.WriteLog("Coping from PDA failed: " + ex.Message, false, true); Coordinator.Canceled = true; } } else { Loging.Loging.WriteLog("Coping from PDA failed: " + e.Message, false, true); Coordinator.Canceled = true; } } } Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs(); args.Maximum = 1; args.Pos = 1; args.runningAction = this; args.Name = Name(); OnExecute(this, args); }
private void ActiveSync_Active() { m_RAPI.Connect(); }