本文整理汇总了C#中RDN.Library.DataModels.Context.ManagementContext类的典型用法代码示例。如果您正苦于以下问题:C# ManagementContext类的具体用法?C# ManagementContext怎么用?C# ManagementContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ManagementContext类属于RDN.Library.DataModels.Context命名空间,在下文中一共展示了ManagementContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getLineUpClock
/// <summary>
/// gets the current line up clock for the game.
/// </summary>
/// <param name="id"></param>
/// <param name="game"></param>
/// <returns></returns>
public static GameStopwatch getLineUpClock(Guid id, GameViewModel game)
{
try
{
ManagementContext db = new ManagementContext();
var getClock = (from xx in db.GameStopWatch
where xx.StopwatchForId == id
where xx.Type == (int)StopWatchTypeEnum.LineUpClock
select xx).FirstOrDefault();
if (getClock != null)
{
game.CurrentLineUpClock = new StopwatchWrapper();
game.CurrentLineUpClock.IsClockAtZero = getClock.IsClockAtZero == 1 ? true : false;
game.CurrentLineUpClock.IsRunning = getClock.IsRunning == 1 ? true : false;
game.CurrentLineUpClock.StartTime = getClock.StartDateTime;
game.CurrentLineUpClock.TimeElapsed = getClock.TimeElapsed;
game.CurrentLineUpClock.TimeRemaining = getClock.TimeRemaining;
game.CurrentLineUpClock.TimerLength = getClock.Length;
}
return getClock;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return null;
}
示例2: insertAssistIntoDb
public static int insertAssistIntoDb(Guid teamId, GameViewModel game, AssistViewModel assisted, ManagementContext db, DataModels.Game.Game g)
{
int c = 0;
try
{
GameMemberAssist assist = new GameMemberAssist();
assist.DateTimeAssisted = assisted.CurrentDateTimeAssisted;
assist.GameAssistId = assisted.AssistId;
assist.JamNumber = assisted.JamNumber;
assist.JamId = assisted.JamId;
assist.PeriodNumber = assisted.Period;
assist.PeriodTimeRemainingMilliseconds = assisted.PeriodTimeRemaining;
assist.Game = g;
assist.MemberWhoAssisted = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == assisted.PlayerWhoAssisted.SkaterId).FirstOrDefault();
if (assist.MemberWhoAssisted != null)
{
db.GameMemberAssist.Add(assist);
c += db.SaveChanges();
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return c;
}
示例3: CommitFeedback
public static void CommitFeedback(string feedback, string league, string email, FeedbackTypeEnum type)
{
try
{
ManagementContext db = new ManagementContext();
ScoreboardFeedback fb = new ScoreboardFeedback();
fb.Created = DateTime.UtcNow;
fb.Feedback = feedback;
fb.League = league;
fb.Email = email;
fb.FeedbackTypeEnum = (byte)FeedbackTypeEnum.None;
db.ScoreboardFeedback.Add(fb);
db.SaveChanges();
string body = "New Feedback Boss:<br/><br/>";
body += feedback + "<br/><br/>";
body += "from: " + email + "<br/>";
body += "url: http://raspberry.rdnation.com/Admin/Feedback<br/>";
body += "You Da Man!";
var emailData = new Dictionary<string, string> { { "body", body } };
EmailServer.EmailServer.SendEmail(ServerConfig.DEFAULT_EMAIL, ServerConfig.DEFAULT_EMAIL_FROM_NAME, ServerConfig.DEFAULT_INFO_EMAIL, EmailServer.EmailServer.DEFAULT_SUBJECT + " New Feedback", emailData, layout: EmailServerLayoutsEnum.Blank, priority: EmailPriority.Normal);
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
}
示例4: DeleteFolderFromLeague
public static bool DeleteFolderFromLeague(Guid leagueId, long folderId)
{
try
{
var dc = new ManagementContext();
var fold = dc.LeagueDocumentFolders.Where(x => x.League.LeagueId == leagueId && x.CategoryId == folderId).FirstOrDefault();
if (fold != null)
{
fold.ParentFolder = null;
var docs = dc.LeagueDocuments.Where(x => x.Category.CategoryId == folderId);
foreach (var doc in docs)
{
doc.Category = null;
}
dc.LeagueDocumentFolders.Remove(fold);
int c = dc.SaveChanges();
return c > 0;
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}
示例5: ToggleMessageLike
/// <summary>
/// This method will add new Forum Message like.
/// Add if it is new entry.Otherwise it will update the Total Count Column.
/// </summary>
/// <param name="MessageId">long MessageId</param>
/// <param name="memberId">Guid memberId</param>
/// <returns></returns>
public static ForumMessage ToggleMessageLike(long MessageId, Guid memberId)
{
try
{
long total;
var dc = new ManagementContext();
var check = dc.ForumMessageLike.Where(x => x.Messages.MessageId == MessageId && x.Member.MemberId == memberId).FirstOrDefault();
if (check != null)
{
if (check.TotalCount == 0)
check.TotalCount = 1;
else if (check.TotalCount == 1)
check.TotalCount = 0;
}
else
{
DataModels.Controls.Forum.ForumMessageLike messageLike = new DataModels.Controls.Forum.ForumMessageLike();
messageLike.Member = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
messageLike.Messages = dc.ForumMessages.Where(x => x.MessageId == MessageId).FirstOrDefault();
messageLike.TotalCount = 1;
dc.ForumMessageLike.Add(messageLike);
}
int c = dc.SaveChanges();
total = dc.ForumMessageLike.Where(x => x.Messages.MessageId == MessageId).Sum(x => x.TotalCount);
if (c > 0)
return new ForumMessage { MessageId = MessageId, MessageLikeCount = total };
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return new ForumMessage { MessageId = MessageId, MessageAgreeCount = 0 };
}
示例6: ChangeClassificationForMember
public static bool ChangeClassificationForMember(Guid duesManagementId, long classificationId, Guid memberId)
{
FeeClassificationFactory fClass = new FeeClassificationFactory();
try
{
var dc = new ManagementContext();
var classy = dc.FeeClassificationByMember.Where(x => x.FeeItem.FeeItem.FeeManagementId == duesManagementId && x.Member.MemberId == memberId).FirstOrDefault();
if (classificationId == 0)
{
dc.FeeClassificationByMember.Remove(classy);
}
else if (classy == null)
{
FeesClassificationByMember m = new FeesClassificationByMember();
var classification = dc.FeeClassification.Where(x => x.FeeItem.FeeManagementId == duesManagementId && x.FeeClassificationId == classificationId).FirstOrDefault();
m.FeeItem = classification;
m.Member = dc.Members.Where(x => x.MemberId == memberId).FirstOrDefault();
classification.MembersClassified.Add(m);
dc.FeeClassificationByMember.Add(m);
}
else
{
classy.FeeItem = dc.FeeClassification.Where(x => x.FeeItem.FeeManagementId == duesManagementId && x.FeeClassificationId == classificationId).FirstOrDefault();
}
int c = dc.SaveChanges();
return c > 0;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}
示例7: Add_New_List
public static bool Add_New_List(RDN.Library.Classes.League.TaskList.TaskListDA NewTaskList)
{
try
{
var dc = new ManagementContext();
DataModels.League.Task.TaskList con = new DataModels.League.Task.TaskList();
con.AssignedTo = NewTaskList.AssignedTo;
con.EndDate = NewTaskList.EndDate;
con.ListAddByMember = dc.Members.Where(x => x.MemberId == NewTaskList.ListAddByMember).FirstOrDefault();
con.ListName = NewTaskList.ListName;
con.TaskListForLeague = dc.Leagues.Where(x => x.LeagueId == NewTaskList.TaskListForLeague).FirstOrDefault();
dc.TaskLists.Add(con);
int c = dc.SaveChanges();
return c > 0;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}
示例8: GetLeagueColors
public static List<ColorDisplay> GetLeagueColors(Guid leagueId)
{
try
{
var dc = new ManagementContext();
var colors = (from xx in dc.LeagueColors
where xx.League.LeagueId == leagueId
select new ColorDisplay
{
ColorId = xx.ColorId,
CSharpColor = xx.Color.ColorIdCSharp,
NameOfColor = xx.Color.ColorName
}).OrderBy(x => x.CSharpColor).ToList();
foreach (var color in colors)
{
Color c = System.Drawing.Color.FromArgb(color.CSharpColor);
color.HexColor = ColorTranslator.ToHtml(c);
}
return colors;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return new List<ColorDisplay>();
}
示例9: DoUpdates
public static int DoUpdates()
{
try
{
int c = 0;
var dc = new ManagementContext();
var mems = dc.LeagueMembers.Where(x => x.LeagueOwnersEnum > 0);
foreach (var mem in mems)
{
mem.LeagueOwnersEnums = (int)mem.LeagueOwnersEnum;
if (mem.LeagueOwnersEnum > 0)
Console.WriteLine(mem.LeagueOwnersEnum);
//leagueMember.LeagueOwnersEnums = (int)owner;
mem.League = mem.League;
mem.Member = mem.Member;
}
c += dc.SaveChanges();
return c;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return 0;
}
示例10: insertBlockIntoDb
public static void insertBlockIntoDb(Guid teamId, GameViewModel game, BlockViewModel block, ManagementContext db, DataModels.Game.Game g)
{
try
{
GameMemberBlock blocks = new GameMemberBlock();
blocks.DateTimeBlocked = block.CurrentDateTimeBlock;
blocks.GameBlockId = block.BlockId;
blocks.JamNumber = block.JamNumber;
blocks.JamId = block.JamId;
blocks.PeriodNumber = block.Period;
blocks.PeriodTimeRemainingMilliseconds = block.PeriodTimeRemaining;
blocks.Game = g;
blocks.MemberWhoBlocked = g.GameTeams.Where(x => x.TeamId == teamId).First().GameMembers.Where(x => x.GameMemberId == block.PlayerWhoBlocked.SkaterId).FirstOrDefault();
if (blocks.MemberWhoBlocked != null)
{
db.GameMemberBlock.Add(blocks);
db.SaveChanges();
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
}
示例11: AddColor
public static bool AddColor(string nameOfColor, string colorHex)
{
try
{
var dc = new ManagementContext();
Color color = ColorTranslator.FromHtml(colorHex);
int arb = color.ToArgb();
var colorDb = dc.Colors.Where(x => x.ColorIdCSharp == arb).FirstOrDefault();
if (colorDb == null)
{
DataModels.Color.Color co = new DataModels.Color.Color();
co.ColorName = nameOfColor;
co.ColorIdCSharp = arb;
dc.Colors.Add(co);
int c = dc.SaveChanges();
return c > 0;
}
return true;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType(), additionalInformation: nameOfColor + " " + colorHex);
}
return false;
}
示例12: GetAllLogos
/// <summary>
/// gets all the logos in the DB.
/// </summary>
/// <returns></returns>
public List<RDN.Portable.Classes.Team.TeamLogo> GetAllLogos(TeamDisplay team)
{
try
{
if (team.LeagueLogos == null || team.LeagueLogos.Count == 0)
{
var dc = new ManagementContext();
if (team.ScoreboardLogos == null || team.ScoreboardLogos.Count == 0)
team.ScoreboardLogos = GetAllScoreboardLogos(team);
var leagues = dc.Leagues.Where(x => x.Logo != null).AsParallel().ToList();
foreach (var league in leagues)
{
RDN.Portable.Classes.Team.TeamLogo logo = new RDN.Portable.Classes.Team.TeamLogo();
logo.ImageUrl = league.Logo.ImageUrl;
logo.TeamName = league.Name;
logo.TeamLogoId = league.Logo.LeaguePhotoId;
team.LeagueLogos.Add(logo);
}
team.LeagueLogos = team.LeagueLogos.OrderBy(x => x.TeamName).ToList();
}
return team.LeagueLogos;
}
catch (Exception e)
{
Library.Classes.Error.ErrorDatabaseManager.AddException(e, e.GetType(), ErrorGroupEnum.Database);
}
return null;
}
示例13: GetAllScoreboardLogos
public List<RDN.Portable.Classes.Team.TeamLogo> GetAllScoreboardLogos(TeamDisplay team)
{
try
{
if (team.ScoreboardLogos == null)
{
var dc = new ManagementContext();
var logos = dc.TeamLogos.AsParallel().OrderBy(x => x.TeamName).ToList();
for (int i = 0; i < logos.Count; i++)
{
team.ScoreboardLogos.Add(new RDN.Portable.Classes.Team.TeamLogo()
{
Height = logos[i].Height.ToString(),
ImageUrl = logos[i].ImageUrl,
ImageUrlThumb = logos[i].ImageUrlThumb,
SaveLocation = logos[i].SaveLocation,
TeamLogoId = logos[i].TeamLogoId,
TeamName = logos[i].TeamName,
Width = logos[i].Width.ToString()
});
}
}
return team.ScoreboardLogos;
}
catch (Exception e)
{
Library.Classes.Error.ErrorDatabaseManager.AddException(e, e.GetType(), ErrorGroupEnum.Database);
}
return null;
}
示例14: GetCurrentBillingStatus
public static LeagueBilling GetCurrentBillingStatus(Guid leagueId)
{
LeagueBilling bi = new LeagueBilling();
try
{
var dc = new ManagementContext();
PaymentGateway pg = new PaymentGateway();
var invoice = pg.GetLatestInvoiceSubscriptionForLeagueId(leagueId);
bi.LeagueId = leagueId;
bi.LeagueName = dc.Leagues.Where(x => x.LeagueId == leagueId).Select(x => x.Name).FirstOrDefault();
if (invoice != null)
{
bi.InvoiceId = invoice.InvoiceId;
bi.Expires = invoice.Subscription.ValidUntil;
bi.LastBilledOn = invoice.Subscription.Created;
bi.MembershipStatus = CurrentStatusOfBillingEnum.League_Membership;
bi.PaymentProviderCustomerId = invoice.PaymentProviderCustomerId;
}
else
{
bi.MembershipStatus = CurrentStatusOfBillingEnum.None;
}
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return bi;
}
示例15: RemoveDuesCollectionItem
public static bool RemoveDuesCollectionItem(long duesItemId, Guid duesManagementId, Guid memId, long duesCollectedId)
{
try
{
var dc = new ManagementContext();
var item = (from xx in dc.FeesCollected
where xx.MemberPaid.MemberId == memId
where xx.FeeItem.FeeCollectionId == duesItemId
where xx.FeeItem.FeeManagedBy.FeeManagementId == duesManagementId
select xx);
foreach (var fee in item)
{
fee.IsPaidInFull = false;
}
var feed = item.Where(x => x.FeeCollectionId == duesCollectedId).FirstOrDefault();
if (feed != null)
dc.FeesCollected.Remove(feed);
int c = dc.SaveChanges();
return true;
}
catch (Exception exception)
{
ErrorDatabaseManager.AddException(exception, exception.GetType());
}
return false;
}