Пример #1
0
        public static async System.Threading.Tasks.Task <Boolean> FetchCompanyEditAsync(Models.Company obj)
        {
            Uri u = new Uri(url1 + "EditProfileCompany?Email=" + obj.Email + "&CompanyName=" + obj.CompanyName +
                            "&CompanyFullName=" + obj.CompanyFullName + "&CompanyAbout=" + obj.CompanyAbout + "&ProductsAbout=" + obj.ProductsAbout + "&Facebook=" + obj.Facebook
                            + "&Instagram=" + obj.Instagram + "&Snapchat=" + obj.Snapchat + "&Youtube=" + obj.Youtube + "&Phone=" + obj.Phone + "&UserPhone=" + obj.UserPhone
                            + "&ContactEmail=" + obj.ContactEmail + "&www=" + obj.www + "&Adress=" + obj.www + "&NIP=" + obj.NIP + "&Forname_And_Surname=" + obj.ForName_And_SurName);

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(u);
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
                    if (Boolean.Parse(jsonDoc["AccountChanged"].ToString()) == true)
                    {
                        return(true);
                    }
                    else if (Boolean.Parse(jsonDoc["Unactual"].ToString()) == true)
                    {
                        LDbConnection.InsertCompany(await DbConnection.FetchCompanyAsync(obj.Email));
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #2
0
        public static async System.Threading.Tasks.Task <Boolean> FetchCompanyJoinExpoAsync(Models.Company us, Models.Expo e)
        {
            Uri u = new Uri(url1 + "insertCExpo?Expoid=" + e.Id + "&Companyid=" + us.Id);

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(u);
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
                    if (Boolean.Parse(jsonDoc["JoinedC"].ToString()) == true)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Пример #3
0
        public static async System.Threading.Tasks.Task <Boolean> FetchUserEditAsync(Models.User obj)
        {
            Uri u = new Uri(url1 + "EditProfileUser?Email=" + obj.Email + "&ForName=" + obj.ForName + "&SurName=" + obj.SurName + "&Phone=" + obj.Phone + "&Nationality=" + obj.Nationality);

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(u);
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
                    if (Boolean.Parse(jsonDoc["AccountChanged"].ToString()) == true)
                    {
                        return(true);
                    }
                    else if (Boolean.Parse(jsonDoc["Unactual"].ToString()) == true)
                    {
                        LDbConnection.InsertUser(await DbConnection.FetchUserAsync(obj.Email));
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #4
0
        public static async System.Threading.Tasks.Task <Boolean> FetchCompanyHistoryAsync(Models.HistoryU obj)
        {
            Uri u = new Uri(url1 + "insertHistoryC?Search=" + obj.Wyszukiwanie + "&Description=" + obj.Description + "&Companyid=" + obj.User + "&Expoid=" + obj.Expo);

            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(u);
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
                    if (Boolean.Parse(jsonDoc["saved"].ToString()) == true)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Пример #5
0
        public static async System.Threading.Tasks.Task <Models.Company> FetchCompanyAsync(string email)
        {
            // Create an HTTP web request using the URL:
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(new Uri(url1 + "/company?Email=" + email));
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            try
            {
                using (System.Net.WebResponse response = await request.GetResponseAsync())
                {
                    // Get a stream representation of the HTTP web response:
                    using (Stream stream = response.GetResponseStream())
                    {
                        // Use this stream to build a JSON document object:
                        System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                        Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());

                        // Return the JSON document:
                        return(Droid.Modules.Parsers.Company(jsonDoc));
                    }
                }
            }
            catch (System.Net.WebException ex)
            {
            }
            return(null);
        }
Пример #6
0
        public static async System.Threading.Tasks.Task <System.Collections.Generic.List <Models.Expo> > FetchUserExposAsync(Models.User u)
        {
            // Create an HTTP web request using the URL:
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(new Uri(url1 + "UserExpos?email=" + u.Email));
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());

                    // Return the JSON document:
                    System.Collections.Generic.List <Models.Expo> lista = new System.Collections.Generic.List <Models.Expo>();
                    for (int i = 0; i != jsonDoc.Count; i++)
                    {
                        Models.Expo e = new Models.Expo
                        {
                            Name_Expo   = jsonDoc[i]["Name_Expo"],
                            Id          = Int32.Parse(jsonDoc[i]["Id"].ToString()),
                            Photo       = jsonDoc[i]["Photo"],
                            MapPhoto    = jsonDoc[i]["MapPhoto"],
                            Adres       = jsonDoc[i]["Adres"],
                            Description = jsonDoc[i]["Description"]
                        };
                        var      start     = double.Parse(jsonDoc[i]["ExpoStartData"].ToString().Replace('/', ' ').Replace('"', ' ').Replace(')', ' ').Replace("Date(", "").Trim());
                        TimeSpan time      = TimeSpan.FromMilliseconds(start);
                        DateTime startdate = new DateTime(1970, 1, 1) + time;

                        e.DataTargowStart = startdate;
                        var      end     = double.Parse(jsonDoc[i]["ExpoEndData"].ToString().Replace('/', ' ').Replace('"', ' ').Replace(')', ' ').Replace("Date(", "").Trim());
                        TimeSpan time1   = TimeSpan.FromMilliseconds(end);
                        DateTime enddate = new DateTime(1970, 1, 1) + time1;

                        e.DataTargowEnd = enddate;
                        lista.Add(e);
                    }
                    return(lista);
                }
            }
        }
Пример #7
0
        public static async System.Threading.Tasks.Task <Models.MobileLogin> FetchLoginAsync(String email, String password)
        {
            Uri u = new Uri(url1 + "Login?Email=" + email + "&Password="******"application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());
                    return(Droid.Modules.Parsers.Login(jsonDoc));
                }
            }
            return(null);
        }
Пример #8
0
        public static async System.Threading.Tasks.Task <System.Collections.Generic.List <Models.HistoryU> > FetchHistory(Models.Company u)
        {
            // Create an HTTP web request using the URL:
            System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(new Uri(url1 + "History?email=" + u.Email));
            request.ContentType = "application/json";
            request.Method      = "GET";

            // Send the request to the server and wait for the response:
            using (System.Net.WebResponse response = await request.GetResponseAsync())
            {
                // Get a stream representation of the HTTP web response:
                using (Stream stream = response.GetResponseStream())
                {
                    // Use this stream to build a JSON document object:
                    System.Json.JsonValue jsonDoc = await System.Threading.Tasks.Task.Run(() => System.Json.JsonObject.Load(stream));

                    Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());

                    // Return the JSON document:
                    System.Collections.Generic.List <Models.HistoryU> lista = new System.Collections.Generic.List <Models.HistoryU>();
                    for (int i = 0; i != jsonDoc.Count; i++)
                    {
                        Models.HistoryU h = new Models.HistoryU
                        {
                            ID           = Int32.Parse(jsonDoc[i]["ID"].ToString()),
                            Description  = jsonDoc[i]["Description"],
                            Wyszukiwanie = jsonDoc[i]["Wyszukiwanie"],
                            User         = Int32.Parse(jsonDoc[i]["User"].ToString()),
                            Expo         = Int32.Parse(jsonDoc[i]["Expo"].ToString())
                        };
                        lista.Add(h);
                    }
                    return(lista);
                }
            }
        }
Пример #9
0
        public async Task <String> GetAccessToken(string url)
        {
            try
            {
                var client   = new System.Net.Http.HttpClient();
                var response = await client.GetAsync(new Uri(url));

                var result = await response.Content.ReadAsStringAsync();

                System.Json.JsonValue json = System.Json.JsonValue.Parse(result);

                return(json.ToString());
            }
            catch
            {
                using (ErrorsContext db = new ErrorsContext())
                {
                    db.Errors.Add(new Error {
                        ErrorText = "Ошибка await GetAccessToken(Не получен code)!"
                    });
                }
                return("");
            }
        }
Пример #10
0
        public async Task <UpdatePushTokenResponse> SendPushToServer(string token)
        {
            UpdatePushTokenResponse updateDeviceTokenResponse = new UpdatePushTokenResponse();

            if (!String.IsNullOrEmpty(SessionHelper.AccessToken))
            {
                UpdatePushTokenRequest updateDeviceTokenRequest = new UpdatePushTokenRequest();
                updateDeviceTokenRequest.DevicePushToken = token;
                updateDeviceTokenRequest.DeviceType      = Device.RuntimePlatform;
                updateDeviceTokenRequest.AuthToken       = SessionHelper.AccessToken;
                System.Json.JsonValue updateUserResponse = await HttpRequestHelper <UpdatePushTokenRequest> .POSTreq(ServiceTypes.UpdatePushToken, updateDeviceTokenRequest);

                updateDeviceTokenResponse = JsonConvert.DeserializeObject <UpdatePushTokenResponse>(updateUserResponse.ToString());
            }
            return(updateDeviceTokenResponse);
        }
Пример #11
0
 public JsonContent(System.Json.JsonValue content) : this(content : content.ToString())
 {
 }