Пример #1
0
 public BaseUserControl(IBaseModel baseModel, bool applyTheme)
 {
     this.applyTheme = applyTheme;
     DataContext = baseModel;
     Model = baseModel;
     BaseWindow.AddStyleResouse(Resources);
 }
Пример #2
0
        /// <summary>
        /// Validiert ein Property
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        private string ValidateProperty(string propertyName, IMethodInvocation input)
        {
            if (!_isChangeNotificationActive)
            {
                return(string.Empty);
            }

            IBaseModel model = (IBaseModel)input.Target;

            ValidationSummary validationSummary = Validator.Validate(model);

            string result = null;

            IList <ValidationEntry> validationEntries = validationSummary.Where(d => d.FieldName == propertyName).ToList();

            if (validationEntries.Any())
            {
                validationEntries.ForEach(d =>
                {
                    if (result != null)
                    {
                        result += ", ";
                    }

                    result += d.Message;
                });
            }

            model.GetType().GetProperty("IsValid").SetValue(input.Target, validationSummary.IsValid);

            return(result);
        }
 public virtual void Update(IBaseModel entity)
 {
     entity.updatedAt = DateTime.Now;
     dbSet.Attach((T)entity);
     _unitOfWork.Db.Entry(entity).State = EntityState.Modified;
     this._unitOfWork.Db.SaveChanges();
 }
Пример #4
0
        public VisualState(IBaseModel model)
        {
            Model = model ?? throw new ArgumentNullException($"{nameof(VisualState)} can not have a null {nameof(IBaseModel)}");

            HookEvents();
            MapProperties();
        }
Пример #5
0
        /// <summary>
        /// EF实体映射业务实体
        /// </summary>
        /// <typeparam name="T">业务实体类型</typeparam>
        /// <param name="entity">EF实体对象</param>
        /// <returns></returns>
        public static T  ToDataObject <T>(this IBaseModel entity) where T : BaseDataObject, new()
        {
            var o = new T();

            AutoMapper.Mapper.DynamicMap(entity, o, entity.GetType(), typeof(T));
            return(o);
        }
Пример #6
0
 public void DeleteTodo(IBaseModel deletedTodo)
 {
     _repository.Remove(deletedTodo);
     _categories = _repository.GetCategories();
     RaisePropertyChanged(() => Categories);
     RaisePropertyChanged(() => FilteredCategories);
 }
Пример #7
0
        public void Animate(
            string animationName,
            Bind pctl,
            IBaseModel model,
            string propertyName,
            object endValue,
            float start,
            float length)
        {
            if (model.GetPropertyByName(propertyName).GetType().Equals(typeof(int)))
            {
                KineticPath path = new KineticPath(
                    (int)pctl.Get(),
                    (int)endValue,
                    length);

                PropertyAnimation anim = new PropertyAnimation(animationName, path.ComputeFrame, pctl);
                anim.Start = GetCurrentGameTime() + start;
                anim.End   = GetCurrentGameTime() + length + start;
                AddAnimation(animationName, anim);
            }
            else
            {
                throw new NotImplementedException("Only integers can be animated now!!!");
            }
        }
Пример #8
0
        public IEnumerable <PropertyDescriptor> GetPrimaryKeyProperties(IBaseModel entity)
        {
            var propertySet = entity.GetProperties();

            if (propertySet == null)
            {
                yield break;
            }

            foreach (var key in propertySet.Keys)
            {
                var propertyInfo = propertySet[key] as PropertyDescriptor;
                if (propertyInfo == null)
                {
                    continue;
                }

                var propertyValue = propertyInfo.GetValue(entity);
                if (propertyValue == null)
                {
                    continue;
                }

                var dataFieldAttribute = propertyInfo.Attributes[typeof(DataFieldAttribute)] as DataFieldAttribute;
                if (!dataFieldAttribute.PrimaryKey)
                {
                    continue;
                }

                yield return(propertyInfo);
            }
        }
Пример #9
0
        public static EGUID Create(this EGUID eguid, IBaseModel model, TableDefinitionAttribute tableDefinition, IEmpresa empresa = null)
        {
            #if !IsPAF
            //-------------------------------------------------------------------------
            // Se o EGUID já foi informado, descartar as condições abaixo.
            // Isso pode dar erros nas importações se for modificado.
            // Pode dar erros nas integrações entre DAV/PV
            // Pode dar erros em todos os lugares que usam a condição EGUID = ??
            // Modifique a condição abaixo apenas se souber o que está fazendo
            //-------------------------------------------------------------------------
              //  if(!eguid.IsNullOrEmpty())
            //    return eguid;
            #endif
            EGUID result = EGUID.Empty;

            string tableName = tableDefinition.TableName;

            if (model is Model.Faturamento.Lancamento.Movimento.NFCe.INFCe && eguid.IsNullOrEmpty())
                tableName = "fat_LanMovNFCe";
            else if (model is Model.Faturamento.Lancamento.Movimento.NFe.INFe && eguid.IsNullOrEmpty())
                tableName = "fat_LanMovNFe";

            IConfiguracaoEGUID conf = new ConfiguracaoEGUID(tableName);
            switch(conf.UsoEGUID)
            {
                case Enuns.Configuracao.UsoEGUID.Custom:

                    if(conf.Code.StartsWith("code={", StringComparison.CurrentCultureIgnoreCase))
                    {
                        string s = conf.Code.Substring(6);
                        s = "public object GetEGUID(object value){" + s.Substring(0, s.Length - 1) + "}";
                        Assembly assembly = Compiler.Compiler.Compile(Code.Builder.Build("OpenPOS", "OpenPOSEGUIDConfiguracao", s));
                        result = Compiler.Compiler.Invoke("OpenPOS.OpenPOSEGUIDConfiguracao", "GetEGUID", assembly, new object[] { eguid }).ToString();
                    }
                    break;

                case Enuns.Configuracao.UsoEGUID.PorEmpresa:
                    //TODO: Aqui temos que melhorar, pois temos que filtrar pela empresa atual, e
                    // Se não encontrada deve-se criar um para a empresa atual.
                    conf.Numero += 1;
                    result = conf.Numero.ToString();
                    break;
                case Enuns.Configuracao.UsoEGUID.PorTabela:
                    conf.Numero += 1;
                    result = conf.Numero.ToString();
                    break;
                case Enuns.Configuracao.UsoEGUID.Default:
                default:
                    result = eguid.IsNullOrEmpty() ? new Random().Next().ToString() : Convert.ToString(eguid);
                    break;
            }

            if(!String.IsNullOrEmpty(conf.Mascara))
                result = conf.Numero.ToString(conf.Mascara);

            conf.Save();

            return result;
        }
Пример #10
0
        public void Update(IBaseModel model)
        {
            ICity city = (ICity)model;

            this.Id         = city.Id;
            this.CitName    = city.CitName;
            this.CitCountry = city.CitCountry;
        }
Пример #11
0
        public VisualState(IBaseModel model)
        {
			if (model == null)
				throw new ArgumentNullException($"{nameof(VisualState)} can not have a null {nameof(IBaseModel)}");

            Model = model;
            HookEvents();
        }
        /// <summary>
        /// Renders the bread crumbs.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="breadCrumbs">The bread crumbs.</param>
        private static void RenderBreadCrumbs(IBaseModel model, IEnumerable <KeyValuePair <string, string> > breadCrumbs)
        {
            List <BreadCrumb> crumbs = breadCrumbs.Select(keyValuePair => new BreadCrumb {
                Text = keyValuePair.Key, Href = keyValuePair.Value
            }).ToList();

            model.BreadCrumbs = crumbs;
        }
Пример #13
0
        public void Update(IBaseModel model)
        {
            IFloor floor = (IFloor)model;

            this.Id        = floor.Id;
            this.FloorName = floor.FloorName;
            this.HallId    = floor.HallId;
        }
        /// <summary>
        /// Adds the user data to view.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="breadCrumbs">The bread crumbs.</param>
        private static void AddUserDataToView(object model, IEnumerable <KeyValuePair <string, string> > breadCrumbs)
        {
            IBaseModel baseInterface = model as IBaseModel;

            if (baseInterface != null)
            {
                RenderBreadCrumbs(baseInterface, breadCrumbs);
            }
        }
Пример #15
0
 public TypePresenter(IBaseModel <CType> model, IItemView <CType> view)
 {
     this.model = model;
     this.view  = view;
     model.Reload();
     view.ItemList = model.ItemList;
     view.Refresh += view_Refresh;
     view.Save    += view_Save;
 }
Пример #16
0
 public void Remove(IBaseModel removedItem)
 {
     using (var context = new ToDoContext())
     {
         var deletedEntity = _mapper.Map <TodoItems>(removedItem);
         context.Remove(deletedEntity);
         context.SaveChanges();
     }
 }
Пример #17
0
        /// <summary>
        /// Retorna o primeiro TableDefinitionAttribute encontrado no modelo
        /// </summary>
        /// <param name="model">Modelo para pesquisar o TableDefinitionAttribute</param>
        /// <param name="first">Se true, retorna o nome da primeira tabela na hierarquia das classes</param>
        /// <returns></returns>
        internal static TableDefinitionAttribute FindTableDefinition(IBaseModel model, bool first)
        {
            var q = (from m in Utilities.DbUtils.GetModels(model).OrderByDescending(o => o.Order)
                     where m.Type.GetCustomAttributes(typeof(TableDefinitionAttribute), false).Count() > 0
                     select m.Type.GetCustomAttributes(typeof(TableDefinitionAttribute), false)[0]
                     as TableDefinitionAttribute);

            return(first ? q.First() : q.Last());
        }
Пример #18
0
        public void Update(IBaseModel model)
        {
            IHall hall = (IHall)model;

            this.Id           = hall.Id;
            this.HalName      = hall.HalName;
            this.HalSitscount = hall.HalSitscount;
            this.CinemaId     = hall.CinemaId;
        }
Пример #19
0
 public CommandFactory(Connection connection,
                       Transaction transaction,
                       Type currentType,
                       IBaseModel model)
 {
     this.connection  = connection;
     this.currentType = currentType;
     this.model       = model;
     this.transaction = transaction;
 }
Пример #20
0
        public VisualState(IBaseModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException($"{nameof(VisualState)} can not have a null {nameof(IBaseModel)}");
            }

            Model = model;
            HookEvents();
        }
Пример #21
0
        public void Update(IBaseModel model)
        {
            ICinema cinema = (ICinema)model;

            this.Id         = cinema.Id;
            this.CityId     = cinema.CityId;
            this.CinName    = cinema.CinName;
            this.CinAddress = cinema.CinAddress;
            this.CinIcon    = cinema.CinIcon;
        }
Пример #22
0
        public void Update(IBaseModel model)
        {
            IShow show = (IShow)model;

            this.Id           = show.Id;
            this.ShwName      = show.ShwName;
            this.ShwDesc      = show.ShwDesc;
            this.ShwPerformer = show.ShwPerformer;
            this.ShwIcon      = show.ShwIcon;
        }
Пример #23
0
 public MaterialPresenter(IBaseModel <CMaterial> model, IItemView <CMaterial> view)
 {
     this.model = model;
     this.view  = view;
     model.Reload();
     view.ItemList = model.ItemList;
     view.Refresh += view_Refresh;
     view.Save    += view_Save;
     view.Delete  += view_Delete;
     view.Add     += view_Add;
 }
Пример #24
0
        /// <summary>
        /// Инициализация.
        /// </summary>
        /// <param name="view">Представление.</param>
        /// <param name="model">Модель.</param>
        public void Init(IDirectoryTransportsView view, IBaseModel <Transport> model)
        {
            _view  = view;
            _model = model;

            _view.Save       += Save_Handler;
            _view.Update     += Update_Handler;
            _view.Delete     += Delete_Handler;
            _view.GetAll     += GetAll_Handler;
            _view.ViewClosed += ViewClosed_Handler;
        }
        /// <summary>
        /// Инициализация.
        /// </summary>
        /// <param name="view">Представление.</param>
        /// <param name="model">Модель.</param>
        public void Init(IDirectoryOrganizationsView view, IBaseModel <Organization> model)
        {
            _view  = view;
            _model = model;

            _view.Save       += Save_Handler;
            _view.Update     += Update_Handler;
            _view.Delete     += Delete_Handler;
            _view.GetAll     += GetAll_Handler;
            _view.ViewClosed += ViewClosed_Handler;
        }
        public DirectoryDirectionsView(IDirectoryDirectionsPresenter presenter, IBaseModel <Direction> model, Direction direction)
            : this()
        {
            _presenter = presenter;
            _model     = model;

            _presenter.Init(this, _model);

            SetValues(direction);

            _isEdit = true;
        }
Пример #27
0
        public void Update(IBaseModel model)
        {
            ISeat seat = (ISeat)model;

            this.Id         = seat.Id;
            this.SeatColumn = seat.SeatColumn;
            this.SeatNum    = seat.SeatNum;
            this.SeatRow    = seat.SeatRow;
            this.IsActive   = seat.IsActive;
            this.SeatType   = seat.SeatType;
            this.FloorId    = seat.FloorId;
        }
Пример #28
0
        protected void SetModel(IBaseModel model, params string[] properties)
        {
            if (model == null)
                throw new ArgumentNullException("model", "Parameter can't be null.");

            this.properties = new List<string>();
            if (properties != null)
                this.properties.AddRange(properties);

            this.model = model;
            model.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);
        }
Пример #29
0
 public CommandFactory(Connection connection,
                       Transaction transaction,
                       Type currentType,
                       IBaseModel model,
                       ForeignKeys foreignKeys)
 {
     this.connection  = connection;
     this.currentType = currentType;
     this.model       = model;
     this.transaction = transaction;
     this.foreignKeys = foreignKeys;
 }
Пример #30
0
        public virtual object Insert(IBaseModel entity)
        {
            DateTime dt = DateTime.Now;

            entity.createdAt = dt;
            entity.updatedAt = dt;

            dynamic obj = dbSet.Add((T)entity);

            this._unitOfWork.Db.SaveChanges();
            return(obj);
        }
Пример #31
0
        public void Update(IBaseModel model)
        {
            IScheduler scheduler = (IScheduler)model;

            this.Id          = scheduler.SchId;
            this.SchName     = scheduler.SchName;
            this.SchDescr    = scheduler.SchDescr;
            this.SchTimeFrom = scheduler.SchTimeFrom;
            this.SchTimeTo   = scheduler.SchTimeTo;
            this.HallId      = scheduler.HallId;
            this.ShowId      = scheduler.ShowId;
        }
Пример #32
0
        public override int Save(IBaseModel businessModel)
        {
            var model = businessModel as IPositionModel;

            if (model == null)
            {
                throw new Exception(MessageModelNull);
            }
            var entity = PopulateModelToNewEntity(model);

            Entities.AddToPositions(entity);
            return(Entities.SaveChanges());
        }
Пример #33
0
 protected virtual void BindDataSource <T>() where T : IBaseModel
 {
     if (Dirty)
     {
         var resultBtn = MessageForm.Ask(this, Resources.title_information, Resources.dirty_form);
         if (resultBtn == DialogResult.No)
         {
             return;
         }
     }
     CurrentModel = LoadModel <T>();
     Dirty        = false;
 }
Пример #34
0
        public void SearchComplete(IBaseModel item)
        {
            if (item == null)
                return;

            AMR_MST04Model model = new AMR_MST04Model();
            model = (AMR_MST04Model)item;

            CurrentData = item;

            if( model.Name.Equals("Tab1") )
                tab1.DataBinding(this.CurrentData);
            else
                tab2.DataBinding(this.CurrentData);
        }
Пример #35
0
 /// <summary>
 /// Converte um modelo no tipo de arquivo esperado
 /// </summary>
 /// <param name="tipo">tipo de arquivo qualquer</param>
 /// <param name="model">modelo esperado</param>
 /// <returns></returns>
 public static TipoArquivo ModelToEnum(this TipoArquivo tipo, IBaseModel model)
 {
     if(model is Model.Arquivo.Registro.IRegistro01)
         return TipoArquivo.MapaResumo;
     else if (model is Model.Cadastro.Item.Produto.IProdutoArvore)
         return TipoArquivo.ArvoreProduto;
     else if (model is Model.Cadastro.Pessoa.ICliente)
         return TipoArquivo.Cliente;
     else if (model is Model.Cadastro.Pessoa.IContador)
         return TipoArquivo.Contador;
     else if (model is Model.Faturamento.Lancamento.Movimento.VendaCF.IVendaCF)
         return TipoArquivo.CupomFiscal;
     else if (model is Model.Faturamento.Lancamento.Movimento.DAV.IDAV)
         return TipoArquivo.DAV;
     else if (model is Model.Cadastro.Pessoa.IEmpresa)
         return TipoArquivo.Empresa;
     else if (model is Model.Cadastro.Pessoa.IFabricante)
         return TipoArquivo.Fabricante;
     else if (model is Model.Cadastro.IFormaPagamento)
         return TipoArquivo.FormaPagamento;
     else if (model is Model.Cadastro.Item.IGrupoItem)
         return TipoArquivo.GrupoItem;
     else if (model is Model.FrenteCaixa.Cadastro.IPDV)
         return TipoArquivo.PDV;
     else if (model is Model.Faturamento.Lancamento.Movimento.PreVenda.IPreVenda)
         return TipoArquivo.PreVenda;
     else if (model is Model.Cadastro.Item.Produto.IProduto)
         return TipoArquivo.Produto;
     else if (model is Model.Cadastro.TabelaPreco.ITabelaPreco)
         return TipoArquivo.TabelaPreco;
     else if (model is Model.Cadastro.IUnidade)
         return TipoArquivo.UnidadeMedida;
     else if (model is Model.Cadastro.Pessoa.IUsuario)
         return TipoArquivo.Usuario;
     else if (model is Model.Cadastro.Pessoa.IVendedor)
         return TipoArquivo.Vendedor;
     else if (model is Model.Cadastro.Pessoa.IFornecedor)
         return TipoArquivo.Fornecedor;
     else if (model is OpenPOS.Model.Faturamento.Lancamento.Cancelamento.ICancelamento)
         return TipoArquivo.Cancelamento;
     else if (model is Model.Financeiro.Lancamento.IContaReceber ||
             model is Model.Financeiro.Lancamento.IContaPagar ||
             model is Model.Financeiro.Lancamento.ILancamento ||
             model is Model.FrenteCaixa.Lancamento.IContaCorrenteCaixa)
         return TipoArquivo.NaoDefinido;
     else
         throw new NotImplementedException("Tipo não implementado. Tipo: " + model == null ? "null" : Unimake.Convert.ToString(model.GetType()));
 }
Пример #36
0
        public void DataBinding(IBaseModel datalist)
        {
            if (datalist == null) return;
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate() { this.DataBinding(datalist); });
            }
            else
            {
                AMR_MST04Model model = new AMR_MST04Model();

                model = (AMR_MST04Model)datalist;
                gridControl1.DataSource = null;
                gridControl1.DataSource = model.DataTable;
                //bindingSource1.DataSource = datalist;

            }
        }
Пример #37
0
        /// <summary>
        /// Retorna o nome do arquivo montado pelo código informado na tag "GetFileName"
        /// </summary>
        /// <param name="code">Código que será compilado para recuperar o nome do arquivo</param>
        /// <param name="model">Modelo que será passado como parâmetro para recuperar o nome do arquivo</param>
        /// <param name="additionalParams">Parâmetros adicionais que será passado ao método</param>
        /// <returns>Nome do arquivo</returns>
        private string GetFileName(string code, IBaseModel model, params object[] additionalParams)
        {
            string result = "";

            code = "public string GetFileName(object value, params object[] additionalParams){" + code + "}";
            //definir o código que deverá ser executado
            Code codeB = Code.Builder.Build("OpenPOS.CodeDom.ETL", "ETLRuntimeClass", code);
            Assembly assembly = Compiler.Compiler.Compile(codeB);
            object createdObj = assembly.CreateInstance("OpenPOS.CodeDom.ETL.ETLRuntimeClass");
            MethodInfo mi = createdObj.GetType().GetMethod("GetFileName");
            object r = mi.Invoke(createdObj, new object[] { model, additionalParams });

            if(r != null)
                result = r.ToString();

            return result;
        }
Пример #38
0
        public void DataBinding(IBaseModel datalist)
        {
            if (datalist == null) return;
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate() { this.DataBinding(datalist); });
            }
            else
            {
                AMR_MST04Model model = new AMR_MST04Model();

                model = (AMR_MST04Model)datalist;
                //gridControl1.DataSource = null;
                //gridControl1.DataSource = model.DataTable;

                this.chartControl1.Series[0].Points.BeginUpdate();
                this.chartControl1.Series[0].Points.Clear();

                foreach (DataRow row in model.DataTable.Rows)
                {
                    string time = row["TOT00DAT"].ToString();
                    // 그래프 Y값 추출
                    DateTime datetime = DateTime.ParseExact(time, "yyyy-MM-dd HH", null);

                    // 센서 값 넣기
                    //double value = Convert.ToDouble(row.ItemArray[1]);
                    double value = Convert.ToDouble(row["TOT00VALUE"]);
                    //double[] value = new double[] { Convert.ToDouble(row.ItemArray[1]), Convert.ToDouble(row.ItemArray[2]), 
                    //                            Convert.ToDouble(row.ItemArray[3]), Convert.ToDouble(row.ItemArray[4]), Convert.ToDouble(row.ItemArray[5]) };


                    // 센서별 데이터 넣기
                    ChartVariable2 chartValue = new ChartVariable2();
                    chartValue.data = new SeriesPoint(datetime, value);
                    this.chartControl1.Series[0].Points.Add(chartValue.data);
                }

                this.chartControl1.Series[0].Points.EndUpdate();

                this.chartControl1.Titles.RemoveAt(0);
                ChartTitle chartTitle1 = new ChartTitle();
                chartTitle1.Text = string.Format("{0}동 {1}호 - {2}", model.MST04DON, model.MST04HNO, this.radioGroup1.Text);
                chartTitle1.Alignment = System.Drawing.StringAlignment.Center;
                chartTitle1.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Top;
                this.chartControl1.Titles.Add(chartTitle1);

            //    ChartTitle chartTitle1 = new ChartTitle();
            //    ChartTitle chartTitle2 = new ChartTitle();
            //    chartTitle1.Text = "Great Lakes Gross State Product";
            //    chartTitle2.Alignment = System.Drawing.StringAlignment.Far;
            //    chartTitle2.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Bottom;
            //    chartTitle2.Font = new System.Drawing.Font("Tahoma", 8F);
            //    chartTitle2.Text = "From www.bea.gov";
            //    chartTitle2.TextColor = System.Drawing.Color.Gray;
            //    this.chartControl1.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] {
            //chartTitle1,
            //chartTitle2});
            }
        }
Пример #39
0
        public void DataBinding(IBaseModel datalist)
        {
            if (datalist == null) return;
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker)delegate() { this.DataBinding(datalist); });
            }
            else
            {

            }

        }
Пример #40
0
 /// <summary>
 /// 그리드뷰 바인딩
 /// </summary>
 /// <param name="loadItem"></param>
 public void LoadComplete(IBaseModel loadItem)
 {
     CurrentData = loadItem;
     bindingSource1.DataSource = CurrentData;
 }
Пример #41
0
        public void ReadingComplete(IBaseModel item)
        {
            if (item == null)
                return;

            AMR_MST04Model model = new AMR_MST04Model();
            model = (AMR_MST04Model)item;

            CurrentData = item;

            this.DataBinding(CurrentData);
            //if (model.Name.Equals("Tab1"))
            //    tab1.DataBinding(this.CurrentData);
            //else
            //    tab2.DataBinding(this.CurrentData);
        }