-
Notifications
You must be signed in to change notification settings - Fork 0
/
Login.xaml.cs
151 lines (120 loc) · 7.1 KB
/
Login.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Collections.ObjectModel;
using BoothLeads.ServiceClient;
using System.IO;
using BoothLeads.ServiceClient.DataContracts;
using System.Text;
using System.Runtime.Serialization.Json;
using System.Windows.Controls.Primitives;
namespace BoothLeads
{
public partial class BLLogin : PhoneApplicationPage
{
SFLoginResponse slResponse = null;
public BLLogin()
{
InitializeComponent();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string serviceUri = SalesForceServiceURL.SVC_AUTHORIZATION_URL;//string.Format(SalesForceServiceURL.SVC_AUTHORIZATION_URL, SalesForceServiceURL.SVC_AUTHORIZATION_USERNAME, SalesForceServiceURL.SVC_AUTHORIZATION_PASSWORD);
WebClient wbClient = new WebClient();
wbClient.UploadStringCompleted += new UploadStringCompletedEventHandler(wbClient_UploadStringCompleted);
wbClient.UploadStringAsync(new Uri(serviceUri), "POST", string.Empty);
}
void wbClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
try
{
Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(SFLoginResponse));
slResponse = (SFLoginResponse)obj.ReadObject(stream);
//txtUserName.Text = slResponse.id;
BoothLeadGlobalAccess.Access_Token = "Bearer " + slResponse.access_token;
//BoothLeadGlobalAccess.SfUserId = slResponse.id;
WebClient wbClient = new WebClient();
string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL,txtUserName.Text,txtPassword.Password);
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "dayanand@globalnest.com", "global281");
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "boothleads.de@gmail.com", "booth281");
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "durga@globalnest.com", "global281");
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "meshramraj@gmail.com", "windows123");
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "boothleads.ba@gmail.com", "booth281");
//string loginURL = string.Format(SalesForceServiceURL.SVC_LOGIN_URL, "boothleads.ea@gmail.com", "global281");
wbClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wbClient_DownloadStringCompleted);
wbClient.Headers["Authorization"] = BoothLeadGlobalAccess.Access_Token;
wbClient.DownloadStringAsync(new Uri(loginURL));
////wbClient.UploadStringAsync(new Uri(loginURL), "POST", string.Empty);
//bool bresult = wbClient.IsBusy;
//SFLoginResponse response = slResponse;
}
catch(Exception excp)
{
MessageBox.Show(excp.Message);
}
}
void wbClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(UsersDetails));
BoothLeadGlobalAccess.BLUserDetails = (UsersDetails)obj.ReadObject(stream);
if (string.IsNullOrEmpty(BoothLeadGlobalAccess.BLUserDetails.error) == false)
MessageBox.Show(BoothLeadGlobalAccess.BLUserDetails.error);
else
NavigationService.Navigate(new Uri(string.Format("/BoothLeads.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/boothleadsMore.xaml"), UriKind.Relative));
//DataReady(BoothLeadGlobalAccess.BLUserDetails.Edetails[0].Event_ID, BoothLeadGlobalAccess.BLUserDetails.UserID);
//NavigationService.Navigate(new Uri(string.Format("/BoothLeads.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/blQRCodeScanner.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/blEventLeadsGridView.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/EventDetails.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/blEventSchedule.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/blEventExhibitors.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/BlSyncLeads.xaml"), UriKind.Relative));
//NavigationService.Navigate(new Uri(string.Format("/UserProfile.xaml"), UriKind.Relative));BlVerifyLead
//NavigationService.Navigate(new Uri(string.Format("/BlVerifyLead.xaml"), UriKind.Relative));
}
private void DataReady(string eventid, string userid)
{
string serviceUri = string.Format(SalesForceServiceURL.SVC_DATAREADY_URL, eventid, userid, 2, 3);
WebClient wbClient1 = new WebClient();
wbClient1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wbClientDataReady_DownloadStringCompleted);
wbClient1.Headers["Authorization"] = BoothLeadGlobalAccess.Access_Token;
wbClient1.DownloadStringAsync(new Uri(serviceUri));
}
void wbClientDataReady_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(BLDataready));
BLDataready evDetails = (BLDataready)obj.ReadObject(stream);
}
void proxy_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Stream stream = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(string));
string result = obj.ReadObject(stream).ToString();
NavigationService.Navigate(new Uri(string.Format("/blEventSchedule.xaml?val={0}", "constant"), UriKind.Relative));
}
private void txtUserName_GotFocus(object sender, RoutedEventArgs e)
{
txtUserName.Text = string.Empty;
}
private void txtPassword_GotFocus(object sender, RoutedEventArgs e)
{
txtPassword.Password = string.Empty;
}
}
}