本文整理汇总了C#中LBT.DAL.DefaultContext类的典型用法代码示例。如果您正苦于以下问题:C# DefaultContext类的具体用法?C# DefaultContext怎么用?C# DefaultContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultContext类属于LBT.DAL命名空间,在下文中一共展示了DefaultContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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();
}
}
}
示例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;
}
示例5: LyconetService
public LyconetService(DefaultContext db, int userId)
{
_csvData = new DataTable();
_summaryMesage = new StringBuilder();
_db = db;
_userId = userId;
}
示例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;
}
示例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();
}
示例8: Insert
public static void Insert(DefaultContext db, Video video, int[] userIds)
{
db.Videos.Add(video);
VideoUserCache.InsertWithoutSave(db, video.VideoId, userIds);
db.SaveChanges();
}
示例9: Validate
public ModelStateDictionary Validate(DefaultContext db)
{
var modelStateDictionary = new ModelStateDictionary();
ValidateUniqueTitle(db, ref modelStateDictionary);
return modelStateDictionary;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}