Ejemplo n.º 1
0
 public void Kill()
 {
     MarketInterface.Exec("DELETE FROM BitCategory WHERE ID=?", new object[] { Index });
     Index   = _parentID = -1;
     _name   = null;
     _parent = null;
 }
Ejemplo n.º 2
0
 public BitCategory(int cIndex, string cName, int cParentID)
 {
     Index     = cIndex;
     Name      = cName;
     _parentID = cParentID;
     _parent   = null;
 }
Ejemplo n.º 3
0
 public BitCategory(string cName)
 {
     Index     = -1;
     Name      = cName;
     _parent   = null;
     _parentID = -1;
 }
Ejemplo n.º 4
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");
     }
 }
Ejemplo n.º 5
0
 public BitCategory()
 {
     Index   = -1;
     _name   = null;
     _parent = null;
 }
Ejemplo n.º 6
0
 private bool setOffer(BitOffer BO, GenericMessage M)
 {
     if (getValue(M.RawContent, "Title") != null)
     {
         try
         {
             BO.Title = getValue(M.RawContent, "Title");
         }
         catch (Exception ex)
         {
             sendErr(new GenericMessage()
             {
                 Receiver = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
             });
             return(false);
         }
     }
     if (getValue(M.RawContent, "Description") != null)
     {
         try
         {
             BO.Description = Encoding.UTF8.GetString(A85(getValue(M.RawContent, "Description")));
         }
         catch (Exception ex)
         {
             sendErr(new GenericMessage()
             {
                 Receiver = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
             });
             return(false);
         }
     }
     if (getValue(M.RawContent, "Category") != null)
     {
         int cat = 0;
         if (int.TryParse(getValue(M.RawContent, "Category"), out cat) && cat > -3 && cat != 0)
         {
             try
             {
                 BitCategory BC = new BitCategory(cat);
                 BO.Category = cat;
             }
             catch (Exception ex)
             {
                 sendErr(new GenericMessage()
                 {
                     Sender = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
                 });
                 return(false);
             }
         }
     }
     if (getValue(M.RawContent, "Files") != null)
     {
         string[] fIndexes = getValue(M.RawContent, "Files").Split(',');
         if (fIndexes.Length > 1 || !string.IsNullOrEmpty(fIndexes[0].ToString()))
         {
             try
             {
                 for (int i = 0; i < fIndexes.Length; i++)
                 {
                     int.Parse(fIndexes[i]);
                 }
                 BO.Files = getValue(M.RawContent, "Files");
             }
             catch (Exception ex)
             {
                 sendErr(new GenericMessage()
                 {
                     Receiver = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
                 });
                 return(false);
             }
         }
         else
         {
         }
     }
     if (getValue(M.RawContent, "Stock") != null)
     {
         try
         {
             int sCount = int.Parse(getValue(M.RawContent, "Stock"));
             if (sCount > -2)
             {
                 BO.Stock = sCount;
             }
             else
             {
                 throw new Exception("Invalid stock count");
             }
         }
         catch (Exception ex)
         {
             sendErr(new GenericMessage()
             {
                 Receiver = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
             });
             return(false);
         }
     }
     if (getValue(M.RawContent, "PriceMap") != null)
     {
         try
         {
             PriceMap PM = new PriceMap(getValue(M.RawContent, "PriceMap"));
             BO.Prices = PM.ToString();
         }
         catch (Exception ex)
         {
             sendErr(new GenericMessage()
             {
                 Receiver = M.Sender, RawContent = "Cannot edit the offer: " + ex.Message, Server = M.Server
             });
             return(false);
         }
     }
     return(true);
 }