private void Add_Click(object sender, EventArgs e) { var category = new RepositoryCategory("new"); Repositories.RepositoryCategories.Add(category); Categories_SelectedIndexChanged(null, null); }
public void CanCreateProduct() { const string productname = "produit1"; const int quantiteMinimale = 15; var marque = new RepositoryMarque().FindAll().First(); var category = new RepositoryCategory().FindAll().First(); var fournisseur = new RepositoryFournisseur().FindAll().First(); var product = FactoryProduct.CreateProduct(productname, quantiteMinimale, category, marque, fournisseur); Assert.AreEqual(product.Name, "produit1"); Assert.AreEqual(product.QuantiteMin, 15); new RepositoryProduct().Save(product); var rp = new RepositoryMarque().FindBy(product.Marque.id); Assert.AreEqual(product.Marque.id, rp.id); Assert.AreEqual(product.Marque.Name, rp.Name); var rc = new RepositoryCategory().FindBy(product.Category.id); Assert.AreEqual(product.Category.id, rc.id); Assert.AreEqual(product.Category.Name, rc.Name); Assert.AreEqual(product.Category.Description, rc.Description); new RepositoryProduct().Remove(product); }
private void newCategoryMenuItem_Click(object sender, EventArgs e) { var toolStripItem = sender as ToolStripItem; if (toolStripItem == null) { return; } var repository = toolStripItem.Tag as Repository; if (repository == null) { return; } var formDashboardCategoryTitle = new FormDashboardCategoryTitle(); formDashboardCategoryTitle.ShowDialog(this); if (string.IsNullOrEmpty(formDashboardCategoryTitle.GetTitle())) { return; } var newRepositoryCategory = new RepositoryCategory(formDashboardCategoryTitle.GetTitle()); RepositoryCategory.RemoveRepository(repository); repository.RepositoryType = RepositoryType.Repository; newRepositoryCategory.AddRepository(repository); Repositories.RepositoryCategories.Add(newRepositoryCategory); dashboardCategoryChanged(this, null); }
/// <summary> /// Déduit à partir d'un chemin physique, le chemin relatif et la catégorie du fichier. /// </summary> /// <param name="physicalPath">Chemin physique dans le référentiel local</param> /// <param name="category">Catégorie du fichier</param> public static string MakeRelative(string physicalPath, out RepositoryCategory category) { if (Utils.StringStartsWith(physicalPath, CandleSettings.RepositoryModelsLocalFolder)) { category = RepositoryCategory.Models; return(physicalPath.Substring(CandleSettings.RepositoryModelsLocalFolder.Length + 1)); } string path = GetFolderPath(RepositoryCategory.Strategies); if (physicalPath.StartsWith(path, StringComparison.CurrentCultureIgnoreCase)) { category = RepositoryCategory.Strategies; return(physicalPath.Substring(path.Length + 1)); } path = GetFolderPath(RepositoryCategory.T4Templates); if (physicalPath.StartsWith(path, StringComparison.CurrentCultureIgnoreCase)) { category = RepositoryCategory.T4Templates; return(physicalPath.Substring(path.Length + 1)); } path = GetFolderPath(RepositoryCategory.Configuration); if (physicalPath.StartsWith(path, StringComparison.CurrentCultureIgnoreCase)) { category = RepositoryCategory.Configuration; return(physicalPath.Substring(path.Length + 1)); } throw new Exception("Unable to find the category for this file."); }
private void addToItem_Click(object sender, EventArgs e) { var toolStripItem = sender as ToolStripItem; if (toolStripItem == null) { return; } if (repository == null) { return; } foreach (RepositoryCategory newRepositoryCategory in Repositories.RepositoryCategories) { if (newRepositoryCategory.Description.Equals(toolStripItem.Text)) { RepositoryCategory.RemoveRepository(repository); repository.RepositoryType = RepositoryType.Repository; newRepositoryCategory.AddRepository(repository); } } dashboardCategoryChanged(this, null); }
/// <summary> /// Récupère un fichier dans le repository /// </summary> /// <param name="category">Category du fichier à récupérer</param> /// <param name="path">Chemin d'accés relatif à la catégorie</param> /// <param name="localFile">Chemin absolu local de destination</param> /// <returns>Status du chargement</returns> public RepositoryServerItemStatus GetFile(RepositoryCategory category, string path, string localFile) { ILogger logger = ServiceLocator.Instance.GetService <ILogger>(); string sourcePath = RepositoryManager.ResolvePath(category, path); if (!File.Exists(sourcePath)) { return(RepositoryServerItemStatus.NotFound); } // C'est le même fichier if (Utils.StringCompareEquals(sourcePath, localFile)) { return(RepositoryServerItemStatus.NotModified); } try { Utils.CopyFile(sourcePath, localFile); return(RepositoryServerItemStatus.Loaded); } catch (Exception ex) { if (logger != null) { logger.WriteError("Get remote file", String.Format("Error : unable to copy the file {0}", path), ex); } } return(RepositoryServerItemStatus.NotFound); }
/// <summary> /// Récupére un fichier en privilégiant la version du repository central /// </summary> /// <param name="category"></param> /// <param name="path"></param> /// <param name="targetFileName"></param> /// <returns></returns> public bool GetFileFromRepository(RepositoryCategory category, string path, string targetFileName) { if (_wsRepository != null) { if (_wsRepository.GetFile(category, path, targetFileName) != RepositoryServerItemStatus.NotFound) { return(true); } } if (_localRepository != null) { if (_localRepository.GetFile(category, path, targetFileName) != RepositoryServerItemStatus.NotFound) { return(true); } } // Si toujours pas, on va lire dans les autres serveurs foreach (IRepositoryProvider provider in _providers) { if (provider != _wsRepository && provider != _localRepository) { if (provider.GetFile(category, path, targetFileName) != RepositoryServerItemStatus.NotFound) { return(true); } } } return(false); }
private void newCategoryMenuItem_Click(object sender, EventArgs e) { if (repository == null) { return; } RepositoryCategory newRepositoryCategory; using (var formDashboardCategoryTitle = new FormDashboardCategoryTitle()) { formDashboardCategoryTitle.ShowDialog(this); if (string.IsNullOrEmpty(formDashboardCategoryTitle.GetTitle())) { return; } newRepositoryCategory = new RepositoryCategory(formDashboardCategoryTitle.GetTitle()); } RepositoryCategory.RemoveRepository(repository); repository.RepositoryType = RepositoryType.Repository; newRepositoryCategory.AddRepository(repository); Repositories.RepositoryCategories.Add(newRepositoryCategory); dashboardCategoryChanged(this, null); }
/// <summary> /// Constructeur à partir d'un chemin relatif /// </summary> /// <param name="category">Categorie dans lequel se trouve le fichier</param> /// <param name="path">Fichier relatif</param> public RepositoryFile(RepositoryCategory category, string path) { Debug.Assert(!Path.IsPathRooted(path), "Le chemin doit etre relatif"); _category = category; _path = path; _absolutePath = CreateAbsoluteLocalPath(path); }
/// <summary> /// Enumerates the recursive. /// </summary> /// <param name="pathRootLength">Length of the path root.</param> /// <param name="di">The di.</param> /// <param name="category">The category.</param> /// <param name="filter">The filter.</param> /// <param name="recursive">if set to <c>true</c> [recursive].</param> /// <returns></returns> public static List <RepositoryFileInfo> EnumerateRecursive(int pathRootLength, DirectoryInfo di, RepositoryCategory category, string filter, bool recursive) { if (String.IsNullOrEmpty(filter)) { filter = "*.*"; } List <RepositoryFileInfo> results = new List <RepositoryFileInfo>(); if (di.Exists) { foreach (FileInfo fi in di.GetFiles(filter)) { RepositoryFileInfo rfi = new RepositoryFileInfo(); rfi.FileName = fi.FullName.Substring(pathRootLength); rfi.LastWriteTimeUtc = fi.LastWriteTimeUtc; results.Add(rfi); } if (recursive) { foreach (DirectoryInfo childDi in di.GetDirectories()) { results.AddRange(EnumerateRecursive(pathRootLength, childDi, category, filter, true)); } } } return(results); }
/// <summary> /// Copie un fichier du repository en local /// </summary> /// <param name="category">Category du fichier à récupérer</param> /// <param name="path">Chemin d'accés relatif à la catégorie</param> /// <param name="localFile">Chemin absolu local de destination</param> /// <returns>Status du chargement</returns> public RepositoryServerItemStatus GetFile(RepositoryCategory category, string path, string localFile) { string url = String.Format("{0}/services/DownloadFile.ashx?c={1}&p={2}", _baseUrl, category, HttpUtility.UrlEncode(path)); return(GetFile(url, localFile)); }
public DashboardCategory(string title, RepositoryCategory repositoryCategory) { InitializeComponent(); SetUpFonts(); Translate(); this.Title = title; this.RepositoryCategory = repositoryCategory; this.AutoSizeMode = AutoSizeMode.GrowAndShrink; }
public UnitOfWork(ApplicationDbContext context) { _context = context; Images = new RepositoryImage(context); Advertisements = new RepositoryAdvertisement(context); Categories = new RepositoryCategory(context); Comments = new RepositoryComment(context); }
public RepositoryFileInfo[] EnumerateCategory(RepositoryCategory category, string filter, bool recursive) { object[] results = this.Invoke("EnumerateCategory", new object[] { category, filter, recursive }); return((RepositoryFileInfo[])(results[0])); }
public void ShowRecentRepositories() { if (!Visible) { return; } // Make sure the dashboard is only initialized once if (!initialized) { // Remove favorites var categories = (from DashboardCategory i in this.groupLayoutPanel.Controls select i).ToList(); this.groupLayoutPanel.Controls.Clear(); foreach (var category in categories) { category.DashboardCategoryChanged -= dashboardCategory_DashboardCategoryChanged; category.DashboardItemClick -= dashboardItem_Click; category.Clear(); } // Show favorites foreach (var category in Repositories.RepositoryCategories) { AddDashboardEntry(category); } initialized = true; } splitContainer6.Panel1MinSize = 1; splitContainer6.Panel2MinSize = 1; splitContainer7.Panel1MinSize = 1; splitContainer7.Panel2MinSize = 1; RecentRepositories.Clear(); RepositoryCategory filteredRecentRepositoryHistory = new RepositoryCategory(); filteredRecentRepositoryHistory.Description = Repositories.RepositoryHistory.Description; filteredRecentRepositoryHistory.CategoryType = Repositories.RepositoryHistory.CategoryType; foreach (Repository repository in Repositories.RepositoryHistory.Repositories) { if (!Repositories.RepositoryCategories.Any(c => c.Repositories.Any(r => r.Path != null && r.Path.Equals(repository.Path, StringComparison.CurrentCultureIgnoreCase)))) { repository.RepositoryType = RepositoryType.History; filteredRecentRepositoryHistory.Repositories.Add(repository); } } RecentRepositories.RepositoryCategory = filteredRecentRepositoryHistory; pictureBox1.BringToFront(); SetSplitterPositions(); }
private void AddDashboardEntry(RepositoryCategory entry) { var dashboardCategory = new DashboardCategory(entry.Description, entry); this.groupLayoutPanel.Controls.Add(dashboardCategory); dashboardCategory.DashboardItemClick += dashboardItem_Click; dashboardCategory.DashboardCategoryChanged += dashboardCategory_DashboardCategoryChanged; }
/// <summary> /// Attention : Ne doit être appelé que par RepositoryManager.StrategiesFolder /// </summary> /// <param name="category"></param> /// <returns></returns> internal static string GetFolderPath(RepositoryCategory category) { if (category == RepositoryCategory.Models) { return(RepositoryModelsLocalFolder); } return(Path.Combine(BaseDirectory, category.ToString())); }
public List <RepositoryFileInfo> EnumerateCategory(RepositoryCategory category, string filter, bool recursive) { CandleRepositoryController.Instance.NotifyAction(Context.User, Context.Request["id"], "EnumerateCategory", category, filter, recursive); DirectoryInfo di = new DirectoryInfo(RepositoryManager.GetFolderPath(category)); List <RepositoryFileInfo> results = FileRepositoryProvider.EnumerateRecursive(di.FullName.Length + 1, di, category, filter, recursive); results.Sort(); return(results); }
public DashboardCategory(string title, RepositoryCategory repositoryCategory) { InitializeComponent(); SetUpFonts(); Translate(); Title = title; RepositoryCategory = repositoryCategory; AutoSizeMode = AutoSizeMode.GrowAndShrink; }
private void removeMenuItem_Click(object sender, EventArgs e) { if (repository == null) { return; } RepositoryCategory.RemoveRepository(repository); repositoryRemoved(repository); dashboardCategoryChanged(this, null); }
/// <summary> /// Création du chemin physique à partir du chemin relatif /// </summary> /// <param name="category">Catégorie ou est stocké le fichier</param> /// <param name="relativePath">Chemin relatif</param> /// <returns>Chemin physique en local</returns> public static string ResolvePath(RepositoryCategory category, string relativePath) { switch (category) { case RepositoryCategory.Models: return(Path.Combine(CandleSettings.RepositoryModelsLocalFolder, relativePath)); default: return(Path.Combine(GetFolderPath(category), relativePath)); } }
/// <remarks/> public void EnumerateCategoryAsync(RepositoryCategory category, string filter, bool recursive, object userState) { if ((this.EnumerateCategoryOperationCompleted == null)) { this.EnumerateCategoryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnEnumerateCategoryOperationCompleted); } this.InvokeAsync("EnumerateCategory", new object[] { category, filter, recursive }, this.EnumerateCategoryOperationCompleted, userState); }
public void GetProductminimal() { const string productname = "HP Desktop I3"; const int quantiteMinimale = 10; const string productname1 = "HP Desktop I5"; const int quantiteMinimale1 = 10; var marque = new RepositoryMarque().FindAll().First(); var category = new RepositoryCategory().FindAll().First(); var fournisseur = new RepositoryFournisseur().FindAll().First(); var product = FactoryProduct.CreateProduct(productname, quantiteMinimale, category, marque, fournisseur); var product1 = FactoryProduct.CreateProduct(productname1, quantiteMinimale1, category, marque, fournisseur); Assert.AreEqual(product.Name, productname); Assert.AreEqual(product.QuantiteMin, quantiteMinimale); Assert.AreEqual(product1.Name, productname1); Assert.AreEqual(product1.QuantiteMin, quantiteMinimale1); new RepositoryProduct().Save(product); new RepositoryProduct().Save(product1); var rp = new RepositoryMarque().FindBy(product.Marque.id); Assert.AreEqual(product.Marque.id, rp.id); Assert.AreEqual(product.Marque.Name, rp.Name); var rc = new RepositoryCategory().FindBy(product.Category.id); Assert.AreEqual(product.Category.id, rc.id); Assert.AreEqual(product.Category.Name, rc.Name); Assert.AreEqual(product.Category.Description, rc.Description); const string stockname = "Stock Tlemcen"; var wilaya = new RepositoryWilaya().FindAll().First(w => w.Name == "Tlemcen"); var commune = new RepositoryWilaya().FindAll().First(w => w.Name == "Tlemcen").Communes.First(com => com.Name == "Tlemcen"); const string adresse = "S3 lot Sekkal el Kiffane"; var stock = FactoryStock.CreateStock(stockname, wilaya, commune, adresse); Assert.AreEqual(stock.Name, stockname); var lineStock = FactoryStock.CreateProductLine(stock, product, 5); var lineStock1 = FactoryStock.CreateProductLine(stock, product1, 20); Assert.AreEqual(lineStock.Product, product); Assert.AreEqual(lineStock.Quantity, 5); Assert.AreEqual(lineStock1.Product, product1); Assert.AreEqual(lineStock1.Quantity, 20); new RepositoryStock().Save(stock); var listProduct = stock.GetProductMinimale(); Assert.AreEqual(listProduct.Count, 1); new RepositoryStock().Remove(stock); new RepositoryProduct().Remove(product); new RepositoryProduct().Remove(product1); }
public void ShowRecentRepositories() { if (!Visible) { return; } //Make sure the dashboard is only initialized once if (!initialized) { //Remove favourites for (int i = splitContainer5.Panel2.Controls.Count; i > 0; i--) { DashboardCategory dashboarCategory = splitContainer5.Panel2.Controls[i - 1] as DashboardCategory; if (dashboarCategory != null) { dashboarCategory.DashboardCategoryChanged -= dashboardCategory_DashboardCategoryChanged; dashboarCategory.DashboardItemClick -= dashboardItem_Click; dashboarCategory.Clear(); splitContainer5.Panel2.Controls.RemoveAt(i - 1); } } //Show favourites Repositories.RepositoryCategories.Aggregate(0, AddDashboardEntry); splitContainer7.SplitterDistance = splitContainer7.Height - (DonateCategory.Height + 25); initialized = true; splitContainer7.SplitterDistance = splitContainer7.Height - (DonateCategory.Height + 25); initialized = true; } RecentRepositories.Clear(); RepositoryCategory filteredRecentRepositoryHistory = new RepositoryCategory(); filteredRecentRepositoryHistory.Description = Repositories.RepositoryHistory.Description; filteredRecentRepositoryHistory.CategoryType = Repositories.RepositoryHistory.CategoryType; foreach (Repository repository in Repositories.RepositoryHistory.Repositories) { if (!Repositories.RepositoryCategories.Any(c => c.Repositories.Any(r => r.Path != null && r.Path.Equals(repository.Path, StringComparison.CurrentCultureIgnoreCase)))) { repository.RepositoryType = RepositoryType.History; filteredRecentRepositoryHistory.Repositories.Add(repository); } } RecentRepositories.RepositoryCategory = filteredRecentRepositoryHistory; }
/// <summary> /// Publie un fichier sur le référentiel /// </summary> /// <param name="fileName">Chemin relatif du fichier</param> /// <param name="category">Categorie d'appartenance</param> /// <param name="remoteName">Nom du fichier destination</param> /// <returns></returns> public string PublishFile(string fileName, RepositoryCategory category, string remoteName) { string url = String.Format("{0}/services/uploadModel.ashx?n={1}&id={2}&c={3}&v={4}", _baseUrl, HttpUtility.UrlEncode(remoteName), CandleSettings.LicenseId, category, CandleSettings.Version); WebClient wc = new WebClient(); wc.Proxy = GetProxy(); wc.UploadFile(url, fileName); return(fileName); }
private int AddDashboardEntry(int y, RepositoryCategory entry) { var dashboardCategory = new DashboardCategory(entry.Description, entry) { Location = new Point(0, y), Width = splitContainer5.Panel2.Width }; splitContainer5.Panel2.Controls.Add(dashboardCategory); dashboardCategory.BringToFront(); y += dashboardCategory.Height; dashboardCategory.DashboardItemClick += dashboardItem_Click; dashboardCategory.DashboardCategoryChanged += dashboardCategory_DashboardCategoryChanged; return(y); }
/// <summary> /// Archive une liste de fichiers /// </summary> /// <param name="fileNames">The file names.</param> public void ArchiveFiles(List <string> fileNames) { RepositoryCategory category = RepositoryCategory.Models; List <string> tmp = new List <string>(); for (int i = 0; i < fileNames.Count; i++) { if (File.Exists(fileNames[i])) { tmp.Add(RepositoryManager.MakeRelative(fileNames[i], out category)); } } if (tmp.Count > 0) { new ZipFileCompressor(_zipFileName, RepositoryManager.GetFolderPath(category), tmp.ToArray(), true); } }
private void removeMenuItem_Click(object sender, EventArgs e) { var toolStripItem = sender as ToolStripItem; if (toolStripItem == null) { return; } var repository = toolStripItem.Tag as Repository; if (repository == null) { return; } RepositoryCategory.RemoveRepository(repository); repositoryRemoved(repository); dashboardCategoryChanged(this, null); }
public FrmEditProduct(ModelViewProduct product, bool newProduct) { InitializeComponent(); var repositoryCategory = new RepositoryCategory(); var repositoryMarque = new RepositoryMarque(); var repositoryFournisseur = new RepositoryFournisseur(); var repositoryProduit = new RepositoryProduct(); _editProductPresenter = new EditProductPresenterPage(this, repositoryCategory, repositoryMarque, repositoryFournisseur, repositoryProduit); _editProductPresenter.Display(); comboBoxCategory.DataSource = Categories; comboBoxCategory.DisplayMember = "Name"; comboBoxCategory.ValueMember = "Name"; comboBoxFournisseur.DataSource = Fournisseurs; comboBoxFournisseur.DisplayMember = "Name"; comboBoxFournisseur.ValueMember = "Name"; comboBoxMarque.DataSource = Marques; comboBoxMarque.DisplayMember = "Name"; comboBoxMarque.ValueMember = "Name"; comboBoxTypeGestion.DataSource = Enum.GetValues(typeof(GestionProduit)); if (!newProduct) { IdProduct = product.Id; textEditNameProduct.Text = product.Nom; comboBoxCategory.SelectedValue = product.Categorie; comboBoxMarque.SelectedValue = product.Marque; comboBoxFournisseur.SelectedValue = product.Fournisseur; textEditQuantité.Text = product.QuantiteMin.ToString(CultureInfo.InvariantCulture); dateEditEntree.Text = product.DateEntree.ToShortDateString(); comboBoxTypeGestion.SelectedItem = product.TypeGestion; } IsProductModified = false; _newProduct = newProduct; }
/// <summary> /// Gets the list for category. /// </summary> /// <param name="category">The category.</param> /// <param name="filter">The filter.</param> /// <returns></returns> private List <string> GetListForCategory(RepositoryCategory category, string filter) { List <string> templates = new List <string>(); IRepositoryProvider provider = _wsRepository; if (provider == null) { provider = _localRepository; if (provider == null) { return(templates); } } List <RepositoryFileInfo> files = null; try { files = provider.EnumerateCategory(category, filter, true); } catch { if (provider == _wsRepository && _localRepository != null) { files = _localRepository.EnumerateCategory(category, filter, true); } } if (files != null) { foreach (RepositoryFileInfo rfi in files) { templates.Add(rfi.FileName); } } return(templates); }
private int AddDashboardEntry(int y, RepositoryCategory entry) { DashboardCategory dashboardCategory = new DashboardCategory(entry.Description, entry) { Location = new Point(0, y), Width = splitContainer5.Panel2.Width }; dashboardCategory.DashboardItemClick += new EventHandler(dashboardItem_Click); splitContainer5.Panel2.Controls.Add(dashboardCategory); dashboardCategory.BringToFront(); y += dashboardCategory.Height; //Recalculate hieght when list is changed //entry.ListChanged += entry_ListChanged; dashboardCategory.DashboardCategoryChanged += new EventHandler(dashboardCategory_DashboardCategoryChanged); return y; }
private int AddDashboardEntry(int y, RepositoryCategory entry) { DashboardCategory dashboardCategory = new DashboardCategory(entry.Description, entry) { Location = new Point(0, y), Width = splitContainer5.Panel2.Width }; splitContainer5.Panel2.Controls.Add(dashboardCategory); dashboardCategory.BringToFront(); y += dashboardCategory.Height; dashboardCategory.DashboardItemClick += dashboardItem_Click; dashboardCategory.DashboardCategoryChanged += dashboardCategory_DashboardCategoryChanged; return y; }
public DashboardCategory(string title, RepositoryCategory repositoryCategory) : this() { Title = title; RepositoryCategory = repositoryCategory; }
void newCategoryMenuItem_Click(object sender, EventArgs e) { ToolStripItem toolStripItem = sender as ToolStripItem; if (toolStripItem == null) return; Repository repository = toolStripItem.Tag as Repository; if (repository == null) return; FormDashboardCategoryTitle formDashboardCategoryTitle = new FormDashboardCategoryTitle(); formDashboardCategoryTitle.ShowDialog(); if (string.IsNullOrEmpty(formDashboardCategoryTitle.GetTitle())) return; RepositoryCategory newRepositoryCategory = new RepositoryCategory(formDashboardCategoryTitle.GetTitle()); RepositoryCategory.RemoveRepository(repository); repository.RepositoryType = RepositoryType.Repository; newRepositoryCategory.AddRepository(repository); Repositories.RepositoryCategories.Add(newRepositoryCategory); dashboardCategoryChanged(this, null); }
private void newCategoryMenuItem_Click(object sender, EventArgs e) { if (repository == null) return; RepositoryCategory newRepositoryCategory; using (var formDashboardCategoryTitle = new FormDashboardCategoryTitle()) { formDashboardCategoryTitle.ShowDialog(this); if (string.IsNullOrEmpty(formDashboardCategoryTitle.GetTitle())) return; newRepositoryCategory = new RepositoryCategory(formDashboardCategoryTitle.GetTitle()); } RepositoryCategory.RemoveRepository(repository); repository.RepositoryType = RepositoryType.Repository; newRepositoryCategory.AddRepository(repository); Repositories.RepositoryCategories.Add(newRepositoryCategory); dashboardCategoryChanged(this, null); }