Esempio n. 1
0
        public EDDN.OutfittingObject GetOutfittingFromFDevIDs(SQL.Datasets.dsEliteDB.tboutfittingbaseDataTable basedata,  Newtonsoft.Json.Linq.JToken outfittingItem, bool param1)
        {
            EDDN.OutfittingObject outfitting = null;
            List<String> nameParts;
            String nameFull;

            try
            {
               
                if(outfittingItem != null)
                { 
                    if(outfittingItem.SelectToken("id", false) == null)
                        throw new NotSupportedException(String.Format("Missing id : {0}", outfittingItem.ToString()));

                    nameFull  = outfittingItem.SelectToken("name", false).ToString().ToLower();
                    nameParts = nameFull.Split(new char[] {'_'}).ToList();

                    if (!ignoreStuff.Contains(nameParts[0]))
                    {
                        SQL.Datasets.dsEliteDB.tboutfittingbaseRow itemData = basedata.FindByid((Int32)outfittingItem.SelectToken("id", false));

                        if(itemData != null)
                        {
                            outfitting = new EDDN.OutfittingObject();

                            outfitting.Id               = itemData.id;
                            outfitting.Category         = itemData.category;
                            outfitting.Name             = itemData.name;
                            outfitting.Mount            = itemData.mount;
                            outfitting.Guidance         = itemData.guidance.ToNString();
                            outfitting.Ship             = itemData.ship.ToNString();
                            outfitting.Class            = itemData._class;
                            outfitting.Rating           = itemData.rating;
                            outfitting.Entitlement      = itemData.entitlement;
                        }
                        else
                            throw new NotSupportedException(String.Format("Unknown id : {0}", outfittingItem.ToString()));
                    }
                }

            }
            catch (NotSupportedException ex)
            {
                Program.MainLog.Log(String.Format("Converting error: {0}", ex.Message));
            }
            catch (Exception ex)
            {
                throw new Exception("Error while converting companion data to shipyard object", ex);
            }

            return outfitting;

        }
Esempio n. 2
0
        public static Address Parse(Newtonsoft.Json.Linq.JToken jToken)
        {
            if (jToken.Type != Newtonsoft.Json.Linq.JTokenType.String)
            {
                throw new ArgumentException("Cannot parse non-string types as addresses");
            }

            return new Address(jToken.ToString());
        }
        internal static CoinsEMarketId Parse(Newtonsoft.Json.Linq.JToken marketIdToken)
        {
            if (marketIdToken.Type != Newtonsoft.Json.Linq.JTokenType.String)
            {
                throw new CoinsEResponseException("Expected market ID as a string but encountered token type \""
                    + marketIdToken.Type + "\".");
            }

            return new CoinsEMarketId(marketIdToken.ToString());
        }
        internal static CryptsyTradeId Parse(Newtonsoft.Json.Linq.JToken tradeIdToken)
        {
            if (tradeIdToken.Type != Newtonsoft.Json.Linq.JTokenType.String)
            {
                throw new CryptsyResponseException("Expected trade ID as a string but encountered token type \""
                    + tradeIdToken.Type + "\".");
            }

            return new CryptsyTradeId(tradeIdToken.ToString());
        }
Esempio n. 5
0
        protected override void MessageReceivedHandler(Newtonsoft.Json.Linq.JObject jsonMessage)
        {
            if (_manager.Config.Filters != null)
            {
                if (ApplyFilters(jsonMessage))
                    return;
            }

            var message = jsonMessage.ToString();

            lock (_locker)
            {
                _jsonQueue.Add(jsonMessage);
            }
        }
        protected override void MessageReceivedHandler(Newtonsoft.Json.Linq.JObject jsonMessage)
        {
            if (_manager.Config.Filters != null)
                ApplyFilters(jsonMessage);

            var message = jsonMessage.ToString();
            LogManager.GetCurrentClassLogger().Trace(message);

            lock (_locker)
            {
                if (_jsonQueue.Count >= _maxQueueSize)
                {
                    // If we've exceeded our queue size, and we're supposed to throw out the oldest objects first,
                    // then remove as many as necessary to get us under our limit
                    if (_queueOverflowDiscardOldest)
                    {
                        LogManager.GetCurrentClassLogger()
                            .Warn("Overflow discarding oldest {0} messages", _jsonQueue.Count - _maxQueueSize + 1);

                        _jsonQueue.RemoveRange(0, (_jsonQueue.Count - _maxQueueSize) + 1);
                    }
                    // Otherwise we're in a "discard newest" mode, and this is the newest message, so just ignore it
                    else
                    {
                        LogManager.GetCurrentClassLogger()
                            .Warn("Overflow discarding newest message: {0}", message);

                        return;
                    }
                }
                _jsonQueue.Add(jsonMessage);
            }
        }
Esempio n. 7
0
 public void populateData(Newtonsoft.Json.Linq.JObject obj)
 {
     Newtonsoft.Json.JsonConvert.PopulateObject(obj.ToString(), this);
 }
Esempio n. 8
0
        public void parseData(Newtonsoft.Json.Linq.JObject obj)
        {
            Newtonsoft.Json.JsonConvert.PopulateObject(obj.ToString(), this);

            String[] array = new String[(int)Fields.COUNT];
            int i = 0;
            foreach (Fields val in Enum.GetValues(typeof(Fields))) {
                array[i] = val.ToString();
                i++;
            }
        }
Esempio n. 9
0
 public Technology(Newtonsoft.Json.Linq.JToken technologyToken)
 {
     this.Title = technologyToken.ToString();
     this.Description = string.Format("Sessions about {0}", Title);
     this.UniqueId = string.Format("Technology-{0}", Title);
 }
Esempio n. 10
0
 public void AddXML(Newtonsoft.Json.Linq.JObject JObject, String RootTag)
 {
     AddXML(Newtonsoft.Json.JsonConvert.DeserializeXmlNode(JObject.ToString(), RootTag));
 }
Esempio n. 11
0
        public bool saveTransaction(Newtonsoft.Json.Linq.JToken model)
        {
            using (var transaction = _ctx.Database.BeginTransaction())
            {
                try
                {
                    JObject obj = JObject.Parse(model.ToString());
                    JToken jsonId = obj["id"];
                    SalesMaster salesMaster = new SalesMaster();
                    salesMaster.Id = jsonId.ToString();

                    JToken jsonLocation = obj["location_name"];
                    salesMaster.LocationName = jsonLocation.ToString();


                    JToken jsonSalesPerson = obj["sales_person_name"];
                    salesMaster.SalesPerson = jsonSalesPerson.ToString();

                    JToken jsonTimeStamp = obj["timeStamp"];
                    salesMaster.TimeStamp = jsonTimeStamp.ToString();

                    JToken jsonCurrency = obj["currency"];
                    salesMaster.Currency = jsonCurrency.ToString();

                    JToken jsonSalesInvoiceNo = obj["sale_invoice_number"];
                    salesMaster.InvoiceNo = jsonSalesInvoiceNo.ToString();

                    JToken jsonSalesAmount = obj["total_sale_amount"];
                    salesMaster.TotalAmount = Convert.ToDouble(jsonSalesAmount.ToString());
                    JToken jsonSalesDetail = obj["SalesDetails"];
                    JToken[] sales = jsonSalesDetail.ToArray();
                    _ctx.salesMaster.Add(salesMaster);
                    foreach (JToken t in sales)
                    {
                        string prodName = t["name"].ToString();
                        int prodId = getProductId(prodName);
                        if (prodId < 0)
                            throw new NullReferenceException();
                        string salesId = salesMaster.Id;
                        int quantity = Convert.ToInt32(t["quantity"].ToString());
                        SalesDetail salesDetail = new SalesDetail() { ProductId = prodId, Quantity = quantity, SalesMasterId = salesId };
                        _ctx.salesDetail.Add(salesDetail);
                    }
                    _ctx.SaveChanges();
                    transaction.Commit();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            
        }
Esempio n. 12
0
 private void writeLocalJson(Newtonsoft.Json.Linq.JArray jsl, string jsonName) /* 更新动画信息json 第一次自定义更新结构 */
 {
     System.IO.File.WriteAllText(Path.Combine(appdataFAPI, @jsonName), jsl.ToString());
 }
 public async void Send(Newtonsoft.Json.Linq.JToken array)
 {
     using (DataWriter dataWriter = new DataWriter(this._socket.OutputStream))
     {
         var result = array.ToString(Formatting.None);
         dataWriter.WriteString(result);
         await dataWriter.StoreAsync();
         dataWriter.DetachStream();
     }
 }