本文整理汇总了C#中ZkData.ZkDataContext类的典型用法代码示例。如果您正苦于以下问题:C# ZkDataContext类的具体用法?C# ZkDataContext怎么用?C# ZkDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZkDataContext类属于ZkData命名空间,在下文中一共展示了ZkDataContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SubmitSpringBattleResult
public static string SubmitSpringBattleResult(Spring.SpringBattleContext result, ZkLobbyServer.ZkLobbyServer server)
{
try
{
if (!result.GameEndedOk) return "Game didn't end properly";
if (result.IsCheating) return "Cheats were enabled during this game";
var db = new ZkDataContext();
var text = new StringBuilder();
var sb = SaveSpringBattle(result, db);
ProcessExtras(result.OutputExtras, sb, db);
if (result.LobbyStartContext.Mode == AutohostMode.Planetwars) ProcessPlanetWars(result, server, sb, db, text);
ProcessElos(result, server, db, sb);
text.AppendLine(string.Format("BATTLE DETAILS AND REPLAY ----> {1}/Battles/Detail/{0} <-----", sb.SpringBattleID, GlobalConst.BaseSiteUrl));
return text.ToString();
}
catch (Exception ex)
{
var data = JsonConvert.SerializeObject(result);
Trace.TraceError($"{ex}\nData:\n{data}");
return $"{ex}\nData:\n{data}";
}
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:28,代码来源:BattleResultHandler.cs
示例2: CopyExtraImages
private void CopyExtraImages() {
var db = new ZkDataContext();
var configs = Path.Combine(targetFolder, "LuaUI", "Configs");
Utils.CheckPath(configs);
var tpath = Path.Combine(configs, "Avatars");
Utils.CheckPath(tpath);
Trace.TraceInformation("Copying avatars");
var spath = Path.Combine(siteBase, "img", "Avatars");
foreach (var file in Directory.GetFiles(spath)) File.Copy(file, Path.Combine(tpath, Path.GetFileName(file)), true);
Trace.TraceInformation("Copying clan icons");
tpath = Path.Combine(configs, "Clans");
Utils.CheckPath(tpath);
spath = Path.Combine(siteBase, "img", "clans");
foreach (var clan in db.Clans.Where(x => !x.IsDeleted))
{
var fileName = $"{clan.Shortcut}.png";
var src = Path.Combine(spath, fileName);
if (File.Exists(src)) File.Copy(src, Path.Combine(tpath, fileName), true);
}
Trace.TraceInformation("Copying faction icons");
tpath = Path.Combine(configs, "Factions");
Utils.CheckPath(tpath);
spath = Path.Combine(siteBase, "img", "factions");
foreach (var fac in db.Factions.Where(x => !x.IsDeleted))
{
var fileName = $"{fac.Shortcut}.png";
var src = Path.Combine(spath, fileName);
if (File.Exists(src)) File.Copy(src, Path.Combine(tpath, fileName), true);
}
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:34,代码来源:SteamDepotGenerator.cs
示例3: AddContribution
public ActionResult AddContribution(int accountID,int kudos, string item, string currency, double gross, double grossEur, double netEur, string email, string comment, bool isSpring, DateTime date) {
using (var db = new ZkDataContext()) {
var acc = db.Accounts.Find(accountID);
var contrib = new Contribution()
{
AccountID = accountID,
ManuallyAddedAccountID = Global.AccountID,
KudosValue = kudos,
ItemName = item,
IsSpringContribution = isSpring,
Comment = comment,
OriginalCurrency = currency,
OriginalAmount = gross,
Euros = grossEur,
EurosNet = netEur,
Time = date,
Name = acc.Name,
Email = email
};
db.Contributions.InsertOnSubmit(contrib);
db.SubmitAndMergeChanges();
acc.Kudos = acc.KudosGained - acc.KudosSpent;
db.SubmitAndMergeChanges();
}
return RedirectToAction("Index");
}
开发者ID:TurBoss,项目名称:Zero-K-Infrastructure,代码行数:28,代码来源:ContributionsController.cs
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var db = new ZkDataContext();
if (!int.TryParse(Request["resourceID"], out resourceID)) {
resourceID = db.Resources.Single(x => x.InternalName == Request["name"]).ResourceID;
}
if (!IsPostBack) {
var res = db.Resources.Where(x => x.ResourceID == resourceID).Single();
lbDetails.Text = string.Format("Download count: {0}<br/>\nFailed downloads (no links): {1}<br/>\n", res.DownloadCount, res.NoLinkDownloadCount);
lbName.Text = res.InternalName;
litLinks.Text = string.Join("<br/>", res.ResourceDependencies.Select(x => x.NeedsInternalName).ToArray());
string name = res.InternalName.EscapePath();
var sb = new StringBuilder();
if (res.TypeID == ZkData.ResourceType.Map) {
sb.AppendFormat("<img src='Resources/{0}.minimap.jpg'><br/>", name);
sb.AppendFormat("<img src='Resources/{0}.heightmap.jpg'><br/>", name);
sb.AppendFormat("<img src='Resources/{0}.metalmap.jpg'><br/>", name);
}
sb.AppendFormat("<a href='Resources/{0}.metadata.xml.gz'>metadata</a><br/>", name);
litBasics.Text = sb.ToString();
}
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:25,代码来源:ResourceDetail.aspx.cs
示例5: CanJoin
public async Task<bool> CanJoin(int accountID, string channel)
{
using (var db = new ZkDataContext()) {
var acc = await db.Accounts.FindAsync(accountID);
return CanJoin(acc, channel);
}
}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:ChannelManager.cs
示例6: DeleteAllPostsByUser
public ActionResult DeleteAllPostsByUser(int accountID, string accountName) {
var db = new ZkDataContext();
var acc = db.Accounts.FirstOrDefault(x => x.AccountID == accountID);
if (acc.Name != accountName) return Content("Invalid safety code");
foreach (var p in acc.ForumPosts) DeletePost(p.ForumPostID);
return RedirectToAction("Index");
}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:ForumController.cs
示例7: ConvertPage
public static void ConvertPage(string pageName, string newName, bool overwrite = false)
{
var db = new ZkDataContext();
ForumThread thread = db.ForumThreads.FirstOrDefault(x=> x.WikiKey == pageName);
if (thread == null)
{
Console.WriteLine("No ZK wiki page with name {0} found", pageName);
return;
}
string text = thread.ForumPosts.First().Text;
text = BBCodeToMediaWiki(text);
Page page = new Page(newWiki, newName);
page.Load();
bool update = false;
if (!page.IsEmpty())
{
if (!overwrite)
{
Console.WriteLine("Page already exists, exiting");
return;
}
else update = true;
}
if (newName.StartsWith("Mission Editor", true, System.Globalization.CultureInfo.CurrentCulture))
page.AddToCategory("Mission Editor");
page.Save(text, update ? "" : "Ported from ZK wiki by DotNetWikiBot", update);
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:30,代码来源:WikiPortingMW.cs
示例8: BattleBalanceData
public BattleBalanceData(int battleID)
{
ZkDataContext db = new ZkDataContext();
SpringBattle game = db.SpringBattles.FirstOrDefault(x => x.SpringBattleID == battleID);
this.battleID = battleID;
this.t1Elo = new List<double>();
this.t2Elo = new List<double>();
this.t1Names = new List<string>();
this.t2Names = new List<string>();
double t1Sum = 0;
double t2Sum = 0;
int t1Count = 0;
int t2Count = 0;
foreach (SpringBattlePlayer player in game.SpringBattlePlayers.Where(x=> !x.IsSpectator))
{
if (player.IsInVictoryTeam)
{
t1Sum += player.Account.EffectiveElo;
this.t1Elo.Add(Math.Floor(player.Account.EffectiveElo+0.5));
this.t1Names.Add(player.Account.Name);
t1Count++;
}
else
{
t2Sum += player.Account.EffectiveElo;
this.t2Elo.Add(Math.Floor(player.Account.EffectiveElo + 0.5));
this.t2Names.Add(player.Account.Name);
t2Count++;
}
}
this.t1Avg = Math.Floor(t1Sum / t1Count + 0.5);
this.t2Avg = Math.Floor(t2Sum / t2Count + 0.5);
this.t1Variance = Math.Floor(Variance(this.t1Elo, this.t1Avg) + 0.5);
this.t2Variance = Math.Floor(Variance(this.t2Elo, this.t2Avg) + 0.5);
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:35,代码来源:BattleBalanceData.cs
示例9: client_ChannelUserAdded
void client_ChannelUserAdded(object sender, ChannelUserInfo e)
{
Task.Run(async () =>
{
try
{
var chan = e.Channel.Name;
List<LobbyMessage> messages;
foreach (var user in e.Users) {
using (var db = new ZkDataContext()) {
messages = db.LobbyMessages.Where(x => x.TargetName == user.Name && x.Channel == chan).OrderBy(x => x.Created).ToList();
db.LobbyMessages.DeleteAllOnSubmit(messages);
db.SubmitChanges();
}
foreach (var m in messages) {
var text = string.Format("!pm|{0}|{1}|{2}|{3}", m.Channel, m.SourceName, m.Created.ToString(CultureInfo.InvariantCulture), m.Message);
await client.Say(SayPlace.User, user.Name, text, false);
await Task.Delay(MessageDelay);
}
}
}
catch (Exception ex)
{
Trace.TraceError("Error adding user: {0}", ex);
}
});
}
开发者ID:ParzivalX,项目名称:Zero-K-Infrastructure,代码行数:27,代码来源:OfflineMessages.cs
示例10: Index
//
// GET: /Poll/
public ActionResult Index(int pollID)
{
var db = new ZkDataContext();
var poll = db.Polls.FirstOrDefault(x => x.PollID == pollID);
if (poll != null) return PartialView("PollView", poll);
return null;
}
开发者ID:ParzivalX,项目名称:Zero-K-Infrastructure,代码行数:10,代码来源:PollController.cs
示例11: GetMissionByID
public Mission GetMissionByID(int missionID)
{
var db = new ZkDataContext();
db.Configuration.ProxyCreationEnabled = false;
var prev = db.Missions.Where(x => x.MissionID == missionID).Include(x=>x.Mutator).SingleOrDefault();
return prev;
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:MissionService.svc.cs
示例12: Index
//
// GET: /News/
public ActionResult Index()
{
Response.ClearContent();
Response.ContentType = "application/rss+xml";
var db = new ZkDataContext();
return View(db.News.Where(x=>x.Created < DateTime.UtcNow).OrderByDescending(x=>x.Created));
}
开发者ID:TurBoss,项目名称:Zero-K-Infrastructure,代码行数:9,代码来源:NewsController.cs
示例13: CachePunishments
private static void CachePunishments()
{
lock (punishmentsLock)
{
using (var db = new ZkDataContext()) punishments = db.Punishments.Where(x => x.BanExpires > DateTime.UtcNow).Include(x=>x.AccountByAccountID).Include(x=>x.AccountByCreatedAccountID).ToList();
}
}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:Punishment.cs
示例14: VerifyAccountHashed
public static Account VerifyAccountHashed(string login, string passwordHash)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(passwordHash)) return null;
var db = new ZkDataContext();
var acc = Account.AccountVerify(db, login, passwordHash);
return acc;
}
开发者ID:ParzivalX,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:AuthServiceClient.cs
示例15: Delete
public ActionResult Delete(int id)
{
var db = new ZkDataContext();
db.Missions.First(x => x.MissionID == id).IsDeleted = true;
db.SubmitChanges();
return RedirectToAction("Index");
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:MissionsController.cs
示例16: GalaxyDialog
public GalaxyDialog()
{
InitializeComponent();
var db = new ZkDataContext();
cmbGal.Items.Add("as new");
foreach (var g in db.Galaxies) cmbGal.Items.Add(g.GalaxyID.ToString());
}
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:7,代码来源:GalaxyDialog.xaml.cs
示例17: ExecuteArmed
public override async Task ExecuteArmed(ServerBattle battle, Say e)
{
var b = battle;
Dictionary<int, double> grouping;
using (var db = new ZkDataContext())
{
if (battle.IsInGame)
grouping = b.spring.LobbyStartContext?.Players.Where(u => !u.IsSpectator)
.GroupBy(u => u.AllyID)
.ToDictionary(x => x.Key, x => x.Average(y => Account.AccountByName(db, y.Name).EffectiveMmElo));
else
grouping = b.Users.Values.Where(u => !u.IsSpectator)
.GroupBy(u => u.AllyNumber)
.ToDictionary(x => x.Key, x => x.Average(y => y.LobbyUser.EffectiveMmElo));
}
KeyValuePair<int, double>? oldg = null;
foreach (var g in grouping)
{
if (oldg != null)
{
var t1elo = oldg.Value.Value;
var t2elo = g.Value;
await
battle.Respond(e,
$"team {oldg.Value.Key + 1} has {Utils.GetWinChancePercent(t2elo - t1elo)}% chance to win over team {g.Key + 1}");
}
oldg = g;
}
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:31,代码来源:CmdPredict.cs
示例18: GenerateTechs
public static void GenerateTechs()
{
var db = new ZkDataContext();
db.StructureTypes.DeleteAllOnSubmit(db.StructureTypes.Where(x => x.Unlock != null));
db.SaveChanges();
foreach (var u in db.Unlocks.Where(x => x.UnlockType == UnlockTypes.Unit))
{
var s = new StructureType()
{
BattleDeletesThis = false,
Cost = u.XpCost / 2,
MapIcon = "techlab.png",
DisabledMapIcon = "techlab_dead.png",
Name = u.Name,
Description = string.Format("Access to {0} and increases influence gains", u.Name),
TurnsToActivate = u.XpCost / 100,
IsBuildable = true,
IsIngameDestructible = true,
IsBomberDestructible = true,
Unlock = u,
UpkeepEnergy = u.XpCost / 5,
IngameUnitName = "pw_" + u.Code,
};
db.StructureTypes.InsertOnSubmit(s);
}
db.SaveChanges();
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:28,代码来源:PlanetwarsFixer.cs
示例19: ChangePermissions
public ActionResult ChangePermissions(int accountID, bool zkAdmin, bool vpnException)
{
var db = new ZkDataContext();
Account acc = db.Accounts.Single(x => x.AccountID == accountID);
Account adminAcc = Global.Account;
Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format("Permissions changed for {0} {1} by {2}", acc.Name, Url.Action("Detail", "Users", new { id = acc.AccountID }, "http"), adminAcc.Name));
if (acc.IsZeroKAdmin != zkAdmin)
{
//reset chat priviledges to 2 if removing adminhood; remove NW subsciption to admin channel
// FIXME needs to also terminate forbidden clan/faction subscriptions
Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format(" - Admin status: {0} -> {1}", acc.IsZeroKAdmin, zkAdmin));
acc.IsZeroKAdmin = zkAdmin;
}
if (acc.HasVpnException != vpnException)
{
Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, string.Format(" - VPN exception: {0} -> {1}", acc.HasVpnException, vpnException));
acc.HasVpnException = vpnException;
}
db.SaveChanges();
Global.Server.PublishAccountUpdate(acc);
return RedirectToAction("Detail", "Users", new { id = acc.AccountID });
}
开发者ID:DeinFreund,项目名称:Zero-K-Infrastructure,代码行数:25,代码来源:UsersController.cs
示例20: Detail
//
// GET: /Maps/
public ActionResult Detail(int id) {
var db = new ZkDataContext();
var res = db.Resources.Single(x => x.ResourceID == id);
var data = GetMapDetailData(res, db);
return View(data);
}
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:10,代码来源:MapsController.cs
注:本文中的ZkData.ZkDataContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论