Exemple #1
0
        public bool AddPFileDetail(int areaId, string filePath, string fileName, string title, string description)
        {
            //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 (!PFileExistsInArea(areaId, fileName))
                {
                    if (File.Exists(filePath + fileName))
                    {
                        PFileDetail pfd = new PFileDetail()
                        {
                            PFileAreaId = areaId,
                            Filename    = fileName,
                            FilePath    = filePath,
                            Title       = title,
                            Description = description
                        };
                        _bbsDataContext.PFileDetails.Add(pfd);
                        _bbsDataContext.SaveChanges();
                        b = true;
                    }
                }
            }
            catch (Exception e)
            {
                b = false;
                LoggingAPI.LogEntry("Exception in DataInterface.AddGFile: " + e);
            }
            return(b);
        }
Exemple #2
0
        //Start new thread
        public void PostMessage(int messagebase, string subject, bool anon, int userid, string message)
        {
            try
            {
                //MessageThread thread = new MessageThread() { MessageBaseId = messagebase, MessageHeaderId = -1 };
                //_bbsDataContext.MessageThreads.Add(thread);
                //_bbsDataContext.SaveChanges();

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

                //thread.MessageHeaderId = header.Id;
                //_bbsDataContext.SaveChanges();

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

                //_bbsDataContext.SaveChanges();
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.PostMessage: " + e.ToString());
            }
        }
Exemple #3
0
        public List <Dictionary <string, string> > GetLast10()
        {
            List <Dictionary <string, string> > glist = new List <Dictionary <string, string> >();

            try
            {
                BBSDataDataContext bbs = GetDataContext();
                var gl2 = bbs.CallLogs.OrderByDescending(p => p.Connected).Take(10)
                          .Join(bbs.Users, g => g.UserId, u => u.UserId, (g, u) => new { connected = g.Connected, user = u.Username })
                          .ToList();

                foreach (var gl in gl2)
                {
                    Dictionary <string, string> d = new Dictionary <string, string>
                    {
                        { "when", gl.connected.ToString("yyyy-MM-dd hh:mm") },
                        { "user", gl.user }
                    };
                    glist.Add(d);
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.GetLast10: " + e.ToString());
            }
            return(glist);
        }
Exemple #4
0
 private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             //which row is highlighted
             foreach (DataGridViewRow row in dataGridView1.SelectedRows)
             {
                 int         id = int.Parse(row.Cells[1].Value.ToString());
                 StateObject so = testserv.connectedSocks.FirstOrDefault(p => p.GetHashCode().Equals(id));
                 if (so != null)
                 {
                     testserv.Disconnect(so);
                 }
                 BBS bbs = bbs_instances.FirstOrDefault(p => p.GetHashCode().Equals(id));
                 bbs_instances.Remove(bbs);
             }
         }
     }
     catch (Exception ex)
     {
         LoggingAPI.LogEntry(ex.Message);
     }
 }
Exemple #5
0
 private void RefreshGrid()
 {
     if (this.dataGridView1.InvokeRequired)
     {
         GenericCallback d = new GenericCallback(RefreshGrid);
         this.Invoke(d);
     }
     else
     {
         try
         {
             dataGridView1.Rows.Clear();
             int i = 0;
             foreach (BBS bbs in bbs_instances)
             {
                 if (bbs.CurrentUser != null)
                 {
                     dataGridView1.Rows.Add(i, bbs.State_Object.GetHashCode(), bbs.State_Object.workSocket.RemoteEndPoint.ToString(), bbs.CurrentUser.Username, bbs.CurrentArea, (DateTime.Now.Subtract(bbs.ConnectionTimeStamp).ToString()));
                 }
                 else
                 {
                     dataGridView1.Rows.Add(i, bbs.State_Object.GetHashCode(), bbs.State_Object.workSocket.RemoteEndPoint.ToString(), "Pending Login", "Login", (DateTime.Now.Subtract(bbs.ConnectionTimeStamp).ToString()));
                 }
                 i++;
             }
             Application.DoEvents();
         }
         catch (Exception ex)
         {
             LoggingAPI.LogEntry(ex.Message);
         }
     }
 }
Exemple #6
0
        public List <AreaListRow> GFileListArea(int?area, int userid)
        {
            //List all files and areas in the current area
            var response = new List <AreaListRow>();

            try
            {
                //User u = GetUserById(userid);
                //User must have at least one access group that matches the gfile area
                List <GFileArea>   gfileAreas   = _bbsDataContext.GFileAreas.Where(p => p.ParentAreaId == area).ToList();
                List <GFileDetail> gfileDetails = _bbsDataContext.GFileDetails.Where(p => p.GFileAreaId == area).ToList();
                int listId = 1;
                foreach (GFileArea gfileArea in gfileAreas)
                {
                    listId++;
                    response.Add(new AreaListRow(gfileArea, listId, AreaListRowType.Area));
                }
                foreach (GFileDetail gfileDetail in gfileDetails)
                {
                    listId++;
                    response.Add(new AreaListRow(gfileDetail, listId, AreaListRowType.Entry));
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.GFile_List_Area(" + area.ToString() + ") : " + e.Message);
            }
            return(response);
        }
        public List <Tuple <string, string> > GetGraffiti()
        {
            var glist = new List <Tuple <string, string> >();

            try
            {
                var graffitis = _bbsDataContext.Graffiti.OrderByDescending(p => p.Posted).Take(10).ToList();
                foreach (var graffiti in graffitis)
                {
                    if (graffiti.User == null)
                    {
                        var user = GetUserById(graffiti.UserId);
                        if (user != null)
                        {
                            glist.Add(new Tuple <string, string>(user.Username, graffiti.Content));
                        }
                    }
                    else
                    {
                        glist.Add(new Tuple <string, string>(graffiti.User.Username, graffiti.Content));
                    }
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.GetGraffiti: " + e.ToString());
            }
            return(glist);
        }
Exemple #8
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());
            }
        }
Exemple #9
0
        public List <Dictionary <string, string> > GetGraffiti()
        {
            List <Dictionary <string, string> > glist = new List <Dictionary <string, string> >();

            try
            {
                BBSDataDataContext bbs = GetDataContext();
                var gl2 = bbs.Graffitis.OrderByDescending(p => p.Posted).Take(10)
                          .Join(bbs.Users, g => g.UserId, u => u.UserId, (g, u) => new { graf = g.Content, posted = g.Posted, user = u.Username })
                          .ToList();

                foreach (var gl in gl2)
                {
                    Dictionary <string, string> d = new Dictionary <string, string>
                    {
                        { "graf", gl.graf },
                        { "user", gl.user }
                    };
                    glist.Add(d);
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.GetGraffiti: " + e.ToString());
            }
            return(glist);
        }
Exemple #10
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);
        }
Exemple #11
0
        public static int FirstUnread(int userid, List <int> messageids)
        {
            int i = -1;

            if (messageids != null)
            {
                if (messageids.Count > 0)
                {
                    try
                    {
                        BBSDataContext bbs = GetContext();
                        i = messageids.FirstOrDefault(q => !(
                                                          bbs.UserReads.Where(p => p.UserId.Equals(userid)).Select(r => r.MessageHeaderId).Contains(q))
                                                      );
                        if (i == null)
                        {
                            i = -1;
                        }
                    }
                    catch (Exception e)
                    {
                        LoggingAPI.LogEntry("Exception in DataInterface.FirstUnread(" + userid.ToString() + ",LIST):" + e.ToString());
                    }
                }
            }
            return(i);
        }
Exemple #12
0
        public IdAndKeys MessageBase_ParentArea(int area)
        {
            IdAndKeys idak = new IdAndKeys()
            {
                Id = -1
            };

            idak.Keys.Add("title", "Main");
            try
            {
                BBSDataDataContext bbs = GetDataContext();
                MessageBaseArea    gfa = bbs.MessageBaseAreas.FirstOrDefault(p => p.MessageBaseAreaId.Equals(area));
                if (gfa != null)
                {
                    idak.Id = gfa.ParentAreaId;
                    if (gfa.ParentAreaId == -1)
                    {
                        idak.Keys["title"] = "Main";
                    }
                    else
                    {
                        idak.Keys["title"] = gfa.Title;
                    }
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.MessageBase_ParentArea: " + e.Message);
            }
            return(idak);
        }
Exemple #13
0
 private void CMD_OLM(string command)
 {
     try
     {
         //What userid and what message?
         int    messagebegins = command.IndexOf(' ', 4);
         string user          = command.Substring(3, messagebegins - 3);
         int    userid        = int.Parse(user);
         string message       = command.Substring(messagebegins, command.Length - messagebegins);
         foreach (BBS bbs2 in _bbs._bbsHost.GetAllNodes())
         {
             if (bbs2.CurrentUser.Id.Equals(userid))
             {
                 if (bbs2.doNotDisturb)
                 {
                     _bbs.WriteLine("~l1~d2That user is currently in DND mode.~d0");
                 }
                 else
                 {
                     bbs2._messageQueue.Add("~l1~c4OLM>~c7" + _bbs.CurrentUser.Username + "~c2:~c1" + message);
                     _bbs.WriteLine("~l1~c9Your message was delivered.");
                 }
             }
         }
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in Main.CMD_OLM: " + e);
     }
 }
Exemple #14
0
///
/// Decription: Open a listener socket and wait for a connection.
///
        private void StartListening()
        {
            // Establish the local endpoint for the socket.
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, this.portNumber);
            // Create a TCP/IP socket.
            Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            // Bind the socket to the local endpoint and listen for incoming connections.
            try
            {
                listener.Bind(localEndPoint);
                listener.Listen(1000);
                while (!ShuttingDown)
                {
                    // Set the event to nonsignaled state.
                    allDone.Reset();
                    // Start an asynchronous socket to listen for connections.

                    listener.BeginAccept(new AsyncCallback(this.AcceptCallback), listener);

                    // Wait until a connection is made before continuing.
                    allDone.WaitOne();
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in Server.StartListening: " + e.Message);
                threadEnd[0].Set();
            }
        }
Exemple #15
0
        public ITerminalType Detect()
        {
            ITerminalType termtype = new TermType_Default();

            try
            {
                bool detected = false;
                while ((!detected) && Host_System.Connected)
                {
                    Host_System.Write("\x93\x0cHit Delete:");
                    char c = Host_System.GetChar();
                    if ((c == 8))
                    {
                        Host_System.WriteLine("ASCII/ANSI Detected");
                        Host_System.Write("ANSI Color? ");
                        bool b = Host_System.YesNo(true, true);
                        if (b)
                        {
                            termtype = new TermType_ANSI();
                            detected = true;
                        }
                        else
                        {
                            termtype = new TermType_Default();
                            detected = true;
                        }
                    }
                    else
                    {
                        if (c == '\x14')
                        {
                            termtype = new TermType_PETSCII40();
                            Host_System.WriteRaw("\x1cp" + "\x81" + "e\x9et" + "\x99s" + "\x9a" + "c\x9c" + "i\x1ci \x05" + "dETECTED\x02!\x05");
                            detected = true;
                        }
                        else
                        {
                            if (c == 127)
                            {
                                Host_System.WriteRaw("\x1b[1;31mA\x1b[1;32mN\x1b[1;33mS\x1b[1;34mI\x1b[1;37m Detected");
                                termtype = new TermType_ANSI();
                                detected = true;
                            }
                            else
                            {
                                Host_System.WriteLine(((int)c).ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in TermDetect.Detect: " + e.Message);
            }
            return(termtype);
        }
Exemple #16
0
        public bool Application()
        {
            var result = false;

            //var quitflag = false;
            try
            {
                //Show new user file
                _bbs.SendFileForTermType("NewUser", true);
                if (!GetUsername())
                {
                    return(false);
                }
                if (!GetPassword())
                {
                    return(false);
                }
                RealName = GetField("Real Name", "~l2~cbEnter your real name.", 0);
                if (RealName == null)
                {
                    return(false);
                }
                Email = GetField("Email", "~l2~cbEnter your email address.", 0);
                if (Email == null)
                {
                    return(false);
                }
                ComputerType = GetField("Computer", "~l2~cbEnter your computer model.", 0);
                if (ComputerType == null)
                {
                    return(false);
                }
                var user = _bbsDataCore.SaveNewUser(Username, Password, RealName, Email, ComputerType, _bbs._remoteAddress, "");
                if (user != null)
                {
                    _bbs.currentUser = user;
                }

                //New User feedback
                _bbs.Write("~l2~cbLeave an introduction message?");
                if (_bbs.YesNo(true, true))
                {
                    var lineEditor = new Line_Editor(_bbs);
                    if (lineEditor.Edit(null))
                    {
                        _bbsDataCore.NewFeedback("New User Feedback", lineEditor.GetMessage(), _bbs.currentUser.Id);
                    }
                }
                //And Done
                result = true;
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in NewUser.Application: " + e.ToString());
            }
            return(result);
        }
Exemple #17
0
        static void Go(string[] args)
        {
            NetworkStream stream;
            TcpClient     irc;
            string        inputLine;
            StreamReader  reader;

            //string nickname;
            try
            {
                irc    = new TcpClient(SERVER, PORT);
                stream = irc.GetStream();
                reader = new StreamReader(stream);
                writer = new StreamWriter(stream);
                // Start PingSender thread
                PingSender ping = new PingSender();
                ping.Start();
                writer.WriteLine(USER);
                writer.Flush();
                writer.WriteLine("NICK " + NICK);
                writer.Flush();
                writer.WriteLine("JOIN " + CHANNEL);
                writer.Flush();
                while (true)
                {
                    while ((inputLine = reader.ReadLine()) != null)
                    {
                        //if (inputLine.EndsWith("JOIN :" + CHANNEL))
                        //{
                        //    // Parse nickname of person who joined the channel
                        //    nickname = inputLine.Substring(1, inputLine.IndexOf("!") - 1);
                        //    // Welcome the nickname to channel by sending a notice
                        //    writer.WriteLine("NOTICE " + nickname + " :Hi " + nickname +
                        //    " and welcome to " + CHANNEL + " channel!");
                        //    writer.Flush();
                        //    // Sleep to prevent excess flood
                        //    Thread.Sleep(2000);
                        //}
                    }
                    // Close all streams
                    writer.Close();
                    reader.Close();
                    irc.Close();
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in Main.MainPrompt: " + e);
                // Show the exception, sleep for a while and try to establish a new connection to irc server
                //Console.WriteLine(e.ToString());
                //Thread.Sleep(5000);
                //string[] argv = { };
                //Main(argv);
            }
        }
Exemple #18
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);
        }
Exemple #19
0
 public void AddConnection(StateObject so)
 {
     try
     {
         StartBBS(so);
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in MainForm.AddConnection: " + e.Message);
     }
 }
Exemple #20
0
        public static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine("SixNet BBS, Starting up...");
            _bbsDatabaseConfiguration = BBSDatabaseConfiguration.LoadConfig("./");
            if (_bbsDatabaseConfiguration == null)
            {
                Console.WriteLine("Run setup utility first.");
                return;
            }
            _connectionString = BBSDatabaseConfiguration.BuildConnectionString(_bbsDatabaseConfiguration);
            LoggingAPI.Init("./Logs/");
            if (BBSDatabaseConfiguration.IsDatabaseSetup(_connectionString))
            {
                Console.WriteLine("Database configured.");
                _core = new BBSDataCore(_connectionString);
            }
            else
            {
                Console.WriteLine("Database not configured - run setup utility.");
                return;
            }
            var config = _core.GetBBSConfig();

            LoggingAPI.LogEntry("Software started.");
            try
            {
                quitFlag = false;
                BBSServer bbsServer = new BBSServer(_connectionString, config.BBSPort, "BBS Server");
                bbsServer.Start();
                while (!quitFlag)
                {
                    Thread.Sleep(100);
                    if (Console.KeyAvailable)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Q)
                        {
                            quitFlag = true;
                            bbsServer.Stop();
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LoggingAPI.Error(e);
            }
            finally
            {
                LoggingAPI.LogEntry("Software shutdown.");
                LoggingAPI.FlushQueue();
            }
        }
Exemple #21
0
 public void UploadedFile(UDFile udf)
 {
     try
     {
         _bbsDataContext.UDFiles.Add(udf);
         _bbsDataContext.SaveChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.UploadedFile(" + udf.Filename + ", " + udf.Description + "): " + e.ToString());
     }
 }
Exemple #22
0
        public bool Application()
        {
            bool result   = false;
            bool quitflag = false;

            try
            {
                //Show new user file
                _bbs.SendFileForTermType("NewUser", true);
                if (!GetUsername())
                {
                    return(false);
                }
                if (!GetPassword())
                {
                    return(false);
                }
                RealName = GetField("Real Name", "~l2~c11Enter your real name.", 0);
                if (RealName == null)
                {
                    return(false);
                }
                Email = GetField("Email", "~l2~c11Enter your email address.", 0);
                if (Email == null)
                {
                    return(false);
                }
                ComputerType = GetField("Computer", "~l2~c11Enter your computer model.", 0);
                if (ComputerType == null)
                {
                    return(false);
                }
                _dataInterface.SaveNewUser(Username, Password, RealName, Email, ComputerType);

                //New User feedback
                _bbs.Write("~l2~c11Leave an introduction message?");
                if (_bbs.YesNo(true, true))
                {
                    Line_Editor e = new Line_Editor(_bbs);
                    if (e.Edit(null))
                    {
                        _dataInterface.NewFeedback("New User Feedback", e.GetMessage(), -1);
                    }
                }
                //And Done
                result = true;
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in NewUser.Application: " + e.ToString());
            }
            return(result);
        }
Exemple #23
0
 public void Punter_Send(string filename, bool IsPrg)
 {
     try
     {
         so.AddReceiver(this.OnReceived);
         punter.Send(File.ReadAllBytes(filename), IsPrg);
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in FileTransfers.Punter_Send(" + filename + "," + ((IsPrg) ? "true" : "false") + "): " + e.ToString());
     }
     so.RemoveReceiver(this.OnReceived);
 }
Exemple #24
0
        public List <NewsItem> GetNews(DateTime fromdate)
        {
            var newsItems = new List <NewsItem>();

            try
            {
                newsItems = _bbsDataContext.NewsItems.Where(p => p.Sent > fromdate).OrderBy(p => p.Sent).ToList();
            } catch (Exception ex)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.GetNews: " + ex.ToString());
            }
            return(newsItems);
        }
Exemple #25
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());
     }
 }
Exemple #26
0
        public List <IdAndKeys> UDBase_List_Area(int area, int userid)
        {
            List <IdAndKeys> response = new List <IdAndKeys>();

            try
            {
                User u = _bbsDataContext.Users.FirstOrDefault(p => p.Id.Equals(userid));
                //TODO: Access group system
                //AccessGroup ag = _bbsDataContext.AccessGroups.FirstOrDefault(p => p.AccessGroupNumber.Equals(u.AccessLevel));
                List <UDBaseArea> arealist = _bbsDataContext.UDBaseAreas.Where(p => p.ParentAreaId.Equals(area)
                                                                               //&& p.AccessLevel <= ag.AccessGroupNumber
                                                                               ).ToList();
                List <UDBase> baselist = _bbsDataContext.UDBases.Where(p => p.UDBaseAreaId.Equals(area)
                                                                       //&& p.AccessLevel <= ag.AccessGroupNumber
                                                                       ).ToList();
                //List<UDFile> filelist = bbs.UDFiles.Where(p=>p.UDBaseId.Equals(
                int listId = 1;
                foreach (UDBaseArea gfa in arealist)
                {
                    IdAndKeys idak = new IdAndKeys()
                    {
                        Id = gfa.Id
                    };
                    idak.Keys.Add("title", gfa.Title);
                    idak.Keys.Add("type", "area");
                    idak.Keys.Add("desc", gfa.Description);
                    idak.Keys.Add("listid", listId.ToString());
                    listId++;
                    response.Add(idak);
                }
                foreach (UDBase gfd in baselist)
                {
                    IdAndKeys idak = new IdAndKeys()
                    {
                        Id = gfd.Id
                    };
                    idak.Keys.Add("type", "base");
                    idak.Keys.Add("title", gfd.Title);
                    idak.Keys.Add("desc", gfd.Description);
                    idak.Keys.Add("listid", listId.ToString());
                    idak.Keys.Add("filepath", gfd.FilePath);
                    listId++;
                    response.Add(idak);
                }
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.UDBase_List_Area(" + area.ToString() + ") : " + e.Message);
            }
            return(response);
        }
Exemple #27
0
        public void DisconnectCallback(IAsyncResult ar)
        {
            StateObject so = (StateObject)ar.AsyncState;

            try
            {
                //parentForm.DropConnection(so);
                so.workSocket.EndDisconnect(ar);
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in Server.DisconnectCallback: " + e.Message);
            }
        }
Exemple #28
0
 public List <UDFile> ListFilesForUDBase(int udbase)
 {
     try
     {
         if (_bbsDataContext.UDFiles.Count(p => p.UDBaseId.Equals(udbase)) > 0)
         {
             return(_bbsDataContext.UDFiles.Where(p => p.UDBaseId.Equals(udbase)).ToList());
         }
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.ListFilesForUDBase(" + udbase.ToString() + "): " + e.ToString());
     }
     return(new List <UDFile>());
 }
Exemple #29
0
        public bool HasRead(int userid, int messageid)
        {
            bool b = false;

            try
            {
                BBSDataDataContext bbs = GetDataContext();
                b = bbs.UserReads.Where(p => p.UserId.Equals(userid)).Select(r => r.MessageHeaderId).Contains(messageid);
            }
            catch (Exception e)
            {
                LoggingAPI.LogEntry("Exception in DataInterface.HasRead(" + userid.ToString() + "," + messageid.ToString() + "):" + e.ToString());
            }
            return(b);
        }
Exemple #30
0
 public byte[] Punter_Receive()
 {
     byte[] b = null;
     try
     {
         so.AddReceiver(this.OnReceived);
         b = punter.Receive();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in FileTransfers.Punter_Receive(): " + e.ToString());
     }
     so.RemoveReceiver(this.OnReceived);
     return(b);
 }