예제 #1
0
 public CCommodities(CCommodities other)             // main fields copied, not the extra data ones
 {
     id            = other.id; name = other.name; buyPrice = other.buyPrice; sellPrice = other.sellPrice; meanPrice = other.meanPrice;
     demandBracket = other.demandBracket; stockBracket = other.stockBracket; stock = other.stock; demand = other.demand;
     type          = other.type;
     StatusFlags   = new List <string>(other.StatusFlags);
     ComparisionLR = ComparisionRL = "";
 }
예제 #2
0
        public static List <CCommodities> Merge(List <CCommodities> left, List <CCommodities> right, string otherstation)
        {
            List <CCommodities> merged = new List <CCommodities>();

            foreach (CCommodities l in left)
            {
                CCommodities m = new CCommodities(l);
                CCommodities r = right.Find(x => x.fdname == l.fdname);
                if (r != null)
                {
                    if (l.buyPrice > 0)     // if we can buy it..
                    {
                        m.ComparisionLR  = (r.sellPrice - l.buyPrice).ToString();
                        m.ComparisionBuy = true;
                    }

                    if (r.buyPrice > 0)
                    {
                        m.ComparisionRL  = (l.sellPrice - r.buyPrice).ToString();
                        m.ComparisionBuy = true;
                    }
                }
                else
                {                                  // not found in right..
                    if (l.buyPrice > 0)            // if we can buy it here, note you can't price it in right
                    {
                        m.ComparisionLR = "No Price";
                    }
                }

                merged.Add(m);
            }

            foreach (CCommodities r in right)
            {
                CCommodities m = merged.Find(x => x.fdname == r.fdname);        // see if any in right we have not merged
                if (m == null)
                {
                    m        = new CCommodities(r);
                    m.fdname = m.fdname + " at " + otherstation;
                    m.ComparisionRightOnly = true;

                    if (r.buyPrice > 0)                             // if we can buy it here, note you can't price it in left
                    {
                        m.ComparisionBuy = true;
                        m.ComparisionRL  = "No price";
                    }
                    merged.Add(m);
                }
            }

            Sort(merged);
            return(merged);
        }