public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { if (obj.getString("cmd") == "vibrate") { Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 200); timer.Tick += (tsender, tevt) => { var t = tsender as System.Windows.Threading.DispatcherTimer; t.Stop(); Microsoft.Devices.VibrateController.Default.Stop(); }; timer.Start(); } if (obj.getString("cmd") == "ring") { SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } }), null); return(null); }
/*public static int IndexOfName(TJSONObject Owner, string Name) * { * int result; * int i; * result = -1; * //@ Unsupported property or method(C): 'Size' * for (i = 0; i < Owner.Size; i ++ ) * { * //@ Unsupported property or method(A): 'Get' * //@ Unsupported property or method(D): 'JsonString' * //@ Unsupported property or method(D): 'Value' * if (Owner.Get(i).JsonString.Value.ToUpper() == Name.ToUpper()) * { * result = i; * break; * } * } * return result; * }*/ // 自己實作之後可以改善效率 public static bool HasName(TJSONObject Owner, string Name) { bool result; result = IndexOfName(Owner, Name) != -1; return(result); }
/** * Returns a TDataSet created by the information contained in the JSONObject * @param value a JSONObject that contains the parameters for create the TDataSet * @return return the TDataSet object created */ public static new TDataSet createFrom(TJSONObject value) { TParams parameters = TParams.CreateParametersFromMetadata(value .getJSONArray("table")); TDataSet dst = new TDataSet(parameters, value); return dst; }
/** * Returns a TDataSet created by the information contained in the JSONObject * @param value a JSONObject that contains the parameters for create the TDataSet * @return return the TDataSet object created */ public static new TDataSet createFrom(TJSONObject value) { TParams parameters = TParams.CreateParametersFromMetadata(value .getJSONArray("table")); TDataSet dst = new TDataSet(parameters, value); return(dst); }
public static int GetStratum_I(TJSONObject Owner, string[] Stratum) { int result; //@ Unsupported property or method(C): 'Value' result = Convert.ToInt32(GetStratumJSONValue(Owner, Stratum).Value); return(result); }
public static double GetStratum_E(TJSONObject Owner, string[] Stratum) { double result; //@ Unsupported property or method(C): 'Value' //@ Unsupported function or procedure: 'StrToFloatDef' result = StrToFloatDef(GetStratumJSONValue(Owner, Stratum).Value, 0.0); return(result); }
public static DateTime GetStratum_D(TJSONObject Owner, string[] Stratum) { DateTime result; //@ Unsupported property or method(C): 'Value' //@ Unsupported function or procedure: 'StrToDateTimeDef' result = StrToDateTimeDef(GetStratumJSONValue(Owner, Stratum).Value, DateTime.Now); return(result); }
// 序列化JSON物件 public static TJSONValue StrToJSONValue(string value) { TJSONValue result; //@ Undeclared identifier(3): 'BytesOf' //@ Undeclared identifier(3): 'TJSONObject' //@ Unsupported property or method(B): 'ParseJSONValue' result = TJSONObject.ParseJSONValue(BytesOf(value), 0); return(result); }
// function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:string=''):string; overload; // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:integer=0):integer; overload; // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:Extended=0.0):Extended; overload; // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:Boolean=false):Boolean; overload; // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:TDateTime=now):TDateTime; overload; // // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:string):string; overload; // begin // try // Result := GetStratumJSONValue(Owner, Stratum).Value; // except // Result := DefValue; // end; // end; // // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:integer):integer; overload; // begin // Result := StrToIntDef(GetStratumJSONValue(Owner, Stratum).Value,DefValue) // end; // // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:Extended):Extended; overload; // begin // Result := StrToFloatDef(GetStratumJSONValue(Owner, Stratum).Value,DefValue); // end; // // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:Boolean):Boolean; overload; // var // mJSONValue:TJSONValue; // begin // mJSONValue :=GetStratumJSONValue(Owner, Stratum); // if mJSONValue is TJSONFalse then // Result := false // else // if mJSONValue is TJSONTrue then // Result := True // else // Result := DefValue; // // end; // // function GetStratumValueDef(Owner:TJSONObject; Stratum:array of string; DefValue:TDateTime):TDateTime; overload; // begin // Result := StrToDateTimeDef(GetStratumJSONValue(Owner, Stratum).Value,DefValue) // end; public static string GetStratum_S(TJSONObject Owner, string[] Stratum) { string result; try { //@ Unsupported property or method(C): 'Value' result = GetStratumJSONValue(Owner, Stratum).Value; } catch { result = ""; } return(result); }
public static TJSONValue GetStratumJSONValue(TJSONObject Owner, string[] Stratum) { TJSONValue result; int i; int index; result = null; if (Stratum.Length == 0) { return(result); } result = Owner; for (i = Stratum.GetLowerBound(0); i <= Stratum.GetUpperBound(0); i++) { //@ Undeclared identifier(3): 'TJSONObject' if (result is TJSONObject) { //@ Undeclared identifier(3): 'TJSONObject' index = IndexOfName(TJSONObject(result), Stratum[i]); if (index != -1) { //@ Undeclared identifier(3): 'TJSONObject' //@ Unsupported property or method(B): 'Get' //@ Unsupported property or method(D): 'JsonValue' result = TJSONObject(result).Get(index).JsonValue; } else { result = null; } } //@ Undeclared identifier(3): 'TJSONArray' //@ Unsupported function or procedure: 'TryStrToInt' else if (result is TJSONArray && TryStrToInt(Stratum[i], index)) { //@ Undeclared identifier(3): 'TJSONArray' //@ Unsupported property or method(B): 'Get' result = TJSONArray(result).Get(index); } else { result = null; } if (!(result != null)) { break; } } return(result); }
public static void ClearJSONObject(TJSONObject xObject) { int i; TJSONPair mPair; //@ Unsupported property or method(C): 'Size' for (i = 0; i < xObject.Size; i++) { //@ Unsupported property or method(A): 'Get' //@ Unsupported property or method(D): 'JsonString' //@ Unsupported property or method(D): 'Value' //@ Unsupported property or method(A): 'RemovePair' mPair = xObject.RemovePair(xObject.Get(i).JsonString.Value); //@ Unsupported property or method(C): 'Free' mPair.Free; } }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { ((MainTweetPage)mp).listBox1.Items.Add(obj.getString("username") + ": " + obj.getString("message")); SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } }), null); return(null); }
private void LoadUsersList() { CTConnection.getLoginUserInstance().GetUserList(users => { this.Dispatcher.BeginInvoke(() => { listBox1.Items.Clear(); UsersArray.Clear(); int i = 0; for (i = 0; i < users.size(); i++) { TJSONObject userItem = users.getJSONObject(i); UsersArray.Add(new UserRecord(userItem.getString("userid"), userItem.getString("username"))); listBox1.Items.Add(userItem.getString("username")); } //listBox1.DataContext = UsersArray; //listBox1.DisplayMemberPath = "UserName"; }); }, ManageExceptionCallback); }
public static bool GetStratum_B(TJSONObject Owner, string[] Stratum) { bool result; TJSONValue mJSONValue; mJSONValue = GetStratumJSONValue(Owner, Stratum); //@ Undeclared identifier(3): 'TJSONFalse' if (mJSONValue is TJSONFalse) { result = false; } //@ Undeclared identifier(3): 'TJSONTrue' else if (mJSONValue is TJSONTrue) { result = true; } else { result = false; } return(result); }
private void LoadAccBookList() { CTConnection.getLoginUserInstance().GetAccListJSON(result => { this.Dispatcher.BeginInvoke(() => { lbAccBook.Items.Clear(); AccBookArray.Clear(); TJSONArray accbooks = result.getJSONArray("accbooks"); int i = 0; for (i = 0; i < accbooks.size(); i++) { TJSONObject AccItem = accbooks.getJSONObject(i); AccBookArray.Add(new AccBook(AccItem.getString("syaccbookcode"), AccItem.getString("syaccbookname"))); lbAccBook.Items.Add(AccItem.getString("syaccbookname")); } if (lbAccBook.Items.Count > 0) { lbAccBook.SelectedIndex = 0; } }); }, ManageExceptionCallback); }
// 以序列的方式操作JSON物件(支援多型) public static void SetStratumValue(TJSONObject Owner, string[] Stratum, int Value) { SetStratumValue(Owner, Stratum, IntToValue(Value)); }
public override TJSONValue Execute(TJSONValue value, int JSONType) { TJSONObject obj = TJSONObject.Parse(value.ToString()); Context.Send(new SendOrPostCallback(x => { string notificationtype = obj.getString("notificationType"); if (notificationtype == "message") { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage mp = frame.Content as PhoneApplicationPage; if (mp is MainTweetPage) { System.Windows.Controls.ListBox listbox = ((MainTweetPage)mp).listBox1; listbox.Items.Add(obj.getString("fromusrname") + " " + obj.getString("datetime")); string msgText = obj.getString("message"); int txtPos = 0; int txtLen = 22; while (txtPos < msgText.Length) { string dipTxt = msgText.Substring(txtPos, txtLen); listbox.Items.Add(dipTxt); txtPos = txtPos + txtLen; if (txtPos + txtLen > msgText.Length) { txtLen = msgText.Length - txtPos; } } SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("tweet.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } else if (notificationtype == "cmd") { if (obj.getString("cmd") == "vibrate") { /* SoundEffect.MasterVolume = 1.0f; * SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); * SoundEffectInstance sfxInstance = sfx.CreateInstance(); * sfxInstance.Play();*/ Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50)); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 0, 200); timer.Tick += (tsender, tevt) => { var t = tsender as System.Windows.Threading.DispatcherTimer; t.Stop(); Microsoft.Devices.VibrateController.Default.Stop(); }; timer.Start(); } if (obj.getString("cmd") == "ring") { SoundEffect.MasterVolume = 1.0f; SoundEffect sfx = SoundEffect.FromStream(TitleContainer.OpenStream("cmd.wav")); SoundEffectInstance sfxInstance = sfx.CreateInstance(); sfxInstance.Play(); } } }), null); return(null); }
public TDataSet(TParams parameters, TJSONObject value) : base(parameters, value) { }
// 以序列的方式操作JSON物件(支援多型) public static void SetStratumValue(TJSONObject Owner, string[] Stratum, TJSONValue Value) { int i; int index; int max; TJSONObject mObj; TJSONObject mObj1; TJSONPair mPar; if (Stratum.Length == 0) { return; } mObj = Owner; max = Stratum.GetUpperBound(0); for (i = 0; i < max; i++) { // 只作到倒數第2個 index = IndexOfName(mObj, Stratum[i]); if (index == -1) { mObj1 = new TJSONObject(); //@ Unsupported property or method(A): 'AddPair' mObj.AddPair(Stratum[i], mObj1); mObj = mObj1; // 現在的兒子是下一次的爸爸 } else { //@ Unsupported property or method(A): 'get' mPar = mObj.get(index); //@ Unsupported property or method(C): 'JsonValue' //@ Undeclared identifier(3): 'TJSONObject' if (mPar.JsonValue is TJSONObject) { //@ Unsupported property or method(C): 'JsonValue' //@ Undeclared identifier(3): 'TJSONObject' mObj = TJSONObject(mPar.JsonValue); } else { // 兒子不是TJSONObject就砍掉重建 //@ Unsupported property or method(C): 'JsonValue' //@ Unsupported property or method(D): 'Free' mPar.JsonValue.Free; mObj1 = new TJSONObject(); //@ Unsupported property or method(C): 'JsonValue' mPar.JsonValue = mObj1; mObj = mObj1; // 現在的兒子是下一次的爸爸 } } } // 做最後一個 index = IndexOfName(mObj, Stratum[max]); if (index == -1) { //@ Unsupported property or method(A): 'AddPair' mObj.AddPair(Stratum[max], Value); } else { //@ Unsupported property or method(A): 'Get' //@ Unsupported property or method(D): 'JsonValue' //@ Unsupported property or method(D): 'Free' mObj.Get(index).JsonValue.Free; //@ Unsupported property or method(A): 'Get' //@ Unsupported property or method(D): 'JsonValue' mObj.Get(index).JsonValue = Value; } }
public static void SetStratumVariant(TJSONObject Owner, string[] Stratum, object Value) { SetStratumValue(Owner, Stratum, VariantToValue(Value)); }
// 以序列的方式操作JSON物件(支援多型) public static void SetStratumValue(TJSONObject Owner, string[] Stratum, DateTime Value) { SetStratumValue(Owner, Stratum, DateTimeToValue(Value)); }
// 以序列的方式操作JSON物件(支援多型) public static void SetStratumValue(TJSONObject Owner, string[] Stratum, bool Value) { SetStratumValue(Owner, Stratum, BooleanToValue(Value)); }