/// <summary> /// Function to generate unique token with expiry against the provided userId. /// Also add a record in database for generated token. /// </summary> /// <param name="userId"></param> /// <returns></returns> public TokensEntity GenerateToken(int userId) { string token = Guid.NewGuid().ToString(); DateTime issuedOn = DateTime.Now; //DateTime expiredOn = DateTime.Now.AddSeconds(Convert.ToDouble(ConfigurationManager.AppSettings["AuthTokenExpiry"])); DateTime expiredOn = DateTime.Now.AddSeconds(900); var tokendomain = new TOKENS { ID_USER = userId, AUTH_TOKEN = token, EMISION = issuedOn, EXPIRACION = expiredOn }; _unitOfWork.TokenRepository.Insert(tokendomain); _unitOfWork.SaveTrazabilidad(); var tokenModel = new TokensEntity() { ID_USER = userId, EMISION = issuedOn, EXPIRACION = expiredOn, AUTH_TOKEN = token }; return(tokenModel); }
private void Register(String user, String name, String surname, String email, String password) { USERS u = new USERS(); u.ID_ROL = int.Parse(user); u.NAME_USER = name; u.SURNAME_USER = surname; u.EMAIL_USER = email; u.PASSWORD_USER = Hashing.HashPassword(password); u.IMAGE_USER = null; u.CREATED_USER = DateTime.Now; u.UPDATED_USER = DateTime.Now; u.STATUS_USER = 1; c.USERS.Add(u); c.SaveChanges(); TOKENS t = new TOKENS(); t.ID_USER = u.ID_USER; t.VALUE_TOKEN = CreateToken(); t.START_TOKEN = DateTime.Now; t.END_TOKEN = t.START_TOKEN.AddMinutes(15); c.TOKENS.Add(t); c.SaveChanges(); SMTPService smtp = new SMTPService(); smtp.SendEmail(u.EMAIL_USER, t.VALUE_TOKEN); }
private void ClientConfirm(int id, String token, String dni, String telephone, String mobile) { TOKENS t = (from data in c.TOKENS where data.VALUE_TOKEN.Contains(token) select data).FirstOrDefault(); c.TOKENS.Remove(t); c.SaveChanges(); USERS u = (from data in c.USERS where data.ID_USER == id select data).FirstOrDefault(); u.STATUS_USER = 2; c.SaveChanges(); CLIENTS x = new CLIENTS() { ID_USER = id, DNI_CLIENT = dni, TELEPHONE_CLIENT = telephone, MOBILE_CLIENT = mobile }; c.CLIENTS.Add(x); c.SaveChanges(); }
private void PlayerConfirm(int id, String token, String nickname, String age, String sex, String description) { TOKENS t = (from data in c.TOKENS where data.VALUE_TOKEN.Contains(token) select data).FirstOrDefault(); c.TOKENS.Remove(t); c.SaveChanges(); USERS u = (from data in c.USERS where data.ID_USER == id select data).FirstOrDefault(); u.STATUS_USER = 2; c.SaveChanges(); PLAYERS p = new PLAYERS() { ID_USER = id, NICK_PLAYER = nickname, AGE_PLAYER = int.Parse(age), SEX_PLAYER = sex, DESCRIPTION_PLAYER = description, PP_PLAYER = 0, NP_PLAYER = 0, SEALS_PLAYER = 0, LEVEL_PLAYER = 1 }; c.PLAYERS.Add(p); c.SaveChanges(); }
public async Task <bool> sendNotificationAsync() { try { var messageInformation = new Message() { notification = new Notification() { title = TITLE, body = MESSAGE }, registration_ids = TOKENS.ToArray() }; //Object to JSON STRUCTURE => using Newtonsoft.Json; string jsonMessage = JsonConvert.SerializeObject(messageInformation); var request = new HttpRequestMessage(HttpMethod.Post, "https://fcm.googleapis.com/fcm/send"); request.Headers.TryAddWithoutValidation("Authorization", "key=" + API_KEY); request.Content = new StringContent(jsonMessage, Encoding.UTF8, "application/json"); HttpResponseMessage result; using (var client = new HttpClient()) { result = await client.SendAsync(request); resultl = result.ToString(); } // saveNotification(); return(true); } catch (Exception e) { } return(false); }
private static void HelpOnHelp() { Add("The command syntax for requesting additional help with NuGetHandler is:"); Add(); Add(" NuGetHandler -h <subject>"); Add(); Add("where <subject> is the desired section of help to be acquired. Given that the"); Add("length of some of the subject matter is quite long, it is recommended that the"); Add("output of the help system be piped to a text file for later review."); Add(); Add("Some subjects will also yield the actual settings as derived from values"); Add("present on the command line and from the various app.*.config files."); Add(@"To cause those values to be displayed, a verbosity value of ""detailed"""); Add("to the command line e.g. -v detailed"); Add(); Add("The list of subjects follows:"); Add(HelpSections.ToString()); SectionBreak("Content of help sections"); Add($"{"<none>".PadItRight()}The program summary plus this help description."); Add(); Add($"{ALL.PadItRight()}Generate the entire help content (best"); Add($"{String.Empty.PadItLeft()}redirected to a file for further perusal)."); Add(); Add($"{APP_CONFIG_SETTINGS.PadItRight()}Just the information as found in the appSettings"); Add($"{String.Empty.PadItLeft()}portion of the app.config file and its possible"); Add($"{String.Empty.PadItLeft()}app.optional.config files."); Add(); Add($"{APP_CONFIG_NUSPEC_DOTNET.PadItRight()}Just the information as found in the"); Add($"{String.Empty.PadItLeft()}DotNetNuSpecSettings section of the app.config"); Add($"{String.Empty.PadItLeft()}file and its possible app.optional.config files."); Add(); Add($"{APP_CONFIG_NUSPEC_NUGET.PadItRight()}"); Add($"{String.Empty.PadItLeft()}NuGetNuSpecSettings section of the app.config file"); Add($"{String.Empty.PadItLeft()}and its possible app.optional.config files."); Add(); Add($"{COMMAND_LINE.PadItRight()}Help on the command line switches and named value"); Add($"{String.Empty.PadItLeft()}pairs plus the command line introduction."); Add(); Add($"{COMMAND_LINE_SWITCHES.PadItRight()}Help on just the command line switches."); Add(); Add($"{COMMAND_LINE_NAMED_VALUES.PadItRight()}Help on just the command line named values."); Add(); Add($"{COMMAND_SEQUENCE.PadItRight()}Complete list of commands and their respective"); Add($"{String.Empty.PadItLeft()}command line parameters as supported in"); Add($"{String.Empty.PadItLeft()}NuGetHandler"); Add(); Add($"{COMMAND_SEQUENCE_DOTNET_CORE.PadItRight()}Just the command sequence that supports .net Core"); Add($"{String.Empty.PadItLeft()}projects (dotnet.exe)"); Add(); Add($"{COMMAND_SEQUENCE_NUGET.PadItRight()}Just the command sequence that supports full"); Add($"{String.Empty.PadItLeft()}framework projects (nuget.exe)"); Add(); Add($"{COMMAND_SEQUENCE_DOTNET_STANDARD.PadItRight()}Just the comnmand sequence that supports .net"); Add($"{String.Empty.PadItLeft()}standard projects (dotnet.exe)"); Add(); Add($"{CONFIG_INFO.PadItRight()}Display the settings for the final app.config,"); Add($"{String.Empty.PadItLeft()}command line calculated values and other"); Add($"{String.Empty.PadItLeft()}information as determined by the program when"); Add($"{String.Empty.PadItLeft()}executed. If a project was designated,"); Add($"{String.Empty.PadItLeft()}the processed project information will be"); Add($"{String.Empty.PadItLeft()}displayed."); Add(); Add($"{ENVIRONMENT.PadItRight()}Help and content for the program environment."); Add(); Add($"{HELP.PadItRight()}This help description."); Add(); Add($"{NUGET_PUSH.PadItRight()}The combined information concerning the locations"); Add($"{String.Empty.PadItLeft()}(Push Repositories) of the various nuget servers"); Add($"{String.Empty.PadItLeft()}and the corresponding destinations (Push"); Add($"{String.Empty.PadItLeft()}Destinations) that match the repositories."); Add(); Add($"{NUGET_PUSH_REPOS.PadItRight()}Just the information on the nuget server"); Add($"{String.Empty.PadItLeft()}repositories"); Add(); Add($"{NUGET_PUSH_DESTINATIONS.PadItRight()}Just the information on the nuget server"); Add($"{String.Empty.PadItLeft()}repository destinations."); Add(); Add($"{POSTBUILD.PadItRight()}Emit the necessary code that should be placed"); Add($"{String.Empty.PadItLeft()}in the Post-Build event section of the properties"); Add($"{String.Empty.PadItLeft()}of a given project."); Add(); Add($"{SETUP.PadItRight()}How to prepare to install the NuGetHandler"); Add($"{String.Empty.PadItLeft()}program."); Add(); Add($"{SUMMARY.PadItRight()}Just the summary information for the NuGetHandler"); Add($"{String.Empty.PadItLeft()}program."); Add(); Add($"{TOKENS.PadItRight()}Help on the replaceable tokens as found in the"); Add($"{String.Empty.PadItLeft()}app.config file."); Add(); }