public static void Main() { //����һ���绰����Ķ��� PhoneBookManager manager = new PhoneBookManager("BugTypes.MDB"); bool result = false; result = manager.addContact("kgd1", "0825-8662237"); result = manager.addContact("kgd2", "0825-8662238"); manager.printPhookBook(); Console.WriteLine("����kgd2�ĵ绰!"); result = manager.updateContact("kgd2", "0825-8662239"); Console.WriteLine("updateContact: {0}\n", result); manager.printPhookBook(); Console.WriteLine("ɾ��kgd2�ĵ绰!"); result = manager.removeContact("kgd2"); Console.WriteLine("removeContact: {0}\n", result); manager.printPhookBook(); //�ر����ݿ����ӣ��������Ҫ�� manager.close(); Console.WriteLine("done..........."); }
public async Task PhoneBook_ConcurrentModification() { PhoneBook phoneBooks = new PhoneBook(); StoreMock.Setup(s => s.CreateAsync(It.IsAny <PhoneBook>())) .Returns <PhoneBook>(p => { phoneBooks = p; return(Task.FromResult(new ResultPhoneBook { isSuccess = true })); }); StoreMock.Setup(s => s.UpdateAsync(It.IsAny <PhoneBook>())) .Returns <PhoneBook>(async p => { return(await Task.Run(async() => { lock (lockObj) { phoneBooks.FirstName = p.FirstName; Thread.Sleep(1); phoneBooks.LastName = p.LastName; } return new ResultPhoneBook { isSuccess = true }; })); }); var phonebookManager = new PhoneBookManager(StoreMock.Object); var phonebookManager2 = new PhoneBookManager(StoreMock.Object); var phoneBook = new PhoneBook(); await phonebookManager.PhoneBookCreate(phoneBook); for (int i = 0; i < 2000; i++) { Task.Run(() => phonebookManager2.PhoneBookUpdate(new PhoneBook { FirstName = "1", LastName = "1" })); Task.Run(() => phonebookManager.PhoneBookUpdate(new PhoneBook { FirstName = "3", LastName = "3" })); Task.Run(() => phonebookManager.PhoneBookUpdate(new PhoneBook { FirstName = "2", LastName = "2" })); } lock (lockObj) { Assert.IsTrue(phoneBooks.FirstName == phoneBooks.LastName); } }
static void Main(string[] args) { IReader reader = new Reader(); IWriter writer = new Writer(); IManager manager = new PhoneBookManager(); ICommandInterpreter command = new CommandInterpreter(manager); var engine = new Engine(reader, writer, command); engine.Run(); }
private void BindPhoneBook() { PhoneBookManager pbm=new PhoneBookManager(); DataTable dt = pbm.GetPhoneBook(); GridView3.DataSource = dt; GridView3.DataBind(); }
protected void LinkButton10_Click(object sender, EventArgs e) { PhoneBookManager pbm = new PhoneBookManager(); TabWebControl1.SelectedTabIndex = 5; ClientScript.RegisterStartupScript(this.GetType(), "", "<script>$('#addtelephonebook').css('display','block');$('#listtelephonebook').css('display','none');</script>"); int phonebookid = Convert.ToInt32(((LinkButton)sender).CommandArgument.ToString()); ModiftyPhonebookid = phonebookid; BindLeftUserInphonebook(phonebookid); phonebooknameinput.Text = pbm.GetAphoneBook(phonebookid).Telbook; BindRightUserInPhoneBook(phonebookid); BindHiddenStringInPhoneBook(); Button19.Text = "修改分组"; }
protected void Button19_Click(object sender, EventArgs e) { PhoneBookManager pbm = new PhoneBookManager(); if (Button19.Text == "确认分组") { string phonebookname = phonebooknameinput.Text.ToString().Trim(); string usernames = TextBox11.Text.ToString().Trim().Substring(0, TextBox11.Text.ToString().Trim().Length - 1); try { pbm.Add(phonebookname, usernames); ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script>alert('添加成功')</script>"); ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script>disaddtelephoebook();</script>"); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>DelAllselectusers()</script>"); BindPhoneBook(); TabWebControl1.SelectedTabIndex = 5; } catch (Exception ex) { throw ex; } } else { pbm.UpdatePhoneBook(ModiftyPhonebookid, phonebooknameinput.Text.ToString().Trim(), TextBox11.Text.ToString().Substring(0, TextBox11.Text.ToString().Length - 1)); ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script>alert('修改成功')</script>"); ClientScript.RegisterStartupScript(this.GetType(), "提示", "<script>disaddtelephoebook();</script>"); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>DelAllselectusers();</script>"); Button19.Text = "确认分组"; BindPhoneBook(); BindAllUser(); TabWebControl1.SelectedTabIndex = 5; } }
private void BindPhonebook() { PhoneBookManager pbm=new PhoneBookManager(); phonebooklist.DataSource = pbm.GetPhoneBook(); phonebooklist.DataTextField = "telbook"; phonebooklist.DataValueField = "id"; phonebooklist.DataBind(); ListItem li = new ListItem(); li.Value = ""; li.Text = "自定义"; phonebooklist.Items.Add(li); }
public PhoneBooksController(PhoneBookManager phoneBookManager) { this.phoneBookManager = phoneBookManager; }