Exemplo n.º 1
0
        public List <ItemSchema.ItemDBSchema> GetUserInventory(string userName)
        {
            var queryRequest = new QueryRequest()
                               .Statement("SELECT meta(`FarmWorld`).id, * FROM FarmWorld WHERE userName=$1 AND uniqueName IS NOT MISSING;")
                               .AddPositionalParameter(userName)
                               .ScanConsistency(ScanConsistency.RequestPlus);
            var result = _bucket.Query <dynamic>(queryRequest);

            if (!result.Success)
            {
                Console.WriteLine(String.Format("Getting items for user {0} failed with error {1}.", userName, result.Errors));
                return(null);
            }

            List <ItemSchema.ItemDBSchema> ret = new List <ItemSchema.ItemDBSchema>(result.Rows.Count);

            foreach (var row in result.Rows)
            {
                Newtonsoft.Json.Linq.JObject itemJson = row.GetValue("FarmWorld");
                string id = row.GetValue("id");

                ItemSchema.ItemDBSchema item = new ItemSchema.ItemDBSchema();
                item.id         = id;
                item.quantity   = itemJson.Value <int>("quantity");
                item.uniqueName = itemJson.Value <string>("uniqueName");
                item.userName   = itemJson.Value <string>("userName");
                ret.Add(item);
            }

            return(ret);
        }
Exemplo n.º 2
0
            public override object ReadJson(JsonReader _Reader, Type _ObjectType, object _ExistingValue, JsonSerializer _Serializer)
            {
                // BaseResponseErrors can either be a string or an object containing more extensive information.
                // Internally we want to represent both version as an object, but when the source data is a simple string we only fill in the message property.

                Newtonsoft.Json.Linq.JToken jtoken = _Serializer.Deserialize <Newtonsoft.Json.Linq.JToken>(_Reader);

                if (jtoken.Type == Newtonsoft.Json.Linq.JTokenType.String)
                {
                    BaseResponseError error = new BaseResponseError();
                    error.Message = jtoken.ToObject <string>();
                    return(error);
                }
                else if (jtoken.Type == Newtonsoft.Json.Linq.JTokenType.Object)
                {
                    Newtonsoft.Json.Linq.JObject jobject = jtoken.ToObject <Newtonsoft.Json.Linq.JObject>();

                    BaseResponseError error = new BaseResponseError();
                    error.Code    = jobject.Value <int>("code");
                    error.Message = jobject.Value <string>("message");
                    error.Type    = jobject.Value <string>("type");
                    return(error);
                }

                throw new ArgumentException("A BaseResponseError is expected to be either a string or an object");
            }
        /// <summary>
        /// Click event of stop button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async Task Stop_Clicked(object sender, EventArgs e)
        {
            isRecording = false;
            try
            {
                if (!isRecording)
                {
                    SwitchPlayOrStop(isRecording, true);

                    recorder.StopRecording();
                    // Request Speech REST API
                    speechRecognition.HttpRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(
                        @"https://speech.platform.bing.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US");
                    // Authenticate and get a JSON Web Token (JWT) from the token service.
                    //if (speechRecognition.Task == null || speechRecognition.Task.IsCompleted)
                    await speechRecognition.Authenticate(SPEECH_API_KEY);

                    // Send the request to Bing Speech API REST end point.
                    var displayText = "Could not detect, please try again!";
                    if (String.IsNullOrEmpty(recorder.WavFilePath))
                    {
                        await DisplayAlert("Message", displayText, "Cancel");

                        return;
                    }
                    speechRecognition.AudioFile = recorder.WavFilePath;
                    speechRecognition.SendRequest();
                    // Get response to get your transcribed text.
                    Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(speechRecognition.GetResponse());
                    //Get Display Text Values
                    if (json.Count > 1)
                    {
                        displayText = json.Value <string>("DisplayText");
                        // Translate the display text
                        tranlation.Key    = GOOGLE_TRANSLATE_API;
                        tranlation.Text   = displayText;
                        tranlation.Target = "ja";
                        await tranlation.Translate();

                        // Get translated text from response
                        json = Newtonsoft.Json.Linq.JObject.Parse(tranlation.StringJsonReponse);
                        json = json.Value <Newtonsoft.Json.Linq.JObject>("data");
                        var translatedText = (from j in json["translations"] select(string) j["translatedText"]).First <string>().ToString();
                        // Get pronunciation for translated text
                        var pronunciation = await tranlation.CallWatsonPronunciationAPI(translatedText);

                        json = Newtonsoft.Json.Linq.JObject.Parse(pronunciation);

                        TranslatedText.Text   = translatedText;
                        TranslatedText.Detail = json.Value <string>("pronunciation");
                    }
                    RecordedText.Text = displayText.ToString();
                    SwitchPlayOrStop(isRecording, false);
                }
            }
            catch (ArgumentException ex)
            {
                await DisplayAlert("Error", ex.Message, "Cancel");
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompoundFilterExpression"/> class.
 /// </summary>
 /// <param name="jobject">The JSON object that contains the data.</param>
 public CompoundFilterExpression(Newtonsoft.Json.Linq.JObject jobject)
     : this()
 {
     ExpressionType = (Model.FilterExpressionType)jobject.Value <int>("ExpressionType");
     foreach (Newtonsoft.Json.Linq.JObject filter in jobject.Value <Newtonsoft.Json.Linq.JArray>("Filters"))
     {
         Filters.Add(FilterExpression.FromJObject(filter));
     }
 }
Exemplo n.º 5
0
 private void TestControlFile(string controlFileContents)
 {
     Newtonsoft.Json.Linq.JObject jsonObj = (Newtonsoft.Json.Linq.JObject)JsonConvert.DeserializeObject(controlFileContents);
     Assert.AreEqual("jekyll", jsonObj.Value <string>("tool"));
     Assert.AreEqual("3.0.1", jsonObj.Value <string>("version"));
     Assert.AreEqual("CC0-1.0", jsonObj.Value <string>("license"));
     Assert.AreEqual("hl7.fhir.us.STU3IGPublisherBuildPackage", jsonObj.Value <string>("npm-name"));
     Assert.AreEqual("implementationguide/2.xml", jsonObj.Value <string>("source"));
 }
        public ActionResult GetProductList(Newtonsoft.Json.Linq.JObject paging)
        {
            int    start  = Int32.Parse(paging.Value <string>("start"));
            int    limit  = Int32.Parse(paging.Value <string>("limit"));
            string filter = paging.Value <string>("filter");

            ProductInfoList list = ProductInfoList.GetProductInfoList(start, limit);

            // temporary limit, have to inmplement a paging mechanism.
            return(this.Direct(new { totalCount = list.TotalCount, records = list }));
        }
Exemplo n.º 7
0
 public void FromJson(Newtonsoft.Json.Linq.JObject json, ref Player obj)
 {
     obj.userName = json.Value <string>("userName");
     obj.xp       = json.Value <int>("xp");
     obj.id       = json.Value <string>("id");
     obj.x        = json.Value <float>("x");
     obj.y        = json.Value <float>("y");
     obj.z        = json.Value <float>("z");
     obj.rot_x    = json.Value <float>("rot_x");
     obj.rot_y    = json.Value <float>("rot_y");
     obj.rot_z    = json.Value <float>("rot_z");
     obj.rot_w    = json.Value <float>("rot_w");
 }
Exemplo n.º 8
0
        /// <summary>
        /// 根据JSON字符串得到组织机构选择属性
        /// </summary>
        /// <param name="json">例:{"dept":"1","station":"0"}</param>
        /// <returns>dept="1" station="0"</returns>
        public string GetOrganizeAttrString(string json)
        {
            Newtonsoft.Json.Linq.JObject jObject = null;
            try
            {
                jObject = Newtonsoft.Json.Linq.JObject.Parse(json);
            }
            catch { }
            if (null == jObject)
            {
                return(string.Empty);
            }
            StringBuilder stringBuilder = new StringBuilder();
            string        unit          = jObject.Value <string>("unit");
            string        dept          = jObject.Value <string>("dept");
            string        station       = jObject.Value <string>("station");
            string        user          = jObject.Value <string>("user");
            string        more          = jObject.Value <string>("more");
            string        group         = jObject.Value <string>("group");
            string        role          = jObject.Value <string>("role");
            string        rootid        = jObject.Value <string>("rootid");

            stringBuilder.Append(" unit=\"" + (unit.IsNullOrWhiteSpace() ? "0" : unit) + "\"");
            stringBuilder.Append(" dept=\"" + (dept.IsNullOrWhiteSpace() ? "0" : dept) + "\"");
            stringBuilder.Append(" station=\"" + (station.IsNullOrWhiteSpace() ? "0" : station) + "\"");
            stringBuilder.Append(" user=\"" + (user.IsNullOrWhiteSpace() ? "0" : user) + "\"");
            stringBuilder.Append(" more=\"" + (more.IsNullOrWhiteSpace() ? "0" : more) + "\"");
            stringBuilder.Append(" group=\"" + (group.IsNullOrWhiteSpace() ? "0" : group) + "\"");
            stringBuilder.Append(" role=\"" + (role.IsNullOrWhiteSpace() ? "0" : role) + "\"");
            stringBuilder.Append(" rootid=\"" + (rootid.IsNullOrWhiteSpace() ? "0" : rootid) + "\"");
            return(stringBuilder.ToString());
        }
        public TaskStatus Handle(IHttpProxy httpHandler)
        {
            httpHandler.ResponseContentType = "application/json";
            var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >();

            try
            {
                if (forms.Count > 0)
                {
                    //验证sign
                    var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan));
                    if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey))
                    {
                        throw new Exception("签名验证失败");
                    }

                    Newtonsoft.Json.Linq.JObject orderJSONObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["tradeDetail"]);
                    string orderId         = orderJSONObj.Value <string>("orderId");
                    double settleAmount    = orderJSONObj.Value <double>("settleAmount");
                    double commisionAmount = orderJSONObj.Value <double>("commisionAmount");
                    if (ResturantFactory.ResturantListener != null)
                    {
                        new Thread(() =>
                        {
                            try
                            {
                                ResturantFactory.ResturantListener.OnReceiveOrderSettlement(ResturantPlatformType.Meituan, orderId, new ServiceAmountInfo()
                                {
                                    PlatformServiceAmount = commisionAmount,
                                    SettleAmount          = settleAmount
                                });
                            }
                            catch { }
                        }).Start();
                    }
                }
            }
            catch (Exception ex)
            {
                using (Log log = new Log("美团SettlementCallback解析错误"))
                {
                    log.Log(ex.ToString());
                }
                throw ex;
            }
            httpHandler.ResponseWrite("{\"data\":\"OK\"}");

            return(TaskStatus.Completed);
        }
Exemplo n.º 10
0
 private void ProcessDetail(IList <string> entStrList, PurchaseInvoice piEnt)
 {
     if (entStrList != null && entStrList.Count > 0)
     {
         ArrayList idarray            = new ArrayList();
         string    purorderId         = string.Empty;
         decimal   totalInvoiceAmount = 0;
         for (int j = 0; j < entStrList.Count; j++)
         {
             Newtonsoft.Json.Linq.JObject objL   = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
             PurchaseInvoiceDetail        pbdEnt = new PurchaseInvoiceDetail();
             pbdEnt.PurchaseInvoiceId     = piEnt.Id;
             pbdEnt.PurchaseOrderDetailId = objL.Value <string>("PurchaseOrderDetailId");
             pbdEnt.ProductId             = objL.Value <string>("ProductId");
             pbdEnt.ProductCode           = objL.Value <string>("ProductCode");
             pbdEnt.ProductName           = objL.Value <string>("ProductName");
             pbdEnt.BuyPrice        = Convert.ToDecimal(objL.Value <string>("BuyPrice"));
             pbdEnt.InvoiceQuantity = Convert.ToInt32(objL.Value <string>("InvoiceQuantity"));
             pbdEnt.InvoiceAmount   = Convert.ToDecimal(objL.Value <string>("InvoiceAmount"));
             pbdEnt.DoCreate();
             totalInvoiceAmount += pbdEnt.InvoiceAmount.Value;
             //循环每个采购详细的发票数量 如果==采购数  则状态改为已关联
             int novoice = Convert.ToInt32(DataHelper.QueryValue("select SHHG_AimExamine.dbo.fun_getNoInvoiceQuantityByPurchaseOrderDetailId('" + pbdEnt.PurchaseOrderDetailId + "')"));
             if (novoice == 0)
             {
                 PurchaseOrderDetail podEnt = PurchaseOrderDetail.TryFind(objL.Value <string>("PurchaseOrderDetailId"));
                 if (podEnt.PurchaseOrderId != purorderId)
                 {
                     idarray.Add(podEnt.PurchaseOrderId);
                     purorderId = podEnt.PurchaseOrderId;
                 }
                 podEnt.InvoiceState = "已关联";
                 podEnt.DoUpdate();
             }
         }
         //如果所有发票详细的金额==发票的总金额  则把发票的状态改为已关联
         if (totalInvoiceAmount == piEnt.InvoiceAmount)
         {
             piEnt.State = "已关联";
             piEnt.DoUpdate();
         }
         //遍历采购单 如果其下所有的采购详细的发票状态都是已关联 则自身变为已关联
         for (int k = 0; k < idarray.Count; k++)
         {
             IList <EasyDictionary> edics = DataHelper.QueryDictList("select Id from SHHG_AimExamine..PurchaseOrderDetail where PurchaseOrderId='" + idarray[k].ToString() + "' and  InvoiceState='未关联'");
             if (edics.Count == 0)
             {
                 PurchaseOrder poEnt = PurchaseOrder.TryFind(idarray[k].ToString());
                 poEnt.InvoiceState = "已关联";
                 if (poEnt.InWarehouseState == "已入库" && poEnt.PayState == "已付款")
                 {
                     poEnt.OrderState = "已结束";
                 }
                 poEnt.DoUpdate();
             }
         }
     }
 }
Exemplo n.º 11
0
        public static bool CheckSign(Newtonsoft.Json.Linq.JObject jsonObj, Config config)
        {
            SortedDictionary <string, object> dict = new SortedDictionary <string, object>();

            foreach (var jsonItem in jsonObj)
            {
                if (jsonItem.Key != "signature")
                {
                    dict[jsonItem.Key] = jsonObj[jsonItem.Key];
                }
            }
            StringBuilder signContent = new StringBuilder();

            foreach (var keyItem in dict)
            {
                signContent.Append(keyItem.Key);
                signContent.Append('=');
                signContent.Append(keyItem.Value.ToString());
            }
            signContent.Append(config.Secret);

            using (MD5 md5hash = MD5.Create())
            {
                var bs = md5hash.ComputeHash(Encoding.UTF8.GetBytes(signContent.ToString()));
                var sb = new StringBuilder();
                foreach (byte b in bs)
                {
                    sb.Append(b.ToString("x2"));
                }
                //所有字符转为大写
                var myresult = sb.ToString().ToUpper();
                return(myresult == jsonObj.Value <string>("signature"));
            }
        }
Exemplo n.º 12
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Newtonsoft.Json.Linq.JObject item = Newtonsoft.Json.Linq.JObject.Load(reader);

            switch (item.Value <string>("type"))
            {
            case "roster":
                PlayerdataRoster _roster = new PlayerdataRoster();
                serializer.Populate(item.CreateReader(), _roster);
                return(_roster);

            case "participant":
                PlayerdataParticipant @_participant = new PlayerdataParticipant();
                serializer.Populate(item.CreateReader(), @_participant);
                return(@_participant);

            case "asset":
                PlayerdataAsset @_asset = new PlayerdataAsset();
                serializer.Populate(item.CreateReader(), @_asset);
                return(@_asset);

            default:
                return(null);
            }
        }
Exemplo n.º 13
0
        public HttpResponseMessage GetUserProfile(Newtonsoft.Json.Linq.JObject jsonData)
        {
            string ntid  = jsonData.Value <string>("ntid");
            var    _user = commonService.GetSystemUserByNTId(ntid, 1);

            // check user is exists
            if (_user == null)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
            // check user is disabled
            if (_user.Enable_Flag == false)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized));
            }
            // update last login time
            systemService.updateLastLoginDate(_user.Account_UID);
            // response user
            return(Request.CreateResponse(new AuthorizedLoginUser
            {
                Account_UID = _user.Account_UID,
                User_Name = _user.User_Name,
                System_Language_UID = _user.System_Language_UID,
                Token = string.Empty,
                MH_Flag = _user.MH_Flag,
                IsMulitProject = _user.IsMulitProject,
                flowChartMaster_Uid = _user.flowChartMaster_Uid,
                USER_Ntid = _user.User_NTID
            }));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Nekoderuスクレイピング用のLambdaエントリポイント
        /// </summary>
        /// <param name="input">CloudWatchのスケジュールイベント引数</param>
        /// <param name="context">Lambdaの実行コンテキスト</param>
        /// <returns></returns>
        public NekoderuScrapingBatch.NekoData FunctionHandler(Object input, ILambdaContext context)
        {
            context.Logger.LogLine("NekoderuBatch実行開始!");

            this.Context = context;
            NekoderuScrapingBatch model = new NekoderuScrapingBatch(context);

            NekoderuScrapingBatch.NekoData ret = null;
            try {
                Newtonsoft.Json.Linq.JObject obj = (Newtonsoft.Json.Linq.JObject)input;
                DateTime stddt = obj.Value <DateTime>("time");

                context.Logger.LogLine("実行日:" + stddt.ToString("yyyy/MM/dd"));

                ret = model.RunMaigoNekoFromKumamotoAnimalCenter(stddt);
                if (ret.NekoList.Count > 0)
                {
                    model.SendMaigoNekoInfo(ret);
                }
                else
                {
                    context.Logger.LogLine("登録データなし");
                }
            } catch (Exception ex) {
                context.Logger.LogLine("NekoderuBatch実行中にエラー発生!");
                context.Logger.LogLine(ex.ToString());
            }

            context.Logger.LogLine("NekoderuBatch実行終了!");
            return(ret);
        }
Exemplo n.º 15
0
        public bool Check(Newtonsoft.Json.Linq.JObject data, RuleContext ctx)
        {
            var created = data.Value <DateTime>("created");

            return(Before.HasValue ? created < Before.Value : true &&
                   After.HasValue ? created > After.Value : true);
        }
Exemplo n.º 16
0
        public HttpResponseMessage ChangeUserPassword([FromBody] string value)
        {
            IUserTkService servUser = UnityHelper.Resolve <IUserTkService>();

            Newtonsoft.Json.Linq.JObject data = Newtonsoft.Json.Linq.JObject.Parse(value);
            try
            {
                servUser.ChangePassword(new Guid(data.Value <string>("userId")), data.Value <string>("olderPassword"), data.Value <string>("newPassword"));

                return(Request.CreateResponse(HttpStatusCode.OK, true));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
        private async Task UpdateItemPrice(String name)
        {
            name = name.ToUpper();
            if (items.TryGetValue(name, out Dictionary <String, String> data))
            {
                if (data.TryGetValue("url_name", out string url_name))
                {
                    await AwaitHttpLock();

                    using (HttpResponseMessage responce = await client.GetAsync(@"items/" + url_name + "/statistics"))
                    {
                        http_lock = false;
                        var str = await responce.Content.ReadAsStringAsync();

                        Newtonsoft.Json.Linq.JObject payload = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(str).payload;
                        Newtonsoft.Json.Linq.JArray  jitems  = payload.Value <Newtonsoft.Json.Linq.JObject>("statistics").Value <Newtonsoft.Json.Linq.JArray>("90days");
                        if (jitems.HasValues)
                        {
                            Dictionary <String, String> stats = jitems.Last.ToObject <Dictionary <String, String> >();
                            foreach (var item in stats)
                            {
                                data[item.Key] = item.Value;
                            }
                        }
                        data["Price Last Updated"] = DateTime.UtcNow.ToString();
                    }
                }
            }
        }
Exemplo n.º 18
0
        //json objekat
        //"{"date":"7-3-2018"}"
        public IActionResult Get([FromBody] Newtonsoft.Json.Linq.JObject jdatum)
        {
            string date = jdatum.Value <string>("date");

            if (Convert.ToDateTime(date).CompareTo(DateTime.Now) > 0)
            {
                return(BadRequest("Prosledjeno je vreme vece od trenutnog!"));
            }

            ZadatakContext db = new ZadatakContext();

            List <DbelementP> lista = db.DbelementP
                                      .Where(el => el.DateAndTimeAdded > Convert.ToDateTime(date)).ToList();

            foreach (DbelementP itemP in lista)
            {
                List <DbelementC> listaC = db.DbelementC.Where(el => el.IdElementP == itemP.IdentifikacioniKod).ToList();
                foreach (DbelementC itemC in listaC)
                {
                    itemP.DbelementC.Add(itemC);
                }
            }

            var obj = JsonConvert.SerializeObject(lista, Formatting.Indented
                                                  , new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(this.Content(obj));
        }
        protected override List <Model.Main.TickerData> GetData(double since)
        {
            List <Model.Main.TickerData> finaldata = new List <Model.Main.TickerData>();
            string contents = "";
            string url      = "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=" + _CurrenciesFrom.FirstOrDefault() + "&tsyms=" + _CurrenciesTo.FirstOrDefault();

            using (var wc = new System.Net.WebClient())
                contents = wc.DownloadString(url);

            Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(contents);

            Newtonsoft.Json.Linq.JToken a = o.Value <Newtonsoft.Json.Linq.JToken>("RAW");

            foreach (Newtonsoft.Json.Linq.JToken p in a)
            {
                foreach (Newtonsoft.Json.Linq.JToken c in p)
                {
                    foreach (Newtonsoft.Json.Linq.JToken b in c)
                    {
                        foreach (Newtonsoft.Json.Linq.JToken x in b)
                        {
                            Model.CryptoCompare.CryptoCompareTickerDataObject responsedata = JsonConvert.DeserializeObject <Model.CryptoCompare.CryptoCompareTickerDataObject>(x.ToString());
                            finaldata.Add(ConvertFromSource(responsedata));
                        }
                    }
                }
            }

            return(finaldata.OrderByDescending(x => x.Volume24HourTo).ToList());
        }
Exemplo n.º 20
0
 private static string ExtractMessage(string json)
 {
     Logger.Information($"Deserializing and trying to get 'message' value from: {json}");
     Newtonsoft.Json.Linq.JObject jsonObject = null;
     try
     {
         jsonObject = Newtonsoft.Json.Linq.JObject.Parse(json);
     }
     catch (Exception ex)
     {
         Logger.Error("Exception while de-serializing message: " + ex.ToString());
     }
     if (jsonObject != null)
     {
         try
         {
             var data = jsonObject.Value <string>("message");
             return(data);
         }
         catch (Exception msgEx)
         {
             Logger.Error($"Exception while extracting 'message' property from JSON: " + msgEx.ToString());
             throw new ApplicationException("Couldn't extract message property.");
         }
     }
     else
     {
         throw new ApplicationException("Couldn't deserialze message.");
     }
 }
Exemplo n.º 21
0
        private void Button3_Click(object sender, EventArgs e)
        {
            var data = File.ReadAllBytes(textBox1.Text);

            Newtonsoft.Json.Linq.JObject res = client.Recognize(data, comboBox2.SelectedItem.ToString(), 16000, null);
            if (res.Value <Int32>("err_no") != 0)
            {
                MessageBox.Show(res.Value <String>("err_msg"));
                return;
            }
            Newtonsoft.Json.Linq.JArray resultList = res.Value <Newtonsoft.Json.Linq.JArray>("result");
            textBox3.Text = "";
            foreach (String resultStr in resultList)
            {
                textBox3.Text += resultStr + "\n";
            }
        }
Exemplo n.º 22
0
 protected override FluentNode Create(Type objectType,
                                      Newtonsoft.Json.Linq.JObject jObject)
 {
     if ("interface".Equals(jObject.Value <string>("Type")))
     {
         return(new FluentInterface("default", "default"));
     }
     return(new FluentMethod("default", "default", "default"));
 }
        public Newtonsoft.Json.Linq.JObject GetFormulariumById(Newtonsoft.Json.Linq.JObject request)
        {
            Formularium formularium = Formularium.GetFormularium(request.Value <int>("id"));

            Newtonsoft.Json.JsonSerializer ser  = new JsonSerializer();
            Newtonsoft.Json.Linq.JObject   json = Newtonsoft.Json.Linq.JObject.FromObject(formularium, ser);

            return(json);
        }
Exemplo n.º 24
0
 private void ProcessDetail(IList <string> entStrList)
 {
     ProductsPart.DeleteAll("PId='" + ent.Id + "'");
     if (entStrList != null && entStrList.Count > 0)
     {
         for (int j = 0; j < entStrList.Count; j++)
         {
             Newtonsoft.Json.Linq.JObject objL = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[j]);
             ProductsPart propartEnt           = new ProductsPart();
             propartEnt.PId    = ent.Id;
             propartEnt.PIsbn  = ent.Isbn;
             propartEnt.CId    = objL.Value <string>("CId");
             propartEnt.CIsbn  = objL.Value <string>("Isbn");
             propartEnt.CCount = objL.Value <int>("CCount");
             propartEnt.Remark = objL.Value <string>("Remark");
             propartEnt.DoCreate();
         }
     }
 }
 protected override FormField Create(Type objectType, 
   Newtonsoft.Json.Linq.JObject jObject)
 {
   //TODO: read the raw JSON object through jObject to identify the type
   //e.g. here I'm reading a 'typename' property:
   if("DerivedType".Equals(jObject.Value<string>("typename"))
     return new DerivedClass();
   else
     return new DefaultClass();
   //now the base class' code will populate the returned object.
 }
Exemplo n.º 26
0
 public UserHubModel(Newtonsoft.Json.Linq.JObject o, ImageSource image)
 {
     UserAvatar             = image;
     UserName               = o.Value <string>("username");
     FeedNum                = o.Value <int>("feed");
     FollowNum              = o.Value <int>("follow");
     FansNum                = o.Value <int>("fans");
     LevelNum               = o.Value <int>("level");
     NextLevelExperience    = o.Value <int>("next_level_experience");
     NextLevelPercentage    = o.Value <double>("next_level_percentage");
     LevelTodayMessage      = o.Value <string>("level_today_message");
     NextLevelNowExperience = $"{nextLevelPercentage / 100 * nextLevelExperience:F0}/{nextLevelExperience}";
 }
        protected override GetMalRecsResponse Create(Type objectType, Newtonsoft.Json.Linq.JObject jObject)
        {
            string recType = jObject.Value <string>("RecommendationType");

            if (recType == null || !RecommendationTypes.GetMalRecsResponseFactories.ContainsKey(recType))
            {
                // fallback
                return(new GetMalRecsResponse <Recommendation>());
            }

            return(RecommendationTypes.GetMalRecsResponseFactories[recType]());
        }
Exemplo n.º 28
0
        private void DoBatchSave()
        {
            IList <string> entStrList = RequestData.GetList <string>("data");
            string         sql        = string.Empty;

            if (entStrList != null && entStrList.Count > 0)
            {
                for (int k = 0; k < entStrList.Count; k++)
                {
                    Newtonsoft.Json.Linq.JObject objL = JsonHelper.GetObject <Newtonsoft.Json.Linq.JObject>(entStrList[k]);
                    if (!string.IsNullOrEmpty(objL.Value <string>("Id")))
                    {
                        ExchangeRate erEnt = ExchangeRate.Find(objL.Value <string>("Id"));
                        erEnt.ModifyDate   = System.DateTime.Now;
                        erEnt.ModifyUserId = UserInfo.UserID;
                        erEnt.ModifyName   = UserInfo.Name;
                        erEnt.MoneyType    = objL.Value <string>("MoneyType");
                        erEnt.Rate         = objL.Value <decimal>("Rate");
                        erEnt.Symbo        = objL.Value <string>("Symbo");
                        erEnt.Remark       = objL.Value <string>("Remark");
                        erEnt.DoUpdate();
                    }
                    else
                    {
                        ExchangeRate erEnt = new ExchangeRate();
                        erEnt.MoneyType    = objL.Value <string>("MoneyType");;
                        erEnt.Rate         = objL.Value <decimal>("Rate");
                        erEnt.Symbo        = objL.Value <string>("Symbo");
                        erEnt.CreateId     = UserInfo.UserID;
                        erEnt.CreateName   = UserInfo.Name;
                        erEnt.ModifyDate   = System.DateTime.Now;
                        erEnt.ModifyUserId = UserInfo.UserID;
                        erEnt.ModifyName   = UserInfo.Name;
                        erEnt.CreateTime   = System.DateTime.Now;
                        erEnt.Remark       = objL.Value <string>("Remark");
                        erEnt.DoCreate();
                    }
                }
            }
        }
Exemplo n.º 29
0
        public HttpResponseMessage Update(Guid userId, [FromBody] string value)
        {
            TakeDocService.Document.Interface.ITypeDocumentService servTypeDocument = Utility.MyUnityHelper.UnityHelper.Resolve <TakeDocService.Document.Interface.ITypeDocumentService>();
            try
            {
                Newtonsoft.Json.Linq.JObject data = Newtonsoft.Json.Linq.JObject.Parse(value);
                Guid typeDocumentId            = new Guid(data.Value <string>("id"));
                Guid entityId                  = new Guid(data.Value <string>("entityId"));
                TakeDocModel.TypeDocument type = servTypeDocument.GetBy(x => x.TypeDocumentId == typeDocumentId && x.EntityId == entityId).First();
                type.TypeDocumentLabel    = data.Value <string>("label");
                type.TypeDocumentPageNeed = data.Value <bool>("pageNeed");
                bool deleted = data.Value <bool>("deleted");
                if (type.EtatDeleteData != deleted)
                {
                    type.EtatDeleteData = deleted;
                    type.UserDeleteData = userId;
                    type.DateDeleteData = System.DateTimeOffset.UtcNow;
                }
                type.TypeDocumentWorkflowTypeId = new Guid(data.Value <string>("workflowTypeId"));

                servTypeDocument.Update(type, userId);

                return(Request.CreateResponse());
            }
            catch (Exception ex)
            {
                TakeDocService.LoggerService.CreateError(ex.Message);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemplo n.º 30
0
        protected override Transaction Create(Type objectType,
                                              Newtonsoft.Json.Linq.JObject jObject)
        {
            //TODO: read the raw JSON object through jObject to identify the type
            //e.g. here I'm reading a 'typename' property:

            if (jObject.Value <string>("transactionTypeId").Equals("3"))
            {
                return(new JournalTransaction());
            }

            return(new Transaction());
        }