本文整理汇总了C#中Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext.SubmitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# CSSDataContext.SubmitChanges方法的具体用法?C# CSSDataContext.SubmitChanges怎么用?C# CSSDataContext.SubmitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext
的用法示例。
在下文中一共展示了CSSDataContext.SubmitChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSaveNewGroup_Click
protected void btnSaveNewGroup_Click(object sender, EventArgs e)
{
using(CSSDataContext db = new CSSDataContext())
{
if (db.Groups.FirstOrDefault(p => p.Name == txtName.Text.Trim()) != null)
{
lblErrorText.Text = "The group or squad name you specified: " + txtName.Text + " already exists.";
return;
}
if (db.Groups.FirstOrDefault(p => p.Tag == txtTag.Text.Trim()) != null)
{
lblErrorText.Text = "The tag name you specified: " + txtTag.Text + " already exists.";
return;
}
db.Groups.InsertOnSubmit(new Group()
{
Name = txtName.Text.Trim(),
DateCreated = DateTime.Now,
IsSquad = chkIsSquad.Checked,
Tag = txtTag.Text
});
db.SubmitChanges();
this.DataBind();
}
}
示例2: TestCheckForUpdates
public void TestCheckForUpdates()
{
int lobbyId = 0;
using (var db = new CSSDataContext())
{
//Create autoupdate files
var file = new AutoUpdateFile() { Filename = "mdl", IsProtected = true };
db.AutoUpdateFiles.InsertOnSubmit(file);
var lobby = db.Lobbies.FirstOrDefault();
lobbyId = lobby.Id;
file.AutoUpdateFile_Lobbies.Add(new AutoUpdateFile_Lobby()
{
CurrentVersion = "1.0",
DateCreated = DateTime.Now,
DateModified = DateTime.Now,
Lobby = lobby,
ValidChecksum = "VALID"
});
db.SubmitChanges();
}
var clientService = new ClientService();
var files = clientService.CheckForUpdates(lobbyId);
var fileResult = files.Files.FirstOrDefault();
Assert.AreEqual(1, files.Files.Count);
Assert.IsTrue(fileResult.IsProtected);
Assert.AreEqual("mdl", fileResult.Filename);
Assert.AreEqual("VALID", fileResult.ValidChecksum.Trim());
Assert.AreEqual("1.0", fileResult.CurrentVersion);
Assert.AreEqual(lobbyId, fileResult.LobbyId);
}
示例3: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
using(CSSDataContext db = new CSSDataContext())
{
// If the page loaded, then don't worry about the date at this point, they'll get a free ride if
// they camped on the page for a while. The date is just to keep the enemy from getting a hold
// of an old email and coming back in with it.
var logins = db.Logins.Where(p => p.PasswordResetGuid == new Guid(Request.Params["resetGuid"]));
foreach(var login in logins)
{
CssMembershipProvider cssMembershipProvider = new CssMembershipProvider();
string tempPassword = cssMembershipProvider.ResetPassword(login.Username, null);
cssMembershipProvider.ChangePassword(login.Username, tempPassword, txtPassword.Text);
}
db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, logins);
foreach (var login in logins)
{
// Keep anyone from reusing an old password reset mail.
login.PasswordResetGuid = Guid.Empty;
}
db.SubmitChanges();
}
divResetPassword.Visible = false;
divResetSuccess.Visible = true;
}
示例4: Write
public static bool Write(CSSDataContext db, LogType type, string message, bool submit)
{
try
{
db.Logs.InsertOnSubmit(new Log()
{
DateOccurred = DateTime.Now,
Message = message,
Type = (byte)type
});
if (submit)
db.SubmitChanges();
Console.WriteLine(String.Format("{0}: {1} {2}", DateTime.Now, type.ToString(), message));
return true;
}
catch(Exception error)
{
var errorMessage = new StringBuilder()
.AppendLine("Failed to write data to log:")
.Append("Type: ").AppendLine(type.ToString())
.Append("Message: ").AppendLine(message);
Debug.WriteLine(errorMessage);
Error.Write(db, new Exception(errorMessage.ToString(), error), submit);
return false;
}
}
示例5: GetGroupMessages
public static List<IMessage> GetGroupMessages(CSSDataContext db, string callsign)
{
var messages = new List<IMessage>();
var aliases = Alias.ListAliases(db, callsign);
foreach (var alias in aliases)
{
messages.AddRange(
alias.GroupMessage_Alias.Where(p => p.DateViewed == null).Select(p => (IMessage) p.GroupMessage).ToList()
);
//messages.AddRange(alias.GroupMessages
// .Where(
// p => p.DateExpires <= DateTime.Now
// && p.DateToSend >= DateTime.Now
// && p.GroupMessage_Alias
// .FirstOrDefault(r => r.Alias == alias && r.DateViewed == null) != null)
// .Select(q => (IMessage)q).ToList());
foreach (var gma in alias.GroupMessage_Alias.Where(p => p.DateViewed == null && messages.Select(q => q.Id).Contains(p.GroupMessageId)))
{
//if (messages.FirstOrDefault(p => p.Id == gma.GroupMessageId) != null)
gma.DateViewed = DateTime.Now;
}
db.SubmitChanges();
}
return messages;
}
示例6: Clean
public static void Clean()
{
using (var db = new CSSDataContext())
{
db.Logs.DeleteAllOnSubmit(db.Logs.Where(p => p.DateOccurred < DateTime.Now.AddDays(-30)));
db.SubmitChanges();
}
}
示例7: Clean
public static void Clean()
{
using (var db = new CSSDataContext())
{
db.LogIPs.DeleteAllOnSubmit(db.LogIPs.Where(p => p.LastAccessed < DateTime.Now.AddDays(-180)));
db.SubmitChanges();
}
}
示例8: GenerateBlackbox
internal static ActiveKey GenerateBlackbox(CSSDataContext db, bool debugMode)
{
var key = Compiler.Build(debugMode);
db.ActiveKeys.InsertOnSubmit(key);
db.SubmitChanges();
return key;
}
示例9: RemoveExpiredCaptchas
public static void RemoveExpiredCaptchas()
{
using (CSSDataContext db = new CSSDataContext())
{
var timeout = DateTime.Now.AddSeconds(-CaptchaExpirationTimeInSeconds);
var oldCaptchas = db.Captchas.Where(p => p.DateCreated < timeout);
db.Captchas.DeleteAllOnSubmit(oldCaptchas);
db.SubmitChanges();
}
}
示例10: btnRecalculatePoll_Click
protected void btnRecalculatePoll_Click(object sender, EventArgs e)
{
using (CSSDataContext db = new CSSDataContext())
{
var poll = db.Polls.FirstOrDefault(p => p.Id == PollID);
poll.Recalculate();
db.SubmitChanges();
}
BindData();
}
示例11: CreateGroup
public static void CreateGroup(CSSDataContext db, string name, bool isSquad, string tag)
{
var g = new Group()
{
DateCreated = DateTime.Now,
Name = name,
IsSquad = isSquad,
Tag = tag
};
db.Groups.InsertOnSubmit(g);
db.SubmitChanges();
}
示例12: AddAlias
public static void AddAlias(CSSDataContext db, string groupName, string alias)
{
var add = new Group_Alias_GroupRole()
{
AliasId = db.Alias.FirstOrDefault(a => a.Callsign == alias).Id,
GroupId = db.Groups.FirstOrDefault(g => g.Name == groupName).Id,
GroupRoleId = db.GroupRoles.FirstOrDefault(gr => gr.Name == "Member").Id //default to member
};
//TODO: Check for condition where alias is already in group
db.Group_Alias_GroupRoles.InsertOnSubmit(add);
db.SubmitChanges();
}
示例13: btnDeleteMessage_Click
protected void btnDeleteMessage_Click(object sender, EventArgs e)
{
int globalMessageID;
if(Int32.TryParse(txtGlobalMessageID.Value, out globalMessageID) == true)
{
using (CSSDataContext db = new CSSDataContext())
{
db.GroupMessages.DeleteAllOnSubmit(db.GroupMessages.Where(p => p.Id == globalMessageID));
db.SubmitChanges();
}
}
BindData();
}
示例14: Execute
public void Execute()
{
using (var db = new CSSDataContext())
{
db.Sessions.DeleteAllOnSubmit(db.Sessions);
db.UsedKeys.DeleteAllOnSubmit(db.UsedKeys);
db.ActiveKeys.DeleteAllOnSubmit(db.ActiveKeys);
db.TransformMethods.DeleteAllOnSubmit(db.TransformMethods);
db.SubmitChanges();
Allegiance.CommunitySecuritySystem.TransformMethodGenerator.Task.Execute(10, 10);
Assert.AreEqual(10, db.TransformMethods.Count());
}
}
示例15: GetPrivateMessages
public static List<IMessage> GetPrivateMessages(CSSDataContext db, string alias)
{
var id = Login.FindLoginByUsernameOrCallsign(db, alias).Id;
var messages = db.PersonalMessages
.Where(pm => pm.LoginId == id && pm.DateViewed == null
&& pm.DateToSend < DateTime.Now).ToList();
foreach (var msg in messages)
msg.DateViewed = DateTime.Now;
db.SubmitChanges();
//return messages.Select(p => p as BaseMessage).ToList();
return messages.Select(p => p as IMessage).ToList();
}