internal RegisterResult Register(string name, System.Delegate callback) { var thunk = (name != "all")? CreateCallback(callback) : CreateGenericCallback(callback); var result = new RegisterResult { thunk = CallbackThunk, id = Callbacks.Count }; Callbacks.Add(thunk); return result; }
public void register(string options) { try { var args = JSON.JsonHelper.Deserialize<string[]>(options); var pushOptions = JSON.JsonHelper.Deserialize<Options>(args[0]); this.channelName = pushOptions.ChannelName; this.toastCallback = pushOptions.NotificationCallback; } catch (Exception) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } this.pushChannel = HttpNotificationChannel.Find(this.channelName); if (this.pushChannel == null) { this.pushChannel = new HttpNotificationChannel(this.channelName); this.PushChannel_HookEvents(); this.pushChannel.Open(); this.pushChannel.BindToShellToast(); this.pushChannel.BindToShellTile(); } else { this.PushChannel_HookEvents(); var result = new RegisterResult(); result.ChannelName = this.channelName; result.Uri = this.pushChannel.ChannelUri.ToString(); this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); } }
void PushChannel_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e) { // return uri to js RegisterResult result = new RegisterResult(); result.ChannelName = this.channelName; result.Uri = pushChannel.ChannelUri.ToString(); this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); }
public static object UNREGISTER_ALL() { string ret = null; try { string ResultMessage = Validate.ValidateCommon(); if (!string.IsNullOrEmpty(ResultMessage)) { return(ResultMessage); } Tuple <DateTime, string> tpl; var tplKey = "UNREGISTER_ALL"; if (_unregisterAllCache.TryGetValue(tplKey, out tpl)) { if ((DateTime.Now - tpl.Item1).TotalSeconds < 1) { ret = tpl.Item2; } } if (String.IsNullOrEmpty(ret)) { ret = middleware.UnregisterAll(); _unregisterAllCache[tplKey] = Tuple.Create(DateTime.Now, ret); } object array; array = RegisterResult.RegisterCheck(ret); if (!CustomRibbon._env) { return(0); } return(XlCall.Excel(XlCall.xlUDF, "Resize", array)); } catch (Exception exception) { if (exception.InnerException == null) { return(exception.Message); } else { return(exception.InnerException.Message); } } }
public static async Task <RegisterResult> ImportUsers(HttpClient _httpClient, Stream fileStream) { List <MemberViewModel> userList = LoadUserList(fileStream); RegisterResult result = new RegisterResult(); foreach (MemberViewModel user in userList) { result = await ImportUser(_httpClient, user); if (!result.Successful) { return(result); } } return(result); }
public RegisterResult Register([FromBody] SystemuserParam pr) { RegisterResult res = new RegisterResult(); try { pr.password = LoginController.MD5Hash(pr.password); if (_dataAccessProvider.RegisterUser(pr.fullname, pr.email, pr.password)) { var message = new MimeMessage(); message.To.Add(new MailboxAddress(pr.fullname, pr.email)); message.From.Add(new MailboxAddress("*****@*****.**", "T.Lo.noreply")); message.Subject = "Register Ticket Lo"; message.Body = new TextPart(TextFormat.Html) { Text = "Hai lu berhasil register... silahkan login lagi cuy" }; using (var emailClient = new SmtpClient()) { emailClient.Connect("smtp.gmail.com", 465); emailClient.Authenticate("*****@*****.**", "BL4CKC412D"); emailClient.Send(message); emailClient.Disconnect(true); } res.Status = "OK"; res.Message = "Register Success"; } else { res.Status = "NG"; res.Message = "Email sudah ada"; } } catch (Exception ex) { res.Status = "NG"; res.Message = ex.ToString(); }//commit return(res); }
/// <summary> /// Register method /// </summary> /// <param name="options"></param> public void register(string options) { Options pushOptions; try { string[] args = JSON.JsonHelper.Deserialize <string[]>(options); pushOptions = JSON.JsonHelper.Deserialize <Options>(args[0]); this.channelName = pushOptions.ChannelName; this.toastCallback = pushOptions.NotificationCallback; } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } pushChannel = HttpNotificationChannel.Find(channelName); if (pushChannel == null) { pushChannel = new HttpNotificationChannel(channelName); pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated; pushChannel.ErrorOccurred += PushChannel_ErrorOccurred; pushChannel.ShellToastNotificationReceived += PushChannel_ShellToastNotificationReceived; pushChannel.Open(); pushChannel.BindToShellToast(); } else { pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated; pushChannel.ErrorOccurred += PushChannel_ErrorOccurred; pushChannel.ShellToastNotificationReceived += PushChannel_ShellToastNotificationReceived; RegisterResult result = new RegisterResult(); result.ChannelName = this.channelName; result.Uri = pushChannel.ChannelUri.ToString(); this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); } PhoneApplicationService service = PhoneApplicationService.Current; service.RunningInBackground += service_RunningInBackground; service.Activated += service_Activated; service.Deactivated += service_Deactivated; }
public void ParseResponse() { string text = @"<?xml version='1.0' encoding=""UTF-8"" standalone=""no"" ?> <!DOCTYPE OPS_envelope SYSTEM ""ops.dtd""> <OPS_envelope> <header> <version>0.9</version> </header> <body> <data_block> <dt_assoc> <item key=""protocol"">XCP</item> <item key=""object"">DOMAIN</item> <item key=""response_code"">200</item> <item key=""is_success"">1</item> <item key=""response_text"">Domain registration successfully completed Domain successfully locked. Whois Privacy successfully enabled.</item> <item key=""action"">REPLY</item> <item key=""attributes""> <dt_assoc> <item key=""registration_text"">Domain registration successfully completed Domain successfully locked. Whois Privacy successfully enabled.</item> <item key=""admin_email"">[email protected]</item> <item key=""registration_code"">200</item> <item key=""id"">1580054</item> </dt_assoc> </item> </dt_assoc> </data_block> </body> </OPS_envelope>"; var result = RegisterResult.Parse(text); Assert.Equal(1580054L, result.Id); Assert.Equal("*****@*****.**", result.AdminEmail); Assert.Equal(200, result.RegistrationCode); Assert.Equal(@"Domain registration successfully completed Domain successfully locked. Whois Privacy successfully enabled.".Replace("\r", ""), result.RegistrationText); Assert.Null(result.Error); }
void rsc_RegisterUserCompleted(object sender, RegisterUserCompletedEventArgs e) { RegisterResult result = (RegisterResult)e.Result; if (result.HasError) { Debug.WriteLine(result.Message); LogMessage = result.Message; ColorLog = COLOR_RED; } else { Debug.WriteLine(result.Message); LogMessage = result.Message; ColorLog = COLOR_GREEN; } }
public void register(string options, bool retry) { if (!TryDeserializeOptions(options, out this.pushOptions)) { SendError(JSONError); return; } HttpNotificationChannel pushChannel = HttpNotificationChannel.Find(this.pushOptions.WP8.ChannelName); if (pushChannel == null) { pushChannel = new HttpNotificationChannel(this.pushOptions.WP8.ChannelName); try { pushChannel.Open(); } catch (InvalidOperationException) { SendError(InvalidRegistrationError); return; } pushChannel.BindToShellToast(); pushChannel.BindToShellTile(); } if ((pushChannel.ChannelUri == null || pushChannel.ChannelUri.ToString() == String.Empty) && retry) { Thread.Sleep(500); register(options, false); } else { SubscribePushChannelEvents(pushChannel); RegisterResult result = new RegisterResult { ChannelName = this.pushOptions.WP8.ChannelName, Uri = pushChannel.ChannelUri == null ? string.Empty : pushChannel.ChannelUri.ToString() }; SendEvent(JsonConvert.SerializeObject(result)); } }
public async Task <RegisterResult> RegisterExternalAsync(string username, string email, string scheme, string identity, string identityName) { var user = new LoginUser() { Username = username, Email = email, CreationTime = DateTime.UtcNow }; var userAuth = new LoginUserAuthentication() { Scheme = StringToScheme(scheme), Identity = identity, Name = identityName, CreationTime = DateTime.UtcNow }; try { user = await _persistence.Users.CreateUserAsync(user); } catch (Exception) { //TODO reduce breadth of exception statement return(RegisterResult.GetFailed("Username is already in use")); } try { userAuth.UserId = user.Id; userAuth = await _persistence.Users.CreateUserAuthenticationAsync(userAuth); } catch (Exception) { // cleanup await _persistence.Users.DeleteUserAsync(user); throw; } // add in option of an email activation step and use options to provide redirect url await SignInAsync(user); return(RegisterResult.GetSuccess()); }
public async void Register_Valid_User_Account(string personnummer, string name, double amount) { var registerUseCase = new RegisterUseCase( customerWriteOnlyRepository, accountWriteOnlyRepository ); RegisterResult result = await registerUseCase.Execute( personnummer, name, amount); Assert.Equal(personnummer, result.Customer.Personnummer); Assert.Equal(name, result.Customer.Name); Assert.True(Guid.Empty != result.Customer.CustomerId); Assert.True(Guid.Empty != result.Account.AccountId); }
public async Task <IHttpActionResult> RegisterDoctor(DoctorRegisterBindingModel model) { RegisterResult result = await Register(model, "doctor"); if (result.IsSuccess) { Doctor doctor = new Doctor() { Image = model.Image, Text = model.Text }; doctor.ApplicationUserId = result.User.Id; doctor.PersonInfo = create_person_info(model); doctor_repository.Create(doctor); } return(result.Result); }
public async Task <IHttpActionResult> RegisterPatient(PatientRegisterBindingModel model) { RegisterResult result = await Register(model, "patient"); if (result.IsSuccess) { Patient patient = new Patient(); patient.IsMen = model.IsMen; patient.DateOfBirth = model.DateOfBirth; patient.MedicalCardNumber = model.MedicalCardNumber; patient.ApplicationUserId = result.User.Id; patient.PersonInfo = create_person_info(model); patient_repository.Create(patient); } return(result.Result); }
private static string RegisterCodeToErrorString(RegisterResult createStatus) { switch (createStatus) { case RegisterResult.DuplicateEmail: return("User name already exists. Please enter a different user name."); case RegisterResult.InvalidPassword: return("The password provided is invalid. Please enter a valid password value."); case RegisterResult.InvalidEmail: return("The e-mail address provided is invalid. Please check the value and try again."); default: return("An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."); } }
/// <summary> /// Register method /// </summary> /// <param name="options"></param> public void register(string options) { Options pushOptions; try { string[] args = JSON.JsonHelper.Deserialize<string[]>(options); pushOptions = JSON.JsonHelper.Deserialize<Options>(args[0]); this.channelName = pushOptions.ChannelName; this.toastCallback = pushOptions.NotificationCallback; } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } pushChannel = HttpNotificationChannel.Find(channelName); if (pushChannel == null) { pushChannel = new HttpNotificationChannel(channelName); pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated; pushChannel.ErrorOccurred += PushChannel_ErrorOccurred; pushChannel.ShellToastNotificationReceived += PushChannel_ShellToastNotificationReceived; pushChannel.Open(); pushChannel.BindToShellToast(); } else { pushChannel.ChannelUriUpdated += PushChannel_ChannelUriUpdated; pushChannel.ErrorOccurred += PushChannel_ErrorOccurred; pushChannel.ShellToastNotificationReceived += PushChannel_ShellToastNotificationReceived; RegisterResult result = new RegisterResult(); result.ChannelName = this.channelName; result.Uri = pushChannel.ChannelUri.ToString(); this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); } PhoneApplicationService service = PhoneApplicationService.Current; service.RunningInBackground += service_RunningInBackground; service.Activated += service_Activated; service.Deactivated += service_Deactivated; }
public void register(string options) { if (!TryDeserializeOptions(options, out this.pushOptions)) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } var pushChannel = HttpNotificationChannel.Find(this.pushOptions.ChannelName); if (pushChannel == null) { pushChannel = new HttpNotificationChannel(this.pushOptions.ChannelName); SubscribePushChannelEvents(pushChannel); try { var count = 0; while (count < 3 && pushChannel.ChannelUri == null) { pushChannel.Open(); System.Threading.Thread.Sleep(100);// custom fix count++; } } catch (InvalidOperationException) { this.DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, InvalidRegistrationError)); return; } pushChannel.BindToShellToast(); pushChannel.BindToShellTile(); } else { SubscribePushChannelEvents(pushChannel); } var result = new RegisterResult { ChannelName = this.pushOptions.ChannelName, Uri = pushChannel.ChannelUri == null ? string.Empty : pushChannel.ChannelUri.ToString() }; this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); }
public async Task <IActionResult> Post([FromBody] RegisterModel model) { var newUser = new User { UserName = model.Username, Email = model.Email }; if (await EmailAlreadyInUse(model.Email)) { var value = new RegisterResult { Successful = false, Errors = new[] { $"{model.Email} address is already in use" } }; return(Ok(value)); } var result = await _userManager.CreateAsync(newUser, model.Password); if (!result.Succeeded) { var errors = result.Errors.Select(x => x.Description); return(Ok(new RegisterResult { Successful = false, Errors = errors })); } var token = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); var url = Url.Action( "Confirm", "EmailConfirmation", new { userId = newUser.Id, token }, protocol: HttpContext.Request.Scheme); await _emailSender.SendEmailAsync(newUser.Email, "Password confirmation", "Confirm your password by visiting the following link: " + url ); return(Ok(new RegisterResult { Successful = true })); }
public async Task <IActionResult> Index() { if (!signInManager.IsSignedIn(User)) { return(RedirectToAction("Login")); } ApplicationUser user = await userManager.FindByEmailAsync(User.Identity.Name); RegisterResult result = new RegisterResult() { FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, }; return(View(result)); }
public async Task <RegisterResult> Register(ServerInfoDto serverInfo) { UpdateLastActivity(); RegisterResult result = AuthServer.Instance.ServerManager.Add(serverInfo) ? RegisterResult.OK : RegisterResult.AlreadyExists; if (result == RegisterResult.OK) { var state = CurrentContext.Channel.GetAttribute(ChannelAttributes.State).Get(); state.ServerId = serverInfo.Id; } return(result); }
// Кнопка Register private async void registerButton_Click(object sender, EventArgs e) { string resultMessage = "Something went wrong, try again"; string name = nameTextBox.Text; string surname = surnameTextBox.Text; string tokenNumber = tokenTextBox.Text; string login = loginRegTextbox.Text; string password = passwordRegTextBox.Text; string passwordConfirm = confirmPasswordTextBox.Text; if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(tokenNumber) || string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(passwordConfirm)) { resultMessage = "Not all fields are filled, try again"; } else { if (password != passwordConfirm) { resultMessage = "Passwords dont match, try again"; } else { RegisterResult registerResult = await userManager.RegisterAsync(name, surname, int.Parse(tokenNumber), login, password); if (registerResult == RegisterResult.LoginExists) { resultMessage = "User with this login is already registered, try again"; } if (registerResult == RegisterResult.TokenExists) { resultMessage = "User with this token is already registered, try again"; } if (registerResult == RegisterResult.Success) { resultMessage = "You are successfully registered"; } } } MessageBox.Show(resultMessage, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
private static bool RegisterClient(Stream stream) { LoginRequest loginRequest = RecieveLoginRequest(stream); RegisterResult result = new RegisterResult(); result.Registered = Server.Instance.GetDatabaseConnection().InsertPlayerQuery(loginRequest.Username, loginRequest.Password, out result.Reason); SendRegisterResult(stream, result); if (result.Registered) { Console.WriteLine("(" + loginRequest.Username + ") Successful register."); return(true); } else { Console.WriteLine("(" + loginRequest.Username + ") Failed register."); return(false); } }
public IActionResult Register([FromBody] UserRegisterRequest request) { RegisterResult result = ClientManager.RegisterClient(request); switch (result) { case RegisterResult.Ok: return(Ok()); case RegisterResult.PhonenumberExists: return(StatusCode(StatusCodes.Status409Conflict, "Phonenumber exists")); case RegisterResult.UsernameExists: return(StatusCode(StatusCodes.Status409Conflict, "Username exists")); default: throw new NotImplementedException($"{result.ToString()} Register result is not implmented"); } }
public virtual SubmitResult RegisterUser(IRegisterModel model) { if (SecurityUnit.UserRepository.NameExists(model.LogonName)) { return(new SubmitResult(1, SecurityUnit.Strings.Message(MessageIds.user_name_exists))); } RegisterResult res = SecurityUnit.UserRepository.AddUser(model); if (res.Success) { var r = SecurityUnit.SaveChanges(); r.Data["Model"] = res.Entity; return(r); } else { return(new SubmitResult(1, res.Message)); } }
private async void CompleteApplicationRegistration(string channelUri, string notificationHubPath, string connectionString) { try { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); var registration = await hub.RegisterNativeAsync(channelUri); var regInfo = new RegisterResult(); regInfo.RegistrationId = registration.RegistrationId; regInfo.ChannelUri = registration.ChannelUri; regInfo.NotificationHubPath = registration.NotificationHubPath; DispatchCommandResult(new PluginResult(PluginResult.Status.OK, regInfo)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
public IActionResult Register([FromBody] UserRegistrationInfo userRegistrationInfo) { if (!this.ModelState.IsValid) { var error = ServiceErrorResponses.BodyIsMissing(nameof(UserRegistrationInfo)); return(this.BadRequest(error)); } RegisterResult result = null; try { result = this.registrator.Register(userRegistrationInfo.Login, userRegistrationInfo.Password); } catch (RegistrationException ex) { return(this.BadRequest(ex.Message)); } return(this.Ok(result)); }
private bool CheckUser(User user) { var result = false; if (user.username == userLogin.username) { RegisterResult = RegisterResult.usernameExist; } else if (user.email == userLogin.email) { RegisterResult = RegisterResult.emailExist; } else { RegisterResult = RegisterResult.ok; result = true; } return(result); }
public void ParseResponse2() { string text = @"<OPS_envelope> <header> <version>0.9</version> </header> <body> <data_block> <dt_assoc> <item key=""protocol"">XCP</item> <item key=""action"">REPLY</item> <item key=""object"">DOMAIN</item> <item key=""is_success"">1</item> <item key=""response_code"">200</item> <item key=""response_text"">Domain registration successfully completed. WHOIS Privacy successfully enabled. Domain successfully locked.</item> <item key=""attributes""> <dt_assoc> <item key=""admin_email"">[email protected]</item> <item key=""whois_privacy_state"">enabled</item> <item key=""registration_text"">Domain registration successfully completed. WHOIS Privacy successfully enabled. Domain successfully locked.</item> <item key=""registration_code"">200</item> <item key=""id"">3735281</item> <item key=""cancelled_orders""> <dt_array> <item key=""0"">1</item> <item key=""1"">2</item> </dt_array> </item> </dt_assoc> </item> </dt_assoc> </data_block> </body> </OPS_envelope>"; var result = RegisterResult.Parse(text); Assert.Equal(3735281, result.Id); Assert.Equal("*****@*****.**", result.AdminEmail); Assert.Equal("enabled", result.WhoisPrivacyState); Assert.Equal(200, result.RegistrationCode); }
private void NameRequestCompleted(AsyncOperation obj) { UnityWebRequestAsyncOperation oper = obj as UnityWebRequestAsyncOperation; UnityWebRequest www = oper.webRequest; if (www.isNetworkError || www.isHttpError) { //Debug.Log(www.error); registerResult(false, ""); } else { // Show results as text //Debug.Log(www.downloadHandler.text); RegisterResult result = RegisterResult.CreateFromJSON(www.downloadHandler.text); registerResult(result.success, result.name); } www.Dispose(); }
public async Task <RegisterResult> RegisterAsync(RegisterUser model) { if (model == null) { } if (!model.CheckValidate()) { } var user = CheckUser(model.UserName); if (user != null) { throw new CoreException("User not found", 0); } user = (TUser)Activator.CreateInstance(typeof(TUser)); user.Create <string>(model); await RegisterAsync(user); return(RegisterResult.Create(user)); }
public async Task <IActionResult> RegisterServerAsync([FromBody] ServerRegisterRequest registerRequest) { xServer.Stats.IncrementPublicRequest(); ServerNodeData serverNode = new ServerNodeData() { ProfileName = registerRequest.ProfileName, NetworkAddress = registerRequest.NetworkAddress, NetworkPort = registerRequest.NetworkPort, KeyAddress = registerRequest.KeyAddress, SignAddress = registerRequest.SignAddress, FeeAddress = registerRequest.FeeAddress, Signature = registerRequest.Signature, Tier = registerRequest.Tier, NetworkProtocol = registerRequest.NetworkProtocol }; RegisterResult registerResult = await xServer.Register(serverNode); return(Json(registerResult)); }
public async void Register_Valid_User_Account(string personnummer, string name, double amount) { var registerUseCase = new RegisterService( customerWriteOnlyRepository, accountWriteOnlyRepository ); var request = new RegisterCommand( personnummer, name, amount ); RegisterResult result = await registerUseCase.Process(request); Assert.Equal(request.Personnummer, result.Customer.Personnummer); Assert.Equal(request.Name, result.Customer.Name); Assert.True(Guid.Empty != result.Customer.CustomerId); Assert.True(Guid.Empty != result.Account.AccountId); }
public async Task <RegisterResult> Register(RegisterModel registerModel) { var registerJson = JsonSerializer.Serialize(registerModel); var response = await _httpClient.PostAsync("api/auth/register", new StringContent(registerJson, Encoding.UTF8, "application/json")); //var registerResult = JsonSerializer.Deserialize<RegisterResult>(await response.Content.ReadAsStringAsync(), new JsonSerializerOptions {PropertyNameCaseInsensitive = true}); var registerResult = new RegisterResult(); if ((int)response.StatusCode == 200) { registerResult.Successful = true; } else { registerResult.Successful = false; } return(registerResult); }
public async Task <RegisterResult> Register(User user, string password) { var res = await userRepo.Create(user, password); var result = new RegisterResult(); if (res.Succeeded) { result.Success = true; result.Username = user.UserName; } else { result.Success = false; foreach (var item in res.Errors) { result.Errors.Add(new Error(item.Code, item.Description)); } } return(result); }
public void register(string options) { Options pushOptions; try { string[] args = JSON.JsonHelper.Deserialize<string[]>(options); pushOptions = JSON.JsonHelper.Deserialize<Options>(args[0]); this.channelName = pushOptions.ChannelName; this.toastCallback = pushOptions.NotificationCallback; } catch (Exception) { DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION)); return; } pushChannel = HttpNotificationChannel.Find(channelName); if (pushChannel == null) { pushChannel = new HttpNotificationChannel(channelName); pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated); pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred); pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived); pushChannel.Open(); pushChannel.BindToShellToast(); } else { pushChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(PushChannel_ChannelUriUpdated); pushChannel.ErrorOccurred += new EventHandler<NotificationChannelErrorEventArgs>(PushChannel_ErrorOccurred); pushChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(PushChannel_ShellToastNotificationReceived); RegisterResult result = new RegisterResult(); result.ChannelName = this.channelName; result.Uri = pushChannel.ChannelUri.ToString(); this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, result)); } }
private static string RegisterCodeToErrorString(RegisterResult createStatus) { switch (createStatus) { case RegisterResult.DuplicateEmail: return "User name already exists. Please enter a different user name."; case RegisterResult.InvalidPassword: return "The password provided is invalid. Please enter a valid password value."; case RegisterResult.InvalidEmail: return "The e-mail address provided is invalid. Please check the value and try again."; default: return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."; } }
private async void CompleteApplicationRegistration(string channelUri, string notificationHubPath, string connectionString, string tags) { try { var hub = new Microsoft.WindowsAzure.Messaging.NotificationHub(notificationHubPath, connectionString); List<string> tagCollection = new List<string>(); if (tags.Contains(",")) { foreach (string tag in tags.Split(',')) { tagCollection.Add(tag); } } else { tagCollection.Add(tags); } var registration = await hub.RegisterNativeAsync(channelUri, tagCollection); var regInfo = new RegisterResult(); regInfo.RegistrationId = registration.RegistrationId; regInfo.ChannelUri = registration.ChannelUri; regInfo.NotificationHubPath = registration.NotificationHubPath; regInfo.Tags = registration.Tags; DispatchCommandResult(new PluginResult(PluginResult.Status.OK, regInfo)); } catch (Exception ex) { DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, ex.Message)); } }
private void GetResponseCallback(IAsyncResult asynchronousResult) { PCOSMessageBase retmsg = new PCOSMsgInvalid(); try { HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response; // End the get response operation response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult); System.IO.Stream streamResponse = response.GetResponseStream(); System.IO.BinaryReader inputstream = new System.IO.BinaryReader(streamResponse); if (inputstream.BaseStream.Length > 0) { byte[] responsebytes = new byte[inputstream.BaseStream.Length]; int totalRead = 0; while (totalRead < inputstream.BaseStream.Length) { responsebytes[totalRead++] = inputstream.ReadByte(); } ArraySegment<byte> raw = new ArraySegment<byte>(responsebytes, 0, totalRead); retmsg = PCOSMsgFactory.Parse(raw); } streamResponse.Close(); inputstream.Close(); response.Close(); } catch (WebException e) { } DSAHelper.RegisterResult registerresult = new RegisterResult(); if(retmsg is PCOSMsgRegisterAck) { PCOSMsgRegisterAck pcosregack = (PCOSMsgRegisterAck)retmsg; registerresult.Registered = true; registerresult.Message = "Registered Successful"; PCSettings.PEMPublic = this.PEMPublicKey; PCSettings.PEMPrivate = this.PEMPrivateKey; PCSettings.MAT = Convert.ToBase64String(pcosregack.MAT); PCSettings.Registered = true; PCSettings.RegDatetime = DateTime.Now; // save it first... PCSettings.Save(); } else if(retmsg is PCOSMsgError) { PCOSMsgError pcosmsgerr = (PCOSMsgError)retmsg; registerresult.Message = pcosmsgerr.ErrorCode + ":" + pcosmsgerr.Reason; } else { registerresult.Message = "Failed to registered with Push Coin server. Please try again at a later time."; } if (OnRegistered != null) OnRegistered(registerresult); }
public RegisterResult Register(string username, string password) { RegisterResult result = new RegisterResult(); result.ResultString = ResultCodes.RegisterUserFail; result.UserId = 0; if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { if (!_repo.UserExists(username)) { User user = _repo.AddUser(username, password); result.ResultString = ResultCodes.RegisterUserSuccess; result.Username = user.Username; result.UserId = user.Id; } else { result.ResultString = ResultCodes.RegisterUserExists; } } return result; }
public ReceivedRegisterResultEventArgs(RegisterResult result) { Result = result; }
RegisterResult ITodoService.Register(string username, string password) { RegisterResult result = new RegisterResult() { ResultString = ResultCodes.RegisterUserFail, UserId = 0 }; try { if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password)) { if (!_repo.UserExists(username)) { User user = _repo.AddUser(username, password); result.ResultString = ResultCodes.RegisterUserSuccess; result.Username = user.Username; result.UserId = user.Id; _log.Info(String.Format("New user is registered: {0}", user.Username)); } else { result.ResultString = ResultCodes.RegisterUserExists; } } } catch (Exception ex) { _log.Error(ex); ServiceDataFault fault = new ServiceDataFault() { Issue = "Register Fail", Details = ex.ToString() }; throw new FaultException<ServiceDataFault>(fault, new FaultReason(fault.Issue)); } return result; }
private void NotifyRegitrationIfNeeded() { Uri currentChannelUri; lock (this) { currentChannelUri = this.currentChannel.ChannelUri; if (currentChannelUri == this.lastChannelUri) { return; } this.lastChannelUri = currentChannelUri; } // If we have a URI, notify the client and take the change to flush any coldstart notification. if (currentChannelUri != null) { var result = new RegisterResult { Uri = currentChannelUri.ToString() }; DispatchNonFinalResult(PluginResult.Status.OK, JsonConvert.SerializeObject(result)); NotifyColdstartNotificationIfNeeded(); } }
public static ModelStateDictionary Register(DefaultContext db, Register model, out RegisterResult registerResult) { var modelStateDictionary = new ModelStateDictionary(); // Attempt to register the user try { var propertyValues = new { model.FirstName, model.LastName, model.Title, model.City, model.DistrictId, model.PhoneNumberPrefix1Id, model.PhoneNumber1, model.PhoneNumberPrefix2Id, model.PhoneNumber2, model.Email1, model.Email2, model.GoogleCredentialsJson, model.GoogleCalendarId, model.PremiumMembershipGranted, model.AccessGranted, model.Ca, model.Presenting, model.MspCoach, model.RegistrarId, Active = true, model.LyonessId, model.Note, model.Tasks, model.Skype, model.SmsEmail, UseMail = true, UseSms = true, UseGoogleCalendar = true, model.ClaAccessExpired, model.ClaAccessYearlyAccessCZK, model.ClaAccessYearlyAccessEUR, model.ClaAccessYearlyAccessUSD, ClaAccessCurrency = model.CurrencyType, model.ClaAccessTrial, model.ClaAccessFixCurrencyChange, model.LCID }; string password = Cryptography.GetRandomPassword(); WebSecurity.CreateUserAndAccount(model.UserName, password, propertyValues); Roles.AddUserToRole(model.UserName, UserProfile.GetRoleTypeDbName(RoleType.AuthGuest)); string textBody = String.Format(MailResource.AccountController_Register_TextBody, model.UserName, password, Url.GetWebRootUrl()); if (!Mail.SendEmail(model.Email1, MailResource.AccountController_Register_Subject, textBody, true, true)) { registerResult = RegisterResult.CannotSendRegisterEmail; return modelStateDictionary; } } catch (MembershipCreateUserException e) { string message = String.Format("Register New User '{0}' - {1}", model.UserName, e.Message); Logger.SetLog(message); registerResult = RegisterResult.Failed; modelStateDictionary.AddModelError(EmptyField, DecodeMembershipCreateStatus(e.StatusCode)); return modelStateDictionary; } catch (Exception e) { Logger.SetLog(e); registerResult = RegisterResult.Failed; modelStateDictionary.AddModelError(EmptyField, ValidationResource.Global_UnexpectedException_ErrorMessage); return modelStateDictionary; } registerResult = RegisterResult.Ok; return modelStateDictionary; }
public override void ReadPayload(ISerializationContext context, IValueReader reader) { Result = (RegisterResult)reader.ReadByte(); }