public void TestFixtureSetUp() { _started = false; var recipientController = new Clerk(this, this); recipientController.Run(); }
public void Then_it_sends_a_telegram() { _actualChit = null; var senderController = new Clerk(this, this); senderController.Run(); OnTelegramRequestReceived(new ChitDeliveredEventArgs(new Chit("Hello, world!"))); }
public void TestFixtureSetUp() { _actualTelegram = null; var recipientController = new Clerk(this, this); recipientController.Run(); _expectedTelegram = new Telegram("Hello, world!"); OnTelegramReceived(new TelegramReceivedEventArgs(_expectedTelegram)); }
internal static void Main() { // Greshno, tai kato ne e rabota na Main metoda da vdiga zaplatatata na employee // Zatova se pravi IncomeVisitor, koito ima pravomostiata da ia vdiga var employee = new Clerk(); employee.Income += 1000; // Setup employee collection var employees = new Employees(); employees.Attach(new Clerk()); employees.Attach(new Director()); employees.Attach(new President()); // Employees are 'visited' employees.Accept(new IncomeVisitor()); employees.Accept(new VacationVisitor()); }
public EditViewModel(Clerk clerk, Product product) : base(clerk, product) { Product = product; SaveProductCommand = new Command ( () => { MessagingCenter.Send <Product>(Product, ASK); }, () => { return(!string.IsNullOrEmpty(Product.Description) && SalePrice > 0 && SalePrice < 100 && SelectedCategory != null); } ); }
private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0) { Clerk clerk = new Clerk() { Clerk_code = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(), Clerk_name = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(), Clerk_job = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString() }; Frm_ClerkUpdate fcu = new Frm_ClerkUpdate(clerk); fcu.ShowDialog(); if (fcu.DialogResult1 == DialogResult.Yes) { ReflashData(); } } }
protected override void SetupDataContext() { Debug.Assert(m_configurationParameters != null); base.SetupDataContext(); //this will normally be the same name as the view, e.g. "basicEdit". This plus the name of the vector //should give us a unique context for the dataTree control parameters. string persistContext = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "persistContext"); if (persistContext != "") { persistContext = m_vectorName + "." + persistContext + ".DataTree"; } else { persistContext = m_vectorName + ".DataTree"; } m_dataEntryForm.PersistenceProvder = new XCore.PersistenceProvider(persistContext, m_mediator.PropertyTable); Clerk.UpdateRecordTreeBarIfNeeded(); SetupSliceFilter(); m_dataEntryForm.Dock = System.Windows.Forms.DockStyle.Fill; m_dataEntryForm.StringTbl = this.StringTbl; m_dataEntryForm.SmallImages = (ImageCollection)this.m_mediator.PropertyTable.GetValue("smallImages"); string sDatabase = Cache.DatabaseName; m_dataEntryForm.Initialize(Cache, true, Inventory.GetInventory("layouts", sDatabase), Inventory.GetInventory("parts", sDatabase)); m_dataEntryForm.Init(m_mediator, m_configurationParameters); m_dataEntryForm.AccessibilityObject.Name = "RecordEditView.DataTree"; //set up the context menu, overriding the automatic menu creator/handler m_menuHandler = DTMenuHandler.Create(m_dataEntryForm, m_configurationParameters); m_menuHandler.Init(m_mediator, m_configurationParameters); // m_dataEntryForm.SetContextMenuHandler(new SliceMenuRequestHandler((m_menuHandler.GetSliceContextMenu)); m_dataEntryForm.SetContextMenuHandler(new SliceShowMenuRequestHandler(m_menuHandler.ShowSliceContextMenu)); Controls.Add(m_dataEntryForm); m_dataEntryForm.BringToFront(); }
/// <summary> /// Initialize this as an IxCoreColleague /// </summary> /// <remarks> subclasses must call this from their Init. /// This was done, rather than providing an Init() here in the normal way, /// to drive home the point that the subclass must set m_fullyInitialized /// to true when it is fully initialized.</remarks> /// <param name="mediator"></param> /// <param name="configurationParameters"></param> protected void InitBase(Mediator mediator, XmlNode configurationParameters) { Debug.Assert(m_fullyInitialized == false, "No way we are fully initialized yet!"); m_mediator = mediator; m_configurationParameters = configurationParameters; ReadParameters(); RecordClerk clerk = ExistingClerk; if (clerk == null) { // NOTE: new clerks do not typically complete ReloadList() // until Clerk.ActivateUI() is set (eg. here in SetupDataContext()). // however, we should further delay loading the list // if the subclass is initializing sorters/filters. // so we use ListUpdateHelper below to delay reloading the list. clerk = Clerk; Debug.Assert(clerk != null); } // suspend any loading of the Clerk's list items until after a // subclass (possibly) initializes sorters/filters // in SetupDataContext() using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(clerk)) { luh.ClearBrowseListUntilReload = true; clerk.UpdateOwningObjectIfNeeded(); SetTreebarAvailability(); AddPaneBar(); // NB: It is critical that we get added *after* our RecordClerk, // so that it will get messages, for example about a change of cache, before we do. mediator.AddColleague(this); SetupDataContext(); } // In case it hasn't yet been loaded, load it! See LT-10185. if (!Clerk.ListLoadingSuppressed && Clerk.RequestedLoadWhileSuppressed) { Clerk.UpdateList(true, true); } ShowRecord(); }
/// <summary> /// create and register a URL describing the current context, for use in going backwards and forwards /// </summary> protected virtual void UpdateContextHistory() { //are we the dominant pane? The thinking here is that if our clerk is controlling the record tree bar, then we are. // The second condition prevents recording the intermediate record in the history when following a link // causes us to change areas and then change records. if (Clerk.IsControllingTheRecordTreeBar && string.IsNullOrEmpty(m_propertyTable.GetStringProperty("SuspendLoadingRecordUntilOnJumpToRecord", null))) { //add our current state to the history system string toolName = m_propertyTable.GetStringProperty("currentContentControl", ""); Guid guid = Guid.Empty; if (Clerk.CurrentObject != null) { guid = Clerk.CurrentObject.Guid; } Clerk.SelectedRecordChanged(true, true); // make sure we update the record count in the Status bar. m_mediator.SendMessage("AddContextToHistory", new FwLinkArgs(toolName, guid), false); } }
private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtCode.Text)) { MessageBox.Show("사원코드를 입력해주세요.", "사원코드를 입력하지 않았습니다.", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCode.Focus(); } else if (new ClerkDAO().CheckClerkData(txtCode.Text)) { MessageBox.Show("이미 등록되어있는 사원코드입니다.\n다른 사원코드를 사용해주세요.", "사원코드 중복", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtCode.Focus(); } else if (String.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("사원이름을 입력해주세요.", "사원이름을 입력하지 않았습니다.", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); } else if (String.IsNullOrEmpty(txtPassword.Text)) { MessageBox.Show("비밀번호를 입력해주세요.", "비밀번호를 입력하지 않았습니다.", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPassword.Focus(); } else { Clerk clerk = new Clerk { Clerk_code = txtCode.Text, Clerk_name = txtName.Text, Clerk_job = cmbJob.Text, Clerk_password = txtPassword.Text }; if (new ClerkDAO().InsertClerk(clerk) != -1) { MessageBox.Show("새로운 사원을 등록했습니다.", "사원등록 성공", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("사원등록에 실패했습니다.", "사원등록 실패", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
protected virtual void PersistSortSequence() { if (Clerk == null || Clerk.IsDisposed) { return; // temporary clerk, such as a concordance in find example dialog. } // If we're being disposed because the application is crashing, we do NOT want to save the sort // sequence. It might contain bad objects, or represent a filtered state that is NOT going to // be persisted because of the crash. LT-11446. if (FwApp.InCrashedState) { return; } var pathname = GetClerkPersistPathname(); var watch = new Stopwatch(); watch.Start(); Clerk.PersistListOn(pathname); watch.Stop(); Debug.WriteLine("Saving clerk " + pathname + " took " + watch.ElapsedMilliseconds + " ms."); }
public bool LoginClerk(string username, string password) { Clerk clerk = GetClerkByUsername(username); bool success = true; if (clerk == null) { success = false; } if (clerk.Password != password) { success = false; } if (!success) { throw new AuthenticationException("Login failed"); } return(success); }
public int UpdateClerk(Clerk clerk) { string storedProcedureName = "UpdateClerk"; SqlParameter[] sqlParameters = { new SqlParameter("Clerk_code", clerk.Clerk_code), new SqlParameter("Clerk_name", clerk.Clerk_name), new SqlParameter("Clerk_job", clerk.Clerk_job) }; DBConnection con = new DBConnection(); try { return(con.ExecuteNonQuery(storedProcedureName, sqlParameters)); } catch (Exception) { throw; } }
public int InsertClerk(Clerk clerk) { string storedProcedureName = "InsertClerk"; DBConnection con = new DBConnection(); SqlParameter[] sqlParameters = new SqlParameter[4]; sqlParameters[0] = new SqlParameter("Clerk_code", clerk.Clerk_code); sqlParameters[1] = new SqlParameter("Clerk_name", clerk.Clerk_name); sqlParameters[2] = new SqlParameter("Clerk_job", clerk.Clerk_job); sqlParameters[3] = new SqlParameter("Clerk_password", clerk.Clerk_password); try { return(con.ExecuteNonQuery(storedProcedureName, sqlParameters)); } catch (Exception) { throw; } }
public void InsertDestination_WhenClerkInsertsADestination_ShouldBeStoredInTheDatabase() { // Arrange var destination = new Destination { Country = "Indonesia", Description = "EcoTourism at its best in exquisite Bali", Name = "Bali" }; var theClerk = new Clerk(); // Act theClerk.InsertsDestination(destination); // Assert Destination actualDestination = null; using (var context = new BreakAwayContext()) { actualDestination = context.Destinations.Where(x => x.Country == "Indonesia").FirstOrDefault(); } Assert.AreEqual(expected: destination, actual: actualDestination); }
public OrderEntryViewModel(Clerk clerk, Client client) { Client = client; Clerk = clerk; Items = new ObservableCollection <OrderTableItem>(); SearchProductCommand = new Command( () => { GetProduct(); }, () => { return(!string.IsNullOrEmpty(Code) && (Code.Length >= 9 && Code.Length <= 13)); }); AddProductCommand = new Command( () => { AddItem(); ClearTable(); }, () => { return(Id > 0 && !string.IsNullOrEmpty(Description) && UnitCost > 0 && Quantity > 0 && ExtendedCost > 0); } ); SaveOrderCommand = new Command(() => { MessagingCenter.Send(this, ASK); }, () => { return(Items.Count >= 1); } ); }
public ActionResult Index(BookingsViewModel model) { ViewBag.message = string.Empty; try { model.LocalAuthorities = GetLocalAuthorities(); var clerk = db.Clerks.FirstOrDefault(x => x.Email.Equals(model.Email.Trim(), StringComparison.OrdinalIgnoreCase)); if (clerk == null) { clerk = new Clerk { Email = model.Email }; db.Clerks.Add(clerk); db.SaveChanges(); } var localAuth = db.LocalAuthorities.First(x => x.Id.Equals(model.SelectedLocalAuthorities)); Booking booking = new Booking { Clerk = clerk, LocalAuthorities = localAuth, DateBooking = model.DateBooking }; bookingsController.PostBooking(booking); ViewBag.message = "Successfully booked!"; } catch (Exception ex) { ViewBag.message = "Error:" + ex.Message; } return(View(model)); }
protected override Clerk nextClerk() { Clerk c = null; while (c == null) { _pool.WaitOne(); lock (this) { if (allClerks.Count > 0) { c = allClerks[0]; allClerks.Remove(c); } else { Console.WriteLine("ERROR"); } } } return(c); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.WriteLine("\nWelcome to Citibank"); Clerk clerk = new Clerk("Clerk 1"); Supervisor supervisor = new Supervisor("Supervisor 1"); Manager manager = new Manager("Manager 1"); clerk.SetNext(supervisor); supervisor.SetNext(manager); State account = new State("Ricky Ricon Bank account", 42069.69); State account2 = new State("Student Bank account", 0.69); State account3 = new State("Fer's Bank account", 123.45); Console.WriteLine("Chain: Clerk > Supervisor > Manager\n"); Console.WriteLine($"Approached {clerk.name}. {clerk.Handle(1000, account)}"); Console.WriteLine($"Approached {clerk.name}. {clerk.Handle(1000, account2)}"); Console.WriteLine($"Approached {clerk.name}. {clerk.Handle(2000, account2)}"); Console.WriteLine($"Approached {clerk.name}. {clerk.Handle(5000, account3)}"); Console.WriteLine($"Approached {clerk.name}. {clerk.Handle(15000)}"); }
// Debit the account, public void DebitAccount(int ammount) { // <snippet11> // Create a new clerk using the AccountCompensator class. Clerk clerk = new Clerk(typeof(AccountCompensator), "An account transaction compensator", CompensatorOptions.AllPhases); // </snippet11> // <snippet12> // Create a record of previous account status, and deliver it to the clerk. int balance = AccountManager.ReadAccountBalance(filename); Object[] record = new Object[2]; record[0] = filename; record[1] = balance; clerk.WriteLogRecord(record); clerk.ForceLog(); // </snippet12> // Perform the transaction balance -= ammount; AccountManager.WriteAccountBalance(filename, balance); // <snippet13> // Commit or abort the transaction if (commit) { ContextUtil.SetComplete(); } else { ContextUtil.SetAbort(); } // </snippet13> }
// GET: Clerks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Clerk clerk = _db.Clerks.Find(id); if (clerk == null) { return(HttpNotFound()); } var users = _db.Users.ToList(); var roles = _db.Roles.ToList(); string roleId = ""; if (clerk.User != null && clerk.User.Roles.Count > 0) { roleId = clerk.User.Roles.FirstOrDefault().RoleId; } ViewBag.Users = new SelectList(users, "Id", "UserName", clerk.UserId); ViewBag.Roles = new SelectList(roles, "Id", "Name", roleId); return(View(clerk)); }
public ActionResult Create([Bind(Include = "ClerkID,FirstName,LastName")] Clerk clerk, string UserID) { if (ModelState.IsValid) { var user = _db.Users.FirstOrDefault(u => u.Id == UserID); if (_db.Clerks.FirstOrDefault(c => c.UserId == UserID) != null) { ModelState.AddModelError("", "The user " + user.UserName + " is already used with another clerk"); var users = _db.Users.ToList(); var roles = _db.Roles.ToList(); ViewBag.Users = new SelectList(users, "Id", "UserName"); ViewBag.Roles = new SelectList(roles, "Id", "Name"); return(View(clerk)); } clerk.UserId = UserID; _db.Clerks.Add(clerk); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(clerk)); }
public async void SavePayment() { using (HttpClient httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Clerk.GetToken()}"); var stringContent = new StringContent(PaymentToJson(), Encoding.UTF8, "application/json"); var response = await httpClient.PostAsync(URL_PAYMENT, stringContent); if (response.IsSuccessStatusCode) { MessagingCenter.Send <String>($"R$ {this.Client.Debt - this.Value}", SUCCESS); } else { var content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); if (response.Content != null) { response.Content.Dispose(); } var simpleHttpResponse = new SimpleHttpResponseException(response.StatusCode, response.ReasonPhrase, content); MessagingCenter.Send(simpleHttpResponse, FAIL); } } }
public void Visit(float context, Clerk clerk) { DoVisit(context, clerk); }
void SelectNewItem() { Clerk.OnJumpToRecord(m_newItem.Hvo); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Base method saves any time you switch between records. /// </summary> /// ------------------------------------------------------------------------------------ protected virtual void PrepCacheForNewRecord() { Clerk.SaveOnChangeRecord(); }
public void Start() { /* * Start up Reflection */ // create two objects Clerk c = new Clerk("Mia", 1988, new string[2] { "EASY", "Reception" }); Manager m = new Manager("Per", 1964); m.Employees.Add(c); m.Employees.Add(new Manager("Michael", 1955)); // printout Clerk Console.WriteLine(); Console.WriteLine("Start with clerk"); Console.WriteLine(); Console.WriteLine(c); TryReflection(c); // printout Manager Console.WriteLine(); Console.WriteLine("Then comes manager"); Console.WriteLine(); Console.WriteLine(m); TryReflection(m); /* * Serializing */ Console.WriteLine(); Console.WriteLine(" ===> Serializing <==="); Console.WriteLine(); // class with simple property types TestVarClass tvc = new TestVarClass(2000000000, -32000, 5000000000, 255, 't', true, "peter"); string jsonSimpleTypes = JsonConvert.SerializeObject(tvc); Console.WriteLine(jsonSimpleTypes); string jsonSimpleTypes2 = MyJsonConverter.Serialize(tvc); Console.WriteLine(jsonSimpleTypes2); // class with object property type AnotherTestClass atc = new AnotherTestClass() { InnerClass = new TestVarClass(30, 30, 30, 30, 'r', false, "anewObject") }; string jsonObjectTypes = JsonConvert.SerializeObject(atc); Console.WriteLine(jsonObjectTypes); string jsonObjectTypes2 = MyJsonConverter.Serialize(atc); Console.WriteLine(jsonObjectTypes2); // Class with List of strings - Clerk String jsonListStrings = JsonConvert.SerializeObject(c); Console.WriteLine(jsonListStrings); Console.WriteLine(MyJsonConverter.Serialize(c)); // Class with List of objects - Manager String jsonListObjects = JsonConvert.SerializeObject(m); Console.WriteLine(jsonListObjects); Console.WriteLine(MyJsonConverter.Serialize(m)); // Class with list of lists TestListInListClass tc = new TestListInListClass(); tc.ListClerks.Add(new List <Clerk>() { new Clerk("df", 1999, new string[] { "hej", "davs" }) }); tc.ListClerks.Add(new List <Clerk>() { new Clerk("dif", 2011, new string[] { "hej", "davs" }) }); tc.ListClerks.Add(new List <Clerk>() { new Clerk("fd", 2001, new string[] { "hej", "davs" }) }); Console.WriteLine(JsonConvert.SerializeObject(tc)); Console.WriteLine(MyJsonConverter.Serialize(tc)); /* * Deserializing */ Console.WriteLine(); Console.WriteLine(" ===> Deserializing <==="); Console.WriteLine(); // Simple types as properties TestVarClass tc2 = MyJsonConverter.Deserialize <TestVarClass>(jsonSimpleTypes); Console.WriteLine(tc2); // Object type as property AnotherTestClass atc2 = MyJsonConverter.Deserialize <AnotherTestClass>(jsonObjectTypes); Console.WriteLine(atc2); // clerk with list of strings //Clerk newClerk = MyJsonConverter.Deserialize<Clerk>(jsonListStrings); //Console.WriteLine("Deserialized clerk: " + newClerk); // Manager with list of objects //Manager newManager = MyJsonConverter.Deserialize<Manager>(jsonListObjects); //Console.WriteLine("Deserialized Manager: " + newManager); }
/// <summary> /// Initialize this as an IxCoreColleague /// </summary> /// <remarks> subclasses must call this from their Init. /// This was done, rather than providing an Init() here in the normal way, /// to drive home the point that the subclass must set m_fullyInitialized /// to true when it is fully initialized.</remarks> /// <param name="mediator"></param> /// <param name="propertyTable"></param> /// <param name="configurationParameters"></param> protected void InitBase(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters) { Debug.Assert(m_fullyInitialized == false, "No way we are fully initialized yet!"); m_mediator = mediator; m_propertyTable = propertyTable; m_configurationParameters = configurationParameters; ReadParameters(); RecordClerk clerk = ExistingClerk; bool fClerkAlreadySuppressed = false; bool fClerkWasCreated = false; if (clerk == null) { // We do NOT want to load the list as part of creating the clerk. // At earliest, we want to do so only when the ListUpdateHelper is disposed, // after the clerk and list are sufficiently initialized (e.g., with saved sorting and filtering // information) to sort correctly. This is part of a fairly convoluted attempt to prevent // sorting the list repeatedly during startup, even though startup involves many events // that normally require it to be resorted. // In this case the clerk will be created with its list already in the ListLoadingSuppressed state, // and already set to indicate that loading is necessary when suppression ends; // we want to pass FALSE to the ListUpdateHelper constructor, however, to pretend that the // list was NOT suppressed when the helper was created, so it will duly be sorted when // the helper is disposed. fClerkWasCreated = true; clerk = CreateClerk(false); Debug.Assert(clerk != null); } else { fClerkAlreadySuppressed = clerk.ListLoadingSuppressed; // If we didn't create the clerk, someone else might have suppressed it. } // suspend any loading of the Clerk's list items until after a // subclass (possibly) initializes sorters/filters // in SetupDataContext() bool didRestoreFromPersistence = false; using (var luh = new RecordClerk.ListUpdateHelper(clerk, fClerkAlreadySuppressed)) { luh.ClearBrowseListUntilReload = true; clerk.UpdateOwningObjectIfNeeded(); SetTreebarAvailability(); AddPaneBar(); //Historical comments here indicated that the Clerk should be processed by the mediator before the //view. This is handled by Priority now, RecordView is by default just after RecordClerk in the processing. mediator.AddColleague(this); SetupDataContext(); // Only if it was just now created should we try to restore from what we persisted. // Otherwise (e.g., FWR-1128) we may miss changes made to the list in other tools. if (fClerkWasCreated) { didRestoreFromPersistence = RestoreSortSequence(); } if (didRestoreFromPersistence) { luh.ListWasRestored(); } } // In case it hasn't yet been loaded, load it! See LT-10185. if (!didRestoreFromPersistence && !Clerk.ListLoadingSuppressed && Clerk.RequestedLoadWhileSuppressed) { Clerk.UpdateList(true, true); // sluggishness culprit for LT-12844 was in here } Clerk.SetCurrentFromRelatedClerk(); // See if some other clerk wants to influence our current object. ShowRecord(); }
private static void Main(string[] args) { #region AbstactFactoryDesignPattern /* Factory factory = new Factory(); * IVehicleFactory bike = factory.GetVehicle(EVehicleType.Bike); * bike.Drive(); * IVehicleFactory scooter = factory.GetVehicle(EVehicleType.Scooter); * scooter.Drive(); * IVehicleFactory car = factory.GetVehicle(EVehicleType.Car); * car.Drive(); * IVehicleFactory bus = factory.GetVehicle(EVehicleType.Bus); * bus.Drive(); * IVehicleFactory lorry = factory.GetVehicle(EVehicleType.Lorry); * lorry.Drive(); * IVehicleFactory train = factory.GetVehicle(EVehicleType.Train); * train.Drive(); * IVehicleFactory ship = factory.GetVehicle(EVehicleType.Ship); * ship.Drive(); * IVehicleFactory helicopter = factory.GetVehicle(EVehicleType.Helicopter); * helicopter.Drive(); */ #endregion AbstactFactoryDesignPattern #region Adapter ITarget Itarget = new EmployeeAdapter(); ThirdPartyBillingSystem client = new ThirdPartyBillingSystem(Itarget); client.ShowEmployeeList(); #endregion Adapter #region Bridge IMessageSender email = new EmailSender(); IMessageSender queue = new MSMQSender(); IMessageSender web = new WebServiceSender(); Message message = new SystemMessage(); message.Subject = "Test Message"; message.Body = "Hi, This is a Test Message"; message.MessageSender = email; message.Send(); message.MessageSender = queue; message.Send(); message.MessageSender = web; message.Send(); UserMessage usermsg = new UserMessage(); usermsg.Subject = "Test Message"; usermsg.Body = "Hi, This is a Test Message"; usermsg.UserComments = "I hope you are well"; usermsg.MessageSender = email; usermsg.Send(); #endregion Bridge #region Builder var vehicleCreator = new VehicleCreator(new HeroBuilder()); vehicleCreator.CreateVehicle(); var vehicle = vehicleCreator.GetVehicle(); vehicle.ShowInfo(); Console.WriteLine("---------------------------------------------"); vehicleCreator = new VehicleCreator(new HondaBuilder()); vehicleCreator.CreateVehicle(); vehicle = vehicleCreator.GetVehicle(); vehicle.ShowInfo(); #endregion Builder #region ChainOfResponsiblity Approver rohit = new Clerk(); Approver rahul = new AssistantManager(); Approver manoj = new Manager(); rohit.Successor = rahul; rahul.Successor = manoj; // Generate and process loan requests var loan = new Loan { Number = 2034, Amount = 24000.00, Purpose = "Laptop Loan" }; rohit.ProcessRequest(loan); loan = new Loan { Number = 2035, Amount = 42000.10, Purpose = "Bike Loan" }; rohit.ProcessRequest(loan); loan = new Loan { Number = 2036, Amount = 156200.00, Purpose = "House Loan" }; rohit.ProcessRequest(loan); #endregion ChainOfResponsiblity #region Command Console.WriteLine("Enter Commands (ON/OFF) : "); string cmd = Console.ReadLine(); Light lamp = new Light(); ICommand switchUp = new FlipUpCommand(lamp); ICommand switchDown = new FlipDownCommand(lamp); Switch s = new Switch(); if (cmd == "ON") { s.StoreAndExecute(switchUp); } else if (cmd == "OFF") { s.StoreAndExecute(switchDown); } else { Console.WriteLine("Command \"ON\" or \"OFF\" is required."); } #endregion Command #region Composite Employee Rahul = new Employee { EmpID = 1, Name = "Rahul" }; Employee Amit = new Employee { EmpID = 2, Name = "Amit" }; Employee Mohan = new Employee { EmpID = 3, Name = "Mohan" }; Rahul.AddSubordinate(Amit); Rahul.AddSubordinate(Mohan); Employee Rita = new Employee { EmpID = 4, Name = "Rita" }; Employee Hari = new Employee { EmpID = 5, Name = "Hari" }; Amit.AddSubordinate(Rita); Amit.AddSubordinate(Hari); Employee Kamal = new Employee { EmpID = 6, Name = "Kamal" }; Employee Raj = new Employee { EmpID = 7, Name = "Raj" }; Contractor Sam = new Contractor { EmpID = 8, Name = "Sam" }; Contractor tim = new Contractor { EmpID = 9, Name = "Tim" }; Mohan.AddSubordinate(Kamal); Mohan.AddSubordinate(Raj); Mohan.AddSubordinate(Sam); Mohan.AddSubordinate(tim); Console.WriteLine("EmpID={0}, Name={1}", Rahul.EmpID, Rahul.Name); foreach (Employee manager in Rahul) { Console.WriteLine("\n EmpID={0}, Name={1}", manager.EmpID, manager.Name); foreach (var employee in manager) { Console.WriteLine(" \t EmpID={0}, Name={1}", employee.EmpID, employee.Name); } } #endregion Composite #region Decorator HondaCity car = new HondaCity(); Console.WriteLine("Honda City base price are : {0}", car.Price); SpecialOffer offer = new SpecialOffer(car); offer.DiscountPercentage = 25; offer.Offer = "25 % discount"; Console.WriteLine("{1} @ Diwali Special Offer and price are : {0} ", offer.Price, offer.Offer); #endregion Decorator #region Facade CarFacade facade = new CarFacade(); facade.CreateCompleteCar(); #endregion Facade #region Flyweight ShapeObjectFactory sof = new ShapeObjectFactory(); IShape shape = sof.GetShape("Rectangle"); shape.Print(); shape = sof.GetShape("Rectangle"); shape.Print(); shape = sof.GetShape("Rectangle"); shape.Print(); shape = sof.GetShape("Circle"); shape.Print(); shape = sof.GetShape("Circle"); shape.Print(); shape = sof.GetShape("Circle"); shape.Print(); int NumObjs = sof.TotalObjectsCreated; Console.WriteLine("\nTotal No of Objects created = {0}", NumObjs); #endregion Flyweight #region FactoryDesignPattern Factory factory = new Factory(); FactoryDesignPattern.IVehicleFactory bike = factory.GetVehicle(EVehicleType.Bike); bike.Drive(); FactoryDesignPattern.IVehicleFactory scooter = factory.GetVehicle(EVehicleType.Scooter); scooter.Drive(); FactoryDesignPattern.IVehicleFactory fcar = factory.GetVehicle(EVehicleType.Car); fcar.Drive(); FactoryDesignPattern.IVehicleFactory bus = factory.GetVehicle(EVehicleType.Bus); bus.Drive(); FactoryDesignPattern.IVehicleFactory lorry = factory.GetVehicle(EVehicleType.Lorry); lorry.Drive(); FactoryDesignPattern.IVehicleFactory train = factory.GetVehicle(EVehicleType.Train); train.Drive(); FactoryDesignPattern.IVehicleFactory ship = factory.GetVehicle(EVehicleType.Ship); ship.Drive(); FactoryDesignPattern.IVehicleFactory helicopter = factory.GetVehicle(EVehicleType.Helicopter); helicopter.Drive(); #endregion FactoryDesignPattern #region Prototype Developer dev = new Developer(); dev.Name = "Rahul"; dev.Role = "Team Leader"; dev.PreferredLanguage = "C#"; Developer devCopy = (Developer)dev.Clone(); devCopy.Name = "Arif"; //Not mention Role and PreferredLanguage, it will copy above Console.WriteLine(dev.GetDetails()); Console.WriteLine(devCopy.GetDetails()); Typist typist = new Typist(); typist.Name = "Monu"; typist.Role = "Typist"; typist.WordsPerMinute = 120; Typist typistCopy = (Typist)typist.Clone(); typistCopy.Name = "Sahil"; typistCopy.WordsPerMinute = 115;//Not mention Role, it will copy above Console.WriteLine(typist.GetDetails()); Console.WriteLine(typistCopy.GetDetails()); #endregion Prototype #region Proxy ProxyClient proxy = new ProxyClient(); Console.WriteLine("Data from Proxy Client = {0}", proxy.GetData()); #endregion Proxy #region Singleton EagerSingleton.Instance.Show(); LazySingleton.Instance.Show(); Singleton.Instance.Show(); #endregion Singleton Console.ReadKey(); }
void SelectNewItem(object sender, bool fromUndoRedo) { ((IActionHandlerExtensions)m_cache.ActionHandlerAccessor).PropChangedCompleted -= SelectNewItem; Clerk.OnJumpToRecord(m_newItem.Hvo); }
static void doClerk(Clerk c) { c.add(); }
/// <summary> /// Initialize this as an IxCoreColleague /// </summary> /// <param name="mediator"></param> /// <param name="propertyTable"></param> /// <param name="configurationParameters"></param> public override void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters) { CheckDisposed(); InitBase(mediator, propertyTable, configurationParameters); m_browseViewer.Init(mediator, propertyTable, configurationParameters); m_fullyInitialized = true; // These have to be done here, rather than in SetupDataContext(), // or the record clerk resets its current object, // when the root object gets set in the borwse view's MakeRoot, // which, in turn, resets its current index to zero, // which fires events. By connecting them here, // they won't be ready to hand off to clients. m_browseViewer.SelectionChanged += OnSelectionChanged; m_browseViewer.SelectedIndexChanged += m_browseViewer_SelectedIndexChanged; m_browseViewer.FilterChanged += FilterChangedHandler; m_browseViewer.SorterChanged += SortChangedHandler; m_browseViewer.ListModificationInProgressChanged += m_browseViewer_ListModificationInProgressChanged; m_browseViewer.BrowseView.RightMouseClickedEvent += OnFwRightMouseClick; m_browseViewer.SelectionDrawingFailure += OnBrowseSelectionDrawingFailed; m_browseViewer.CheckBoxChanged += OnCheckBoxChanged; Clerk.FilterChangedByClerk += Clerk_FilterChangedByClerk; Clerk.SorterChangedByClerk += Clerk_SorterChangedByClerk; if (m_browseViewer.BulkEditBar != null) { // We have a browse viewer that is using a bulk edit bar, so make sure our RecordClerk // is properly setup/sync'd with its saved settings. m_browseViewer.BulkEditBar.TargetComboSelectedIndexChanged += TargetColumnChanged; if (m_browseViewer.BulkEditBar.ExpectedListItemsClassId != 0) { m_browseViewer.BulkEditBar.OnTargetComboSelectedIndexChanged(); CheckExpectedListItemsClassInSync(); } else { // now that we're finished setting up the bulk edit bar, we need to make // sure our clerk loads its defaults, since bulk edit didn't provide information // for which list items class to load objects for. if (Clerk.ListSize == 0) { Clerk.OnChangeListItemsClass(Clerk.SortItemProvider.ListItemsClass, 0, false); } } } // We're seeing an odd crash occurring during Init.ShowRecord() (see LT-9498) // where the Display is getting updated in RestoreSelectionAndScrollPos // after ShowRecord() below sets m_browseViewer.CurrentIndex. // As far as I (EricP) can tell "RestoreSelectionAndScrollPos" should only occur // after Init() (ie. Application.Idle()) and the user has created a new selection based upon // clicking or keyboard input. In otherwords, there is no reason to try to // restore a BrowseView Selection that has occurred before the user has // done anything to create a selection with the cursor. // In effort to avoid this crashing path, we clear any RootBox.Selection that // has been set by the program up to this point. If a Selection exists, // we will display a Debug message alerting programmers to investigate // how they got into this state. // The only reliable ways to trigger the assertion below seemed to involve active filters // and switching between areas (not tools). Since clicking Ignore seems to not cause // any problems, I am commenting out the assertion for now. if (m_browseViewer.BrowseView != null && m_browseViewer.BrowseView.RootBox != null && m_browseViewer.BrowseView.RootBox.Selection != null) { //Debug.Fail("Not sure how/why we have a RootBox.Selection at this point in initialization. " + // "Please comment in LT-9498 how you reproduced this. Perhaps it would indicate how to reproduce this crash."); m_browseViewer.BrowseView.RootBox.DestroySelection(); } // ShowRecord() was called in InitBase, but quit without doing anything, // so call it again, since we are ready now. ShowRecord(); }
protected override void SetupDataContext() { base.SetupDataContext(); // Make sure our persisted sorter/filters are up to date so browse viewer // has the latest set for configuring/activating the filterBar bool fNeedReload = Clerk.UpdateFiltersAndSortersIfNeeded(); // This is mainly to handle the possibility that one of our objects in a virtual // property has been deleted, either by some other tool, or by another client altogether. // Enhance: it would be very nice not to do this any time we can be sure it isn't needed. // The second 'true' here is to make it skip the sort. The sort has to be skipped at this // point because our VC has been disposed, and we haven't made a new one yet. The sort // will happen later in the sequence of Init when InitSorter is called int hvo = 0; if (Clerk.OwningObject != null) { hvo = Clerk.OwningObject.Hvo; } // We must update the list if needed BEFORE we create the actual view, otherwise, if it is trying // to display an out-of-date list containing deleted objects, all kinds of things may go wrong. if (XmlUtils.GetOptionalBooleanAttributeValue(m_configurationParameters, "forceReloadListOnInitOrChangeRoot", false)) { m_propertyTable.SetProperty(Clerk.Id + "_AlwaysRecomputeVirtualOnReloadList", true, true); // (EricP) when called by RecordView.InitBase() in the context of ListUpdateHelper.ClearBrowseListUntilReload // the list does not get reloaded until ListUpdateHelper is disposed, but the views property // will get cleared to prevent these views from accessing invalid objects. Clerk.UpdateList(false, true); } m_browseViewer = CreateBrowseViewer(m_configurationParameters, hvo, m_fakeFlid, Cache, m_mediator, m_propertyTable, Clerk.SortItemProvider, Clerk.VirtualListPublisher); m_browseViewer.SortersCompatible += Clerk.AreSortersCompatible; // If possible make it use the style sheet appropriate for its main window. m_browseViewer.SuspendLayout(); SetStyleSheet(); m_browseViewer.Dock = DockStyle.Fill; RecordFilter linkFilter = m_browseViewer.FilterFromLink(); SetupLinkScripture(); if (linkFilter != null) { Clerk.OnChangeFilter(new FilterChangeEventArgs(linkFilter, Clerk.Filter)); } if (Clerk.Filter != null && !Clerk.Filter.IsValid) { Clerk.ResetFilterToDefault(); } m_browseViewer.UpdateFilterBar(Clerk.Filter); bool fSortChanged = m_browseViewer.InitSorter(Clerk.Sorter); // true if we had to change sorter // Do this AFTER we init the sorter and filter, so if any changes are made to the // sorter or filter as we install, we still get the right load. if (fSortChanged) { HandleSortChange(); // Keep the current index -- see LT-8755. } else { List <int> sortedCols = m_browseViewer.SortedColumns; Clerk.IsDefaultSort = sortedCols.Count > 0 && sortedCols[0] == m_browseViewer.DefaultSortColumn; // This won't actually load if in the context of UpdateListHelper() Clerk.UpdateList(true, fNeedReload); } // Do this very late, it can't display properly until its record list has been built and sorted. Controls.Add(m_browseViewer); m_browseViewer.BringToFront(); m_browseViewer.ResumeLayout(); }
public static void Validate(Clerk clerk) { ValidateUsername(clerk.Username); ValidatePassword(clerk.Password); }
// Constructor. internal ClerkInfo(Clerk clerk) { this.clerk = clerk; }
/// <summary> /// This gets triggered when something goes wrong during drawing or hiding the selection /// in the browse view. Usually this is because of incomplete refresh, when some crucial object /// got deleted. Reconstructing the list often fixes things. /// </summary> public void OnBrowseSelectionDrawingFailed(object sender, EventArgs args) { CheckDisposed(); Clerk.OnRefresh(null); }