Example #1
0
 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);
         }
     }
 }
Example #2
0
        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();
            }
        }
Example #3
0
 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);
     }
 }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
        }
 //ü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();
 }