Example #1
0
 public void Kill()
 {
     MarketInterface.Exec("DELETE FROM BitCategory WHERE ID=?", new object[] { Index });
     Index   = _parentID = -1;
     _name   = null;
     _parent = null;
 }
Example #2
0
 public void Kill()
 {
     MarketInterface.Exec("DELETE FROM BitOffer WHERE ID=?", new object[] { Index });
     _stock      = _category = Index = -1;
     _pricemap   = _files = _address = _description = _title = null;
     _lastModify = DateTime.Now;
 }
Example #3
0
 public void Kill()
 {
     if (Index >= 0)
     {
         MarketInterface.Exec("DELETE FROM BitFile WHERE ID=?", new object[] { Index });
         if (File.Exists(vName))
         {
             File.Delete(vName);
         }
     }
     Index = -1;
 }
Example #4
0
 public BitFile(int i)
 {
     SQLRow[] SR = MarketInterface.ExecReader("SELECT Name,Address FROM BitFile WHERE ID=?", new object[] { i });
     if (SR != null && SR.Length > 0)
     {
         Index    = i;
         _name    = SR[0].Values["Name"].ToString();
         _address = SR[0].Values["Address"].ToString();
     }
     else
     {
         throw new Exception("Invalid Index");
     }
 }
Example #5
0
 public BitCategory(int cIndex)
 {
     SQLRow[] RR = MarketInterface.ExecReader("SELECT * FROM BitCategory WHERE ID=?", new object[] { cIndex });
     if (RR.Length == 1)
     {
         _name     = RR[0].Values["Name"].ToString();
         Index     = cIndex;
         _parentID = RR[0].Values["Parent"] == null ? -1 : (int)RR[0].Values["Parent"];
         if (_parentID > -1)
         {
             _parent = new BitCategory(_parentID);
         }
     }
     else
     {
         throw new Exception("Invalid Category ID");
     }
 }
Example #6
0
 public BitOffer(int i)
 {
     SQLRow[] SR = MarketInterface.ExecReader("SELECT * FROM BitOffer WHERE ID=?", new object[] { i });
     if (SR != null && SR.Length > 0)
     {
         Index        = i;
         _title       = SR[0].Values["Title"].ToString();
         _description = SR[0].Values["Description"].ToString();
         _address     = SR[0].Values["Address"].ToString();
         _category    = (int)SR[0].Values["Category"];
         _files       = SR[0].Values["Files"].ToString();
         _stock       = (int)SR[0].Values["Stock"];
         _pricemap    = SR[0].Values["PriceMap"].ToString();
         _lastModify  = (DateTime)SR[0].Values["LastModify"];
     }
     else
     {
         throw new Exception("Invalid Index");
     }
 }
Example #7
0
 public BitTransaction(int tIndex)
 {
     SQLRow[] SR = MarketInterface.ExecReader("SELECT * FROM BitTransaction WHERE ID=?", new object[] { tIndex });
     if (SR != null && SR.Length > 0)
     {
         Index            = tIndex;
         _addrBuyer       = SR[0].Values["AddressBuyer"].ToString();
         _addrSeller      = SR[0].Values["AddressSeller"].ToString();
         _amount          = (int)SR[0].Values["Amount"];
         _offer           = (int)SR[0].Values["Offer"];
         _state           = (TransactionState)(int)SR[0].Values["State"];
         _buyerComment    = SR[0].Values["BuyerComment"].ToString();
         _sellerComment   = SR[0].Values["SellerComment"].ToString();
         _buyerRating     = (Rating)(int)SR[0].Values["BuyerRating"];
         _sellerRating    = (Rating)(int)SR[0].Values["SellerRating"];
         _transactionTime = (DateTime)SR[0].Values["TransactionTime"];
     }
     else
     {
         throw new Exception("Invalid Index");
     }
 }
Example #8
0
        private void parseRating(GenericMessage M)
        {
            //RATING <ADDR> <ACTION>
            //ADDR: Bitmessage Address
            //ACTION: GET
            string[] Parts = M.Command.Split(' ');
            if (Parts.Length == 3)
            {
                switch (Parts[2].ToUpper())
                {
                case "GET":
                    StringBuilder Ratings = new StringBuilder();
                    SQLRow[]      Rows;
                    Rows = MarketInterface.ExecReader("SELECT * FROM BitTransaction WHERE AddressBuyer=?", new object[] { Parts[1] });
                    foreach (SQLRow r in Rows)
                    {
                        Ratings.AppendFormat("{0}\t{1}\t{2}\t{3}\r\n", (int)r.Values["State"], r.Values["AddressSeller"].ToString(), (int)r.Values["SellerRating"], Base.B64enc(r.Values["SellerComment"].ToString()));
                    }
                    Rows = MarketInterface.ExecReader("SELECT * FROM BitTransaction WHERE AddressSeller=?", new object[] { Parts[1] });
                    foreach (SQLRow r in Rows)
                    {
                        Ratings.AppendFormat("{0}\t{1}\t{2}\t{3}\r\n", (int)r.Values["State"], r.Values["AddressBuyer"].ToString(), (int)r.Values["BuyerRating"], Base.B64enc(r.Values["BuyerComment"].ToString()));
                    }
                    sendMsg(new GenericMessage()
                    {
                        Receiver = M.Sender, Command = M.Command, RawContent = Ratings.ToString(), Server = M.Server
                    });
                    break;

                default:
                    sendErr(new GenericMessage()
                    {
                        Receiver = M.Sender, RawContent = "invalid RATING command", Server = M.Server
                    });
                    break;
                }
            }
        }
Example #9
0
        private static int getUnconfirmedStock(int ID)
        {
            var Rows = MarketInterface.ExecReader("SELECT SUM(Amount) AS Q FROM BitTransaction WHERE Offer=? AND State=0", new object[] { ID });

            return(Rows[0].Values["Q"] == null ? 0 : (int)Rows[0].Values["Q"]);
        }
Example #10
0
        private void parseMain(GenericMessage M)
        {
            //MAIN <ACTION>
            //ACTION: INFO,SETTINGS,CATLIST,OFFERLIST
            string[] Parts = M.Command.Split(' ');
            if (Parts.Length == 2)
            {
                switch (Parts[1].ToUpper())
                {
                case "INFO":
                    if (File.Exists("INFO.TXT"))
                    {
                        sendMsg(new GenericMessage()
                        {
                            Receiver = M.Sender, Command = "MAIN INFO", RawContent = "AyrAs BitMarket\n\n" + File.ReadAllText("INFO.TXT"), Server = M.Server
                        });
                    }
                    else
                    {
                        sendMsg(new GenericMessage()
                        {
                            Receiver = M.Sender, Command = "MAIN INFO", RawContent = "AyrAs BitMarket\n\nThis Market has no informations published yet.", Server = M.Server
                        });
                    }
                    break;

                case "SETTINGS":
                    sendMsg(new GenericMessage()
                    {
                        Receiver   = M.Sender,
                        Command    = "MAIN SETTINGS",
                        RawContent = string.Format(@"FILE.NAME=50{0}RAW
FILE.CONTENT=-1{0}A85
OFFER.NAME=50{0}RAW
OFFER.FILES=50{0}RAW
OFFER.PRICEMAP=200{0}RAW
OFFER.DESCRIPTION=2000{0}A85
OFFER.MESSAGE=-1{0}A85
TRANSACTION.COMMENT=200{0}B64", '\t'),
                        Server     = M.Server
                    });
                    break;

                case "CATLIST":
                    SQLRow[]      SRc = MarketInterface.ExecReader("SELECT ID,Parent,Name FROM BitCategory ORDER BY Parent,ID");
                    StringBuilder SBc = new StringBuilder();
                    foreach (SQLRow R in SRc)
                    {
                        SBc.AppendFormat("{0},{1},{2}\n", R.Values["ID"], R.Values["Parent"], R.Values["Name"]);
                    }
                    SRc = null;
                    sendMsg(new GenericMessage()
                    {
                        Receiver = M.Sender, Command = "MAIN CATLIST", RawContent = SBc.ToString().Trim(), Server = M.Server
                    });
                    break;

                case "OFFERLIST":
                    SQLRow[]      SRo = MarketInterface.ExecReader("SELECT ID,Category,Stock,PriceMap,Title FROM BitOffer WHERE Category!=-2 ORDER BY LastModify DESC");
                    StringBuilder SBo = new StringBuilder();
                    foreach (SQLRow R in SRo)
                    {
                        SBo.AppendFormat("{0},{1},{2},{3},{4}\n", R.Values["ID"], R.Values["Category"], R.Values["Stock"], R.Values["PriceMap"], R.Values["Title"]);
                    }
                    SRo = null;
                    sendMsg(new GenericMessage()
                    {
                        Receiver = M.Sender, Command = "MAIN OFFERLIST", RawContent = SBo.ToString().Trim(), Server = M.Server
                    });
                    break;

                default:
                    sendErr(new GenericMessage()
                    {
                        Receiver = M.Sender, RawContent = "Invalid MAIN command", Server = M.Server
                    });
                    break;
                }
            }
        }