/// <summary> /// 获取用户的游戏状态 /// </summary> /// <param name="key">UserID</param> /// <returns></returns> public GameInfo GetGameData(string key) { var data = new GameInfo(); try { //首先从服务端缓存获取 data = CacheExts <GameInfo> .GetValue(key); if (data == null) { //缓存不存在,则读取用户本地Cookie解析成游戏对象 var cookieStr = CookiesHelper.GetCookieValue(key); var json = EncryptAndDecrypt.Decrypt(cookieStr); data = JsonConvert.DeserializeObject <GameInfo>(json); } } catch {} if (data == null) { //如果都没有,则初始化一个游戏对象 data = new GameInfo(); RefNum(ref data); } return(data); }
static void Main(string[] args) { Console.WriteLine("Enter a string to be encrypted: "); string userString = Console.ReadLine(); string cleanString = EncryptAndDecrypt.CleanString(userString); EncryptAndDecrypt.SetCypherKey(); EncryptAndDecrypt.SetCypherWord(); Console.WriteLine($"\nYour entry: {cleanString} is in plain text form."); string encryptedWithSingleKey = EncryptAndDecrypt.EncryptWithKey(cleanString); Console.WriteLine($"\nEncrpted: String with a single key: {encryptedWithSingleKey}"); Console.WriteLine($"Decrypted: {EncryptAndDecrypt.DecryptWithKey(encryptedWithSingleKey)}"); string encryptedWithWordKey = EncryptAndDecrypt.EncryptWithWord(cleanString); Console.WriteLine($"\nEncrypted: String encrypted with a word: {encryptedWithWordKey}"); Console.WriteLine($"Decrypted: {EncryptAndDecrypt.DecryptWithWord(encryptedWithWordKey)}"); string encryptedWithStringKey = EncryptAndDecrypt.EncryptWithString(cleanString); Console.WriteLine($"\nEncrypted: String encrypted with a word and a string: {encryptedWithStringKey}"); Console.WriteLine($"Decrypted: {EncryptAndDecrypt.DecryptWithString(encryptedWithStringKey)}"); }
public LoginInfoModel GetLoginInfo() { var model = new LoginInfoModel(); var loginCookie = CookiesHelper.GetCookie(WebConfigOperation.CookieName);//是否已存在登录的用户cookie if (loginCookie != null) { //2.获取用户信息 model.UserInfo = new LoginBLL().GetUserInfo(loginCookie.Value); if (model.UserInfo == null) { return(model); } } var ykCookie = CookiesHelper.GetCookie(WebConfigOperation.YkCookieName); if (ykCookie == null) { var yk = EncryptAndDecrypt.Encrypt(DateTime.Now.ToString()); CookiesHelper.AddCookie(WebConfigOperation.YkCookieName, yk); CookiesHelper.SetCookie(WebConfigOperation.YkCookieName, DateTime.Now.AddMonths(1)); model.ykCookie = yk; } else { model.ykCookie = ykCookie.Value.ToString(); } return(model); }
/// <summary> /// 登陆/注册 /// </summary> /// <param name="uid"></param> /// <param name="pwd"></param> /// <returns>用户对象</returns> public UserInfo LoginIn(string uid, string pwd) { //用户密码加密保存 pwd = EncryptAndDecrypt.Encrypt(pwd); var dal = new UserDal(); var tryuser = dal.ExistUser(uid); if (tryuser == null) { //若尝试登录的用户ID不存在,则直接新增该用户 dal.AddUser(new UserInfo { UserID = uid, Pwd = pwd }); } var user = new UserDal().GetUser(uid, pwd); if (user != null) { SetLoginCookie(user); } return(user); }
/// <summary> /// 设置登陆cookie /// </summary> /// <param name="user"></param> public void SetLoginCookie(UserInfo user) { var userInfo = JsonConvert.SerializeObject(new { user.UserID, user.CreateTime }); var cookieStr = EncryptAndDecrypt.Encrypt(userInfo); CookiesHelper.AddCookie(WebConfigOperation.CookieName, cookieStr); CookiesHelper.SetCookie(WebConfigOperation.CookieName, DateTime.Now.AddMonths(1)); }
public async Task SaveToFileAsync(IStorageFile storageFile, string password, PasswordKeeper passwordKeeper) { using (var stream = await storageFile.OpenTransactedWriteAsync()) { using (var mem = new MemoryStream(Encoding.UTF8.GetBytes(passwordKeeper.SaveToJson()))) { EncryptAndDecrypt.Encrypt(mem, password, stream.Stream.AsStreamForWrite()); } await stream.CommitAsync(); } }
public AuthenticateResponse Authenticate(AuthenticateRequest model) { DateTime currentDate = DateTime.UtcNow.AddHours(8); var token = ""; model.Password = EncryptAndDecrypt.ConvertToEncrypt(model.Password); _oUser = new Users() { Username = model.Username, Password = model.Password, LastLoginDate = currentDate }; try { int operationType = Convert.ToInt32(OperationType.Login); using (IDbConnection con = new SqlConnection(AppSettings.ConnectionStrings)) { if (con.State == ConnectionState.Closed) { con.Open(); } var oUsers = con.Query <Users>("sp_Users", _oUser.SetParameters(_oUser, operationType), commandType: CommandType.StoredProcedure).ToList(); if (oUsers != null && oUsers.Count() > 0) { _oUser = oUsers.SingleOrDefault(x => x.Username == model.Username && x.Password == model.Password); // authentication successful so generate jwt token token = GenerateJWTToken(_oUser); } } // return null if user not found if (_oUser == null) { return(null); } ; } catch (Exception) { throw; } return(new AuthenticateResponse(_oUser, token)); }
/// <summary> /// 保存游戏数据 /// </summary> /// <param name="game"></param> public void SetGameData(string key, GameInfo game) { //IIS缓存 CacheExts <GameInfo> .SetValue(key, game, noSlidingExpiration : false); //客户端持久化存储 var json = JsonConvert.SerializeObject(game); var cookieStr = EncryptAndDecrypt.Encrypt(json); CookiesHelper.AddCookie(key, cookieStr); CookiesHelper.SetCookie(key, DateTime.Now.AddMonths(1)); }
public async Task <UserDto> ValidateUsersServices(string email, string password) { try { string encrypted = string.Empty; string encryptkey = _appSettings.EncryptAndDecryptKey; if (!string.IsNullOrEmpty(password)) { encrypted = EncryptAndDecrypt.Encrypt(password, encryptkey); password = encrypted; } User userModel = await _iUsersRepository.ValidateUsersRepository(email, password); UserDto userDto = _mapper.Map <UserDto>(userModel); if (userModel.Role != null && !(string.IsNullOrEmpty(userModel.Role.Role1))) { userDto.Role = userModel.Role.Role1; } // return null if user not found if (userDto == null) { return(null); } // authentication successful so generate jwt token var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_appSettings.Secret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, Convert.ToString(userDto.UserId)), new Claim(ClaimTypes.Role, userDto.Role) }), Expires = DateTime.UtcNow.AddDays(7), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); userDto.Token = tokenHandler.WriteToken(token); // remove password before returning userDto.Password = null; return(userDto); } catch (Exception) { throw; } }
//Convert File to video ready to upload public static void EncryptAndConvert(string filepath) { //fetch file string base64 = ConvertFileToBase64(filepath); //password string for encryption string encryptBase64Pass = RandomData.GetRandomString(12); //encrypt with random string string encryptedBase64 = EncryptAndDecrypt.SimpleEncryptWithPassword(base64, encryptBase64Pass); //convert to video }
public async Task <PasswordKeeper> LoadFromFileAsync(IStorageFile storageFile, string password) { using (var stream = await storageFile.OpenStreamForReadAsync()) { using (var mem = new MemoryStream()) { EncryptAndDecrypt.Decrypt(stream, password, mem); var passwordKeeper = new PasswordKeeper(); mem.Seek(0, SeekOrigin.Begin); passwordKeeper.LoadString(GetText(mem)); return(passwordKeeper); } } }
/// <summary> /// 返回用户信息 /// </summary> /// <param name="userId">用户id</param> /// <param name="userType">用户类型</param> /// <returns></returns> public UserInfo GetUserInfo(string CookieStr) { var userInfo = new UserInfo(); try { var JsonStr = EncryptAndDecrypt.Decrypt(CookieStr); userInfo = JsonConvert.DeserializeObject <UserInfo>(JsonStr); } catch (Exception ex) { return(null); } return(userInfo); }
//public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) //{ // var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>(); // ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); // if (user == null) // { // context.SetError("invalid_grant", "The user name or password is incorrect."); // return; // } // ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, // OAuthDefaults.AuthenticationType); // ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, // CookieAuthenticationDefaults.AuthenticationType); // AuthenticationProperties properties = CreateProperties(user.UserName); // AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); // context.Validated(ticket); // context.Request.Context.Authentication.SignIn(cookiesIdentity); //} public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { try { _login = new MSEADEW_BAL.BAL.Admin.Login(); _dataSet = new DataSet(); _dataSet = _login.GetLoginDetails(context.UserName); string encriptedPassword = EncryptAndDecrypt.Encrypt(context.Password); if (_dataSet.Tables[0].Rows[0][2].ToString() == encriptedPassword) { var Identity = new ClaimsIdentity(context.Options.AuthenticationType); Identity.AddClaim(new Claim("UserId", context.UserName)); var props = new AuthenticationProperties(new Dictionary <string, string> { { "Email", _dataSet.Tables[0].Rows[0][1].ToString() }, { "RoleId", _dataSet.Tables[0].Rows[0][5].ToString() }, { "FirstName", _dataSet.Tables[0].Rows[0][3].ToString() }, { "LastName", _dataSet.Tables[0].Rows[0][4].ToString() }, { "UserId", _dataSet.Tables[0].Rows[0][0].ToString() }, }); AuthenticationTicket ticket = new AuthenticationTicket(Identity, props); context.Validated(Identity); context.Validated(ticket); } else { context.SetError("invalid_grant", "The user name or password is incorrect."); //if (user.Invalid_Attempts_Count < 5 && userInvalidAttempts.IsLocked == false) } } catch (Exception exception) { throw exception; } }
public override void Dispose() { base.Dispose(); DisposeTextBlock(TextBlock1); TextBlock1 = null; DisposeTextBlock(TextBlock2); TextBlock2 = null; DisposeTextBlock(TextBlock3); TextBlock3 = null; DisposeTextBlock(TextBlock4); TextBlock4 = null; DisposeTextBlock(TextBlock5); TextBlock5 = null; DisposeTextBlock(TextBlock6); TextBlock6 = null; DisposeTextBlock(TextBlock7); TextBlock7 = null; DisposeTextBlock(TextBlock8); TextBlock8 = null; Button1.Click -= Button_Click_1; DisposeButton(Button1); Button1 = null; DisposeRadioButton(rdEncrypt); rdEncrypt = null; DisposeRadioButton(rdDecrypt); rdDecrypt = null; securityOptions.ClearValue(StackPanel.OrientationProperty); securityOptions.ClearValue(StackPanel.VerticalAlignmentProperty); securityOptions = null; EncryptAndDecrypt.ClearValue(Grid.BackgroundProperty); EncryptAndDecrypt.ClearValue(Grid.PaddingProperty); EncryptAndDecrypt.Children.Clear(); EncryptAndDecrypt.ColumnDefinitions.Clear(); EncryptAndDecrypt.RowDefinitions.Clear(); EncryptAndDecrypt = null; }
public async Task <int> InsertUserServices(UserDto userDto) { int result = 0; try { string encrypted = string.Empty; string key = _appSettings.EncryptAndDecryptKey; if (!string.IsNullOrEmpty(userDto.Password)) { encrypted = EncryptAndDecrypt.Encrypt(userDto.Password, key); userDto.Password = encrypted; } User user = _mapper.Map <User>(userDto); result = await _iUsersRepository.InsertUserRepository(user); } catch (Exception) { throw; } return(result); }
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext) { if ( actionContext.ActionDescriptor.GetCustomAttributes <SkipLoginAttribute>(false).Count == 0 && actionContext.ActionDescriptor.ControllerDescriptor.GetCustomAttributes <SkipLoginAttribute>(false).Count == 0 ) { var CookieUserName = WebConfigOperation.CookieName; HttpCookie cookie = HttpContext.Current.Request.Cookies[CookieUserName]; if (cookie == null) { var data = new { Code = 2001, Msg = "用户未登陆", Success = false }; actionContext.Response = new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent(JsonConvert.SerializeObject(data), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return; } else { var CookieEnStr = cookie.Value; var JsonStr = EncryptAndDecrypt.Decrypt(CookieEnStr); var userInfo = JsonConvert.DeserializeObject <UserInfo>(JsonStr); if (userInfo == null) { var data = new { Code = 2001, Msg = "用户未登陆", Success = false }; actionContext.Response = new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent(JsonConvert.SerializeObject(data), System.Text.Encoding.GetEncoding("UTF-8"), "application/json") }; return; } } } //验证通过 base.OnActionExecuting(actionContext); }
/// <summary> /// 验证权限(行为过滤器,action执行前会先执行这里) /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { if (!filterContext.ActionDescriptor.IsDefined(typeof(SkipLoginAttribute), false) && !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(SkipLoginAttribute), false)) { HttpCookie cookie = HttpContext.Current.Request.Cookies[WebConfigOperation.CookieName]; if (cookie == null) { //var para = HttpContext.Current.Request.Url.Query; //var url = "/" + filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "/" + filterContext.ActionDescriptor.ActionName + para; //filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", url })); filterContext.Result = new JsonResult { Data = new { Code = 2001, Msg = "请登录后重试" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return; } else { var CookieStr = cookie.Value; var JsonStr = EncryptAndDecrypt.Decrypt(CookieStr); var userInfo = JsonConvert.DeserializeObject <UserInfo>(JsonStr); if (userInfo == null) { //var para = HttpContext.Current.Request.Url.Query; //var url = "/" + filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "/" + filterContext.ActionDescriptor.ActionName + para; //filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Login", action = "Index", url })); filterContext.Result = new JsonResult { Data = new { Code = 2001, Msg = "请登录后重试" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return; } } } }
public static async Task <string> GetTinyUrl(GeoCoordinate gc) { //https://<domain>/default.aspx?V=2&t=SKe/CBsBqQ3mMrXFT4s2UIk6ADFMpCqYljOpw00KNmkvVt8LnTxgiozDf9qIYF0MMSGsfzGnb9P8SEgPKmqo9w==&ut=635651427039540000&d=635651229039990000&l=17.4315747&g=78.3433867 string url = Config.GuardianPortalUrl + @"default.aspx?V=2&"; if (Globals.IsRegisteredUser && !Globals.IsDataNetworkAvailable) { string encryptedParameters = EncryptAndDecrypt.Encrypt(string.Format("p={0}&s={1}&f={2}", Globals.User.CurrentProfileId, Globals.CurrentProfile.SessionToken, Globals.CurrentProfile.IsSOSOn)); string encodeEncryptedParams = EncryptAndDecrypt.EncodeString(encryptedParameters); url += string.Format("t={0}&ut={1}&", encodeEncryptedParams, DateTime.UtcNow.Ticks.ToString()); } url += string.Format("d={0}&l={1}&g={2}", DateTime.Now.Ticks.ToString(), gc.Latitude, gc.Longitude); if (Globals.IsRegisteredUser && Globals.IsDataNetworkAvailable) { url = string.Format("pr={0}&s={1}", Globals.User.CurrentProfileId, Globals.CurrentProfile.SessionToken); } return(await Utility.GetShortUrl(url)); }
public Users AddUser(Users users) { _oUser = new Users(); DateTime aDate = DateTime.Now; var birthDate = users.BirthDate; users.Password = EncryptAndDecrypt.ConvertToEncrypt(users.Password); users.DateCreated = aDate; try { int operationType = Convert.ToInt32(users.UserId == 0 ? OperationType.Insert : OperationType.Update); using (IDbConnection con = new SqlConnection(AppSettings.ConnectionStrings)) { if (con.State == ConnectionState.Closed) { con.Open(); } var oUsers = con.Query <Users>("sp_Users", _oUser.SetParameters(users, operationType), commandType: CommandType.StoredProcedure); if (oUsers != null && oUsers.Count() > 0) { _oUser = oUsers.FirstOrDefault(); } } } catch (Exception ex) { _oUser.Message = ex.Message; } return(_oUser); }
public string SwitchOnSOSviaSMS(string encryptedParms, string utcTicks, string ticks, string lat, string longi) { try { if (!string.IsNullOrEmpty(encryptedParms)) { string decodeEncryptedString = EncryptAndDecrypt.DecodeString(encryptedParms); if (!string.IsNullOrEmpty(decodeEncryptedString)) { string decryptedParameters = EncryptAndDecrypt.Decrypt(decodeEncryptedString); if (!string.IsNullOrEmpty(decryptedParameters)) { string[] parameters = Regex.Split(decryptedParameters, "&"); string ProfileID = Regex.Split(parameters[0], "=")[1]; string Token = Regex.Split(parameters[1], "=")[1]; string SOS = Regex.Split(parameters[2], "=")[1]; new GeoUpdate().SwitchOnSOSviaSMS(ProfileID, Token, SOS, ticks, lat, longi, utcTicks).GetAwaiter().GetResult(); return(ProfileID + "," + Token); } } else { throw new InvalidDataException(); } } return(null); } catch (Exception ex) { throw ex; } }
public void SendSMSFormList(object obj) { try { List <QueueService> listSend = (List <QueueService>)obj; MTQueueReportProvider providerMTR = new MTQueueReportProvider(); MTProvider providerMT = new MTProvider(); QueueServiceProvider qsProvider = new QueueServiceProvider(); EncryptAndDecrypt ead = new EncryptAndDecrypt(); SubTelcoProvider stProvider = new SubTelcoProvider(); RouteTelcoProvider routeProvider = new RouteTelcoProvider(); while (listSend != null && listSend.Count > 0) { //string str_result = "0:NONE_ROUTE"; QueueService model = listSend[0]; //if(model.Receiver.Contains("904993309") || model.Receiver.Contains("988018028")) //{ // str_result = SendSMS(model, false, ead, stProvider, routeProvider); //} string str_result = SendSMS(model, false, ead, stProvider, routeProvider); var results = str_result.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToList(); int result = Convert.ToInt32(results[0]); if (result == 501 || result == 502 || result == 503 || result == 555) { //FAIL MT mt = new MT() { Content = model.Content, DateCreate = model.DateCreate, Dest = model.Dest, Password = model.Password, Priority = model.Priority, ProcessingCode = model.ProcessingCode, Receiver = model.Receiver, Source = model.Source, Status = ConfigType.MT_STATUS_NOT_NOTIFY_ERROR, TimeSend = DateTime.Now, TransID = model.TransID, TransTime = model.TransTime, User = model.User, Result = result, SMSID = model.SMSID, RouteName = results[1] }; providerMT.Insert(mt); } else { //SUCCESS MTQueueReport mt = new MTQueueReport() { Content = model.Content, DateCreate = model.DateCreate, Dest = model.Dest, Password = model.Password, Priority = model.Priority, ProcessingCode = model.ProcessingCode, Receiver = model.Receiver, Source = model.Source, Status = ConfigType.MT_STATUS_NOT_NOTIFY, TimeSend = DateTime.Now, TransID = model.TransID, TransTime = model.TransTime, User = model.User, Result = result, SMSID = model.SMSID, RouteName = results[1] }; providerMTR.Insert(mt); } logger.Info("SendSMS [" + results[1] + "] : " + model.Receiver + " | " + model.Content + " | " + result); listSend.RemoveAt(0); qsProvider.DeleteById(model.Id); Thread.Sleep(10); } _doneEvent.Set(); } catch (Exception ex) { logger.Error(ex); _doneEvent.Set(); Thread.Sleep(1000); //SendSMSFormList(listSend); } }
public string SendSMS(object obj, bool IsBackup, EncryptAndDecrypt ead, SubTelcoProvider stProvider, RouteTelcoProvider routeProvider) { try { QueueService model = (QueueService)obj; string content = model.Content; if (model.ProcessingCode.Equals(ConfigType.QueueService_ProcessingCode_OTP)) { content = ead.Decrypt(content); } var modeltelco = stProvider.getSubTelcoByDest(model.Receiver); if (modeltelco == null) { return(503 + ":NONE_TELCO"); } else { // CHECK TELCO Telco telco = modeltelco.Telco; // GET ROUTE int route = routeProvider.getRoute(telco.Id, IsBackup); int result = 0; string code_Route = ""; if (route == ConfigType.ROUTE_VNET) { result = ConnectVNet.SendSMS(validatePhone(model.Receiver), content); if (result == 0) { code_Route = "VNET"; //string log = string.Format("SendSMS: {0} -> {1} | {2}", model.Receiver, model.Content, code_Route); //logger.Info(log + " - " + model.ProcessingCode); return(result + ":" + code_Route); } else if (!IsBackup) { return(SendSMS(obj, true, ead, stProvider, routeProvider)); } else { return(501 + ":" + code_Route); } } else if (route == ConfigType.ROUTE_VNTP) { result = ConnectVNTP.SendSMS(validatePhone(model.Receiver), content); if (result == 0) { code_Route = "VNTP"; return(result + ":" + code_Route); } else if (!IsBackup) { return(SendSMS(obj, true, ead, stProvider, routeProvider)); } else { return(501 + ":" + code_Route); } } else if (route == ConfigType.ROUTE_SOUTHtelecom) { string str_result = ConnectSOUTHtelecom.SendSMSBrandName(validatePhone(model.Receiver), content, "VietinBank"); if (result == 0) { code_Route = "SOUTHtelecom"; return(result + ":" + code_Route); } else if (!IsBackup) { return(SendSMS(obj, true, ead, stProvider, routeProvider)); } else { return(501 + ":" + code_Route); } } else { code_Route = "NONE_ROUTE"; //string log = string.Format("SendSMS: {0} -> {1} | {2}", model.Receiver, model.Content, code_Route); //logger.Info(log + " - " + model.ProcessingCode); return(502 + ":" + code_Route); } } } catch (Exception ex) { logger.Error(ex); return(555 + ":SendSMS_EX_ERROR"); } }
public string SendMT(string xmlreq) { logger.Info("xmlreq befor:" + xmlreq); xmlreq = Server.HtmlDecode(xmlreq); logger.Info("xmlreq after:" + xmlreq); SMSRS response = new SMSRS(); try { SMSRQ request = ConvertXML.XMLToModel <SMSRQ>(xmlreq); response.HEADER = new HEADERRES() { DEST = request.HEADER.DEST, PWD = request.HEADER.PWD, SOURCE = request.HEADER.SOURCE, TRANSID = request.HEADER.TRANSID, TRANSTIME = request.HEADER.TRANSTIME, USER = request.HEADER.USER, }; if (ValidateUser.CheckUser(request.HEADER.USER, request.HEADER.PWD)) { DateTime transTime = DateTime.ParseExact(request.HEADER.TRANSTIME, "yyyyMMddHHmmss", null); QueueServiceProvider provider = new QueueServiceProvider(); EncryptAndDecrypt ead = new EncryptAndDecrypt(); foreach (var item in request.DATA.SMS) { QueueService model = new QueueService() { Content = item.CONTENT, Dest = request.HEADER.DEST, Password = request.HEADER.PWD, Priority = item.PRIORITY, ProcessingCode = item.PROCESSINGCODE, Receiver = item.RECEIVER, Source = request.HEADER.SOURCE, TransID = request.HEADER.TRANSID, TransTime = transTime, DateCreate = DateTime.Now, User = request.HEADER.USER, SMSID = item.SMSID }; provider.Insert(model); } response.DATA = new DATARES() { ERROR = new ERRORRES() { ERRCODE = ConfigType.RS_SUCCESS, ERRDESC = ConfigType.RS_SUCCESS_MESS } }; } else { response.DATA = new DATARES() { ERROR = new ERRORRES() { ERRCODE = ConfigType.RS_PASSWORD_FAIL, ERRDESC = ConfigType.RS_PASSWORD_FAIL_MESS } }; } } catch (Exception ex) { response.DATA = new DATARES() { ERROR = new ERRORRES() { ERRCODE = ConfigType.RS_SYSTEM_ERROR, ERRDESC = ConfigType.RS_SYSTEM_ERROR_MESS } }; logger.Error(ex); } string responseXML = ConvertXML.ModelToXMLString <SMSRS>(response); logger.Info("Response: " + responseXML); //ResultModel result = new ResultModel() //{ // xmlres = Server.UrlEncode(responseXML), //}; //return result; return(Server.HtmlEncode(responseXML)); }
protected void btnDecrypt_Click(object sender, EventArgs e) { txtToEncrypt.Text = EncryptAndDecrypt.Decrypt(txtToDecrypt.Text, true); }