• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DbManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DbManager的典型用法代码示例。如果您正苦于以下问题:C# DbManager类的具体用法?C# DbManager怎么用?C# DbManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DbManager类属于命名空间,在下文中一共展示了DbManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetLastDeltaIndexDate

 public static DateTime GetLastDeltaIndexDate(ModuleInfo module)
 {
     using (var db = new DbManager("default"))
     {
         return db.ExecuteScalar<DateTime>(new SqlQuery("webstudio_index").Select("last_modified").Where("index_name", module.Delta));
     }
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:DbProvider.cs


示例2: SaveFeeds

        public static void SaveFeeds(IEnumerable<FeedRow> feeds, string key, DateTime value)
        {
            using (var db = new DbManager(Constants.FeedDbId))
            {
                db.ExecuteNonQuery(new SqlInsert("feed_last", true).InColumnValue("last_key", key).InColumnValue("last_date", value));
            }

            const int feedsPortionSize = 1000;
            var aggregatedDate = DateTime.UtcNow;

            var feedsPortion = new List<FeedRow>();
            foreach (var feed in feeds)
            {
                feedsPortion.Add(feed);
                if (feedsPortion.Sum(f => f.Users.Count) <= feedsPortionSize) continue;

                SaveFeedsPortion(feedsPortion, aggregatedDate);
                feedsPortion.Clear();
            }

            if (feedsPortion.Any())
            {
                SaveFeedsPortion(feedsPortion, aggregatedDate);
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:25,代码来源:FeedAggregateDataProvider.cs


示例3: TestSqlConnection_AddNewBookthenRollback_ReturnBookInitialCount

 private static int TestSqlConnection_AddNewBookthenRollback_ReturnBookInitialCount()
 {
     var dbManager = new DbManager<BooksContext>();
     var before = 0;
     dbManager.Connect(database =>
     {
         try
         {
             TransactionHelper.Begin(() =>
             {
                 before = database.Books.Count();
                 database.Books.Add(new Book
                 {
                     Name = "Test Book",
                     Isbn = "IKS9001F"
                 });
                 database.SaveChanges();
                 throw new Exception("Database offline! please try again later");
             });
         }
         catch (Exception ex)
         {
             throw new CustomException<DatabaseErrorExceptionArgs>(new DatabaseErrorExceptionArgs(ex.Message));
         }
     });
     return before;
 }
开发者ID:francis04j,项目名称:LayeredArchitecture,代码行数:27,代码来源:Transactional_Tests.cs


示例4: GetAll

 public List<Message> GetAll()
 {
     using (var db = new DbManager(DatabaseId))
     {
         return db.ExecuteList(CreateQuery()).ConvertAll(ToMessage);
     }
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:MessageDao.cs


示例5: AddWebDomain

        public WebDomainDto AddWebDomain(string name, bool isVerified, DbManager db)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentNullException("name");

            if (db == null)
                throw new ArgumentNullException("db");

            var domain = GetDomain(name, db);
            if (domain != null)
                throw new DuplicateNameException(String.Format("Domain with name {0}. Already added to tenant {1}.",
                                                               domain.name, domain.tenant));

            var domainAddTime = DateTime.UtcNow.ToDbStyle();

            var addWebDomainQuery = new SqlInsert(DomainTable.name)
                .InColumnValue(DomainTable.Columns.id, 0)
                .InColumnValue(DomainTable.Columns.name, name)
                .InColumnValue(DomainTable.Columns.tenant, tenant)
                .InColumnValue(DomainTable.Columns.is_verified, isVerified)
                .InColumnValue(DomainTable.Columns.date_added, domainAddTime)
                .Identity(0, 0, true);

            var addedDomainId = db.ExecuteScalar<int>(addWebDomainQuery);
            return new WebDomainDto(addedDomainId, name, tenant, isVerified);
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:26,代码来源:WebDomainDal.cs


示例6: GetStatData

        public override List<UsageSpaceStatItem> GetStatData()
        {
            if (!DbRegistry.IsDatabaseRegistered(FileConstant.DatabaseId))
            {
                DbRegistry.RegisterDatabase(FileConstant.DatabaseId, ConfigurationManager.ConnectionStrings[FileConstant.DatabaseId]);
            }

            using (var filedb = new DbManager(FileConstant.DatabaseId))            
            {
                var q = new SqlQuery("files_file f")
                    .Select("b.right_node")
                    .SelectSum("f.content_length")
                    .InnerJoin("files_folder_tree t", Exp.EqColumns("f.folder_id", "t.folder_id"))
                    .InnerJoin("files_bunch_objects b", Exp.EqColumns("t.parent_id", "b.left_node"))
                    .Where("b.tenant_id", TenantProvider.CurrentTenantID)
                    .Where(Exp.Like("b.right_node", "crm/crm_common/", SqlLike.StartWith))
                    .GroupBy(1);

                return filedb.ExecuteList(q)
                    .Select(r => new UsageSpaceStatItem
                        {

                            Name = Resources.CRMCommonResource.ProductName,
                            SpaceUsage = Convert.ToInt64(r[1]),
                            Url = VirtualPathUtility.ToAbsolute(PathProvider.StartURL())
                        })
                    .ToList();
            }        
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:29,代码来源:CRMsSpaceUsageStatManager.cs


示例7: GetTenants

        public List<Tenant> GetTenants()
        {
            var result = new List<Tenant>();
            var tenants = CoreContext.TenantManager.GetTenants();

            if (useUserActivity && last != DateTime.MinValue)
            {
                using (var db = new DbManager(dbid))
                {
                    var ids = db
                        .ExecuteList(new SqlQuery("webstudio_useractivity").Select("tenantid").Where(Exp.Ge("ActivityDate", last.AddMinutes(-1))).GroupBy(1))
                        .ConvertAll(r => (int)r[0]);
                    result.AddRange(tenants.FindAll(t => ids.Contains(t.TenantId)));

                    ids = db
                        .ExecuteList(new SqlQuery("files_file").Select("tenant_id").Where(Exp.Ge("modified_on", last.AddMinutes(-1))).GroupBy(1))
                        .ConvertAll(r => (int)r[0]);
                    result.AddRange(tenants.FindAll(t => ids.Contains(t.TenantId)));
                }
            }
            else
            {
                result.AddRange(tenants);
            }
            last = DateTime.UtcNow;

            result.RemoveAll(t => t.Status != TenantStatus.Active);
            return result;
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:29,代码来源:TenantsProvider.cs


示例8: GetByFilter

        public List<TimeSpend> GetByFilter(TaskFilter filter, bool isAdmin, bool checkAccess)
        {
            var query = CreateQuery();

            if (filter.Max != 0 && !filter.Max.Equals(int.MaxValue))
            {
                query.SetFirstResult((int)filter.Offset);
                query.SetMaxResults((int)filter.Max * 2);
            }

            if (!string.IsNullOrEmpty(filter.SortBy))
            {
                var sortColumns = filter.SortColumns["TimeSpend"];
                sortColumns.Remove(filter.SortBy);

                query.OrderBy("t." + filter.SortBy, filter.SortOrder);

                foreach (var sort in sortColumns.Keys)
                {
                    query.OrderBy("t." + sort, sortColumns[sort]);
                }
            }

            query = CreateQueryFilter(query, filter, isAdmin, checkAccess);

            using (var db = new DbManager(DatabaseId))
            {
                return db.ExecuteList(query).ConvertAll(ToTimeSpend);
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:30,代码来源:TimeSpendDao.cs


示例9: GetSubtasks

 public List<Subtask> GetSubtasks(int taskid)
 {
     using (var db = new DbManager(DatabaseId))
     {
         return db.ExecuteList(CreateQuery().Where("task_id", taskid)).ConvertAll(ToSubTask);
     }
 }
开发者ID:vlslavik,项目名称:teamlab.v7.5,代码行数:7,代码来源:SubtaskDao.cs


示例10: GetStatData

        public override List<UsageSpaceStatItem> GetStatData()
        {
            using (var filedb = new DbManager(FileConstant.DatabaseId))
            using (var projdb = new DbManager(PROJECTS_DBID))
            {
                var q = new SqlQuery("files_file f")
                    .Select("b.right_node")
                    .SelectSum("f.content_length")
                    .InnerJoin("files_folder_tree t", Exp.EqColumns("f.folder_id", "t.folder_id"))
                    .InnerJoin("files_bunch_objects b", Exp.EqColumns("t.parent_id", "b.left_node"))
                    .Where("b.tenant_id", TenantProvider.CurrentTenantID)
                    .Where(Exp.Like("b.right_node", "projects/project/", SqlLike.StartWith))
                    .GroupBy(1);

                var sizes = filedb.ExecuteList(q)
                    .Select(r => new {ProjectId = Convert.ToInt32(((string) r[0]).Substring(17)), Size = Convert.ToInt64(r[1])})
                    .GroupBy(r => r.ProjectId)
                    .ToDictionary(g => g.Key, g => g.Sum(a => a.Size));

                q = new SqlQuery("projects_projects")
                    .Select("id", "title")
                    .Where("tenant_id", TenantProvider.CurrentTenantID)
                    .Where(Exp.In("id", sizes.Keys));

                return projdb.ExecuteList(q)
                    .Select(r => new UsageSpaceStatItem
                        {
                            Name = Convert.ToString(r[1]),
                            SpaceUsage = sizes[Convert.ToInt32(r[0])],
                            Url = String.Concat(PathProvider.BaseAbsolutePath, "projects.aspx?prjID=" + Convert.ToInt32(r[0]))
                        })
                    .OrderByDescending(i => i.SpaceUsage)
                    .ToList();
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:35,代码来源:ProjectsSpaceUsageStatManager.cs


示例11: CreateFreeDnsRecords

        public DnsDto CreateFreeDnsRecords(string dkimSelector, string domainCheckerPrefix, 
            string spf, DbManager db = null)
        {
            if (string.IsNullOrEmpty(dkimSelector))
                throw new ArgumentNullException("dkimSelector");

            if (string.IsNullOrEmpty(domainCheckerPrefix))
                throw new ArgumentNullException("domainCheckerPrefix");

            if (string.IsNullOrEmpty(spf))
                throw new ArgumentNullException("spf");

            string privateKey, publicKey;
            DnsChecker.DnsChecker.GenerateKeys(out privateKey, out publicKey);

            var domainCheckValue = PasswordGenerator.GenerateNewPassword(16);
            var domainCheck = domainCheckerPrefix + ": " + domainCheckValue;

            var insertValuesQuery = new SqlInsert(DnsTable.name)
                .InColumnValue(AddressTable.Columns.id, 0)
                .InColumnValue(DnsTable.Columns.user, _user)
                .InColumnValue(DnsTable.Columns.tenant, _tenant)
                .InColumnValue(DnsTable.Columns.dkim_selector, dkimSelector)
                .InColumnValue(DnsTable.Columns.dkim_private_key, privateKey)
                .InColumnValue(DnsTable.Columns.dkim_public_key, publicKey)
                .InColumnValue(DnsTable.Columns.domain_check, domainCheck)
                .InColumnValue(DnsTable.Columns.spf, spf)
                .Identity(0, 0, true);

            var dnsRecordId = NullSafeExecuteScalar<int>(db, insertValuesQuery);
            return new DnsDto(dnsRecordId, _tenant, _user, Defines.UNUSED_DNS_SETTING_DOMAIN_ID, dkimSelector, 
                privateKey, publicKey, domainCheck, spf);
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:33,代码来源:DnsDal.cs


示例12: AccountController

 public AccountController()
 {
     _dbManager = new DbManager();
     _repository = new Repository();
     var store = new UserStore<ApplicationUser>(_dbManager);
     _userManager = new UserManager<ApplicationUser>(store);
 }
开发者ID:nditz,项目名称:TMS-WEB,代码行数:7,代码来源:AccountController.cs


示例13: GetStatData

        public override List<SpaceUsageStatManager.UsageSpaceStatItem> GetStatData()
        {
            var data = new List<SpaceUsageStatManager.UsageSpaceStatItem>();
            
            if (!DbRegistry.IsDatabaseRegistered(FILES_DBID)) DbRegistry.RegisterDatabase(FILES_DBID, ConfigurationManager.ConnectionStrings[FILES_DBID]);
            using (var filedb = new DbManager(FILES_DBID))            
            {
                var q = new SqlQuery("files_file f")
                    .Select("b.right_node")
                    .SelectSum("f.content_length")
                    .InnerJoin("files_folder_tree t", Exp.EqColumns("f.folder_id", "t.folder_id"))
                    .InnerJoin("files_bunch_objects b", Exp.EqColumns("t.parent_id", "b.left_node"))
                    .Where("b.tenant_id", CoreContext.TenantManager.GetCurrentTenant().TenantId)
                    .Where(Exp.Like("b.right_node", "crm/crm_common/", SqlLike.StartWith))
                    .GroupBy(1);

                var size = filedb.ExecuteList(q).Select(r =>  Convert.ToInt64(r[1])).FirstOrDefault();
                
                
                    data.Add(new UsageSpaceStatItem()
                    {
                         
                        Name = Resources.CRMCommonResource.ProductName,
                        SpaceUsage = size,
                        Url = VirtualPathUtility.ToAbsolute(PathProvider.StartURL())
                    });
            }        

            return data;
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:30,代码来源:CRMsSpaceUsageStatManager.cs


示例14: Search

 public static IEnumerable<int> Search(ModuleInfo module)
 {
     using (var db = new DbManager(TextIndexCfg.ConnectionStringName))
     {
         return db.ExecuteList(module.SqlQuery).ConvertAll(r => GetId(r[0]));
     }
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:DbProvider.cs


示例15: DbDao

        protected DbDao(DbManager db, int tenant)
        {
            if (db == null) throw new ArgumentNullException("db");

            this.db = db;
            Tenant = tenant;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:7,代码来源:DbDao.cs


示例16: DBResourceReader

        public DBResourceReader(string fileName, CultureInfo culture)
        {
            language = culture.Name;
            Data = new Hashtable();

            if (language == "")
                language = "Neutral";

            using (var dbManager = new DbManager("tmresource"))
            {
                var sql = new SqlQuery("res_data")
                    .Select("res_data.title", "textValue")
                    .InnerJoin("res_files", Exp.EqColumns("res_files.id", "res_data.fileID"))
                    .LeftOuterJoin("res_cultures", Exp.EqColumns("res_cultures.title", "res_data.cultureTitle"))
                    .Where("ResName", fileName)
                    .Where("res_cultures.Title", language);

                var list = dbManager.ExecuteList(sql);

                foreach (var t in list)
                {
                    Data.Add(t[0], t[1]);
                }
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:25,代码来源:DBResourceReader.cs


示例17: GetIPGeolocation

 public IPGeolocationInfo GetIPGeolocation(string ip)
 {
     try
     {
         var ipformatted = FormatIP(ip);
         using (var db = new DbManager(dbid))
         {
             var q = new SqlQuery("dbip_location")
                 .Select("ip_start", "ip_end", "country", "city", "timezone_offset", "timezone_name")
                 .Where(Exp.Le("ip_start", ipformatted))
                 .OrderBy("ip_start", false)
                 .SetMaxResults(1);
             return db
                 .ExecuteList(q)
                 .Select(r => new IPGeolocationInfo()
                 {
                     IPStart = Convert.ToString(r[0]),
                     IPEnd = Convert.ToString(r[1]),
                     Key = Convert.ToString(r[2]),
                     City = Convert.ToString(r[3]),
                     TimezoneOffset = Convert.ToDouble(r[4]),
                     TimezoneName = Convert.ToString(r[5])
                 })
                 .SingleOrDefault(i => ipformatted.CompareTo(i.IPEnd) <= 0) ??
                 IPGeolocationInfo.Default;
         }
     }
     catch (Exception error)
     {
         log.Error(error);
     }
     return IPGeolocationInfo.Default;
 }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:33,代码来源:GeolocationHelper.cs


示例18: AddLoginEvent

        private static void AddLoginEvent(EventMessage message)
        {
            using (var db = new DbManager(messagesDbId))
            {
                var i = new SqlInsert(loginEventsTable)
                    .InColumnValue("ip", message.IP)
                    .InColumnValue("login", message.Initiator)
                    .InColumnValue("browser", message.Browser)
                    .InColumnValue("mobile", message.Mobile)
                    .InColumnValue("platform", message.Platform)
                    .InColumnValue("date", message.Date)
                    .InColumnValue("tenant_id", message.TenantId)
                    .InColumnValue("user_id", message.UserId)
                    .InColumnValue("page", message.Page)
                    .InColumnValue("action", message.Action);

                if (message.Description != null && message.Description.Any())
                {
                    i = i.InColumnValue("description", JsonConvert.SerializeObject(message.Description, new JsonSerializerSettings
                        {
                            DateTimeZoneHandling = DateTimeZoneHandling.Utc
                        }));
                }

                db.ExecuteNonQuery(i);
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:27,代码来源:MessagesRepository.cs


示例19: GetTemplate

 public ReportTemplate GetTemplate(int id)
 {
     using (var db = new DbManager(DatabaseId))
     {
         return db.ExecuteList(Query(ReportTable).Select(columns).Where("id", id)).ConvertAll(ToTemplate).SingleOrDefault();
     }
 }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:7,代码来源:ReportDao.cs


示例20: PanelDbManager

        public PanelDbManager(IHost host, PluginParameter data)
        {
			_host = host;
			_shellData = (Shell)data[0];
			_shellSqlConn = GetShellSqlConn();

			// init StrRes to translate string
			StrRes.SetHost(_host);
            Init();			

            //绑定事件
			_dbManager = new DbManager(_host, _shellData, _shellSqlConn.type);
			_dbManager.ConnectDbCompletedToDo += DbManagerConnectDbCompletedToDo;
			_dbManager.GetDbNameCompletedToDo += DbManagerGetDbNameCompletedToDo;
			_dbManager.GetDbTableNameCompletedToDo += DbManagerGetTableNameCompletedToDo;
			_dbManager.GetColumnTypeCompletedToDo += DbManagerGetColumnTypeCompletedToDo;
			_dbManager.ExecuteReaderCompletedToDo += DbManagerExecuteReaderCompletedToDo;
			_dbManager.ExecuteNonQueryCompletedToDo += DbManagerExecuteNonQueryCompletedToDo;

			RefreshServerStatus(false);


	        if (string.IsNullOrEmpty(_shellSqlConn.type) || string.IsNullOrEmpty(_shellSqlConn.conn))
	        {
		        MessageBox.Show("shell's sqlConnection is null or space");
	        }
	        else
	        {
				//连接数据库
				_dbManager.ConnectDb(_shellSqlConn.conn);
	        }
        }
开发者ID:kevins1022,项目名称:Altman,代码行数:32,代码来源:PanelDbManager.cs



注:本文中的DbManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DbModelBuilder类代码示例发布时间:2022-05-24
下一篇:
C# DbItem类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap