Пример #1
0
        static SimpleQueryTests()
        {
            repository = new Repository("SimpleQueryTests");
            schema = new Schema(repository, "news");
            schema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = DataType.String,
                Length = 256
            });
            schema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = DataType.Int
            });

            folder = new TextFolder(repository, "news");
            folder.SchemaName = schema.Name;

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(schema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(folder);

            InitializeData();
        }
Пример #2
0
        static CategoriesQueryTests()
        {
            repository = new Repository("CategoriesQueryTests");

            categorySchema = new Schema(repository, "category");
            categorySchema.AddColumn(new Column() { Name = "title", DataType = DataType.String, Length = 256 });

            categoryFolder = new TextFolder(repository, "category") { SchemaName = categorySchema.Name };

            newsSchema = new Schema(repository, "news");
            newsSchema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = DataType.String,
                Length = 256
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = DataType.Int
            });

            newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name, CategoryFolders = new[] { categoryFolder.Name } };

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(categorySchema);
            providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
            providerFactory.GetProvider<ITextFolderProvider>().Add(categoryFolder);
            InitializeData();
        }
Пример #3
0
        public void Render(Layout layout, ProviderFactory loader)
        {
            int resolution = GetValue<int>("resolution");

              var size = layout.GetPageSizeInPixels(resolution);
              var composed = new Image(size.ToDimensions(), ImageBaseType.Rgb);

              if (layout.Render(loader,
            new ImageRenderer(layout, composed, resolution)))
            ;

              // Fix me: check next couple of lines!
            #if false
            DialogState = DialogStateType.SrcImgValid;
              else
            DialogState = DialogStateType.SrcImgInvalid;
            #endif
              if (GetValue<bool>("flatten"))
            {
              composed.Flatten();
            }

              if (GetValue<int>("color_mode") == 0) // ColorMode.GRAY)
            {
              composed.ConvertGrayscale();
            }

              new Display(composed);
              Display.DisplaysFlush();
        }
Пример #4
0
        static SchemaManagerTests()
        {
            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);

        }
Пример #5
0
        static ParentQueryTests()
        {
            repository = new Repository("ParentQueryTests");

            commentSchema = new Schema(repository, "comments");
            commentSchema.AddColumn(new Column() { Name = "title", DataType = Kooboo.Data.DataType.String, Length = 256 });


            newsSchema = new Schema(repository, "news") { ChildSchemas = new[] { commentSchema.Name } };
            newsSchema.AddColumn(new Column()
            {
                Name = "Title",
                DataType = Kooboo.Data.DataType.String,
                Length = 256
            });
            newsSchema.AddColumn(new Column()
            {
                Name = "Comments",
                DataType = Kooboo.Data.DataType.Int
            });

            newsFolder = new TextFolder(repository, "news") { SchemaName = newsSchema.Name };

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<ISchemaProvider>().Add(commentSchema);
            providerFactory.GetProvider<ISchemaProvider>().Add(newsSchema);
            providerFactory.GetProvider<ITextFolderProvider>().Add(newsFolder);
            InitializeData();
        }
Пример #6
0
        static BinaryContentProviderTests()
        {
            repository = new Repository("SimpleQueryTests");

            binaryFolder = new MediaFolder(repository, "image");

            ProviderFactory providerFactory = new ProviderFactory();
            Providers.DefaultProviderFactory = providerFactory;
            providerFactory.GetProvider<IRepositoryProvider>().Add(repository);
            providerFactory.GetProvider<IMediaFolderProvider>().Add(binaryFolder);
        }
        public void CraeteProviderFactoryFact()
        {
            var ns = @"Data";
            var output = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName(), ns);
            ns = string.IsNullOrWhiteSpace(ns) ? "" : string.Format(@".{0}", ns);
            var context = new ProviderFactoryContext
            {
                Namespace = new Namespace(NAMESPACE, ns),
                Imports = new[] {@"System", @"System.Data.Common", @"System.Configuration", @"kkkkkkaaaaaa.Data.Common",},
                TypeName = new TypeName(@"TestProviderFactory"),
                ConnectionStringSectionName = @"db",
                InvariantName = @"USystem.Data.SqlClient",
                OutputPath = output,
            };

            var provider = new ProviderFactory(context);
            provider.CreateFactory();

            TextTemplatingProcess.StartExplorer(context.OutputPath);
        }
Пример #8
0
        public void BasicPropertiesTest()
        {
            ListBox listbox = new ListBox();
            IRawElementProviderSimple provider = ProviderFactory.GetProvider(listbox);

            TestProperty(provider,
                         AutomationElementIdentifiers.ControlTypeProperty,
                         ControlType.List.Id);

            TestProperty(provider,
                         AutomationElementIdentifiers.LocalizedControlTypeProperty,
                         "list");

            TestProperty(provider,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         true);



            //TODO: AutomationElementIdentifiers.BoundingRectangleProperty
            //TODO: AutomationElementIdentifiers.ClickablePointProperty
            //TODO: AutomationElementIdentifiers.IsKeyboardFocusableProperty
            //TODO: AutomationElementIdentifiers.HelpTextProperty
        }
Пример #9
0
        internal IDbConnection OpenConnection(string connectionString)
        {
            IDbConnection connection;

#if !NETSTANDARD
            if (ProviderFactory != null)
            {
                connection = ProviderFactory.CreateConnection();
            }
            else
#endif
            {
                connection = (IDbConnection)Activator.CreateInstance(ConnectionType);
            }

            if (connection == null)
            {
                throw new NLogRuntimeException("Creation of connection failed");
            }

            connection.ConnectionString = connectionString;
            connection.Open();
            return(connection);
        }
Пример #10
0
        /// <summary>
        /// 保存卡片与卡片事件信息(用于停车场产生事件时更新卡片状态并保存事件)
        /// </summary>
        /// <param name="card"></param>
        /// <param name="report"></param>
        /// <returns></returns>
        public CommandResult SaveCardAndEvent(CardInfo card, CardEventReport report)
        {
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            if (card.CardType == CardType.Ticket && report.IsExitEvent)  ////纸票出场后将其删除
            {
                _Provider.Delete(card, unitWork);
            }
            else
            {
                CardInfo info = card.Clone();
                //卡片状态保持用数据库中的状态
                info.ParkingStatus = report.ParkingStatus;
                info.LastDateTime  = report.EventDateTime;
                info.LastEntrance  = report.EntranceID;
                info.LastCarPlate  = report.CarPlate;
                if (report.LimitationRemain != info.LimitationRemain)
                {
                    info.LimitationRemain    = report.LimitationRemain;
                    info.LimitationTimestamp = report.EventDateTime;
                }
                //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空
                if (!report.IsExitEvent)
                {
                    info.ClearPaidData();
                }
                _Provider.Update(info, card, unitWork);
            }
            ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri);

            icp.Insert((new CardEventRecord(report)), unitWork);

            if (report.IsExitEvent && report.Limitation > 0) //出场事件且有限时停车的记录才要记录到上传表中。
            {
                ECardRecord ecr = new ECardRecord()
                {
                    SheetID          = card.SheetID,
                    Carplate         = report.CarPlate,
                    CardID           = report.CardID,
                    EventDt          = report.EventDateTime,
                    EnterDt          = report.LastDateTime,
                    Limitation       = report.Limitation,
                    LimitationRemain = report.LimitationRemain
                };
                IECardRecordProvider iecr = ProviderFactory.Create <IECardRecordProvider>(_RepoUri);
                iecr.Insert(ecr, unitWork);
            }
            CommandResult ret = unitWork.Commit();

            if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态
            {
                //卡片状态保持用数据库中的状态
                card.ParkingStatus    = report.ParkingStatus;
                card.LastDateTime     = report.EventDateTime;
                card.LastEntrance     = report.EntranceID;
                card.LastCarPlate     = report.CarPlate;
                card.LimitationRemain = report.LimitationRemain;
                //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空
                if (!report.IsExitEvent)
                {
                    card.ClearPaidData();
                }
            }
            return(ret);
        }
Пример #11
0
        private static void TestCngKeyDerivation(ProviderFactory factory, byte[] kdk, byte[] label, byte[] contextHeader, byte[] context, int numDerivedBytes, string expectedDerivedSubkeyAsBase64)
        {
            byte[] derivedSubkey = new byte[numDerivedBytes];

            fixed (byte* pbKdk = kdk)
            fixed (byte* pbLabel = label)
            fixed (byte* pbContext = context)
            fixed (byte* pbDerivedSubkey = derivedSubkey)
            {
                ISP800_108_CTR_HMACSHA512Provider provider = factory(pbKdk, (uint)kdk.Length);
                provider.DeriveKeyWithContextHeader(pbLabel, (uint)label.Length, contextHeader, pbContext, (uint)context.Length, pbDerivedSubkey, (uint)derivedSubkey.Length);
            }

            Assert.Equal(expectedDerivedSubkeyAsBase64, Convert.ToBase64String(derivedSubkey));
        }
Пример #12
0
 public SimpleRepository() : this(ProviderFactory.GetProvider(), SimpleRepositoryOptions.Default)
 {
 }
Пример #13
0
 public SimpleRepository(SimpleRepositoryOptions options) : this(ProviderFactory.GetProvider(), options)
 {
 }
Пример #14
0
 public PinjimuDB(string connectionString, string providerName)
 {
     DataProvider = ProviderFactory.GetProvider(connectionString, providerName);
     Init();
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 public Select() : this(ProviderFactory.GetProvider())
 {
 }
 public TestPerformaceDBDB(string connectionString, string providerName)
 {
     DataProvider = ProviderFactory.GetProvider(connectionString, providerName);
     Init();
 }
        private void Can_script_windows(bool whenDatabaseExists)
        {
            ResetDatabase();

            var migrator1 = CreateMigrator <ShopContext_v1>();
            var version1  = new MigrationScaffolder(migrator1.Configuration).Scaffold("Version1");

            CreateMigrator <ShopContext_v1>(scaffoldedMigrations: version1).Update();

            var migrator2 = CreateMigrator <ShopContext_v2>(scaffoldedMigrations: version1);

            var version2 = new MigrationScaffolder(migrator2.Configuration).Scaffold("Version2");

            CreateMigrator <ShopContext_v2>(scaffoldedMigrations: new[] { version1, version2 }).Update();

            var migrator3 = CreateMigrator <ShopContext_v3>(scaffoldedMigrations: new[] { version1, version2 });
            var version3  = new MigrationScaffolder(migrator3.Configuration).Scaffold("Version3");

            var migrator4          = CreateMigrator <ShopContext_v3>(scaffoldedMigrations: new[] { version1, version2, version3 });
            var scriptingDecorator = new MigratorScriptingDecorator(migrator4);

            if (!whenDatabaseExists)
            {
                ResetDatabase();
            }

            // All
            var script = scriptingDecorator.ScriptUpdate(DbMigrator.InitialDatabase, null);

            Assert.True(script.Contains(CreateMetadataStatement));
            Assert.True(script.Contains("Version1"));
            Assert.True(script.Contains("Version2"));
            Assert.True(script.Contains("Version3"));
            Assert.False(script.Contains("AutomaticMigration"));

            if (!whenDatabaseExists ||
                DatabaseProvider == DatabaseProvider.SqlClient)
            {
                using (var connection = ProviderFactory.CreateConnection())
                {
                    connection.ConnectionString = ConnectionString;

                    using (var command = connection.CreateCommand())
                    {
                        connection.Open();

                        foreach (var batch in script.Split(new[] { "GO\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            command.CommandText = batch;
                            command.ExecuteNonQuery();
                        }
                    }
                }
            }

            // 1
            script = scriptingDecorator.ScriptUpdate(DbMigrator.InitialDatabase, version1.MigrationId);

            Assert.True(script.Contains(CreateMetadataStatement));
            Assert.True(script.Contains("Version1"));
            Assert.False(script.Contains("Version2"));
            Assert.False(script.Contains("Version3"));
            Assert.False(script.Contains("AutomaticMigration"));

            // 1 & 2
            script = scriptingDecorator.ScriptUpdate(DbMigrator.InitialDatabase, version2.MigrationId);

            Assert.True(script.Contains(CreateMetadataStatement));
            Assert.True(script.Contains("Version1"));
            Assert.True(script.Contains("Version2"));
            Assert.False(script.Contains("Version3"));
            Assert.False(script.Contains("AutomaticMigration"));
        }
Пример #18
0
        ///// <summary>
        ///// 卡片出内车场费用后的卡片信息(将费用累加到累计停车费用)
        ///// </summary>
        ///// <param name="info">卡片</param>
        ///// <param name="ts">费率</param>
        ///// <param name="carType">车型</param>
        ///// <param name="chargeDateTime">缴费时间</param>
        ///// <returns></returns>
        //private void CardPayNestedParkFee(CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime)
        //{
        //    ParkAccountsInfo parkFee = ts.CalculateCardNestedParkFee(card, carType, chargeDateTime);

        //    ////不产生费用的,不记录缴费时间和累计停车费用,只更新内车场累计停车时间
        //    //if (parkFee.Accounts > 0)
        //    //{
        //    //    card.TotalFee += parkFee.Accounts;
        //    //    card.IsIndoorPaid = true;//更新内车场缴费标识
        //    //    card.PaidDateTime = chargeDateTime;//记录缴费时间
        //    //}

        //    card.TotalFee += parkFee.Accounts;

        //    if (card.IsIndoorPaid && ts.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime))
        //    {
        //        //已缴费,并且处于缴费后免费时间的,不记录缴费时间
        //        //(防止下面这种情况出现:中央收费后设置允许15分钟内可以免费出场,则有些车主在入场后每隔15分钟去刷一次卡交费,
        //        //这样出场时就不会产生费用)
        //    }
        //    else
        //    {
        //        card.PaidDateTime = chargeDateTime;//记录缴费时间
        //    }


        //    card.IsInNestedPark = false ;//出内车场状态
        //    card.IsIndoorPaid = true;//更新内车场缴费标识
        //    card.UpdateIndoorTimeInterval(chargeDateTime);//更新内车场累计停车时间

        //}

        ///// <summary>
        ///// 卡片进入内车场
        ///// </summary>
        ///// <param name="info">卡片</param>
        ///// <param name="enterDateTime">进入时间</param>
        ///// <returns>进行后的卡片信息</returns>
        //private void CardEnterNestedPark(CardInfo info, DateTime enterDateTime)
        //{
        //    info.IsIndoorPaid = false ;//清除内车场缴费标识
        //    info.IsInNestedPark = true;
        //    info.IndoorInDateTime = enterDateTime;
        //}
        #endregion

        #region 公共方法
        ///// <summary>
        ///// 更新卡片写卡模式的相关数据(包括卡格式版本、室内停车场的进入时间、
        ///// 室内停车场累计停车时间、缴费时间、当前车场已收的停车费用、累计停车费用、停车状态等)
        ///// </summary>
        ///// <param name="info"></param>
        ///// <returns></returns>
        //public CommandResult UpdateOffLineCardData(CardInfo info)
        //{
        //    CardInfo original = _Provider.GetByID(info.CardID).QueryObject;
        //    if (original != null)
        //    {
        //        CardInfo card = original.Clone();
        //        //只更新写卡模式相关的属性
        //        card.CardVersion = info.CardVersion;
        //        card.IndoorInDateTime = info.IndoorInDateTime;
        //        card.IndoorTimeInterval = info.IndoorTimeInterval;
        //        card.PaidDateTime = info.PaidDateTime;
        //        card.ParkFee = info.ParkFee;
        //        card.TotalFee = info.TotalFee;

        //        //收费时需要更停车状态
        //        card.ParkingStatus = info.ParkingStatus;

        //        return _Provider.Update(card, original);
        //    }
        //    return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord));
        //}

        /// <summary>
        /// 删除卡片最近的一条缴费记录
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public CommandResult DeleteLastPayment(CardInfo info)
        {
            if (info.LastPayment != null)
            {
                CardInfo        card        = info.Clone();
                CardPaymentInfo paymentInfo = info.LastPayment;
                //CardPaymentInfo record = null;
                IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
                ICardPaymentRecordProvider recordProvider = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri);

                ////重新设置卡片费用信息
                ////card.TotalFee += paymentInfo.Paid + paymentInfo.Discount;//加上删除的收费费用和折扣

                //if (!string.IsNullOrEmpty(paymentInfo.LastStationID)
                //    || paymentInfo.LastTotalPaid != 0
                //    || paymentInfo.LastTotalDiscount != 0)
                //{
                //    //有上上次的缴费记录
                //    //先查找卡片是否有多条缴费记录
                //    CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition();
                //    con.CardID = card.CardID;
                //    con.EnterDateTime = card.LastDateTime;
                //    List<CardPaymentInfo> records = recordProvider.GetItems(con).QueryObjects;
                //    if (records.Count > 1)//有多条缴费记录
                //    {
                //        records = (from r in records
                //                   orderby r.ChargeDateTime descending
                //                   select r).ToList();
                //        record = records[1];//获取第二近的缴费记录
                //    }

                //}
                //if (record != null)
                //{
                //    //删除的记录的车场停车费用比上一条记录的停车费用多,说明两条记录之间有费用产生
                //    if (paymentInfo.ParkFee > record.ParkFee)
                //    {
                //        //如果两条记录相隔缴费时间内有产生费用,累计费用需要减去产生的费用
                //        card.TotalFee -= paymentInfo.ParkFee - record.ParkFee;
                //        card.ParkFee = record.ParkFee;//重新设置外车场费用
                //    }
                //    card.PaidDateTime = record.ChargeDateTime;//重新设置收费时间
                //    card.IsPaid = true;
                //}
                //else
                //{
                //    //没有上上次的缴费记录
                //    card.TotalFee -= paymentInfo.Accounts;//减去应缴费用
                //    card.TotalFee = card.TotalFee < 0 ? 0 : card.TotalFee;
                //    card.ParkFee = 0;
                //    card.IsPaid = false;//设置为未缴费
                //    card.PaidDateTime = null;
                //}

                //已缴费用减去记录收取的费用和折扣费用
                card.TotalPaidFee -= paymentInfo.Paid + paymentInfo.Discount;
                if (card.TotalPaidFee < 0)
                {
                    card.TotalPaidFee = 0;
                }

                _Provider.Update(card, info, unitWork);

                recordProvider.Delete(paymentInfo);

                CommandResult result = unitWork.Commit();

                if (result.Result == ResultCode.Successful)
                {
                    //删除成功,更新卡片信息
                    //info.ParkingStatus = card.ParkingStatus;
                    //info.TotalFee = card.TotalFee;
                    //info.PaidDateTime = card.PaidDateTime;
                    //info.ParkFee = card.ParkFee;
                    info.TotalPaidFee = card.TotalPaidFee;
                }
                return(result);
            }
            return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)));
        }
Пример #19
0
 public BatchTests()
 {
     provider = ProviderFactory.GetProvider("WestWind");
 }
Пример #20
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="repoUri">存储层的资源标识(可以是数据库连接字符串或文件名等,根据存储层的不同可以设置不同的值)</param>
 public CardBll(string repoUri)
 {
     this._RepoUri  = repoUri;
     this._Provider = ProviderFactory.Create <ICardProvider>(repoUri);
 }
 public Provider6(ProviderFactory pf)
 {
     this.pf = pf;
 }
 public void TestCleanup()
 {
     providerFactory = null;
 }
 public void TestInitialize()
 {
     providerFactory = new ProviderFactory();
 }
Пример #24
0
 internal Provider(Type provider, ProviderBase instance, ProviderFactory factory)
 {
     this.provider = provider;
     this.instance = instance;
     this.factory = factory;
 }
Пример #25
0
        /// <summary>
        /// 通过查询条件获取相应的卡片删除记录
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public QueryResultList <CardDeleteRecord> GetCardDeleteRecords(RecordSearchCondition search)
        {
            ICardDeleteRecordProvider provider = ProviderFactory.Create <ICardDeleteRecordProvider>(_RepoUri);

            return(provider.GetItems(search));
        }
Пример #26
0
 public void SetUp()
 {
     ProviderFactory.Register <SqlCeBulkInsertProvider>("System.Data.SqlServerCe.SqlCeConnection");
 }
 public override void Setup()
 {
     ProviderFactory.Register <T>(ProviderConnectionType);
     base.Setup();
 }
Пример #28
0
        public static IDataProvider GetProvider(string connection = "DefaultConnection")
        {
            string database = System.Configuration.ConfigurationManager.ConnectionStrings[connection].ToString();

            return(ProviderFactory.GetProvider(database, "MySql.Data.MySqlClient"));
        }
 public TestPerformaceDBDB()
 {
     DataProvider = ProviderFactory.GetProvider("TestDB");
     Init();
 }
Пример #30
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="repoUri">存储层的资源标识(可以是数据库连接字符串或文件名等,根据存储层的不同可以设置不同的值)</param>
 public WorkstationBll(string repoUri)
 {
     provider = ProviderFactory.Create <IWorkstationProvider>(repoUri);
 }
Пример #31
0
 private DomObjectQuery NewObjectQuery(IEnumerable <DomNode> items)
 {
     return(ProviderFactory.CreateObjectQuery(items));
 }
Пример #32
0
        /// <summary>
        /// Data retrieval
        /// </summary>
        /// <returns></returns>
        private DataSet GenerateReturnSet()
        {
            DataSet result = null;

            if (_url != null)
            {
                SqlQuery qry = null;
                //Query q;

                if (!String.IsNullOrEmpty(_url.TableName))
                {
                    qry = new Select().From(_url.TableName);
                    IDataProvider provider = ProviderFactory.GetProvider();
                    ITable        tbl      = provider.FindTable(_url.TableName);

                    if (_url.PrimaryKey != null)
                    {
                        qry = qry.Where(tbl.PrimaryKey.Name).IsEqualTo(_url.PrimaryKey);
                    }
                    //q.WHERE(q.Schema.PrimaryKey.ParameterName, _url.PrimaryKey);

                    if (_url.Parameters != null)
                    {
                        IDictionaryEnumerator loopy = _url.Parameters.GetEnumerator();
                        IColumn column;

                        string paramName;
                        object paramValue;

                        while (loopy.MoveNext())
                        {
                            paramName  = loopy.Key.ToString();
                            paramValue = loopy.Value;

                            int pageSize  = 0;
                            int pageIndex = -1;

                            if (paramName.ToLowerInvariant() == "pagesize" || paramName.ToLowerInvariant() == "pageindex")
                            {
                                if (paramName.ToLowerInvariant() == "pagesize")
                                {
                                    pageSize = int.Parse(paramValue.ToString());
                                }

                                if (paramName.ToLowerInvariant() == "pageindex")
                                {
                                    pageIndex = int.Parse(paramValue.ToString());
                                }

                                if (pageSize > 0 && pageIndex > -1)
                                {
                                    qry.Paged(pageIndex + 1, pageSize);
                                }
                            }
                            else
                            {
                                Comparison comp;
                                EvalComparison(paramName, out paramName, out comp);
                                column = tbl.GetColumn(paramName);

                                //if this column is a string, by default do a fuzzy search
                                if (comp == Comparison.Like || column.IsString)
                                {
                                    comp       = Comparison.Like;
                                    paramValue = String.Concat("%", paramValue, "%");
                                    qry        = qry.Where(column.Name).Like(paramValue.ToString());
                                }
                                else if (paramValue.ToString().ToLower() == "null")
                                {
                                    qry = qry.Where(column.Name).IsNull();
                                }

                                //q.WHERE(column.ColumnName, comp, paramValue);
                            }
                        }
                    }

                    result = provider.ExecuteDataSet(qry.GetCommand());
                }
                else if (!String.IsNullOrEmpty(_url.SpName))
                {
                    StoredProcedure sp = new StoredProcedure(_url.SpName);

                    if (_url.Parameters != null)
                    {
                        IDictionaryEnumerator loopy = _url.Parameters.GetEnumerator();
                        while (loopy.MoveNext())
                        {
                            sp.Command.AddParameter(loopy.Key.ToString(), loopy.Value, DbType.AnsiString);
                        }
                    }
                    result = sp.ExecuteDataSet();
                }
            }
            return(result);
        }
Пример #33
0
 public PinjimuDB()
 {
     DataProvider = ProviderFactory.GetProvider("DataConnectionString");
     Init();
 }
Пример #34
0
 public BatchQuery() : this(ProviderFactory.GetProvider())
 {
 }
Пример #35
0
 protected override IRawElementProviderSimple GetProvider()
 {
     return(ProviderFactory.GetProvider(item));
 }
Пример #36
0
        protected SisoDatabase(ISisoConnectionInfo connectionInfo, IDbProviderFactory dbProviderFactory)
        {
            Ensure.That(connectionInfo, "connectionInfo").IsNotNull();
            Ensure.That(dbProviderFactory, "dbProviderFactory").IsNotNull();

            _lockObject       = new object();
            _connectionInfo   = connectionInfo;
            _providerFactory  = dbProviderFactory;
            Settings          = ProviderFactory.GetSettings();
            ServerClient      = ProviderFactory.GetServerClient(ConnectionInfo);
            StructureSchemas  = new StructureSchemas(new StructureTypeFactory(), new AutoStructureSchemaBuilder());
            Serializer        = new DefaultSisoSerializer();
            StructureBuilders = new StructureBuilders(() => Serializer, schema => ProviderFactory.GetGuidStructureIdGenerator(), (schema, dbClient) => ProviderFactory.GetIdentityStructureIdGenerator(dbClient));
            Maintenance       = new SisoDatabaseMaintenance(this);
            _dbSchemas        = ProviderFactory.GetDbSchemaManagerFor(this);
        }
Пример #37
0
        private Task TriggerReconnectionAttempt()
        {
            if (closed)
            {
                return(Task.CompletedTask);
            }

            return(reconnectControl.ScheduleReconnect(Reconnect));

            async Task Reconnect()
            {
                IProvider provider          = null;
                Exception failure           = null;
                long      reconnectAttempts = reconnectControl.RecordNextAttempt();

                try
                {
                    if (uris.Any())
                    {
                        for (int i = 0; i < uris.Size(); i++)
                        {
                            var target = uris.GetNext();
                            if (target == null)
                            {
                                Tracer.Debug("Failover URI collection unexpectedly modified during connection attempt.");
                                continue;
                            }

                            try
                            {
                                Tracer.Debug($"Connection attempt:[{reconnectAttempts}] to: {target.Scheme}://{target.Host}:{target.Port} in-progress");
                                provider = ProviderFactory.Create(target);
                                await provider.Connect(connectionInfo).Await();
                                await InitializeNewConnection(provider).Await();

                                return;
                            }
                            catch (Exception e)
                            {
                                Tracer.Info($"Connection attempt:[{reconnectAttempts}] to: {target.Scheme}://{target.Host}:{target.Port} failed");
                                failure = e;
                                try
                                {
                                    provider?.Close();
                                }
                                catch
                                {
                                }
                                finally
                                {
                                    provider = null;
                                }
                            }
                        }
                    }
                    else
                    {
                        Tracer.Debug("No remote URI available to connect to in failover list");
                        // TODO Handle this one.
                        failure = new IOException("No remote URI available for reconnection during connection attempt: " + reconnectAttempts);
                    }
                }
                catch (Exception unknownFailure)
                {
                    Tracer.Warn($"Connection attempt:[{reconnectAttempts}] failed abnormally.");
                    failure = failure ?? unknownFailure;
                }
                finally
                {
                    if (provider == null)
                    {
                        Tracer.Debug($"Connection attempt:[{reconnectControl.ReconnectAttempts}] failed error: {failure?.Message}");
                        if (!reconnectControl.IsReconnectAllowed(failure))
                        {
                            ReportReconnectFailure(failure);
                        }
                        else
                        {
                            await reconnectControl.ScheduleReconnect(Reconnect).Await();
                        }
                    }
                }
            }
        }
Пример #38
0
        //****** OPERATIONS
        public override UserProfile GetProfile()
        {
            Token       token    = ConnectionToken;
            UserProfile profile  = new UserProfile(ProviderType);
            string      response = "";

            //If token already has profile for this provider, we can return it to avoid a call
            if (token.Profile.IsSet || !IsProfileSupported)
            {
                return(token.Profile);
            }

            var provider = ProviderFactory.GetProvider(token.Provider);

            if (GetScope().ToLower().Contains("https://www.googleapis.com/auth/userinfo.profile"))
            {
                try
                {
                    logger.Debug("Executing profile feed");
                    Stream responseStream = AuthenticationStrategy.ExecuteFeed(ProfileEndpoint, this, token, TRANSPORT_METHOD.GET).GetResponseStream();
                    response = new StreamReader(responseStream).ReadToEnd();
                }
                catch
                { throw; }

                try
                {
                    JObject profileJson = JObject.Parse(response);
                    //{"entry":{"profileUrl":"https://plus.google.com/103908432244378021535","isViewer":true,"id":"103908432244378021535",
                    //    "name":{"formatted":"deepak Aggarwal","familyName":"Aggarwal","givenName":"deepak"},
                    //    "thumbnailUrl":"http://www.,"urls":[{"value":"https://plus.google.com/103908432244378021535","type":"profile"}],
                    //    "photos":[{"value":"http://www.google.com/ig/c/photos/public/AIbEiAIAAABDCJ_d1payzeKeNiILdmNhcmRfcGhvdG8qKGFjM2RmMzQ1ZDc4Nzg5NmI5NmFjYTc1NDNjOTA3MmQ5MmNmOTYzZWIwAe0HZMa7crOI_laYBG7LxYvlAvqe","type":"thumbnail"}],"displayName":"deepak Aggarwal"}}
                    profile.Provider          = ProviderType;
                    profile.ID                = profileJson.Get("id");
                    profile.Email             = profileJson.Get("email");
                    profile.ProfileURL        = profileJson.Get("link");
                    profile.FirstName         = profileJson.Get("given_name");
                    profile.LastName          = profileJson.Get("family_name");
                    profile.ProfilePictureURL = profileJson.Get("picture");
                    profile.GenderType        = Utility.ParseGender(profileJson.Get("gender"));
                }
                catch (Exception ex)
                {
                    logger.Error(ErrorMessages.ProfileParsingError(response), ex);
                    throw new DataParsingException(response, ex);
                }
            }
            else
            {
                profile.FirstName = token.ResponseCollection["openid.ext1.value.firstname"];
                profile.LastName  = token.ResponseCollection["openid.ext1.value.lastname"];
            }
            if (string.IsNullOrEmpty(profile.Email))
            {
                profile.Email = token.ResponseCollection.Get("openid.ext1.value.email");
            }
            profile.Country  = token.ResponseCollection.Get("openid.ext1.value.country");
            profile.Language = token.ResponseCollection.Get("openid.ext1.value.language");
            profile.IsSet    = true;
            token.Profile    = profile;
            logger.Info("Profile successfully received");

            return(profile);
        }
Пример #39
0
 public SimpleRepository(string connectionStringName, SimpleRepositoryOptions options)
     : this(ProviderFactory.GetProvider(connectionStringName), options)
 {
 }
Пример #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Insert"/> class.
 /// </summary>
 public Insert() : this(ProviderFactory.GetProvider())
 {
 }
Пример #41
0
 public SolutionDataBaseDB(string connectionString, string providerName)
 {
     DataProvider = ProviderFactory.GetProvider(connectionString, providerName);
     Init();
 }
Пример #42
0
 public TestDB(string connection, string provider) : this(ProviderFactory.GetProvider(connection, provider))
 {
 }