Ejemplo n.º 1
0
        private void OnRefresh_Core()
        {
            //Generate collection of Notes
            Animate      = true;
            Instructions = "Loading Passwords";

            Task.Run(() =>
            {
                var passwords = passwordManager.Get_PasswordByContactID <Passwords>(Constants.InMemory_ContactID);
                if (passwords.Count != 0)
                {
                    foreach (var password in passwords)
                    {
                        PasswordCellViewModel obj = new PasswordCellViewModel(password, navigation, dialogue);
                        obj._DeleteContent       += RemovePassword_FromCollection;

                        this.Passwords.Add(obj);
                    }
                }
            }).ContinueWith((e) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    ReloadData = true;
                    Animate    = false;
                });
            });
        }
Ejemplo n.º 2
0
        private async void AddPasswords_ToCollection(Passwords obj)
        {
            //Add Notes to Server
            Animate      = true;
            Instructions = "Creating Password";

            //Diagnostics
            string Message    = string.Empty;
            string StackTrace = string.Empty;
            bool   _HasError  = false;

            string cid = obj.Password_ID; //Temp Client Id

            await Task.Run(() =>
            {
                try
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        var curr             = new PasswordCellViewModel(obj, navigation, dialogue);
                        curr._DeleteContent += RemovePassword_FromCollection;
                        this.Passwords.Add(curr);
                    });

                    DataVaultWebServiceClient dataService = new DataVaultWebServiceClient(ConfigurationManager.InSecurePublicBinding(), new System.ServiceModel.EndpointAddress(Constants.Data_InSecureUrl));
                    var response = dataService._AddPassword(LocalMapper.MapPassword_ToServer(obj));
                    if (response.Errors.Count != 0)
                    {
                        response.Errors.ForEach(w =>
                        {
                            //Add to log table for diagnostics

                            if (this.logging != null)
                            {
                                var log = LocalMapper.Map_LogWithMessage(w, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                                this.logging.AddLog(log);
                            }
                        });

                        _HasError = true;
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            var password = this.Passwords.SingleOrDefault(w => w.ID.Equals(cid));
                            password.ID  = response.Content_ID;
                            ReloadData   = true;
                        });

                        //Update Password
                        obj.Password_ID = response.Content_ID;
                        this.passwordManager.UpdatePassword(obj);
                    }
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        Message    = ex.InnerException.Message;
                        StackTrace = ex.InnerException.StackTrace;
                    }
                    else
                    {
                        Message    = ex.Message;
                        StackTrace = ex.StackTrace;
                    }

                    _HasError = true;
                    var mEx   = new Exceptions(logging, Message, StackTrace);
                    if (mEx != null)
                    {
                        mEx.HandleException(mEx, logging);
                    }
                }
            }).ContinueWith((e) =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    Animate = false;
                    //if (_HasError && dialogue != null)
                    //    dialogue.ShowAlert("mmm...Something went wrong", Message);
                });
            });
        }