static void Main(string[] args) { int SERVICE_PORT = 8100; if (1 == args.Length) { Int32.TryParse(args[0], out SERVICE_PORT); } const string SERVICE_NAME = "mathService"; BrokerHelper brokerHelper = new BrokerHelper(); HttpChannel channel = new HttpChannel(SERVICE_PORT); ChannelServices.RegisterChannel(channel, false); RemotingConfiguration.RegisterWellKnownServiceType( typeof(MathServiceImp), SERVICE_NAME, WellKnownObjectMode.Singleton); string serverLocation = string.Format("http://localhost:{0}/{1}", SERVICE_PORT, SERVICE_NAME); Console.WriteLine("Server run at location: {0}", serverLocation); // register itself to Broker brokerHelper.registerServer(SERVICE_NAME, serverLocation); Console.WriteLine("Press a key to exit"); Console.ReadLine(); brokerHelper.unregisterServer(SERVICE_NAME); ChannelServices.UnregisterChannel(channel); }
public AtMostOnce(BrokerHelper brokerHelper, string topico, string consumerGroup, IMessageWriter messageWriter) { _brokerHelper = brokerHelper; _topico = topico; _consumerGroup = consumerGroup; _messageWriter = messageWriter; }
/// <summary> /// kafka辅助类构造方法 /// </summary> /// <param name="sectionName">config中配置节点名称</param> /// <param name="isProducer"></param> public KafkaHelper(string sectionName, bool isProducer = true) { _isProducer = isProducer; _config = KafkaConfig.GetConfig(sectionName); _brokerHelper = new BrokerHelper(_config.Broker); if (isProducer) { _produceHelper = new ProduceHelper(_brokerHelper); } else { _consumerHelper = new ConsumerHelper(_brokerHelper); } }
} // AuthorizeCore protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { if (filterContext.HttpContext.Request.IsAjaxRequest()) { //use code 423 for ajax request to avoid redirection by forms auth module filterContext.Result = new HttpStatusCodeResult(423); return; } // if if (IsAdminPageRedirect) { var workplaceContext = ObjectFactory.GetInstance <IEzbobWorkplaceContext>(); if (workplaceContext.User != null) { var oBrokerHelper = new BrokerHelper(); if (oBrokerHelper.IsBroker(workplaceContext.User.EMail)) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "BrokerHome" }, { "Area", "Broker" } }); return; } // if } // if if (this.areaName.ToString() == filterContext.RouteData.DataTokens["area"].ToString()) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "AdminLogOn" }, { "controller", "Account" }, { "Area", "" }, { "ReturnUrl", filterContext.HttpContext.Request.RawUrl } }); return; } // if } // if base.HandleUnauthorizedRequest(filterContext); } // HandleUnauthorizedRequest
static void Main(string[] args) { HttpChannel channel = new HttpChannel(); const string SERVICE_NAME = "mathService"; ChannelServices.RegisterChannel(channel, false); BrokerHelper brokerHelper = new BrokerHelper(); // connect to Broker string serverLocation = brokerHelper.locateServer(SERVICE_NAME); Console.WriteLine("Try to connect to server from location: " + serverLocation); IMathService clientProxy = (IMathService) Activator.GetObject(typeof(IMathService), serverLocation); Console.WriteLine("Client.main(): Reference acquired"); dynamic total = clientProxy.Sum(99, 1); Console.WriteLine("Calling remote method {0} + {1} = {2}", 99, 1, total); }
public System.Web.Mvc.ActionResult FinishWizardLater() { var blm = new WizardBrokerLeadModel(Session); ms_oLog.Debug("Broker fill wizard later request: {0}", blm); if (blm.BrokerFillsForCustomer) { StringActionResult sar = null; try { sar = this.m_oServiceClient.Instance.BrokerBackFromCustomerWizard(blm.LeadID); } catch (Exception e) { ms_oLog.Warn(e, "Failed to retrieve broker details, falling back to customer's dashboard."); } // try if (sar == null) { ms_oLog.Debug("Failed to retrieve broker details."); } else { BrokerHelper.SetAuth(null, HttpContext); ms_oLog.Debug("Restoring broker identity after filling customer wizard: '{0}'.", sar.Value); BrokerHelper.SetAuth(sar.Value); blm.Unset(); return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker" })); } // if } // if ms_oLog.Debug("Broker fill wizard later request failed, redirecting back to customer wizard."); blm.Unset(); return(RedirectToAction("Index", "Wizard", new { Area = "Customer" })); } // FinishWizardLater
public System.Web.Mvc.ActionResult FillWizard(int?nLeadID, string sLeadEmail, string sContactEmail) { nLeadID = nLeadID ?? 0; ms_oLog.Debug( "Broker fill wizard request for contact email {0} and lead id {1} lead email {2}.", sContactEmail, nLeadID, sLeadEmail ); var oIsAuthResult = IsAuth <BrokerForJsonResult>("Send invitation", sContactEmail); if (oIsAuthResult != null) { Session[Constant.Broker.MessageOnStart] = oIsAuthResult.error; Session[Constant.Broker.MessageOnStartSeverity] = Constant.Severity.Error; return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker", })); } // if if ((nLeadID > 0) && !string.IsNullOrWhiteSpace(sLeadEmail)) { ms_oLog.Warn( "Both lead id ({0}) and lead email ({1}) specified while there can be only one.", nLeadID, sLeadEmail ); Session[Constant.Broker.MessageOnStart] = "Could not process fill all the details request."; Session[Constant.Broker.MessageOnStartSeverity] = Constant.Severity.Error; return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker", })); } // if BrokerLeadDetailsActionResult bld; try { bld = this.m_oServiceClient.Instance.BrokerLeadCanFillWizard( nLeadID.Value, sLeadEmail, sContactEmail, UiOrigin ); } catch (Exception e) { ms_oLog.Alert( e, "Failed to process fill wizard request for contact email {0} and lead id {1} lead email {2}.", sContactEmail, nLeadID, sLeadEmail ); Session[Constant.Broker.MessageOnStart] = "Could not process fill all the details request."; Session[Constant.Broker.MessageOnStartSeverity] = Constant.Severity.Error; return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker", })); } // try if (bld.LeadID < 1) { ms_oLog.Warn( "Validated lead id is {0}. Source lead id is {1} lead email {2}.", bld.LeadID, nLeadID, sLeadEmail ); Session[Constant.Broker.MessageOnStart] = "Could not process fill all the details request."; Session[Constant.Broker.MessageOnStartSeverity] = Constant.Severity.Error; return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker", })); } // if this.m_oHelper.Logoff(User.Identity.Name, HttpContext); if (bld.CustomerID > 0) { BrokerHelper.SetAuth(bld.LeadEmail, HttpContext, "Customer"); } // ReSharper disable ObjectCreationAsStatement // This constructor sets Session data. new WizardBrokerLeadModel( Session, bld.LeadID, bld.LeadEmail, bld.FirstName, bld.LastName, true ); // ReSharper restore ObjectCreationAsStatement ms_oLog.Debug( "Broker fill wizard request for contact email {0} and lead id {1} lead email {2} complete.", sContactEmail, nLeadID, sLeadEmail ); return(RedirectToAction("Index", "Wizard", new { Area = "Customer" })); } // FillWizard
public ConsumidorCommitManual(BrokerHelper brokerHelper, string consumerGroup) : base(brokerHelper, consumerGroup) { }
public ProdutorAssincronoSchema(BrokerHelper brokerHelper, IMessageWriter messageWriter) : base(brokerHelper, messageWriter) { }
public ProdutorSincrono(BrokerHelper brokerHelper, IMessageWriter messageWriter) : base(brokerHelper, messageWriter) { }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var workplaceContext = ObjectFactory.GetInstance <IEzbobWorkplaceContext>(); if (workplaceContext.User != null) { var oBrokerHelper = new BrokerHelper(); if (oBrokerHelper.IsBroker(workplaceContext.User.EMail)) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "BrokerHome" }, { "Area", "Broker" } }); return; } // if } // if var isUnderwriter = workplaceContext.UserRoles.Any( x => x.ToLower() == "crm" || x.ToLower() == "manager" || x.ToLower() == "underwriter" ); if (isUnderwriter) { filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary { { "action", "Index" }, { "controller", "Customers" }, { "Area", "Underwriter" } }); return; } // if var customer = workplaceContext.Customer; if (customer == null) { return; } var routeDictionary = new RouteValueDictionary { { "action", "Index" }, { "Area", "Customer" } }; if (customer.WizardStep.TheLastOne) { if (filterContext.RouteData.Values["controller"].ToString() == "Profile") { return; } routeDictionary.Add("controller", "Profile"); filterContext.Result = new RedirectToRouteResult(routeDictionary); } else { if (filterContext.RouteData.Values["controller"].ToString() == "Wizard") { return; } routeDictionary.Add("controller", "Wizard"); filterContext.Result = new RedirectToRouteResult(routeDictionary); } // if } // OnActionExecuting
public JsonResult CustomerCreatePassword(CreatePasswordModel model) { var customerIp = RemoteIp(); if (!ModelState.IsValid) { log.Debug( "Customer create password attempt from remote IP {0}: model state is invalid, list of errors:", customerIp ); foreach (var val in ModelState.Values) { if (val.Errors.Count < 1) { continue; } foreach (var err in val.Errors) { log.Debug("Model value '{0}' with error '{1}'.", val.Value, err.ErrorMessage); } } // for each value log.Debug("End of list of errors."); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // if var pu = new PasswordUtility(CurrentValues.Instance.PasswordHashCycleCount); log.Debug( "Customer create password attempt from remote IP {0} received: {1}...", customerIp, pu.Generate(model.UserName, model.Password) ); CustomerOriginEnum origin = UiCustomerOrigin.Get().GetOrigin(); SetPasswordActionResult spar; try { spar = this.serviceClient.Instance.SetCustomerPasswordByToken( model.Token, origin, new DasKennwort(model.Password), new DasKennwort(model.signupPass2), model.IsBrokerLead, customerIp ); } catch (Exception e) { log.Warn(e, "Failed to set new password for user '{0}'.", model.UserName); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // try if (!string.IsNullOrWhiteSpace(spar.ErrorMsg)) { log.Warn( "Failed to set a password for user name {0}, error message returned: {1}.", model.UserName, spar.ErrorMsg ); return(Json(new { success = false, errorMessage = spar.ErrorMsg, }, JsonRequestBehavior.AllowGet)); } // if if (spar.UserID <= 0) { log.Warn("Failed to set a password (returned user id is 0) for user name {0}.", model.UserName); return(Json(new { success = false, errorMessage = "Failed to set a password.", }, JsonRequestBehavior.AllowGet)); } // if if (spar.IsBroker) { BrokerHelper.SetAuth(spar.Email); return(Json(new { success = true, errorMessage = string.Empty, broker = true, })); } // if is broker if (spar.SessionID != 0) { Session["UserSessionId"] = spar.SessionID; } if (string.IsNullOrWhiteSpace(spar.ErrorMsg)) { model.SetCookie(LogOnModel.Roles.Customer); this.context.SetSessionOrigin(origin); } // if return(Json(new { success = string.IsNullOrWhiteSpace(spar.ErrorMsg), errorMessage = spar.ErrorMsg, broker = false, }, JsonRequestBehavior.AllowGet)); } // CustomerCreatePassword
public ProdutorFireAndForget(BrokerHelper brokerHelper, IMessageWriter messageWriter) : base(brokerHelper, messageWriter) { }
protected ConsumidorAbstrato(BrokerHelper brokerHelper, string consumerGroup) { _brokerHelper = brokerHelper; ConsumerGroup = consumerGroup; }
public ConsumidorCommitAutomatico(BrokerHelper brokerHelper, string consumerGroup) : base(brokerHelper, consumerGroup) { }
protected ProdutorAbstrato(BrokerHelper brokerHelper, IMessageWriter messageWriter) { _brokerHelper = brokerHelper; _messageWriter = messageWriter; }
public CriacaoTopico(BrokerHelper brokerHelper) : base(brokerHelper, new Infra.NullMessageWriter()) { }
public ConsumidorAPartirDeOffset(BrokerHelper brokerHelper, string consumerGroup) : base(brokerHelper, consumerGroup) { }
public JsonResult Signup(BrokerSignupModel model) { string sReferredBy = ""; if (Request.Cookies.AllKeys.Contains(Constant.SourceRef)) { var oCookie = Request.Cookies[Constant.SourceRef]; if (oCookie != null) { sReferredBy = oCookie.Value; } } // if var uio = UiCustomerOrigin.Get(); ms_oLog.Debug( "Broker sign up request:" + "\n\tFirm name: {0}" + "\n\tFirm reg #: {1}" + "\n\tContact person name: {2}" + "\n\tContact person email: {3}" + "\n\tContact person mobile: {4}" + "\n\tMobile code: {5}" + "\n\tContact person other phone: {6}" + "\n\tFirm web site URL: {7}" + "\n\tCaptcha enabled: {8}" + "\n\tTerms ID: {9}" + "\n\tReferred by (source ref): {10}" + "\n\tFCARegistered: {11}" + "\n\tLicense Number: {12}" + "\n\tUI origin: {13}", model.FirmName, model.FirmRegNum, model.ContactName, model.ContactEmail, model.ContactMobile, model.MobileCode, model.ContactOtherPhone, model.FirmWebSite, model.IsCaptchaEnabled == 0 ? "no" : "yes", model.TermsID, sReferredBy, model.FCARegistered, model.LicenseNumber, uio.CustomerOriginID ); if (!ModelState.IsValid) { return(new BrokerForJsonResult(string.Join( "; ", ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage) ))); } // if if (User.Identity.IsAuthenticated) { ms_oLog.Warn( "Sign up request with contact email {0}: already authorized as {1}.", model.ContactEmail, User.Identity.Name ); return(new BrokerForJsonResult("You are already logged in.")); } // if BrokerPropertiesActionResult bp; try { bp = this.m_oServiceClient.Instance.BrokerSignup( model.FirmName, model.FirmRegNum, model.ContactName, model.ContactEmail, model.ContactMobile, model.MobileCode, model.ContactOtherPhone, new DasKennwort(model.Password), new DasKennwort(model.Password2), model.FirmWebSite, model.IsCaptchaEnabled != 0, model.TermsID, sReferredBy, model.FCARegistered, model.LicenseNumber, uio.CustomerOriginID ); if (!string.IsNullOrEmpty(bp.Properties.ErrorMsg)) { ms_oLog.Warn("Failed to sign up as a broker. {0}", bp.Properties.ErrorMsg); return(new BrokerForJsonResult(bp.Properties.ErrorMsg)); } // if } catch (Exception e) { ms_oLog.Alert(e, "Failed to sign up as a broker."); return(new BrokerForJsonResult("Registration failed. Please contact customer care.")); } // try BrokerHelper.SetAuth(model.ContactEmail); ms_oLog.Debug("Broker sign up succeeded for: {0}", model.ContactEmail); return(new PropertiesBrokerForJsonResult(oProperties: bp.Properties) { antiforgery_token = AntiForgery.GetHtml().ToString() }); } // Signup