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

C# DAL.DefaultContext类代码示例

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

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



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

示例1: OnAuthorization

        public virtual void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext == null)
                throw new ArgumentNullException("filterContext");

            if (filterContext.HttpContext == null)
                throw new Exception("filterContext.HttpContext");

            int currentLcid = Thread.CurrentThread.CurrentCulture.LCID;
            int lcid = 1029;
            string requestLcid = filterContext.HttpContext.Request.QueryString["LCID"];
            IPrincipal user = filterContext.HttpContext.User;
            if (!String.IsNullOrEmpty(requestLcid))
            {
                filterContext.Controller.ViewBag.LCID = requestLcid;
                Int32.TryParse(requestLcid, out lcid);
            }
            else if (user.Identity.IsAuthenticated)
            {
                var db = new DefaultContext();
                UserProfile userProfile = UserProfileCache.GetDetail(db, user.Identity.Name);
                lcid = userProfile.LCID;
            }

            CultureInfo cultureInfo = CultureInfo.GetCultureInfo(lcid);
            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:28,代码来源:SetLanguageAttribute.cs


示例2: GetIndex

        public static MeetingTitleType[] GetIndex(DefaultContext db, string sortOrder)
        {
            IQueryable<MeetingTitleType> meetingTitleTypes = db.MeetingTitleTypes.AsQueryable();

            switch (sortOrder)
            {
                default:
                    meetingTitleTypes = meetingTitleTypes.OrderBy(ba => ba.Title);
                    break;

                case TitleDescSortOrder:
                    meetingTitleTypes = meetingTitleTypes.OrderByDescending(ba => ba.Title);
                    break;

                case MeetingTypeAscSortOrder:
                    meetingTitleTypes = meetingTitleTypes.OrderBy(ba => ba.MeetingType);
                    break;

                case MeetingTypeDescSortOrder:
                    meetingTitleTypes = meetingTitleTypes.OrderByDescending(ba => ba.MeetingType);
                    break;
            }

            return meetingTitleTypes.ToArray();
        }
开发者ID:MulderFox,项目名称:Main,代码行数:25,代码来源:MeetingTitleTypeCache.cs


示例3: SavePropertiesBagItem

        public static void SavePropertiesBagItem(DefaultContext db, string key, string value, bool saveChangesToDb)
        {
            lock (LockPropertiesBags)
            {
                PropertiesBag propertiesBag = _propertiesBags.SingleOrDefault(pb => pb.Key.Equals(key));
                if (propertiesBag == null)
                {
                    propertiesBag = new PropertiesBag { Key = key, Value = value };
                    _propertiesBags.Add(propertiesBag);
                }
                else
                {
                    propertiesBag.Value = value;
                }

                PropertiesBag dbPropertiesBag = db.PropertiesBags.Find(key);
                if (dbPropertiesBag == null)
                {
                    dbPropertiesBag = new PropertiesBag { Key = key, Value = value };
                    db.PropertiesBags.Add(dbPropertiesBag);
                }
                else
                {
                    dbPropertiesBag.Value = value;
                }

                if (saveChangesToDb)
                {
                    db.SaveChanges();
                }
            }
        }
开发者ID:MulderFox,项目名称:Main,代码行数:32,代码来源:PropertiesBagCache.cs


示例4: SendEmails

        public ModelStateDictionary SendEmails(DefaultContext db)
        {
            var modelStateDictionary = new ModelStateDictionary();
            UserProfile[] userProfiles = UserProfileCache.GetIndex(db);
            bool success = true;
            foreach (UserProfile userProfile in userProfiles.Where(up => !String.IsNullOrEmpty(up.Email1)))
            {
                bool partialSuccess = Mail.SendEmail(userProfile.Email1, Subject, Body, true, true);
                if (partialSuccess)
                {
                    string logMessage = String.Format("Email for user {0} with address {1} was successfully sent.", userProfile.FullName, userProfile.Email1);
                    Logger.SetLog(logMessage);
                }
                else
                {
                    string errorMessage = String.Format("Email for user {0} with address {1} was not sent.", userProfile.FullName, userProfile.Email1);
                    Logger.SetErrorLog(errorMessage);
                }

                success &= partialSuccess;
            }

            if (!success)
            {
                modelStateDictionary.AddModelError(BaseCache.EmptyField, ValidationResource.BulkMail_SomeEmailWasNotSent_ErrorMessage);
            }

            return modelStateDictionary;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:29,代码来源:BulkMailModelView.cs


示例5: LyconetService

 public LyconetService(DefaultContext db, int userId)
 {
     _csvData = new DataTable();
     _summaryMesage = new StringBuilder();
     _db = db;
     _userId = userId;
 }
开发者ID:MulderFox,项目名称:Main,代码行数:7,代码来源:LyconetService.cs


示例6: OnAuthorization

        public virtual void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext == null)
                throw new ArgumentNullException("filterContext");

            if (filterContext.HttpContext == null)
                throw new Exception("filterContext.HttpContext");

            AutomaticLogoutIntervalType automaticLogoutIntervalType;
            bool isUserAutomaticLogoutIntervalSet;
            IPrincipal user = filterContext.HttpContext.User;
            if (user.Identity.IsAuthenticated)
            {
                var db = new DefaultContext();
                UserProfile userProfile = UserProfileCache.GetDetail(db, user.Identity.Name);
                automaticLogoutIntervalType = userProfile.AutomaticLogoutInterval;
                isUserAutomaticLogoutIntervalSet = true;
            }
            else
            {
                automaticLogoutIntervalType = AutomaticLogoutIntervalType.SixtyMinutes;
                isUserAutomaticLogoutIntervalSet = false;
            }

            filterContext.Controller.ViewBag.IsUserAutomaticLogoutIntervalSet = isUserAutomaticLogoutIntervalSet;
            filterContext.Controller.ViewBag.UserAutomaticLogoutInterval = (int)automaticLogoutIntervalType;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:27,代码来源:SetAutomaticLogoutAttribute.cs


示例7: MeetingBusinessInfoDetail

        public MeetingBusinessInfoDetail(Meeting meeting, DefaultContext db, int userId, bool isAdmin)
            : base(meeting, db, userId, isAdmin)
        {
            if (meeting == null || meeting.MeetingType != MeetingType.Lgs)
                return;

            City = meeting.City;
            AddressLine1 = meeting.AddressLine1;
            MeetingType = MeetingType.Lgs;
            MeetingKind = MeetingKind.Public;
            Date = meeting.Started.Date;
            StartTime = meeting.Started.ToString("HH:mm");
            FinishTime = meeting.Finished.ToString("HH:mm");

            var attendees = new List<MeetingDetailAttendee>();
            foreach (MeetingAttendee meetingAttendee in meeting.MeetingAttendees.Where(ma => ma.AttendeeId.HasValue || ma.UserAttendeeId.HasValue))
            {
                MeetingDetailAttendee attendee;
                if (meetingAttendee.AttendeeId.HasValue)
                {
                    bool showContactAcronym = ShowContactAcronym(db, userId, meetingAttendee.Attendee.RegistrarId);
                    attendee = new MeetingDetailAttendee
                                   {
                                       MeetingAttendeeId = meetingAttendee.MeetingAttendeeId,
                                       FirstName = showContactAcronym
                                                       ? meetingAttendee.Attendee.FirstNameAcronym
                                                       : meetingAttendee.Attendee.FirstName,
                                       LastName = showContactAcronym
                                                      ? meetingAttendee.Attendee.LastNameAcronym
                                                      : meetingAttendee.Attendee.LastName,
                                       City = meetingAttendee.Attendee.CityIndexView,
                                       LyonessId = meetingAttendee.Attendee.LyonessId,
                                       Leader = meetingAttendee.Attendee.Registrar.FullNameWithoutLyonessId,
                                       AccessUnsign =
                                           isAdmin || meeting.OrganizerId == userId ||
                                           meeting.SecondaryOrganizerId == userId ||
                                           meetingAttendee.Attendee.RegistrarId == userId
                                   };
                }
                else
                {
                    attendee = new MeetingDetailAttendee
                    {
                        MeetingAttendeeId = meetingAttendee.MeetingAttendeeId,
                        FirstName = meetingAttendee.UserAttendee.FirstName,
                        LastName = meetingAttendee.UserAttendee.LastName,
                        City = meetingAttendee.UserAttendee.CityIndexView,
                        LyonessId = meetingAttendee.UserAttendee.LyonessId,
                        Leader = meetingAttendee.UserAttendee.Registrar == null
                         ? NullDisplayText
                         : meetingAttendee.UserAttendee.Registrar.FullNameWithoutLyonessId,
                        AccessUnsign = isAdmin || meeting.OrganizerId == userId || meeting.SecondaryOrganizerId == userId || meetingAttendee.UserAttendeeId == userId
                    };
                }

                attendees.Add(attendee);
            }

            MeetingAttendees = attendees.ToArray();
        }
开发者ID:MulderFox,项目名称:Main,代码行数:60,代码来源:MeetingModelView.cs


示例8: Insert

        public static void Insert(DefaultContext db, Video video, int[] userIds)
        {
            db.Videos.Add(video);

            VideoUserCache.InsertWithoutSave(db, video.VideoId, userIds);

            db.SaveChanges();
        }
开发者ID:MulderFox,项目名称:Main,代码行数:8,代码来源:VideoCache.cs


示例9: Validate

        public ModelStateDictionary Validate(DefaultContext db)
        {
            var modelStateDictionary = new ModelStateDictionary();

            ValidateUniqueTitle(db, ref modelStateDictionary);

            return modelStateDictionary;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:8,代码来源:ManualTypeModelView.cs


示例10: GetUserProfileIndexForAdmin

        /// <summary>
        /// Gets the user profile index for admin.
        /// </summary>
        /// <param name="db">The db.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="searchString">The search string.</param>
        /// <param name="searchStringAccording">The search string according.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <returns>IEnumerable{UserProfileIndex}.</returns>
        public static UserProfileIndex[] GetUserProfileIndexForAdmin(DefaultContext db, int userId, string searchString, string searchStringAccording, string sortOrder)
        {
            var parameter = new SqlParameter(UserIdSqlParameter, userId);
            UserProfileIndex[] userProfiles = db.Database.SqlQuery<UserProfileIndex>(GetUserProfileIndexForAdminProcedureTemplate, parameter).ToArray();

            userProfiles = GetUserProfileIndex(userProfiles, searchString, searchStringAccording, sortOrder);
            return userProfiles;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:17,代码来源:UserProfileCache.cs


示例11: CheckTasks

        public static void CheckTasks(DefaultContext db)
        {
            PeopleContactTask[] peopleContactTasks = GetPeopleContactTasks(db);
            var groupedPeopleContactTasks = peopleContactTasks.GroupBy(p => p.RegistrarId, (key, g) => new { RegistrarId = key, PeopleContactTasks = g.ToArray() }).ToArray();

            foreach (var groupedPeopleContactTask in groupedPeopleContactTasks)
            {
                if (groupedPeopleContactTask.PeopleContactTasks[0].UseMail)
                {
                    var actualTasks = new StringBuilder();
                    var delayedTasks = new StringBuilder();
                    foreach (PeopleContactTask peopleContactTask in groupedPeopleContactTask.PeopleContactTasks)
                    {
                        switch (peopleContactTask.PeopleContactTaskType)
                        {
                            case PeopleContactTaskType.Actual:
                                actualTasks.AppendLine(peopleContactTask.Text);
                                break;

                            case PeopleContactTaskType.Delayed:
                                delayedTasks.AppendLine(peopleContactTask.Text);
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                        }
                    }

                    if (actualTasks.Length == 0)
                    {
                        actualTasks.AppendLine(MailResource.TaskSchedulerController_ExecuteCheckTasks_NoTasks);
                    }

                    if (delayedTasks.Length == 0)
                    {
                        delayedTasks.AppendLine(MailResource.TaskSchedulerController_ExecuteCheckTasks_NoTasks);
                    }

                    string textBody = String.Format(MailResource.TaskSchedulerController_ExecuteCheckTasks_TextBody,
                                                    actualTasks, delayedTasks, Url.GetWebRootUrl());

                    Mail.SendEmail(groupedPeopleContactTask.PeopleContactTasks[0].Email1,
                                        MailResource.TaskSchedulerController_ExecuteCheckTasks_Subject, textBody,
                                        true, true);
                }

                if (groupedPeopleContactTask.PeopleContactTasks[0].UseSms && !String.IsNullOrEmpty(groupedPeopleContactTask.PeopleContactTasks[0].SmsEmail))
                {
                    string textBody =
                        String.Format(SmsResource.TaskSchedulerController_ExecuteCheckTasks_TextBody,
                                      groupedPeopleContactTask.PeopleContactTasks.Count());

                    Mail.SendEmail(groupedPeopleContactTask.PeopleContactTasks[0].SmsEmail,
                                        SmsResource.TaskSchedulerController_ExecuteCheckTasks_Subject, textBody,
                                        true, true);
                }
            }
        }
开发者ID:MulderFox,项目名称:Main,代码行数:58,代码来源:PeopleContactCache.cs


示例12: FindVideoFilePath

        private void FindVideoFilePath()
        {
            if (!IsValid)
                return;

            Video video = null;
            using (var db = new DefaultContext())
            {
                if (_isAdmin && Id > 0)
                {
                    video = VideoCache.GetDetail(db, Id);
                }
                else if (!String.IsNullOrEmpty(Token))
                {
                    string decryptedToken = Cryptography.Decrypt(Token);
                    if (String.IsNullOrEmpty(decryptedToken))
                        return;

                    int videoTokenId;
                    if (!Int32.TryParse(decryptedToken, out videoTokenId) || videoTokenId < 1)
                        return;

                    VideoToken videoToken = VideoTokenCache.GetDetail(db, videoTokenId);
                    if (videoToken == null)
                        return;

                    if (!videoToken.IsPlayedByRecipient && videoToken.Sender != null && videoToken.Recipient != null)
                    {
                        DateTime timeToSend = DateTime.Now.AddSeconds(videoToken.Video.Duration);
                        string textBody = String.Format(videoToken.Video.EmailSenderBody, videoToken.Recipient.FullName, videoToken.Video.Title, timeToSend.ToString("dd. MM. yyyy HH:mm:ss"));
                        var lazyMail = new LazyMail
                                           {
                                               Address = videoToken.Sender.Email1,
                                               TextBody = textBody,
                                               TimeToSend = timeToSend
                                           };
                        LazyMailCache.InsertWithoutSave(db, lazyMail);

                        videoToken.IsPlayedByRecipient = true;

                        VideoTokenCache.Update(db, videoToken);
                    }

                    video = videoToken.Video;
                }
            }

            if (video == null)
                return;

            string videoAbsoluteFilePath = FileService.GetAbsoluteFilePath(_server, video.RelativeFilePath);
            if (!File.Exists(videoAbsoluteFilePath))
                return;

            VideoRelativeFilePath = video.RelativeFilePath;
            VideoAbsoluteFilePath = videoAbsoluteFilePath;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:57,代码来源:StreamVideoModelView.cs


示例13: ValidateUniqueTitle

        protected void ValidateUniqueTitle(DefaultContext db, ref ModelStateDictionary modelStateDictionary, int? modelTypeId = null)
        {
            bool isUnique = ManualTypeCache.IsTitleUnique(db, Title, modelTypeId);
            if (isUnique)
                return;

            string errorMessage = String.Format(ValidationResource.Global_OwnUnique_ErrorMessage, FieldResource.Global_Title_Name);
            modelStateDictionary.AddModelError(BaseCache.TitleField, errorMessage);
        }
开发者ID:MulderFox,项目名称:Main,代码行数:9,代码来源:ManualTypeModelView.cs


示例14: Validate

        public ModelStateDictionary Validate(DefaultContext db)
        {
            var modelStateDictionary = new ModelStateDictionary();

            Currency[] otherCurrencies = CurrencyCache.GetIndex(db, CurrencyId);
            ValidateUniqueCurrency(otherCurrencies, ref modelStateDictionary);
            ValidateExchangeRate(ref modelStateDictionary);

            return modelStateDictionary;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:10,代码来源:Currency.cs


示例15: GetUserProfileIndexTree

        /// <summary>
        /// Gets the user profile index tree.
        /// </summary>
        /// <param name="db">The db.</param>
        /// <param name="userId">The user id.</param>
        /// <returns>IEnumerable{UserProfileIndexTree}.</returns>
        public static UserProfileIndexTree[] GetUserProfileIndexTree(DefaultContext db, int userId)
        {
            var parameter = new SqlParameter(UserIdSqlParameter, userId);
            UserProfileIndexTree[] userProfiles = db.Database.SqlQuery<UserProfileIndexTree>(GetUserProfileIndexTreeProcedureTemplate, parameter).ToArray();
            foreach (UserProfileIndexTree userProfileIndexTree in userProfiles)
            {
                userProfileIndexTree.IsEditable = !userProfileIndexTree.IsPoliciesAccepted;
            }

            return userProfiles;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:17,代码来源:UserProfileCache.cs


示例16: SendLazyMails

        public static void SendLazyMails(DefaultContext db)
        {
            DateTime currentTime = DateTime.Now;
            LazyMail[] lazyMails = db.LazyMails.Where(lm => lm.TimeToSend <= currentTime).ToArray();
            foreach (LazyMail lazyMail in lazyMails)
            {
                Mail.SendEmail(lazyMail.Address, MailResource.TaskSchedulerController_SendLazyMails_Subject, lazyMail.TextBody, true, true);

                db.LazyMails.Remove(lazyMail);
                db.SaveChanges();
            }
        }
开发者ID:MulderFox,项目名称:Main,代码行数:12,代码来源:LazyMailCache.cs


示例17: GetUserProfileIndex

        /// <summary>
        /// Gets the index of the user profile.
        /// </summary>
        /// <param name="db">The db.</param>
        /// <param name="userId">The user id.</param>
        /// <param name="searchString">The search string.</param>
        /// <param name="searchStringAccording">The search string according.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <returns>IEnumerable{UserProfileIndex}.</returns>
        public static UserProfileIndex[] GetUserProfileIndex(DefaultContext db, int userId, string searchString, string searchStringAccording, string sortOrder)
        {
            var parameter = new SqlParameter(UserIdSqlParameter, userId);
            UserProfileIndex[] userProfiles = db.Database.SqlQuery<UserProfileIndex>(GetUserProfileIndexProcedureTemplate, parameter).ToArray();
            foreach (UserProfileIndex userProfileIndex in userProfiles)
            {
                userProfileIndex.IsEditable = !userProfileIndex.IsPoliciesAccepted;
            }

            userProfiles = GetUserProfileIndex(userProfiles, searchString, searchStringAccording, sortOrder);
            return userProfiles;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:21,代码来源:UserProfileCache.cs


示例18: Update

        public static bool Update(DefaultContext db, ref District district)
        {
            District dbDistrict = GetDetail(db, district.DistrictId);
            if (dbDistrict == null)
                return false;

            dbDistrict.CopyFrom(district);
            db.SaveChanges();

            district = dbDistrict;
            return true;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:12,代码来源:DistrictCache.cs


示例19: Update

        public static bool Update(DefaultContext db, ref MeetingTitleType meetingTitleType)
        {
            MeetingTitleType dbMeetingTitleType = GetDetail(db, meetingTitleType.MeetingTitleTypeId);
            if (dbMeetingTitleType == null)
                return false;

            dbMeetingTitleType.CopyFrom(meetingTitleType);
            db.SaveChanges();

            meetingTitleType = dbMeetingTitleType;
            return true;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:12,代码来源:MeetingTitleTypeCache.cs


示例20: Update

        public static bool Update(DefaultContext db, ref Currency currency)
        {
            Currency dbCurrency = GetDetail(db, currency.CurrencyId);
            if (dbCurrency == null)
                return false;

            dbCurrency.CopyFrom(currency);
            db.SaveChanges();

            currency = dbCurrency;
            return true;
        }
开发者ID:MulderFox,项目名称:Main,代码行数:12,代码来源:CurrencyCache.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# EF.LDLLogisticsEntities类代码示例发布时间:2022-05-26
下一篇:
C# LANDCOMP.ExecuteSTP类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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