public Case(Auction Auction, Customer Customer) { this._id = Guid.NewGuid (); this._createtimestamp = SNDK.Date.CurrentDateTimeToTimestamp (); this._updatetimestamp = SNDK.Date.CurrentDateTimeToTimestamp (); this._no = Helpers.NewNo (); this._customerid = Customer.Id; this._auctionid = Auction.Id; this._title = string.Empty; this._customerreference = string.Empty; this._preparationfee = 0; this._commisionfeepercentage = 0; this._commisionfeeminimum = 0; this._commisionfeepercentage = SorentoLib.Services.Settings.Get<int> (Enums.SettingsKey.didius_value_seller_commission_percentage); this._commisionfeeminimum = SorentoLib.Services.Settings.Get<int> (Enums.SettingsKey.didius_value_seller_commission_minimum); this._settled = false; }
public static Auction Load(Guid Id) { Auction result; try { Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, Id.ToString ()).SelectSingleNode ("(//didius.auction)[1]"))); result = new Auction (); 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 ("no")) { result._no = (string)item["no"]; } if (item.ContainsKey ("title")) { result._title = (string)item["title"]; } if (item.ContainsKey ("begin")) { result._begin = int.Parse ((string)item["begin"]); } if (item.ContainsKey ("end")) { result._end = int.Parse ((string)item["end"]); } if (item.ContainsKey ("deadline")) { result._deadline = int.Parse ((string)item["deadline"]); } if (item.ContainsKey ("pickupbegin")) { result._pickupbegin = int.Parse ((string)item["pickupbegin"]); } if (item.ContainsKey ("pickupend")) { result._pickupend = int.Parse ((string)item["pickupend"]); } if (item.ContainsKey ("pickuptext")) { result._pickuptext = (string)item["pickuptext"]; } if (item.ContainsKey ("location")) { result._location = (string)item["location"]; } if (item.ContainsKey ("description")) { result._description = (string)item["description"]; } if (item.ContainsKey ("livebiders")) { foreach (XmlDocument livebider in (List<XmlDocument>)item["livebiders"]) { result._livebiders.Add (LiveBider.FromXmlDocument (livebider)); } } if (item.ContainsKey ("buyernos")) { result._buyernos = (string)item["buyernos"]; } if (item.ContainsKey ("notes")) { result._notes = (string)item["notes"]; } if (item.ContainsKey ("type")) { result._type = SNDK.Convert.StringToEnum<Enums.AuctionType> ((string)item["type"]); } if (item.ContainsKey ("status")) { result._status = SNDK.Convert.StringToEnum<Enums.AuctionStatus> ((string)item["status"]); } } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.AUCTION", exception.Message)); // EXCEPTION: Excpetion.AuctionLoadGuid throw new Exception (string.Format (Strings.Exception.AuctionLoadGuid, Id)); } return result; }
public static Auction FromXmlDocument(XmlDocument xmlDocument) { Hashtable item; Auction result = new Auction (); try { item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//didius.Auction)[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 ("no")) { result._no = (string)item["no"]; } if (item.ContainsKey ("title")) { result._title = (string)item["title"]; } if (item.ContainsKey ("begin")) { result._begin = SNDK.Date.DateTimeToTimestamp (DateTime.ParseExact ((string)item["begin"], "yyyy/MM/dd HH:mm", null)); } if (item.ContainsKey ("end")) { result._end = SNDK.Date.DateTimeToTimestamp (DateTime.ParseExact ((string)item["end"], "yyyy/MM/dd HH:mm", null)); } if (item.ContainsKey ("deadline")) { result._deadline = SNDK.Date.DateTimeToTimestamp (DateTime.ParseExact ((string)item["deadline"], "yyyy/MM/dd HH:mm", null)); } if (item.ContainsKey ("pickupbegin")) { result._pickupbegin = SNDK.Date.DateTimeToTimestamp (DateTime.ParseExact ((string)item["pickupbegin"], "yyyy/MM/dd HH:mm", null)); } if (item.ContainsKey ("pickupend")) { result._pickupend = SNDK.Date.DateTimeToTimestamp (DateTime.ParseExact ((string)item["pickupend"], "yyyy/MM/dd HH:mm", null)); } if (item.ContainsKey ("pickuptext")) { result._pickuptext = (string)item["pickuptext"]; } if (item.ContainsKey ("location")) { result._location = (string)item["location"]; } if (item.ContainsKey ("description")) { result._description = (string)item["description"]; } if (item.ContainsKey ("livebiders")) { foreach (XmlDocument livebider in (List<XmlDocument>)item["livebiders"]) { result._livebiders.Add (LiveBider.FromXmlDocument (livebider)); } } if (item.ContainsKey ("buyernos")) { result._buyernos = (string)item["buyernos"]; } if (item.ContainsKey ("notes")) { result._notes = (string)item["notes"]; } if (item.ContainsKey ("type")) { result._type = SNDK.Convert.StringToEnum<Enums.AuctionType> ((string)item["type"]); } if (item.ContainsKey ("status")) { result._status = SNDK.Convert.StringToEnum<Enums.AuctionStatus> ((string)item["status"]); } return result; }
public static List<Item> List(Auction Auction) { List<Item> result = new List<Item> (); foreach (SorentoLib.Services.DatastoreItem item in SorentoLib.Services.Datastore.ListOfShelfsNew (DatastoreAisle, new SorentoLib.Services.Datastore.MetaSearch ("auctionid", SorentoLib.Enums.DatastoreMetaSearchComparisonOperator.Equal, Auction.Id))) { try { result.Add (FromXmlDocument (item.Get<XmlDocument> ())); } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.ITEM", exception.Message)); // LOG: LogDebug.ItemList SorentoLib.Services.Logging.LogDebug (string.Format (Strings.LogDebug.ItemList, item.Id)); } } result.Sort (delegate (Item item1, Item item2) { return item1._catalogno.CompareTo (item2._catalogno); }); return result; // List<Item> result = new List<Item> (); // // foreach (Case c in Auction.Cases) // { // result.AddRange (Item.List (c)); // } // // result.Sort (delegate (Item item1, Item item2) { return item1._catalogno.CompareTo (item2._catalogno); }); // // return result; }
public static List<Item> List(Auction Auction, int Index, int Count) { List<Item> result = new List<Item> (); List<SorentoLib.Services.DatastoreItem> datastoreitems = SorentoLib.Services.Datastore.ListOfShelfsNew (DatastoreAisle, new SorentoLib.Services.Datastore.MetaSearch ("auctionid", SorentoLib.Enums.DatastoreMetaSearchComparisonOperator.Equal, Auction.Id)); int counter = 0; List<Item> temp = new List<Item> (); foreach (SorentoLib.Services.DatastoreItem datastoreitem in datastoreitems) { try { // if (((dd*count) => counter) && ((dd*count) => counter)) // { // } temp.Add (FromXmlDocument (datastoreitem.Get<XmlDocument> ())); } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.ITEM", exception.Message)); // LOG: LogDebug.ItemList SorentoLib.Services.Logging.LogDebug (string.Format (Strings.LogDebug.ItemList, datastoreitem.Id)); } // counter++; } temp.Sort (delegate (Item item1, Item item2) { return item1._catalogno.CompareTo (item2._catalogno); }); foreach (Item item in temp) { // Console.WriteLine ((Index * Count) +" < "+ counter +" "+ counter +"<"+ ((Index * Count))); if ((Index * Count) <= counter && counter < ((Index * Count) + Count)) { // Item item = Item.FromXmlDocument (datastoreitem.Get<XmlDocument> ()); // result.Add (FromXmlDocument (datastoreitem.Get<XmlDocument> ())); result.Add (item); } counter++; } return result; }
public static int NewCatalogNo(Auction Auction, int MinCatalogNo) { int result = MinCatalogNo; List<int> used = new List<int> (); foreach (Case c in Case.List (Auction)) { foreach (Item i in Item.List (c)) { // Console.WriteLine (i.CatalogNo); used.Add (i.CatalogNo); } } //used.Sort (delegate (int int1, int int2) { return int1.CompareTo (int2); }); Console.WriteLine (used.Contains (MinCatalogNo)); while (used.Contains (result)) { result++; } Console.WriteLine ("BLALB"+ result); // { // if (!used.Find (19)); // { // Console.WriteLine ("FOUND"); // result = MinCatalogNo; // break; // } // MinCatalogNo++; // } // if (used.Count > 0) // { // for (int i = MinCatalogNo; i <= (used.Count+1); i++) // { // if (!used.Contains (i)) // { // result = i; // break; // } // } // } return result; }
public static int NewCatalogNo(Auction Auction) { return NewCatalogNo (Auction, 1); }
public static bool IsCatalogNoTaken(Auction Auction, int CatalogNo) { bool result = false; foreach (Case c in Case.List (Auction)) { foreach (Item i in Item.List (c)) { if (i.CatalogNo == CatalogNo) { result = true; break; } } if (result) { break; } } return result; }
public static List<Item> GetItemsCustomerBidOn(Customer Customer, Auction Auction) { List<Item> result = new List<Item> (); List<Guid> itemids = new List<Guid> (); foreach (Bid bid in Bid.List (Customer)) { if (!itemids.Contains (bid.ItemId)) { Item item = Item.Load (bid.ItemId); if (item.Case.AuctionId == Auction.Id) { itemids.Add (bid.ItemId); result.Add (item); } } } return result; }
public static TurnoverReport Create(Auction Auction) { TurnoverReport result = new TurnoverReport (); foreach (Item item in Item.List (Auction)) { // if (item.CurrentBidId != Guid.Empty) if (item.Invoiced) { Case case_ = Case.Load (item.CaseId); Bid bid = Bid.Load (item.CurrentBidId); TurnoverReportSellerLine sellerline = new TurnoverReportSellerLine (item); TurnoverReportSeller seller = result._sellers.Find(TurnoverReportSeller => TurnoverReportSeller.Id == case_.CustomerId); if (seller == null) { seller = new TurnoverReportSeller (Customer.Load (case_.CustomerId)); result._sellers.Add (seller); } seller.Amount += sellerline.Amount; seller.VatAmount += sellerline.VatAmount; seller.CommissionFee += sellerline.CommissionFee; seller.VatCommissionFee += sellerline.VatCommissionFee; result._sellerlines.Add (sellerline); TurnoverReportBuyerLine buyerline = new TurnoverReportBuyerLine (item); TurnoverReportBuyer buyer = result._buyers.Find(TurnoverReportBuyer => TurnoverReportBuyer.Id == bid.CustomerId); if (buyer == null) { buyer = new TurnoverReportBuyer (Customer.Load (bid.CustomerId)); result._buyers.Add (buyer); } buyer.Amount += buyerline.Amount; buyer.VatAmount += buyerline.VatAmount; buyer.CommissionFee += buyerline.CommissionFee; buyer.VatCommissionFee += buyerline.VatCommissionFee; result._buyerlines.Add (buyerline); } else { Case case_ = Case.Load (item.CaseId); TurnoverReportSellerLine sellerline = new TurnoverReportSellerLine (item); TurnoverReportSeller seller = result._sellers.Find(TurnoverReportSeller => TurnoverReportSeller.Id == case_.CustomerId); if (seller == null) { seller = new TurnoverReportSeller (Customer.Load (case_.CustomerId)); result._sellers.Add (seller); } seller.Amount += sellerline.Amount; seller.VatAmount += sellerline.VatAmount; seller.CommissionFee += sellerline.CommissionFee; seller.VatCommissionFee += sellerline.VatCommissionFee; result._sellerlines.Add (sellerline); result._notsoldlines.Add (new TurnoverReportNotSoldLine (item)); } } return result; }
public static List<Settlement> List(Auction Auction) { List<Settlement> result = new List<Settlement> (); foreach (string id in SorentoLib.Services.Datastore.ListOfShelfs (DatastoreAisle, new SorentoLib.Services.Datastore.MetaSearch ("auctionid", SorentoLib.Enums.DatastoreMetaSearchComparisonOperator.Equal, Auction.Id))) { try { result.Add (Load (new Guid (id))); } catch (Exception exception) { // LOG: LogDebug.ExceptionUnknown SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.SETTLEMENT", exception.Message)); // LOG: LogDebug.SettlementList SorentoLib.Services.Logging.LogDebug (string.Format (Strings.LogDebug.SettlementList, id)); } } return result; }
public static List<Case> List(Auction Auction) { return List (Auction.Id); }
public static Invoice Create(Auction Auction, Customer Customer, bool Simulate) { Invoice result = new Invoice (Customer); List<Item> items; if (Auction != null) { items = Item.List (Auction); } else { items = Item.List (); } foreach (Item item in items) { if (item.AppovedForInvoice) { if (!item.Invoiced) { if (item.CurrentBid != null) { if (item.CurrentBid.CustomerId == Customer.Id) { Case _case = Case.Load (item.CaseId); result._auctionids.Add (_case.AuctionId); result.Lines.Add (new InvoiceLine (item)); } } } } } if (result.Lines.Count == 0) { // EXCEPTION: Exception.InvoiceEmpty throw new Exception (string.Format (Strings.Exception.InvoiceEmpty)); } if (!Simulate) { foreach (InvoiceLine line in result.Lines) { Item item = Item.Load (line.ItemId); item.Invoiced = true; item.Save (); } result.Save (); } return result; }
public static Invoice Create(Auction Auction, Customer Customer) { return Create (Auction, Customer, false); }