private WebServices.MSPBTRootObject GetPBTList()
		{
			WebServices wbs = new WebServices ();
			string mysoalPBTRaw = wbs.getMySoalPBT (Intent.GetStringExtra ("SiteCode"));
			WebServices.MSPBTRootObject pbtList = JsonConvert.DeserializeObject<WebServices.MSPBTRootObject> (mysoalPBTRaw);
			//Toast.MakeText (this, mysoalPBTRaw, ToastLength.Short).Show ();

			return pbtList;
		}
예제 #2
0
		public string GetMyKomunitiJSONData(string token, int paging)
		{
			WebServices wbs = new WebServices ();
			return wbs.GetMyKomunitiAdminFeed (token,paging);
		}
예제 #3
0
		private string SetupMyKomunitiData(){

			WebServices wbs = new WebServices ();

			string tokenData = Activity.Intent.GetStringExtra ("Token");

			string tokenWBSRaw = wbs.setMySkoolAuth(tokenData);

			string tokenWBS = "";

			Console.WriteLine ("Raw Data: {0}",tokenWBSRaw);

			try {

				var tokenWBSjson = JsonConvert.DeserializeObject<WebServices.mySkoolAuthToken> (tokenWBSRaw);

				tokenWBS = tokenWBSjson.token.ToString();

			}
			catch(Exception e) {

				string eLimit = string.Format ("{0}", e).Substring (0, 20);

				AlertDialog alertDialog;
				AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Activity);

				alertDialogBuilder
					.SetTitle ("Masalah")
					.SetMessage (string.Format("Maaf. Sila cuba sekali lagi ({0}...).",eLimit))
					.SetCancelable (true)
					.SetPositiveButton ("OK", exitHandler);

				alertDialog = alertDialogBuilder.Create ();

				alertDialog.Show ();

			}

			return tokenWBS;
		}
예제 #4
0
		private void setupMyHealthData(int page){

			WebServices wbs = new WebServices ();

			string tokenData = Activity.Intent.GetStringExtra ("Token");

			string tokenWBSRaw = wbs.getMyHealthBWRecords(tokenData,page);

			int totalPage = 0;

			Console.WriteLine ("Raw Data: {0}",tokenWBSRaw);

			try {

				var tokenWBSjson = JsonConvert.DeserializeObject<WebServices.MyHealthBodyWeightData> (tokenWBSRaw);

				totalPage = tokenWBSjson.W_data.total;
				lastPage = tokenWBSjson.W_data.last_page;

				Console.WriteLine("[Tab 2] Total BloodPressure: {0}",totalPage);

				if(totalPage != 0)
				{
					if(isRefreshing == true){
						listData.Clear ();
					}
					
					Activity.RunOnUiThread (() => {
						llMHeT2ErrorLayout.Visibility = ViewStates.Gone;
					});

					foreach(var GetData in tokenWBSjson.W_data.data)
					{
						Console.WriteLine("[Tab2] Data MDateTime: {0}",GetData.MdateTime);
						listData.Add(new MyHealth_BodyWeight_ListData() {

							mDateTime = DateTime.ParseExact(GetData.MdateTime.ToString(), "yyyy-MM-dd HH:mm:ss", 
								CultureInfo.InvariantCulture).ToString("dd MMM. yyyy, h:mm:ss tt"),
							mWeight = float.Parse (GetData.WeightValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.###### kg"),
							mNettWeight = GetData.LeanWeight,
							mBMI = float.Parse (GetData.BMI, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######"),
							mBoneMass = float.Parse (GetData.BoneValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######"),
							mFat = float.Parse (GetData.FatValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######")+" %"

						});
						myHealthBWDateList.Add(DateTime.ParseExact(GetData.Mdatef.ToString(), "yyyy-MM-dd", 
							CultureInfo.InvariantCulture).ToString("dd MMM. yyyy"));
						myHealthBWTimeList.Add(DateTime.ParseExact(GetData.Mtimef.ToString(), "HH:mm:ss", 
							CultureInfo.InvariantCulture).ToString("h:mm:ss tt"));
						myHealthBWWeightList.Add(float.Parse (GetData.WeightValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.###### kg"));
						myHealthBWBMIList.Add(float.Parse (GetData.BMI, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######"));
						myHealthBWFatList.Add(float.Parse (GetData.FatValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######")+" %");
						myHealthBWLeanWeightList.Add(float.Parse (GetData.LeanWeight, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######"));
						myHealthBWBoneMassList.Add(float.Parse (GetData.BoneValue, CultureInfo.InvariantCulture.NumberFormat).ToString("0.######"));
						myHealthBWStatusList.Add(getBMIStatus(GetData.BMI));
					}
				}
				else
				{
					Activity.RunOnUiThread (() => {
						llMHeT2ErrorLayout.Visibility = ViewStates.Visible;
						tvMHeT2ErrorStatus.Text = "Anda belum melakukan sebarang pemeriksaan berat badan di PI1M.";
					});
				}
			}
			catch(Exception e) {

				Console.WriteLine ("[Tab_2] Error on inserting data: {0} ",e);

				string eLimit = string.Format ("{0}", e).Substring (0, 20);

				Activity.RunOnUiThread (() => {

					AlertDialog alertDialog;
					AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Activity);

					alertDialogBuilder
						.SetTitle ("Masalah")
					//.SetMessage (string.Format ("Maaf. Sila cuba sekali lagi ({0}...).", eLimit))
						.SetMessage (string.Format ("Tiada data ditemui. Anda mungkin belum membuat sebarang pemeriksaan berat badan di PI1M. Sila hubungi Pengurus PI1M berdekatan dengan anda untuk pertanyaan."))
						.SetCancelable (true)
						.SetPositiveButton ("OK", delegate {
							
					});

					alertDialog = alertDialogBuilder.Create ();

					alertDialog.Show ();

					llMHeT2ErrorLayout.Visibility = ViewStates.Visible;
					tvMHeT2ErrorStatus.Text = "Anda belum melakukan sebarang pemeriksaan berat badan di PI1M.";

				});

			}

			if (Activity != null) {

				Activity.RunOnUiThread (() => {
					
					if (page == 1) {
						
						listDataBW = new MyHealth_BodyWeight_ListDataHolderList (listData);

						mLayoutManager = new LinearLayoutManager (Activity);
						recyclerView.SetLayoutManager (mLayoutManager);

						recyclerAdapterBW = new MyHealth_BodyWeight_RecyclerViewAdapter (Activity, listDataBW, totalPage);
						recyclerView.SetAdapter (recyclerAdapterBW);

						recyclerAdapterBW.ItemClick += ItemClicked;

					} else {
						
						recyclerAdapterBW.NotifyDataSetChanged ();

					}

				});

			}
			//return listData;
		}
예제 #5
0
		public string getMySkoolJSONData(string token, int page)
		{
			WebServices wbs = new WebServices ();
			return wbs.getMySkoolPetiMasuk (token, page);
		}
예제 #6
0
		private void setupMyHealthData(int page){

			WebServices wbs = new WebServices ();

			string tokenData = Activity.Intent.GetStringExtra ("Token");

			string tokenWBSRaw = wbs.getMyHealthBPRecords(tokenData,page);

			int totalPage = 0;


			Console.WriteLine ("Raw Data: {0}",tokenWBSRaw);

			try {

				var tokenWBSjson = JsonConvert.DeserializeObject<WebServices.MyHealthBloodPressureData> (tokenWBSRaw);

				totalPage = tokenWBSjson.BP_data.total;
				lastPage = tokenWBSjson.BP_data.last_page;

				if (totalPage != 0)
				{
					if(isRefreshing == true){
						listData.Clear ();
					}
					
					foreach(var GetData in tokenWBSjson.BP_data.data)
					{
						Console.WriteLine("[Tab2] Data MDateTime: {0}",GetData.MdateTime);
						myHealthDateList.Add(GetData.Mdatef);
						myHealthTimeList.Add(GetData.Mtimef);
						myHealthPulseList.Add(GetData.HR);
						myHealthBPMList.Add(GetData.HP+" / "+GetData.LP+" "+GetData.BPUnitText);
						myHealthStatusList.Add(setStatus(GetData.color));
						listData.Add(new MyHealth_BloodPressure_ListData() {

							mDateTime = DateTime.ParseExact(GetData.MdateTime.ToString(), "yyyy-MM-dd HH:mm:ss", 
								CultureInfo.InvariantCulture
							).ToString("dd MMM. yyyy, h:mm:ss tt"),
							mPressure = GetData.HP+" / "+GetData.LP+" "+GetData.BPUnitText,
							mPulse = GetData.HR+" BPM",
							mBgColor = "#FF"+GetData.color,
							mStatus = setStatus(GetData.color)

						});
					}

					Activity.RunOnUiThread (() => {
						llMHeT1ErrorLayout.Visibility = ViewStates.Gone;
						progressDialog.Hide();
					});
				}
				else
				{
					Activity.RunOnUiThread (() => {
						llMHeT1ErrorLayout.Visibility = ViewStates.Visible;
						tvMHeT1ErrorStatus.Text = "Anda belum membuat sebarang pemeriksaan tekanan darah di PI1M.";
						progressDialog.Hide();
					});
				}
			
			}
			catch(Exception e) {

				Console.WriteLine ("[Tab_2] Error on inserting data: {0} ",e);

				string eLimit = string.Format ("{0}", e).Substring (0, 20);

				Activity.RunOnUiThread (() => {

					AlertDialog alertDialog;
					AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder (Activity);

					alertDialogBuilder
						.SetTitle ("Masalah")
						//.SetMessage (string.Format ("Maaf. Sila cuba sekali lagi ({0}...).", eLimit))
						.SetMessage (string.Format ("Tiada data ditemui. Anda mungkin belum membuat sebarang pemeriksaan tekanan darah di PI1M. Sila hubungi Pengurus PI1M berdekatan dengan anda untuk pertanyaan."))
						.SetCancelable (true)
						.SetPositiveButton ("OK", delegate {
							
					});

					alertDialog = alertDialogBuilder.Create ();

					alertDialog.Show ();

					llMHeT1ErrorLayout.Visibility = ViewStates.Visible;
					tvMHeT1ErrorStatus.Text = "Anda belum membuat sebarang pemeriksaan tekanan darah di PI1M.";

				});

			}

			if (Activity != null) {

				Activity.RunOnUiThread (() => {
					if (page == 1) {
						listDataHL = new MyHealth_BloodPressure_ListDataHolderList (listData);

						mLayoutManager = new LinearLayoutManager (Activity);
						recyclerView.SetLayoutManager (mLayoutManager);

						recyclerAdapter = new MyHealth_BloodPressure_RecyclerViewAdapter (Activity, listDataHL, totalPage);
						recyclerView.SetAdapter (recyclerAdapter);

						recyclerAdapter.ItemClick += ItemClicked;

						progressDialog.Hide ();

						if (isRefreshing == true) { 
							Toast.MakeText (Activity, "Data terkini telah dimuatkan..", ToastLength.Short).Show ();
						}
					} else {
						recyclerAdapter.NotifyDataSetChanged ();
					}
				});
			}
			//return listData;
		}
예제 #7
0
		public string getMyShopFeedJSONData()
		{
			WebServices wbs = new WebServices ();
			return wbs.getMyShopFeed ();
		}
예제 #8
0
		public void processTheLogin(string username, string password, string deviceToken, string imei)
		{
			//Looper.Prepare ();
			//loadingDialog = ProgressDialog.Show (this, "Sila Tunggu", "Sedang Mengesahkan...");
			//Looper.Loop ();

			WebServices wbs = new WebServices ();

			sqliteFile = "PI1Mv2DB.db3";
			libraryPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
			folderPath = libraryPath + "/data/";
			dbPath = System.IO.Path.Combine (folderPath, sqliteFile);

			dbConn = new SQLite.SQLiteConnection (dbPath);
			Console.WriteLine ("[LoginActivity] Checking database path: {0}", dbPath);

			string loginDataRAW = "";

			Console.WriteLine ("[LoginActivity] GCM Token retrieved: {0}", deviceToken);
			//Console.WriteLine ("[LoginActivity] GCM Token recheck: {0}", getAndroidDeviceToken());

			if (retryTimes != 3) {

				if (deviceToken == "") {

					//deviceToken = getAndroidDeviceToken ();
					Thread.Sleep (2000);
					ThreadPool.QueueUserWorkItem(o => processTheLogin(etLLLoginUsername.Text,etLLLoginPassword.Text,GcmClient.GetRegistrationId(this),imei));
					
				} else {
					
					loginDataRAW = wbs.getLoginData2 (username, password, deviceToken, imei, "and");

					var loginData = JsonConvert.DeserializeObject<WebServices.LoginData_TableItems> (loginDataRAW);

					Console.WriteLine ("[LoginActivity] RAW Login Data: {0}", loginDataRAW);
					Console.WriteLine ("[LoginActivity] Status: {0}", loginData.success);

					if (loginData.success == 1) {

						try {

							//check if data exists
							var queryStatus = dbConn.Query<MMenu_LoginInfo> ("SELECT * FROM MMenu_LoginInfo WHERE li_userid = ?", loginData.user_id);
							int existsUserId = 0;

							foreach (var status in queryStatus) {
								Console.WriteLine ("[LoginActivity] User id {0} is detected, login state to {1}", status.li_userid, status.li_loginstate);
								existsUserId = Convert.ToInt32 (status.li_userid.ToString ());
							}

							if (existsUserId != Convert.ToInt32 (loginData.user_id.ToString ())) {
								Console.WriteLine ("[LoginActivity] Insert data...");

								dbConn.Insert (new MMenu_LoginInfo () {
									li_userid = loginData.user_id,
									li_email = loginData.email,
									li_fullname = loginData.full_name,
									li_sitename = loginData.site_name,
									li_sitecode = loginData.sitecode,
									li_siteid = loginData.site_id,
									li_icno = loginData.ic_no,
									li_dashtoken = loginData.token,
									li_loginstate = "1"
								});

								Console.WriteLine ("[LoginActivity] Data Inserted");
							} else {
								Console.WriteLine ("[LoginActivity] Data is existed. Set loginstate to userid {0}...", loginData.user_id);
								var s = dbConn.Query<MMenu_LoginInfo> ("UPDATE MMenu_LoginInfo SET li_loginstate = '1' WHERE li_userid = ?;", loginData.user_id);
								Console.WriteLine ("[MainActivity] Check if logging out is success: {0}", s);
							}

						} catch (Exception e) {

							Console.WriteLine ("[LoginActivity] Error in inserting data: {0}", e);

						}

						Intent mainActivity = new Intent (this, typeof(Splash));
						mainActivity.PutExtra ("UserID", loginData.user_id);
						mainActivity.PutExtra ("Email", loginData.email);
						mainActivity.PutExtra ("FullName", loginData.full_name);
						mainActivity.PutExtra ("SiteName", loginData.site_name);
						mainActivity.PutExtra ("SiteCode", loginData.sitecode);
						mainActivity.PutExtra ("ICNo", loginData.ic_no);
						mainActivity.PutExtra ("Token", loginData.token);
						StartActivity (mainActivity);

						//store SharedPreferences for future use
						ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (this);
						ISharedPreferencesEditor editor = prefs.Edit ();
						editor.PutString ("userID", loginData.user_id);
						editor.Apply();      

						MyVote.Const.tokenData = loginData.token;
						MyVote.Const.siteID = loginData.site_id;

						this.Finish ();
					} else {
					
						//Looper.Prepare ();
						RunOnUiThread (() => {
						
							//loadingDialog.Hide();
							mProgressBar.Visibility = ViewStates.Invisible;
							btnLLLoginAuthBtn.Enabled = true;
							etLLLoginUsername.Enabled = true;
							etLLLoginPassword.Enabled = true;
							Snackbar
								.Make(FindViewById(Android.Resource.Id.Content),Resource.String.login_failed_warning,Snackbar.LengthLong)
								.SetAction(Resource.String.generallabel_okbtn,delegate {})
								.Show();
							//Toast.MakeText (this, "Nama Pengguna dan/atau Kata Laluan tidak sah.", ToastLength.Long).Show ();

						});
						//Looper.Loop ();
						//loadingDialog.Hide ();

					}

				}

				retryTimes++;

			} else {

				RunOnUiThread (() => {

					//loadingDialog.Hide();
					mProgressBar.Visibility = ViewStates.Invisible;
					btnLLLoginAuthBtn.Enabled = true;
					etLLLoginUsername.Enabled = true;
					etLLLoginPassword.Enabled = true;
					Snackbar
						.Make(FindViewById(Android.Resource.Id.Content),Resource.String.login_unknownfailure_warning,Snackbar.LengthLong)
						.SetAction(Resource.String.generallabel_okbtn,delegate {})
						.Show();
					//Toast.MakeText (this, "Terdapat masalah. Sila cuba sekali lagi.", ToastLength.Long).Show ();

				});

				//GcmClient.UnRegister (this);
				retryTimes = 0;

			}
		}