예제 #1
0
 /// <summary>
 /// Maps a set of types to their respective DataAccessors.
 /// </summary>
 /// <param name="types">The types to map</param>
 /// <returns>A list of DataAccessors that have a 1 to 1 correspondence to the given
 /// types.</returns>
 public static DataAccessor[] MapTypesToDataAccessors(Type[] types) {
     DataAccessor[] accessors = new DataAccessor[types.Length];
     for (int i = 0; i < types.Length; ++i) {
         accessors[i] = new DataAccessor(types[i]);
     }
     return accessors;
 }
        public static async Task<MEntity> CreateMEntityWithSomeNEntites()
        {
            var mEntity = new MEntity
            {
                Name = "MEntityWithSomeNEntities " + DateTime.Now,
                ObjectState = EObjectState.Added
            };

            var firstNEntity = new NEntity
            {
                Name = "FirstRelatedNEntity " + DateTime.Now,

                ObjectState = EObjectState.Added
            };

            var secondNEntitiy = new NEntity
            {
                Name = "SecondRelatedNEntity " + DateTime.Now,
                ObjectState = EObjectState.Added
            };

            mEntity.NEntities.Add(firstNEntity);
            mEntity.NEntities.Add(secondNEntitiy);

            using (IDataAccessor dataAccessor = new DataAccessor(DbContextFactory))
            {
                dataAccessor.InsertOrUpdate(mEntity);
                await dataAccessor.SaveChangesAsync();
            }
            return mEntity;
        }
        public IEnumerable<RegistroC170> GetRegistrosC170(string codChaveNotaFiscal)
        {
            try
            {

                if (regC170Accessor == null)
                {
                    regC170Accessor =
                        UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsFiscalRepository.GetSelectRegistrosC170(),
                        new FilterByCdEmpresaPkNotaFisParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder<RegistroC170>.MapAllProperties()
                        .DoNotMap(p => p.NUM_ITEM)
                        .Build());
                }

                List<RegistroC170> resultado = regC170Accessor.Execute(
                    UndTrabalho.CodigoEmpresa,
                    codChaveNotaFiscal).ToList();
                int numeroItem = 0;
                foreach (RegistroC170 regC170 in resultado)
                    regC170.NUM_ITEM = ++numeroItem;
                return resultado;
            }
            catch (Exception)
            {
                throw;
            }
        }
        public SimulatedLdapProfileStore(Database database)
        {
            this.accessor = database.CreateSprocAccessor<ProfileStoreData>("aexpense_ProfileStore_GetProfileFromUser");
            this.retryPolicy = RetryPolicyFactory.GetRetryPolicy<SqlDatabaseTransientErrorDetectionStrategy>();

            AExpenseEvents.Log.ProfileStoreInitialized();
        }
예제 #5
0
        public async Task UpdateMEntityAddNewNEntity()
        {
            const string newNEntityName = "UpdateMEntityAddNewNEntity - newNEntity";
            var mEntity = await DatabaseInitializeHelper.CreateSimpleMEntity();

            var newNEntity = new NEntity
            {
                Name = newNEntityName,
                ObjectState = EObjectState.Added
            };

            mEntity.NEntities.Add(newNEntity);
            mEntity.ObjectState = EObjectState.Modified;

            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                dataAccessor.InsertOrUpdate(mEntity);
                Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!");
                await dataAccessor.SaveChangesAsync();
                Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!");
            }

            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                var loadedMEntity = await dataAccessor.GetSingleAsync<MEntity>(mE => mE.Id.Equals(mEntity.Id), mE => mE.NEntities);
                Assert.AreEqual(1, loadedMEntity.NEntities.Count);
                Assert.AreEqual(newNEntityName, loadedMEntity.NEntities.First().Name);
            }
        }
예제 #6
0
        public async Task DeleteSimpleEntity()
        {
            var mEntity = await DatabaseInitializeHelper.CreateSimpleMEntity();
            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                //Sicherstellen, dass die MEntity auch in der DB bekannt ist.
                Assert.IsTrue(await dataAccessor.Set<MEntity>().AnyAsync(mE => mE.Id.Equals(mEntity.Id)));
            }



            //Neuen DataAccessor holen, damit die Operation nicht durch LocalCache verfälscht wird
            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                dataAccessor.Delete(mEntity);
                Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!");
                await dataAccessor.SaveChangesAsync();
                Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!");
            }


            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                //Sicherstellen, dass die MEntity auch in der DB bekannt ist.
                Assert.IsFalse(await dataAccessor.Set<MEntity>().AnyAsync(mE => mE.Id.Equals(mEntity.Id)));
            }

        }
        private void OnDataAdded(AddedDataEvent addedData) {
            var accessor = new DataAccessor(addedData.AddedDataType);

            DataRenderer renderer;
            if (DataRegistry.TryGetRenderer(accessor, out renderer)) {
                SparseArray<DataRenderer> renderers = GetRenderers(addedData.Entity);
                renderer.Initialize(addedData.Entity);
                renderers[accessor.Id] = renderer;
            }
        }
예제 #8
0
 public IEnumerable<Empresa> ListAll()
 {
     if (empresaAccessor == null)
     {
         empresaAccessor = UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
           SqlExpressionsRepository.GetSelectListAllEmpresas(),
           MapBuilder<Empresa>.MapAllProperties().Build());
     }
         
     return empresaAccessor.Execute();
 }
 public RegistroI075 GetRegistroI075(string codigoHistorico)
 {
     if (this.regI075Accessor == null)
     {
         this.regI075Accessor =
             UndTrabalho.DBArquivoSpedContabil.CreateSqlStringAccessor(
               SqlExpressionsContabilRepository.GetSelectRegistroI075(),
               new FilterByCdHistParameterMapper(UndTrabalho.DBArquivoSpedContabil),
               MapBuilder<RegistroI075>.MapAllProperties().Build());
     }
     return this.regI075Accessor.Execute(codigoHistorico).FirstOrDefault();
 }
예제 #10
0
			public /*[a]*/override/*[/a]*/ string /*[a]*/GetSqlText/*[/a]*/(DataAccessor accessor, DbManager dbManager)
			{
				switch (dbManager.DataProvider.Name)
				{
					case "Sql"   :
					case "Access": return SqlText;
					case "Oracle": return OracleText ?? SqlText;
					case "Fdp"   : return FbText     ?? SqlText;
					case "SQLite": return SQLiteText ?? SqlText;
				}

				throw new ApplicationException(string.Format("Unknown data provider '{0}'", dbManager.DataProvider.Name));
			}
        private void OnDataRemoved(RemovedDataEvent removedData) {
            SparseArray<DataRenderer> renderers;
            if (_renderers.TryGetValue(removedData.Entity.UniqueId, out renderers)) {
                var accessor = new DataAccessor(removedData.RemovedDataType);

                if (renderers.ContainsKey(accessor.Id)) {
                    DataRenderer renderer = renderers[accessor.Id];
                    renderers.Remove(accessor.Id);

                    renderer.Dispose();
                }
            }
        }
예제 #12
0
        public void Initialize(ContentEntitySerializationFormat format, IEventDispatcher eventDispatcher) {
            _eventDispatcher = eventDispatcher;
            _uniqueId = format.UniqueId;
            PrettyName = format.PrettyName ?? "";

            foreach (ContentEntity.DataInstance data in format.Data) {
                DataAccessor accessor = new DataAccessor(data.CurrentData);

                if (data.WasAdded) {
                    _toAddStage1.Add(data.CurrentData);
                }

                else {
                    if (data.CurrentData is Data.NonVersioned) {
                        _data[accessor.Id] = new NonVersionedDataContainer(
                            (Data.NonVersioned)data.CurrentData);
                    }

                    else {
                        _data[accessor.Id] = new VersionedDataContainer(
                            (Data.IVersioned)data.PreviousData,
                            (Data.IVersioned)data.CurrentData,
                            (Data.IVersioned)data.CurrentData.Duplicate());
                    }

                    // There is going to be an ApplyModification call before systems actually view
                    // this Entity instance. With that in mind, we can treat our data initialization
                    // as if if were operating on the previous frame.

                    if (data.WasModified) {
                        // This is kind of an ugly hack, because to get the correct Previous/Current
                        // data we need to move Previous into Current so that Previous will reflect
                        // the true Previous value, not the Current one.

                        // Internal signal that a modification is going to take place
                        Modify(accessor);

                        if (data.CurrentData is Data.IVersioned) {
                            // Move Previous into Current, so that after the ApplyModification we
                            // have the correct data values
                            var container = (VersionedDataContainer)_data[accessor.Id];
                            container.Current.CopyFrom(container.Previous);
                        }
                    }

                    if (data.WasRemoved) {
                        RemoveData(accessor);
                    }
                }
            }
        }
예제 #13
0
 public IEnumerable<Registro0220> GetRegistros0220(string codigoProduto)
 {
     if (this.reg0220Accessor == null)
     {
         this.reg0220Accessor =
             UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
               SqlExpressionsFiscalRepository.GetSelectRegistro0220(),
               new FilterByCdEmpresaCdProdParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
               MapBuilder<Registro0220>.MapAllProperties()
               .Build());
     }
     return this.reg0220Accessor.Execute(
         UndTrabalho.CodigoEmpresa, codigoProduto).ToList();
 }
예제 #14
0
 public Registro0150 GetRegistro0150(string codigoParticipante)
 {
     if (this.reg0150Accessor == null)
     {
         this.reg0150Accessor =
             UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
               SqlExpressionsFiscalRepository.GetSelectRegistro0150(),
               new FilterByCdCliforParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
               MapBuilder<Registro0150>.MapAllProperties()
               .Map(p => p.END).ToColumn("ENDERECO")
               .Build());
     }
     return this.reg0150Accessor.Execute(codigoParticipante).FirstOrDefault();
 }
예제 #15
0
 public Registro0200 GetRegistro0200(string codigoProduto)
 {
     if (this.reg0200Accessor == null)
     {
         this.reg0200Accessor =
             UndTrabalho.DBOrigemDadosContmatic.CreateSqlStringAccessor(
               SqlExpressionsContmaticRepository.GetSelectRegistro0200(),
               new FilterByCdEmpresaCdProdParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
               MapBuilder<Registro0200>.MapAllProperties()
               .Build());
     }
     return this.reg0200Accessor.Execute(
         UndTrabalho.CodigoEmpresa, codigoProduto).FirstOrDefault();
 }
        public IEnumerable<RegistroD590> GetRegistrosD590(string codNR_SEQNF)
        {
            if (regD590Accessor == null)
            {
                regD590Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistrosD590(),
                    new FilterByCdEmpresaPkNotaFisParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroD590>.MapAllProperties().Build());
            }

            return regD590Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                codNR_SEQNF).ToList();
        }
        public IEnumerable<RegistroH010> GetRegistrosH010(DateTime dataInventario)
        {
            if (regH010Accessor == null)
            {
                regH010Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    "SELECT * FROM SP_SPEDFIS_LORENZON_REGH010(?, ?)",
                    new FilterByCdEmpresaDtInveParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroH010>.MapAllProperties().Build());
            }

            return regH010Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                dataInventario).ToList();
        }
예제 #18
0
        public IEnumerable<RegistroH010> GetRegistrosH010(DateTime dataInventario)
        {
            if (regH010Accessor == null)
            {
                regH010Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistrosH010(),
                    new FilterByCdEmpresaDtInveParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroH010>.MapAllProperties().Build());
            }

            return regH010Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                dataInventario).ToList();
        }
        public static async Task<NEntity> CreateSimpleNEntity()
        {
            var newNEntity = new NEntity
            {
                Name = "Simple NEntity " + DateTime.Now,
                ObjectState = EObjectState.Added
            };

            using (IDataAccessor dataAccessor = new DataAccessor(DbContextFactory))
            {
                dataAccessor.InsertOrUpdate(newNEntity);
                await dataAccessor.SaveChangesAsync();
            }
            return newNEntity;
        }
예제 #20
0
 public Registro0190 GetRegistro0190(string codigoUnidade)
 {
     if (this.reg0190Accessor == null)
     {
         this.reg0190Accessor =
             UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
               SqlExpressionsFiscalRepository.GetSelectRegistro0190(),
               new FilterByCdTpUnidParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
               MapBuilder<Registro0190>.MapNoProperties()
               .Map(p => p.UNID).ToColumn("UNID")
               .Map(p => p.DESCR).ToColumn("DESCR")
               .Build());
     }
     return this.reg0190Accessor.Execute(codigoUnidade).FirstOrDefault();
 }
        public IEnumerable<RegistroC120> GetRegistrosC120(string codChaveNotaFiscal, string codEmp)
        {
            if (regC120Accessor == null)
            {
                regC120Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsPisCofinsRepository.GetSelectRegistrosC120(),
                        new FilterByCdEmpresaPkNotaFisParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder<RegistroC120>.MapAllProperties().Build());
            }

            return regC120Accessor.Execute(
                codEmp,
                codChaveNotaFiscal).ToList();
        }
예제 #22
0
        public RegistroC410 GetRegistroC410(string codECF, DateTime dtEmissao)
        {
            if (regC410Accessor == null)
            {
                regC410Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistroC410(),
                    new FilterByCdEmpresaPkEcfDiaParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroC410>.MapAllProperties().Build());
            }

            return regC410Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                codECF,
                dtEmissao).FirstOrDefault();
        }
예제 #23
0
        public IEnumerable<RegistroE530> GetRegistrosE530(DateTime dtPeriodoInicial, DateTime dtPeriodoFinal)
        {
            if (regE530Accessor == null)
            {
                regE530Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistrosE530(),
                    new FilterByCdEmpresaDtEmiNfParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroE530>.MapAllProperties().Build());
            }

            return regE530Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                dtPeriodoInicial,
                dtPeriodoFinal).ToList();
        }
예제 #24
0
 public IEnumerable<RegistroI050> GetRegistrosI050(string contaSuperior, int nivelContasFilhas)
 {
     if (regI050Accessor == null)
     {
         regI050Accessor =
             UndTrabalho.DBArquivoSpedContabil.CreateSqlStringAccessor(
             SqlExpressionsContabilRepository.GetSelectRegistrosI050(),
             new FilterByCdEmpresaContaSuperiorNivelParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
             MapBuilder<RegistroI050>.MapAllProperties()
             .Build());
     }
     return regI050Accessor.Execute(
         UndTrabalho.CodigoEmpresa,
         contaSuperior,
         nivelContasFilhas);
 }
예제 #25
0
        public async Task GetEntitiesAsync()
        {
            var mEntity1 = await DatabaseInitializeHelper.CreateMEntityWithSomeNEntites();
            var mEntity2 = await DatabaseInitializeHelper.CreateMEntityWithSomeNEntites();
            var mEntity3 = await DatabaseInitializeHelper.CreateMEntityWithSomeNEntites();

            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                var mEntities = await dataAccessor.GetEntitiesAsync<MEntity>(mE => mE.Id.Equals(mEntity1.Id) || mE.Id.Equals(mEntity2.Id),
                    mE => mE.NEntities);
                Assert.AreEqual(2, mEntities.Count);
                Assert.IsTrue(mEntities.Any(mE => mE.Id.Equals(mEntity1.Id)));
                Assert.IsTrue(mEntities.Any(mE => mE.Id.Equals(mEntity2.Id)));
            }

        }
        public IEnumerable<RegistroI310> GetRegistrosI310(DateTime dataBalancete)
        {
            if (regI310Accessor == null)
            {
                regI310Accessor =
                    UndTrabalho.DBArquivoSpedContabil.CreateSqlStringAccessor(
                      SqlExpressionsContabilRepository.GetSelectRegistrosI310(),
                      new FilterByCdEmpresaDtBcteParameterMapper(UndTrabalho.DBArquivoSpedContabil),
                      MapBuilder<RegistroI310>.MapAllProperties()
                      .Build());
            }

            return regI310Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                dataBalancete);
        }
        public IEnumerable <Registro1105> GetRegistros1105(string numDeclaracaoExportacao)
        {
            if (reg1105Accessor == null)
            {
                reg1105Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsFiscalRepository.GetSelectRegistros1105(),
                        new FilterByCdEmpresaPeriodoDeclExportParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder <Registro1105> .MapAllProperties().Build());
            }

            return(reg1105Accessor.Execute(
                       UndTrabalho.CodigoEmpresa,
                       UndTrabalho.DataInicial,
                       UndTrabalho.DataFinal,
                       numDeclaracaoExportacao));
        }
        public IEnumerable <Registro1210> GetRegistros1210(string codAjusteApuracao)
        {
            if (reg1210Accessor == null)
            {
                reg1210Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsFiscalRepository.GetSelectRegistros1210(),
                        new FilterByCdEmpresaPeriodoCodAjApurParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder <Registro1210> .MapAllProperties().Build());
            }

            return(reg1210Accessor.Execute(
                       UndTrabalho.CodigoEmpresa,
                       UndTrabalho.DataInicial,
                       UndTrabalho.DataFinal,
                       codAjusteApuracao));
        }
예제 #29
0
파일: DRIPage.xaml.cs 프로젝트: Ncf4n1/NuMo
        //for code reuse
        public void setValuesHelper()
        {
            var db = DataAccessor.getDataAccessor();

            calculateSaveNum();

            var calories = calculateCalories();
            var sugar    = calculateSugar(calories);

            //macronutrients
            this.FindByName <Entry>("dri_calories").Text     = calories;
            this.FindByName <Entry>("dri_totalCarbs").Text   = totalCarbs[saveNum];
            this.FindByName <Entry>("dri_sugar").Text        = sugar;
            this.FindByName <Entry>("dri_dietaryFiber").Text = dietaryFiber[saveNum];
            this.FindByName <Entry>("dri_netCarbs").Text     = netCarbs[saveNum];
            this.FindByName <Entry>("dri_protein").Text      = protein[saveNum];

            //vitamins
            this.FindByName <Entry>("dri_vitaminA").Text        = vitaminA[saveNum];
            this.FindByName <Entry>("dri_vitaminC").Text        = vitaminC[saveNum];
            this.FindByName <Entry>("dri_vitaminD").Text        = vitaminD[saveNum];
            this.FindByName <Entry>("dri_vitaminE").Text        = vitaminE[saveNum];
            this.FindByName <Entry>("dri_vitaminK").Text        = vitaminK[saveNum];
            this.FindByName <Entry>("dri_thiamin").Text         = thiamin[saveNum];
            this.FindByName <Entry>("dri_riboflavin").Text      = riboflavin[saveNum];
            this.FindByName <Entry>("dri_niacin").Text          = niacin[saveNum];
            this.FindByName <Entry>("dri_vitaminB6").Text       = vitaminB6[saveNum];
            this.FindByName <Entry>("dri_folate").Text          = folate[saveNum];
            this.FindByName <Entry>("dri_vitaminB12").Text      = vitaminB12[saveNum];
            this.FindByName <Entry>("dri_pantothenicAcid").Text = pantothenicAcid[saveNum];

            //minerals
            this.FindByName <Entry>("dri_calcium").Text    = calcium[saveNum];
            this.FindByName <Entry>("dri_iron").Text       = iron[saveNum];
            this.FindByName <Entry>("dri_magnesium").Text  = magnesium[saveNum];
            this.FindByName <Entry>("dri_phosphorus").Text = phosphorus[saveNum];
            this.FindByName <Entry>("dri_potassium").Text  = potassium[saveNum];
            this.FindByName <Entry>("dri_sodium").Text     = sodium[saveNum];
            this.FindByName <Entry>("dri_zinc").Text       = zinc[saveNum];
            this.FindByName <Entry>("dri_copper").Text     = copper[saveNum];
            this.FindByName <Entry>("dri_manganese").Text  = manganese[saveNum];
            this.FindByName <Entry>("dri_selenium").Text   = selenium[saveNum];

            //save for the nutrient graphs
            saveInfo();
        }
예제 #30
0
        public IEnumerable <RegistroC405> GetRegistrosC405(string codECF)
        {
            if (regC405Accessor == null)
            {
                regC405Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsFiscalRepository.GetSelectRegistrosC405(),
                        new FilterByCdEmpresaPkEcfPeriodoParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder <RegistroC405> .MapAllProperties().Build());
            }

            return(regC405Accessor.Execute(
                       UndTrabalho.CodigoEmpresa,
                       codECF,
                       UndTrabalho.DataInicial,
                       UndTrabalho.DataFinal).ToList());
        }
예제 #31
0
        public Data.IData AddOrModify(DataAccessor accessor)
        {
            if (ContainsData(accessor) == false || WasRemoved(accessor))
            {
                lock (_toAddStage1) {
                    Data.IData added = GetAddedData_unlocked(accessor);
                    if (added == null)
                    {
                        added = AddData_unlocked(accessor);
                    }

                    return(added);
                }
            }

            return(Modify(accessor));
        }
예제 #32
0
        /// <summary>
        /// Attempts to retrieve a data instance with the given DataAccessor from the list of added
        /// data.
        /// </summary>
        /// <param name="accessor">The DataAccessor to lookup</param>
        /// <returns>A data instance, or null if it cannot be found</returns>
        private Data.IData GetAddedData_unlocked(DataAccessor accessor)
        {
            int id = accessor.Id;

            // TODO: optimize this so we don't have to search through all added data... though
            // this should actually be pretty quick
            for (int i = 0; i < _toAddStage1.Count; ++i)
            {
                int addedId = DataAccessorFactory.GetId(_toAddStage1[i].GetType());
                if (addedId == id)
                {
                    return(_toAddStage1[i]);
                }
            }

            return(null);
        }
예제 #33
0
        public void SetOptions()
        {
            MenuOptions.Add("1. Cancel");
            MenuOptions.Add("2. Preview Order");
            MenuOptions.Add("3. Build Your Own");
            var i         = 3;
            var pizzaList = DataAccessor.GetPresetPizzas();

            foreach (var pizzaID in pizzaList)
            {
                i++;
                APizza newPizza = Factory.CreateAPizza();
                newPizza.BuildPizzaFromData(DataAccessor.CreatePresetPizza(pizzaID));
                PizzaList.Add(newPizza);
                MenuOptions.Add($"{i}. {newPizza.Name}");
            }
        }
예제 #34
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.PM.PO.POLine poLine = (UFIDA.U9.PM.PO.POLine)key.GetEntity();

            if (poLine == null)
            {
                return;
            }
            else
            {
                UFIDA.U9.PM.PO.PurchaseOrder po = poLine.PurchaseOrder;
                //委外订单短缺关闭时,若财务未核销(备料单行核销数量<>已发料数量),则不允许关闭
                if (po.Org.Code == "300" && po.SubType.Value.ToString() != "-1" && poLine.Status == PODOCStatusEnum.ClosedShort)
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", po.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_PurchaseOrderAU", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }//end if
            }
        }
예제 #35
0
    public static void _FillDropDown(string qry, string textfield, string valuefield, string defaultsel, string defaultval, DropDownList ddl, params SqlParameter[] arrParam)
    {
        if (defaultsel != "")
        {
            ListItem li = new ListItem(defaultsel, defaultval);
            ddl.Items.Add(li);
        }

        SqlDataReader dr = DataAccessor.ExecuteQueryDataReader(qry, arrParam);

        while (dr.Read())
        {
            ListItem li1 = new ListItem(dr[textfield].ToString(), dr[valuefield].ToString());
            ddl.Items.Add(li1);
        }
        dr.Close();
    }
예제 #36
0
        //
        public void setupdata()
        {
            var loaded = DataAccessor.load();

            if (!loaded.res)
            {
                return;
            }

            var res = Items.Where(x => x.Name.Value == loaded.data.ProcessName).ToList();

            if (res.Count != 0)
            {
                SelectedItem.Value = res[0];
            }
            PathOfScreencapture.Value = loaded.data.FolderPath;
        }
예제 #37
0
    private void populateGroupGrid()
    {
        string strQry = @"
	    select * from leadmaster
	    inner join BlockLeadUser
	    on BlockLeadUser.LeadID  = leadmaster. LeadID  where  BlockLeadUser.UserID = @UserID  "    ;

        strQry += "order by BlockLeadUser.DateCreated desc";

        SqlParameter[] param = new SqlParameter[1];
        param[0]       = new SqlParameter("@UserID", SqlDbType.NVarChar, 150);
        param[0].Value = Session["UserID"].ToString();
        DataTable dt = DataAccessor.ExecuteQueryDataTable(strQry, param);

        rptUsers.DataSource = dt;
        rptUsers.DataBind();
    }
        private void OnDataRemoved(RemovedDataEvent removedData)
        {
            SparseArray <DataRenderer> renderers;

            if (_renderers.TryGetValue(removedData.Entity.UniqueId, out renderers))
            {
                var accessor = new DataAccessor(removedData.RemovedDataType);

                if (renderers.ContainsKey(accessor.Id))
                {
                    DataRenderer renderer = renderers[accessor.Id];
                    renderers.Remove(accessor.Id);

                    renderer.Dispose();
                }
            }
        }
예제 #39
0
        public void ResultsAreReturnedWhenExecutingAsyncStoredProcAccessorInValidStoredProc()
        {
            Database            db       = new DatabaseProviderFactory(base.ConfigurationSource).Create("DefaultSqlAsync");
            DataAccessor <Test> accessor = db.CreateSprocAccessor <Test>("GetTestData1");
            AsyncCallback       cb       = new AsyncCallback(EndExecuteAccessor <Test>);
            DbAsyncState        state    = new DbAsyncState(db, accessor);
            IAsyncResult        result   = accessor.BeginExecute(cb, state);

            state.AutoResetEvent.WaitOne(new TimeSpan(0, 0, 15));
            IEnumerable <Test> resultSet = (IEnumerable <Test>)state.State;

            if (state.Exception != null)
            {
                Console.WriteLine(state.Exception.ToString());
            }
            Assert.IsInstanceOfType(state.Exception, typeof(SqlException));
        }
        public IEnumerable <RegistroC500> GetRegistrosC500(string codCNPJ)
        {
            if (regC500Accessor == null)
            {
                regC500Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                        SqlExpressionsPisCofinsRepository.GetSelectRegistrosC500(),
                        new FilterByCdEmpresaCdCNPJDtEmiNfParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                        MapBuilder <RegistroC500> .MapAllProperties().Build());
            }

            return(regC500Accessor.Execute(
                       UndTrabalho.CodigoEmpresa,
                       codCNPJ,
                       UndTrabalho.DataInicial,
                       UndTrabalho.DataFinal).ToList());
        }
예제 #41
0
    public static string GetCompanyTerms()
    {
        string strCompanyTerms = string.Empty;

        string strQry = "SELECT CompanyTermsConditions FROM Settings";

        SqlDataReader drEmails = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drEmails.Read())
        {
            strCompanyTerms = GetWebsiteURL() + "/images/" + drEmails["CompanyTermsConditions"].ToString();
        }

        drEmails.Close();

        return(strCompanyTerms);
    }
        public IEnumerable<RegistroA100> GetRegistrosA100(string codCNPJ, string codEmp)
        {
            if (regA100Accessor == null)
            {
                regA100Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsPisCofinsRepository.GetSelectRegistrosA100(),
                    new FilterByCdEmpresaCdCNPJDtEmiNfParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroA100>.MapAllProperties().Build());
            }

            return regA100Accessor.Execute(
                codEmp,
                codCNPJ,
                UndTrabalho.DataInicial,
                UndTrabalho.DataFinal).ToList();
        }
        public void ResultsAreReturnedWhenExecutingAsyncStoredProcAccessor()
        {
            Database db = new DatabaseProviderFactory(base.ConfigurationSource).Create("DefaultSqlAsync");
            DataAccessor <TopTenProduct> accessor = db.CreateSprocAccessor <TopTenProduct>("Ten Most Expensive Products");
            AsyncCallback cb     = new AsyncCallback(EndExecuteAccessor <TopTenProduct>);
            DbAsyncState  state  = new DbAsyncState(db, accessor);
            IAsyncResult  result = accessor.BeginExecute(cb, state);

            state.AutoResetEvent.WaitOne(new TimeSpan(0, 0, 15));
            IEnumerable <TopTenProduct> resultSet = (IEnumerable <TopTenProduct>)state.State;

            object[] paramsArray = { };
            DataSet  ds          = db.ExecuteDataSet("Ten Most Expensive Products", paramsArray);

            Assert.IsNull(state.Exception);
            Assert.AreEqual <int>(ds.Tables[0].Rows.Count, resultSet.Count());
        }
예제 #44
0
        public IEnumerable<RegistroC405> GetRegistrosC405(string codECF)
        {
            if (regC405Accessor == null)
            {
                regC405Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistrosC405(),
                    new FilterByCdEmpresaPkEcfPeriodoParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<RegistroC405>.MapAllProperties().Build());
            }

            return regC405Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                codECF,
                UndTrabalho.DataInicial,
                UndTrabalho.DataFinal).ToList();
        }
예제 #45
0
        async void AddVisualize(object sender, EventArgs args)
        {
            var db = DataAccessor.getDataAccessor();

            /* check to see if the DRI values are blank. Blank values means no profile is setup
             * No DRI values will make the visualization crash and the app will crash too
             * to prevent app crashing a pop up box is displayed telling the user to create a profile
             */

            if (db.getDRIValue(db.GetDRINames()[0]) == "")
            {
                Empty_profile_error();
                return;  // return is used to keep the screen from navigating to the visualize page.
            }

            await Navigation.PushAsync(new VisualizePage());  // waits for the visualize page button to be pushed
        }
예제 #46
0
    public static string GetPageTitle()
    {
        string PageTitle = string.Empty;

        string strQry = "SELECT PageTitle FROM Settings";

        SqlDataReader drPageTitle = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drPageTitle.Read())
        {
            PageTitle = drPageTitle["PageTitle"].ToString();
        }

        drPageTitle.Close();

        return(PageTitle);
    }
예제 #47
0
        [HttpGet("Random/{quantity}")] //Returns a list of the chosen quantity.
        public List <Movie> RandomMovie(int quantity)
        {
            Random       rand      = new Random();
            List <Movie> movieLib  = DataAccessor.GetAllMovies();
            List <Movie> randomLib = new List <Movie>();
            int          count     = movieLib.Count();

            for (int i = 0; i < quantity; i++)
            {
                int   shuffle = rand.Next(0, count);
                Movie movie   = movieLib[shuffle];
                movieLib.Remove(movie);
                randomLib.Add(movie);
                count--;
            }
            return(randomLib);
        }
예제 #48
0
    public static string GetWebsiteURL()
    {
        string strCompanyTerms = string.Empty;

        string strQry = "SELECT WebsiteURL FROM Settings";

        SqlDataReader drEmails = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drEmails.Read())
        {
            strCompanyTerms = drEmails["WebsiteURL"].ToString();
        }

        drEmails.Close();

        return(strCompanyTerms);
    }
예제 #49
0
    public static string GetDefaultCurrencyID()
    {
        string strCurrencyID = string.Empty;

        string strQry = "SELECT CurrencyID FROM CurrencyMaster WHERE IsDefault = 1";

        SqlDataReader drEmails = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drEmails.Read())
        {
            strCurrencyID = drEmails["CurrencyID"].ToString();
        }

        drEmails.Close();

        return(strCurrencyID);
    }
예제 #50
0
    public static string GetCompanyPhone()
    {
        string strCompanyPhone = string.Empty;

        string strQry = "SELECT CompanyPhone FROM Settings";

        SqlDataReader drEmails = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drEmails.Read())
        {
            strCompanyPhone = drEmails["CompanyPhone"].ToString();
        }

        drEmails.Close();

        return(strCompanyPhone);
    }
예제 #51
0
        public IActionResult UpdateAnswer(int answer_id, string answer_detail, string update)
        {
            Answer a = DataAccessor.GetAnswer(answer_id);

            if (update == "Delete")
            {
                long q_id = a.question_id;
                DataAccessor.DeleteAnswer(answer_id);
                return(RedirectToAction("Detail", "DevHub", new { id = q_id }));
            }
            else
            {
                a.detail = answer_detail;
                DataAccessor.SaveAnswer(a);
                return(RedirectToAction("Detail", "DevHub", new { id = a.question_id }));
            }
        }
        public IEnumerable<Registro1105> GetRegistros1105(string numDeclaracaoExportacao)
        {
            if (reg1105Accessor == null)
            {
                reg1105Accessor =
                    UndTrabalho.DBArquivoSpedFiscal.CreateSqlStringAccessor(
                    SqlExpressionsFiscalRepository.GetSelectRegistros1105(),
                    new FilterByCdEmpresaPeriodoDeclExportParameterMapper(UndTrabalho.DBArquivoSpedFiscal),
                    MapBuilder<Registro1105>.MapAllProperties().Build());
            }

            return reg1105Accessor.Execute(
                UndTrabalho.CodigoEmpresa,
                UndTrabalho.DataInicial,
                UndTrabalho.DataFinal,
                numDeclaracaoExportacao);
        }
예제 #53
0
        private static void Main(string[] args)
        {
            DataAccessor.SetDefaultConfiguration();
            ExtendedConsole.Initialize();

            PrintAvailableCommands();

            while (!_exited)
            {
                if (ExtendedConsole.TryReadCommand(out ConsoleCommand command))
                {
                    ExtendedConsole.ExecuteCommand(command);
                }
            }

            Console.WriteLine("The program has successfully completed its work");
        }
        public void Test1()
        {
            var accessor = new DataAccessor();

            accessor.Define <Dto>()
            .Map(x => x.Id, cfg => cfg.DeltaCoded());

            using (var stream = new MemoryStream())
            {
                using (var writer = accessor.CreateWriter <Dto>(stream))
                {
                    writer.Write(new Dto {
                        Id = 1
                    });
                }
            }
        }
예제 #55
0
    public static string GetCompanyLogo2()
    {
        string strCompanyLogo = string.Empty;

        string strQry = "SELECT CompanyLogo2 FROM Settings";

        SqlDataReader drEmails = DataAccessor.ExecuteQueryDataReader(strQry, null);

        while (drEmails.Read())
        {
            strCompanyLogo = "images/" + drEmails["CompanyLogo2"].ToString();
        }

        drEmails.Close();

        return(strCompanyLogo);
    }
예제 #56
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.MO.Issue.IssueDoc issueDoc = (UFIDA.U9.MO.Issue.IssueDoc)key.GetEntity();
            if (issueDoc == null)
            {
                return;
            }
            else
            {
                if (issueDoc.Org.Code == "300")
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("DocNo", issueDoc.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("BeforeConfirmDate", "", ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("ConfirmDate", "", ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_MoIssueDoc", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "1")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
예제 #57
0
        public IList <CardInfo> SearchByCondition(Hashtable theHashtable, DataAccessor theDataAccessor, int Size, int BeginSize, string strOrderBy, ref SystemMessageInfo theSystemMessageInfo)
        {
            SystemMessage     _objSystemMessage     = new SystemMessage();
            SystemMessageInfo _objSystemMessageInfo = new SystemMessageInfo();

            IList <CardInfo> objIListCardTypeInfo = new List <CardInfo>();
            XmlDocument      objXmlDocument       = Helper.FormatConvert.HashtableToXml(theHashtable);

            DataSet objDataSet = new DataSet();

            try
            {
                string[] strReturnXml = ServiceWrapper.Current.SelectCardInfoByCondition(objXmlDocument.OuterXml, Size, BeginSize, strOrderBy);

                CurrentUser.Current.TotalCount = Int32.Parse(strReturnXml[0].ToString());

                objDataSet = Helper.FormatConvert.XmlToDataSet(strReturnXml[1]);
                try
                {
                    if (objDataSet.Tables.Count > 0)
                    {
                        foreach (DataRow objDataRow in objDataSet.Tables[0].Rows)
                        {
                            CardInfo objCardTypeInfo = GetInfoFromDataRow(objDataRow);
                            objIListCardTypeInfo.Add(objCardTypeInfo);
                        }
                    }
                }
                catch (Exception e)
                {
                    _objSystemMessageInfo           = _objSystemMessage.GetInfoByCode("WebServiceParseToInfoFail");
                    _objSystemMessageInfo.Success   = false;
                    _objSystemMessageInfo.Exception = e.Message;
                }
            }
            catch (Exception e)
            {
                _objSystemMessageInfo           = _objSystemMessage.GetInfoByCode("WebServiceConnectFail");
                _objSystemMessageInfo.Success   = false;
                _objSystemMessageInfo.Exception = e.Message;
            }

            theSystemMessageInfo = _objSystemMessageInfo;
            return(objIListCardTypeInfo);
        }
예제 #58
0
        public async Task InsertMEntityWithSomeNEntities()
        {
            const string mEntityName = "InsertMEntityWithSomeNEntities - Parent MEntity";
            const string firstNEntityName = "InsertMEntityWithSomeNEntities - First NEntity";
            const string secondNEntityName = "InsertMEntityWithSomeNEntities - Second NEntity";

            var mEntity = new MEntity
            {
                Name = mEntityName,
                ObjectState = EObjectState.Added
            };

            var firstNEntity = new NEntity
            {
                Name = firstNEntityName,
                ObjectState = EObjectState.Added
            };

            var secondNEntitiy = new NEntity
            {
                Name = secondNEntityName,
                ObjectState = EObjectState.Added
            };

            mEntity.NEntities.Add(firstNEntity);
            mEntity.NEntities.Add(secondNEntitiy);

            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                dataAccessor.InsertOrUpdate(mEntity);
                Assert.IsTrue(dataAccessor.HasPendingChanges, "HasPendingChanges should be true!");
                await dataAccessor.SaveChangesAsync();
                Assert.IsFalse(dataAccessor.HasPendingChanges, "HasPendingChanges should be false directly after Saving!");
            }

            using (IDataAccessor dataAccessor = new DataAccessor(_dbContextFactory))
            {
                Assert.IsTrue(await dataAccessor.Set<MEntity>().AnyAsync(mE => mE.Name.EndsWith(mEntityName)));
                var loadedMEntity = await dataAccessor.GetSingleAsync<MEntity>(entity => entity.Name.EndsWith(mEntityName),
                    entity => entity.NEntities);
                Assert.AreEqual(2, loadedMEntity.NEntities.Count);
                Assert.IsTrue(loadedMEntity.NEntities.Any(nE => nE.Name.Equals(secondNEntityName)));
                Assert.IsTrue(loadedMEntity.NEntities.Any(nE => nE.Name.Equals(firstNEntityName)));
            }
        }
예제 #59
0
        public void Notify(params object[] args)
        {
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }

            //将入口参数列表中第一个参数,转成EntityEvent,并取EntityKey存入key
            UFSoft.UBF.Business.BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            //key的有效性判断
            if (key == null)
            {
                return;
            }
            //转成所需实体,同时判断有效性
            UFIDA.U9.SM.SO.SO so = (UFIDA.U9.SM.SO.SO)key.GetEntity();

            if (so == null)
            {
                return;
            }
            else
            {
                if (so.Org.Code == "300" && so.DescFlexField.PrivateDescSeg1.Contains("PO"))
                {
                    try
                    {
                        DataParamList dp = new DataParamList();
                        dp.Add(DataParamFactory.Create("SODocNo", so.DocNo, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.Create("PoDocNo", so.DescFlexField.PrivateDescSeg1, ParameterDirection.Input, DbType.String, 50));
                        dp.Add(DataParamFactory.CreateOutput("Result", DbType.String));
                        DataAccessor.RunSP("sp_Auctus_BE_SOAI", dp);
                        string result = dp["Result"].Value.ToString();
                        if (result != "0")
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public ManualSimulationDialog()
        {
            InitializeComponent();
            _failistObject       = DataAccessor.DeserializeData();
            this.FormBorderStyle = FormBorderStyle.FixedDialog;

            foreach (var item in _failistObject.IdFailureX)
            {
                comboBox1.Items.Add(item);
            }
            foreach (var item in _failistObject.IdPlanes)
            {
                comboBox2.Items.Add(item);
            }
            comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
            comboBox2.SelectedIndexChanged += ComboBox2_SelectedIndexChanged;
            RemoveErrorButton.Click        += RemoveErrorButton_Click;
        }