• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DataAccess.CSSDataContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Allegiance.CommunitySecuritySystem.DataAccess.CSSDataContext的典型用法代码示例。如果您正苦于以下问题:C# CSSDataContext类的具体用法?C# CSSDataContext怎么用?C# CSSDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSSDataContext类属于Allegiance.CommunitySecuritySystem.DataAccess命名空间,在下文中一共展示了CSSDataContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LoadPlayerDataResponse

        public LoadPlayerDataResponse(LoadPlayerDataRequest playerData)
        {
            using (CSSStatsDataContext statsDB = new CSSStatsDataContext())
            {
                using (CSSDataContext db = new CSSDataContext())
                {
                    var login = Login.FindLoginByUsernameOrCallsign(db, playerData.LoginUsername);

                    if (login == null)
                    {
                        Succeeded = false;
                        ErrorMessage = "Couldn't find player's login user id.";
                        return;
                    }

                    ScoreQueue scoreQueue = statsDB.ScoreQueues.FirstOrDefault(p => p.LoginId == login.Id && p.GameGuid == playerData.GameGuid);

                    if (scoreQueue == null)
                    {
                        statsDB.ScoreQueues.InsertOnSubmit(new ScoreQueue()
                        {
                            LoginId = login.Id,
                            GameGuid = playerData.GameGuid,
                            Score = playerData.Score,
                            PilotBaseKills = playerData.PilotBaseKills,
                            PilotBaseCaptures = playerData.PilotBaseCaptures,
                            WarpsSpotted = playerData.WarpsSpotted,
                            AsteroidsSpotted = playerData.AsteroidsSpotted,
                            MinerKills = playerData.MinerKills,
                            BuilderKills = playerData.BuilderKills,
                            LayerKills = playerData.LayerKills,
                            CarrierKills = playerData.CarrierKills,
                            PlayerKills = playerData.PlayerKills,
                            BaseKills = playerData.BaseKills,
                            BaseCaptures = playerData.BaseCaptures,
                            TechsRecovered = playerData.TechsRecovered,
                            Flags = playerData.Flags,
                            Artifacts = playerData.Artifacts,
                            Rescues = playerData.Rescues,
                            Kills = playerData.Kills,
                            Assists = playerData.Assists,
                            Deaths = playerData.Deaths,
                            Ejections = playerData.Ejections,
                            Win = playerData.Win,
                            Lose = playerData.Lose,
                            CommandWin = playerData.CommandWin,
                            CommandLose = playerData.CommandLose,
                            TimePlayed = playerData.TimePlayed,
                            TimeCommanded = playerData.TimeCommanded,
                            CommandCredit = playerData.CommandCredit,
                            CombatRating = playerData.CombatRating
                        });
                    }

                    statsDB.SubmitChanges();
                }
            }

            this.Succeeded = true;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:60,代码来源:LoadPlayerDataResponse.cs


示例2: 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


示例3: 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


示例4: Handle

        public static bool Handle(HttpContext context, int lobbyId, string filename)
        {
            using (var db = new CSSDataContext())
            {
                if (filename.Contains(".."))
                    throw new Exception("Could not load path.");

                var lobby       = db.Lobbies.Single(p => p.IsEnabled && p.Id == lobbyId);
                var filepath    = Path.Combine(lobby.BasePath, filename);

                //If file is not found, attempt to send file from the default path
                var info = new FileInfo(filepath);

                if (!info.Exists)
                {
                    filepath    = Path.Combine(ConfigurationManager.AppSettings["DefaultLobbyPath"], filename);
                    info        = new FileInfo(filepath);

                    if (!info.Exists)
                        throw new FileNotFoundException();
                }

                //Transmit the file
                context.Response.Clear();
                context.Response.ContentType = "application/octet-stream";
                context.Response.AddHeader("Content-Length", info.Length.ToString());
                context.Response.AddHeader("Content-Disposition",
                    string.Format("attachment; filename=\"{0}\"",
                    Path.GetFileName(filename)));
                context.Response.TransmitFile(filepath);
            }

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


示例5: cvCaptcha_ServerValidate

        protected void cvCaptcha_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool isValid = false;

            if (ViewState["captchaToken"] != null)
            {
                Guid captchaToken = (Guid)ViewState["captchaToken"];
                using (CSSDataContext db = new CSSDataContext())
                {
                    var captcha = db.Captchas.FirstOrDefault(p => p.Id == captchaToken);

                    //args.Value
                    //CustomValidator cvCaptcha = (CustomValidator)source;
                    //TextBox txtValidationCode = (TextBox) cvCaptcha.ControlToValidate;
                    if (captcha != null && args.Value.Equals(captcha.Answer, StringComparison.InvariantCultureIgnoreCase) == true)
                    {
                        isValid = true;
                    }
                }
            }

            if (isValid == false)
                ViewState["captchaToken"] = null;

            args.IsValid = isValid;
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:26,代码来源:CreateUser.aspx.cs


示例6: CreateUser

        public static void CreateUser(string user, string password, string email)
        {
            using (var db = new CSSDataContext())
            {
                var identity = new Identity()
                {
                    DateLastLogin = DateTime.Now,
                    LastGlobalMessageDelivery = DateTime.Now
                };

                var login = new Login()
                {
                    Username    = user,
                    Password    = Hash(password),
                    Email       = email,
                    DateCreated = DateTime.Now,
                };

                var alias = new Alias()
                {
                    Callsign    = user,
                    DateCreated = DateTime.Now,
                    IsDefault   = true,
                    IsActive = true
                };

                login.Aliases.Add(alias);
                identity.Logins.Add(login);
                login.Lobby_Logins.Add(new Lobby_Login() { Lobby = db.Lobbies.First(p => p.Name == "Production") });

                db.Identities.InsertOnSubmit(identity);
                db.SubmitChanges();
            }
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:34,代码来源:Test.cs


示例7: 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


示例8: 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


示例9: 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


示例10: Verify

        /// <summary>
        /// Calls BlackboxServer module to verify login and retrieve blackbox information.
        /// </summary>
        internal LoginResult Verify(bool useDebugBlackbox)
        {
            byte[] data;

            var alias   = Alias;

            string ipAddress = "127.0.0.1";
            if (HttpContext.Current != null)
                ipAddress = HttpContext.Current.Request.UserHostAddress;

            var result = Validation.CreateSession(ipAddress, Username, Password, LobbyId, useDebugBlackbox, ref alias, out data);

            int rank = 0;

            using (CSSDataContext db = new CSSDataContext())
            {
                var rankDetail = DataAccess.Alias.GetRankForCallsign(db, alias);
                if (rankDetail != null)
                    rank = (int)rankDetail.Rank;
            }

            return new LoginResult()
            {
                Status          = result,
                BlackboxData    = data,
                AcceptedAlias   = alias,
                Rank			= rank
            };
        }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:32,代码来源:LoginData.cs


示例11: BindData

 private void BindData()
 {
     using (CSSDataContext db = new CSSDataContext())
     {
         gvPolls.DataSource = db.Polls.OrderByDescending(p => p.DateExpires);
         gvPolls.DataBind();
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:8,代码来源:Default.aspx.cs


示例12: 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


示例13: 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


示例14: ListBans

 internal static List<Ban> ListBans(string alias)
 {
     using (var db = new CSSDataContext())
     {
         var login = Login.FindLoginByUsernameOrCallsign(db, alias);
         return login.Identity.Bans.ToList();
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:8,代码来源:BanData.cs


示例15: FindLoginByUsernameOrCallsign

        public static Login FindLoginByUsernameOrCallsign(CSSDataContext db, string usernameOrCallsign)
        {
            var login = FindLoginByUsername(db, usernameOrCallsign);

            if (login == null)
                login = FindLoginByCallsign(db, usernameOrCallsign);

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


示例16: 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


示例17: MyClassInitialize

 public static void MyClassInitialize(TestContext testContext)
 {
     using (var db = new CSSDataContext())
     {
         if (db.DatabaseExists() == false)
         {
             db.CreateDatabase();
         }
     }
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:10,代码来源:TaskTest.cs


示例18: GetAllFromCache

 public static List<Login_UnlinkedLogin> GetAllFromCache()
 {
     return CacheManager<List<Login_UnlinkedLogin>>.Get("DataAccessIdentity::AreIdentitiesPermanentlyUnlinked:Login_UnlinkedLogins", CacheSeconds.TenSeconds, delegate()
     {
         using (CSSDataContext db = new CSSDataContext())
         {
             return db.Login_UnlinkedLogins.ToList();
         }
     });
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:10,代码来源:Login_UnlinkedLogin.cs


示例19: 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


示例20: GetAllFromCache

 public static List<Login> GetAllFromCache()
 {
     return CacheManager<List<Login>>.Get("Login::GetAll()", CacheSeconds.TenSeconds, delegate()
     {
         using (CSSDataContext db = new CSSDataContext())
         {
             return db.Logins.ToList();
         }
     });
 }
开发者ID:LordBlacksun,项目名称:Allegiance-Community-Security-System,代码行数:10,代码来源:Login.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Model.Beat类代码示例发布时间:2022-05-24
下一篇:
C# WinShooterServerRemoting.Structs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap