protected override void OnDeleteDirectories(FilePath[] localPaths, bool force, IProgressMonitor monitor, bool keepLocal) { foreach (FilePath localPath in localPaths) { Bazaar.Remove(localPath.FullPath, force, monitor); } }
protected override void OnRevert(FilePath[] localPaths, bool recurse, IProgressMonitor monitor) { foreach (FilePath localPath in localPaths) { Bazaar.Revert(localPath.FullPath, recurse, monitor, new BazaarRevision(this, BazaarRevision.HEAD)); } }
protected override void OnRevertRevision(FilePath localPath, Revision revision, IProgressMonitor monitor) { if (IsModified(BazaarRepository.GetLocalBasePath(localPath))) { MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, GettextCatalog.GetString("You have uncommitted local changes. Revert anyway?")); try { if ((int)ResponseType.Yes != md.Run()) { return; } } finally { md.Destroy(); } } BazaarRevision brev = (BazaarRevision)revision; string localPathStr = localPath.FullPath; Bazaar.Merge(localPathStr, localPathStr, false, true, brev, (BazaarRevision)(brev.GetPrevious()), monitor); }
/// <summary> /// This method is to avoid deadlock in the sense that stores have products to /// sell but customer does not have any money. Creates four customer and threads. /// Start thread after x milliseconds. /// </summary> /// <param name="bank"></param> /// <param name="bazaar"></param> public void GenerateExtraCustomers(Bank.BankFlyweight.Bank bank, Bazaar bazaar) { Thread[] extraCostumerThreads = new Thread[5]; var custom = new Customer(115, "John", bank, bazaar); var custom1 = new Customer(116, "Hans", bank, bazaar); var custom2 = new Customer(117, "Leila", bank, bazaar); var custom3 = new Customer(118, "Tina", bank, bazaar); var custom4 = new Customer(119, "Ringo", bank, bazaar); var customerList = new List <Customer>(); customerList.Add(custom); customerList.Add(custom1); customerList.Add(custom2); customerList.Add(custom3); customerList.Add(custom4); for (var i = 0; i < customerList.Count; i++) { var customer = customerList[i]; var thread = new Thread(customer.BuyItem); extraCostumerThreads[i] = thread; } foreach (var customerThread in extraCostumerThreads) { customerThread.Start(); Thread.Sleep(200); } }
protected override void OnCheckout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor) { Bazaar.StoreCredentials(Url); BazaarRevision brev = (null == rev) ? new BazaarRevision(this, BazaarRevision.HEAD) : (BazaarRevision)rev; Bazaar.Checkout(Url, targetLocalPath.FullPath, brev, recurse, monitor); }
/// <summary> /// Adds a customer to the list and returns it /// </summary> /// <param name="bank"></param> /// <param name="bazaar"></param> /// <returns>Customer Returns a customer if created successfully</returns> private Customer AddCustomerToList(Bank.BankFlyweight.Bank bank, Bazaar bazaar) { var values = Enum.GetValues(typeof(Names)); var customerName = values.GetValue(Client.Rnd.Next(0, values.Length)); var nameIsTaken = false; while (!nameIsTaken) { if (_nameList.Count != 0) { foreach (var name in _nameList) { if (name.Equals(customerName.ToString())) { nameIsTaken = true; } } } if (nameIsTaken) { customerName = values.GetValue(Client.Rnd.Next(values.Length)); nameIsTaken = false; } else { _nameList.Add(customerName.ToString()); return(new Customer(_socialSecurityNumber++, customerName.ToString(), bank, bazaar)); } } return(null); }
/// <summary> /// Creates All Customers /// </summary> /// <param name="bank"></param> /// <param name="bazaar"></param> private void CreateAllCustomers(Bank.BankFlyweight.Bank bank, Bazaar bazaar) { for (var i = 0; i < AmountOfCustomers - 1; i++) { Customers.Add(AddCustomerToList(bank, bazaar)); } }
protected override void OnIgnore(FilePath[] localPath) { foreach (var path in localPath) { Bazaar.Ignore(path.FullPath); } }
public virtual void Resolve(FilePath[] localPaths, bool recurse, IProgressMonitor monitor) { foreach (FilePath localPath in localPaths) { Bazaar.Resolve(localPath.FullPath, recurse, monitor); } }
public List <Bazaar> GetBazaarById(int memberId) { SqlConnection connection = new SqlConnection(databaseConString); string query = "select * from tbl_Members as m inner join tbl_Users as u on m.user_id = u.u_id join tbl_Bazaars as b on b.member_id = m.m_id WHERE member_id = +'" + memberId + "'"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); List <Bazaar> memberBazaars = new List <Bazaar>(); int serialNo = 1; while (reader.Read()) { Bazaar aBazaar = new Bazaar(); aBazaar.SerialNo = serialNo++; //aBazaar.MemberName = reader["user_name"].ToString(); //aBazaar.MemberEmail = reader["email"].ToString(); aBazaar.BazaarDate = reader["bazaar_date"].ToString(); aBazaar.BazaarAmount = int.Parse(reader["bazaar_amount"].ToString()); memberBazaars.Add(aBazaar); } reader.Close(); connection.Close(); return(memberBazaars); }
protected override void OnAdd(FilePath[] localPaths, bool recurse, IProgressMonitor monitor) { foreach (FilePath localPath in localPaths) { Bazaar.Add(localPath.FullPath, recurse, monitor); } }
protected override Repository OnPublish(string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor) { serverPath = string.Format("{0}{1}{2}", Url, Url.EndsWith("/") ? string.Empty : "/", serverPath); Bazaar.StoreCredentials(serverPath); Bazaar.Push(serverPath, localPath.FullPath, false, false, false, monitor); return(new BazaarRepository(Bazaar, serverPath)); }
protected override Revision[] OnGetHistory(FilePath localFile, Revision since) { if (null == LocalBasePath) { LocalBasePath = GetLocalBasePath(localFile.FullPath); } return(Bazaar.GetHistory(this, localFile.FullPath, since)); }
/// <summary> /// Starts all store threads /// </summary> /// <param name="bazaar"></param> public void StartAllStoresThreads(Bazaar bazaar) { CreateAllStoresThreads(bazaar); foreach (var storeThread in StoreThreads) { storeThread.Start(); } }
protected override IEnumerable <VersionInfo> OnGetVersionInfo(IEnumerable <FilePath> paths, bool getRemoteStatus) { foreach (var localPath in paths) { statusCache[localPath] = Bazaar.GetVersionInfo(this, localPath.FullPath, getRemoteStatus); } return(statusCache.Select(s => s.Value)); }
private void InitializeShops() { Mall mall = new Mall(); Bazaar bazaar = new Bazaar(mall); Store store = new Store(bazaar); shops.Add("Mall", mall); shops.Add("Bazaar", bazaar); shops.Add("Store", store); }
protected void AddBazaarButton_Click(object sender, EventArgs e) { Bazaar aBazaar = new Bazaar(); aBazaar.MemberId = int.Parse(memberNameDropDownList.SelectedValue); aBazaar.BazaarDate = Request.Form["bazaarDateTextBox"]; aBazaar.BazaarAmount = int.Parse(Request.Form["bazaarAmountTextBox"]); message.Text = aBazaarManager.AddBazaar(aBazaar); }
public string AddBazaar(Bazaar aBazaar) { if (aBazaarGateway.AddBazaar(aBazaar) > 0) { return("Added Successfully"); } else { return("Could Not Added!"); } }
public static IDataProvider CreateDataProvider() { var shops = new Dictionary <string, IShop>(); var mall = new Mall(null); var bazaar = new Bazaar(mall); var store = new Store(bazaar); shops.Add("Mall", mall); shops.Add("Bazaar", bazaar); shops.Add("Store", store); return(new MarketDataProvider(shops, new TypeProvider(typeof(IShop).Assembly))); }
protected override VersionInfo[] OnGetDirectoryVersionInfo(FilePath localDirectory, bool getRemoteStatus, bool recursive) { VersionInfo[] versions = Bazaar.GetDirectoryVersionInfo(this, localDirectory.FullPath, getRemoteStatus, recursive); if (null != versions) { foreach (VersionInfo version in versions) { statusCache[version.LocalPath] = version; } } return(versions); }
/// <summary> /// Creates all store threads /// </summary> /// <param name="bazaar"></param> private void CreateAllStoresThreads(Bazaar bazaar) { var storesList = bazaar.ListOfAllStores; var i = 0; foreach (var store in storesList) { var thread = new Thread(store.FillProducts); StoreThreads[i] = thread; ++i; } }
public static IDictionary <string, IShop> CreatePredefinedShops() { IDictionary <string, IShop> shops = new Dictionary <string, IShop>(); Mall mall = new Mall(); Bazaar bazaar = new Bazaar(mall); Store store = new Store(bazaar); shops.Add(mall.GetType().Name, mall); shops.Add(bazaar.GetType().Name, bazaar); shops.Add(store.GetType().Name, store); return(shops); }
public int AddBazaar(Bazaar aBazaar) { SqlConnection connection = new SqlConnection(databaseConString); string query = "INSERT INTO tbl_Bazaars VALUES ('" + aBazaar.MemberId + "','" + aBazaar.BazaarDate + "','" + aBazaar.BazaarAmount + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int dbRowAffected = command.ExecuteNonQuery(); connection.Close(); return(dbRowAffected); }
public override string GetBaseText(FilePath localFilePath) { string localFile = localFilePath.FullPath; try { return(Bazaar.GetTextAtRevision(localFile, new BazaarRevision(this, BazaarRevision.HEAD))); } catch (Exception e) { LoggingService.LogError("Error getting base text", e); } return(localFile); }
protected override void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor) { if (IsModified(BazaarRepository.GetLocalBasePath(localPath))) { MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, GettextCatalog.GetString("You have uncommitted local changes. Revert anyway?")); try { if ((int)ResponseType.Yes != md.Run()) { return; } } finally { md.Destroy(); } } BazaarRevision brev = (null == revision) ? new BazaarRevision(this, BazaarRevision.HEAD) : (BazaarRevision)revision; Bazaar.Revert(localPath.FullPath, true, monitor, brev); }
public virtual void Bind(string branchUrl, FilePath localPath, IProgressMonitor monitor) { Bazaar.Bind(branchUrl, localPath.FullPath, monitor); }
public virtual void Uncommit(FilePath localPath, IProgressMonitor monitor) { Bazaar.Uncommit(localPath.FullPath, monitor); }
public virtual Dictionary <string, BranchType> GetKnownBranches(FilePath localPath) { return(Bazaar.GetKnownBranches(localPath.FullPath)); }
public virtual void Export(FilePath localPath, FilePath exportLocation, IProgressMonitor monitor) { Bazaar.Export(localPath.FullPath, exportLocation.FullPath, monitor); }
public virtual void Push(string pushLocation, FilePath localPath, bool remember, bool overwrite, bool omitHistory, IProgressMonitor monitor) { Bazaar.StoreCredentials(pushLocation); Bazaar.Push(pushLocation, localPath.FullPath, remember, overwrite, omitHistory, monitor); }