private ConsoleSearchResultFacetField[] GetFacets(SearchResult queryResult, ICollection <DocumentField> facetFields) { if (queryResult.Facets == null) { return(null); } var result = new List <ConsoleSearchResultFacetField>(); foreach (var field in facetFields.Where(f => queryResult.Facets.ContainsKey(f.Name))) { if (field.Label == null) { continue; } Facet[] values = queryResult.Facets[field.Name]; if (values.Length == 0) { continue; } result.Add(new ConsoleSearchResultFacetField { FieldName = MakeFieldNameJsFriendly(field.Name), Label = StringResourceSystemFacade.ParseString(field.Label), Facets = values.Select(v => new ConsoleSearchResultFacetValue { Value = v.Value, HitCount = v.HitCount, Label = (field.Facet.PreviewFunction ?? (value => value))(v.Value) }).ToArray() }); } return(result.ToArray()); }
public override void BindStateToProperties() { if (this.ReadOnly) { return; } try { if (string.IsNullOrEmpty(this.CurrentStringValue)) { this.Date = null; } else { DateTime parsedTime; if (!DateTimeExtensionMethods.TryParseInTimeZone(this.CurrentStringValue, out parsedTime)) { throw new FormatException(); } if (!ShowHours) { parsedTime -= parsedTime.TimeOfDay; } this.Date = parsedTime.FromTimeZoneToUtc().ToLocalTime(); } this.IsValid = true; } catch (Exception) { this.IsValid = false; this.ValidationError = string.Format(StringResourceSystemFacade.GetString("Composite.Management", "Validation.DateTime.InvalidDateFormat"), this.CurrentStringValue, SampleDateString); } }
private void IsValidMethodName(object sender, ConditionalEventArgs e) { IMethodBasedFunctionInfo function = this.GetBinding <IMethodBasedFunctionInfo>("NewMethodBasedFunction"); FlowControllerServicesContainer container = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); var flowRenderingService = container.GetService <IFormFlowRenderingService>(); if (function.UserMethodName == String.Empty) { string errorMessage = StringResourceSystemFacade.GetString("Composite.Plugins.MethodBasedFunctionProviderElementProvider", "AddFunction.MethodNameIsEmpty"); ShowFieldMessage("NewMethodBasedFunction", errorMessage); e.Result = false; return; } if (!function.Namespace.IsCorrectNamespace('.')) { string errorMessage = StringResourceSystemFacade.GetString("Composite.Plugins.MethodBasedFunctionProviderElementProvider", "AddFunction.InvalidNamespace"); ShowFieldMessage("NewMethodBasedFunction", errorMessage); e.Result = false; return; } bool exists = FunctionFacade.FunctionExists(function.Namespace, function.UserMethodName); if (exists) { string errorMessage = StringResourceSystemFacade.GetString("Composite.Plugins.MethodBasedFunctionProviderElementProvider", "AddFunction.NameAlreadyUsed"); errorMessage = string.Format(errorMessage, StringExtensionMethods.CreateNamespace(function.Namespace, function.UserMethodName)); ShowFieldMessage("NewMethodBasedFunction.UserMethodName", errorMessage); e.Result = false; return; } e.Result = true; }
private void changeLocaleCodeActivity_Execute_ExecuteCode(object sender, EventArgs e) { WorkflowActionToken workflowActionToken = (WorkflowActionToken)this.ActionToken; CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(workflowActionToken.Payload); UserSettings.ActiveLocaleCultureInfo = cultureInfo; string currentConsoleId = GetCurrentConsoleId(); foreach (string consoleId in GetConsoleIdsOpenedByCurrentUser()) { if (consoleId != currentConsoleId) { ConsoleMessageQueueFacade.Enqueue(new CloseAllViewsMessageQueueItem { Reason = StringResourceSystemFacade.GetString("Composite.C1Console.Users", "ChangeOwnActiveLocaleWorkflow.CloseAllViews.Message") }, consoleId); } ConsoleMessageQueueFacade.Enqueue(new CollapseAndRefreshConsoleMessageQueueItem(), consoleId); ConsoleMessageQueueFacade.Enqueue(new BroadcastMessageQueueItem { Name = "ActiveLocaleChanged", Value = "" }, consoleId); } }
private ConsoleSearchResultFacetField[] EmptyFacetsFromSelections( ConsoleSearchQuery query, List <DocumentField> facetFields) { if (query.Selections == null) { return(null); } return((from selection in query.Selections where selection.Values.Length > 0 let facetField = facetFields.First(ff => ff.Name == selection.FieldName) select new ConsoleSearchResultFacetField { FieldName = MakeFieldNameJsFriendly(selection.FieldName), Label = StringResourceSystemFacade.ParseString(facetField.Label), Facets = selection.Values.Select(value => new ConsoleSearchResultFacetValue { Label = (facetField.Facet.PreviewFunction ?? (v => v))(value), Value = value, HitCount = 0 }).ToArray() }).ToArray()); }
private void step1CodeActivity_ValidateInstallation_ExecuteCode(object sender, EventArgs e) { try { UploadedFile uploadedFile = this.GetBinding<UploadedFile>("UploadedFile"); PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(uploadedFile.FileStream, true); if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0) { this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(packageManagerInstallProcess.PreInstallValidationResult)); } else { List<PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate(); if (validationResult.Count > 0) { this.UpdateBinding("LayoutLabel", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallLocalPackage.ShowWarning.LayoutLabel")); this.UpdateBinding("TableCaption", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallLocalPackage.ShowWarning.InfoTableCaption")); this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(validationResult)); } else { this.Bindings.Add("PackageManagerInstallProcess", packageManagerInstallProcess); this.Bindings.Add("FlushOnCompletion", packageManagerInstallProcess.FlushOnCompletion); this.Bindings.Add("ReloadConsoleOnCompletion", packageManagerInstallProcess.ReloadConsoleOnCompletion); } } } catch (Exception ex) { this.UpdateBinding("Errors", new List<List<string>> { new List<string> { ex.Message, "" } }); } }
public static string Localize(string text) { if (text.Contains("T(")) { var match = _t.Match(text); if (match.Success) { var key = match.Groups[1].Value; var localized = C1Res.T(key); if (localized != null) { return(text.Remove(match.Index, match.Length).Insert(match.Index, localized)); } } } if (text.Contains("${")) { return(StringResourceSystemFacade.ParseString(text)); } return(text); }
public DataGroupingProviderHelper(ElementProviderContext elementProviderContext) { _elementProviderContext = elementProviderContext; _undefinedLabelValue = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "UndefinedLabelTemplate"); this.FolderOpenIcon = GetIconHandle("datagroupinghelper-folder-open"); this.FolderClosedIcon = GetIconHandle("datagroupinghelper-folder-closed"); this.OnCreateLeafElement = d => new Element(_elementProviderContext.CreateElementHandle(d.GetDataEntityToken())); this.OnGetDataScopeIdentifier = t => DataScopeIdentifier.Administrated; this.OnAddActions = (e, p) => e; AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataEntityToken>(this); AuxiliarySecurityAncestorFacade.AddAuxiliaryAncestorProvider <DataGroupingProviderHelperEntityToken>(this); DataEventSystemFacade.SubscribeToDataAfterUpdate(typeof(IData), (sender, args) => { if (!OnOwnsType(args.DataType)) { return; } var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(args.DataType); IEnumerable <DataFieldDescriptor> groupingDataFieldDescriptors = from dfd in dataTypeDescriptor.Fields where dfd.GroupByPriority != 0 orderby dfd.GroupByPriority select dfd; if (groupingDataFieldDescriptors.Any()) { EntityTokenCacheFacade.ClearCache(args.Data.GetDataEntityToken()); } }, false); }
public static ElementAction CreateSortAction(string url, string label) { if (String.IsNullOrEmpty(label)) { label = StringResourceSystemFacade.GetString("CompositeC1Contrib.Sorting", "Sort"); } else { label = StringResourceSystemFacade.GetString("CompositeC1Contrib.Sorting", "Sort") + " " + label; } var urlAction = new UrlActionToken(label, BaseUrl + url, new[] { PermissionType.Edit, PermissionType.Publish }); return(new ElementAction(new ActionHandle(urlAction)) { VisualData = new ActionVisualizedData { Label = label, ToolTip = label, Icon = new ResourceHandle("Composite.Icons", "cut"), ActionLocation = ActionLocation } }); }
public override IEnumerable <C1Console.Elements.ElementAction> GetActions() { return(new[] { new ElementAction(new ActionHandle(new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageTemplateElementProvider.EditRazorPageTemplateWorkflow"), _editWebsiteFilePermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.RazorPageTemplate", "EditRazorFileAction.Label"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.RazorPageTemplate", "EditRazorFileAction.ToolTip"), Icon = EditTemplateIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryFileActionGroup } } } }); }
public IEnumerable <Element> GetRoots(SearchToken seachToken) { int userGroupCount = DataFacade.GetData <IUserGroup>().Count(); Element element = new Element(_elementProviderContext.CreateElementHandle(new UserGroupElementProviderRootEntityToken())) { VisualData = new ElementVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.RootLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.RootToolTip"), HasChildren = userGroupCount > 0, Icon = UserGroupElementProvider.RootClosedIcon, OpenedIcon = UserGroupElementProvider.RootOpenIcon } }; element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.UserGroupElementProvider.AddNewUserGroupWorkflow"), AddNewUserGroupPermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.AddNewUserGroupLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.AddNewUserGroupToolTip"), Icon = UserGroupElementProvider.AddUserGroupIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); yield return(element); }
private void editCodeActivity_ShowBaloon_ExecuteCode(object sender, EventArgs e) { this.ShowFieldMessage("SystemActiveLocale.UrlMappingName", StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "EditSystemLocaleWorkflow.UrlMappingName.InUseMessage")); }
private string GetText(string key) { return(StringResourceSystemFacade.GetString("Composite.Plugins.MethodBasedFunctionProviderElementProvider", key)); }
private static string GetLocalized(string text) { return(text.Contains("${") ? StringResourceSystemFacade.ParseString(text) : text); }
public static bool SubmitForm(ParameterList parameters, string captchaText) { try { _compiler.SaveControlProperties(); } catch (Exception) { } webUiControl.InitializeViewState(); Dictionary <string, string> errorMessages = formHelper.BindingsToObject(bindings, newData); DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(newData.DataSourceId.InterfaceType); foreach (var property in newData.DataSourceId.InterfaceType.GetProperties()) { if (property.PropertyType == typeof(string) && (string)property.GetValue(newData, null) == string.Empty) { property.SetValue(newData, null, null); } } ValidationResults validationResults = ValidationFacade.Validate(newData.DataSourceId.InterfaceType, newData); var isValid = true; var useCaptcha = parameters.GetParameter <bool>("UseCaptcha"); if (useCaptcha) { var Session = HttpContext.Current.Session; if (Session["FormsRendererCaptcha"] == null || !Captcha.IsValid(captchaText, Session["FormsRendererCaptcha"].ToString())) { ErrorSummary.AddError(StringResourceSystemFacade.GetString("Composite.Forms.Renderer", "Composite.Forms.Captcha.CaptchaText.error")); isValid = false; } } if (validationResults.IsValid == false) { isValid = false; Dictionary <string, string> errorSummary = new Dictionary <string, string>(); foreach (ValidationResult result in validationResults) { var label = result.Key; var help = result.Message; try { label = dataTypeDescriptor.Fields[result.Key].FormRenderingProfile.Label; help = dataTypeDescriptor.Fields[result.Key].FormRenderingProfile.HelpText; //if no HelpText specified - use standard C1 error if (help == string.Empty) { help = result.Message; } string error = GetLocalized(label) + ": " + GetLocalized(help); if (!errorSummary.ContainsValue(error)) { errorSummary.Add(errorSummary.Count().ToString(), error); } } catch { } } // add errors to ErrorSummary foreach (var dict in errorSummary) { ErrorSummary.AddError(dict.Value); } } //TODO: Looks like rudimentary code related to old C1 errros with binding? if (errorMessages != null) { isValid = false; foreach (var kvp in errorMessages) { var label = kvp.Key; try { label = dataTypeDescriptor.Fields[kvp.Key].FormRenderingProfile.Label; } catch { } ErrorSummary.AddError(GetLocalized(label) + ": " + GetLocalized(kvp.Value)); } } if (isValid) { using (new DataScope(DataScopeIdentifier.Administrated)) { IPublishControlled publishControlled = newData as IPublishControlled; if (publishControlled != null) { publishControlled.PublicationStatus = GenericPublishProcessController.Draft; } DataFacade.AddNew(newData); using (var datascope = new FormsRendererDataScope(newData)) { var formEmailHeaders = parameters.GetParameter("Email") as IEnumerable <FormEmail>; if (formEmailHeaders != null) { foreach (var formEmail in formEmailHeaders) { ParameterFacade.ResolveProperties(formEmail); var inputXml = GetXElement(newData); var body = new XhtmlDocument(); body.AppendDocument(formEmail.Body); if (formEmail.AppendFormData) { var formData = new XDocument(); var xslTransform = new XslCompiledTransform(); xslTransform.LoadFromPath(FormsRendererLocalPath + "Xslt/MailBody.xslt"); using (var writer = formData.CreateWriter()) { xslTransform.Transform(inputXml.CreateReader(), writer); } body.AppendDocument(formData); } Reflection.CallStaticMethod <object>("Composite.Core.WebClient.Renderings.Page.PageRenderer", "NormalizeXhtmlDocument", body); var mailMessage = new MailMessage(); try { mailMessage.From = new MailAddress(formEmail.From); } catch (Exception e) { LoggingService.LogError(string.Format("Mail sending(From: '{0}')", formEmail.From), e.Message); continue; } try { mailMessage.To.Add(formEmail.To); } catch (Exception e) { LoggingService.LogError(string.Format("Mail sending(To: '{0}')", formEmail.To), e.Message); continue; } if (!string.IsNullOrEmpty(formEmail.Cc)) { try { mailMessage.CC.Add(formEmail.Cc); } catch (Exception e) { LoggingService.LogError(string.Format("Mail sending(Cc: '{0}')", formEmail.Cc), e.Message); } } try { mailMessage.Subject = formEmail.Subject; mailMessage.IsBodyHtml = true; mailMessage.Body = body.ToString(); new SmtpClient().Send(mailMessage); } catch (Exception e) { throw new InvalidOperationException("Unable to send mail. Please ensure that web.config has correct /configuration/system.net/mailSettings: " + e.Message); } } } } } } return(isValid); }
public IEnumerable <Element> GetRoots(SearchToken searchToken) { int pages; using (new DataScope(DataScopeIdentifier.Administrated)) { pages = PageServices.GetChildrenCount(Guid.Empty); } EntityToken entityToken = new PageElementProviderEntityToken(_context.ProviderName); var dragAndDropInfo = new ElementDragAndDropInfo(); dragAndDropInfo.AddDropType(typeof(IPage)); dragAndDropInfo.SupportsIndexedPosition = true; var element = new Element(_context.CreateElementHandle(entityToken), dragAndDropInfo) { VisualData = new ElementVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabelToolTip"), HasChildren = pages != 0, Icon = PageElementProvider.RootClosed, OpenedIcon = PageElementProvider.RootOpen } }; element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageElementProvider.AddNewPageWorkflow"), AddWebsitePermissionTypes) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddPageAtRoot"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddPageAtRootToolTip"), Icon = PageElementProvider.AddPage, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new ViewUnpublishedItemsActionToken())) { VisualData = new ActionVisualizedData { //Label = "List unpublished Pages and Folder Data", //ToolTip = "Get an overview of pages and page folder data that haven't been published yet.", Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItemsToolTip"), Icon = PageElementProvider.ListUnpublishedItems, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = ViewActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.AddMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .AddAssociatedTypePermissionTypes) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeToolTip"), Icon = AddDataAssociationTypeIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = false, ActionGroup = MetaDataAppendedActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.EditMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .EditAssociatedTypePermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeToolTip"), Icon = EditDataAssociationTypeIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = false, ActionGroup = MetaDataAppendedActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.DeleteMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .RemoveAssociatedTypePermissionTypes))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeToolTip"), Icon = RemoveDataAssociationTypeIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = false, ActionGroup = MetaDataAppendedActionGroup } } }); // Creates a problem for the front-end "toolbar caching" mechanism - dont re-introduce this right befroe a release // Reason: ActionTokin is always unique for a page, making the ActionKey (hash) unique //if (RuntimeInformation.IsDebugBuild) //{ // element.AddAction(new ElementAction(new ActionHandle(new DisplayLocalOrderingActionToken(Guid.Empty))) // { // VisualData = new ActionVisualizedData // { // Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingLabel"), // ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingToolTip"), // Icon = CommonElementIcons.Nodes, // Disabled = false, // ActionLocation = new ActionLocation // { // ActionType = ActionType.DeveloperMode, // IsInFolder = false, // IsInToolbar = false, // ActionGroup = AppendedActionGroup // } // } // }); //} yield return(element); }
private List <Element> GetConnectionElements() { var connections = DataFacade.GetData <ISqlConnection>(); var queries = DataFacade.GetData <ISqlFunctionInfo>(); List <Element> elements = new List <Element>(); foreach (ISqlConnection connection in connections) { int queryCount = queries.Where(x => x.ConnectionId == connection.Id).Count(); bool hasChildren = queryCount > 0; Element element = new Element(_context.CreateElementHandle(connection.GetDataEntityToken())) { VisualData = new ElementVisualizedData() { Label = connection.Name, ToolTip = connection.EncryptedConnectionString.Decrypt(), HasChildren = hasChildren, Icon = SqlFunctionElementProvider.Connection, OpenedIcon = SqlFunctionElementProvider.Connection } }; elements.Add(element); element.AddAction( new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.SqlFunctionElementProvider.EditSqlConnectionWorkflow"), new PermissionType[] { PermissionType.Edit } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.EditConnection"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.EditConnectionToolTip"), Icon = EditConnection, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction( new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.SqlFunctionElementProvider.DeleteSqlConnectionWorkflow"), new PermissionType[] { PermissionType.Delete } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.DeleteConnection"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.DeleteConnectionToolTip"), Icon = DeleteConnection, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction( new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.SqlFunctionElementProvider.AddNewSqlFunctionProviderWorkflow"), new PermissionType[] { PermissionType.Add } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.AddQuery"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.AddQueryToolTip"), Icon = AddConnection, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); } return(elements); }
private static string GetText(string key) { return(StringResourceSystemFacade.GetString("Composite.Plugins.UserControlFunction", key)); }
private static string GetText(string key) { return(StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", key)); }
private string GetText(string key) { return(StringResourceSystemFacade.GetString("Composite.Management", key)); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { var dataEntityToken = (DataEntityToken)this.EntityToken; var user = (IUser)dataEntityToken.Data; var userFormLogin = user.GetUserFormLogin(); this.Bindings.Add(BindingNames.User, user); this.Bindings.Add(BindingNames.UserFormLogin, userFormLogin); this.Bindings.Add(BindingNames.NewPassword, NotPassword); CultureInfo userCulture = UserSettings.GetUserCultureInfo(user.Username); CultureInfo c1ConsoleUiLanguage = UserSettings.GetUserC1ConsoleUiLanguage(user.Username); List <KeyValuePair> regionLanguageList = StringResourceSystemFacade.GetSupportedCulturesList(); Dictionary <string, string> culturesDictionary = StringResourceSystemFacade.GetAllCultures(); this.Bindings.Add("AllCultures", culturesDictionary); this.Bindings.Add("CultureName", userCulture.Name); this.Bindings.Add("C1ConsoleUiCultures", regionLanguageList); this.Bindings.Add("C1ConsoleUiLanguageName", c1ConsoleUiLanguage.Name); if (UserSettings.GetActiveLocaleCultureInfos(user.Username).Any() && (user.Username != UserSettings.Username)) { this.Bindings.Add("ActiveLocaleName", UserSettings.GetCurrentActiveLocaleCultureInfo(user.Username).Name); this.Bindings.Add("ActiveLocaleList", DataLocalizationFacade.ActiveLocalizationCultures.ToDictionary(f => f.Name, DataLocalizationFacade.GetCultureTitle)); } var clientValidationRules = new Dictionary <string, List <ClientValidationRule> > { { "Username", ClientValidationRuleFacade.GetClientValidationRules(user, "Username") }, { "Group", ClientValidationRuleFacade.GetClientValidationRules(user, "Group") } }; IFormMarkupProvider markupProvider = new FormDefinitionFileMarkupProvider(@"\Administrative\EditUserStep1.xml"); XDocument formDocument; using (var reader = markupProvider.GetReader()) { formDocument = XDocument.Load(reader); } XElement bindingsElement = formDocument.Root.Element(DataTypeDescriptorFormsHelper.CmsNamespace + FormKeyTagNames.Bindings); XElement layoutElement = formDocument.Root.Element(DataTypeDescriptorFormsHelper.CmsNamespace + FormKeyTagNames.Layout); XElement tabPanelsElement = layoutElement.Element(DataTypeDescriptorFormsHelper.MainNamespace + "TabPanels"); List <XElement> placeHolderElements = tabPanelsElement.Elements(DataTypeDescriptorFormsHelper.MainNamespace + "PlaceHolder").ToList(); UpdateFormDefinitionWithUserGroups(user, bindingsElement, placeHolderElements[1]); UpdateFormDefinitionWithActivePerspectives(user, bindingsElement, placeHolderElements[2]); //UpdateFormDefinitionWithGlobalPermissions(user, bindingsElement, placeHolderElements[1]); if (DataLocalizationFacade.ActiveLocalizationCultures.Any()) { UpdateFormDefinitionWithActiveLocales(user, bindingsElement, placeHolderElements[1]); } string formDefinition = formDocument.GetDocumentAsString(); this.DeliverFormData( user.Username, StandardUiContainerTypes.Document, formDefinition, this.Bindings, clientValidationRules ); }
/// <exclude /> public GenericPublishProcessController() { _transitions = new Dictionary <string, IList <string> > { { Draft, new List <string> { AwaitingApproval, AwaitingPublication, Published } }, { AwaitingApproval, new List <string> { Draft, AwaitingPublication, Published } }, { AwaitingPublication, new List <string> { Draft, AwaitingApproval, Published } }, { Published, new List <string> { Draft, AwaitingApproval, AwaitingPublication } } }; _visualTransitions = new Dictionary <string, IList <string> > { { Draft, new List <string> { _draftDisabled, _forwardToAwaitingApproval, _forwardToAwaitingPublication, Published } }, { AwaitingApproval, new List <string> { Draft, _awaitingApprovalDisabled, _forwardToAwaitingPublication, Published } }, { AwaitingPublication, new List <string> { Draft, _backToAwaitingApproval, _awaitingPublicationDisabled, Published } }, { Published, new List <string>() } // when public, no "send to" available. }; _transitionNames = new Dictionary <string, string> { { Draft, ManagementStrings.PublishingStatus_draft }, { AwaitingApproval, ManagementStrings.PublishingStatus_awaitingApproval }, { AwaitingPublication, ManagementStrings.PublishingStatus_awaitingPublication }, { Published, ManagementStrings.PublishingStatus_published } }; Func <ElementAction> sendBackToDraftAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendToDraft) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendToDraft"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendToDraftToolTip"), Icon = GenericPublishProcessController.SendBackToDraft, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> sendForwardToAwaitingApprovalAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForApproval) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApproval"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApprovalToolTip"), Icon = GenericPublishProcessController.SendForwardForApproval, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> sendForwardToAwaitingPublicationAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForPublication) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublication"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublicationToolTip"), Icon = GenericPublishProcessController.SendForwardForPublication, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> publishAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Publish) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "Publish"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "PublishToolTip"), Icon = GenericPublishProcessController.Publish, Disabled = false, BulkExecutionDialog = new DialogStrings { Title = LocalizationFiles.Composite_Plugins_PageElementProvider.ViewUnpublishedItems_PublishConfirmTitle, Text = LocalizationFiles.Composite_Plugins_PageElementProvider.ViewUnpublishedItems_PublishConfirmText }, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup, ActionBundle = "Publish" } }, TagValue = BulkPublishingCommandsTag }; // "arrow pointing left when state change is going backwards" actions Func <ElementAction> sendBackToAwaitingApprovalAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForApproval) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApproval"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApprovalToolTip"), Icon = GenericPublishProcessController.SendForwardForApproval, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> sendBackToAwaitingPublicationAction = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForPublication) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublication"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublicationToolTip"), Icon = GenericPublishProcessController.SendForwardForApproval, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag, }; // disabled actions Func <ElementAction> draftActionDisabled = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendToDraft) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendToDraft"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendToDraftToolTip"), Icon = GenericPublishProcessController.SendBackToDraft, Disabled = true, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> awaitingApprovalActionDisabled = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForApproval) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApproval"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForApprovalToolTip"), Icon = GenericPublishProcessController.SendForwardForApproval, Disabled = true, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> awaitingPublicationActionDisabled = () => new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.SendForPublication) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublication"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "SendForPublicationToolTip"), Icon = GenericPublishProcessController.SendBackForPublication, Disabled = true, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; Func <ElementAction> publishActionDisabled = () => new ElementAction(new ActionHandle(new DisabledActionToken())) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "Publish"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "PublishToolTip"), Icon = GenericPublishProcessController.Publish, Disabled = true, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } }, TagValue = BulkPublishingCommandsTag }; _visualTransitionsActions = new Dictionary <string, Func <ElementAction> > { { Draft, sendBackToDraftAction }, { _backToAwaitingApproval, sendBackToAwaitingApprovalAction }, { _backToAwaitingPublication, sendBackToAwaitingPublicationAction }, { _forwardToAwaitingApproval, sendForwardToAwaitingApprovalAction }, { _forwardToAwaitingPublication, sendForwardToAwaitingPublicationAction }, { Published, publishAction }, { _draftDisabled, draftActionDisabled }, { _awaitingApprovalDisabled, awaitingApprovalActionDisabled }, { _awaitingPublicationDisabled, awaitingPublicationActionDisabled }, { _publishedDisabled, publishActionDisabled } }; }
public async Task <ConsoleSearchResult> QueryAsync(ConsoleSearchQuery query) { if (_searchProvider == null || query == null) { return(null); } Thread.CurrentThread.CurrentCulture = UserSettings.CultureInfo; Thread.CurrentThread.CurrentUICulture = UserSettings.C1ConsoleUiLanguage; var documentSources = _docSourceProviders.SelectMany(dsp => dsp.GetDocumentSources()).ToList(); var allFields = documentSources.SelectMany(ds => ds.CustomFields).ToList(); var facetFields = RemoveDuplicateKeys( allFields .Where(f => f.FacetedSearchEnabled && f.Label != null), f => f.Name).ToList(); if (string.IsNullOrEmpty(query.Text)) { return(new ConsoleSearchResult { QueryText = string.Empty, FacetFields = EmptyFacetsFromSelections(query, facetFields), TotalHits = 0 }); } var selections = new List <SearchQuerySelection>(); if (query.Selections != null) { foreach (var selection in query.Selections) { string fieldName = ExtractFieldName(selection.FieldName); var field = allFields.Where(f => f.Facet != null) .FirstOrDefault(f => f.Name == fieldName); Verify.IsNotNull(field, $"Failed to find a facet field by name '{fieldName}'"); selections.Add(new SearchQuerySelection { FieldName = fieldName, Values = selection.Values, Operation = field.Facet.FacetType == FacetType.SingleValue ? SearchQuerySelectionOperation.Or : SearchQuerySelectionOperation.And }); } } var sortOptions = new List <SearchQuerySortOption>(); if (!string.IsNullOrEmpty(query.SortBy)) { string sortByFieldName = ExtractFieldName(query.SortBy); var sortTermsAs = allFields .Where(f => f.Name == sortByFieldName && f.Preview != null && f.Preview.Sortable) .Select(f => f.Preview.SortTermsAs) .FirstOrDefault(); sortOptions.Add(new SearchQuerySortOption(sortByFieldName, query.SortInReverseOrder, sortTermsAs)); } var culture = !string.IsNullOrEmpty(query.CultureName) ? new CultureInfo(query.CultureName) : UserSettings.ActiveLocaleCultureInfo; var searchQuery = new SearchQuery(query.Text, culture) { Facets = facetFields.Select(f => new KeyValuePair <string, DocumentFieldFacet>(f.Name, f.Facet)).ToList(), Selection = selections, SortOptions = sortOptions }; searchQuery.FilterByUser(UserSettings.Username); searchQuery.AddFieldFacet(DocumentFieldNames.Source); var result = await _searchProvider.SearchAsync(searchQuery); var items = result.Items.Evaluate(); if (!items.Any()) { return(new ConsoleSearchResult { QueryText = query.Text, FacetFields = EmptyFacetsFromSelections(query, facetFields), TotalHits = 0 }); } var documents = items.Select(m => m.Document); HashSet <string> dataSourceNames; Facet[] dsFacets; if (result.Facets != null && result.Facets.TryGetValue(DocumentFieldNames.Source, out dsFacets)) { dataSourceNames = new HashSet <string>(dsFacets.Select(v => v.Value)); } else { Log.LogWarning(nameof(ConsoleSearchRpcService), "The search provider did not return the list of document sources"); dataSourceNames = new HashSet <string>(documents.Select(d => d.Source).Distinct()); } var dataSources = documentSources.Where(d => dataSourceNames.Contains(d.Name)).ToList(); var previewFields = RemoveDuplicateKeys( dataSources .SelectMany(ds => ds.CustomFields) .Where(f => f.FieldValuePreserved), f => f.Name).ToList(); return(new ConsoleSearchResult { QueryText = query.Text, Columns = previewFields.Select(pf => new ConsoleSearchResultColumn { FieldName = MakeFieldNameJsFriendly(pf.Name), Label = StringResourceSystemFacade.ParseString(pf.Label), Sortable = pf.Preview.Sortable }).ToArray(), Rows = documents.Select(doc => new ConsoleSearchResultRow { Label = doc.Label, Url = GetFocusUrl(doc.SerializedEntityToken), Values = GetPreviewValues(doc, previewFields) }).ToArray(), FacetFields = GetFacets(result, facetFields), TotalHits = result.TotalHits }); }
/// <exclude /> public List <ElementAction> GetActions(IData data, Type elementProviderType) { if (!(data is IPublishControlled) || !data.DataSourceId.DataScopeIdentifier.Equals(DataScopeIdentifier.Administrated)) { return(new List <ElementAction>()); } if (data is ILocalizedControlled && !UserSettings.ActiveLocaleCultureInfo.Equals(data.DataSourceId.LocaleScope)) { return(new List <ElementAction>()); } var publishControlled = (IPublishControlled)data; IList <string> visualTrans; if (!_visualTransitions.TryGetValue(publishControlled.PublicationStatus, out visualTrans)) { throw new InvalidOperationException($"Unknown publication state '{publishControlled.PublicationStatus}'"); } var clientActions = visualTrans.Select(newState => _visualTransitionsActions[newState]()).ToList(); IData publicData = DataFacade.GetDataFromOtherScope(data, DataScopeIdentifier.Public, true, false).FirstOrDefault(); if (publicData != null) { var unpublishAction = new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Unpublish) { DoIgnoreEntityTokenLocking = true })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "Unpublish"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UnpublishToolTip"), Icon = GenericPublishProcessController.Unpublish, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } } }; clientActions.Add(unpublishAction); if (publishControlled.PublicationStatus == Draft) { if (ProcessControllerAttributesFacade.IsActionIgnored(elementProviderType, GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges) == false) { ActionToken actionToken; IActionTokenProvider actionTokenProvider = ProcessControllerAttributesFacade.GetActionTokenProvider(elementProviderType, GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges); if (actionTokenProvider != null) { actionToken = actionTokenProvider.GetActionToken(GenericPublishProcessControllerActionTypeNames.UndoUnpublishedChanges, data); } else { actionToken = new UndoPublishedChangesActionToken(); } var undoPublishedChangesAction = new ElementAction(new ActionHandle(actionToken)) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UndoPublishedChanges"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "UndoPublishedChangesToolTip"), Icon = GenericPublishProcessController.UndoUnpublishedChanges, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Other, IsInFolder = false, IsInToolbar = true, ActionGroup = WorkflowActionGroup } } }; clientActions.Add(undoPublishedChangesAction); } } } return(clientActions); }
protected void Page_Load(object sender, EventArgs e) { string functionName = Request.QueryString["Name"]; bool isWidget = bool.Parse(Request.QueryString["IsWidget"] ?? "false"); this.PageLabel = functionName; IMetaFunction function = isWidget ? FunctionFacade.GetWidgetFunction(functionName) : (IMetaFunction)FunctionFacade.GetFunction(functionName); var functionDescriptors = new XElement("ul", new XAttribute("id", "functionList")); XElement descriptionElement = null; XElement parametersTable = null; XNamespace functionNamespace = FunctionTreeConfigurationNames.NamespaceName; var codeElement = new XElement(functionNamespace + (isWidget ? "widgetfunction" : "function"), new XAttribute("name", functionName), new XAttribute(XNamespace.Xmlns + "f", FunctionTreeConfigurationNames.NamespaceName)); if (!string.IsNullOrEmpty(function.Description)) { descriptionElement = new XElement("div", new XAttribute("class", "description"), StringResourceSystemFacade.ParseString(function.Description)); } if (function.ParameterProfiles.Any()) { parametersTable = new XElement("table", new XAttribute("class", "parameters")); foreach (ParameterProfile parameterProfile in function.ParameterProfiles) { string helpText = parameterProfile.HelpDefinition.GetLocalized().HelpText; if (!string.IsNullOrEmpty(helpText)) { helpText = string.Format(" {0}", helpText); } var parameterRow = new XElement("tr", new XAttribute("title", parameterProfile.LabelLocalized), new XElement("td", new XAttribute("class", string.Format("requiredInfo required{0}", parameterProfile.IsRequired))), new XElement("td", new XAttribute("class", "name"), parameterProfile.Name), new XElement("td", new XAttribute("class", "type"), new XElement("span", new XAttribute("class", "typeinfo"), parameterProfile.Type.GetShortLabel())), new XElement("td", new XAttribute("class", "description"), helpText ) ); parametersTable.Add(parameterRow); var codeParameter = new XElement(functionNamespace + "param", new XAttribute("name", parameterProfile.Name)); string value = parameterProfile.IsRequired ? "[Required Value]" : "[Optional Value]"; if (parameterProfile.Type.IsPrimitive || parameterProfile.Type == typeof(string) || parameterProfile.Type == typeof(Guid)) { codeParameter.Add(new XAttribute("value", value)); } else { codeParameter.Add(value); } codeParameter.Add(new XAttribute(XNamespace.Xmlns + "f", FunctionTreeConfigurationNames.NamespaceName)); codeElement.Add(codeParameter); } } var functionDescriptor = new XElement("li", new XElement("div", new XAttribute("class", "header"), functionName, new XElement("span", new XAttribute("class", "typeinfo"), " ← " + function.ReturnType.GetShortLabel())), descriptionElement, parametersTable ); functionDescriptors.Add(functionDescriptor); var hans = new XElement("div", functionDescriptors); hans.Add(new XElement("div", new XAttribute("style", "padding-left: 45px"), new XElement("div", new XAttribute("style", "font-weight: bold"), "Function Markup"), new XElement("div", new XAttribute("style", "padding-left: 10px"), new XElement("pre", codeElement.ToString(SaveOptions.OmitDuplicateNamespaces))) )); functionInfoPlaceholder.Controls.Add(new LiteralControl(hans.ToString(SaveOptions.DisableFormatting))); }
public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer) { DataEntityToken token = (DataEntityToken)entityToken; IPublishControlled publishControlled = (IPublishControlled)DataFacade.GetDataFromDataSourceId(token.DataSourceId); ValidationResults validationResults = ValidationFacade.Validate((IData)publishControlled); if (validationResults.IsValid) { UpdateTreeRefresher treeRefresher = new UpdateTreeRefresher(token.Data.GetDataEntityToken(), flowControllerServicesContainer); if (actionToken is PublishActionToken) { publishControlled.PublicationStatus = Published; } else if (actionToken is DraftActionToken) { publishControlled.PublicationStatus = Draft; } else if (actionToken is AwaitingApprovalActionToken) { publishControlled.PublicationStatus = AwaitingApproval; } else if (actionToken is AwaitingPublicationActionToken) { publishControlled.PublicationStatus = AwaitingPublication; } else if (actionToken is UnpublishActionToken) { publishControlled.PublicationStatus = Draft; using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope()) { IData data = DataFacade.GetDataFromOtherScope(token.Data, DataScopeIdentifier.Public).SingleOrDefault(); if (data != null) { IPage page = data as IPage; if (page != null) { IEnumerable <IData> referees; using (new DataScope(DataScopeIdentifier.Public)) { referees = page.GetMetaData(); } DataFacade.Delete(referees, CascadeDeleteType.Disable); } DataFacade.Delete(data, CascadeDeleteType.Disable); } transactionScope.Complete(); } } else if (actionToken is UndoPublishedChangesActionToken) { using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope()) { using (ProcessControllerFacade.NoProcessControllers) { var administrativeData = (IPublishControlled)token.Data; IData publishedData = DataFacade.GetDataFromOtherScope(token.Data, DataScopeIdentifier.Public).Single(); publishedData.FullCopyChangedTo(administrativeData); administrativeData.PublicationStatus = Draft; DataFacade.Update(administrativeData); } transactionScope.Complete(); } } else { throw new ArgumentException("Unknown action token", "actionToken"); } DataFacade.Update(publishControlled); treeRefresher.PostRefreshMesseges(publishControlled.GetDataEntityToken()); } else { var managementConsoleMessageService = flowControllerServicesContainer.GetService <IManagementConsoleMessageService>(); StringBuilder sb = new System.Text.StringBuilder(); sb.AppendLine(StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "ValidationErrorMessage")); foreach (ValidationResult result in validationResults) { sb.AppendLine(result.Message); } managementConsoleMessageService.ShowMessage(DialogType.Error, StringResourceSystemFacade.GetString("Composite.Plugins.GenericPublishProcessController", "ValidationErrorTitle"), sb.ToString()); } return(null); }
private Element CreateXmlFunctionInfoElement(INamespaceTreeBuilderLeafInfo leafInfo, string connectionId) { var element = new Element(_context.CreateElementHandle(((SqlNamespaceTreeBuilderLeafInfo)leafInfo).EntityToken)) { VisualData = new ElementVisualizedData { Label = leafInfo.Name, ToolTip = leafInfo.Name, HasChildren = false, Icon = SqlFunctionElementProvider.Function } }; element.AddAction( new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.SqlFunctionElementProvider.EditSqlFunctionProviderWorkflow"), new PermissionType[] { PermissionType.Edit } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.EditQuery"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.EditQueryToolTip"), Icon = SqlFunctionElementProvider.EditFunction, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction( new ElementAction(new ActionHandle( new WorkflowActionToken( WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.SqlFunctionElementProvider.DeleteSqlFunctionProviderWorkflow"), new PermissionType[] { PermissionType.Delete } ))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.DeleteQuery"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.SqlFunction", "SqlFunctionElementProvider.DeleteQueryToolTip"), Icon = SqlFunctionElementProvider.DeleteFunction, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); return(element); }
/// <exclude /> public void AttachElementActions(IEnumerable <Element> elements) { foreach (Element element in elements) { DataEntityToken dataEntityToken = element.ElementHandle.EntityToken as DataEntityToken; if (dataEntityToken != null) { element.AddAction( new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.VisualFunctionElementProviderHelper.AddVisualFunctionWorkflow")))) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.AddNewLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.AddNewToolTip"), Icon = this.AddRenderingFunctionIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = false, ActionGroup = AppendedActionGroup } } }); if (GetRenderingFunctions(dataEntityToken.Data.DataSourceId.InterfaceType).Count() > 0) { element.AddAction( new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.VisualFunctionElementProviderHelper.SelectVisualFunctionWorkflow")) { Payload = "Edit" })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.EditLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.EditToolTip"), Icon = this.EditRenderingFunctionIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = false, ActionGroup = AppendedActionGroup } } }); element.AddAction( new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.VisualFunctionElementProviderHelper.SelectVisualFunctionWorkflow")) { Payload = "Delete" })) { VisualData = new ActionVisualizedData { Label = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.DeleteLabel"), ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.VisualFunction", "VisualFunctionElementProviderHelper.DeleteToolTip"), Icon = this.DeleteRenderingFunctionIcon, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = true, ActionGroup = AppendedActionGroup } } }); } } } }
private List <Element> GetElements(List <KeyValuePair <PageLocaleState, IPage> > pages, bool rootPages) { //ElementDragAndDropInfo dragAndDropInfo = new ElementDragAndDropInfo(typeof(IPage)); //dragAndDropInfo.AddDropType(typeof(IPage)); //dragAndDropInfo.SupportsIndexedPosition = true; string editPageLabel = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.EditPage"); string editPageToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.EditPageToolTip"); string localizePageLabel = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.LocalizePage"); string localizePageToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.LocalizePageToolTip"); string addNewPageLabel = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddSubPage"); string addNewPageToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddSubPageToolTip"); string deletePageLabel = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.Delete"); string deletePageToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DeleteToolTip"); string urlMappingName = null; if (UserSettings.ForeignLocaleCultureInfo != null) { urlMappingName = DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo); } var elements = new Element[pages.Count]; ParallelFacade.For("PageElementProvider. Getting elements", 0, pages.Count, i => { var kvp = pages[i]; IPage page = kvp.Value; EntityToken entityToken = page.GetDataEntityToken(); var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IPage)); dragAndDropInfo.AddDropType(typeof(IPage)); dragAndDropInfo.SupportsIndexedPosition = true; var element = new Element(_context.CreateElementHandle(entityToken), MakeVisualData(page, kvp.Key, urlMappingName, rootPages), dragAndDropInfo); element.PropertyBag.Add("Uri", "~/page({0})".FormatWith(page.Id)); element.PropertyBag.Add("ElementType", "application/x-composite-page"); element.PropertyBag.Add("DataId", page.Id.ToString()); if (kvp.Key == PageLocaleState.Own) { // Normal actions element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, EditPermissionTypes))) { VisualData = new ActionVisualizedData { Label = editPageLabel, ToolTip = editPageToolTip, Icon = PageElementProvider.EditPage, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Add, AddPermissionTypes))) { VisualData = new ActionVisualizedData { Label = addNewPageLabel, ToolTip = addNewPageToolTip, Icon = PageElementProvider.AddPage, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Add, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Delete, DeletePermissionTypes))) { VisualData = new ActionVisualizedData { Label = deletePageLabel, ToolTip = deletePageToolTip, Icon = DeletePage, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Delete, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); _pageAssociatedHelper.AttachElementActions(element, page); } else if (kvp.Key == PageLocaleState.ForeignActive) { // Localized actions bool addAction = false; Guid parentId = page.GetParentId(); if (parentId == Guid.Empty) { addAction = true; } else { using (new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo)) { bool exists = DataFacade.GetData <IPage>(f => f.Id == parentId).Any(); if (exists) { addAction = true; } } } if (addAction) { element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageElementProvider.LocalizePageWorkflow"), LocalizePermissionTypes))) { VisualData = new ActionVisualizedData { Label = localizePageLabel, ToolTip = localizePageToolTip, Icon = PageElementProvider.LocalizePage, Disabled = false, ActionLocation = new ActionLocation { ActionType = ActionType.Edit, IsInFolder = false, IsInToolbar = true, ActionGroup = PrimaryActionGroup } } }); } } elements[i] = element; }); return(new List <Element>(elements)); }
private static string GetLocalizedText(string key) { return(StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", key)); }