Пример #1
0
        private void web_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                return;
            }

            try {
                string v = System.Text.Encoding.UTF8.GetString(e.Result, 0, e.Result.Length).Trim();

                if (v != "")
                {
                    NewVersion = v;

                    if (UpdateAvailable != null)
                    {
                        UpdateAvailable(this, new UpdateArgs(v, String.Compare(NowVersion, v) != 0));
                        return;
                    }
                }
            }
            catch { }

            if (UpdateAvailable != null)
            {
                UpdateAvailable(this, new UpdateArgs(NowVersion, false));
            }
        }
        /// <summary>
        /// Used to handle the web client upload values completed event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An System.EventArgs that contains no event data.</param>
        private void UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            // is no longer submitting
            this.isSubmitting = false;

            // check if error occurred and if so report to console and set error message.
            if (e.Error != null)
            {
                Debug.LogException(e.Error);
                this.errorMessage = e.Error.Message;
                return;
            }

            // check if canceled submission
            var local = LocalizationManager.Instance;

            if (e.Cancelled)
            {
                this.errorMessage = local.Get("Canceled");
                return;
            }

            try
            {
                var data = System.Text.Encoding.UTF8.GetString(e.Result);
                var json = Editor.JSON.Parse(data);
                // attempt to get the success and message element values
                var messageElement = json["Message"].Value;
                var successElement = json["Success"].AsBool;

                // if not successful report the error
                if (!successElement)
                {
                    this.errorMessage = messageElement;
                    return;
                }

                // set status to the message.
                this.statusMessage         = messageElement;
                this.successfullySubmitted = true;

                //if (this.HandleXmlResponse(e, local))
                //{
                //    return;
                //}
            }
            catch (Exception ex)
            {
                // if something goes wrong report it
                this.errorMessage = ex.Message;
                return;
            }

            // cleanup variables
            this.errorMessage  = null;
            this.statusMessage = string.Empty;
            this.email         = string.Empty;
            this.subject       = string.Empty;
            this.message       = string.Empty;
        }
Пример #3
0
        private static void WebClient_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null)
                {
                    string responseString = Encoding.UTF8.GetString(e.Result);

                    var responseProperties = responseString.Split('&');
                    var tokenProperty      = responseProperties[0].Split('=');
                    var token = Uri.UnescapeDataString(tokenProperty[1]);

                    var properties = (from prop in token.Split('&')
                                      let pair = prop.Split(new[] { '=' }, 2)
                                                 select new { Name = pair[0], Value = pair[1] })
                                     .ToDictionary(p => p.Name, p => p.Value);

                    var epochStart = new DateTime(1970, 01, 01, 0, 0, 0, 0, DateTimeKind.Utc);

                    _tokenExpiresOn = epochStart.AddSeconds(int.Parse(properties["ExpiresOn"]));
                    _token          = "WRAP access_token=\"" + token + "\"";
                }
                else
                {
                    // TODO: log exception
                }
            }
            catch (Exception)
            {
                // TODO: log exception
            }
            _tokenRequested = false;
        }
Пример #4
0
        private static void StartMp3Downloads(object sender, UploadValuesCompletedEventArgs e)
        {
            _downloadCancel = false;

            if (e.Error != null)
            {
                Error(null, new EventArgs());
                return;
            }

            var rawLoginResponse = e.Result;

            var downloadedLinksRaw = Encoding.Default.GetString(rawLoginResponse);
            var regex = new Regex(@"https?.*/(.*\.mp3)");

            var match = Regex.Match(downloadedLinksRaw, @"https?.*/(.*\.mp3)");

            while (match.Success)
            {
                downloadableItems.Add(new DownloadableItem
                {
                    Id         = Guid.NewGuid(),
                    RemotePath = match.Groups[0].ToString(),
                    LocalPath  = Path.Combine(LocalFolder, match.Groups[1].ToString()),
                    Complete   = false
                });
                match = match.NextMatch();
            }

            totalLinks = downloadableItems.Count();
            client.DownloadFileCompleted += DownloadFileCallback;

            DownloadNextFile();
        }
Пример #5
0
        void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            Activity.RunOnUiThread(async() =>
            {
                //string id = Encoding.UTF8.GetString(e.Result); //Get the data echo backed from PHP
                //int newID = 0;
                //int.TryParse(id, out newID); //Cast the id to an integer

                if (OnCreateContact != null)
                {
                    //Broadcast event

                    //OnCreateContact.Invoke(this, new CreateContactEventArgs(txtEmail.Text, txtFirstname.Text, txtLastname.Text, txtPassword.Text, txtUsername.Text));
                    var person = new Usuario(txtEmail.Text, txtFirstname.Text, txtLastname.Text, txtPassword.Text, txtUsername.Text);
                    var json   = JsonConvert.SerializeObject(person);
                    // var content = new StringContent(json, Encoding.UTF8, "application/json");

                    Servicios s = new Servicios();
                    await s.MakePostRequest("http://didacdedm.pythonanywhere.com/api/users/add", json);
                }

                //mProgressBar.Visibility = ViewStates.Invisible;
                this.Dismiss();
            });
        }
Пример #6
0
 private void ReceiveUploadValuesCompleted(object sender, UploadValuesCompletedEventArgs args)
 {
     try
     {
         if (!args.Cancelled)
         {
             if (!HasID)
             {
                 var  response  = Encoding.ASCII.GetString(args.Result);
                 bool wasListed = IsListedOk;
                 ID = int.Parse(response);
                 if (HasID)
                 {
                     IsListedOk = true;
                     if (!wasListed)
                     {
                         OnServerNotifierListedStateChanged();
                     }
                     OnServerNotifierSuccess();
                 }
             }
             else
             {
                 OnServerNotifierSuccess();
             }
         }
     }
     catch (Exception e)
     {
         IsListedOk = false;
         OnServerNotifierListedStateChanged();
         OnServerNotifierError(e.ToString());
     }
 }
Пример #7
0
        protected void OnVerifyCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            // Only process the response if we are not closing the dialog.
            if (!isCanceling)
            {
                if (e.Error != null)    // Check if allocation succeeded
                {
                    ApiError error = ApiClient.ParseError(e.Error);
                    if (error != null)
                    {
                        Program.ShowError(this, "目前所有票亭都在忙碌中。(錯誤代碼:{0})", "派票不成功", error.Code);
                    }
                    else
                    {
                        Program.ShowError(this, e.Error, "派票不成功");
                    }

                    return;
                }
                else
                {
                    // Allocation succeeded
                    int boothId = (int)ApiClient.ParseJson(e.Result)["booth_id"];
                    OnBoothAllocated(boothId);
                    MessageBox.Show(this, String.Format("請至 {0} 號平板投票。", boothId), "派票成功",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                OnCancelled();
            }

            this.Close();
        }
Пример #8
0
        private void UploadValuesFinishPass(object sender, UploadValuesCompletedEventArgs e)
        {
            string json = Encoding.UTF8.GetString(e.Result);

            PassResult.Text          = json;
            PasswordResetBtn.Enabled = true;
        }
Пример #9
0
        /// <summary>
        /// Event that occurs when user registration details are uploaded. If an error string
        /// is returned, an error message is displayed. Otherwise, the user is sent back to the
        /// menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            RunOnUiThread(() =>
            {
                newID = System.Text.Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
                newID = newID.Replace("\r", string.Empty).Replace("\n", string.Empty);

                progressBar.Visibility = ViewStates.Invisible;
                if (newID == "duplicate")
                {
                    errorLog.Text = "This email is already in use.";
                }
                else
                {
                    ISharedPreferences pref         = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
                    ISharedPreferencesEditor editor = pref.Edit();
                    editor.PutString("UserID", newID);
                    editor.Apply();


                    SmsManager.Default.SendTextMessage(etPhoneNumber.Text, null, ("Confirmation message to " + etFullName.Text), null, null);

                    var intent = new Intent(this, typeof(menu));
                    StartActivity(intent);
                    Finish();
                }
            });
        }
Пример #10
0
    /// <summary>
    /// Callback of upload method
    /// </summary>
    private void UploadedCallback(object sender, UploadValuesCompletedEventArgs e)
    {
        //If uploading has not cancelled and error has not accured
        if (!e.Cancelled && e.Error == null)
        {
            //Get the response
            byte[] response = e.Result;

            //Open it in XML document, to reach an uploaded link
            XmlDocument doc = new XmlDocument();
            doc.Load(new MemoryStream(response));
            //Find link element in XML and store it in a field
            XmlNode nodeImageLink = doc.GetElementsByTagName("link")[0];
            this.LinkToScreenShot = nodeImageLink.InnerText;
            this.isUploaded       = true;
            Debug.Log("Uploaded successfully! Here is your link - " + LinkToScreenShot);
            //
        }
        else
        {
            LinkToScreenShot = string.Empty;
            //
            if (e.Cancelled)
            {
                Debug.Log("Uploading was cancelled");
            }
            else
            {
                Debug.Log(e.Error.Message);
            }
        }
    }
Пример #11
0
        protected void OnUploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }
            if (e.Error != null)
            {
                ApiError error = ApiClient.ParseError(e.Error);
                if (error != null)
                {
                    Program.ShowError(this, "請確認帳號密碼是否正確。(錯誤代碼:{0})", "登入失敗", error.Code);
                }
                else
                {
                    Program.ShowError(this, e.Error, "登入失敗");
                }
            }
            else
            {
                // Parse and load the token
                string token = (string)ApiClient.ParseJson(e.Result)["token"];
                ApiClient.SetToken(token);

                OnLoginSucceeded(null);
                this.Close();
            }
        }
        private void LoginCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            string data = Encoding.UTF8.GetString(e.Result);

            Console.WriteLine("WE FOUND SOME DATA " + data);
            LoggedUser = JsonConvert.DeserializeObject <User>(data);


            LoggedUser.ContactList = JsonConvert.DeserializeObject <List <Contact> >(LoggedUser.ContactListString);
            if (LoggedUser.ContactList == null)
            {
                LoggedUser.ContactList = new List <Contact>();
            }
            LoggedUser.FriendRequestList = JsonConvert.DeserializeObject <List <FriendRequest> >(LoggedUser.FriendRequestsString);
            if (LoggedUser.FriendRequestList == null)
            {
                LoggedUser.FriendRequestList = new List <FriendRequest>();
            }
            List <Unit> unitList = JsonConvert.DeserializeObject <List <Unit> >(LoggedUser.UnitListString);

            LoggedUser.UnitList = unitList;
            NameValueCollection parameters = new NameValueCollection();

            parameters.Add("Username", LoggedUser.Username);
            parameters.Add("Password", LoggedUser.Password);
            parameters.Add("Request", "GetConversations");

            Uri mUri = new Uri("http://arcane-headland-59258.herokuapp.com/PHPAPI.php");

            mClient.UploadValuesCompleted -= LoginCompleted;
            mClient.UploadValuesCompleted += ConversationsCompleted;

            mClient.UploadValuesAsync(mUri, parameters);
        }
Пример #13
0
        private void uploadcomlogin(object sender, UploadValuesCompletedEventArgs e)
        {
            RunOnUiThread(() => {
                try{
                    string user1 = Encoding.UTF8.GetString(e.Result);

                    string lgn = "No Such User Found";

                    if (user1 == lgn)
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(this);
                        builder.SetTitle("Warning!");
                        builder.SetMessage("Incorrect,  Username Or Password");
                        builder.SetPositiveButton("OK", (s, ev) => { });
                        builder.Show();
                    }
                    else
                    {
                        Intent i = new Intent(this, typeof(Admin));
                        i.PutExtra("username", user.Text);
                        StartActivity(i);
                    }


                    progressbar.Visibility = ViewStates.Invisible;
                }catch (Exception ex)
                {
                    progressbar.Visibility = ViewStates.Invisible;
                    Toast.MakeText(this, "Something Went Wrong!", ToastLength.Short).Show();
                }
            });
        }
Пример #14
0
        /// <summary>
        /// Event that occurs when user profile details are uploaded. If an error string
        /// is returned, an error message is displayed. Otherwise, the user is sent back to the
        /// profile page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            RunOnUiThread(() =>
            {
                string returnValue = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
                returnValue        = returnValue.Replace("\r", string.Empty).Replace("\n", string.Empty);
                if (returnValue == "duplicate")
                {
                    errorLog.Text = "The email you tried to change to is already in use.";
                }
                else
                {
                    string json = Encoding.UTF8.GetString(e.Result);
                    studentInfo = JsonConvert.DeserializeObject <List <Student> >(json);


                    progressBar.Visibility = ViewStates.Invisible;

                    Intent intent = new Intent(this, typeof(profile));


                    //Sends new profile info back to profile so it doesn't have to be downloaded again
                    intent.PutExtra("Edit", JsonConvert.SerializeObject(studentInfo));

                    StartActivity(intent);
                    Finish();
                }
                progressBar.Visibility = ViewStates.Invisible;
                waiting = false;
            });
        }
Пример #15
0
        void upload_progress_complete(object sender, UploadValuesCompletedEventArgs e)
        {
            group_upload_progress.Text = "Upload Progress";
            progress.Value             = 0;

            String response = Encoding.UTF8.GetString(e.Result);

            String delete_hash = Global_Func.get_text_inbetween(response, "deletehash\":\"", "\",\"name\"").Replace("\\", "");
            String link        = Global_Func.get_text_inbetween(response, "link\":\"", "\"}").Replace("\\", "");

            list_image_links.Items.Add(
                new ListViewItem(new String[] { link, delete_hash })
                );

            list_image_links.Items[list_image_links.Items.Count - 1].EnsureVisible();

            if (Settings.copy_links_to_clipboard)
            {
                Clipboard.SetText(link);
            }

            if (Settings.balloon_messages)
            {
                balloon_tip(link, "Upload Complete!", 2000);
            }

            Global_Func.play_sound("success.wav");
        }
Пример #16
0
 private void uploadcomlogin(object sender, UploadValuesCompletedEventArgs e)
 {
     RunOnUiThread(() => {
         StartActivity(new Intent(this, typeof(Admin)));
         Toast.MakeText(this, "value inserted successfully!", ToastLength.Short).Show();
     });
 }
Пример #17
0
        /// <summary>
        /// Event that occurs when user input is uploaded. If an error value is returned, an
        /// error message is displayed. Otherwise, a success message is displayed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            Activity.RunOnUiThread(() =>
            {
                string result = System.Text.Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
                result        = result.Replace("\r", string.Empty).Replace("\n", string.Empty);
                if (result == "None")
                {
                    txtResetError.Text     = "Error: This email address doesn't belong to a registered account. Please try again.";
                    progressBar.Visibility = ViewStates.Invisible;
                }
                else
                {
                    string json = Encoding.UTF8.GetString(e.Result);
                    studentInfo = JsonConvert.DeserializeObject <List <Student> >(json);

                    string password    = studentInfo[0].PasswordHash;
                    string PhoneNumber = studentInfo[0].PhoneNumber;

                    progressBar.Visibility = ViewStates.Invisible;


                    SmsManager.Default.SendTextMessage(PhoneNumber, null, ("Your new temporary password is " + password + "    Please remember to change your password as soon as you log in."), null, null);

                    Dismiss();
                }
            });
        }
        private void Wclient_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            try
            {
                string          json = Encoding.UTF8.GetString(e.Result);
                OperationResult or   = JsonConvert.DeserializeObject <OperationResult>(json);

                // Oculto la Progressbar
                RunOnUiThread(() => { mProgress.Visibility = ViewStates.Invisible; });

                if (or.error)
                {
                    // Ha ocurrido un error!
                    RunOnUiThread(() =>
                    {
                        mTextError.Text       = "Ah ocurrido un error al realizar el registro\nPor favor, intente nuevamente mas tarde";
                        mTextError.Visibility = ViewStates.Visible;
                    });
                }
                else
                {
                    // Guardo el Id de mi nuevo Cliente
                    fm.SetValue("id", or.data.ToString());
                    fm.SetValue("email", client.email);
                    fm.SetValue("password", client.HashPassword());

                    // Cargo la vista de Registro de Perfil
                    Managment.ActivityManager.TakeMeTo(this, typeof(RegisterProfileActivity), false);
                }
            }
            catch (Exception ex)
            {
                Managment.ActivityManager.ShowError(this, new Error(errCode, errMsg));
            }
        }
Пример #19
0
        void mPackageDownloadClient_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }
            if (e.Error != null)
            {
                AddErrorMessage(" error." + Environment.NewLine);
                StopDownload();
                MessageBox.Show(this, string.Format("Error logging into AVSIM: {0}{1}{2}{3}", e.Error.Message, Environment.NewLine, Environment.NewLine, e.Error.InnerException != null ? e.Error.InnerException.Message : ""), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            CookieCollection cookies       = mPackageDownloadClient.CookieContainer.GetCookies(new Uri(AVSIM_LOGIN_URL));
            bool             gotAuthCookie = false;

            foreach (Cookie cookie in cookies)
            {
                cookie.Path = "/";
                if (cookie.Name == "LibraryLogin")
                {
                    gotAuthCookie = true;
                }
            }
            mPackageDownloadClient.CookieContainer.Add(cookies);
            if (!gotAuthCookie)
            {
                AddErrorMessage(" error." + Environment.NewLine);
                StopDownload();
                MessageBox.Show(this, "AVSIM login failed. Please check your username and password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            AddMessage(" done." + Environment.NewLine);
            DownloadNextPackage();
        }
Пример #20
0
 private void SubmitComplete(object sender, UploadValuesCompletedEventArgs e)
 {
     try
     {
         if (!e.Cancelled)
         {
             string  response   = Encoding.UTF8.GetString(e.Result);
             JObject jsonObject = JObject.Parse(response);
             if (jsonObject["message"] != null)
             {
                 Main.NewText((string)jsonObject["message"]);
             }
             else
             {
                 Main.NewText("Schematics Server problem 12");
             }
         }
         else
         {
             Main.NewText("Schematics Server problem 2");
         }
     }
     catch
     {
         Main.NewText("Schematics Server problem 3");
     }
     submitWait = false;
 }
        private void ConversationsCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            mClient.UploadValuesCompleted -= ConversationsCompleted;
            if (e.Result == null)
            {
                ServiceException();
                return;
            }
            string data = Encoding.UTF8.GetString(e.Result);

            Console.WriteLine("Data HERE?: " + data);
            List <RootObject> obj = JsonConvert.DeserializeObject <List <RootObject> >(data);


            AssignMessages(obj);
            SetContentView(Resource.Layout.Main);
            UnitPageButton        = FindViewById <ImageButton>(Resource.Id.GoToUnitButton);
            UnitPageButton.Click += UnitsPage;

            FriendRequestsPageButton = FindViewById <ImageButton>(Resource.Id.GoToFriendRequestsButton);
            if (LoggedUser.FriendRequestList.Count > 0)
            {
                FriendRequestsPageButton.SetBackgroundResource(Resource.Drawable.ic_info);
            }

            FriendRequestsPageButton.Click += FriendRequestsPage;
            LoadContacts();
        }
Пример #22
0
        private void ReceiveModInfo(object sender, UploadValuesCompletedEventArgs e)
        {
            _loading = false;
            string description = Language.GetTextValue("tModLoader.ModInfoProblemTryAgain");
            string homepage    = "";

            if (!e.Cancelled)
            {
                try {
                    string response = Encoding.UTF8.GetString(e.Result);
                    if (!string.IsNullOrEmpty(response))
                    {
                        try {
                            JObject joResponse = JObject.Parse(response);
                            description = (string)joResponse["description"];
                            homepage    = (string)joResponse["homepage"];
                        }
                        catch (Exception err) {
                            Logging.tML.Error($"Problem during JSON parse of mod info for {_modDisplayName}", err);
                        }
                    }
                }
                catch (Exception err) {
                    Logging.tML.Error($"There was a problem trying to receive the result of a mod info request for {_modDisplayName}", err);
                }
            }

            _info = description;
            if (_info.Equals(""))
            {
                _info = Language.GetTextValue("tModLoader.ModInfoNoDescriptionAvailable");
            }
            _url   = homepage;
            _ready = true;
        }
Пример #23
0
        private void Ws_login_completed(object sender, UploadValuesCompletedEventArgs e)
        {
            try
            {
                if (e.Error == null ||
                    Utils.IsNullOrEmpty(e.Error.ToString()))
                {
                    string source = Encoding.UTF8.GetString(e.Result);

                    if (LoginCompleted != null)
                    {
                        LoginCompleted(this, new ResultEventArgs(true, source));
                    }
                }
                else
                {
                    throw e.Error;
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog(ex.Message, ex);

                if (Error != null)
                {
                    Error(this, new ErrorEventArgs(ex));
                }
            }
        }
        private void ConversationRefreshComplete(object sender, UploadValuesCompletedEventArgs e)
        {
            mClient.UploadValuesCompleted -= ConversationRefreshComplete;
            if (e.Result == null)
            {
                ServiceException();
                return;
            }
            string data = Encoding.UTF8.GetString(e.Result);

            Console.WriteLine(data);
            List <RootObject> obj = JsonConvert.DeserializeObject <List <RootObject> >(data);

            AssignMessages(obj);

            ListView messageListView = FindViewById <ListView>(Resource.Id.messageListView);

            Console.WriteLine("LIST POS: " + currentContact.ListPosition);
            //Console.WriteLine(LoggedUser.ContactList[currentContact.ListPosition].messageList[0].message);
            MessageAdapter adapter = new MessageAdapter(this, LoggedUser.ContactList[currentContact.ListPosition].messageList);

            messageListView.Adapter = adapter;

            messageListView.SetSelection(adapter.Count - 1);
            TextView messageInput = FindViewById <TextView>(Resource.Id.MessageInput);

            messageInput.Text     = "";
            SendButton.Enabled    = true;
            RefreshButton.Enabled = true;
            BackButton.Enabled    = true;

            MessengerLoader.Visibility = ViewStates.Invisible;
        }
Пример #25
0
        /// <summary>
        /// Occurs when an Email value has been uploaded to the server. Displays error text if
        /// server found no student with that Email otherwise takes user to the student's profile
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void email_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            if (emailCount < 1)
            {
                emailCount += 1;
                RunOnUiThread(() =>
                {
                    if (e.Result != null)
                    {
                        studentID = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
                        studentID = studentID.Replace("\r", string.Empty).Replace("\n", string.Empty);

                        if (studentID == "None")
                        {
                            txtErrorLog.Text = "Error: There is no student with this email address.";
                        }
                        else
                        {
                            var intent = new Intent(this, typeof(profile));
                            intent.PutExtra("Owner", studentID);
                            StartActivity(intent);
                        }
                        waiting = false;
                        progressBar.Visibility = ViewStates.Invisible;
                    }
                });
            }
        }
Пример #26
0
        /// <summary>
        /// Occurs when an ID value has been uploaded to the server. Displays error text if
        /// server found no student with that ID otherwise takes user to the student's profile
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void id_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            if (idCount < 1)//If no other results have been returned (prevents multiple events occuring when this page is returned to)
            {
                idCount += 1;
                RunOnUiThread(() =>
                {
                    try
                    {
                        if (e.Result != null)
                        {
                            studentID = Encoding.UTF8.GetString(e.Result, 0, e.Result.Length);
                            studentID = studentID.Replace("\r", string.Empty).Replace("\n", string.Empty);

                            if (studentID == "None")
                            {
                                txtErrorLog.Text = "Error: There is no student with this ID.";
                            }
                            else
                            {
                                var intent = new Intent(this, typeof(profile));
                                intent.PutExtra("StudentID", studentID);
                                StartActivity(intent);
                            }
                            waiting = false;
                            progressBar.Visibility = ViewStates.Invisible;
                        }
                    }
                    catch (System.Reflection.TargetInvocationException)
                    {
                        ;
                    }
                });
            }
        }
Пример #27
0
        void wc_UploadValuesCompleted1(object sender, UploadValuesCompletedEventArgs e)
        {
            //将同步结果写入日志文件
            string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";

            System.IO.File.AppendAllText(new DataItemDetailBLL().GetItemValue("imgPath") + "/logs/" + fileName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + System.Text.Encoding.UTF8.GetString(e.Result) + "\r\n");
        }
        private void Client_UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e)
        {
            client = new WebClient();
            uri    = new Uri("http://" + ip + "/sendEmailReschedule.php");
            NameValueCollection parameter = new NameValueCollection();

            parameter.Add("cname", cname);
            parameter.Add("ename", ename);
            parameter.Add("adate", "2018/" + amonth + "/" + aday);
            parameter.Add("atime", ahour + ":" + amin);
            parameter.Add("service", aservice);
            client.UploadValuesAsync(uri, parameter);


            if (type.Equals("1"))
            {
                var intent = new Intent(this, typeof(ScheduleActivity));
                StartActivity(intent);
            }
            else if (type.Equals("0"))
            {
                var intent = new Intent(this, typeof(BookingActivity));
                StartActivity(intent);
            }
        }
Пример #29
0
        void wc_UploadValuesCompleted1(object sender, UploadValuesCompletedEventArgs e)
        {
            //将同步结果写入日志文件
            string fileName = "dept_" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            try
            {
                var error = e.Error;
                if (error == null)
                {
                    byte[] bytes  = e.Result;
                    string result = "";
                    if (bytes.Length > 0)
                    {
                        result = System.Text.Encoding.UTF8.GetString(bytes);
                        dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(result);
                        if (dy.code == 0)
                        {
                            result = "推送并修改用户信息成功";
                        }
                        else
                        {
                            result = "推送并修改用户信息失败,错误信息:" + dy.message;
                        }
                    }
                    eventLog1.WriteEntry(string.Format("{0}:推送用户成功,返回结果:{1}", DateTime.Now.ToString(), result));
                }
            }
            catch (Exception ex)
            {
                eventLog1.WriteEntry(string.Format("同步用户发生错误:{0}", ex));
            }
        }
Пример #30
0
        internal static void GetSchematicsComplete(object sender, UploadValuesCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {
                string  response   = Encoding.UTF8.GetString(e.Result);
                JObject jsonObject = new JObject();
                try
                {
                    jsonObject = JObject.Parse(response);
                }
                catch (Exception ex)
                {
                    Main.NewText("Bad JSON: " + response);
                }
                string message = (string)jsonObject["message"];
                if (message != null)
                {
                    Main.NewText(message);
                }
                JArray schematicslist = (JArray)jsonObject["schematics"];
                if (schematicslist != null)
                {
                    schematicsToLoad = new Queue <JObject>();
                    CheatSheet.instance.numberOnlineToLoad = CheatSheet.DefaultNumberOnlineToLoad;
                    //List<PaintToolsSlot> list = new List<PaintToolsSlot>();
                    foreach (JObject schematic in schematicslist.Children <JObject>())
                    {
                        schematicsToLoad.Enqueue(schematic);

                        //int id = (int)schematic["id"];
                        //string name = (string)schematic["name"];
                        //int rating = (int)schematic["rating"];
                        //int vote = (int)schematic["vote"];
                        //string tiledata = (string)schematic["tiledata"];
                        //try
                        //{
                        //	Tile[,] tiles = LoadTilesFromBase64(tiledata);
                        //	if (tiles.GetLength(0) > 0)
                        //	{
                        //		var paintToolsSlot = new PaintToolsSlot(GetStampInfo(tiles));
                        //		paintToolsSlot.browserID = id;
                        //		paintToolsSlot.browserName = name;
                        //		paintToolsSlot.rating = rating;
                        //		paintToolsSlot.vote = vote;
                        //		list.Add(paintToolsSlot);
                        //	}
                        //}
                        //catch { }
                    }
                    //if (list.Count > 0)
                    //	CheatSheet.instance.paintToolsUI.view.Add(list.ToArray());
                }
            }
            else
            {
                Main.NewText("Schematics Server problem 2");
            }
            waiting = false;
        }
Пример #31
0
 protected void testySuccess(object data, UploadValuesCompletedEventArgs status, Charp.CharpCtx ctx)
 {
     Console.WriteLine ("success " + entryResource.Text);
 }
		protected virtual void OnUploadValuesCompleted (
			UploadValuesCompletedEventArgs args)
		{
			if (UploadValuesCompleted != null)
				UploadValuesCompleted (this, args);
		}
Пример #33
0
Файл: test.cs Проект: mono/gert
	static void BeginCapture_UploadValuesCompleted (object sender, UploadValuesCompletedEventArgs e)
	{
		byte [] bytResponse = e.Result;
		_response = Encoding.UTF7.GetString (bytResponse);
	}