//发送命令,false表示超时,true表示有返回值 public bool SendCommand(byte[] dataBytes) { try { if (CmdClient != null && CmdClient.GetStream() != null) { if (CmdClient.GetStream().CanWrite) { if (ACPacketHandle == null) { ACPacketHandle = new EventWaitHandle(false, EventResetMode.AutoReset); } CmdClient.GetStream().Write(dataBytes, 0, dataBytes.Length); if (!ACPacketHandle.WaitOne(1000))//等待信号超时 { ACPacketHandle.Reset(); Exception MyEx = new Exception("接收应答超时!"); throw MyEx; } return(true); } } Status = "网络连接故障"; return(false); } catch (Exception MyEx) { Status = MyEx.Message; return(false); } }
private void ButtonAjout_Click(object sender, EventArgs e) { try { if (ProgramManager.DetecteurErreurSaisieNewClient(NomClient, CodeClient, CodePostale, Adresse1) == true) { ProgramManager.InsertClientRapide(CmdClient.RequetAjoutClientRapide(CodeClient.Text, Adresse1.Text, Adresse2.Text, CodePostale.Text, VilleClient.Text, NomClient.Text)); AlimenterGrid.FillDataGridView <Client>(GcLicence, ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()), ProgramManager.Chargement(ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()))); MsgBox.Show(this, MessagesSystem.ClientAddSuccecful); } else { MsgBox.Show(this, MessagesSystem.ErreurAjoutClientExpress); } } catch (Exception EX) { MsgBox.Show(this, EX.Message); } }
/// <summary> /// Methode qui permet de faire une tetative de connection a la base de donné /// </summary> /// <param name="ImputNom">Text saisie dans la zone de text du nom de l'administrateur</param> /// <param name="ImputPassword">Zone de saisie du mot de passe </param> /// <returns>true si les identitifant sont correcte , false si non </returns> public static bool LoginEssai(string ImputNom, string ImputPassword, XtraForm frm) { OleDbDataReader MONoBJET = ProgramManager.Chargementreader(CmdClient.RequetteLogin(ImputNom, ImputPassword)); int count = 0; bool LoginSucc; while (MONoBJET.Read()) { count += 1; } if (count == 1) { LoginManager.LoginProcess(true); LoginSucc = true; } else { LoginManager.LoginProcess(false); LoginSucc = false; } return(LoginSucc); }
public void Stop() { if (CmdClient != null) { CmdClient.Close(); } if (_cmdListenert != null) { _cmdListenert.Stop(); } if (CmdThread != null) { if (CmdThread.IsAlive) { CmdThread.Abort(); } } if (DataClient != null) { DataClient.Close(); } if (_dataListener != null) { _dataListener.Stop(); } if (DataThread != null) { if (DataThread.IsAlive) { DataThread.Abort(); } } if (BssFile.Opened) { BssFile.Close(); } }
int Run(string[] args) { if (args.Length == 0) { return(Usage(null)); } for (int i = 0; i < args.Length;) { string s = args[i++]; if (s.StartsWith("-")) { if (i == args.Length) { return(Usage("incomplete option")); } if (s == "-s") { Configuration.CreateDefaultConfig(Path.GetFullPath(args[i++])); } else if (s == "-p") { port = Int32.Parse(args[i++]); if (port == 0) { return(Usage("invalid port: 0")); } } else if (s == "-l") { //if (!Log.SetLevel(args[i++])) // return Usage("Unknown trace level"); Console.WriteLine("trace level option '-l' not supported"); } else if (s == "-c") { //Log.SetCategory(args[i++]); Console.WriteLine("category option '-c' not supported"); } else if (s == "-n") { host = args[i++]; } else { return(Usage("unknown option")); } } else { switch (s) { case "invite": if (args.Length - i != 2 && args.Length - i != 3) { return(Usage("operation 'invite' takes 2 or 3 params")); } return(Invite(args.Length - i == 2? null: args[i + 2], new Uri(Path.GetFullPath(args[i])), args[i + 1])); case "accept": if (args.Length - i != 2) { return(Usage("operation 'accept' takes 2 params")); } return(Accept(args[i], args[i + 1])); case "sync": if (args.Length - i != 1) { return(Usage("operation 'sync' takes 1 param")); } return(CmdClient.RunOnce(new Uri(Path.GetFullPath(args[i])), null)? 0: 40); case "localsync": if (args.Length - i != 2) { return(Usage("operation 'localsync' takes 2 params")); } return(CmdClient.RunOnce(new Uri(Path.GetFullPath(args[i])), args[i + 1])? 0: 41); case "server": if (args.Length - i != 0) { return(Usage("operation 'server' takes 0 params")); } return(RunServer()); default: return(Usage("unknown operation '" + s + "'")); } } } return(Usage("no operation specified")); }
private void BoutonDetails_Click(object sender, EventArgs e) { try { if (IsLicenced) { if (CodeClient.Text != String.Empty) { FrmDetails Details = new FrmDetails(); Details.ShowInTaskbar = false; Details.ClientCode = CodeClient.Text; if (Details.ClientCode != "") { Details.Dialog = true; Details.ShowDialog(); Details.ClientCode = ""; AlimenterGrid.FillDataGridView <Client>(GcLicence, ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()), ProgramManager.Chargement(ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()))); FindInGridControl(CodeClient.Text); NomClient.ResetText(); CodeClient.ResetText(); CodePostale.ResetText(); VilleClient.ResetText(); Adresse1.ResetText(); Adresse2.ResetText(); } else { CodeClient.BackColor = Color.Red; Details.Dispose(); return; } } else { MsgBox.Show(this, MessagesSystem.ErreurAjoutClientExpress); CodeClient.BackColor = Color.Red; } } else { MsgBox.Show(this, "User Not Licenced !!!"); return; } } catch (Exception ex) { MsgBox.Show(this, ex.Message); } }
private void GenererLicence_Click(object sender, EventArgs e) { if (ProgramManager.DetecteurErreurSaisieNewClient(NomClient, CodeClient, CodePostale, Adresse1) == true) { FixRadioGroup(); string licences = GetLicences.GetSeriale(NomClient, CodeClient, CodePostale, Adresse1, GropLicences); ImputLicences.Text = licences; DateDebutLicenece.Text = DateTime.Today.ToString("dd-MM-yyyy"); DateFin.Text = Convert.ToDateTime(LicenceDelaisManager.FinLicence(DateTime.Today, LicenceDelaisManager.LicenceLength(GropLicences.Properties.Items[GropLicences.SelectedIndex].Description))).ToString("dd-MM-yyyy"); NombreDeJour.Text = LicenceDelaisManager.LicenceLength(GropLicences.Properties.Items[GropLicences.SelectedIndex].Description).ToString(); ProgramManager.InserstionData(CmdLicenceLoad.UpdateDataClient(NomClient, CodeClient, CodePostale, VilleClient, Adresse1, Adresse2, GropLicences)); ProgramManager.InserstionData(CmdLicenceLoad.LoadDataToDataBase(DateDebutLicenece.Text, DateFin.Text, ImputLicences.Text, NombreDeJour.Text, CodeClient.Text, GropLicences.Properties.Items[GropLicences.SelectedIndex].Description)); AlimenterGrid.FillDataGridView <Client>(GcLicence, ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()), ProgramManager.Chargement(ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()))); FindInGridControl(CodeClient.Text); NomClient.ResetText(); CodeClient.ResetText(); CodePostale.ResetText(); VilleClient.ResetText(); Adresse1.ResetText(); Adresse2.ResetText(); DateDebutLicenece.ResetText(); DateFin.ResetText(); ImputLicences.ResetText(); NombreDeJour.ResetText(); MsgBox.Show(this, MessagesSystem.ModifSaved); } else { MsgBox.Show(this, MessagesSystem.ErreurAjoutClientExpress); } }
private void Sauvgarder_Click(object sender, EventArgs e) { try { ProgramManager.InserstionData(CmdLicenceLoad.LoadDataToDataBase(DateDebutLicenece.Text, DateFin.Text, ImputLicences.Text, NombreDeJour.Text, CodeClient.Text, GropLicences.Properties.Items[GropLicences.SelectedIndex].Description)); AlimenterGrid.FillDataGridView <Client>(GcLicence, ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()), ProgramManager.Chargement(ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()))); MsgBox.Show(this, MessagesSystem.LoadDataSucced + NomClient.Text); if (ImputLicences.Text == MessagesSystem.StringVide) { MsgBox.Show(this, MessagesSystem.StringVide); } } catch (Exception ex) { MsgBox.Show(this, ex.Message); } }
private void FrmAcceuil_Shown(object sender, EventArgs e) { ImageList il = new ImageList(); il.Images.Add(Properties.Resources.Licence1); il.Images.Add(Properties.Resources.Licence2); il.Images.Add(Properties.Resources.Licence3); LicImageCombo.SmallImages = il; LicImageCombo.Items.Add("Licence1", "Licence1", 0); LicImageCombo.Items.Add("Licence2", "Licence2", 1); LicImageCombo.Items.Add("Licence3", "Licence3", 2); AlimenterGrid.FillDataGridView <Client>(GcLicence, ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()), ProgramManager.Chargement(ProgramManager.Chargementreader(CmdClient.RequetteCaracteristiqueClient()))); }