private async void RegisterAccountAsync() { if (this.ViewModel.AllInputFilledOut()) { UserNetworkManager manager = new UserNetworkManager(); this.CustomActivityIndicator.IsRunning = true; User user = await manager.RegisterUser(this.ViewModel.GenerateUserFromInput()); if (user.Success && string.IsNullOrEmpty(user.Message)) { await DisplayAlert("Success", $"Your account has been created", "Continue"); // save user login data to app data Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(user); await Application.Current.SavePropertiesAsync(); Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage(user)); } else { await DisplayAlert("Register Account Error", $"{user.Message}", "OK"); } this.CustomActivityIndicator.IsRunning = false; } else { await DisplayAlert("Register Account Error", $"Please fill out all inputs correctly and accept terms of use.", "OK"); } }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <returns></returns> private static RuleHistoryInfo CreteRuleHistoryInfo(IDataReader reader) { try { string value = DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "OBJECTSNAPSHOT", true, string.Empty).ToString(); PublishedObject pubObj = null; if (!string.IsNullOrEmpty(value)) { pubObj = (PublishedObject)ObjectSerializerHelper.Deserialize(value); } value = DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "MAILMESSAGESNAPSHOT", true, string.Empty).ToString(); Subscriber.Dispatcher.CalendarMail.MailRequest mailRequest = null; if (!string.IsNullOrEmpty(value)) { mailRequest = (Subscriber.Dispatcher.CalendarMail.MailRequest)ObjectSerializerHelper.Deserialize(value); } return(new RuleHistoryInfo { Id = Convert.ToInt32(DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "ID", false).ToString()), IdRule = Convert.ToInt32(DataAccess.Helper.DataReaderHelper.GetValue <object>(reader, "RULEID", false).ToString()), Published = (DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "COMPUTED", false) == "1"), PublishDate = DataAccess.Helper.DataReaderHelper.GetValue <DateTime>(reader, "COMPUTEDATE", true, DateTime.MinValue), ErrorInfo = new ErrorInfo { Id = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORID", true, string.Empty), Message = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORDESCRIPTION", true, string.Empty), Stack = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ERRORSTACK", true, string.Empty) }, Author = new EventAuthorInfo { Id = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "AUTHORID", true, string.Empty), Name = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "AUTHORNAME", true, string.Empty), IdRole = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ROLEID", true, string.Empty), RoleName = DataAccess.Helper.DataReaderHelper.GetValue <string>(reader, "ROLENAME", true, string.Empty) }, ObjectSnapshot = pubObj, MailMessageSnapshot = mailRequest }); } catch (SubscriberException pubEx) { _logger.Error(pubEx.Message); throw pubEx; } catch (Exception ex) { _logger.Error(ex.Message); throw new SubscriberException(ErrorCodes.UNHANDLED_ERROR, string.Format(ErrorDescriptions.UNHANDLED_ERROR, ex.Message), ex); } finally { _logger.Info("END"); } }
private async void ValidateLoginAsync() { //Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage()); if (!String.IsNullOrEmpty(this.TextUsername) && !String.IsNullOrEmpty(this.TextPassword)) { UserNetworkManager manager = new UserNetworkManager(); this.CustomActivityIndicator.IsRunning = true; User user = await manager.LoginAsync(this.TextUsername, this.TextPassword); if (user.Success && String.IsNullOrEmpty(user.Message)) { // save user login data to app data Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(user); await Application.Current.SavePropertiesAsync(); Application.Current.MainPage = new BaseNavigationPage(new ManageImageFileContentPage(user)); } else { await DisplayAlert("Error", $"{user.Message}", "OK"); } this.CustomActivityIndicator.IsRunning = false; } else { await DisplayAlert("Error", $"Username and password is required.", "OK"); } }
public static Project Load(string pathName) { var result = ObjectSerializerHelper.DeSerializeObjectFromFile <Project>(pathName); result.FixupReferences(); return(result); }
public async Task <bool> UserMultipleSubscribe() { var manager = new UserNetworkManager(); if (await manager.UserMultipleSubscribeAsync(User.AuthToken)) { User.HasMultipleSubscription = true; // save user login data to app data Application.Current.Properties["User"] = ObjectSerializerHelper.ConvertObjectToBase64(User); await Application.Current.SavePropertiesAsync(); return(true); } return(false); }
public void TestHotkey() { string xmlStr = ""; { var hk = new Hotkey { Alt = true, Key = System.Windows.Input.Key.B }; xmlStr = ObjectSerializerHelper.SerializeObjectToString(hk); } { var hk2 = ObjectSerializerHelper.DeSerializeObjectFromString <Hotkey>(xmlStr); Assert.IsTrue(hk2.Alt == true); Assert.IsTrue(hk2.Ctrl == false); Assert.IsTrue(hk2.Shift == false); Assert.IsTrue(hk2.Key == System.Windows.Input.Key.B); } }
public App() { InitializeComponent(); //Register Syncfusion license Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NDk3MDNAMzEzNjJlMzQyZTMwV1V1UHBKOWF3MlMyYU1qdHJWcFRlRHhKc0JSMkIzTmY4bmh0bTM3elpUZz0="); if (Application.Current.Properties.ContainsKey("User")) { try { var user = ObjectSerializerHelper.Convertbase64StringToObject <User>((string)Application.Current.Properties["User"]); MainPage = new BaseNavigationPage(new ManageImageFileContentPage(user)); } catch { MainPage = new SplashContentPage(); } } else { MainPage = new SplashContentPage(); } }
public void Save(string pathName) { ObjectSerializerHelper.SerializeObjectToXmlFile(this, pathName); }
/// <summary> /// Aggiornamento dati /// </summary> /// <param name="data"></param> /// <returns></returns> public static RuleHistoryInfo SaveHistoryItem(RuleHistoryInfo data) { _logger.Info("BEGIN"); try { Database db = DbHelper.CreateDatabase(); using (DBCommandWrapper cw = db.GetStoredProcCommandWrapper(DbHelper.GetSpNameForPackage("InsertHistory"))) { cw.AddInParameter("pRuleId", DbType.Int32, data.IdRule); cw.AddInParameter("pIdObject", DbType.String, data.ObjectSnapshot.IdObject); cw.AddInParameter("pObjectType", DbType.String, data.ObjectSnapshot.ObjectType); cw.AddInParameter("pObjectTemplateName", DbType.String, data.ObjectSnapshot.TemplateName); cw.AddInParameter("pObjectDescription", DbType.String, data.ObjectSnapshot.Description); cw.AddInParameter("pAuthorName", DbType.String, data.Author.Name); cw.AddInParameter("pAuthorId", DbType.String, data.Author.Id); cw.AddInParameter("pRoleName", DbType.String, data.Author.RoleName); cw.AddInParameter("pRoleId", DbType.String, data.Author.IdRole); if (data.ObjectSnapshot != null) { cw.AddClobParameter("pObjectSnapshot", ObjectSerializerHelper.Serialize(data.ObjectSnapshot)); } else { cw.AddClobParameter("pObjectSnapshot", DBNull.Value); } if (data.MailMessageSnapshot != null) { cw.AddClobParameter("pMailMessageSnapshot", ObjectSerializerHelper.Serialize(data.MailMessageSnapshot)); } else { cw.AddClobParameter("pMailMessageSnapshot", DBNull.Value); } cw.AddInParameter("pComputed", DbType.StringFixedLength, (data.Published ? "1" : "0")); cw.AddInParameter("pComputeDate", DbType.DateTime, data.PublishDate); if (data.ErrorInfo != null) { cw.AddInParameter("pErrorId", DbType.String, data.ErrorInfo.Id); cw.AddInParameter("pErrorDescription", DbType.String, data.ErrorInfo.Message); cw.AddInParameter("pErrorStack", DbType.String, data.ErrorInfo.Stack); } else { cw.AddInParameter("pErrorId", DbType.String, DBNull.Value); cw.AddInParameter("pErrorDescription", DbType.String, DBNull.Value); cw.AddInParameter("pErrorStack", DbType.String, DBNull.Value); } cw.AddOutParameter("pId", DbType.Int32, 4); db.ExecuteNonQuery(cw); if (cw.RowsAffected == 1) { data.Id = Convert.ToInt32(cw.GetParameterValue("pId")); } else { throw new SubscriberException(ErrorCodes.SP_EXECUTION_ERROR, string.Format(ErrorDescriptions.SP_EXECUTION_ERROR, "InsertHistory", ErrorDescriptions.SP_EXECUTE_NO_ROWS)); } } return(data); } catch (SubscriberException pubEx) { _logger.Error(pubEx.Message); throw pubEx; } catch (Exception ex) { _logger.Error(ex.Message); throw new SubscriberException(ErrorCodes.UNHANDLED_ERROR, string.Format(ErrorDescriptions.UNHANDLED_ERROR, ex.Message), ex); } finally { _logger.Info("END"); } }