void terminalRapi_RAPIFileCoping(long totalSize, long completed, Exception e) { if (this.InvokeRequired) { OpenNETCF.Desktop.Communication.RAPICopingHandler del = new OpenNETCF.Desktop.Communication.RAPICopingHandler(terminalRapi_RAPIFileCoping); this.Invoke(del, totalSize, completed, e); } else { if (e == null) frm.SetProgress(totalSize, completed); else { frm.SetError(totalSize, completed,e); } } }
private void Form1_Load(object sender, EventArgs e) { System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); System.Reflection.AssemblyName an = a.GetName(); //an.Version.ToString(); this.Text = string.Format("ТСД Сервер. Версия {0}", an.Version); timer1.Enabled = true; stopGoodBtn.Enabled = false; stopDocsBtn.Enabled = false; terminalRapi.ActiveSync.Active += new OpenNETCF.Desktop.Communication.ActiveHandler(ActiveSync_Active); terminalRapi.ActiveSync.IPChange += new OpenNETCF.Desktop.Communication.IPAddrHandler(ActiveSync_IPChange); terminalRapi.ActiveSync.Answer += new OpenNETCF.Desktop.Communication.AnswerHandler(ActiveSync_Answer); terminalRapi.ActiveSync.Disconnect += new OpenNETCF.Desktop.Communication.DisconnectHandler(ActiveSync_Disconnect); terminalRapi.ActiveSync.Inactive += new OpenNETCF.Desktop.Communication.InactiveHandler(ActiveSync_Inactive); terminalRapi.RAPIConnected += new OpenNETCF.Desktop.Communication.RAPIConnectedHandler(terminalRapi_RAPIConnected); onCopyDelegate = new OpenNETCF.Desktop.Communication.RAPICopingHandler(terminalRapi_RAPIFileCoping); this.importDocBtn.Enabled = Properties.Settings.Default.ImportDocsEnabled; this.importGoodBtn.Enabled = Properties.Settings.Default.ImportProductsEnabled; this.settingsBtn.Enabled = Properties.Settings.Default.SettingsEnabled; cbEraseTerminalDB.Checked = Properties.Settings.Default.EraseTerminalDB; }
private void button2_Click(object sender, EventArgs e) { try { terminalRapi.Connect(true,5000); if (terminalRapi.Connected) { this.button1.Enabled = false; this.button2.Enabled = false; this.button3.Enabled = false; richTextBox1.Text = ""; OpenNETCF.Desktop.Communication.RAPICopingHandler onCopyDelegate = new OpenNETCF.Desktop.Communication.RAPICopingHandler(terminalRapi_RAPIFileCoping); terminalRapi.RAPIFileCoping += onCopyDelegate; IAsyncResult ar = terminalRapi.BeginCopyFileToDevice(Application.StartupPath + "\\products.sdf", Properties.Settings.Default.TSDDBPAth + "products.sdf", true, new AsyncCallback(OnEndCopyFile), null); if (frm.ShowDialog() == DialogResult.Abort) { richTextBox1.AppendText("Отмена копирования...\n"); richTextBox1.AppendText("Дождитесь завершения... \n"); terminalRapi.RAPIFileCoping -= onCopyDelegate; terminalRapi.CancelCopyFileToDevice(); } } else { MessageBox.Show("Терминал не подключен. Проверьте подключение.", "Статус загрузки на терминал", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception err) { MessageBox.Show("Ошибка загрузки на терминал: "+err.Message, "Статус загрузки на терминал", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void terminalRapi_RAPIFileCoping(string name, long totalSize, long completed, Exception e) { if (this.InvokeRequired) { OpenNETCF.Desktop.Communication.RAPICopingHandler del = new OpenNETCF.Desktop.Communication.RAPICopingHandler(terminalRapi_RAPIFileCoping); this.Invoke(del,name, totalSize, completed, e); } else { progressForms[name].FormCaption = string.Format("Копирование {0}", System.IO.Path.GetFileName(name)); if (e == null) { progressForms[name].SetProgress(totalSize, completed); //if (totalSize == completed) //{ // copiedFileList.Remove(name); // if (copiedFileList.Count == 0) // mEvt.Set(); //} } else { frm.SetError(totalSize, completed, e); copyStatesb.AppendFormat("Ошибка копирования {0}.\n", name); richTextBox1.AppendText(string.Format("Ошибка копирования {0}. \n",name)); } } }