private void InitiEditBoxes(WifiCredentialsDataModel cred) { this.edHost.Text = cred.RemoteHostName; this.edPort.Text = cred.RemoteServiceName; this.edPwd.Text = cred.WifiPassword; this.edSsid.Text = cred.SSID; }
protected override void OnAppearing() { App.Wrapper.CurrentSupportedLanguage(this.LanguageUpdate); this.interceptor.Changed = false; if (this.index != null) { // Can load this one from storage since not yet loaded App.Wrapper.RetrieveWifiCredData( this.index, this.OnLoadSuccess, this.ErrAndCLose); if (this.dataModel == null) { this.OnErr(string.Format("Data model for '{0}' is NULL", this.index.Display)); } } else { //create a new Data model for create this.dataModel = new WifiCredentialsDataModel(); } if (this.dataModel != null) { this.edSsid.Text = this.dataModel.SSID; this.edHost.Text = this.dataModel.RemoteHostName; this.edPort.Text = this.dataModel.RemoteServiceName; this.edPwd.Text = this.dataModel.WifiPassword; } base.OnAppearing(); }
private void OnRetrieveOk(WifiCredentialsDataModel data) { this.dataModelToEdit = data; this.Title = data.SSID; this.txtPwd.Password = data.WifiPassword; this.txtHostName.Text = data.RemoteHostName; this.txtServiceName.Text = data.RemoteServiceName; }
//private async Task<WifiCredAndIndex> WifiGetStoredCredentials(string ssid, OnErr onError) { private WifiCredAndIndex WifiGetStoredCredentials(string ssid, OnErr onError) { //return await Task.Run<WifiCredAndIndex>(() => { WifiCredAndIndex result = null; this.GetWifiCredList( (list) => { foreach (var item in list) { this.log.Info("WifiGetStoredCredentials", () => string.Format("SSID '{0}' List itm display '{1}", ssid, item.Display)); if (item.Display == ssid) { this.RetrieveWifiCredData( item, (data) => { this.log.Info("WifiGetStoredCredentials", () => string.Format("FOUND SSID '{0}'", item.Display)); result = new WifiCredAndIndex() { Index = item, Data = data, RequiresUserData = (data.RemoteHostName.Trim().Length == 0 || data.RemoteServiceName.Trim().Length == 0 || data.WifiPassword.Trim().Length == 0), }; }, onError); break; } } if (result == null) { // Create new one WifiCredentialsDataModel dm = new WifiCredentialsDataModel() { SSID = ssid, }; this.CreateNewWifiCred( ssid, dm, (ndx) => { result = new WifiCredAndIndex() { Data = dm, Index = ndx, RequiresUserData = true, }; }, onError); } }, onError); return(result); //}); }
public void SaveWifiCred(IIndexItem <DefaultFileExtraInfo> idx, WifiCredentialsDataModel data, Action onSuccess, OnErr onError) { WrapErr.ToErrReport(9999, () => { ErrReport report; WrapErr.ToErrReport(out report, 9999, () => { if (idx.Display.Length == 0) { onError.Invoke(this.GetText(MsgCode.EmptyName)); } else if (string.IsNullOrWhiteSpace(data.SSID)) { onError.Invoke(this.GetText(MsgCode.EmptySSID)); } else if (string.IsNullOrWhiteSpace(data.RemoteHostName)) { onError.Invoke(this.GetText(MsgCode.EmptyHostName)); } else if (string.IsNullOrWhiteSpace(data.RemoteServiceName)) { onError.Invoke(this.GetText(MsgCode.EmptyPort)); } else if (string.IsNullOrWhiteSpace(data.WifiPassword)) { onError.Invoke(this.GetText(MsgCode.EmptyPwd)); } else { idx.Display = data.SSID; this.wifiCredStorage.Store(data, idx); onSuccess.Invoke(); } }); if (report.Code != 0) { onError.Invoke(this.GetText(MsgCode.SaveFailed)); } }); }
private void btnOk_Click(object sender, RoutedEventArgs e) { switch (this.processType) { case ProcessType.Edit: // This is an edit of an existing this.dataModelToEdit.RemoteHostName = this.txtHostName.Text; this.dataModelToEdit.RemoteServiceName = this.txtServiceName.Text; this.dataModelToEdit.WifiPassword = this.txtPwd.Password; DI.Wrapper.SaveWifiCred( this.index, this.dataModelToEdit, this.OnSaveOk, this.OnDataErr); break; case ProcessType.Init: if (this.index == null) { // Validate entries in wrapper level this.Result.IsChanged = true; this.Result.HostName = txtHostName.Text; this.Result.ServiceName = txtServiceName.Text; this.Result.Password = this.txtPwd.Password; this.Close(); } break; case ProcessType.Create: WifiCredentialsDataModel dm = new WifiCredentialsDataModel() { SSID = this.txtSSID.Text, RemoteHostName = this.txtHostName.Text, RemoteServiceName = this.txtServiceName.Text, WifiPassword = this.txtPwd.Password, }; DI.Wrapper.CreateNewWifiCred(dm.SSID, dm, this.OnSaveOk, this.OnDataErr); break; } }
public void CreateNewWifiCred(string display, WifiCredentialsDataModel data, Action <IIndexItem <DefaultFileExtraInfo> > onSuccess, OnErr onError) { WrapErr.ToErrReport(9999, () => { ErrReport report; WrapErr.ToErrReport(out report, 9999, () => { if (display.Length == 0) { onError.Invoke(this.GetText(MsgCode.EmptyName)); } else { IIndexItem <DefaultFileExtraInfo> idx = new IndexItem <DefaultFileExtraInfo>(data.UId) { Display = display, }; this.SaveWifiCred(idx, data, () => { onSuccess(idx); }, onError); } }); if (report.Code != 0) { onError.Invoke(this.GetText(MsgCode.SaveFailed)); } }); }
private void OnLoadSuccess(WifiCredentialsDataModel dataModel) { this.dataModel = dataModel; }