Beispiel #1
0
        public static 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();
                        gfd.GFileAreaId     = areaid;
                        gfd.Filename        = filename;
                        gfd.Added           = DateTime.Now;
                        gfd.DisplayFilename = title;
                        gfd.Description     = description;
                        gfd.PETSCII         = PETSCII;
                        gfd.FileSizeInBytes = (int)(new FileInfo(filename).Length);
                        BBSDataContext bbs = new BBSDataContext();
                        bbs.GFileDetails.Add(gfd);
                        bbs
                            b = true;
                    }
                }
            }
            catch (Exception e)
            {
                b = false;
            }
            return(b);
        }
Beispiel #2
0
        public void CmdRead(int fileId)
        {
            GFileDetail gfile = _bbsDataCore.GetGFileDetail(fileId);

            _bbs.WriteLine("~l2~c1Filename: ~c7" + gfile.Title);
            _bbs.WriteLine("~c1Description: ~c7" + gfile.Description);
            _bbs.Write("~c7" + Utils.Repeat('\xc0', _bbs.terminalType.Columns()) + "~c1");
            outputrow = 0;
            string[] lines = File.ReadAllLines(gfile.FilePath + gfile.Filename);
            foreach (string s in lines)
            {
                if (_bbs.terminalType.Columns() == 40)
                {
                    if (s.Length > 40)
                    {
                        List <string> t = Utils.Split(s, 40).ToList();
                        foreach (string tt in t)
                        {
                            if (t[t.Count - 1] == tt)
                            {
                                if (!OutputLine(tt, true))
                                {
                                    return;
                                }
                            }
                            else
                            {
                                if (!OutputLine(tt, false))
                                {
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!OutputLine(s, true))
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (!OutputLine(s, true))
                    {
                        return;
                    }
                }
            }
        }
Beispiel #3
0
        public bool AddGFileDetail(int areaId, string filePath, string fileName, string title, string description, string notes, 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(filePath + fileName))
                    {
                        GFileDetail gfd = new GFileDetail()
                        {
                            GFileAreaId     = areaId,
                            Filename        = fileName,
                            FilePath        = filePath,
                            Added           = DateTime.Now,
                            Title           = title,
                            Description     = description,
                            Notes           = notes,
                            PETSCII         = PETSCII,
                            FileSizeInBytes = (int)(new FileInfo(filePath + fileName).Length)
                        };
                        _bbsDataContext.GFileDetails.Add(gfd);
                        _bbsDataContext.SaveChanges();
                        b = true;
                    }
                }
            }
            catch (Exception e)
            {
                b = false;
                LoggingAPI.LogEntry("Exception in DataInterface.AddGFile: " + e);
            }
            return(b);
        }
Beispiel #4
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);
        }