コード例 #1
0
        public static void PostReply(int messagebase, string subject, bool anon, int userid, string message, int threadid)
        {
            try
            {
                BBSDataContext bbs = GetContext();

                MessageHeader header = new MessageHeader()
                {
                    MessageBaseId = messagebase, Anonymous = anon, Posted = DateTime.Now, Subject = subject, UserId = userid, MessageThreadId = threadid
                };
                bbs.MessageHeaders.Add(header);
                bbs.SaveChanges();

                MessageBody body = new MessageBody()
                {
                    Body = message, MessageHeaderId = header.MessageHeaderId
                };
                bbs.MessageBodies.Add(body);

                bbs.SaveChanges();
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.PostMessage: " + e.ToString());
            }
        }
コード例 #2
0
        public static bool InitializeDatabase()
        {
            bool           b      = true;
            BBSDataContext bbs    = BBSDataContext.GetContext();
            SysConfig      config = null;

            try
            {
                config = bbs.SysConfigs.First(p => true);
            }
            catch (Exception e)
            {
                //nada
                LoggingAPI.LogEntry("Exception in DBUpdater.InitializeDatabase (Initial config check): " + e.Message);
            }
            if (config == null)
            {
                //Create base config
                config = new SysConfig()
                {
                    DatabaseVersion = 0
                };
                bbs.SysConfigs.Add(config);

                bbs.SaveChanges();

                //Create Sysop User
                User u = new User()
                {
                    Username          = "******",
                    HashedPassword    = "******",
                    LastConnection    = DateTime.Now,
                    LastConnectionIP  = "127.0.0.1",
                    LastDisconnection = DateTime.Now
                };
                bbs.Users.Add(u);
                bbs.SaveChanges();

                //Reload to get id in case it didn't autofill
                u = bbs.Users.FirstOrDefault(p => p.Username.Equals("Six"));

                //Create base bbsconfig
                BBSConfig bconfig = new BBSConfig()
                {
                    SysOpUserId = u.UserId,
                    BBS_Name    = "The Darkside BBS"
                };

                bbs.BBSConfigs.Add(bconfig);

                bbs.SaveChanges();
            }
            return(b);
        }
コード例 #3
0
        public static bool SaveNewUser(string un, string pw, string rn, string em, string co)
        {
            bool b = false;

            try
            {
                string Un = Utils.ToSQL(un);
                string Pw = Utils.ToSQL(pw);
                string Rn = Utils.ToSQL(rn);
                string Em = Utils.ToSQL(em);
                string Co = Utils.ToSQL(co);
                User   u  = new User()
                {
                    Username = Un, HashedPassword = Pw, RealName = Rn, Email = Em, ComputerType = Co, AccessLevel = 0
                };
                u.LastConnection    = DateTime.Now;
                u.LastDisconnection = DateTime.Now;
                BBSDataContext bbs = GetContext();
                bbs.Users.Add(u);
                bbs.SaveChanges();
                b = true;
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.SaveNewUser: " + e.ToString());
                b = false;
            }
            return(b);
        }
コード例 #4
0
        public static void RecordDisconnection(int callLogId)
        {
            BBSDataContext bbs = GetContext();
            CallLog        cl  = bbs.CallLogs.FirstOrDefault(p => p.CallLogId.Equals(callLogId));

            if (cl != null)
            {
                cl.Disconnected = DateTime.Now;
                bbs.SaveChanges();
            }
        }
コード例 #5
0
        public static void UpdateCallLog(int callLogId, int userid) //Used after new user reg
        {
            BBSDataContext bbs = GetContext();
            CallLog        cl  = bbs.CallLogs.FirstOrDefault(p => p.CallLogId.Equals(callLogId));

            if (cl != null)
            {
                cl.UserId = userid;
                bbs.SaveChanges();
            }
        }
コード例 #6
0
        public static int RecordConnection(int userid)
        {
            int            i   = -1;
            BBSDataContext bbs = GetContext();
            CallLog        cl  = new CallLog()
            {
                Connected = DateTime.Now, Disconnected = DateTime.Now, UserId = userid
            };

            bbs.CallLogs.Add(cl);
            bbs.SaveChanges();
            return(i);
        }
コード例 #7
0
 public static void AddGraffiti(string graffiti, int userid)
 {
     try
     {
         BBSDataContext bbs = GetContext();
         Graffiti       g   = new Graffiti()
         {
             Content = graffiti, Posted = DateTime.Now, UserId = userid
         };
         bbs.Graffitis.Add(g);
         bbs.SaveChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.AddGraffiti: " + e.ToString());
     }
 }
コード例 #8
0
 public static void NewFeedback(string subject, string body, int fromuser)
 {
     try
     {
         BBSDataContext bbs = GetContext();
         Feedback       f   = new Feedback()
         {
             Subject = subject, Body = body, FromUser = fromuser, Sent = DateTime.Now
         };
         bbs.Feedbacks.Add(f);
         bbs.SaveChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.NewFeedback: " + e.ToString());
     }
 }
コード例 #9
0
 public static void MarkRead(int userid, int messageid)
 {
     try
     {
         if (!HasRead(userid, messageid))
         {
             BBSDataContext bbs = GetContext();
             UserRead       ur  = new UserRead()
             {
                 UserId = userid, MessageHeaderId = messageid
             };
             bbs.UserReads.Add(ur);
             bbs.SaveChanges();
         }
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.MarkRead(" + userid.ToString() + "," + messageid.ToString() + "):" + e.ToString());
     }
 }
コード例 #10
0
        public static void SaveUserDefinedField(int userid, string key, string value)
        {
            BBSDataContext   bbs = GetContext();
            UserDefinedField udf = bbs.UserDefinedFields.FirstOrDefault(p => p.UserId.Equals(userid) && p.Key.ToUpper().Equals(key.ToUpper()));

            if (udf != null)
            {
                //Modify
                udf.FieldValue = value;
            }
            else
            {
                //New
                udf = new UserDefinedField()
                {
                    Key = key, FieldValue = value, UserId = userid
                };
                bbs.UserDefinedFields.Add(udf);
            }
            bbs.SaveChanges();
        }