public static void Bid(Customer Customer, Item Item, decimal Amount) { if (Amount > 0 && Amount > Item.NextBidAmount) { // Create new AutoBud. AutoBid autobid = new AutoBid (Customer, Item, Amount); autobid.Save (); // Console.WriteLine ("[1]SENDMAIL: Autobid placed: "+ Amount); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Email, "Autobud oprettet","Du har oprettet et autobud på:\n Katalog nr.: "+ Item.CatalogNo +"\n\n"+ Item.Title +"\n\n"+"Autobud max: "+ Amount +" kr.\n\n"); // If no other bids have been made, place the first one. // if (Item.BidAmount == 0) // { // decimal nextbidamount = Item.NextBidAmount; // Bid bid = new Bid (Customer, Item, nextbidamount); // bid.Save (); // Console.WriteLine ("[2]SENDMAIL: Autobid Bid placed: "+ nextbidamount); // SorentoLib.Tools.Helpers.SendMail ("*****@*****.**", Customer.Email, "Bud afgivet","Du har afgivet et autobud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ nextbidamount +" kr.\n\n"); // } SorentoLib.Services.Logging.LogDebug ("[DIDIUS.ITEM]: Autobid placed on item "+ Item.Id); } else if (Amount > 0 && Amount < Item.NextBidAmount) { Bid bid = new Bid (Customer, Item, Amount); bid.Save (); // Console.WriteLine ("[2]SENDMAIL: Bid placed: "+ Amount); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Email, "Bud afgivet","Du har afgivet et bud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ Amount +" kr.\n\n"); // Console.WriteLine ("[3]SENDMAIL: Bid overbid: "+ Amount +" < "+ Item.NextBidAmount); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Email, "Overbudt","Din bud sum på "+ Amount +" kr. på effekt: "+ Item.Title +" er blevet overbudt.\n\n"); SorentoLib.Services.Logging.LogDebug ("[DIDIUS.ITEM]: Low bid placed on item "+ Item.Id); } else { decimal nextbidamount = Item.NextBidAmount; bool autobidplaced = false; // Place any AutoBids that equal the next bid amount. { List<AutoBid> autobids = AutoBid.List (Item); foreach (AutoBid autobid in autobids) { if (autobid.Amount == nextbidamount) { Bid bid = new Bid (Customer.Load (autobid.CustomerId), Item, nextbidamount); bid.Save (); autobidplaced = true; // Console.WriteLine ("[4]SENDMAIL: Autobid Bid placed: "+ nextbidamount +" ("+ Customer.Load (autobid.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Load (autobid.CustomerId).Email, "Bud afgivet","Du har afgivet et autobud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ nextbidamount +" kr.\n\n"); } } } // Place single bid. { Bid bid = new Bid (Customer, Item, nextbidamount); bid.Save (); // Console.WriteLine ("[5]SENDMAIL: Bid placed: "+ nextbidamount); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Email, "Bud afgivet","Du har afgivet et bud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ nextbidamount +" kr.\n\n"); // if (autobidplaced) // { // Console.WriteLine ("[7]SENDMAIL: Bid overbid: "+ nextbidamount +" < ???"); // SorentoLib.Tools.Helpers.SendMail ("*****@*****.**", Customer.Email, "Overbudt","Din bud sum på "+ nextbidamount +" kr. på effekt: "+ Item.Title +" er blevet overbudt af et tidligere bud med samme sum.\n\n"); // } } SorentoLib.Services.Logging.LogDebug ("[DIDIUS.ITEM]: High bid placed on item "+ Item.Id); } // Place AutoBids { decimal nextbidamount = Item.NextBidAmount; decimal currentbidamount = Item.BidAmount; List<AutoBid> autobids = AutoBid.List (Item); // Place highest AutoBid. if (autobids.Count > 0) { AutoBid high = autobids[0]; decimal low = currentbidamount; // See if we have more than one Autobid. if (autobids.Count > 1) { // Only AutoBids that are still above the current bid amount. if (autobids[1].Amount > currentbidamount) { low = autobids[1].Amount; } } if (high.Amount >= nextbidamount) { decimal bla = CalculateNextBidAmount (low); // Console.WriteLine (bla); if (bla > high.Amount) { bla = high.Amount; } Bid bid = new Bid (Customer.Load (high.CustomerId), Item, bla); bid.Save (); // Console.WriteLine ("[6]SENDMAIL: Autobid Bid placed: "+ bla +" ("+ Customer.Load (high.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Load (high.CustomerId).Email, "Bud afgivet","Du har afgivet et autobud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ CalculateNextBidAmount (low) +" kr.\n\n"); foreach (AutoBid autobid in autobids) { if (autobid.Id != high.Id && autobid.Amount == bla) { Bid bid2 = new Bid (Customer.Load (autobid.CustomerId), Item, bla); bid2.Save (); // Console.WriteLine ("[7]SENDMAIL: Autobid Bid placed: "+ bla +" ("+ Customer.Load (autobid.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Email, "Bud afgivet","Du har afgivet et autobud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ nextbidamount +" kr.\n\n"); // Console.WriteLine ("[9]SENDMAIL: Bid overbid by Autobid : "+ Amount +" < "+ bla +"("+ Customer.Load (autobid.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Load (autobid.CustomerId).Email, "Overbudt","Din bud sum på "+ autobid.Amount +" kr. på effekt: "+ Item.Title +" er blevet overbudt.\n\n"); } } } } // Place any AutoBids that equal next bid amount. foreach (AutoBid autobid in autobids) { if (autobid.Amount > currentbidamount && autobid.Amount < Item.BidAmount) { Bid bid = new Bid (Customer.Load (autobid.CustomerId), Item, autobid.Amount); bid.Save (); // Console.WriteLine ("[8]SENDMAIL: Autobid Bid placed: "+ autobid.Amount +" ("+ Customer.Load (autobid.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Load (autobid.CustomerId).Email, "Bud afgivet","Du har afgivet et autobud på effekt: "+ Item.Title +"\n\n"+"Bud sum: "+ Amount +" kr.\n\n"); // Console.WriteLine ("[9]SENDMAIL: Bid overbid: "+ autobid.Amount +" < "+ Item.NextBidAmount +"("+ Customer.Load (autobid.CustomerId).Name +")"); SorentoLib.Tools.Helpers.SendMail (SorentoLib.Services.Settings.Get<string> (Enums.SettingsKey.didius_email_sender), Customer.Load (autobid.CustomerId).Email, "Overbudt","Din bud sum på "+ Amount +" kr. på effekt: "+ Item.Title +" er blevet overbudt.\n\n"); } } } }
public static Bid Load(Guid Id) { Bid result; try { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, Id.ToString ()).SelectSingleNode ("(//didius.bid)[1]"))); result = new Bid (); result._id = new Guid ((string)item["id"]); if (item.ContainsKey ("createtimestamp")) { result._createtimestamp = int.Parse ((string)item["createtimestamp"]); } if (item.ContainsKey ("updatetimestamp")) { result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]); } if (item.ContainsKey ("customerid")) { result._customerid = new Guid ((string)item["customerid"]); } if (item.ContainsKey ("itemid")) { result._itemid = new Guid ((string)item["itemid"]); } if (item.ContainsKey ("sort")) { result._sort = long.Parse((string)item["sort"]); } if (item.ContainsKey ("amount")) { result._amount = decimal.Parse ((string)item["amount"], System.Globalization.CultureInfo.InvariantCulture); } } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.BID", exception.Message)); // EXCEPTION: Excpetion.BidLoadGuid throw new Exception (string.Format (Strings.Exception.BidLoadGuid, Id)); } return result; }
public static void OnlineBid(Customer Customer, Item Item) { Bid bid = new Bid (Customer, Item, Item.NextBidAmount); bid.Save (); }
public static Bid FromXmlDocument(XmlDocument xmlDocument) { Hashtable item; Bid result = new Bid (); try { item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//didius.Bid)[1]"))); } catch { item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument); } if (item.ContainsKey ("id")) { result._id = new Guid ((string)item["id"]); } else { throw new Exception (string.Format (Strings.Exception.ItemFromXmlDocument, "ID")); } if (item.ContainsKey ("createtimestamp")) { result._createtimestamp = int.Parse ((string)item["createtimestamp"]); } if (item.ContainsKey ("updatetimestamp")) { result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]); } if (item.ContainsKey ("customerid")) { result._customerid = new Guid ((string)item["customerid"]); } else { throw new Exception (string.Format (Strings.Exception.BidFromXmlDocument, "CUSTOMERID")); } if (item.ContainsKey ("itemid")) { result._itemid = new Guid ((string)item["itemid"]); } else { throw new Exception (string.Format (Strings.Exception.BidFromXmlDocument, "ITEMID")); } if (item.ContainsKey ("sort")) { result._sort = long.Parse((string)item["sort"]); } if (item.ContainsKey ("amount")) { result._amount = decimal.Parse ((string)item["amount"], System.Globalization.CultureInfo.InvariantCulture); } return result; }