public void TryParse() { if (responsestr != null && webrequest != null) { url=webrequest.baseurl; //set real server url; if (url.Equals (URLManager.ServerURL) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { var jValue = JsonObject.Parse (responsestr); if (jValue.ContainsKey ("serverURL")) { URLManager.Setnn_baseurl (jValue ["serverURL"]); } } //Return all countries which are used in registration else if (url.Equals (URLManager.Country) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<Country> countrylist = new List<Country> (); var jValue = JsonObject.Parse (responsestr); if (jValue.ContainsKey ("items")) { var list = jValue ["items"]; foreach (var item in list) { countrylist.Add (new Country () { country_code = ((JsonValue)item) ["country_code"], country_name = ((JsonValue)item) ["country_name"], }); } } parsedobject = countrylist; } //Return all State and Provnces which are used in registration else if (url.Equals (URLManager.StateAndProvince) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<StateAndProvince> mlist = new List<StateAndProvince> (); var jValue = JsonObject.Parse (responsestr); if (jValue.ContainsKey ("items")) { var list = jValue ["items"]; foreach (var item in list) { StateAndProvince stateandprovince = JsonConvert.DeserializeObject<StateAndProvince> (item.ToString ()); mlist.Add (stateandprovince); } } parsedobject = mlist; } //Authenticate a user else if (url.Equals (URLManager.Login) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Login loginrturn = new Login (); var jValue = JsonObject.Parse (responsestr); if (jValue.ContainsKey ("loginsuccess")) { loginrturn.loginsuccess = jValue ["loginsuccess"]; } if (jValue.ContainsKey ("token_id")) { loginrturn.token_id = jValue ["token_id"]; } if (jValue.ContainsKey ("err_message")) { loginrturn.err_message = jValue ["err_message"]; } parsedobject = loginrturn; } //Create a new user else if (url.Equals (URLManager.Register) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Register registerreturn = new Register (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("result_success")) { registerreturn.result_success = jvalue ["result_success"]; } if (jvalue.ContainsKey ("err_message")) { registerreturn.err_message = jvalue ["err_message"]; } parsedobject = registerreturn; } //Reset user password else if (url.Equals (URLManager.RestPassword) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { ResetPass resetpassreturn = new ResetPass (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("result_success")) { resetpassreturn.result_success = jvalue ["result_success"]; } if (jvalue.ContainsKey ("err_message")) { resetpassreturn.err_message = jvalue ["err_message"]; } parsedobject = resetpassreturn; } //Return all locations which has available events else if (url.Equals (URLManager.Locations) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<Tap5050Location> mlist = new List<Tap5050Location> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050Location location = JsonConvert.DeserializeObject<Tap5050Location> (item.ToString ()); mlist.Add (location); } } parsedobject = mlist; } //Return all the events associate with the location and seller else if (url.Equals (URLManager.Events) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<Tap5050Event> mlist = new List<Tap5050Event> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050Event eventdetail = JsonConvert.DeserializeObject<Tap5050Event> (item.ToString ()); if (!String.IsNullOrEmpty (eventdetail.leader_board)) { string[] leadersString = eventdetail.leader_board.Split('\\'); foreach (var x in leadersString) { if (!String.IsNullOrEmpty (x)) { Tap5050LeaderBoard Tap5050LeaderBoard = new Tap5050LeaderBoard (); string[] stringData = x.Split (';'); Tap5050LeaderBoard.sales = stringData [0]; Tap5050LeaderBoard.last_name = stringData [1].Substring(1); Tap5050LeaderBoard.first_name = stringData [2].Substring(1); Tap5050LeaderBoard.email = stringData [3].Substring(1); eventdetail.LeaderBoardList.Add (Tap5050LeaderBoard); } } } if (!String.IsNullOrEmpty (eventdetail.group_leader_board)) { string[] leadersString = eventdetail.group_leader_board.Split('\\'); foreach (var x in leadersString) { if (!String.IsNullOrEmpty (x)) { Tap5050GroupLeaderBoard Tap5050LeaderBoard = new Tap5050GroupLeaderBoard (); string[] stringData = x.Split (';'); Tap5050LeaderBoard.group_sales = stringData [0]; Tap5050LeaderBoard.groupName = stringData [1].Substring(1); eventdetail.groupLeaderBoardList.Add (Tap5050LeaderBoard); } } } mlist.Add (eventdetail); } } mlist.Sort((Tap5050Event a, Tap5050Event b) => { if (a.gross_sales == "") return 1; if (b.gross_sales == "") return -1; if (Int32.Parse(a.gross_sales) > Int32.Parse(b.gross_sales)) return -1; else return 1; }); parsedobject = mlist; } //Check if the token if valid or not, if its valid it also extend the token else if (url.Equals (URLManager.Checktoken) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //Check if a buyer is a registered user else if (url.Equals (URLManager.CheckUser) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { Tap5050CheckUser result = JsonConvert.DeserializeObject<Tap5050CheckUser> (responsestr); parsedobject = result; } //User request a temp password to login else if (url.Equals (URLManager.RequestTempPass) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //Get the basic information of the user, URLManager.AccountInfo==URLManager.Account, same url differnt verb else if (url.Equals (URLManager.AccountInfo) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { Tap5050AccountInfo result = JsonConvert.DeserializeObject<Tap5050AccountInfo> (responsestr); parsedobject = result; } //edit account result else if (url.Equals (URLManager.UpdateAccountInfo) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //relationship operations else if (url.Equals (URLManager.Relationship) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<Tap5050Relationships> klist = new List<Tap5050Relationships> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050Relationships location = JsonConvert.DeserializeObject<Tap5050Relationships> (item.ToString ()); klist.Add (location); } } parsedobject = klist; } else if (url.Equals (URLManager.Relationship) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)) { Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } else if (url.Equals (URLManager.Relationship) && webrequest.verb.Equals (NetworkManager.HTTPVerb.DELETE)) { Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } else if (url.Equals (URLManager.BaseLocationURL) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { var jValue = JsonObject.Parse (responsestr); GeonamesCountry geonamecountry = new GeonamesCountry (); if (jValue.ContainsKey ("geonames")) { var list = jValue ["geonames"]; foreach (var item in list) { if ((item as JsonValue).ContainsKey ("adminCode1")) { geonamecountry.adminCode1 = ((JsonValue)item) ["adminCode1"]; } if ((item as JsonValue).ContainsKey ("countryName")) { geonamecountry.countryName = ((JsonValue)item) ["countryName"]; } if ((item as JsonValue).ContainsKey ("countryCode")) { geonamecountry.countryCode = ((JsonValue)item) ["countryCode"]; } if ((item as JsonValue).ContainsKey ("adminName1")) { geonamecountry.adminName1 = ((JsonValue)item) ["adminName1"]; } } } parsedobject = geonamecountry; } else if (url.Equals (URLManager.EventHistory) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)) { List<Tap5050HistoryEvents> hlist = new List<Tap5050HistoryEvents> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050HistoryEvents hisotry = JsonConvert.DeserializeObject<Tap5050HistoryEvents> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //version 2 parse actions for team componenet //20. Create Group else if(url.Equals (URLManager.Team) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //21. Disband Group else if(url.Equals (URLManager.Team) && webrequest.verb.Equals (NetworkManager.HTTPVerb.DELETE)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //22. Get List of Groups else if(url.Equals (URLManager.Team) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)){ List<Tap5050TeamInfo> hlist = new List<Tap5050TeamInfo> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050TeamInfo hisotry = JsonConvert.DeserializeObject<Tap5050TeamInfo> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //23. Group invitation else if(url.Equals (URLManager.TeamInvitation) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //24. Get group invite notifications else if(url.Equals (URLManager.TeamInvitation) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)){ List<Tap5050TeamInvitation> hlist = new List<Tap5050TeamInvitation> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050TeamInvitation hisotry = JsonConvert.DeserializeObject<Tap5050TeamInvitation> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //25. Accept Group invitation else if(url.Equals (URLManager.TeamInvitation) && webrequest.verb.Equals (NetworkManager.HTTPVerb.PUT)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //26. Reject Group Invitation else if(url.Equals (URLManager.TeamInvitation) && webrequest.verb.Equals (NetworkManager.HTTPVerb.DELETE)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //27. Join Group Request else if(url.Equals (URLManager.JoinTeamRequest) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //28. Get group request notifications else if(url.Equals (URLManager.JoinTeamRequest) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)){ List<Tap5050TeamRequest> hlist = new List<Tap5050TeamRequest> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050TeamRequest hisotry = JsonConvert.DeserializeObject<Tap5050TeamRequest> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //29. Accept Group request else if(url.Equals (URLManager.JoinTeamRequest) && webrequest.verb.Equals (NetworkManager.HTTPVerb.PUT)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //30. Reject Join Group request else if(url.Equals (URLManager.JoinTeamRequest) && webrequest.verb.Equals (NetworkManager.HTTPVerb.DELETE)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //31. Get group member Info else if(url.Equals (URLManager.TeamMember) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)){ List<Tap5050TeamMemberInfo> hlist = new List<Tap5050TeamMemberInfo> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050TeamMemberInfo hisotry = JsonConvert.DeserializeObject<Tap5050TeamMemberInfo> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //32. Leave group (Both leader and user can use this to kick or leave group) else if(url.Equals (URLManager.TeamMember) && webrequest.verb.Equals (NetworkManager.HTTPVerb.DELETE)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //33. Get Potential Seller to invite (Get a list of potential group member to invite) else if(url.Equals (URLManager.PotentialTeam) && webrequest.verb.Equals (NetworkManager.HTTPVerb.GET)){ List<Tap5050PotentialTeamMemberInfo> hlist = new List<Tap5050PotentialTeamMemberInfo> (); var jvalue = JsonObject.Parse (responsestr); if (jvalue.ContainsKey ("items")) { var list = jvalue ["items"]; foreach (var item in list) { Tap5050PotentialTeamMemberInfo hisotry = JsonConvert.DeserializeObject<Tap5050PotentialTeamMemberInfo> (item.ToString ()); hlist.Add (hisotry); } } parsedobject = hlist; } //34. IOS_PushNotificationTK else if(url.Equals (URLManager.IOS_PushNotificationTK) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } //in app reset password else if(url.Equals (URLManager.InAppResetPWD) && webrequest.verb.Equals (NetworkManager.HTTPVerb.POST)){ Tap5050Result result = JsonConvert.DeserializeObject<Tap5050Result> (responsestr); parsedobject = result; } }//end of responsestr != null && webrequest != null }
public TeamLeaderBoardCard(Tap5050GroupLeaderBoard leaderboarditem,int typeflag=2) { tap5050leaderboard = leaderboarditem; listtypeflag = typeflag; }