/**** ** Generic helpers ****/ /// <summary>Read the config file, migrating legacy settings if applicable.</summary> private ModConfig LoadConfig() { // migrate legacy settings try { if (File.Exists(Path.Combine(this.Helper.DirectoryPath, "config.json"))) { JObject model = this.Helper.ReadConfig <JObject>(); // merge ToggleLookupInFrontOfPlayer bindings into ToggleLookup JObject controls = model.Value <JObject>("Controls"); string toggleLookup = controls?.Value <string>("ToggleLookup"); string toggleLookupInFrontOfPlayer = controls?.Value <string>("ToggleLookupInFrontOfPlayer"); if (!string.IsNullOrWhiteSpace(toggleLookupInFrontOfPlayer)) { controls.Remove("ToggleLookupInFrontOfPlayer"); controls["ToggleLookup"] = string.Join(", ", (toggleLookup ?? "").Split(',').Concat(toggleLookupInFrontOfPlayer.Split(',')).Select(p => p.Trim()).Where(p => p != "").Distinct()); this.Helper.WriteConfig(model); } } } catch (Exception ex) { this.Monitor.Log("Couldn't migrate legacy settings in config.json; they'll be removed instead.", LogLevel.Warn); this.Monitor.Log(ex.ToString()); } // load config return(this.Helper.ReadConfig <ModConfig>()); }
public void PopulateCardSets(Dictionary <string, string> cardSets, JToken cardJToken, string defaultSetCode) { if (cardSets == null || cardJToken == null || string.IsNullOrEmpty(defaultSetCode)) { UnityEngine.Debug.LogError($"PopulateCardSets::MissingInput:{cardSets}:{defaultSetCode}:{cardJToken}"); return; } if (CardSetsInListIsCsv) { string codesCsv = cardJToken.Value <string>(CardSetIdentifier) ?? defaultSetCode; string namesCsv = cardJToken.Value <string>(CardSetNameIdentifier) ?? codesCsv; string[] codes = codesCsv.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] names = namesCsv.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < codes.Length; i++) { string code = codes[i]; string name = i < names.Length ? names[i] : code; cardSets[code] = name; } } else if (CardSetsInList) { List <JToken> setJTokens = new List <JToken>(); try { setJTokens = (cardJToken[CardSetIdentifier] as JArray)?.ToList() ?? new List <JToken>(); } catch { UnityEngine.Debug.LogWarning($"PopulateCardSets::BadCardSetIdentifier for {cardJToken.ToString()}"); } foreach (JToken setJToken in setJTokens) { if (CardSetIsObject) { JObject setObject = setJToken as JObject; string setCode = setObject?.Value <string>(SetCodeIdentifier) ?? defaultSetCode; string setName = setObject?.Value <string>(SetNameIdentifier) ?? setCode; cardSets[setCode] = setName; } else { string code = setJToken.Value <string>(CardSetIdentifier) ?? defaultSetCode; string name = setJToken.Value <string>(CardSetNameIdentifier) ?? code; cardSets[code] = name; } } } else if (CardSetIsObject) { JObject setObject = null; try { setObject = cardJToken[CardSetIdentifier] as JObject; } catch { UnityEngine.Debug.LogWarning($"PopulateCardSets::BadCardSetIdentifier for {cardJToken.ToString()}"); } string setCode = setObject?.Value <string>(SetCodeIdentifier) ?? defaultSetCode; string setName = setObject?.Value <string>(SetNameIdentifier) ?? setCode; cardSets[setCode] = setName; } else { string code = cardJToken.Value <string>(CardSetIdentifier) ?? defaultSetCode; string name = cardJToken.Value <string>(CardSetNameIdentifier) ?? code; cardSets[code] = name; } }
public CoolapkMessageException(JObject o, Exception innerException) : base(o?.Value <string>("message") ?? string.Empty, innerException) { if (o != null && o.TryGetValue("messageStatus", out JToken token)) { MessageStatus = token.ToString(); } }
/// <inheritdoc /> public override void Run(JObject userData, ClaimsIdentity identity, string issuer) { var value = userData?.Value <string>(JsonKey); if (string.IsNullOrEmpty(value)) { // Not found return; } var claim = identity.FindFirst(c => string.Equals(c.Type, JsonKey, System.StringComparison.OrdinalIgnoreCase)); if (claim != null && string.Equals(claim.Value, value, System.StringComparison.Ordinal)) { // Duplicate return; } claim = identity.FindFirst(c => { // If this claimType is mapped by the JwtSeurityTokenHandler, then this property will be set return(c.Properties.TryGetValue(JwtSecurityTokenHandler.ShortClaimTypeProperty, out var shortType) && string.Equals(shortType, JsonKey, System.StringComparison.OrdinalIgnoreCase)); }); if (claim != null && string.Equals(claim.Value, value, System.StringComparison.Ordinal)) { // Duplicate with an alternate name. return; } identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); }
public Task <object?> GetData(string path) { var value = path.SplitPath() .Aggregate((JToken?)data, (data, segment) => data?.Value <JToken>(segment)); return(Task.FromResult <object?>(value)); }
/// <inheritdoc /> public override void Run(JObject userData, ClaimsIdentity identity, string issuer) { var value = userData?.Value <string>(JsonKey); if (!string.IsNullOrEmpty(value)) { identity.AddClaim(new Claim(ClaimType, value, ValueType, issuer)); } }
internal void TryAddClaimByJsonKey(string propertyName, string claimType, string valueType = ClaimValueTypes.String) { var value = userData?.Value <string>(propertyName); if (!string.IsNullOrEmpty(value)) { identity.AddClaim(new Claim(claimType, value, valueType, issuer)); } }
public static Resolutions FromJson(JObject json) { Resolutions resolutions = null; if (json != null) { resolutions = new Resolutions { ResolutionsPerAuthority = json?.Value <JArray>("resolutionsPerAuthority").ToObject <List <ResolutionAuthorityResult> >() }; } return(resolutions); }
public static void LoadUsers(string url = "https://api.hipchat.com/v2/user?max-results=1000&startIndex=0&include-guests=false&include-deleted=false") { var client = new HipchatClient(_personalAccessToken); Task <HttpResponseMessage> response = client.GetAsync(url); response.Wait(); Task <string> y = response.Result.Content.ReadAsStringAsync(); y.Wait(); var resObj = JObject.Parse(y.Result); JObject links = resObj.Value <JObject>("links"); string next = links?.Value <string>("next"); if (next != null) { LoadUsers(next); } JArray items = resObj.Value <JArray>("items"); using (var ctx = new HipchatEntities()) { foreach (var i in items) { long userId = i.Value <long>("id"); string name = i.Value <string>("name"); string mentionName = i.Value <string>("mention_name"); Console.WriteLine($"Loading user '{name}'..."); var user = ctx.Users.FirstOrDefault(r => r.id == userId); if (user == null) { user = new User() { name = name, id = userId, mention_name = mentionName }; ctx.Users.Add(user); } ctx.SaveChanges(); LoadUserMessages(userId); } } }
private static IDictionary <string, string> GetObjectArgument(JObject arguments, string dotNetPropertyName) { JObject jObject = arguments?.Value <JObject>(dotNetPropertyName.ToCamelCase()); if (jObject == null) { return(null); } var dictionary = new Dictionary <string, string>(); foreach (JProperty jProperty in jObject.Properties()) { dictionary.Add(jProperty.Name, jProperty.Value.ToString()); } return(dictionary); }
/// <summary> /// Ship id, filename pairs /// </summary> private void BuildFileRegistry() { try { FileRegistry.Clear(); foreach (string file in fileList) { JObject obj = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(file)); string id = obj?.Value <string>("id"); if (id != null && !FileRegistry.ContainsKey(id)) { FileRegistry.Add(id, file); } } } catch (Exception e) { Console.WriteLine($"invalid file {e}"); } }
public SpeechletRequest Parse(JObject json) { var requestTypeParts = json?.Value <string>("type")?.Split('.'); if (requestTypeParts == null) { throw new ArgumentException("json"); } var requestType = requestTypeParts.Length > 1 ? requestTypeParts[0] : string.Empty; var requestSubtype = requestTypeParts.Last(); var request = Parse(requestType, requestSubtype, json); if (request == null) { throw new ArgumentException("json"); } return(request); }
/// <summary> /// ship id, ship shape pairs /// useful if we only want to draw the shapes /// </summary> private void BuildShapeRegistry() { try { ShapeRegistry.Clear(); foreach (string file in fileList) { JObject obj = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(file)); string id = obj?.Value <string>("id"); //build the ship's shape ShapeFactory shapeFac = new ShapeFactory(); float scale = obj.Value <float>("scale"); Shape shape = shapeFac.Create(obj.Value <JObject>("shape"), scale, SwinGame.PointAt(0, 0)); //done if (id != null && shape != null && !ShapeRegistry.ContainsKey(id)) { ShapeRegistry.Add(id, shape); } } } catch (Exception e) { Console.WriteLine($"invalid file {e}"); } }
public void ParseData(string data) { if (Properties.Length > 0) { JObject obj = JsonConvert.DeserializeObject <JObject>(data); if (obj != null) { for (int i = 0; i < Properties.Length; i++) { Properties[i].InputData = DevilCfg.ReguexTypeValue(Properties[i].TypeName, obj.Value <string>(Properties[i].PropertyName), Properties[i].DefaultValue); } } } UpdatePropertiesInfo(); }
public void LoadCardFromJToken(JToken cardJToken, string defaultSetCode) { if (cardJToken == null) { UnityEngine.Debug.LogWarning("LoadCardFromJToken::NullCardJToken"); return; } string cardId = cardJToken.Value <string>(CardIdIdentifier) ?? string.Empty; if (string.IsNullOrEmpty(cardId)) { UnityEngine.Debug.LogWarning("LoadCardFromJToken::InvalidCardId:" + cardJToken.ToString()); return; } string cardName = cardJToken.Value <string>(CardNameIdentifier) ?? string.Empty; Dictionary <string, PropertyDefValuePair> cardProperties = new Dictionary <string, PropertyDefValuePair>(); foreach (PropertyDef property in CardProperties) { PropertyDefValuePair newPropertyEntry = new PropertyDefValuePair() { Def = property }; try { string listValue = string.Empty; JObject jObject = null; switch (property.Type) { case PropertyType.ObjectEnumList: listValue = string.Empty; foreach (JToken jToken in cardJToken[property.Name]) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } jObject = jToken as JObject; listValue += jObject?.Value <string>("id") ?? string.Empty; } newPropertyEntry.Value = listValue; break; case PropertyType.ObjectList: listValue = string.Empty; foreach (JToken jToken in cardJToken[property.Name]) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } jObject = jToken as JObject; listValue += jObject?.ToString() ?? string.Empty; } newPropertyEntry.Value = listValue; break; case PropertyType.ObjectEnum: jObject = cardJToken[property.Name] as JObject; newPropertyEntry.Value = jObject.Value <string>("id") ?? string.Empty; break; case PropertyType.Object: jObject = cardJToken[property.Name] as JObject; newPropertyEntry.Value = jObject?.ToString() ?? string.Empty; break; case PropertyType.StringEnumList: case PropertyType.StringList: listValue = string.Empty; foreach (JToken jToken in cardJToken[property.Name]) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } listValue += jToken.Value <string>() ?? string.Empty; } newPropertyEntry.Value = listValue; break; case PropertyType.EscapedString: newPropertyEntry.Value = (cardJToken.Value <string>(property.Name) ?? string.Empty).Replace("\\", ""); break; case PropertyType.StringEnum: case PropertyType.Number: case PropertyType.Integer: case PropertyType.Boolean: case PropertyType.String: default: newPropertyEntry.Value = cardJToken.Value <string>(property.Name) ?? string.Empty; break; } } catch { newPropertyEntry.Value = string.Empty; } cardProperties[property.Name] = newPropertyEntry; } HashSet <string> setCodes = new HashSet <string>(); if (SetsInCardObject) { JToken setContainer = cardJToken[CardSetIdentifier]; List <JToken> setJTokens = (setContainer as JArray)?.ToList() ?? new List <JToken>(); if (setJTokens.Count == 0) { setJTokens.Add(setContainer); } foreach (JToken jToken in setJTokens) { JObject setObject = jToken as JObject; string setCode = setObject?.Value <string>(SetCodeIdentifier); if (setCode == null) { UnityEngine.Debug.LogWarning("LoadCardFromJToken::InvalidSetObject:" + setContainer.ToString()); } else { setCodes.Add(setCode); } } } else { setCodes.Add(cardJToken.Value <string>(CardSetIdentifier) ?? defaultSetCode); } foreach (string cardSet in setCodes) { bool isReprint = CardNames.Contains(cardName); if (!isReprint) { CardNames.Add(cardName); } Card newCard = new Card(this, setCodes.Count > 1 ? (cardId + "_" + cardSet) : cardId, cardName, cardSet, cardProperties, isReprint); LoadedCards[newCard.Id] = newCard; if (!Sets.ContainsKey(cardSet)) { LoadedSets[cardSet] = new Set(cardSet); } } }
private void UpdateMatch(UpdateData u) { try { JObject c = u.Entity as JObject; switch (u.UpdateType) { case UpdateType.Create: UoW.MatchRepo.AddMatch(c.Value <int>("Id"), c.Value <int>("HomeTeamId"), c.Value <int>("AwayTeamId"), c.Value <short>("GoalsH"), c.Value <short>("GoalsA"), c.Value <short>("Round"), c.Value <StateEnum>("State"), TimeSpan.ParseExact(c.Value <string>("Time"), "g", CultureInfo.InvariantCulture), DateTime.ParseExact(c.Value <string>("Date"), "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture), c.Value <int>("LeagueId"), c.Value <int>("StadiumId")); break; case UpdateType.Update: UoW.MatchRepo.UpdateMatch(new Match { Id = c.Value <int>("Id"), HomeTeamId = c.Value <int>("HomeTeamId"), AwayTeamId = c.Value <int>("AwayTeamId"), GoalsH = c.Value <short>("GoalsH"), GoalsA = c.Value <short>("GoalsA"), Round = c.Value <short>("Round"), State = c.Value <StateEnum>("State"), Time = TimeSpan.ParseExact(c.Value <string>("Time"), "g", CultureInfo.InvariantCulture), Date = DateTime.ParseExact(c.Value <string>("Date"), "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture), LeagueId = c.Value <int>("LeagueId"), StadiumId = c.Value <int>("StadiumId") }); break; case UpdateType.Delete: break; default: break; } } catch (Exception) { } }
public string getChangeHsCode(DataTable dt, JObject json) { string str = ""; if (dt.Rows[0]["HSCODE"].ToString() != json.Value <string>("HSCODE").ToString()) { str += "HS编码:" + dt.Rows[0]["HSCODE"] + "——>" + json.Value <string>("HSCODE") + "。"; } if (dt.Rows[0]["HSNAME"].ToString() != json.Value <string>("HSNAME").ToString()) { str += "名称:" + dt.Rows[0]["HSNAME"] + "——>" + json.Value <string>("HSNAME") + "。"; } if (dt.Rows[0]["LEGALUNIT"].ToString() != json.Value <string>("LEGALUNITNAME").ToString()) { str += "法定单位:" + dt.Rows[0]["LEGALUNIT"] + "——>" + json.Value <string>("LEGALUNITNAME") + "。"; } if (dt.Rows[0]["NUM"].ToString() != json.Value <string>("NUMNAME").ToString()) { str += "数量:" + dt.Rows[0]["NUMNAME"] + "——>" + json.Value <string>("NUMNAME") + "。"; } if (dt.Rows[0]["WEIGHT"].ToString() != json.Value <string>("WEIGHT").ToString()) { str += "重量:" + dt.Rows[0]["WEIGHT"] + "——>" + json.Value <string>("WEIGHT") + "。"; } if (dt.Rows[0]["CUSTOMREGULATORY"].ToString() != json.Value <string>("CUSTOMREGULATORY").ToString()) { str += "海关监管:" + dt.Rows[0]["CUSTOMREGULATORY"] + "——>" + json.Value <string>("CUSTOMREGULATORY") + "。"; } if (dt.Rows[0]["INSPECTIONREGULATORY"].ToString() != json.Value <string>("INSPECTIONREGULATORY").ToString()) { str += "检验检疫:" + dt.Rows[0]["INSPECTIONREGULATORY"] + "——>" + json.Value <string>("INSPECTIONREGULATORY") + "。"; } if (dt.Rows[0]["ENABLED"].ToString() != json.Value <string>("ENABLED").ToString()) { str += "启用情况:" + dt.Rows[0]["ENABLED"] + "——>" + json.Value <string>("ENABLED") + "。"; } if (dt.Rows[0]["StartDate"].ToString() != json.Value <string>("STARTDATE")) { str += "开始时间:" + dt.Rows[0]["StartDate"] + "——>" + json.Value <string>("STARTDATE") + "。"; } if (dt.Rows[0]["EndDate"].ToString() != json.Value <string>("ENDDATE")) { str += "停用时间:" + dt.Rows[0]["EndDate"] + "——>" + json.Value <string>("ENDDATE") + "。"; } if (dt.Rows[0]["remark"].ToString() != json.Value <string>("REMARK")) { str += "备注:" + dt.Rows[0]["remark"] + "——>" + json.Value <string>("REMARK") + "。"; } return(str); }
public override void Read(JObject jOperation) { Path = jOperation.Value <string>("path"); Value = jOperation.GetValue("value"); }
private static string GetHistoryContentJson(JObject apiResponse) { var content_struct = new CrmHistoryContent { @from = apiResponse.Value <String>("from"), to = apiResponse.Value <String>("to"), cc = apiResponse.Value <String>("cc"), bcc = apiResponse.Value <String>("bcc"), subject = apiResponse.Value <String>("subject"), important = apiResponse.Value <Boolean>("important"), chain_id = apiResponse.Value <String>("chainId"), is_sended = apiResponse.Value <Int32>("folder") == 1, date_created = apiResponse.Value <String>("date"), introduction = apiResponse.Value <String>("introduction"), message_id = apiResponse.Value <Int32>("id") }; var serializer = new DataContractJsonSerializer(typeof(CrmHistoryContent)); using (var stream = new MemoryStream()) { serializer.WriteObject(stream, content_struct); return(Encoding.UTF8.GetString(stream.ToArray())); } }
public static T SafeValue <T>(this JObject jObject) { return(jObject?.Value <string>() == null ? default(T) : jObject.Value <T>()); }
private async Task ApplyPendingUpdatesAsync(CancellationToken cancellationToken) { // apply pending updates until we're cancelled (e.g., due to ios background timeout). List <Tuple <PushNotificationUpdate, Protocol> > pendingUpdateProtocols; lock (_pendingUpdateProtocols) { pendingUpdateProtocols = _pendingUpdateProtocols.ToList(); } SensusServiceHelper.Get().Logger.Log("Attempting to apply " + pendingUpdateProtocols.Count + " pending update(s).", LoggingLevel.Normal, GetType()); foreach (Tuple <PushNotificationUpdate, Protocol> pendingUpdateProtocol in pendingUpdateProtocols) { try { if (cancellationToken.IsCancellationRequested) { SensusServiceHelper.Get().Logger.Log("Cancellation token cancelled while applying pending update(s). ", LoggingLevel.Normal, GetType()); break; } PushNotificationUpdate pendingUpdate = pendingUpdateProtocol.Item1; Protocol protocol = pendingUpdateProtocol.Item2; #region callback if (pendingUpdate.Type == PushNotificationUpdateType.Callback) { string callbackId = pendingUpdate.Content.Value <string>("callback-id"); string invocationId = pendingUpdate.Content.Value <string>("invocation-id"); #if __IOS__ // cancel any previously delivered local notifications for the callback. we do not need to cancel // any pending notifications, as they will either (a) be canceled if the callback is non-repeating // or (b) be replaced if the callback is repeating and gets rescheduled. furthermore, there is a // race condition on app activation in which the callback is updated, run, and rescheduled, after // which the push notification is delivered and is processed. cancelling the newly rescheduled // pending local push notification at this point will terminate the local invocation loop, and the // callback command at this point will contain an invalid invocation ID causing it to not be // rescheduled). thus, both local and remote invocation will terminate and the probe will halt. UserNotifications.UNUserNotificationCenter.Current.RemoveDeliveredNotifications(new[] { callbackId }); #endif await SensusContext.Current.CallbackScheduler.RaiseCallbackAsync(callbackId, invocationId); } #endregion #region clear pnr backlog else if (pendingUpdate.Type == PushNotificationUpdateType.ClearPushNotificationRequestBacklog) { await ClearPushNotificationRequestBacklogAsync(cancellationToken); } #endregion #region protocol else if (pendingUpdate.Type == PushNotificationUpdateType.Protocol) { List <ProtocolSetting> settings = pendingUpdate.Content.Value <JArray>("settings") .Select(setting => setting.ToObject <ProtocolSetting>()) .ToList(); if (await protocol.ApplySettingsAsync(settings, cancellationToken)) { JObject userNotificationObject = pendingUpdate.Content.Value <JObject>("user-notification"); if (userNotificationObject != null) { string message = userNotificationObject.Value <string>("message"); message = "Your study has been updated" + (string.IsNullOrWhiteSpace(message) ? "." : ": " + message.Trim()); await IssueNotificationAsync("Study Updated", message, pendingUpdate.Id, true, protocol, null, NotificationUserResponseAction.None, message); } } } #endregion #region survey agent policy else if (pendingUpdate.Type == PushNotificationUpdateType.SurveyAgentPolicy) { await protocol.UpdateScriptAgentPolicyAsync(pendingUpdate.Content); } #endregion #region sensing agent policy else if (pendingUpdate.Type == PushNotificationUpdateType.SensingAgentPolicy) { await protocol.UpdateSensingAgentPolicyAsync(pendingUpdate.Content); } #endregion } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Exception while applying update: " + ex.Message, LoggingLevel.Normal, GetType()); } finally { // if we haven't been cancelled, then consider the pending update to be complete. this // leaves open the race condition in which the update was actually applied just prior // to the cancellation. in this case, the update will be retained and will be run again // the next time we receive a push notification. we don't see much harm in this for the // operations listed above. if (!cancellationToken.IsCancellationRequested) { lock (_pendingUpdateProtocols) { _pendingUpdateProtocols.Remove(pendingUpdateProtocol); } } } } lock (_pendingUpdateProtocols) { SensusServiceHelper.Get().Logger.Log(_pendingUpdateProtocols.Count + " pending update(s) left.", LoggingLevel.Normal, GetType()); } }
//点击修改 public int update_base_company(JObject json, string stopman) { int i = 0; FormsIdentity identity = HttpContext.Current.User.Identity as FormsIdentity; string userName = identity.Name; string a = json.Value <string>("DECLNATURENAME"); JObject json_user = Extension.Get_UserInfo(userName); //修改经营单位代码 string sql = @"update base_company set code='{0}', name='{1}', remark='{2}', startdate=to_date('{3}','yyyy/mm/dd'), enddate=to_date('{4}','yyyy/mm/dd'), englishname='{5}',declnature='{6}',inspcode='{7}', inspnature='{8}',goodslocal='{9}',receivertype='{10}', SOCIALCREDITNO='{11}',enabled='{12}',stopman='{13}',createdate = sysdate where id='{14}'"; sql = string.Format(sql, json.Value <string>("CODE"), json.Value <string>("NAME"), json.Value <string>("REMARK"), json.Value <string>("STARTDATE") == "" ? DateTime.MinValue.ToShortDateString() : json.Value <string>("STARTDATE"), json.Value <string>("ENDDATE") == "" ? DateTime.MaxValue.ToShortDateString() : json.Value <string>("ENDDATE"), json.Value <string>("ENGLISHNAME"), json.Value <string>("DECLNATURENAME"), json.Value <string>("INSPCODE"), json.Value <string>("INSPNATURENAME"), json.Value <string>("GOODSLOCAL"), json.Value <string>("RECEIVERTYPE"), json.Value <string>("SOCIALCREDITNO"), json.Value <string>("ENABLED"), stopman, json.Value <string>("ID")); i = DBMgrBase.ExecuteNonQuery(sql); //修改客商信息代码 //info.Code, info.InspCode, info.InCode sql = @"update sys_customer set hscode='{0}',ciqcode='{1}' where code='{2}'"; sql = String.Format(sql, json.Value <string>("CODE"), json.Value <string>("INSPCODE"), json.Value <string>("INCODE")); DBMgrBase.ExecuteNonQuery(sql); return(i); }
private void UpdateTeam(UpdateData u) { try { JObject c = u.Entity as JObject; switch (u.UpdateType) { case UpdateType.Create: ImageManager.SaveImage(c.Value <byte[]>("Image"), c.Value <string>("ImageName")); UoW.TeamRepo.AddTeam(c.Value <int>("Id"), c.Value <string>("Name"), DateTime.ParseExact(c.Value <string>("Year"), "yyyy", CultureInfo.InvariantCulture), c.Value <string>("Coach"), c.Value <string>("Sex"), c.Value <CountriesEnum>("Country"), c.Value <int>("StadiumId"), c.Value <int>("LeagueId"), c.Value <string>("ImageName")); break; case UpdateType.Update: ImageManager.SaveImage(c.Value <byte[]>("Image"), c.Value <string>("ImageName")); UoW.TeamRepo.UpdateTeam(new Team { Id = c.Value <int>("Id"), Name = c.Value <string>("Name"), Year = DateTime.ParseExact(c.Value <string>("Year"), "yyyy", CultureInfo.InvariantCulture), Coach = c.Value <string>("Coach"), Sex = c.Value <string>("Sex"), Country = c.Value <CountriesEnum>("Country"), StadiumId = c.Value <int>("StadiumId"), LeagueId = c.Value <int>("LeagueId"), ImageName = c.Value <string>("ImageName") }); break; case UpdateType.Delete: break; default: break; } } catch (Exception) { } }
//获取修改记录 public string getBlendChange(DataTable dt, JObject json, string table) { string str = ""; switch (table) { case "insp_portin": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "国内口岸代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "国内口岸名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名称:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } break; case "insp_portout": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "国际口岸代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "国际口岸名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名称:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } if (dt.Rows[0]["country"].ToString() != json.Value <string>("COUNTRYNAME")) { str += "所属国家:" + dt.Rows[0]["country"] + "——>" + json.Value <string>("COUNTRYNAME") + "。"; } break; case "base_currency": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "币制代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "币制名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["abbreviation"].ToString() != json.Value <string>("ABBREVIATION")) { str += "币制缩写:" + dt.Rows[0]["ABBREVIATION"] + "——>" + json.Value <string>("ABBREVIATION") + "。"; } break; case "base_inspcountry": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "国家代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "中文名:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } if (dt.Rows[0]["AIRABBREV"].ToString() != json.Value <string>("AIRABBREV")) { str += "空运缩写:" + dt.Rows[0]["AIRABBREV"] + "——>" + json.Value <string>("AIRABBREV") + "。"; } if (dt.Rows[0]["OCEANABBREV"].ToString() != json.Value <string>("OCEANABBREV")) { str += "海运缩写:" + dt.Rows[0]["OCEANABBREV"] + "——>" + json.Value <string>("OCEANABBREV") + "。"; } break; case "base_productunit": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "计量单位代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "计量单位名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名称:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } break; case "base_insplicense": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "许可证代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["INNAME"].ToString() != json.Value <string>("INNAME")) { str += "进口许可证名称:" + dt.Rows[0]["INNAME"] + "——>" + json.Value <string>("INNAME") + "。"; } if (dt.Rows[0]["OUTNAME"].ToString() != json.Value <string>("OUTNAME")) { str += "出口许可证名称:" + dt.Rows[0]["OUTNAME"] + "——>" + json.Value <string>("OUTNAME") + "。"; } break; case "base_inspinvoice": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "随附单据代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["INNAME"].ToString() != json.Value <string>("INNAME")) { str += "进口随附单据名称:" + dt.Rows[0]["INNAME"] + "——>" + json.Value <string>("INNAME") + "。"; } if (dt.Rows[0]["OUTNAME"].ToString() != json.Value <string>("OUTNAME")) { str += "出口随附单据名称:" + dt.Rows[0]["OUTNAME"] + "——>" + json.Value <string>("OUTNAME") + "。"; } break; case "base_country": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "国家代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["EZM"].ToString() != json.Value <string>("EZM")) { str += "二字码:" + dt.Rows[0]["EZM"] + "——>" + json.Value <string>("EZM") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "中文名:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } if (dt.Rows[0]["RATE"].ToString() != json.Value <string>("RATE")) { str += "优/普税率:" + dt.Rows[0]["RATE"] + "——>" + json.Value <string>("RATE") + "。"; } break; case "base_decltradeway": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "贸易方式代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "贸易方式简称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["FULLNAME"].ToString() != json.Value <string>("FULLNAME")) { str += "贸易方式全称:" + dt.Rows[0]["FULLNAME"] + "——>" + json.Value <string>("FULLNAME") + "。"; } break; case "base_exemptingnature": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "征免性质代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "征免性质简称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["FULLNAME"].ToString() != json.Value <string>("FULLNAME")) { str += "征免性质全称:" + dt.Rows[0]["FULLNAME"] + "——>" + json.Value <string>("FULLNAME") + "。"; } break; case "base_exchangeway": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "结汇方式代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "结汇方式简称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["FULLNAME"].ToString() != json.Value <string>("FULLNAME")) { str += "结汇方式全称:" + dt.Rows[0]["FULLNAME"] + "——>" + json.Value <string>("FULLNAME") + "。"; } break; case "base_harbour": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "港口代码:" + dt.Rows[0]["CODE"] + "——>" + json.Value <string>("CODE") + "。"; } if (dt.Rows[0]["COUNTRY"].ToString() != json.Value <string>("COUNTRY")) { str += "所属国家:" + dt.Rows[0]["COUNTRY"] + "——>" + json.Value <string>("COUNTRY") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "港口名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["ENGLISHNAME"].ToString() != json.Value <string>("ENGLISHNAME")) { str += "英文名称:" + dt.Rows[0]["ENGLISHNAME"] + "——>" + json.Value <string>("ENGLISHNAME") + "。"; } break; case "base_booksdata": if (dt.Rows[0]["TRADE"].ToString() != json.Value <string>("TRADE")) { str += "贸易方式代码:" + dt.Rows[0]["TRADE"].ToString() + "——>" + json.Value <string>("TRADE"); } if (dt.Rows[0]["ISINPORTNAME"].ToString() != json.Value <string>("ISINPORTNAME")) { str += "贸易方式代码:" + dt.Rows[0]["ISINPORTNAME"].ToString() + "——>" + json.Value <string>("ISINPORTNAME"); } if (dt.Rows[0]["ISPRODUCTNAME"].ToString() != json.Value <string>("ISPRODUCTNAME")) { str += "贸易方式代码:" + dt.Rows[0]["ISPRODUCTNAME"].ToString() + "——>" + json.Value <string>("ISPRODUCTNAME"); } break; case "sys_repway": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "申报方式代码:" + dt.Rows[0]["CODE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "申报方式名称:" + dt.Rows[0]["NAME"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["BUSITYPE"].ToString() != json.Value <string>("BUSITYPE")) { str += "申报方式名称:" + dt.Rows[0]["BUSITYPE"].ToString() + "——>" + json.Value <string>("BUSITYPE"); } break; case "base_containersize": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "集装箱尺寸代码:" + dt.Rows[0]["CODE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "集装箱尺寸:" + dt.Rows[0]["NAME"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["DECLSIZE"].ToString() != json.Value <string>("DECLSIZE")) { str += "集装箱申报尺寸:" + dt.Rows[0]["DECLSIZE"].ToString() + "——>" + json.Value <string>("DECLSIZE"); } break; case "base_containertype": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "集装箱类型代码:" + dt.Rows[0]["CODE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "集装箱类型:" + dt.Rows[0]["NAME"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["CONTAINERCODE"].ToString() != json.Value <string>("CONTAINERCODE")) { str += "集装箱编码:" + dt.Rows[0]["CONTAINERCODE"].ToString() + "——>" + json.Value <string>("CONTAINERCODE"); } break; case "sys_woodpacking": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "木质包装代码:" + dt.Rows[0]["CODE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "木质包装名称:" + dt.Rows[0]["NAME"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["HSCODE"].ToString() != json.Value <string>("HSCODE")) { str += "木质包装HS编码:" + dt.Rows[0]["HSCODE"].ToString() + "——>" + json.Value <string>("HSCODE"); } break; case "sys_declarationcar": if (dt.Rows[0]["LICENSE"].ToString() != json.Value <string>("CODE")) { str += "车牌号:" + dt.Rows[0]["LICENSE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["WHITECARD"].ToString() != json.Value <string>("NAME")) { str += "白卡号:" + dt.Rows[0]["WHITECARD"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["MODELS"].ToString() != json.Value <string>("MODELS")) { str += "车型:" + dt.Rows[0]["MODELS"].ToString() + "——>" + json.Value <string>("MODELS"); } if (dt.Rows[0]["MOTORCADE"].ToString() != json.Value <string>("MOTORCADE")) { str += "车型:" + dt.Rows[0]["MOTORCADE"].ToString() + "——>" + json.Value <string>("MOTORCADE"); } break; case "sys_reportlibrary": if (dt.Rows[0]["CODE"].ToString() != json.Value <string>("CODE")) { str += "申报库别代码:" + dt.Rows[0]["CODE"].ToString() + "——>" + json.Value <string>("CODE"); } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME")) { str += "申报库别名称:" + dt.Rows[0]["NAME"].ToString() + "——>" + json.Value <string>("NAME"); } if (dt.Rows[0]["DECLNAME"].ToString() != json.Value <string>("DECLNAME")) { str += "报关单名称:" + dt.Rows[0]["DECLNAME"].ToString() + "——>" + json.Value <string>("DECLNAME"); } if (dt.Rows[0]["INTERNALTYPE"].ToString() != json.Value <string>("INTERNALTYPE")) { str += "进出口类型:" + dt.Rows[0]["INTERNALTYPE"].ToString() + "——>" + json.Value <string>("INTERNALTYPE"); } break; } if (dt.Rows[0]["StartDate"].ToString() != json.Value <string>("STARTDATE")) { str += "开始时间:" + dt.Rows[0]["StartDate"] + "——>" + json.Value <string>("STARTDATE") + "。"; } if (dt.Rows[0]["EndDate"].ToString() != json.Value <string>("ENDDATE")) { str += "停用时间:" + dt.Rows[0]["EndDate"] + "——>" + json.Value <string>("ENDDATE") + "。"; } if (dt.Rows[0]["remark"].ToString() != json.Value <string>("REMARK")) { str += "备注:" + dt.Rows[0]["remark"] + "——>" + json.Value <string>("REMARK") + "。"; } return(str); }
public string getChangeHsCode2(DataTable dt, JObject json) { string str = ""; if (dt.Rows[0]["HSCODE"].ToString() != json.Value <string>("HSCODE").ToString()) { str += "HS编码:" + dt.Rows[0]["HSCODE"] + "——>" + json.Value <string>("HSCODE") + "。"; } if (dt.Rows[0]["NAME"].ToString() != json.Value <string>("NAME").ToString()) { str += "名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["LEGALUNIT"].ToString() != json.Value <string>("LEGALUNIT").ToString()) { str += "法定单位:" + dt.Rows[0]["LEGALUNIT"] + "——>" + json.Value <string>("LEGALUNIT") + "。"; } if (dt.Rows[0]["SECONDUNIT"].ToString() != json.Value <string>("SECONDUNIT").ToString()) { str += "第二单位单位:" + dt.Rows[0]["SECONDUNIT"] + "——>" + json.Value <string>("SECONDUNIT") + "。"; } if (dt.Rows[0]["EXTRACODE"].ToString() != json.Value <string>("EXTRACODE").ToString()) { str += "附加码:" + dt.Rows[0]["EXTRACODE"] + "——>" + json.Value <string>("EXTRACODE") + "。"; } if (dt.Rows[0]["EXTRACODE"].ToString() != json.Value <string>("EXTRACODE").ToString()) { str += "附加码:" + dt.Rows[0]["EXTRACODE"] + "——>" + json.Value <string>("EXTRACODE") + "。"; } if (dt.Rows[0]["CUSTOMREGULATORY"].ToString() != json.Value <string>("CUSTOMREGULATORY").ToString()) { str += "海关监管:" + dt.Rows[0]["CUSTOMREGULATORY"] + "——>" + json.Value <string>("CUSTOMREGULATORY") + "。"; } if (dt.Rows[0]["INSPECTIONREGULATORY"].ToString() != json.Value <string>("INSPECTIONREGULATORY").ToString()) { str += "国检监管:" + dt.Rows[0]["INSPECTIONREGULATORY"] + "——>" + json.Value <string>("INSPECTIONREGULATORY") + "。"; } if (dt.Rows[0]["GENERALRATE"].ToString() != json.Value <string>("GENERALRATE").ToString()) { str += "一般税率:" + dt.Rows[0]["GENERALRATE"] + "——>" + json.Value <string>("GENERALRATE") + "。"; } if (dt.Rows[0]["FAVORABLERATE"].ToString() != json.Value <string>("FAVORABLERATE").ToString()) { str += "最惠税率:" + dt.Rows[0]["FAVORABLERATE"] + "——>" + json.Value <string>("FAVORABLERATE") + "。"; } if (dt.Rows[0]["VATRATE"].ToString() != json.Value <string>("VATRATE").ToString()) { str += "增值税率:" + dt.Rows[0]["VATRATE"] + "——>" + json.Value <string>("VATRATE") + "。"; } if (dt.Rows[0]["EXPORTREBATRATE"].ToString() != json.Value <string>("EXPORTREBATRATE").ToString()) { str += "出口退税率:" + dt.Rows[0]["EXPORTREBATRATE"] + "——>" + json.Value <string>("EXPORTREBATRATE") + "。"; } if (dt.Rows[0]["TEMPRATE"].ToString() != json.Value <string>("TEMPRATE").ToString()) { str += "暂定税率:" + dt.Rows[0]["TEMPRATE"] + "——>" + json.Value <string>("TEMPRATE") + "。"; } if (dt.Rows[0]["CONSUMERATE"].ToString() != json.Value <string>("CONSUMERATE").ToString()) { str += "消费税率:" + dt.Rows[0]["CONSUMERATE"] + "——>" + json.Value <string>("CONSUMERATE") + "。"; } if (dt.Rows[0]["EXPORTRATE"].ToString() != json.Value <string>("EXPORTRATE").ToString()) { str += "出口税率:" + dt.Rows[0]["EXPORTRATE"] + "——>" + json.Value <string>("EXPORTRATE") + "。"; } if (dt.Rows[0]["TOPPRICE"].ToString() != json.Value <string>("TOPPRICE").ToString()) { str += "最高价格:" + dt.Rows[0]["TOPPRICE"] + "——>" + json.Value <string>("TOPPRICE") + "。"; } if (dt.Rows[0]["LOWPRICE"].ToString() != json.Value <string>("LOWPRICE").ToString()) { str += "最低价格:" + dt.Rows[0]["LOWPRICE"] + "——>" + json.Value <string>("LOWPRICE") + "。"; } if (dt.Rows[0]["SPECIALMARK"].ToString() != json.Value <string>("SPECIALMARK").ToString()) { str += "特殊标志:" + dt.Rows[0]["SPECIALMARK"] + "——>" + json.Value <string>("SPECIALMARK") + "。"; } if (dt.Rows[0]["ELEMENTS"].ToString() != json.Value <string>("ELEMENTS").ToString()) { str += "申报要素:" + dt.Rows[0]["ELEMENTS"] + "——>" + json.Value <string>("ELEMENTS") + "。"; } if (dt.Rows[0]["ENABLED"].ToString() != json.Value <string>("ENABLED").ToString()) { str += "启用情况:" + dt.Rows[0]["ENABLED"] + "——>" + json.Value <string>("ENABLED") + "。"; } if (dt.Rows[0]["StartDate"].ToString() != json.Value <string>("STARTDATE")) { str += "开始时间:" + dt.Rows[0]["StartDate"] + "——>" + json.Value <string>("STARTDATE") + "。"; } if (dt.Rows[0]["EndDate"].ToString() != json.Value <string>("ENDDATE")) { str += "停用时间:" + dt.Rows[0]["EndDate"] + "——>" + json.Value <string>("ENDDATE") + "。"; } if (dt.Rows[0]["remark"].ToString() != json.Value <string>("REMARK")) { str += "备注:" + dt.Rows[0]["remark"] + "——>" + json.Value <string>("REMARK") + "。"; } return(str); }
void processResponseOk(GcmAsyncParameters asyncParam) { var result = new GcmMessageTransportResponse() { ResponseCode = GcmMessageTransportResponseCode.Ok, Message = asyncParam.Message }; var json = new JObject(); var str = string.Empty; try { str = (new StreamReader(asyncParam.WebResponse.GetResponseStream())).ReadToEnd(); } catch { } try { json = JObject.Parse(str); } catch { } result.NumberOfCanonicalIds = json.Value<long>("canonical_ids"); result.NumberOfFailures = json.Value<long>("failure"); result.NumberOfSuccesses = json.Value<long>("success"); var jsonResults = json["results"] as JArray; if (jsonResults == null) jsonResults = new JArray(); foreach (var r in jsonResults) { var msgResult = new GcmMessageResult(); msgResult.MessageId = r.Value<string>("message_id"); msgResult.CanonicalRegistrationId = r.Value<string>("registration_id"); msgResult.ResponseStatus = GcmMessageTransportResponseStatus.Ok; if (!string.IsNullOrEmpty(msgResult.CanonicalRegistrationId)) { msgResult.ResponseStatus = GcmMessageTransportResponseStatus.CanonicalRegistrationId; } else if (r["error"] != null) { var err = r.Value<string>("error") ?? ""; switch (err.ToLowerInvariant().Trim()) { case "ok": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.Ok; break; case "missingregistration": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.MissingRegistrationId; break; case "unavailable": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.Unavailable; break; case "notregistered": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.NotRegistered; break; case "invalidregistration": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.InvalidRegistration; break; case "mismatchsenderid": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.MismatchSenderId; break; case "messagetoobig": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.MessageTooBig; break; case "invaliddatakey": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.InvalidDataKey; break; case "invalidttl": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.InvalidTtl; break; case "internalservererror": msgResult.ResponseStatus = GcmMessageTransportResponseStatus.InternalServerError; break; default: msgResult.ResponseStatus = GcmMessageTransportResponseStatus.Error; break; } } result.Results.Add(msgResult); } asyncParam.WebResponse.Close(); int index = 0; var response = result; foreach (var r in response.Results) { var singleResultNotification = GcmNotification.ForSingleResult(response, index); if (r.ResponseStatus == GcmMessageTransportResponseStatus.Ok) { asyncParam.Callback(this, new SendNotificationResult(singleResultNotification)); } else if (r.ResponseStatus == GcmMessageTransportResponseStatus.CanonicalRegistrationId) { var newRegistrationId = r.CanonicalRegistrationId; var oldRegistrationId = string.Empty; if (singleResultNotification.RegistrationIds != null && singleResultNotification.RegistrationIds.Count > 0) oldRegistrationId = singleResultNotification.RegistrationIds[0]; asyncParam.Callback(this, new SendNotificationResult(singleResultNotification, false, new DeviceSubscriptonExpiredException()) { OldSubscriptionId = oldRegistrationId, NewSubscriptionId = newRegistrationId, IsSubscriptionExpired = true }); } else if (r.ResponseStatus == GcmMessageTransportResponseStatus.Unavailable) { asyncParam.Callback(this, new SendNotificationResult(singleResultNotification, true, new Exception("Unavailable Response Status"))); } else if (r.ResponseStatus == GcmMessageTransportResponseStatus.NotRegistered) { var oldRegistrationId = string.Empty; if (singleResultNotification.RegistrationIds != null && singleResultNotification.RegistrationIds.Count > 0) oldRegistrationId = singleResultNotification.RegistrationIds[0]; asyncParam.Callback(this, new SendNotificationResult(singleResultNotification, false, new DeviceSubscriptonExpiredException()) { OldSubscriptionId = oldRegistrationId, IsSubscriptionExpired = true, SubscriptionExpiryUtc = DateTime.UtcNow }); } else { asyncParam.Callback(this, new SendNotificationResult(singleResultNotification, false, new GcmMessageTransportException(r.ResponseStatus.ToString(), response))); } index++; } Interlocked.Decrement(ref waitCounter); }
private static string ParseContactInfo(JObject obj, string key) { return(obj?.Value <JArray>("elements")? .FirstOrDefault(x => x["type"]?.ToString() == key)?["value"]?.ToString()); }
public void PopulateCardProperty(Dictionary <string, PropertyDefValuePair> cardProperties, JToken cardJToken, PropertyDef property, string key) { if (cardProperties == null || cardJToken == null || property == null) { UnityEngine.Debug.LogError($"PopulateCardProperty::MissingInput:{cardProperties}:{cardJToken}:{property}"); return; } try { PropertyDefValuePair newProperty = new PropertyDefValuePair() { Def = property }; string listValue = string.Empty; JObject jObject = null; switch (property.Type) { case PropertyType.ObjectEnumList: listValue = string.Empty; foreach (JToken jToken in cardJToken[property.Name]) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } jObject = jToken as JObject; listValue += jObject?.Value <string>(CardPropertyIdentifier) ?? string.Empty; } newProperty.Value = listValue; cardProperties[key] = newProperty; break; case PropertyType.ObjectList: foreach (PropertyDef childProperty in property.Properties) { newProperty = new PropertyDefValuePair() { Def = childProperty }; listValue = string.Empty; Dictionary <string, PropertyDefValuePair> values = new Dictionary <string, PropertyDefValuePair>(); int i = 0; foreach (JToken jToken in cardJToken[property.Name]) { PopulateCardProperty(values, jToken, childProperty, key + childProperty.Name + i); i++; } foreach (var entry in values) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } listValue += entry.Value.Value.Replace(EnumDef.Delimiter, ", "); } newProperty.Value = listValue; cardProperties[key + PropertyDef.ObjectDelimiter + childProperty.Name] = newProperty; } break; case PropertyType.ObjectEnum: jObject = cardJToken[property.Name] as JObject; newProperty.Value = jObject.Value <string>(CardPropertyIdentifier) ?? string.Empty; cardProperties[key] = newProperty; break; case PropertyType.Object: jObject = cardJToken[property.Name] as JObject; if (jObject != null && jObject.HasValues) { PopulateCardProperties(cardProperties, cardJToken[property.Name], property.Properties, key + PropertyDef.ObjectDelimiter); } else { PopulateEmptyCardProperty(cardProperties, property, key); } break; case PropertyType.StringEnumList: case PropertyType.StringList: listValue = string.Empty; if (string.IsNullOrEmpty(property.Delimiter)) { foreach (JToken jToken in cardJToken[property.Name]) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } listValue += jToken.Value <string>() ?? string.Empty; } } else { foreach (string token in (cardJToken.Value <string>(property.Name) ?? string.Empty).Split(new[] { property.Delimiter }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrEmpty(listValue)) { listValue += EnumDef.Delimiter; } listValue += token; } } newProperty.Value = listValue; cardProperties[key] = newProperty; break; case PropertyType.EscapedString: newProperty.Value = (cardJToken.Value <string>(property.Name) ?? string.Empty) .Replace(PropertyDef.EscapeCharacter, string.Empty); cardProperties[key] = newProperty; break; case PropertyType.StringEnum: case PropertyType.Boolean: case PropertyType.Integer: case PropertyType.String: default: newProperty.Value = cardJToken.Value <string>(property.Name) ?? string.Empty; cardProperties[key] = newProperty; break; } } catch { PopulateEmptyCardProperty(cardProperties, property, key); } }
private async void BackgroundCheck() { //`! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //`! !!! !!! //`! !!! Turn off Debug Visualizer before stepping through this method live on the stream!!! !!! //`! !!! !!! //`! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! webRequest = WebRequest.Create(string.Format("https://widgets.streamloots.com/alerts/{0}/media-stream", streamlootsID.GetStr())); ((HttpWebRequest)webRequest).AllowReadStreamBuffering = false; WebResponse response = webRequest.GetResponse(); responseStream = response.GetResponseStream(); UTF8Encoding encoder = new UTF8Encoding(); string cardStr = string.Empty; var buffer = new byte[100000]; while (true) { try { while (responseStream.CanRead) { int len = await responseStream.ReadAsync(buffer, 0, 100000); if (len <= 10) { continue; } string text = encoder.GetString(buffer, 0, len); if (string.IsNullOrEmpty(text)) { continue; } cardStr += text; try { JObject cardObject = JObject.Parse("{ " + cardStr + " }"); if (cardObject == null) { continue; } if (!cardObject.ContainsKey("data")) { continue; } cardStr = string.Empty; JObject cardData = cardObject.Value <JObject>("data"); if (!cardData.ContainsKey("data")) { continue; } JObject cardDataData = cardData.Value <JObject>("data"); if (!cardDataData.ContainsKey("type")) { continue; } string type = cardDataData.Value <string>("type"); switch (type.ToLower()) { case "purchase": ProcessChestPurchase(cardObject); break; case "redemption": ProcessCardRedemption(cardObject); break; default: Console.WriteLine($"Unknown Streamloots packet type: {type}"); break; } } catch (Exception) { } // To handle the case where partial packet data is received } } catch (Exception ex) { //System.Diagnostics.Debugger.Break(); Console.WriteLine(ex.ToString()); webRequest = WebRequest.Create(string.Format("https://widgets.streamloots.com/alerts/{0}/media-stream", streamlootsID.GetStr())); ((HttpWebRequest)webRequest).AllowReadStreamBuffering = false; response = webRequest.GetResponse(); responseStream = response.GetResponseStream(); encoder = new UTF8Encoding(); cardStr = string.Empty; buffer = new byte[100000]; } } }
public string getChangeBase_year2(DataTable dt, JObject json) { string str = ""; if (dt.Rows[0]["NAME"] != json.Value <string>("NAME")) { str += "规则名称:" + dt.Rows[0]["NAME"] + "——>" + json.Value <string>("NAME") + "。"; } if (dt.Rows[0]["CUSTOMAREA"].ToString() != json.Value <string>("CUSTOMAREA")) { str += "申报关区:" + dt.Rows[0]["CUSTOMAREA"] + "——>" + json.Value <string>("CUSTOMAREA") + "。"; } if (dt.Rows[0]["ENABLED"] != json.Value <string>("ENABLED")) { str += "是否启用:" + dt.Rows[0]["ENABLED"] + "——>" + json.Value <string>("ENABLED") + "。"; } if (dt.Rows[0]["StartDate"] != json.Value <string>("STARTDATE")) { str += "开始时间:" + dt.Rows[0]["StartDate"] + "——>" + json.Value <string>("STARTDATE") + "。"; } if (dt.Rows[0]["EndDate"] != json.Value <string>("ENDDATE")) { str += "停用时间:" + dt.Rows[0]["EndDate"] + "——>" + json.Value <string>("ENDDATE") + "。"; } if (dt.Rows[0]["remark"] != json.Value <string>("REMARK")) { str += "备注:" + dt.Rows[0]["remark"] + "——>" + json.Value <string>("REMARK") + "。"; } return(str); }
DocumentContainer CreateContainer(JObject jObject) { DocumentContainer container = new DocumentContainer(); container.Id = jObject.Value<string>("_id"); if (container.Id == null) return null; container.Key = jObject.Value<string>("_key"); if (container.Key == null) return null; container.Rev = jObject.Value<string>("_rev"); if (container.Rev == null) return null; container.From = jObject.Value<string>("_from"); container.To = jObject.Value<string>("_to"); container.Document = jObject; return container; }
private static SpeechletRequest RequestFromJson(JObject json) { SpeechletRequest request; var requestTypeParts = json?.Value <string>("type")?.Split('.'); if (requestTypeParts == null) { throw new ArgumentException("json"); } var requestType = requestTypeParts[0]; var requestSubType = requestTypeParts.Length > 1 ? requestTypeParts[1] : null; var requestId = json.Value <string>("requestId"); var timestamp = DateTimeHelpers.FromAlexaTimestamp(json); var locale = json.Value <string>("locale"); switch (requestType) { case "LaunchRequest": request = new LaunchRequest(requestId, timestamp, locale); break; case "IntentRequest": IntentRequest.DialogStateEnum dialogState = IntentRequest.DialogStateEnum.NONE; Enum.TryParse(json.Value <string>("dialogState"), out dialogState); var intent = Intent.FromJson(json.Value <JObject>("intent")); request = new IntentRequest(requestId, timestamp, locale, intent, dialogState); break; case "SessionStartedRequest": request = new SessionStartedRequest(requestId, timestamp, locale); break; case "SessionEndedRequest": SessionEndedRequest.ReasonEnum reason = SessionEndedRequest.ReasonEnum.NONE; Enum.TryParse(json.Value <string>("reason"), out reason); var sessionError = Error.FromJson(json.Value <JObject>("error")); request = new SessionEndedRequest(requestId, timestamp, locale, reason, sessionError); break; case "AudioPlayer": var token = json.Value <string>("token"); var offset = json.Value <long?>("offsetInMilliseconds"); var playbackError = Error.FromJson(json.Value <JObject>("error")); var currentPlaybackState = PlaybackState.FromJson(json.Value <JObject>("currentPlaybackState")); switch (requestSubType) { case "PlaybackFailed": request = new AudioPlayerPlaybackFailedRequest(requestId, timestamp, locale, requestSubType, token, playbackError, currentPlaybackState); break; default: request = new AudioPlayerRequest(requestId, timestamp, locale, requestSubType, token, offset); break; } break; case "PlaybackController": request = new PlaybackControllerRequest(requestId, timestamp, locale, requestSubType); break; case "Display": var listItemToken = json.Value <string>("token"); request = new DisplayRequest(requestId, timestamp, locale, requestSubType, listItemToken); break; case "System": switch (requestSubType) { case "ExceptionEncountered": var systemError = Error.FromJson(json.Value <JObject>("error")); var cause = Cause.FromJson(json.Value <JObject>("cause")); request = new SystemExceptionEncounteredRequest(requestId, timestamp, locale, requestSubType, systemError, cause); break; default: throw new ArgumentException("json"); } break; default: throw new ArgumentException("json"); } return(request); }