public HttpResponseMessage Post(AccountRegistrationService.RegisterNewAccountModel registerNewAccountModel) { HttpResponseMessage httpResponse = new HttpResponseMessage(); if (ModelState.IsValid) { //AccountRegistrationService.AccountRegistrationServiceClient accountRegistrationClient = new AccountRegistrationService.AccountRegistrationServiceClient(); //var registrationServiceResponse = accountRegistrationClient.RegisterAccount(registerNewAccountModel); //accountRegistrationClient.Close(); var accountRegistrationServiceClient = new AccountRegistrationService.AccountRegistrationServiceClient(); try { accountRegistrationServiceClient.Open(); var registrationServiceResponse = accountRegistrationServiceClient.RegisterAccount(registerNewAccountModel, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountRegistrationServiceClient); if (registrationServiceResponse.isSuccess) { httpResponse = Request.CreateResponse(HttpStatusCode.Created, registrationServiceResponse); } else { httpResponse = Request.CreateResponse(HttpStatusCode.OK, registrationServiceResponse); } } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountRegistrationServiceClient, exceptionMessage, currentMethodString); // Upate the response object var exceptionResponse = new Sahara.Api.Accounts.Registration.AccountRegistrationService.DataAccessResponseType(); exceptionResponse.isSuccess = false; exceptionResponse.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; exceptionResponse.ErrorMessages[0] = exceptionMessage; #endregion httpResponse = Request.CreateResponse(HttpStatusCode.OK, exceptionResponse); } } else { httpResponse = Request.CreateErrorResponse(HttpStatusCode.OK, ModelState); } return(httpResponse); }
public JsonNetResult RefundPayment(string accountId, string chargeId, decimal refundAmount) { DataAccessResponseType response = null; if (string.IsNullOrEmpty(accountId)) { response = new DataAccessResponseType { isSuccess = false, ErrorMessage = "Cannot apply refunds on closed/null accounts." }; } else { var user = AuthenticationCookieManager.GetAuthenticationCookie(); if (response == null) { var accountBillingServiceClient = new AccountBillingService.AccountBillingServiceClient(); try { accountBillingServiceClient.Open(); response = accountBillingServiceClient.RefundPayment( accountId, chargeId, refundAmount, AuthenticationCookieManager.GetAuthenticationCookie().Id, PlatformAdminSite.AccountBillingService.RequesterType.PlatformUser, Common.SharedClientKey );//, //user.Id, //PlatformAdminSite.AccountManagementService.RequesterType.PlatformUser).ToList(); //Close the connection WCFManager.CloseConnection(accountBillingServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountBillingServiceClient, exceptionMessage, currentMethodString); #endregion } } } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public ActionResult Forgot(PasswordClaim password) { if (ModelState.IsValid) { var claimResponse = new PlatformManagementService.DataAccessResponseType(); var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient(); try { //Attempt to send lost password claim platformManagementServiceClient.Open(); claimResponse = platformManagementServiceClient.ClaimLostPassword(password.Email, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object claimResponse.isSuccess = false; claimResponse.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //claimresponse.ErrorMessages[0] = exceptionMessage; #endregion } if (claimResponse.isSuccess) { return(RedirectToAction("sent", "password")); } else { //ModelState.AddModelError("", "Invalid username or password."); //foreach (string error in authResponse.ErrorMessages) //{ ModelState.AddModelError("CoreServiceError", claimResponse.ErrorMessage); //} return(View(password)); } } else { return(View(password)); } }
public JsonNetResult SubscribeFromSub(string accountId, string planName, string frequencyMonths, string cardName, string cardNumber, string cvc, string expirationMonth, string expirationYear) { var response = new AccountManagementService.DataAccessResponseType(); var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { //Get the ip address and call origin var ipAddress = Request.UserHostAddress; var origin = "Web"; accountManagementServiceClient.Open(); response = accountManagementServiceClient.CreateSubscripton( accountId, planName, frequencyMonths, cardName, cardNumber, cvc, expirationMonth, expirationYear, null, //<-- Exempt AccountManagementService.RequesterType.Exempt, //<-- Exempt ipAddress, origin, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public ActionResult Index(CreateUserFromInvitationModel createUser) { if (ModelState.IsValid) { var response = new AccountManagementService.DataAccessResponseType(); var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { accountManagementServiceClient.Open(); response = accountManagementServiceClient.RegisterInvitedAccountUser(createUser.AccountNameKey, createUser.Email, createUser.FirstName, createUser.LastName, createUser.Password, createUser.Role, createUser.Owner, createUser.InvitationCode, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } if (response.isSuccess) { return(RedirectToAction("Success", "Invitations")); } else { foreach (string error in response.ErrorMessages) { ModelState.AddModelError("Errors", error); } return(View(createUser)); } } else { return(View(createUser)); } }
public AccountNameValidationResponse AccountNameValidation(AccountNameValidator accountNameValidator) { string accountName = accountNameValidator.AccountName; var response = new AccountNameValidationResponse(); var accountRegistrationServiceClient = new AccountRegistrationService.AccountRegistrationServiceClient(); try { accountRegistrationServiceClient.Open(); var validationResponse = accountRegistrationServiceClient.ValidateAccountName(accountName); if (validationResponse.isValid) { response.valid = true; response.message = accountName + " is available!"; } else { response.valid = false; response.message = validationResponse.validationMessage; } //CommonMethods.MethodsClient commonMethodsClient = new CommonMethods.MethodsClient(); response.subdomain = accountRegistrationServiceClient.ConvertToAccountNameKey(accountName); //Close the connection WCFManager.CloseConnection(accountRegistrationServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountRegistrationServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.valid = false; response.message = WCFManager.UserFriendlyExceptionMessage; #endregion } return(response); }
public ActionResult Reset(string passwordClaimKey) { //Get the subdomain (if exists) for the site string accountNameKey = Common.GetSubDomain(Request.Url); if (String.IsNullOrEmpty(accountNameKey)) { return(Content("No account specified.")); } var email = String.Empty; var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { //Get the password claim email from CoreServices accountManagementServiceClient.Open(); email = accountManagementServiceClient.GetLostPasswordClaim(accountNameKey, passwordClaimKey, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); #endregion } if (String.IsNullOrEmpty(email)) { return(Content("Password claim key does not exist.")); } else { var resetPassword = new ResetPassword { AccountNameKey = accountNameKey, Email = email, PasswordClaimKey = passwordClaimKey }; return(View(resetPassword)); } }
public JsonNetResult UploadPhoto() // HttpPostedFileBase file) // Object file) { var length = Request.ContentLength; var bytes = new byte[length]; Request.InputStream.Read(bytes, 0, length); var response = new DataAccessResponseType(); var platformManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); JsonNetResult jsonNetResult = new JsonNetResult(); try { platformManagementServiceClient.Open(); var user = AuthenticationCookieManager.GetAuthenticationCookie(); response = platformManagementServiceClient.UpdateAccountUserProfilePhoto( user.AccountID.ToString(), user.Id, bytes, user.Id, AccountAdminSite.AccountManagementService.RequesterType.Exempt, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public JsonNetResult MarkNotificationRead(string notificationType, string notificationId) { var accountCommunicationServiceClient = new AccountCommunicationService.AccountCommunicationServiceClient(); try { accountCommunicationServiceClient.Open(); //Convert notification type to Enum NotificationType _convertedNotificationType = (NotificationType)Enum.Parse(typeof(NotificationType), notificationType); var response = accountCommunicationServiceClient.UpdateNotificationStatus( _convertedNotificationType, NotificationStatus.Read, "Unread", AuthenticationCookieManager.GetAuthenticationCookie().Id, notificationId, Common.SharedClientKey ); //Close the connection WCFManager.CloseConnection(accountCommunicationServiceClient); JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountCommunicationServiceClient, exceptionMessage, currentMethodString); #endregion JsonNetResult jsonNetErrorResult = new JsonNetResult(); jsonNetErrorResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetErrorResult.Data = new DataAccessResponseType { isSuccess = false, ErrorMessage = WCFManager.UserFriendlyExceptionMessage }; return(jsonNetErrorResult); } }
public JsonNetResult TradeCredits(string toAccountId, int creditsAmount, string description) { var accountUser = AuthenticationCookieManager.GetAuthenticationCookie(); var response = new AccountAdminSite.AccountCommerceService.DataAccessResponseType(); var accountCommerceServiceClient = new AccountCommerceService.AccountCommerceServiceClient(); try { //Get the ip address and call origin var ipAddress = Request.UserHostAddress; var origin = "Web"; accountCommerceServiceClient.Open(); response = accountCommerceServiceClient.TradeCredits( accountUser.AccountID.ToString(), toAccountId, creditsAmount, description, accountUser.Id, AccountAdminSite.AccountCommerceService.RequesterType.AccountUser, ipAddress, origin, Common.SharedClientKey ); //Close the connection WCFManager.CloseConnection(accountCommerceServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountCommerceServiceClient, exceptionMessage, currentMethodString); #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public ActionResult Index(string invitationCode) { if (invitationCode == null) { return(Content("ERROR: No verification code present.")); } else { var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient(); try { platformManagementServiceClient.Open(); var invitedUser = platformManagementServiceClient.GetPlatformUserInvitation(invitationCode, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformManagementServiceClient); if (invitedUser == null) { return(Content("Not a valid invitation key, or key has expired")); } var creatUser = new CreateUserFromInvitationModel(); creatUser.InvitationCode = invitedUser.InvitationKey; creatUser.Email = invitedUser.Email; creatUser.FirstName = invitedUser.FirstName; creatUser.LastName = invitedUser.LastName; creatUser.Role = invitedUser.Role; return(View(creatUser)); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString); #endregion return(Content("ERROR: " + WCFManager.UserFriendlyExceptionMessage)); } } }
public JsonNetResult UpdateName(string firstName, string lastName) { var response = new DataAccessResponseType(); var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { accountManagementServiceClient.Open(); var user = AuthenticationCookieManager.GetAuthenticationCookie(); response = accountManagementServiceClient.UpdateAccountUserFullName( user.AccountID.ToString(), user.Id, firstName, lastName, user.Id, RequesterType.Exempt, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public JsonNetResult GetOtherAccounts() { List <UserAccount> response = null; try { var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { accountManagementServiceClient.Open(); response = accountManagementServiceClient.GetAllAccountsForEmail(AuthenticationCookieManager.GetAuthenticationCookie().Email, Common.SharedClientKey).ToList(); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); } catch { // Use cookies instead JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = AuthenticationCookieManager.GetAuthenticationCookie(); return(jsonNetResult); } }
public JsonNetResult RemoveSalesLeadLabel(int index) { var response = new ApplicationLeadsService.DataAccessResponseType(); var applicationLeadsServiceClient = new ApplicationLeadsService.ApplicationLeadsServiceClient(); var authCookie = AuthenticationCookieManager.GetAuthenticationCookie(); var accountNameKey = authCookie.AccountNameKey; var userId = authCookie.Id.ToString(); var accountSettings = AccountSettings.GetAccountSettings_Internal(accountNameKey); var label = accountSettings.SalesSettings.LeadLabels[index]; try { applicationLeadsServiceClient.Open(); response = applicationLeadsServiceClient.RemoveLabel(accountNameKey, label, userId, ApplicationLeadsService.RequesterType.AccountUser, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(applicationLeadsServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(applicationLeadsServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public static AccountsSnapshot GetAccountsSnapshot() { var accountsSnapshotLoclCacheKey = "accountsSnapshotcachekey"; var accountsSnapshot = new AccountsSnapshot(); if (System.Web.HttpRuntime.Cache.Get(accountsSnapshotLoclCacheKey) == null) { //if local cache is empty var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient(); try { platformManagementServiceClient.Open(); accountsSnapshot = platformManagementServiceClient.GetAccountsShapshot(Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformManagementServiceClient); //Store snapshot in local cache for 5 seconds (for charting components to use): System.Web.HttpRuntime.Cache.Insert(accountsSnapshotLoclCacheKey, accountsSnapshot, null, DateTime.Now.AddSeconds(5), Cache.NoSlidingExpiration, CacheItemPriority.Default, null); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString); #endregion } } else { // Get snapshot from cache accountsSnapshot = (AccountsSnapshot)System.Web.HttpRuntime.Cache.Get(accountsSnapshotLoclCacheKey); } return(accountsSnapshot); }
public JsonNetResult GetNotificationsByType(string notificationType, string notificationStatus) { var userId = AuthenticationCookieManager.GetAuthenticationCookie().Id; var accountCommunicationServiceClient = new AccountCommunicationService.AccountCommunicationServiceClient(); try { accountCommunicationServiceClient.Open(); //Convert notification type to Enum NotificationType _convertedNotificationType = (NotificationType)Enum.Parse(typeof(NotificationType), notificationType); //Convert notification status to Enum NotificationStatus _convertedNotificationStatus = (NotificationStatus)Enum.Parse(typeof(NotificationStatus), notificationStatus); var userNotifications = accountCommunicationServiceClient.GetAccountUserNotificationsByType(_convertedNotificationType, _convertedNotificationStatus, userId, Common.SharedClientKey).ToList(); //Close the connection WCFManager.CloseConnection(accountCommunicationServiceClient); JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = userNotifications; return(jsonNetResult); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountCommunicationServiceClient, exceptionMessage, currentMethodString); #endregion JsonNetResult jsonNetErrorResult = new JsonNetResult(); jsonNetErrorResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetErrorResult.Data = WCFManager.UserFriendlyExceptionMessage; return(jsonNetErrorResult); } }
public JsonNetResult UpdatePlanVisibility(string paymentPlanName, bool isVisible) { var response = new AccountPaymentPlanService.DataAccessResponseType(); var accountPaymentPlanServiceClient = new AccountPaymentPlanService.AccountPaymentPlanServiceClient(); try { accountPaymentPlanServiceClient.Open(); response = accountPaymentPlanServiceClient.UpdatePlanVisibility( paymentPlanName, isVisible, AuthenticationCookieManager.GetAuthenticationCookie().Id, PlatformAdminSite.AccountPaymentPlanService.RequesterType.PlatformUser, Common.SharedClientKey ); //Close the connection WCFManager.CloseConnection(accountPaymentPlanServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountPaymentPlanServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public JsonNetResult GenerateApiKey(string name, string description) { string response = null; var applicationApiKeysServiceClient = new ApplicationApiKeysService.ApplicationApiKeysServiceClient(); try { var authCookie = AuthenticationCookieManager.GetAuthenticationCookie(); var requesterId = authCookie.Id; var accountNameKey = authCookie.AccountNameKey; applicationApiKeysServiceClient.Open(); response = applicationApiKeysServiceClient.GenerateApiKey(accountNameKey, name, description, requesterId, ApplicationApiKeysService.RequesterType.AccountUser, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(applicationApiKeysServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(applicationApiKeysServiceClient, exceptionMessage, currentMethodString); // Upate the response object //response.isSuccess = false; //response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = response; return(jsonNetResult); }
public ActionResult Reset(string passwordClaimKey) { var email = string.Empty; var platformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient(); try { //Get the password claim email from CoreServices platformManagementServiceClient.Open(); email = platformManagementServiceClient.GetLostPasswordClaim(passwordClaimKey, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformManagementServiceClient, exceptionMessage, currentMethodString); #endregion } if (String.IsNullOrEmpty(email)) { return(Content("Password claim key does not exist.")); } else { var resetPassword = new ResetPassword { Email = email, PasswordClaimKey = passwordClaimKey }; return(View(resetPassword)); } }
public String PerformanceTest_WCFCache_GetAccountsListNoncached() { var watch = Stopwatch.StartNew(); var infrastructureTestsServiceClient = new InfrastructureTestsService.InfrastructureTestsServiceClient(); infrastructureTestsServiceClient.Open(); var result = infrastructureTestsServiceClient.PerformanceTest_InternalCaching_GetAccounts(false, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(infrastructureTestsServiceClient); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; return("Account List (WCF: No Cache):" + elapsedMs + "ms"); }
public String PerformanceTest_GetPlansWCF() { var watch = Stopwatch.StartNew(); List <AccountPaymentPlanService.PaymentPlan> paymentPlans = null; var accountPaymentPlanServiceClient = new AccountPaymentPlanService.AccountPaymentPlanServiceClient(); accountPaymentPlanServiceClient.Open(); paymentPlans = accountPaymentPlanServiceClient.GetPaymentPlans(false, true).ToList(); //Close the connection WCFManager.CloseConnection(accountPaymentPlanServiceClient); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; return("GetPlans (WCF): " + elapsedMs + "ms"); }
public JsonNetResult GetReport(int sinceHoursAgo) { #region Get data from WCF var PlatformManagementServiceClient = new PlatformManagementService.PlatformManagementServiceClient(); var billingReport = new BillingReport(); try { PlatformManagementServiceClient.Open(); billingReport = PlatformManagementServiceClient.GetBillingReport(sinceHoursAgo, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(PlatformManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(PlatformManagementServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = billingReport; return(jsonNetResult); }
public ValidationResponse PostLastNameValidation(LastNameValidator nameValidator) { var response = new ValidationResponse(); var accountRegistrationServiceClient = new AccountRegistrationService.AccountRegistrationServiceClient(); try { accountRegistrationServiceClient.Open(); var validationResponse = accountRegistrationServiceClient.ValidateLastName(nameValidator.LastName); //Close the connection WCFManager.CloseConnection(accountRegistrationServiceClient); response.valid = validationResponse.isValid; response.message = validationResponse.validationMessage; } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountRegistrationServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.valid = false; response.message = WCFManager.UserFriendlyExceptionMessage; #endregion } return(response); }
public JsonNetResult GetBalanceTransactionsForSource(string sourceId) { #region Get data from WCF var platformBillingServiceClient = new PlatformBillingService.PlatformBillingServiceClient(); var sourceBalanceTransactions = new SourceBalanceTransactions(); try { platformBillingServiceClient.Open(); sourceBalanceTransactions = platformBillingServiceClient.GetBalanceTransactionsForSource(sourceId, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(platformBillingServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(platformBillingServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = sourceBalanceTransactions; return(jsonNetResult); }
public ActionResult Index() { //Check if Platform exists var platformInitializationServiceClient = new PlatformInitializationService.PlatformInitializationServiceClient(); platformInitializationServiceClient.Open(); var isInitialized = platformInitializationServiceClient.IsPlatformInitialized(); //Close the connection WCFManager.CloseConnection(platformInitializationServiceClient); CoreServices.Platform.Initialized = isInitialized; if (!isInitialized) { return(View(new RegisterPlatformUserModel())); } else { return(RedirectToAction("PlatformExists")); } }
public ActionResult RefreshPlatformSettings() { #region Communicate with CoreServices and get updated subset of static settings for this client to work with var platformSettingsServiceClient = new PlatformSettingsService.PlatformSettingsServiceClient(); // <-- We only use PlatformSettingsServiceClient in EnviornmentSettings because it is ONLY used at application startup: try { platformSettingsServiceClient.Open(); var platformSettingsResult = platformSettingsServiceClient.GetCorePlatformSettings(Common.SharedClientKey); CoreServices.PlatformSettings = platformSettingsResult; //Close the connections WCFManager.CloseConnection(platformSettingsServiceClient); return(Content("<b style='color:darkgreen'>Settings refreshed!</b>")); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connections & manage the exceptions WCFManager.CloseConnection(platformSettingsServiceClient, exceptionMessage, currentMethodString); #endregion platformSettingsServiceClient.Close(); return(Content("<b style='color:red'>" + e.ToString() + "</b>")); } #endregion }
public static DataAccessResponseType UpdateAccountSettings_Internal(string accountNameKey, AccountSettingsDocumentModel accountSettingsDocumentModel) { var response = new AccountManagementService.DataAccessResponseType(); var accountManagementServiceClient = new AccountManagementService.AccountManagementServiceClient(); try { accountManagementServiceClient.Open(); response = accountManagementServiceClient.UpdateAccountSettings(accountNameKey, accountSettingsDocumentModel, AuthenticationCookieManager.GetAuthenticationCookie().Id, AccountAdminSite.AccountManagementService.RequesterType.AccountUser, Common.SharedClientKey); //Close the connection WCFManager.CloseConnection(accountManagementServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(accountManagementServiceClient, exceptionMessage, currentMethodString); // Upate the response object response.isSuccess = false; response.ErrorMessage = WCFManager.UserFriendlyExceptionMessage; //response.ErrorMessages[0] = exceptionMessage; #endregion } return(response); }
// GET: /Dashboard/ public ActionResult Index() { //Check if Platform exists //TO DO: Move this to a static variable that checks on startup var platformInitializationServiceClient = new PlatformInitializationService.PlatformInitializationServiceClient(); platformInitializationServiceClient.Open(); var isInitialized = platformInitializationServiceClient.IsPlatformInitialized(); //Close the connection WCFManager.CloseConnection(platformInitializationServiceClient); if (!isInitialized) { //If platform does not exist then rederect to Platform Initialization Controller return(RedirectToAction("Index", "Initialization")); } return(View(GetAccountsSnapshot())); }
public JsonNetResult Subsubcategory(string categoryNameKey, string subcategoryNameKey, string subsubcategoryNameKey, bool includeHidden = false, bool includeItems = false) { ExecutionType executionType = ExecutionType.local; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //Get the subdomain (if exists) for the api call string accountNameKey = Common.GetSubDomain(Request.Url); if (String.IsNullOrEmpty(accountNameKey)) { return(new JsonNetResult { Data = "Not found" }); //return Request.CreateResponse(HttpStatusCode.NotFound); } SubsubcategoryModel subsubcategory = null; SubsubcategoryDetailsJson subsubcategoryDetailsObjectJson = null; string localCacheKey = accountNameKey + ":subsubcategory:" + categoryNameKey + ":" + subcategoryNameKey + ":" + subsubcategoryNameKey + ":includeHidden:" + includeHidden + "includeProducts:" + includeItems; #region (Plan A) Get json from local cache try { subsubcategoryDetailsObjectJson = (SubsubcategoryDetailsJson)HttpRuntime.Cache[localCacheKey]; } catch (Exception e) { var error = e.Message; //TODO: Log: error message for local cache call } #endregion if (subsubcategoryDetailsObjectJson == null) { #region (Plan B) Get Public json from second layer of Redis Cache IDatabase cache = CoreServices.RedisConnectionMultiplexers.RedisMultiplexer.GetDatabase(); string pathAndQuery = Common.GetApiPathAndQuery(Request.Url); string hashApiKey = accountNameKey + ":apicache"; string hashApiField = pathAndQuery; try { var redisApiValue = cache.HashGet(hashApiKey, hashApiField); if (redisApiValue.HasValue) { subsubcategoryDetailsObjectJson = JsonConvert.DeserializeObject <SubsubcategoryDetailsJson>(redisApiValue); executionType = ExecutionType.redis_secondary; } } catch { } #endregion if (subsubcategoryDetailsObjectJson == null) { #region (Plan C) Get category data from Redis Cache and rebuild try { //IDatabase cache = CoreServices.RedisConnectionMultiplexers.RedisMultiplexer.GetDatabase(); string hashMainKey = accountNameKey + ":categories"; string hashMainField = categoryNameKey + "/" + subcategoryNameKey + "/" + subsubcategoryNameKey + ":public"; if (includeHidden == true) { hashMainField = categoryNameKey + "/" + subcategoryNameKey + "/" + subsubcategoryNameKey + ":private"; } try { var redisValue = cache.HashGet(hashMainKey, hashMainField); if (redisValue.HasValue) { subsubcategory = JsonConvert.DeserializeObject <ApplicationCategorizationService.SubsubcategoryModel>(redisValue); executionType = ExecutionType.redis_main; } } catch { } } catch (Exception e) { var error = e.Message; //TODO: Log: error message for Redis call } #endregion if (subsubcategory == null) { #region (Plan D) Get data from WCF var applicationCategorizationServiceClient = new ApplicationCategorizationService.ApplicationCategorizationServiceClient(); try { applicationCategorizationServiceClient.Open(); subsubcategory = applicationCategorizationServiceClient.GetSubsubcategoryByNames(accountNameKey, categoryNameKey, subcategoryNameKey, subsubcategoryNameKey, includeHidden, Common.SharedClientKey); executionType = ExecutionType.wcf; WCFManager.CloseConnection(applicationCategorizationServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(applicationCategorizationServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion } } #region Transform into json object, add images & cache locally or locally and radisAPI layer if (subsubcategoryDetailsObjectJson != null) { //Just cache locally (we got json from the api redis layer) HttpRuntime.Cache.Insert(localCacheKey, subsubcategoryDetailsObjectJson, null, DateTime.Now.AddMinutes(Common.CategorizationCacheTimeInMinutes), TimeSpan.Zero); } else if (subsubcategory != null) { //Transform categories into JSON and cache BOTH locally AND into redis subsubcategoryDetailsObjectJson = Transforms.Json.CategorizationTransforms.Subsubcategory(accountNameKey, subsubcategory, includeItems, includeHidden); HttpRuntime.Cache.Insert(localCacheKey, subsubcategoryDetailsObjectJson, null, DateTime.Now.AddMinutes(Common.CategorizationCacheTimeInMinutes), TimeSpan.Zero); try { cache.HashSet(hashApiKey, hashApiField, JsonConvert.SerializeObject(subsubcategoryDetailsObjectJson), When.Always, CommandFlags.FireAndForget); } catch { } } #endregion } if (subsubcategoryDetailsObjectJson == null) { //return empty return(new JsonNetResult()); } //Add execution data stopWatch.Stop(); subsubcategoryDetailsObjectJson.executionType = executionType.ToString(); subsubcategoryDetailsObjectJson.executionTime = stopWatch.Elapsed.TotalMilliseconds + "ms"; JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented; jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime jsonNetResult.Data = subsubcategoryDetailsObjectJson; return(jsonNetResult); }
public static List <PropertyModel> GetProperties(string accountNameKey, PropertyListType propertyListType, out ExecutionType executionTypeResult) { List <PropertyModel> properties = null; executionTypeResult = ExecutionType.redis_main; #region (Plan A) Get data from Redis Cache try { IDatabase cache = CoreServices.RedisConnectionMultiplexers.RedisMultiplexer.GetDatabase(); string hashMainKey = accountNameKey + ":properties"; string hashMainField = propertyListType.ToString().ToLower(); try { var redisValue = cache.HashGet(hashMainKey, hashMainField); if (redisValue.HasValue) { properties = JsonConvert.DeserializeObject <List <PropertyModel> >(redisValue); executionTypeResult = ExecutionType.redis_main; } } catch { } } catch (Exception e) { var error = e.Message; //TODO: Log: error message for Redis call } #endregion if (properties == null) { #region (Plan D) Get data from WCF var applicationPropertiesServiceClient = new ApplicationPropertiesService.ApplicationPropertiesServiceClient(); try { applicationPropertiesServiceClient.Open(); properties = applicationPropertiesServiceClient.GetProperties(accountNameKey, propertyListType, Common.SharedClientKey).ToList(); executionTypeResult = ExecutionType.wcf; WCFManager.CloseConnection(applicationPropertiesServiceClient); } catch (Exception e) { #region Manage Exception string exceptionMessage = e.Message.ToString(); var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; // Abort the connection & manage the exception WCFManager.CloseConnection(applicationPropertiesServiceClient, exceptionMessage, currentMethodString); #endregion } #endregion } return(properties); }