本文整理汇总了C#中ZkData.ZkDataContext.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# ZkDataContext.SubmitChanges方法的具体用法?C# ZkDataContext.SubmitChanges怎么用?C# ZkDataContext.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZkData.ZkDataContext
的用法示例。
在下文中一共展示了ZkDataContext.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeFeaturedOrder
public ActionResult ChangeFeaturedOrder(int id, float? featuredOrder, string script)
{
var db = new ZkDataContext();
var mis = db.Missions.SingleOrDefault(x => x.MissionID == id);
mis.FeaturedOrder = featuredOrder;
if (mis.IsScriptMission && !string.IsNullOrEmpty(script)) mis.Script = script;
db.SubmitChanges();
var order = 1;
if (featuredOrder.HasValue) foreach (var m in db.Missions.Where(x => x.FeaturedOrder != null).OrderBy(x => x.FeaturedOrder)) m.FeaturedOrder = order++;
db.SubmitChanges();
return RedirectToAction("Index");
}
示例2: Delete
public ActionResult Delete(int id)
{
var db = new ZkDataContext();
db.Missions.First(x => x.MissionID == id).IsDeleted = true;
db.SubmitChanges();
return RedirectToAction("Index");
}
示例3: 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);
}
});
}
示例4: Main
static void Main(string[] args)
{
var db = new ZkDataContext();
var dict = db.Accounts.ToDictionary(x => x.AccountID);
var path = args.Length > 0 ? args[0] : @"accounts.txt";
using (var r = new StreamReader(path)) {
string line;
while ((line = r.ReadLine()) != null) {
Account ac = null;
try {
var parts = line.Split(' ');
if (parts.Length < 9) {
Trace.TraceError("Faulty line: ", line);
continue;
}
var name = parts[0];
var pass = parts[1];
var flags = parts[2];
//var cookie = int.Parse(parts[3]);
var lastLogin = ConvertTimestamp(double.Parse(parts[4]) / 1000);
var lastIP = parts[5];
var registered = ConvertTimestamp(double.Parse(parts[6]) / 1000);
var country = parts[7];
var id = int.Parse(parts[8]);
Account de = null;
dict.TryGetValue(id, out de);
Console.WriteLine(string.Format("{0} {1}", id, name));
if (de == null || name != de.Name || pass != de.Password || registered != de.FirstLogin ) {
if (de == null) {
ac = new Account();
db.Accounts.InsertOnSubmit(ac);
} else ac = db.Accounts.SingleOrDefault(x => x.LobbyID == id);
ac.LobbyID = id;
ac.Name = name;
//ac.Flags = flags;
ac.Password = pass;
//ac.UserCookie = cookie;
if (lastLogin.HasValue) ac.LastLogin = lastLogin.Value;
//ac.LastIP = lastIP;
if (registered.HasValue) ac.FirstLogin = registered.Value;
if (ac.LastLogin == DateTime.MinValue) ac.LastLogin = registered ?? DateTime.UtcNow;
//ac.Created = registered;
ac.Country = country;
Console.Write(" CHANGED!");
db.SubmitChanges();
}
} catch (Exception e) {
Console.WriteLine("Problem importing line: {0}: {1}", line, e);
db = new ZkDataContext();
}
}
}
}
示例5: NewPoll
public ActionResult NewPoll(string question, string answers, bool? isAnonymous)
{
var p = new Poll() { CreatedAccountID = Global.AccountID, IsHeadline = true, QuestionText = question, IsAnonymous = isAnonymous == true, };
var db = new ZkDataContext();
foreach (var a in answers.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) p.PollOptions.Add(new PollOption() { OptionText = a });
db.Polls.InsertOnSubmit(p);
db.SubmitChanges();
return RedirectToAction("UserVotes", new { id = Global.AccountID });
}
示例6: ChangeHideCountry
public ActionResult ChangeHideCountry(int accountID, bool hideCountry)
{
var db = new ZkDataContext();
Account acc = db.Accounts.Single(x => x.AccountID == accountID);
if (hideCountry) acc.Country = "??";
// TODO reimplement ? Global.Nightwatch.Tas.SetHideCountry(acc.Name, hideCountry);
db.SubmitChanges();
return RedirectToAction("Detail", "Users", new { id = acc.AccountID });
}
示例7: DeletePost
public ActionResult DeletePost(int? postID)
{
var db = new ZkDataContext();
var post = db.ForumPosts.Single(x => x.ForumPostID == postID);
var thread = post.ForumThread;
int threadID = thread.ForumThreadID;
//int index = post.ForumThread.ForumPosts.IndexOf(post);
int page = GetPostPage(post);
db.ForumPosts.DeleteOnSubmit(post);
if (thread.ForumPosts.Count() <= 1 && IsNormalThread(thread)) {
db.ForumThreadLastReads.DeleteAllOnSubmit(db.ForumThreadLastReads.Where(x => x.ForumThreadID == thread.ForumThreadID).ToList());
db.ForumThreads.DeleteOnSubmit(thread);
db.SubmitChanges();
return RedirectToAction("Index");
}
db.SubmitChanges();
ResetThreadLastPostTime(threadID);
return RedirectToAction("Thread", new { id = threadID, page = page });
}
示例8: DeleteResource
public static ReturnValue DeleteResource(string internalName)
{
var db = new ZkDataContext();
var todel = db.Resources.SingleOrDefault(x => x.InternalName == internalName);
if (todel == null) return ReturnValue.ResourceNotFound;
RemoveResourceFiles(todel);
db.Resources.Remove(todel);
db.SubmitChanges();
return ReturnValue.Ok;
}
示例9: Detail
//
// GET: /Battles/
public ActionResult Detail(int id)
{
var db = new ZkDataContext();
var bat = db.SpringBattles.FirstOrDefault(x => x.SpringBattleID == id);
if (bat == null) return Content("No such battle exists");
if (bat.ForumThread != null)
{
bat.ForumThread.UpdateLastRead(Global.AccountID, false);
db.SubmitChanges();
}
return View(bat);
}
示例10: JoinFaction
public ActionResult JoinFaction(int id) {
if (Global.Account.FactionID != null) return Content("Already in faction");
if (Global.Account.Clan != null && Global.Account.Clan.FactionID != id) return Content("Must leave current clan first");
var db = new ZkDataContext();
Account acc = db.Accounts.Single(x => x.AccountID == Global.AccountID);
acc.FactionID = id;
Faction faction = db.Factions.Single(x => x.FactionID == id);
if (faction.IsDeleted && !(Global.Account.Clan != null && Global.Account.Clan.FactionID == id)) throw new ApplicationException("Cannot join deleted faction");
db.Events.InsertOnSubmit(Global.CreateEvent("{0} joins {1}", acc, faction));
db.SubmitChanges();
return RedirectToAction("Index", "Factions");
}
示例11: UndeleteMission
public void UndeleteMission(int missionID, string author, string password)
{
var db = new ZkDataContext();
var prev = db.Missions.Where(x => x.MissionID == missionID).SingleOrDefault();
if (prev != null)
{
var acc = AuthServiceClient.VerifyAccountPlain(author, password);
if (acc == null) throw new ApplicationException("Invalid login name or password");
if (acc.AccountID != prev.AccountID && !acc.IsZeroKAdmin) throw new ApplicationException("You cannot undelete a mission from an other user");
prev.IsDeleted = false;
db.SubmitChanges();
}
else throw new ApplicationException("No such mission found");
}
示例12: Detail
/// <summary>
/// Shows clan page
/// </summary>
/// <returns></returns>
public ActionResult Detail(int id)
{
var db = new ZkDataContext();
var clan = db.Clans.First(x => x.ClanID == id);
if (Global.ClanID == clan.ClanID)
{
if (clan.ForumThread != null)
{
clan.ForumThread.UpdateLastRead(Global.AccountID, false);
db.SubmitChanges();
}
}
return View(clan);
}
示例13: AddBlockedHost
public ActionResult AddBlockedHost(string hostname, string comment)
{
ZkDataContext db = new ZkDataContext();
if (String.IsNullOrWhiteSpace(hostname)) return Content("Hostname cannot be empty");
db.BlockedHosts.InsertOnSubmit(new BlockedHost()
{
HostName = hostname,
Comment = comment,
});
db.SubmitChanges();
var str = string.Format("{0} added new blocked VPN host: {1}", Global.Account.Name, hostname);
Global.Server.GhostChanSay(GlobalConst.ModeratorChannel, str);
return RedirectToAction("BlockedVPNs");
}
示例14: ChangeAccountDeleted
public ActionResult ChangeAccountDeleted(int accountID, bool isDeleted)
{
var db = new ZkDataContext();
Account acc = db.Accounts.Single(x => x.AccountID == accountID);
if (acc.IsDeleted != isDeleted)
{
Global.Nightwatch.Tas.Say(SayPlace.Channel, AuthService.ModeratorChannel, string.Format("Account {0} {1} deletion status changed by {2}", acc.Name, Url.Action("Detail", "Users", new { id = acc.AccountID }, "http"), Global.Account.Name), true);
Global.Nightwatch.Tas.Say(SayPlace.Channel, AuthService.ModeratorChannel, string.Format(" - {0} -> {1}", acc.IsDeleted, isDeleted), true);
acc.IsDeleted = isDeleted;
}
db.SubmitChanges();
return RedirectToAction("Detail", "Users", new { id = acc.AccountID });
}
示例15: ResetThreadLastPostTime
/// <summary>
/// Set the last post time of the thread to current time (includes edits)
/// </summary>
void ResetThreadLastPostTime(int threadID) {
var db = new ZkDataContext();
var thread = db.ForumThreads.FirstOrDefault(x => x.ForumThreadID == threadID);
var lastPost = thread.Created;
foreach (var p in thread.ForumPosts.Reverse())
{
if (p.ForumPostEdits.Count > 0)
{
var lastEdit = p.ForumPostEdits.Last().EditTime;
if (lastEdit > lastPost) lastPost = lastEdit;
} else if (p.Created > lastPost) lastPost = p.Created;
}
thread.LastPost = lastPost;
db.SubmitChanges();
}