public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var fieldToken = (FormFieldEntityToken)entityToken; var definition = DynamicFormsFacade.GetFormByName(fieldToken.FormName); var field = definition.Model.Fields.Get(fieldToken.FieldName); definition.Model.Fields.Remove(field); if (RenderingLayoutFacade.HasCustomRenderingLayout(fieldToken.FormName)) { var layout = RenderingLayoutFacade.GetRenderingLayout(fieldToken.FormName); var fieldElement = layout.Body.Descendants().SingleOrDefault(el => el.Name == Namespaces.Xhtml + "p" && el.Value.Trim() == "%" + field.Name + "%"); if (fieldElement != null) { fieldElement.Remove(); } RenderingLayoutFacade.SaveRenderingLayout(fieldToken.FormName, layout); } DynamicFormsFacade.SaveForm(definition); LocalizationsFacade.DeleteNamespace(Localization.GenerateKey(fieldToken.FormName, fieldToken.FieldName)); new ParentTreeRefresher(flowControllerServicesContainer).PostRefreshMessages(entityToken); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { string functionNamePrefix = ""; if (entityToken.Id.IndexOf('.') > -1) { functionNamePrefix = entityToken.Id.Substring(entityToken.Id.IndexOf('.') + 1); } bool widgets = entityToken.Id.ToLower().Contains("widget"); string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string url = UrlUtils.ResolveAdminUrl(string.Format("content/views/functiondoc/FunctionDocumentation.aspx?functionPrefix={0}&widgets={1}", functionNamePrefix, widgets)); ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, EntityToken = EntityTokenSerializer.Serialize(entityToken, true), ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Documentation" }, currentConsoleId); return(null); }
protected void ActionChangeCallback(ActionToken actionToken) { if (ActionChanged != null) { ActionChanged(this, new EventArgs <ActionToken>(actionToken)); } }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var packageName = PackageCreatorFacade.ActivePackageName; if (entityToken is PackageCreatorEntityToken) { packageName = (entityToken as PackageCreatorEntityToken).Source; } if (string.IsNullOrEmpty(packageName)) { flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); var consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message")); return(null); } if (actionToken is AddLocalizationActionToken) { var token = actionToken as AddLocalizationActionToken; PackageCreatorFacade.AddItem(new PCLocalizations(token.CultureName), packageName); } var treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer); treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken()); return(null); }
public override void RemoveRunningActionToken(ActionToken token) { lock (mLockObject) { mRunningActionTokens.Remove(token); } }
public override void AddRunningActionToken(ActionToken token) { lock (mLockObject) { mRunningActionTokens.Add(token); } }
public ActionToken ExecuteAsync(IActionItem actionCase) { var action = actionCase as ActionBase; ActionToken ret = null; if (action != null) { if (!SuppressDebugOutput) { "{0:X2} (E){1}"._DLOG(SessionId, action.GetName() + action.AboutMeSafe()); } if (action.Token != null) { action.Token.HandleMe = (x) => OnHandleToken(x); action.Token.LogEntryPointClassLineNumber = GetLineNumberInTheEntryPointClass(LogEntryPointClass); action.Token.StartSignal = _actionStartSignal; } ret = action.Token; ActionCaseConsumer.Add(action); if (!isDisposing) { //_actionStartSignal.WaitOne(1000); if (!SuppressDebugOutput) { "{0:X2} (R){1}"._DLOG(SessionId, action.GetName() + action.AboutMeSafe()); } } } return(ret); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); if (actionToken.Serialize() == "ShowGraph") { string url = string.Format("{0}?EntityToken={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/Default.aspx"), System.Web.HttpUtility.UrlEncode(serializedEntityToken)); ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId); } else if (actionToken.Serialize() == "ShowOrientedGraph") { Guid id = Guid.NewGuid(); string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.RelationshipGraph", id)); C1File.WriteAllLines(filename, new string[] { serializedEntityToken }); string url = string.Format("{0}?Id={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/ShowRelationshipOrientedGraph.aspx"), id); ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId); } return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { //string documentTitle = "Unpublished Pages and Page Folder Data"; //string description = "The list below display pages and page data which are currently being edited or are ready to be approved / published."; string documentTitle = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-title"); string description = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-description"); string emptyLabel = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "ViewUnpublishedItems-document-empty-label"); string url = string.Format("{0}?showpagedata=true&title={1}&description={2}&emptyLabel={3}", UrlUtils.ResolveAdminUrl(string.Format("content/views/publishworkflowstatus/ViewUnpublishedItems.aspx")), HttpUtility.UrlEncode(documentTitle, Encoding.UTF8), HttpUtility.UrlEncode(description, Encoding.UTF8), HttpUtility.UrlEncode(emptyLabel, Encoding.UTF8)); IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); OpenViewMessageQueueItem openViewMsg = new OpenViewMessageQueueItem { EntityToken = EntityTokenSerializer.Serialize(entityToken, true), ViewId = "ViewUnpublishedPageItems", Label = documentTitle, Url = url, ViewType = ViewType.Main }; ConsoleMessageQueueFacade.Enqueue(openViewMsg, consoleServices.CurrentConsoleId); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var packageName = PackageCreatorFacade.ActivePackageName; if (entityToken is PackageCreatorEntityToken) { packageName = (entityToken as PackageCreatorEntityToken).Source; } if (string.IsNullOrEmpty(packageName)) { flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message")); return(null); } if (actionToken is PackageCreatorActionToken) { var token = actionToken as PackageCreatorActionToken; foreach (var item in PackageCreatorActionFacade.GetPackageCreatorItems(entityToken)) { if (item.CategoryName == token.CategoryName) { //if diffent item for one category and entitytoken var itemActionToken = item as IPackItemActionToken; if (itemActionToken != null) { if (token.Name != itemActionToken.ActionTokenName) { continue; } } if (item is IPackToggle) { if ((item as IPackToggle).CheckedStatus == ActionCheckedStatus.Checked) { PackageCreatorFacade.RemoveItem(item, packageName); } else { PackageCreatorFacade.AddItem(item, packageName); } var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer); parentTreeRefresher.PostRefreshMesseges(entityToken); } else { PackageCreatorFacade.AddItem(item, packageName); } break; } } } SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer); treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken()); return(null); }
private void saveInfoCodeActivity_ExecuteCode(object sender, EventArgs e) { var package = this.GetBinding <PackageInformation>("Package"); PackageCreatorFacade.SavePackageInformation(package); if (!string.IsNullOrEmpty(Payload)) { var type = StringConversionServices.DeserializeValueString(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]); ActionToken actionToken = ActionTokenSerializer.Deserialize(type); ActionExecutorFacade.Execute(package.GetEntityToken(), actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); } else { ActionExecutorFacade.Execute( package.GetEntityToken(), new SetActivePackageActionToken(), WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); } SpecificTreeRefresher treeRefresher = this.CreateSpecificTreeRefresher(); treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken()); }
internal static void FireOnBeforeActionExecution(EntityToken entityToken, ActionToken actionToken) { if (_onBeforeActionExecutionDelegates != null) { _onBeforeActionExecutionDelegates(new BeforeActionEventArgs(entityToken, actionToken)); } }
public void DisposesDisposableAndKeepsPermanentTokens() { var localMap = new ActionPipeMap() .StartsAt <DummyDisposableAction1>() .Then <DummyDisposableAction2>(); var newToken = new ActionToken(); var disposableType1 = new DummyDisposableType1(); var disposableType2 = new DummyDisposableType2(); newToken.Set(disposableType1, ItemLifespan.Permanent); newToken.Set(disposableType2, ItemLifespan.SingleRun); newToken.Set(new DummyType(), ItemLifespan.Permanent); newToken.Set(new DummyType2(), ItemLifespan.SingleRun); var pipe = new ActionPipe(localMap, newToken, new TransientDependencyResolver()); using (var dispatcher = new ActionDispatcher(ResourcePlan.Empty, 2, TaskCreationOptions.None, pipe)) { dispatcher.AsyncExecute().Wait(); } Assert.IsFalse(newToken.Contains <IDisposable>()); Assert.IsTrue(newToken.Contains <DummyDisposableType1>()); Assert.IsFalse(newToken.Contains <DummyDisposableType2>()); Assert.IsFalse(disposableType1.DisposeCalled); Assert.IsTrue(disposableType2.DisposeCalled); Assert.IsTrue(newToken.Contains <DummyType>()); Assert.IsFalse(newToken.Contains <DummyType2>()); }
public void CreateMemberGenericObserveTest() { bool isInvoked = false; IDisposable result = null; var listenerMock = new EventListenerMock(); var source = new BindingSourceModel(); const string path = "path"; var property = AttachedBindingMember.CreateMember <BindingSourceModel, string>(path, (info, o) => null, (info, o, v) => { }, (info, o, arg3) => { isInvoked = true; info.ShouldNotBeNull(); o.ShouldEqual(source); arg3.ShouldEqual(listenerMock); return(result); }); property.TryObserve(source, listenerMock).ShouldBeNull(); isInvoked.ShouldBeTrue(); isInvoked = false; result = new ActionToken(() => { }); property.TryObserve(source, listenerMock).ShouldEqual(result); isInvoked.ShouldBeTrue(); }
private void codeActivity_ExecuteCode(object sender, EventArgs e) { var type = StringConversionServices.DeserializeValueType(StringConversionServices.ParseKeyValueCollection(Payload)["ActionToken"]); ActionToken actionToken = (ActionToken)Activator.CreateInstance(type); ActionExecutorFacade.Execute(this.EntityToken, actionToken, WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId)); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); StringBuilder sb = new StringBuilder(); var elementInformationService = flowControllerServicesContainer.GetService <IElementInformationService>(); if (elementInformationService != null) { Dictionary <string, string> piggybag = elementInformationService.Piggyback; foreach (var kvp in piggybag) { Core.Serialization.StringConversionServices.SerializeKeyValuePair(sb, kvp.Key, kvp.Value); } } Guid id = Guid.NewGuid(); string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.showinfo", id)); C1File.WriteAllLines(filename, new string[] { serializedEntityToken, sb.ToString() }); string url = string.Format("{0}?PiggyBagId={1}", UrlUtils.ResolveAdminUrl("content/views/showelementinformation/Default.aspx"), id); ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show Element Information..." }, currentConsoleId); return(null); }
public bool Equals(DestinyInsertPlugsActionRequest input) { if (input == null) { return(false); } return (( ActionToken == input.ActionToken || (ActionToken != null && ActionToken.Equals(input.ActionToken)) ) && ( ItemInstanceId == input.ItemInstanceId || (ItemInstanceId.Equals(input.ItemInstanceId)) ) && ( Plug == input.Plug || (Plug != null && Plug.Equals(input.Plug)) ) && ( CharacterId == input.CharacterId || (CharacterId.Equals(input.CharacterId)) ) && ( MembershipType == input.MembershipType || (MembershipType != null && MembershipType.Equals(input.MembershipType)) )); }
internal static void FireOnAfterActionExecution(EntityToken entityToken, ActionToken actionToken, FlowToken flowToken) { if (_onAfterActionExecutionDelegates != null) { _onAfterActionExecutionDelegates(new AfterActionEventArgs(entityToken, actionToken, flowToken)); } }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { UrlActionToken urlActionToken = (UrlActionToken)actionToken; string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string url = urlActionToken.Url; string extendedUrl = $"{url}{(url.Contains("?") ? "&" : "?")}EntityToken={HttpUtility.UrlEncode(serializedEntityToken)}"; if (extendedUrl.IndexOf("consoleId", StringComparison.OrdinalIgnoreCase) == -1) { extendedUrl = $"{extendedUrl}&consoleId={currentConsoleId}"; } ConsoleMessageQueueFacade.Enqueue( new OpenViewMessageQueueItem { Url = extendedUrl, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = urlActionToken.Label, IconResourceHandle = urlActionToken.Icon }, currentConsoleId); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var token = (ToggleFunctionRouteActionToken)actionToken; using (var data = new DataConnection()) { var route = data.Get <IFunctionRoute>().SingleOrDefault(r => r.Function == token.Function); if (route == null) { route = data.CreateNew <IFunctionRoute>(); route.Id = Guid.NewGuid(); route.Function = token.Function; data.Add(route); } else { data.Delete(route); } } var treeRefresher = new ParentTreeRefresher(flowControllerServicesContainer); treeRefresher.PostRefreshMesseges(entityToken); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { SearchActionToken searchActionToken = (SearchActionToken)actionToken; string currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken); string viewId = Guid.NewGuid().ToString(); string url = UrlUtils.ResolveAdminUrl(string.Format("content/dialogs/treesearch/treeSearchForm.aspx?ProviderName={0}&EntityToken={1}&ViewId={2}&ConsoleId={3}", HttpUtility.UrlEncode(searchActionToken.ProviderName), HttpUtility.UrlEncode(serializedEntityToken), HttpUtility.UrlEncode(viewId), HttpUtility.UrlEncode(currentConsoleId))); ConsoleMessageQueueFacade.Enqueue( new OpenViewMessageQueueItem { Url = url, ViewId = viewId, ViewType = ViewType.ModalDialog, Label = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElements"), ToolTip = StringResourceSystemFacade.GetString("Composite.Management", "RelationshipGraphActionExecutor.SearchElementsToolTip"), IconResourceHandle = CommonElementIcons.Question }, currentConsoleId); return(null); }
public TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent) { List <Task> newTasks = new List <Task>(); lock (_lock) { foreach (Func <EntityToken, ActionToken, Task> taskCreator in _taskCreators) { try { Task task = taskCreator(entityToken, actionToken); if (task == null) { continue; } bool result = task.TaskManager.OnCreated(task.Id, taskManagerEvent); if (result == false) { continue; } _tasks.Add(task); newTasks.Add(task); } catch (Exception ex) { Log.LogError("TaskManagerFacade", "Starting new task failed with following exception"); Log.LogError("TaskManagerFacade", ex); } } } return(new TaskContainer(newTasks, null)); }
/// <exclude /> public static FlowToken ExecuteSecurityViolation(ActionToken actionToken, EntityToken entityToken, FlowControllerServicesContainer flowControllerServicesContainer) { EntityToken newEntityToken = new SecurityViolationWorkflowEntityToken(); WorkflowActionToken newActionToken = new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Actions.Workflows.SecurityViolationWorkflow")); return(Execute(newEntityToken, newActionToken, flowControllerServicesContainer)); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { PackageCreatorFacade.DeletePackageInformation(entityToken.Source); SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer); treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken()); return(null); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var service = ServiceLocator.GetService <ISearchIndexUpdater>(); service?.Rebuild(); return(null); }
public override ActionToken SetLearnMode(LearnModes mode, bool isSubstituteDenied, int timeoutMs, Action <IActionItem> completedCallback) { ActionToken ret = null; SetLearnModeSlaveOperation oper = new SetLearnModeSlaveOperation(mode, SetAssignStatusSignal, timeoutMs); learnModeOperation = oper; ret = ExecuteAsync(oper, completedCallback); return(ret); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { MessageBoxActionToken messageBoxActionToken = (MessageBoxActionToken)actionToken; IManagementConsoleMessageService managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); managementConsoleMessageService.ShowMessage(messageBoxActionToken.DialogType, messageBoxActionToken.Title, messageBoxActionToken.Message); return(null); }
public void Init() { resourceManager = new ResourceManager(); map = new ActionPipeMap() .StartsAt <DummyAction1>() .Then <DummyAction2>() .ThenParallely <DummyAction3, DummyAction4>(); token = new ActionToken(); taskFactory = new TaskFactory(); }
private string GetShowFunction(EntityToken entityToken, ActionToken actionToken) { return(string.Format("VersioningReport.Show('{0}','{1}','{2}','{3}','{4}');", providerName, EntityTokenSerializer.Serialize(entityToken, true).SerializeToJs(), ActionTokenSerializer.Serialize(actionToken, true).SerializeToJs(), piggybag, piggybagHash )); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { var downloadActionToken = (DownloadSubmittedFormsActionToken)actionToken; var currentConsoleId = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>().CurrentConsoleId; var url = "/formbuilder/" + downloadActionToken.FormName + "/submits" + downloadActionToken.Extension; ConsoleMessageQueueFacade.Enqueue(new DownloadFileMessageQueueItem(url), currentConsoleId); return(null); }
public void replaces_matches_with_values() { const string data = "Circle: 8"; const string pattern = "Circle:\\s+(\\d+)$"; const string action = "var circle $1;put #var circle $1"; var token = new ActionToken(); token.When = pattern; token.Action = action; var context = new ActionContext(); context.Match = data; context.Token = token; var scriptContext = new ScriptContext(Guid.NewGuid().ToString(), "Name", CancellationToken.None, theServices, null); scriptContext.DebugLevel = 5; context.ScriptContext = scriptContext; theReporter.OnNext(context); Assert.AreEqual("var circle 8;put #var circle 8", theExectuter.LastBlocks); }
public ActionResult SendChangePasswordLink(string Name, string Email, string RequestID, string SessionID) { if (AppSession.Parameters.RegistrationResetPassword.Value == "false") { if (AppSession.IsMemberInAdminRole) { } else { string ReturnUrl = AppSession.ReturnUrl; ReturnUrl = (ReturnUrl != null && ReturnUrl.Length > 0) ? ReturnUrl : ((AppSession.Parameters.RulesRedirectAfterLogin.Value != null && AppSession.Parameters.RulesRedirectAfterLogin.Value.Length > 0) ? AppSession.Parameters.RulesRedirectAfterLogin.Value : Url.Content("~/")); AuditEvent.AppEventError(AppSession.Parameters.GeneralAdminEmail.Value, "Somebody tries to request changing password but it was switched off. ", AuditEvent.GetSessionDetails()); return new RedirectResult(ReturnUrl); } } RequestResultModel _model = new RequestResultModel(); if (Name == null || Name.Trim().Length == 0 || Email == null || Email.Trim().Length == 0 || !AppSession.IsEmail(Email)) { _model = new RequestResultModel(); _model.Title = "Warning"; _model.InfoType = RequestResultInfoType.ErrorOrDanger; if (Name == null || Name.Trim().Length == 0) _model.Message = String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.NameIsEmpty")); if (Email == null || Email.Trim().Length == 0) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.EmailIsEmpty")); if (Email != null && !AppSession.IsEmail(Email)) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.EmailWrongFromat")); _model.Message = String.Format("<ul>{0}</ul>", _model.Message); return Json(new { Status = RequestResultInfoType.ErrorOrDanger, NotifyType = NotifyType.DialogInline, Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model) }, JsonRequestBehavior.AllowGet); } Member Member = Members.GetByEmailName(Email, Name); if (!AppSession.IsEmail(Email)) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.WrongEmail"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventWarning(AppSession.Parameters.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountWrongEmail, Member.Name, Member.Email)); } else { if (Member.MemberID <= 0) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.AccountDoesntExist"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventWarning(AppSession.Parameters.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountAccountDoesntExist, Name, Email)); } else { try { string ResetToken = Web.Admin.Logic.StringTool.RandomString(20); if (!SendChangePasswordEmail(Name, Email, ResetToken)) { throw new Exception("Changing password link notification e-mail has not been send!"); }; _model.Title = GetLabel("Account.Controller.Congrat"); _model.Message = GetLabel("Account.Controller.ResetPassMail"); _model.InfoType = RequestResultInfoType.Success; ActionToken actionToken = new ActionToken(); actionToken.Email = Email; actionToken.Token = HttpUtility.UrlDecode(ResetToken); actionToken.ActionType = ActionTokenTypes.PasswordReset; actionToken.ReturnURL = AppSession.ReturnUrl != null ? AppSession.ReturnUrl : (AppSession.Parameters.RulesRedirectAfterLogout.Value != "" ? AppSession.Parameters.RulesRedirectAfterLogout.Value : ""); actionToken.Save(); AuditEvent.AppEventSuccess(AppSession.Parameters.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountResetPassMail, Member.Name, Member.Email)); } catch (Exception ex) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.CantSendNotification"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventError(Email ,"Send change password link: Something went wrong with e-mail notification: " + ex.Message, AuditEvent.GetSessionDetails(ex.StackTrace),true); } } } return Json(new { Status = _model.InfoType, NotifyType = NotifyType.DialogInline, Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model) }, JsonRequestBehavior.AllowGet); }
public static TokenDefinitionRegistry Default() { var registry = new TokenDefinitionRegistry(); registry.New(d => { d.Type = "exit"; d.Pattern = "^exit"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = match.Value }; return token; }; }); registry.New(d => { d.Type = "comment"; d.Pattern = "^#.*"; d.Ignore = true; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = match.Value }; return token; }; }); registry.New(d => { d.Type = "label"; d.Pattern = RegexPatterns.Label; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = match.Groups[1].Value }; return token; }; }); registry.New(d => { d.Type = "goto"; d.Pattern = "^goto"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "waitfor"; d.Pattern = "^waitfor\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "waitforre"; d.Pattern = "^waitforre\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "match"; d.Pattern = "^match\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { const string Goto_Regex = "^match\\b\\s([\\w\\.-]+)\\s(.*)"; var gotoMatch = Regex.Match(source, Goto_Regex, RegexOptions.IgnoreCase); var token = new MatchToken { Text = source, Type = def.Type, IsRegex = false, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(), Goto = gotoMatch.Groups[1].Value, Pattern = gotoMatch.Groups[2].Value.Trim() }; return token; }; }); registry.New(d => { d.Type = "matchre"; d.Pattern = "^matchre\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { const string Goto_Regex = "^matchre\\b\\s([\\w\\.-]+)\\s(.*)"; var gotoMatch = Regex.Match(source, Goto_Regex, RegexOptions.IgnoreCase); var token = new MatchToken { Text = source, Type = def.Type, IsRegex = true, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(), Goto = gotoMatch.Groups[1].Value, Pattern = gotoMatch.Groups[2].Value.Trim() }; return token; }; }); registry.New(d => { d.Type = "matchwait"; d.Pattern = "^matchwait"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "pause"; d.Pattern = "^pause"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "put"; d.Pattern = "^put"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "echo"; d.Pattern = "^echo"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; if(token.Value == null || token.Value.Length == 0 || !token.Value.EndsWith("\n")) { token.Value += "\n"; } return token; }; }); registry.New(d => { d.Type = "var"; d.Pattern = "^var"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "var"; d.Pattern = "^setvariable"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "unvar"; d.Pattern = "^unvar\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "hasvar"; d.Pattern = "^hasvar\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "save"; d.Pattern = "^save"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim() }; return token; }; }); registry.New(d => { d.Type = "if"; d.Pattern = "^if\\b"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new IfToken { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "if_"; d.Pattern = "^if_(\\d+)"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new IfToken { Text = source, Type = def.Type, Value = match.Value, ReplaceBlocks = false, Blocks = new IfBlocks { IfEval = match.Groups[1].Value, IfBlock = value } }; return token; }; }); registry.New(d => { d.Type = "move"; d.Pattern = "^move"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "nextroom"; d.Pattern = "^nextroom"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "action"; d.Pattern = "^action\\b(.*)\\bwhen\\b(.*)"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new ActionToken { Text = source, Type = def.Type, Value = value, Action = match.Groups[1].Value.Trim(), When = match.Groups[2].Value.Trim() }; return token; }; }); registry.New(d => { d.Type = "send"; d.Pattern = "^send"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "debuglevel"; d.Pattern = "^debuglevel"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "parse"; d.Pattern = "^parse"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "containsre"; d.Pattern = "^containsre"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var token = new Token { Text = source, Type = def.Type, Value = value }; return token; }; }); registry.New(d => { d.Type = "gosub"; d.Pattern = "^gosub"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var value = source.Substring(match.Index + match.Length, source.Length - (match.Index + match.Length)).Trim(); var labelMatch = Regex.Match(value, RegexPatterns.Gosub); var splitArgs = Regex .Matches(value, RegexPatterns.Arguments) .Cast<Match>() .Select(m => m.Groups["match"].Value.Trim('"')) .Skip(1) .ToArray(); var token = new GotoToken { Text = source, Type = def.Type, Value = value, Label = labelMatch.Groups["label"].Value, Args = splitArgs }; return token; }; }); registry.New(d => { d.Type = "return"; d.Pattern = "^return"; d.Ignore = false; d.BuildToken = (source, match, def)=> { var token = new Token { Text = source, Type = def.Type, Value = "return" }; return token; }; }); return registry; }
/// <exclude /> public SecurityToken(EntityToken entityToken, ActionToken actionToken, UserToken userToken) { _entityToken = entityToken; _actionToken = actionToken; _userToken = userToken; }
public ActionResult Register(string Name, string Email, string Password, string Confirmation, string ReturnUrl, List<ProfileFieldInfo> FieldInfo, string RequestID, string SessionID, int TimeZoneOffset) { AppParams.RefreshAppParameters(); string AfterSingUpRedirectUrl = ""; if (AppSession.Parameters.RegistrationSelfRegistration.Value == "false") { if (AppSession.IsMemberInAdminRole) { } else { if (ReturnUrl == null || ReturnUrl.Trim().Length == 0) ReturnUrl = (ReturnUrl != null && ReturnUrl.Length > 0) ? ReturnUrl : ((AppSession.Parameters.RulesRedirectAfterLogin.Value != null && AppSession.Parameters.RulesRedirectAfterLogin.Value.Length > 0) ? AppSession.Parameters.RulesRedirectAfterLogin.Value : Url.Content("~/")); AuditEvent.AppEventError(AppSession.Parameters.GeneralAdminEmail.Value, "Somebody tries to Register notification but it was switched off. ", AuditEvent.GetSessionDetails()); return new RedirectResult(ReturnUrl); } } RequestResultModel _model = new RequestResultModel(); if (AppSession.IsEmail(Name)) { _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.NameLooksLikeEmail")); } if (Name == null || Name.Trim().Length == 0 || ((Password == null || Password.Trim().Length == 0)) || Email == null || Email.Trim().Length == 0 || Password != Confirmation || !AppSession.IsEmail(Email) || (Password != null && Password.Length > 0 && Password.Length <=3) || (Confirmation != null && Confirmation.Length > 0 && Confirmation.Length <=3)) { if (Name == null || Name.Trim().Length == 0) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.NameIsEmpty")); if ((Password == null || Password.Trim().Length == 0)) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.PasswordIsEmty")); if (Email == null || Email.Trim().Length == 0) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.EmailIsEmpty")); if (Email != null && !AppSession.IsEmail(Email)) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.EmailWrongFromat")); if (Password != Confirmation) _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.PasswordNoMatch")); if ((Password != null && Password.Length > 0 && Password.Length < AppSession.PasswordMaxLength) || (Confirmation != null && Confirmation.Length > 0 && Confirmation.Length < AppSession.PasswordMaxLength)) { _model.Message += String.Format("<li>{0}</<li>", String.Format(GetLabel("Account.CreateAccount.PasswordLength"), AppSession.PasswordMaxLength)); } } // Check mandatory fields if (FieldInfo != null) { foreach (ProfileFieldInfo Field in FieldInfo) { ProfileField profileField = ProfileFields.GetBy(int.Parse(Field.ID)); if (profileField.IsMandatory == 1 && (Field.Value == null || Field.Value.Trim().Length == 0)) { _model.Message += String.Format("<li>{0}</li>", String.Format(GetLabel("Account.CreateAccount.Mandatory"), profileField.FieldName)); } if (profileField.IsMandatory == 1 && profileField.FieldTypeID == ProfileFieldTypeEnum.CheckBox && Field.Value != null && Field.Value.ToLower() == "false") { _model.Message += String.Format("<li>{0}</li>", String.Format(GetLabel("Account.CreateAccount.Mandatory"), profileField.FieldName)); } } } bool nonAlphaNumeric = Name.Replace(" ", "").All(c => char.IsLetterOrDigit(c)); if (!nonAlphaNumeric) { _model.Message += String.Format("<li>{0}</<li>", GetLabel("Account.CreateAccount.NameNonAlfaNum")); } if (_model.Message.Length > 0) { _model.Message = String.Format("<ul class=\"error-message-list\">{0}</ul>", _model.Message); _model.InfoType = RequestResultInfoType.ErrorOrDanger; return Json(new { Status = RequestResultInfoType.ErrorOrDanger, NotifyType = NotifyType.DialogInline, Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model) }, JsonRequestBehavior.AllowGet); } // Check email format if (!AppSession.IsEmail(Email)) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.WrongEmail"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventError(AppParams.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountWrongEmail, Name, Email)); } else { if (!AppSession.IsMailDomainAllowed(Email)) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.DomainNotAllowed"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventError(AppParams.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountDomainNotAllowed, Name, Email)); } else { Member Member = Members.GetByEmailOrName(Email, Name); if (Member.MemberID > 0) { _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.AccountExists"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventError(AppParams.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountAccountExists, Name, Email)); } else { // Was account activated ? // Was account blocked ? Member member = new Logic.Objects.Member(); member.Name = Name; member.Email = Email; member.Password = Password; member.IsBuiltIn = false; member.Created = DateTime.UtcNow; member.Save(); try { string ActivateToken = Web.Admin.Logic.StringTool.RandomString(20); if (!SendActivationEmail(Name, Email, ActivateToken)){ throw new Exception("Creating an account notification e-mail has not been send!"); } ActionToken actionToken = new ActionToken(); actionToken.Email = Email; actionToken.Token = HttpUtility.UrlDecode(ActivateToken); actionToken.ActionType = ActionTokenTypes.SelfActivation; actionToken.ReturnURL = AppSession.ReturnUrl != null ? AppSession.ReturnUrl : ( AppSession.Parameters.RulesRedirectAfterLogout.Value != "" ? AppSession.Parameters.RulesRedirectAfterLogout.Value : "") ; actionToken.Save(); if (member.MemberID > 0) { string[] RoleNames = AppParams.RegistrationMemberRegistrationToRoles.Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (String RoleName in RoleNames) { Role role = Web.Admin.Logic.Collections.Roles.GetBy(RoleName.Trim()); if (role.RoleID > 0) { MemberRole memberrole = new MemberRole(); memberrole.MemberID = member.MemberID; memberrole.RoleID = role.RoleID; memberrole.Save(); } } } if (FieldInfo != null) { foreach (ProfileFieldInfo Field in FieldInfo) { ProfileField profileField = ProfileFields.GetBy(int.Parse(Field.ID)); MemberProfileField memberProfileField = new MemberProfileField(); memberProfileField.MemberID = member.MemberID; memberProfileField.FieldID = int.Parse(Field.ID); memberProfileField.FieldValue = Field.Value; if (Field.Value == null || Field.Value.Trim().Length == 0) memberProfileField.Delete(); else memberProfileField.Save(); } } Domain _domain = Domains.GetByName(AppSession.SignUpDomain); if (_domain.DomainID > 0) { MemberDomain _memberDomain = new MemberDomain(); _memberDomain.DomainID = _domain.DomainID; _memberDomain.MemberID = member.MemberID; _memberDomain.Save(); } if (AppSession.Parameters.RulesRedirectAfterSignUp.Value != null && AppSession.Parameters.RulesRedirectAfterSignUp.Value.Length > 0) AfterSingUpRedirectUrl = AppSession.Parameters.RulesRedirectAfterSignUp.Value; _model.Title = GetLabel("Account.Controller.Congrat"); _model.Message = GetLabel("Account.Controller.ActivationMailSent"); _model.InfoType = RequestResultInfoType.Success; AuditEvent.AppEventSuccess(AppParams.GeneralAdminEmail.Value, String.Format(AuditEvent.AccountActivationMailSent, Name, Email)); } catch (Exception ex) { try { // Try to delete member if notification was failed. member.Delete(); } catch { } _model.Title = GetLabel("Account.Controller.Warning"); _model.Message = GetLabel("Account.Controller.CantSendNotification"); _model.InfoType = RequestResultInfoType.ErrorOrDanger; AuditEvent.AppEventError(Email ,"Registration: Something went wrong with e-mail notification: " + ex.Message, AuditEvent.GetSessionDetails(ex.StackTrace),true); } } } } return Json(new { Status = _model.InfoType, RedirectTo = AfterSingUpRedirectUrl, NotifyType = NotifyType.DialogInline, Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model) }, JsonRequestBehavior.AllowGet); }