Esempio n. 1
0
        public void PostReply(int messagebase, string subject, bool anon, int userid, string message, int threadid)
        {
            try
            {
                BBSDataDataContext bbs = GetDataContext();

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

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

                bbs.SubmitChanges();
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.PostMessage: " + e.ToString());
            }
        }
Esempio n. 2
0
        public 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;
                BBSDataDataContext bbs = GetDataContext();
                bbs.Users.InsertOnSubmit(u);
                bbs.SubmitChanges();
                b = true;
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.SaveNewUser: " + e.ToString());
                b = false;
            }
            return(b);
        }
Esempio n. 3
0
        public void RecordDisconnection(int callLogId)
        {
            BBSDataDataContext bbs = GetDataContext();
            CallLog            cl  = bbs.CallLogs.FirstOrDefault(p => p.CallLogId.Equals(callLogId));

            if (cl != null)
            {
                cl.Disconnected = DateTime.Now;
                bbs.SubmitChanges();
            }
        }
Esempio n. 4
0
        public void UpdateCallLog(int callLogId, int userid) //Used after new user reg
        {
            BBSDataDataContext bbs = GetDataContext();
            CallLog            cl  = bbs.CallLogs.FirstOrDefault(p => p.CallLogId.Equals(callLogId));

            if (cl != null)
            {
                cl.UserId = userid;
                bbs.SubmitChanges();
            }
        }
Esempio n. 5
0
 public void UploadedFile(UDFile udf)
 {
     try
     {
         BBSDataDataContext bbs = GetDataContext();
         bbs.UDFiles.InsertOnSubmit(udf);
         bbs.SubmitChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.UploadedFile(" + udf.Filename + ", " + udf.Description + "): " + e.ToString());
     }
 }
Esempio n. 6
0
        public int RecordConnection(int userid)
        {
            int i = -1;
            BBSDataDataContext bbs = GetDataContext();
            CallLog            cl  = new CallLog()
            {
                Connected = DateTime.Now, Disconnected = DateTime.Now, UserId = userid
            };

            bbs.CallLogs.InsertOnSubmit(cl);
            bbs.SubmitChanges();
            return(i);
        }
Esempio n. 7
0
 public void AddGraffiti(string graffiti, int userid)
 {
     try
     {
         BBSDataDataContext bbs = GetDataContext();
         Graffiti           g   = new Graffiti()
         {
             Content = graffiti, Posted = DateTime.Now, UserId = userid
         };
         bbs.Graffitis.InsertOnSubmit(g);
         bbs.SubmitChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.AddGraffiti: " + e.ToString());
     }
 }
Esempio n. 8
0
 public void NewFeedback(string subject, string body, int fromuser)
 {
     try
     {
         BBSDataDataContext bbs = GetDataContext();
         Feedback           f   = new Feedback()
         {
             Subject = subject, Body = body, FromUser = fromuser, Sent = DateTime.Now
         };
         bbs.Feedbacks.InsertOnSubmit(f);
         bbs.SubmitChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.Error("Exception", e);
     }
 }
Esempio n. 9
0
 public void MarkRead(int userid, int messageid)
 {
     try
     {
         if (!HasRead(userid, messageid))
         {
             BBSDataDataContext bbs = GetDataContext();
             UserRead           ur  = new UserRead()
             {
                 UserId = userid, MessageHeaderId = messageid
             };
             bbs.UserReads.InsertOnSubmit(ur);
             bbs.SubmitChanges();
         }
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.MarkRead(" + userid.ToString() + "," + messageid.ToString() + "):" + e.ToString());
     }
 }
Esempio n. 10
0
        public void SaveUserDefinedField(int userid, string key, string value)
        {
            BBSDataDataContext bbs = GetDataContext();
            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.InsertOnSubmit(udf);
            }
            bbs.SubmitChanges();
        }
Esempio n. 11
0
        public bool AddGFile(int areaid, string title, string filename, string description, bool PETSCII)
        {
            //filename must include relative path from bbs
            //determines file size on its own
            //Will not allow re-add of the same filename to the same area
            bool b = false;

            try
            {
                if (!GFileExistsInArea(areaid, filename))
                {
                    if (File.Exists(filename))
                    {
                        GFileDetail gfd = new GFileDetail()
                        {
                            GFileAreaId     = areaid,
                            Filename        = filename,
                            Added           = DateTime.Now,
                            DisplayFilename = title,
                            Description     = description,
                            PETSCII         = PETSCII,
                            FileSizeInBytes = (int)(new FileInfo(filename).Length)
                        };
                        BBSDataDataContext bbs = GetDataContext();
                        bbs.GFileDetails.InsertOnSubmit(gfd);
                        bbs.SubmitChanges();
                        b = true;
                    }
                }
            }
            catch (Exception e)
            {
                b = false;
                LoggingAPI.LogEntry("Exception in DataInterface.AddGFile: " + e);
            }
            return(b);
        }