예제 #1
0
 public void GetClassificationReception()
 {
     try
     {
         var objClassification = new SwiftExpressWSClassification();
         var pResult           = "";
         var ds = objClassification.GetClassificationReception(_cs, ref pResult);
         if (pResult == "")
         {
             if (ds.Tables[0].Rows.Count > 0)
             {
                 CbType.DataSource = ds;
                 CbType.TextField  = "VALUE_TEXT_CLASSIFICATION";
                 CbType.ValueField = "MPC01";
                 CbType.DataBind();
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('" + pResult + "');", true);
         }
         objClassification.Dispose();
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "ErrorText", "CallError('Error: " + ex.Message + "');", true);
     }
 }
예제 #2
0
        public static CbTypeViewModel Map(this CbType data)
        {
            var model = new CbTypeViewModel();

            model.Id               = data.Id;
            model.Title            = data.Title;
            model.BeginDate        = data.BeginDate;
            model.EndDate          = data.EndDate;
            model.MetalComposition = data.MetalComposition;
            model.Diameter         = data.Diameter;
            model.Mass             = data.Mass;
            model.MeltValue        = data.MeltValue;
            model.ObverseImageUri  = data.ObverseImageUri;
            model.ReverseImageUri  = data.ReverseImageUri;
            model.SourceUri        = data.Variety.SourceUri;
            model.Coins            = Map(data.Coins);

            model.CountryTitle      = data.Variety.Denomination.Country.Title;
            model.DenominationId    = data.Variety.Denomination.Id;
            model.DenominationTitle = data.Variety.Denomination.Title;
            model.VarietyId         = data.Variety.Id;
            model.VarietyTitle      = data.Variety.Title;

            model.ImageViewModel = new CbCoinImageViewModel
            {
                Title           = data.Title,
                ObverseImageUri = data.ObverseImageUri,
                ReverseImageUri = data.ReverseImageUri
            };

            return(model);
        }
예제 #3
0
 private CbVal(CbType tag, string str)
 {
     Type     = tag;
     data     = default;
     this.str = str;
     arr      = null;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #4
0
 private CbVal(CbType tag)
 {
     Type     = tag;
     data     = default;
     str      = null;
     arr      = null;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #5
0
 private CbVal(CbUnion union)
 {
     Type       = CbType.Union;
     data       = default;
     str        = null;
     arr        = null;
     obj        = null;
     this.union = union;
     numCache   = null;
 }
예제 #6
0
 private CbVal(Dictionary <string, CbVal> obj)
 {
     Type     = CbType.Obj;
     data     = default;
     str      = null;
     arr      = null;
     this.obj = obj;
     union    = null;
     numCache = null;
 }
예제 #7
0
 private CbVal(List <CbVal> arr)
 {
     Type     = CbType.Arr;
     data     = default;
     str      = null;
     this.arr = arr;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #8
0
 private CbVal(Guid uuid)
 {
     Type = CbType.UUID;
     data = new UnionStruct {
         uuid = uuid
     };
     str      = null;
     arr      = null;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #9
0
 private CbVal(DateTime date)
 {
     Type = CbType.Date;
     data = new UnionStruct {
         date = date
     };
     str      = null;
     arr      = null;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #10
0
 private CbVal(bool boolean)
 {
     Type = CbType.Bool;
     data = new UnionStruct {
         boolean = boolean
     };
     str      = null;
     arr      = null;
     obj      = null;
     union    = null;
     numCache = null;
 }
예제 #11
0
        public IList <CbType> ScrapeTypes(string uri)
        {
            System.Threading.Thread.Sleep(1000);

            var types = new List <CbType>();

            var html = GetHtml(uri);

            // get all divs (they alternate between type info and coins) and remove ones we don't want
            var divs = html["div.content > div"].ToList();

            divs.RemoveAt(0);
            //divs.RemoveRange(divs.Count() - 5, 5);

            for (var i = 0; i < divs.Count(); i++)
            {
                var miClass = divs[i].GetAttribute("style");
                if (!miClass.Contains("text-align:"))
                {
                    continue;
                }

                CQ htmlDiv = divs[i].InnerHTML;

                // get title and date range
                var h2 = htmlDiv["h2"].FirstOrDefault();
                GetTypeTitleAndDates(h2.InnerText, out string title, out short beginDate, out short endDate);

                // check if type is already added
                i++; // increment to next div that has coin table
                var exist = types.FirstOrDefault(x => x.Title == title && x.BeginDate == beginDate && x.EndDate == endDate);
                if (exist == null)
                {
                    // get specs
                    var specDivs = htmlDiv["div.coin-table-specs"].ToList();
                    GetTypeSpecs(specDivs, out string metalComposition, out string diameter, out string mass);

                    // create type

                    var type = new CbType
                    {
                        Title            = title,
                        MetalComposition = metalComposition,
                        Diameter         = GetCleanMeasurement(diameter),
                        Mass             = GetCleanMeasurement(mass),
                        BeginDate        = beginDate,
                        EndDate          = endDate,
                        MeltValue        = 0m,
                        Coins            = ScrapeCoins(divs[i])
                    };
                    types.Add(type);
                }
                else
                {
                    // type already exists...just get coins
                    var coins = ScrapeCoins(divs[i]);
                    foreach (var coin in coins)
                    {
                        exist.Coins.Add(coin);
                    }
                }
            }

            return(types);
        }