using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace FypXFP {
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Login : ContentPage
{ private FypXFP.ServiceReference1.CMSServiceClient _client;
public Login() { InitializeComponent(); }
private void Save_Clicked(object sender, EventArgs e)
{ var endpoint = new EndpointAddress("http://192.168.43.101/FYP_Admin/webservices/cmsservice.svc");
var binding = new BasicHttpBinding
{ Name = "basicHttpBinding",
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647 };
TimeSpan timeout = new TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
_client = new FypXFP.ServiceReference1.CMSServiceClient(binding, endpoint);
string uname = tbuserentry.Text.Trim();
string password = Pwd.Text.Trim();
_client.ValidateUserAsync(uname, password);
_client.ValidateUserCompleted += _client_ValidateUserCompleted;
} public async void Redirect(Boolean Result)
{ if (Result == true)
{
Navigation.InsertPageBefore(new TicketPage(), this);
await Navigation.PopAsync(); }
else
{
await DisplayAlert("Alert", "Something wrong", "Cancel");
}
}
private void _client_ValidateUserCompleted(object sender, ServiceReference1.ValidateUserCompletedEventArgs e)
{
if (e.Result == true)
{
Device.BeginInvokeOnMainThread(() => {
Redirect(true);
});
} else
{
Device.BeginInvokeOnMainThread(() => {
Redirect(false);
});
}
} } }