public bool AddSession(TorrentSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            using (IDbConnection connection = _connectionFactory.GetConnection()) {
                int isActive = (session.IsActive ? 1 : 0);
                return(connection.Execute(
                           $"INSERT INTO {nameof(TorrentSession) } ({nameof(session.EncCodePage)}, " +
                           $" {nameof(session.Title)}, {nameof(session.Path)}, {nameof(session.IsActive)}," +
                           $" {nameof(session.PiecesHave)}, {nameof(session.Metainfo)}, {nameof(session.LastValidated)}  ) VALUES(?,?,?,?,?,?,?)",
                           new
                {
                    session.EncCodePage,
                    session.Title,
                    session.Path,
                    isActive,
                    session.PiecesHave,
                    session.Metainfo,
                    session.LastValidated
                }
                           ) > 0);
            }
        }
Beispiel #2
0
        //this saveLog method only saves a log of one given RM instence...
        public static bool Dump(Stream stream, TorrentSession tSession)
        {
            //construct the string... with all of the logs together...
            string log;

            log = "\n ApplicationSettings.cs Log \n\n" + Logger.appErrLog;
            //if the log is empty then add a empy line
            if (Logger.appErrLog.Length == 0)
            {
                log += "~~~EMPTY~~~\n\n";
            }

            log += "\n memRead.cs Log \n\n" + Logger.memErrLog;

            //if the log is empty then add a empy line
            if (Logger.memErrLog.Length == 0)
            {
                log += "~~~EMPTY~~~\n\n";
            }

            log += "\n\n ====== RM Object : " + tSession.currentTorrentFile.Name + "======\n\n" + tSession.strBigLog;

            return(WriteLog(stream, log));
        }
        private void newRM(string torrentPath)
        {
            //         try
            //         {

            //make this user proof! :P
            //disable the new RM tool bar button
            toolStripButton1.Enabled = false;

            //disable the new RM menu item
            newRMToolStripMenuItem.Enabled = false;

            //global counter for RMs
            Program.RMcount++;

            //Initillize the Item and it's sub items... so that this will go on gracefuly :)
            //add a new item to the list this will be properly modified by the Form1 UI later

            //temp sub item
            ListViewItem.ListViewSubItem tmpSitem;

            listMain.Items.Add(new ListViewItem());

            //set the items color accoring to the last time's set color...
            if (listMain.Items.Count == 1)
            {
                listMain.Items[listMain.Items.Count - 1].BackColor = Color.AliceBlue;
            }
            else
            {
                if (listMain.Items[listMain.Items.Count - 2].BackColor == Color.AliceBlue)
                {
                    //this is the current last item...
                    listMain.Items[listMain.Items.Count - 1].BackColor = Color.White;
                }
                else
                {
                    listMain.Items[listMain.Items.Count - 1].BackColor = Color.AliceBlue;
                }
            }
            //fill the item with sub items
            for (int a = 0; a < 14; a++)
            {
                tmpSitem = new ListViewItem.ListViewSubItem();
                listMain.Items[listMain.Items.Count - 1].SubItems.Add(tmpSitem);
            }

            //create and add to the collection...
            tempRM = new TorrentSession(Program.RMcount);
            Program.rmCol.Add(tempRM);



            //show the New Torrent UI ;)
            Program.tempConUI = new rm2.UI.TorrerntSettingsUI();
            Program.tempConUI.currentRMIns = Program.rmCol[Program.RMcount];
            Program.tempConUI.Show();
            if (torrentPath != null)
            {
                Program.tempConUI.loadTorrentFileInfo(torrentPath, true);
            }


            //ListViewItem item = listMain.Items.Add(file.Name);
            // listMain.Items[Program.RMcount].SubItems.Add(Program.rmCol[Program.RMcount].currentTorrent.tracker);
            // listMain.Items[Program.RMcount].Text = Program.RMcount.ToString();
            // listMain.Items[Program.RMcount].SubItems[0].Text = Program.rmCol[Program.RMcount].currentTorrent.tracker;


            //       }
            //       catch (Exception e)
            //       {
            //           MessageBox.Show(e.ToString(), "clsMain>newRM() error!");
            //       }
        }
Beispiel #4
0
 private void RegisterSession(TorrentSession session)
 {
 }