当前位置: 首页>>代码示例>>C#>>正文


C# CSSDataContext.SubmitChanges方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:29,代码来源:Default.aspx.cs

示例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);
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:35,代码来源:AutoUpdateTest.cs

示例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;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:32,代码来源:ResetPassword.aspx.cs

示例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;
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:31,代码来源:Log.cs

示例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;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:30,代码来源:GroupMessage.cs

示例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();
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:8,代码来源:Log.cs

示例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();
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:8,代码来源:LogIP.cs

示例8: GenerateBlackbox

        internal static ActiveKey GenerateBlackbox(CSSDataContext db, bool debugMode)
        {
            var key = Compiler.Build(debugMode);

            db.ActiveKeys.InsertOnSubmit(key);
            db.SubmitChanges();

            return key;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:9,代码来源:Task.cs

示例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();
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:10,代码来源:Captcha.cs

示例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();
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:12,代码来源:EditPoll.aspx.cs

示例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();
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:12,代码来源:Group.cs

示例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();
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:13,代码来源:Group.cs

示例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();
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:14,代码来源:GlobalMessage.aspx.cs

示例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());
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:15,代码来源:TaskTest.cs

示例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();
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:15,代码来源:PersonalMessage.cs


注:本文中的Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext.SubmitChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。