public string GetSystemFormRelativeUrl(string entityName, Guid formId, int formType) { switch (formType) { case (int)SystemForm.Schema.OptionSets.type.InteractionCentricDashboard_10: return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&extraqs=%26formId%3d%7b{formId}%7d%26dashboardType%3d1032&pagetype=icdashboardeditor"); case (int)SystemForm.Schema.OptionSets.type.Dashboard_0: return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&extraqs=%26formId%3d%7b{formId}%7d%26dashboardType%3d1030&pagetype=dashboardeditor"); case (int)SystemForm.Schema.OptionSets.type.Mobile_Express_5: return($"/m/Console/EntityConfig.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&etn={entityName}&formid=%7b{formId}%7d"); default: if ((this.EntitiesIntellisenseData?.Entities?.ContainsKey(entityName)).GetValueOrDefault()) { string formTypeString = SystemFormRepository.GetFormTypeString(formType); if (!string.IsNullOrEmpty(formTypeString)) { var linkedEntityObjectCode = this.EntitiesIntellisenseData.Entities[entityName].ObjectTypeCode; if (linkedEntityObjectCode.HasValue) { return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&etc={linkedEntityObjectCode}&extraqs=formtype%3d{formTypeString}%26formId%3d{formId}%26action%3d-1&pagetype=formeditor"); } } } break; } return(null); }
private async Task <bool> ValidateDocumentSystemFormXml(ConnectionData connectionData, XDocument doc) { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ValidatingXmlForFieldFormat1, SystemForm.Schema.Attributes.formxml); ContentComparerHelper.ClearRoot(doc); bool validateResult = await SystemFormRepository.ValidateXmlDocumentAsync(connectionData, _iWriteToOutput, doc); if (!validateResult) { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.ValidatingXmlForFieldFailedFormat1, SystemForm.Schema.Attributes.formxml); _iWriteToOutput.ActivateOutputWindow(connectionData); var dialogResult = MessageBoxResult.Cancel; var thread = new Thread(() => { dialogResult = MessageBox.Show(Properties.MessageBoxStrings.ContinueOperation, Properties.MessageBoxStrings.QuestionTitle, MessageBoxButton.OKCancel, MessageBoxImage.Question); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); if (dialogResult != MessageBoxResult.OK) { return(false); } } return(true); }
private async Task GettingSystemFormCurrentAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, Guid formId, ActionOnComponent actionOnComponent, string fieldName, string fieldTitle) { var repositorySystemForm = new SystemFormRepository(service); var systemForm = await repositorySystemForm.GetByIdAsync(formId, ColumnSetInstances.AllColumns); if (actionOnComponent == ActionOnComponent.SingleXmlField) { if (string.Equals(fieldName, SystemForm.Schema.Attributes.formxml, StringComparison.InvariantCultureIgnoreCase)) { GetCurrentSystemFormXml(service, commonConfig, systemForm); } } else if (actionOnComponent == ActionOnComponent.SingleField) { if (string.Equals(fieldName, SystemForm.Schema.Attributes.formjson, StringComparison.InvariantCultureIgnoreCase)) { GetCurrentSystemFormJson(service, commonConfig, systemForm); } } else if (actionOnComponent == ActionOnComponent.EntityDescription) { await GetCurrentEntityDescription(service, commonConfig, systemForm); } else if (actionOnComponent == ActionOnComponent.Description) { await GetCurrentFormDescription(service, commonConfig, systemForm); } }
protected override async Task <List <SystemForm> > GetSystemFormAsync(IOrganizationServiceExtented service) { List <SystemForm> result = new List <SystemForm>(); var descriptor = new SolutionComponentDescriptor(service); var repository = new SystemFormRepository(service); var imageComponents = _solutionImage.Components.Where(c => c.ComponentType == (int)ComponentType.SystemForm); if (imageComponents.Any()) { var solutionComponents = await descriptor.GetSolutionComponentsListAsync(imageComponents); if (solutionComponents.Any()) { var tempList = await repository.GetListByIdListAsync(solutionComponents.Select(s => s.ObjectId.Value), new ColumnSet(true)); result.AddRange(tempList); } } var hashSet = new HashSet <Guid>(result.Select(c => c.Id)); imageComponents = _solutionImage.Components.Where(c => c.ComponentType == (int)ComponentType.Entity); if (imageComponents.Any()) { var solutionComponents = await descriptor.GetSolutionComponentsListAsync(imageComponents); if (solutionComponents.Any()) { var entities = solutionComponents .Where(c => c.RootComponentBehaviorEnum.GetValueOrDefault(SolutionComponent.Schema.OptionSets.rootcomponentbehavior.Include_Subcomponents_0) == SolutionComponent.Schema.OptionSets.rootcomponentbehavior.Include_Subcomponents_0 && c.ObjectId.HasValue) .Select(e => descriptor.MetadataSource.GetEntityMetadata(e.ObjectId.Value)) .Where(e => e != null) .Select(e => e.LogicalName) .ToArray(); if (entities.Any()) { var tempList = await repository.GetListForEntitiesAsync(entities, new ColumnSet(true)); foreach (var item in tempList) { if (hashSet.Add(item.Id)) { result.Add(item); } } } } } return(result); }
private async Task CopingToClipboardSystemFormCurrentTabsAndSections(IOrganizationServiceExtented service, CommonConfiguration commonConfig, JavaScriptObjectType jsObjectType, string entityName, Guid formId, int formType) { var repositorySystemForm = new SystemFormRepository(service); var systemForm = await repositorySystemForm.GetByIdAsync(formId, ColumnSetInstances.AllColumns); string formXml = systemForm.FormXml; if (string.IsNullOrEmpty(formXml)) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionEntityFieldIsEmptyFormat4, service.ConnectionData.Name, SystemForm.Schema.EntityLogicalName, systemForm.Name, SystemForm.Schema.Headers.formxml); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); return; } try { var fileGenerationOptions = FileGenerationConfiguration.GetFileGenerationOptions(); var config = new CreateFileJavaScriptConfiguration(fileGenerationOptions); var doc = XElement.Parse(formXml); var descriptor = new SolutionComponentDescriptor(service); descriptor.SetSettings(commonConfig); var handler = new FormDescriptionHandler(descriptor, new DependencyRepository(service)); FormInformation formInfo = handler.GetFormInformation(doc); var stringBuilder = new StringBuilder(); using (var writer = new StringWriter(stringBuilder)) { var handlerCreate = new CreateFormTabsJavaScriptHandler(writer, config, jsObjectType, service); handlerCreate.WriteContentOnlyForm(formInfo); } ClipboardHelper.SetText(stringBuilder.ToString().Trim(' ', '\r', '\n')); this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.CopyingEntityJavaScriptContentOnFormCompletedFormat2, systemForm.ObjectTypeCode, systemForm.Name); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); service.TryDispose(); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } }
private async Task <Tuple <bool, SystemForm> > GetSystemFormByAttribute(IOrganizationServiceExtented service, CommonConfiguration commonConfig, string systemFormId) { var repositorySystemForm = new SystemFormRepository(service); var systemForm = await repositorySystemForm.GetByIdAsync(Guid.Parse(systemFormId), ColumnSetInstances.AllColumns); if (systemForm == null) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, Properties.OutputStrings.InConnectionSystemFormWasNotFoundFormat2, service.ConnectionData.Name, systemFormId); this._iWriteToOutput.ActivateOutputWindow(service.ConnectionData); WindowHelper.OpenSystemFormExplorer(_iWriteToOutput, service, commonConfig, systemFormId); } return(Tuple.Create(systemForm != null, systemForm)); }
private async Task CheckingUnknownFormControlType(ConnectionData connectionData, CommonConfiguration commonConfig) { var service = await ConnectAndWriteToOutputAsync(connectionData); if (service == null) { return; } StringBuilder content = new StringBuilder(); content.AppendLine(Properties.OutputStrings.ConnectingToCRM); content.AppendLine(connectionData.GetConnectionDescription()); content.AppendFormat(Properties.OutputStrings.CurrentServiceEndpointFormat1, service.CurrentServiceEndpoint).AppendLine(); Dictionary <string, FormatTextTableHandler> dictUnknownControls = new Dictionary <string, FormatTextTableHandler>(StringComparer.InvariantCultureIgnoreCase); var descriptor = new SolutionComponentDescriptor(service); var handler = new FormDescriptionHandler(descriptor, new DependencyRepository(service)); var repositorySystemForm = new SystemFormRepository(service); var formList = await repositorySystemForm.GetListAsync(null, null, new ColumnSet(true)); foreach (var systemForm in formList .OrderBy(f => f.ObjectTypeCode) .ThenBy(f => f.Type?.Value) .ThenBy(f => f.Name) ) { string formXml = systemForm.FormXml; if (!string.IsNullOrEmpty(formXml)) { XElement doc = XElement.Parse(formXml); var tabs = handler.GetFormTabs(doc); var unknownControls = tabs.SelectMany(t => t.Sections).SelectMany(s => s.Controls).Where(c => c.GetControlType() == FormControl.FormControlType.UnknownControl); foreach (var control in unknownControls) { if (!dictUnknownControls.ContainsKey(control.ClassId)) { FormatTextTableHandler tableUnknownControls = new FormatTextTableHandler(); tableUnknownControls.SetHeader("Entity", "FormType", "Form", "State", "Attribute", "Form Url"); dictUnknownControls[control.ClassId] = tableUnknownControls; } dictUnknownControls[control.ClassId].AddLine( systemForm.ObjectTypeCode , systemForm.FormattedValues[SystemForm.Schema.Attributes.type] , systemForm.Name , systemForm.FormattedValues[SystemForm.Schema.Attributes.formactivationstate] , control.Attribute , service.UrlGenerator.GetSolutionComponentUrl(ComponentType.SystemForm, systemForm.Id) ); } } } if (dictUnknownControls.Count > 0) { content.AppendLine().AppendLine(); content.AppendFormat("Unknown Form Control Types: {0}", dictUnknownControls.Count); foreach (var classId in dictUnknownControls.Keys.OrderBy(s => s)) { content.AppendLine().AppendLine(); content.AppendLine(classId); var tableUnknownControls = dictUnknownControls[classId]; foreach (var str in tableUnknownControls.GetFormatedLines(false)) { content.AppendLine(_tabSpacer + str); } } commonConfig.CheckFolderForExportExists(this._iWriteToOutput); string fileName = string.Format("{0}.Checking Unknown Form Control Types at {1}.txt" , connectionData.Name , DateTime.Now.ToString("yyyy.MM.dd HH-mm-ss") ); string filePath = Path.Combine(commonConfig.FolderForExport, FileOperations.RemoveWrongSymbols(fileName)); File.WriteAllText(filePath, content.ToString(), new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(connectionData, "Unknown Form Control Types were exported to {0}", filePath); this._iWriteToOutput.PerformAction(service.ConnectionData, filePath); } else { this._iWriteToOutput.WriteToOutput(connectionData, "No Unknown Form Control Types in CRM were founded."); this._iWriteToOutput.ActivateOutputWindow(connectionData); } }
private async Task <string> CreateFormsEventsFile(IOrganizationServiceExtented service, string fileFolder, string fileNameFormat, string connectionDataName, bool onlyWithFormLibraries) { this._iWriteToOutput.WriteToOutput(service.ConnectionData, "Start analyzing System Forms."); var repository = new SystemFormRepository(service); var allForms = (await repository.GetListAsync()) .OrderBy(ent => ent.ObjectTypeCode) .ThenBy(ent => ent.Type.Value) .ThenBy(ent => ent.Name) ; SolutionComponentDescriptor descriptor = new SolutionComponentDescriptor(service); var handler = new FormDescriptionHandler(descriptor, new DependencyRepository(service)); StringBuilder content = new StringBuilder(); foreach (var systemForm in allForms) { string entityName = systemForm.ObjectTypeCode; string name = systemForm.Name; string typeName = systemForm.FormattedValues[SystemForm.Schema.Attributes.type]; string formXml = systemForm.FormXml; if (!string.IsNullOrEmpty(formXml)) { XElement doc = XElement.Parse(formXml); string events = handler.GetEventsDescription(doc); if (!string.IsNullOrEmpty(events)) { string desc = handler.GetFormLibrariesDescription(doc); if (onlyWithFormLibraries && string.IsNullOrEmpty(desc)) { continue; } if (content.Length > 0) { content .AppendLine() .AppendLine(new string('-', 100)) .AppendLine() ; } content.AppendFormat("Entity: {0}", entityName).AppendLine(); content.AppendFormat("Form Type: {0}", typeName).AppendLine(); content.AppendFormat("Form Name: {0}", name).AppendLine(); if (!string.IsNullOrEmpty(desc)) { content.AppendLine("FormLibraries:"); content.Append(desc); } content.AppendLine("Events:"); content.AppendLine(events); } } } string filePath = string.Empty; if (content.Length > 0) { string fileName = string.Format("{0}{1} {2}.txt" , (!string.IsNullOrEmpty(connectionDataName) ? connectionDataName + "." : string.Empty) , fileNameFormat.Trim() , EntityFileNameFormatter.GetDateString() ); filePath = Path.Combine(fileFolder, FileOperations.RemoveWrongSymbols(fileName)); if (!Directory.Exists(fileFolder)) { Directory.CreateDirectory(fileFolder); } File.WriteAllText(filePath, content.ToString(), new UTF8Encoding(false)); this._iWriteToOutput.WriteToOutput(service.ConnectionData, "System Forms Events were exported to {0}", filePath); } else { this._iWriteToOutput.WriteToOutput(service.ConnectionData, "No Forms Events were founded."); } return(filePath); }
private string GetSolutionComponentRelativeUrl(ComponentType componentType, Guid objectId) { switch (componentType) { case ComponentType.SavedQueryVisualization: { var respositorySolution = new SolutionRepository(this._service); var chart = _service.RetrieveByQuery <SavedQueryVisualization>(SavedQueryVisualization.EntityLogicalName, objectId, new ColumnSet(SavedQueryVisualization.Schema.Attributes.primaryentitytypecode)); if (chart != null && !string.IsNullOrEmpty(chart.PrimaryEntityTypeCode)) { if ((this._service.ConnectionData.IntellisenseData?.Entities?.ContainsKey(chart.PrimaryEntityTypeCode)).GetValueOrDefault()) { var linkedEntityObjectCode = this._service.ConnectionData.IntellisenseData.Entities[chart.PrimaryEntityTypeCode].ObjectTypeCode; if (linkedEntityObjectCode.HasValue) { return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&extraqs=etc%3d{linkedEntityObjectCode}%26id%3d%7b{objectId}%7d&pagetype=vizdesigner"); } } } } break; case ComponentType.SystemForm: { var respositorySolution = new SolutionRepository(this._service); var systemform = _service.RetrieveByQuery <SystemForm>(SystemForm.EntityLogicalName, objectId, new ColumnSet(SystemForm.Schema.Attributes.type, SystemForm.Schema.Attributes.objecttypecode)); if (systemform != null && systemform.Type != null) { switch (systemform.Type.Value) { case (int)SystemForm.Schema.OptionSets.type.InteractionCentricDashboard_10: return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&extraqs=%26formId%3d%7b{systemform.Id}%7d%26dashboardType%3d1032&pagetype=icdashboardeditor"); case (int)SystemForm.Schema.OptionSets.type.Dashboard_0: return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&extraqs=%26formId%3d%7b{systemform.Id}%7d%26dashboardType%3d1030&pagetype=dashboardeditor"); case (int)SystemForm.Schema.OptionSets.type.Mobile_Express_5: return($"/m/Console/EntityConfig.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&etn={systemform.ObjectTypeCode}&formid=%7b{systemform.Id}%7d"); case (int)SystemForm.Schema.OptionSets.type.Task_Flow_Form_9: { var workflowRepository = new WorkflowRepository(_service); var linkedWorkflow = workflowRepository.FindLinkedWorkflow(systemform.Id, new ColumnSet(false)); if (linkedWorkflow != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.Workflow, linkedWorkflow.Id)); } } break; default: if ((this._service.ConnectionData.IntellisenseData?.Entities?.ContainsKey(systemform.ObjectTypeCode)).GetValueOrDefault()) { string formtype = SystemFormRepository.GetFormTypeString(systemform.Type?.Value); if (!string.IsNullOrEmpty(formtype)) { var linkedEntityObjectCode = this._service.ConnectionData.IntellisenseData.Entities[systemform.ObjectTypeCode].ObjectTypeCode; if (linkedEntityObjectCode.HasValue) { return($"/main.aspx?appSolutionId=%7b{Solution.Schema.InstancesUniqueId.DefaultId}%7d&etc={linkedEntityObjectCode}&extraqs=formtype%3d{formtype}%26formId%3d{systemform.Id}%26action%3d-1&pagetype=formeditor"); } } } break; } } } break; case ComponentType.SiteMap: { var respositorySolution = new SolutionRepository(this._service); //designer/sitemap/FD140AAF-4DF4-11DD-BD17-0019B9312238/39983702-960A-E711-80DD-00155D018C04#/SiteMapHome/39983702-960a-e711-80dd-00155d018c04 return($"/designer/sitemap/{Solution.Schema.InstancesUniqueId.DefaultId}/{objectId}#/SiteMapHome/{objectId}"); } break; case ComponentType.AttributeMap: { var attributeMap = _service.RetrieveByQuery <AttributeMap>(AttributeMap.EntityLogicalName, objectId, new ColumnSet(AttributeMap.Schema.Attributes.entitymapid)); if (attributeMap != null && attributeMap.EntityMapId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.EntityMap, attributeMap.EntityMapId.Id)); } } break; case ComponentType.DisplayStringMap: { var displayMap = _service.RetrieveByQuery <DisplayStringMap>(DisplayStringMap.EntityLogicalName, objectId, new ColumnSet(DisplayStringMap.Schema.Attributes.displaystringid)); if (displayMap != null && displayMap.DisplayStringId.HasValue) { return(this.GetSolutionComponentRelativeUrl(ComponentType.DisplayString, displayMap.DisplayStringId.Value)); } } break; case ComponentType.RolePrivileges: { var entity = _service.RetrieveByQuery <RolePrivileges>(RolePrivileges.EntityLogicalName, objectId, new ColumnSet(RolePrivileges.Schema.Attributes.roleid)); if (entity != null && entity.RoleId.HasValue) { return(this.GetSolutionComponentRelativeUrl(ComponentType.Role, entity.RoleId.Value)); } } break; case ComponentType.FieldPermission: { var entity = _service.RetrieveByQuery <FieldPermission>(FieldPermission.EntityLogicalName, objectId, new ColumnSet(FieldPermission.Schema.Attributes.fieldsecurityprofileid)); if (entity != null && entity.FieldSecurityProfileId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.FieldSecurityProfile, entity.FieldSecurityProfileId.Id)); } } break; case ComponentType.ReportEntity: { var entity = _service.RetrieveByQuery <ReportEntity>(ReportEntity.EntityLogicalName, objectId, new ColumnSet(ReportEntity.Schema.Attributes.reportid)); if (entity != null && entity.ReportId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.Report, entity.ReportId.Id)); } } break; case ComponentType.ReportCategory: { var entity = _service.RetrieveByQuery <ReportCategory>(ReportCategory.EntityLogicalName, objectId, new ColumnSet(ReportCategory.Schema.Attributes.reportid)); if (entity != null && entity.ReportId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.Report, entity.ReportId.Id)); } } break; case ComponentType.ReportVisibility: { var entity = _service.RetrieveByQuery <ReportVisibility>(ReportVisibility.EntityLogicalName, objectId, new ColumnSet(ReportVisibility.Schema.Attributes.reportid)); if (entity != null && entity.ReportId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.Report, entity.ReportId.Id)); } } break; case ComponentType.AppModule: { var respositorySolution = new SolutionRepository(this._service); // /designer/app/47FB3607-13DA-E811-8114-001DD8B71D68/7A536683-A60D-E811-8105-001DD8B71D68#/AppDesignerCanvas/7a536683-a60d-e811-8105-001dd8b71d68 return($"/designer/app/{Solution.Schema.InstancesUniqueId.DefaultId}/{objectId}#/AppDesignerCanvas/{objectId}"); } break; case ComponentType.AppModuleRoles: { var appModuleRoles = _service.RetrieveByQuery <AppModuleRoles>(AppModuleRoles.EntityLogicalName, objectId, new ColumnSet(AppModuleRoles.Schema.Attributes.appmoduleid)); if (appModuleRoles != null && appModuleRoles.AppModuleId != null) { return(this.GetSolutionComponentRelativeUrl(ComponentType.AppModule, appModuleRoles.AppModuleId.Id)); } } break; //case ComponentType.RibbonCommand: // return $""; //case ComponentType.RibbonContextGroup: // return $""; //case ComponentType.RibbonCustomization: // return $""; //case ComponentType.RibbonRule: // return $""; //case ComponentType.RibbonTabToCommandMap: // return $""; //case ComponentType.RibbonDiff: // return $""; //case ComponentType.SLAItem: // return $""; //case ComponentType.Relationship: // return $""; //case ComponentType.AttributePicklistValue: // return $""; //case ComponentType.AttributeLookupValue: // return $""; //case ComponentType.ViewAttribute: // return $""; //case ComponentType.LocalizedLabel: // return $""; //case ComponentType.RelationshipExtraCondition: // return $""; //case ComponentType.EntityRelationshipRole: // return $""; //case ComponentType.EntityRelationshipRelationships: // return $""; //case ComponentType.ManagedProperty: // return $""; //case ComponentType.Form: // return $""; //case ComponentType.Organization: // return $""; //case ComponentType.Attachment: // return $""; //case ComponentType.PluginType: // return $""; //case ComponentType.PluginAssembly: // return $""; //case ComponentType.SDKMessageProcessingStep: // return $""; //case ComponentType.SDKMessageProcessingStepImage: // return $""; //case ComponentType.ServiceEndpoint: // return $""; //case ComponentType.RoutingRule: // return $""; //case ComponentType.RoutingRuleItem: // return $""; //case ComponentType.ConvertRule: // return $""; //case ComponentType.ConvertRuleItem: // return $""; //case ComponentType.HierarchyRule: // return $""; //case ComponentType.MobileOfflineProfileItem: // return $""; //case ComponentType.SimilarityRule: // return $""; } return(this._service.ConnectionData.GetSolutionComponentRelativeUrl(componentType, objectId)); }