Example #1
0
 //private readonly IImagem _imagem;
 public CadastrarItemHandler(IMediator mediator, IRepositoryEmpresa repositoryEmpresa, IRepositoryItem repositoryItem, IUnitOfWork unitOfWork)
 {
     _mediator          = mediator;
     _repositoryEmpresa = repositoryEmpresa;
     _repositoryItem    = repositoryItem;
     _unitOfWork        = unitOfWork;
 }
        /// <summary>
        /// Gets the description of the item to be displayed in the UI.
        /// </summary>
        public static string GetDescription(this IRepositoryItem item)
        {
            switch (item.Type)
            {
            case RepositoryItemType.TmsSource:
                var tmsItem = item as ITmsItem;
                return(GetDescription(tmsItem));

            case RepositoryItemType.Image:
            case RepositoryItemType.Vector:
                var fileItem = item as IFileItem;
                if (fileItem != null)
                {
                    return(GetDescription(fileItem.Filename));
                }
                break;

            case RepositoryItemType.DatabaseLayer:
                var layerItem = item as IDatabaseLayerItem;
                return(GetDescription(layerItem));

            case RepositoryItemType.Database:
                var dbItem = item as IDatabaseItem;
                return(GetDescription(dbItem));
            }

            return(string.Empty);
        }
        private void UpdateDocumentList()
        {
            IRepositoryItem folder = repoView.SelectedItem;

            if (folder != null)
            {
                txtFolder.Text = folder.ResourceId;

                if (!this.SelectFoldersOnly)
                {
                    ResourceList list = null;
                    if (!this.UseFilter)
                    {
                        list = _conn.ResourceService.GetRepositoryResources(folder.ResourceId, 1);
                    }
                    else
                    {
                        list = _conn.ResourceService.GetRepositoryResources(folder.ResourceId, this.Filter.ToString(), 1);
                    }

                    PopulateDocumentList(list);
                }
            }
            btnPreview.Enabled             = false;
            lblPreviewNotAvailable.Visible = true;
            if (picPreview.Image != null)
            {
                picPreview.Image.Dispose();
                picPreview.Image = null;
            }
        }
Example #4
0
 public RetornarCardapioMesaHandler(IMediator mediator, IRepositoryItem repositoryItem, IRepositoryMesa repositoryMesa, IRepositoryEmpresa repositoryEmpresa)
 {
     _mediator          = mediator;
     _repositoryItem    = repositoryItem;
     _repositoryMesa    = repositoryMesa;
     _repositoryEmpresa = repositoryEmpresa;
 }
Example #5
0
 public void UpdateState(IRepositoryItem item)
 {
     if (item != null && _layers != null)
     {
         item.SubItems.UpdateState(_layers);
     }
 }
 public RepositoryEventArgs(IRepositoryItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     Item = item;
 }
Example #7
0
 private static void SetParent(ICollection <IRepositoryItem> items, IRepositoryItem parent)
 {
     foreach (IRepositoryItem item in items)
     {
         item.Parent = parent;
         SetParent(item.Items, item);
     }
 }
 public ServiceCart(IRepositoryItem service, IUnitOfWork unitofwork)
     : base(unitofwork)
 {
     if (null == service)
     {
         throw new ArgumentNullException("service");
     }
     _service = service;
 }
Example #9
0
 public RealizarPedidoHandler(IMediator mediator, IRepositoryItemComanda repositoryItemComanda, IRepositoryComanda repositoryComanda, IRepositoryUsuario repositoryUsuario, IRepositoryMesa repositoryMesa, IRepositoryItem repositoryItem, IUnitOfWork unitOfWork)
 {
     _mediator              = mediator;
     _repositoryUsuario     = repositoryUsuario;
     _repositoryItemComanda = repositoryItemComanda;
     _unitOfWork            = unitOfWork;
     _repositoryMesa        = repositoryMesa;
     _repositoryItem        = repositoryItem;
     _repositoryComanda     = repositoryComanda;
 }
 public RetornarComandaHandler(IMediator mediator, IRepositoryComanda repositoryComanda, IRepositoryEmpresa repositoryEmpresa, IRepositoryMesa repositoryMesa, IRepositoryItemComanda repositoryItemComanda,
                               IRepositoryItem repositoryItem)
 {
     _mediator              = mediator;
     _repositoryEmpresa     = repositoryEmpresa;
     _repositoryMesa        = repositoryMesa;
     _repositoryComanda     = repositoryComanda;
     _repositoryItemComanda = repositoryItemComanda;
     _repositoryItem        = repositoryItem;
 }
Example #11
0
        public ActionResult Spiele(int kategorie_id = 5)
        {
            List <Item> items;

            rep = new RepositoryItemDB();
            rep.Open();
            items = rep.GetItemsByCategory(kategorie_id);
            rep.Close();

            return(View(items));
        }
Example #12
0
        public ActionResult Gartenausstattung(int kategorie_id = 3)
        {
            List <Item> items;

            rep = new RepositoryItemDB();
            rep.Open();
            items = rep.GetItemsByCategory(kategorie_id);
            rep.Close();

            return(View(items));
        }
Example #13
0
 private void SaveExpadedFolders(IRepositoryItem root)
 {
     foreach (var f in root.SubItems.OfType <IFolderItem>())
     {
         if (f.Expanded)
         {
             _repository.ExpandedFolders.Add(f.GetPath());
             SaveExpadedFolders(f);
         }
     }
 }
Example #14
0
        //GET: Home
        public ActionResult Index()
        {
            List <Item> items;

            rep = new RepositoryItemDB();
            rep.Open();
            items = rep.GetAllItem();
            rep.Close();

            return(View(items));
        }
        public IRepositoryItem GetBeverage(string beverageName)
        {
            IRepositoryItem item = items.SingleOrDefault(i => i.Beverage.Name == beverageName);

            if (item == null)
            {
                throw new Exception($"Нет такого напитка {beverageName}");
            }

            return(item);
        }
Example #16
0
        private void RestoreFoldersExpandedState(IRepositoryItem root)
        {
            foreach (var f in root.SubItems.OfType <IFolderItem>())
            {
                if (_expandedFolders.Contains(f.GetPath().ToLower()))
                {
                    f.ForceExpand();

                    RestoreFoldersExpandedState(f);
                }
            }
        }
 public RepositoryModelItem(IRepositoryItem item)
 {
     _item = item;
     if (this.IsRoot)
     {
         this.ImageIndex = RepositoryIcons.RES_ROOT;
     }
     else
     {
         if (this.IsFolder)
         {
             this.ImageIndex = RepositoryIcons.RES_FOLDER;
         }
         else
         {
             this.ImageIndex = RepositoryIcons.GetImageIndexForResourceType(_item.ResourceType);
         }
     }
 }
Example #18
0
        private void UpdateDescription(IRepositoryItem item)
        {
            richTextBox1.SetText("Loading...");

            Task <string> .Factory.StartNew(item.GetDescription).ContinueWith(description =>
            {
                try
                {
                    string msg = string.Format("{0}{2}{2}{1}", item.DisplayName, description.Result,
                                               Environment.NewLine);
                    richTextBox1.SetDescription(msg);
                }
                catch (Exception ex)
                {
                    Logger.Current.Error("Failed to load datasource description: {0}", ex, item.DisplayName);
                    richTextBox1.SetText("Failed to load description.");
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        public IRepositoryItem Show(IRepositoryItem item)
        {
            Owner = ApplicationExtention.ActiveWindow;
            if (Application.Current != null)
            {
                Application.Current.DisableWindow();
            }

            if (item == null)
            {
                AddMode     = true;
                Item        = new RepositoryItem();
                WindowTitle = "Добавление";
            }
            else
            {
                AddMode     = false;
                Item        = item;
                WindowTitle = "Редактирование";
            }

            bool?show = ShowDialog();

            if (Application.Current != null)
            {
                Application.Current.EnableWindow();
            }

            if (show.HasValue && show.Value == true)
            {
                return(_repositoryItem);
            }
            else
            {
                return(null);
            }
        }
Example #20
0
        public bool AddRepositoryItem(IRepositoryItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (!_repositoryItems.Contains(item))
            {
                App.ToLogInfo(String.Format("Добавление элемента в репозиторий: <{0}>", item.ToString()));

                RepositoryItems.Add(item);

                if (RepositoryItemAdded != null)
                {
                    RepositoryItemAdded(this, new RepositoryItemAddedEventArgs(item));
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #21
0
 public ServiceItem(IRepositoryItem iRepositoryProcurement) : base(iRepositoryProcurement)
 {
 }
 /// <summary>
 /// Обновление элемента на основании переданного
 /// </summary>
 public void Update(IRepositoryItem item)
 {
     this.Title       = item.Title;
     this.Description = item.Description;
 }
Example #23
0
 private void RefreshItem(IRepositoryItem item)
 {
     item.Refresh();
     View.Tree.UpdateState(item);
 }
Example #24
0
 /// <summary>
 /// Обновление элемента на основании переданного
 /// </summary>
 public void Update(IRepositoryItem item)
 {
     this.Title        = item.Title;
     this.Description  = item.Description;
     this.SqlViewModel = (item as RepositoryItem).SqlViewModel;
 }
 public RetornarItensEmpresaHandler(IMediator mediator, IRepositoryItem repositoryItem)
 {
     _mediator       = mediator;
     _repositoryItem = repositoryItem;
 }
 public RepositoryItemAddedEventArgs(IRepositoryItem item)
 {
     this.NewRepositoryItem = item;
 }
Example #27
0
        internal RepositoryItem(string connectionName, IRepositoryItem item)
        {
            _name     = string.Empty;
            _children = new Dictionary <string, RepositoryItem>();

            this.ConnectionName = connectionName;
            this.CreatedDate    = item.CreatedDate;
            this.ModifiedDate   = item.ModifiedDate;
            this.Owner          = item.Owner;
            this.ResourceId     = item.ResourceId;
            this.ResourceType   = item.ResourceType;
            this.Name           = item.Name; //set name last because update logic requires other properties be set already

            if (this.IsRoot)
            {
                this.Icon = Properties.Resources.server;
            }
            else
            {
                //TODO: Should probably centralize this in ResourceIconCache
                switch (item.ResourceType)
                {
                case "DrawingSource":
                    this.Icon = Properties.Resources.blueprints;
                    break;

                case "FeatureSource":
                    this.Icon = Properties.Resources.database_share;
                    break;

                case "Folder":
                    this.Icon = Properties.Resources.folder_horizontal;
                    break;

                case "LayerDefinition":
                    this.Icon = Properties.Resources.layer;
                    break;

                case "MapDefinition":
                    this.Icon = Properties.Resources.map;
                    break;

                case "WebLayout":
                    this.Icon = Properties.Resources.application_browser;
                    break;

                case "ApplicationDefinition":
                    this.Icon = Properties.Resources.applications_stack;
                    break;

                case "SymbolLibrary":
                    this.Icon = Properties.Resources.images_stack;
                    break;

                case "PrintLayout":
                    this.Icon = Properties.Resources.printer;
                    break;

                case "SymbolDefinition":
                    this.Icon = Properties.Resources.marker;
                    break;

                case "WatermarkDefinition":
                    this.Icon = Properties.Resources.water;
                    break;

                case "TileSetDefinition":
                    this.Icon = Properties.Resources.grid;
                    break;

                default:
                    this.Icon = Properties.Resources.document;
                    break;
                }
            }

            _notify = true;
        }
Example #28
0
        private static void SeedPipe(UnitOfWorkProcurement unit, IRepositoryItem repItem, IRepositoryItemType repItemType, IRepositoryTemplateItem repTemplateItem, IRepositoryTemplateAttribute repTemplateAttribute
                                     , IRepositoryAttributeValue repAttributeValue)
        {
            //Pipe_catalogue.csv

            #region Pipe
            ItemType itemType = new ItemType()
            {
                Name = "Pipe"
            };
            repItemType.Insert(itemType);


            TemplateAttribute spec = new TemplateAttribute()
            {
                Name = "Specification", Order = 1
            };
            TemplateAttribute grade = new TemplateAttribute()
            {
                Name = "Grade", Order = 2
            };
            TemplateAttribute nps = new TemplateAttribute()
            {
                Name = "NPS", Order = 3
            };
            TemplateAttribute thickness = new TemplateAttribute()
            {
                Name = "Thickness", Order = 54
            };
            TemplateAttribute welded = new TemplateAttribute()
            {
                Name = "Welded/Seamless", Order = 5
            };
            TemplateAttribute kg = new TemplateAttribute()
            {
                Name = "Kg/m", Order = 6
            };

            //UNSPSC Code;Specification;Grade;NPS;Thickness;Welded/Seamless;Kg/m
            List <TemplateAttribute> attributes = new List <TemplateAttribute>()
            {
                spec,
                grade,
                nps,
                thickness,
                welded,
                kg,
                new TemplateAttribute()
                {
                    Name = "Reference standard", Order = 7
                },
                new TemplateAttribute()
                {
                    Name = "Rating class", Order = 8
                },
                new TemplateAttribute()
                {
                    Name = "Material Specification", Order = 9
                },
                new TemplateAttribute()
                {
                    Name = "Endings", Order = 10
                },
            };
            repTemplateAttribute.InsertRange(attributes);
            TemplateItem pipe = new TemplateItem()
            {
                Name = "Pipe", ItemType = itemType, ModelAttributes = attributes
            };
            repTemplateItem.Insert(pipe);

            IEnumerable <string> lines = System.IO.File.ReadLines(@"C:\Proc\Pipe_catalogue.csv");

            int count = 1;

            foreach (var line in lines)
            {
                string[] columnsValues = null;
                if (count == 1)
                {
                    columnsValues = line.Split(';');
                }
                else
                {
                    columnsValues = line.Split(';');

                    Item item = new Item()
                    {
                        Template = pipe,
                        UNSPSC   = columnsValues[0]
                    };
                    repItem.Insert(item);
                    unit.SaveChanges();

                    List <AttributeValue> listAttrValues = new List <AttributeValue>()
                    {
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = spec, Value = columnsValues[1]
                        },
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = grade, Value = columnsValues[2]
                        },
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = nps, Value = columnsValues[3]
                        },
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = thickness, Value = columnsValues[4]
                        },
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = welded, Value = columnsValues[5]
                        },
                        new AttributeValue()
                        {
                            Item = item, TemplateAttribute = kg, Value = columnsValues[6]
                        }
                    };
                    repAttributeValue.InsertRange(listAttrValues);
                    item.AttributeValues = listAttrValues;
                    repItem.Update(item);
                }
                count++;

                if (count >= 700)
                {
                    break;
                }
            }



            #endregion
        }
Example #29
0
 public RepositoryModelItem(IRepositoryItem item)
 {
     _item = item;
     if (this.IsRoot)
     {
         this.ImageIndex = RepositoryIcons.RES_ROOT;
     }
     else
     {
         if (this.IsFolder)
             this.ImageIndex = RepositoryIcons.RES_FOLDER;
         else
             this.ImageIndex = RepositoryIcons.GetImageIndexForResourceType(_item.ResourceType);
     }
 }
Example #30
0
        internal RepositoryItem(string connectionName, IRepositoryItem item)
        {
            _name = string.Empty;
            _children = new Dictionary<string, RepositoryItem>();

            this.ConnectionName = connectionName;
            this.CreatedDate = item.CreatedDate;
            this.ModifiedDate = item.ModifiedDate;
            this.Owner = item.Owner;
            this.ResourceId = item.ResourceId;
            this.ResourceType = item.ResourceType.ToString();
            this.Name = item.Name; //set name last because update logic requires other properties be set already

            if (this.IsRoot)
            {
                this.Icon = Properties.Resources.server;
            }
            else
            {
                switch (item.ResourceType)
                {
                    case ResourceTypes.DrawingSource:
                        this.Icon = Properties.Resources.blueprints;
                        break;
                    case ResourceTypes.FeatureSource:
                        this.Icon = Properties.Resources.database_share;
                        break;
                    case ResourceTypes.Folder:
                        this.Icon = Properties.Resources.folder_horizontal;
                        break;
                    case ResourceTypes.LayerDefinition:
                        this.Icon = Properties.Resources.layer;
                        break;
                    case ResourceTypes.MapDefinition:
                        this.Icon = Properties.Resources.map;
                        break;
                    case ResourceTypes.WebLayout:
                        this.Icon = Properties.Resources.application_browser;
                        break;
                    case ResourceTypes.ApplicationDefinition:
                        this.Icon = Properties.Resources.applications_stack;
                        break;
                    case ResourceTypes.SymbolLibrary:
                        this.Icon = Properties.Resources.images_stack;
                        break;
                    case ResourceTypes.PrintLayout:
                        this.Icon = Properties.Resources.printer;
                        break;
                    case ResourceTypes.SymbolDefinition:
                        this.Icon = Properties.Resources.marker;
                        break;
                    case ResourceTypes.WatermarkDefinition:
                        this.Icon = Properties.Resources.water;
                        break;
                    default:
                        this.Icon = Properties.Resources.document;
                        break;
                }
            }

            _notify = true;
        }
Example #31
0
 public ServiceItem(IRepositoryItem repositoryItem) : base(repositoryItem)
 {
     _repositoryItem = repositoryItem;
 }
        private void InitCommands()
        {
            AddCommand = new DelegateCommand(() =>
            {
                AddEditWindow aer      = new AddEditWindow();
                IRepositoryItem result = aer.Show(null);

                if (result != null)
                {
                    if (SelectedItem != null)
                    {
                        result.Parent = SelectedItem;
                        SelectedItem.Items.Add(result);
                    }
                    else
                    {
                        result.Parent = null;
                        RepositoryItems.Add(result);
                    }
                    App.Log.Log(String.Format("В репозиторий добавлен элемент <{0}>", result));
                    OnPropertyChanged("IsEmptyList");
                    Save();
                }
            });

            RemoveCommand = new DelegateCommand(() =>
            {
                if (SelectedItem == null)
                {
                    return;
                }

                if (App.ShowQuestion("Вы действительно хотите удалить запись с именем '" + SelectedItem.Title + "'?") == System.Windows.MessageBoxResult.Yes)
                {
                    IRepositoryItem parent = SelectedItem.Parent;
                    if (parent != null)
                    {
                        parent.Items.Remove(SelectedItem);
                    }
                    else
                    {
                        RepositoryItems.Remove(SelectedItem);
                    }
                    App.Log.Log(String.Format("Из репозитория удалён элемент <{0}>", SelectedItem));
                    Save();
                }
            }, (param) =>
            {
                return(SelectedItem != null);
            });

            EditCommand = new DelegateCommand(() =>
            {
                if (SelectedItem == null)
                {
                    throw new InvalidOperationException("EditCommand - SelectedItem == null");
                }
                App.Log.Log(String.Format("Попытка изменения элемента репозитория: <{0}>", SelectedItem));
                AddEditWindow aer      = new AddEditWindow();
                aer.Owner              = App.Current.MainWindow;
                IRepositoryItem result = aer.Show(SelectedItem.Clone());

                if (result != null)
                {
                    IRepositoryItem parent = SelectedItem.Parent;
                    if (parent != null)
                    {
                        int index = parent.Items.IndexOf(SelectedItem);
                        if (index > 0)
                        {
                            parent.Items[index] = result;
                        }
                        SelectedItem = result;
                    }
                    else
                    {
                        SelectedItem = result;
                    }
                    App.Log.Log(String.Format("Изменённый элемент репозитория: <{0}>", result));
                    Save();
                }
            }, (param) =>
            {
                return(SelectedItem != null);
            });

            LoadCommand = new DelegateCommand(() =>
            {
                if (SelectedItem == null)
                {
                    throw new InvalidOperationException("EditCommand - SelectedItem == null");
                }

                if (SelectedItem.Type == RepositoryItemType.Group)
                {
                    throw new ArgumentException("Выбрана не запись, а группа!");
                }

                SqlViewModel = (SelectedItem as RepositoryItem).SqlViewModel;

                FuncSqlViewModelSelected?.Invoke(this, new SelectFuncSqlViewModelEventArgs(SelectedItem.Title, SqlViewModel));

                App.Log.Log(String.Format("Выбран элемент репозитория: <{0}>", SelectedItem));
            }, (param) =>
            {
                return(SelectedItem is RepositoryItem);
            });

            ImportCommand = new DelegateCommand(() =>
            {
                if (RepositoryItems != null && RepositoryItems.Count > 0)
                {
                    if (App.ShowQuestion("Очистить список перед импортом'?") == System.Windows.MessageBoxResult.Yes)
                    {
                        RepositoryItems.Clear();
                    }
                }
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.AddExtension    = true;
                ofd.CheckFileExists = true;
                ofd.Filter          = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION);
                ofd.FilterIndex     = 0;
                bool?show           = ofd.ShowDialog(Application.Current.MainWindow);
                if (show != null && show.HasValue && show.Value == true)
                {
                    App.Log.Log("Попытка импорта списка запросов из файла '" + ofd.FileName + "'");
                    bool success = true;
                    IList <IRepositoryItem> list = Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonDeSerialize(
                        ofd.FileName,
                        (e) =>
                    {
                        success = false;
                        App.ToLogException(e);
                        App.ShowError(String.Format("Не удалось импортировать список запросов.\n\t{0}", e.Message), "ОШИБКА");
                    });
                    if (list != null)
                    {
                        var notImported = new List <IRepositoryItem>();
                        foreach (var item in list)
                        {
                            if (_repository.AddRepositoryItem(item) == false)
                            {
                                notImported.Add(item);
                            }
                        }
                        int toImportCount    = GetRequestsCountInList(list);
                        int notImportedCount = GetRequestsCountInList(notImported);
                        int allCount         = GetRequestsCountInList(RepositoryItems);
                        string message       = String.Format("Завершён. Импортировано {0} запросов из списка. Не удалось импортировать {1} запросов. Всего сейчас в списке {2} запросов.",
                                                             toImportCount - notImportedCount, notImportedCount, allCount);
                        App.Log.Log(message);
                        App.ShowInfo(message, "ИМПОРТ");
                    }
                    else if (success)
                    {
                        string message = "Ничего не импортировано. Файл пуст!";
                        App.Log.Log(message);
                        App.ShowInfo(message, "ИМПОРТ");
                    }
                }
            });
            ExportCommand = new DelegateCommand(() =>
            {
                Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog();
                ofd.AddExtension = true;
                ofd.Filter       = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION);
                ofd.FilterIndex  = 0;
                bool?show        = ofd.ShowDialog(Application.Current.MainWindow);
                if (show != null && show.HasValue && show.Value == true)
                {
                    App.Log.Log("Попытка экспорта списка запросов в файл '" + ofd.FileName + "'");
                    bool success = true;
                    Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonSerialize(
                        RepositoryItems.ToList(),
                        ofd.FileName,
                        (e) =>
                    {
                        success = false;
                        App.ToLogException(e);
                        App.ShowError(String.Format("Не удалось экспортировать список запросов.\n\t{0}", e.Message), "ОШИБКА");
                    });
                    if (success)
                    {
                        string message = String.Format("Экспортировано {0} запросов.", RepositoryItems.Count);
                        App.Log.Log(message);
                        App.ShowInfo(message, "ЭКСПОРТ");
                    }
                }
            }, (param) =>
            {
                if (RepositoryItems == null)
                {
                    return(false);
                }
                else
                {
                    return(RepositoryItems.Count != 0);
                }
            });
        }