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 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); } } }
static RapiComm() { _rapi = new OpenNETCF.Desktop.Communication.RAPI(); _rapi.RAPIConnected += new OpenNETCF.Desktop.Communication.RAPIConnectedHandler(Connection_RAPIConnected); _rapi.RAPIDisconnected += new OpenNETCF.Desktop.Communication.RAPIConnectedHandler(Connection_RAPIDisconnected); _rapi.RAPIConnectingStateChanged += new EventHandler(Connection_RAPIConnecting); }
public ActiveSyncOptions(String divMobiPath, String taxonNamePath, int timeOut, bool useDevice) : this() { this._MobileDBPath = divMobiPath; this._MobileTaxonPath = taxonNamePath; this._ConnectingTimeOut = timeOut/1000; this._UseDevice = useDevice; rapi = new RAPI(); this.fillOptions(); }
public MainForm() { InitializeComponent(); RAPI device = new RAPI(); device.Connect(); IEnumerable<FileInformation> lol = device.EnumerateFiles(@"\Application Data\SU_MT2000_SUIDScanner\admit-lists\*"); foreach (FileInformation i in lol) { Console.WriteLine(i.FileName); } }
private void button1_Click(object sender, EventArgs e) { try { DialogResult pesan; pesan = MessageBox.Show("Download data dari PDT?", "Konfirmasi", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (pesan == DialogResult.OK) { label1.Text = ""; using (RAPI MyRapi = new RAPI()) if (MyRapi.DevicePresent) { int x = 0; MyRapi.Connect(true); string pc = @"" + textBox2.Text; string pdt = @"\Application\Backup\Transfer\"; var fl = MyRapi.EnumFiles(pdt + @"\*"); if (fl == null) { MessageBox.Show("File Tidak Ditemukan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return; } bool Hapus = false; if (checkBox1.Checked == true) { Hapus = true; } //DialogResult dr = MessageBox.Show("Delete Data di PDT ?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); //if (DialogResult.Yes == dr) //{ // Hapus = true; //} foreach (FileInformation file in fl) { if (File.Exists(pc + "\\" + file.FileName)) { File.Delete(pc + "\\" + file.FileName); } MyRapi.CopyFileFromDevice(pc + "\\" + file.FileName, pdt + "\\" + file.FileName); if (Hapus) { MyRapi.DeleteDeviceFile(pdt + "\\" + file.FileName); } x++; label1.Text = "Mohon Tunggu"; } MyRapi.Disconnect(); if (x != 0) { label1.Text = "Copy Berhasil"; MessageBox.Show("Copy file to "+textBox2.Text+" berhasil.", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } } else { label1.Text = "Please Connect to the Mobile Device"; MessageBox.Show("Please Connect to the Mobile Device", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); return; } } } catch (Exception ex) { label1.Text = ""; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
public GoogleMapsForm(int width, int height, bool googleMap) { InitializeComponent(); this.GoogleMap = googleMap; this.buttonSave.Enabled = false; this.buttonSaveToDevice.Enabled = false; this.setMobileSize(width, height); if (googleMap) { webBrowserMap.AllowWebBrowserDrop = false; webBrowserMap.IsWebBrowserContextMenuEnabled = false; webBrowserMap.WebBrowserShortcutsEnabled = false; webBrowserMap.ObjectForScripting = this; try { rapi = new RAPI(); if (rapi.DevicePresent) { this.setMobileSize(rapi.GetDeviceCapabilities(DeviceCaps.HorizontalResolution), rapi.GetDeviceCapabilities(DeviceCaps.VerticalResolution)); } } catch (Exception) { MessageBox.Show("Device Size couldn't be automatically retrieved. Default values will be used.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); this.setMobileSize(width, height); } String fullPath = Environment.CurrentDirectory + @"\Ressources\GoogleMap.html"; try { if (File.Exists(fullPath)) { System.Uri u = new Uri(fullPath); webBrowserMap.Navigate(u); showOverlay(); webBrowserMap.Visible = true; pictureBoxMap.Visible = false; this.groupBoxGoogleMap.Enabled = true; this.groupBoxMap.Enabled = false; showToolStripMenuItem.Enabled = true; openMapToolStripMenuItem.Enabled = false; } else { throw new ConnectionCorruptedException("GoogleMaps Script couldn't be located. Please ensure that there is a directory named 'Ressources' and a HTML-File 'GoogleMaps.html' within."); } } catch (Exception) { throw new DataFunctionsException("Exception while opening GoogleMaps Script."); } } else { try { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Choose map to be shown"; dlg.Filter = "JPEG (*.JPEG, *.JPG)|*.jpg;*.jpeg|GIF (*.gif)|*.gif|PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp"; if (dlg.ShowDialog() == DialogResult.OK) { pictureBoxMap.Image = zoomImage(new Bitmap(dlg.FileName)); readSettingsFromXML(Path.GetDirectoryName(dlg.FileName), Path.GetFileNameWithoutExtension(dlg.FileName)); deltaX = (pictureBoxMap.Width - pictureBoxMap.Image.Width) / 2; deltaY = (pictureBoxMap.Height - pictureBoxMap.Image.Height) / 2; showOverlay(); } webBrowserMap.Visible = false; pictureBoxMap.Visible = true; this.groupBoxGoogleMap.Enabled = false; this.groupBoxMap.Enabled = true; showToolStripMenuItem.Enabled = false; openMapToolStripMenuItem.Enabled = true; } catch (Exception) { throw new DataFunctionsException("Exception while opening map and reading settings from XML file."); } } }
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); }
internal CFPerformanceMonitor(RAPI rapi) { m_stats = new PerformanceStatistics(); m_rapi = rapi; }
//überarbeiten private void MobileToDesktop(Object o) { AutoResetEvent evnt = (AutoResetEvent)o; RAPI rap; //try //{ rap = new RAPI(); //} //catch (Exception e) //{ // MessageBox.Show("Unable to initialize Rapi! Please Connect manually."); // return; //} if (rap.DevicePresent == true) { try { rap.Connect(); rap.CopyFileFromDevice(progPath, mobileDBPath, true);//Datenbank in das ausführende Verzeichnis als ArbeitsDB kopieren activesync = true; } catch (Exception e) { MessageBox.Show("RapiError! Please copy Your Files manually"); activesync = false; } } else { activesync = false; } evnt.Set(); }
IList<Type> usedTypes = new List<Type>(); //verwaltet die Typen, die synchronisiert werden sollen #endregion Fields #region Constructors // Constructor public Form1() { InitializeComponent(); rapi = new RAPI(); progPath = Environment.CurrentDirectory + @"\MobileDB.sdf"; if (System.IO.File.Exists(progPath)) File.Delete(progPath); taxPath = Environment.CurrentDirectory + @"\TaxonNames.sdf"; if (System.IO.File.Exists(taxPath)) File.Delete(taxPath); progPicturePath = Environment.CurrentDirectory + @"\pictures\"; if (!System.IO.Directory.Exists(progPicturePath)) System.IO.Directory.CreateDirectory(progPicturePath); mobileConnected = false; repositoryConnected = false; divMobiTypes.Add(typeof(Property)); divMobiTypes.Add(typeof(Analysis)); divMobiTypes.Add(typeof(AnalysisTaxonomicGroup)); divMobiTypes.Add(typeof(CollectionAgent)); divMobiTypes.Add(typeof(CollectionEvent)); divMobiTypes.Add(typeof(CollectionEventImage)); divMobiTypes.Add(typeof(CollectionEventLocalisation)); divMobiTypes.Add(typeof(CollectionEventProperty)); divMobiTypes.Add(typeof(CollectionSpecimen)); divMobiTypes.Add(typeof(CollectionSpecimenImage)); divMobiTypes.Add(typeof(CollEventImageType_Enum)); divMobiTypes.Add(typeof(CollSpecimenImageType_Enum)); divMobiTypes.Add(typeof(CollTaxonomicGroup_Enum)); divMobiTypes.Add(typeof(Identification)); divMobiTypes.Add(typeof(IdentificationUnit)); divMobiTypes.Add(typeof(IdentificationUnitAnalysis)); divMobiTypes.Add(typeof(LocalisationSystem)); divMobiTypes.Add(typeof(CollCircumstances_Enum)); divMobiTypes.Add(typeof(CollUnitRelationType_Enum)); divMobiTypes.Add(typeof(CollectionEventSeries)); //Bis hier: Korrepondiert zu DBVersion 20 //divMobiTypes.Add(typeof(CollectionEventSeriesImage)); //divMobiTypes.Add(typeof(CollEventSeriesImageType_Enum)); ////Bis hier: Korrepondiert zu DBVersion 22 divMobiTypes.Add(typeof(CollIdentificationCategory_Enum)); //divMobiTypes.Add(typeof(CollTypeStatus_Enum)); //divMobiTypes.Add(typeof(CollIdentificationQualifier_Enum)); ////Bis hier: Korrepondiert zu DBVersion 25 //divMobiTypes.Add(typeof(CollLabelTranscriptionState_Enum)); //divMobiTypes.Add(typeof(CollLabelType_Enum)); ////Bis hier: Korrepondiert zu DBVersion 27 //divMobiTypes.Add(typeof(Collection)); //divMobiTypes.Add(typeof(CollectionProject)); //divMobiTypes.Add(typeof(CollectionSpecimenPart)); //divMobiTypes.Add(typeof(CollMaterialCategory_Enum)); //Bis hier: Korrepondiert zu DBVersion 31 divMobiTypes.Add(typeof(IdentificationUnitGeoAnalysis)); divMobiTypes.Add(typeof(AnalysisResult)); divMobiTypes.Add(typeof(UserTaxonomicGroupTable)); //Bis hier: Korrepondiert zu DBVersion 34 //Verwendete Typen von der Synchronisationsdatenbank in Liste einfügen syncTypes.Add(typeof(SyncItem)); syncTypes.Add(typeof(FieldState)); try { this.readSettingsFromXML(); } catch (Exception ex) { MessageBox.Show("Unable to read XML-Settings"); } }