public static void UpdateProjectName(string solutionPath, string oldProjectUniqueName, string newProjectUniqueName)
        {
            CrmDexExConfig crmDexExConfig = ConfigFile.GetConfigFile(solutionPath);

            if (crmDexExConfig == null)
            {
                return;
            }

            bool updated = false;

            foreach (CrmDevExConfigOrgMap crmDevExConfigOrgMap in crmDexExConfig.CrmDevExConfigOrgMaps)
            {
                if (crmDevExConfigOrgMap.ProjectUniqueName.Equals(oldProjectUniqueName, StringComparison.InvariantCultureIgnoreCase))
                {
                    crmDevExConfigOrgMap.ProjectUniqueName = newProjectUniqueName;
                    updated = true;
                }
            }

            if (updated)
            {
                ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
            }
        }
예제 #2
0
        public static CrmDevExAssembly HandleMappings(string solutionPath, Project project, Guid organizationId, ObservableCollection <CrmSolution> solutions, ObservableCollection <CrmAssembly> assemblies)
        {
            CrmDexExConfig       crmDexExConfig       = CrmDeveloperExtensions2.Core.Config.Mapping.GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = CrmDeveloperExtensions2.Core.Config.Mapping.GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            CrmDevExAssembly crmDevExAssembly = crmDevExConfigOrgMap.Assembly;

            if (crmDevExAssembly == null)
            {
                return(null);
            }

            if (assemblies.Count(a => a.AssemblyId == crmDevExAssembly.AssemblyId) < 1)
            {
                crmDevExConfigOrgMap.Assembly = null;

                ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);

                return(null);
            }

            if (solutions.Count(s => s.SolutionId == crmDevExAssembly.SolutionId) >= 1)
            {
                return(crmDevExAssembly);
            }

            crmDevExAssembly.SolutionId = solutions[0].SolutionId; //Default

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);

            return(crmDevExAssembly);
        }
예제 #3
0
        public void CreateConfigFile()
        {
            CrmDexExConfig config1 = ConfigFile.CreateConfigFile(Guid.Empty, "TestProject", _testFilepath);

            CrmDexExConfig config2 = ConfigFile.GetConfigFile(_testFilepath);

            Assert.AreEqual(config1.CrmDevExConfigOrgMaps[0].OrganizationId, config2.CrmDevExConfigOrgMaps[0].OrganizationId);
        }
예제 #4
0
        public static void AddOrUpdateMapping(string solutionPath, Project project, CrmDevExSolutionPackage solutionPackage, Guid organizationId)
        {
            CrmDexExConfig crmDexExConfig = CoreMapping.GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = CoreMapping.GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            crmDevExConfigOrgMap.SolutionPackage = solutionPackage;

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
예제 #5
0
        public void UpdateConfigFile()
        {
            CrmDexExConfig config1 = ConfigFile.GetConfigFile(_testFilepath);

            ConfigFile.UpdateConfigFile(_testFilepath, config1);

            CrmDexExConfig config2 = ConfigFile.GetConfigFile(_testFilepath);

            Assert.AreEqual(config1.CrmDevExConfigOrgMaps[0].OrganizationId, config2.CrmDevExConfigOrgMaps[0].OrganizationId);
        }
        public static void RemoveMappings(string solutionPath, Project project, List <CrmDexExConfigWebResource> crmDexExConfigWebResources, Guid organizationId)
        {
            CrmDexExConfig       crmDexExConfig       = GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            crmDevExConfigOrgMap.WebResources.RemoveAll(
                w => crmDexExConfigWebResources.Any(m => m.WebResourceId == w.WebResourceId));

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
        private static void UpdateMapping(CrmDexExConfig crmDexExConfig, string solutionPath, Project project, WebResourceItem webResourceItem, Guid organizationId)
        {
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            List <CrmDexExConfigWebResource> crmDexExConfigWebResources = crmDevExConfigOrgMap.WebResources.Where(w => w.WebResourceId == webResourceItem.WebResourceId).ToList();

            crmDexExConfigWebResources.ForEach(w => w.File = webResourceItem.BoundFile);
            crmDevExConfigOrgMap.WebResources.RemoveAll(w => string.IsNullOrEmpty(w.File));

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
예제 #8
0
        public static ObservableCollection <WebResourceItem> HandleMappings(string solutionPath, Project project, ObservableCollection <WebResourceItem> webResourceItems, Guid organizationId)
        {
            CrmDexExConfig       crmDexExConfig       = CrmDeveloperExtensions2.Core.Config.Mapping.GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = CrmDeveloperExtensions2.Core.Config.Mapping.GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            if (crmDevExConfigOrgMap.WebResources == null)
            {
                crmDevExConfigOrgMap.WebResources = new List <CrmDexExConfigWebResource>();
            }

            List <CrmDexExConfigWebResource> mappingsToRemove = new List <CrmDexExConfigWebResource>();

            //Remove mappings where CRM web resource was deleted
            List <CrmDexExConfigWebResource> mappedWebResources = crmDevExConfigOrgMap.WebResources;

            foreach (CrmDexExConfigWebResource crmDexExConfigWebResource in mappedWebResources)
            {
                if (webResourceItems.Count(w => w.WebResourceId == crmDexExConfigWebResource.WebResourceId) != 0)
                {
                    continue;
                }

                mappingsToRemove.Add(crmDexExConfigWebResource);
                mappedWebResources.Remove(crmDexExConfigWebResource);
            }

            //Add bound file from mapping
            foreach (CrmDexExConfigWebResource crmDexExConfigWebResource in mappedWebResources)
            {
                if (webResourceItems.Count(w => w.WebResourceId == crmDexExConfigWebResource.WebResourceId) > 0)
                {
                    webResourceItems.Where(w => w.WebResourceId == crmDexExConfigWebResource.WebResourceId).ToList()
                    .ForEach(w => w.BoundFile = crmDexExConfigWebResource.File);
                }
            }

            //Remove mappings where project file was deleted
            foreach (CrmDexExConfigWebResource crmDexExConfigWebResource in mappedWebResources)
            {
                string mappedFilePath = FileSystem.BoundFileToLocalPath(crmDexExConfigWebResource.File, project.FullName);
                if (!File.Exists(mappedFilePath))
                {
                    mappingsToRemove.Add(crmDexExConfigWebResource);
                    webResourceItems.Where(w => w.BoundFile == crmDexExConfigWebResource.File).ToList().ForEach(w => w.BoundFile = null);
                }
            }

            if (mappingsToRemove.Count > 0)
            {
                RemoveMappings(solutionPath, project, mappingsToRemove, organizationId);
            }

            return(webResourceItems);
        }
        private static void AddMapping(CrmDexExConfig crmDexExConfig, string solutionPath, Project project, WebResourceItem webResourceItem, Guid organizationId)
        {
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            CrmDexExConfigWebResource crmDexExConfigWebResource = new CrmDexExConfigWebResource
            {
                WebResourceId = webResourceItem.WebResourceId,
                File          = webResourceItem.BoundFile
            };

            crmDevExConfigOrgMap.WebResources.Add(crmDexExConfigWebResource);

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
        public static CrmDexExConfig CreateConfigFile(Guid organizationId, string projectUniqueName, string solutionPath)
        {
            CrmDexExConfig crmDexExConfig = new CrmDexExConfig
            {
                CrmDevExConfigOrgMaps = new List <CrmDevExConfigOrgMap>
                {
                    new CrmDevExConfigOrgMap
                    {
                        OrganizationId    = organizationId,
                        ProjectUniqueName = projectUniqueName
                    }
                }
            };

            string text = JsonConvert.SerializeObject(crmDexExConfig, Formatting.Indented);

            WriteConfigFile(solutionPath, text);

            return(crmDexExConfig);
        }
        private static CrmDevExConfigOrgMap GetOrgMap(ref CrmDexExConfig crmDexExConfig, Guid organizationId, string projectUniqueName)
        {
            CrmDevExConfigOrgMap orgMap = crmDexExConfig.CrmDevExConfigOrgMaps.FirstOrDefault(o => o.OrganizationId == organizationId);

            if (orgMap != null)
            {
                return(orgMap);
            }

            orgMap = new CrmDevExConfigOrgMap
            {
                OrganizationId    = organizationId,
                ProjectUniqueName = projectUniqueName,
                WebResources      = new List <CrmDexExConfigWebResource>()
            };

            crmDexExConfig.CrmDevExConfigOrgMaps.Add(orgMap);

            return(orgMap);
        }
예제 #12
0
        public static CrmDevExSolutionPackage HandleMappings(string solutionPath, Project project, ObservableCollection<CrmSolution> crmSolutions, Guid organizationId)
        {
            CrmDexExConfig crmDexExConfig = CoreMapping.GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = CoreMapping.GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            if (crmDevExConfigOrgMap.SolutionPackage == null)
                return null;

            foreach (CrmSolution crmSolution in crmSolutions)
            {
                if (crmSolution.SolutionId == crmDevExConfigOrgMap.SolutionPackage.SolutionId)
                    return crmDevExConfigOrgMap.SolutionPackage;
            }

            crmDevExConfigOrgMap.SolutionPackage = null;

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);

            return null;
        }
예제 #13
0
        public static void RemoveProject(string solutionPath, string projectUniqueName)
        {
            if (!ConfigFile.ConfigFileExists(solutionPath))
            {
                return;
            }

            CrmDexExConfig crmDexExConfig  = ConfigFile.GetConfigFile(solutionPath);
            var            orgMapsToDelete = crmDexExConfig.CrmDevExConfigOrgMaps.Where(o => o.ProjectUniqueName == projectUniqueName);

            if (orgMapsToDelete.Any())
            {
                MessageBoxResult result = MessageBox.Show("Delete project mappings?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                if (result != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            crmDexExConfig.CrmDevExConfigOrgMaps.RemoveAll(o => o.ProjectUniqueName == projectUniqueName);

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
예제 #14
0
        public static void AddOrUpdateMapping(string solutionPath, Project project, Guid assemblyId, Guid solutionId, int deploymentType, bool backupFiles, Guid organizationId)
        {
            CrmDexExConfig       crmDexExConfig       = CrmDeveloperExtensions2.Core.Config.Mapping.GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = CrmDeveloperExtensions2.Core.Config.Mapping.GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            if (assemblyId != Guid.Empty)
            {
                CrmDevExAssembly crmDevExAssembly = new CrmDevExAssembly
                {
                    AssemblyId     = assemblyId,
                    SolutionId     = solutionId,
                    DeploymentType = deploymentType,
                    BackupFiles    = backupFiles
                };
                crmDevExConfigOrgMap.Assembly = crmDevExAssembly;
            }
            else
            {
                crmDevExConfigOrgMap.Assembly = null;
            }

            ConfigFile.UpdateConfigFile(solutionPath, crmDexExConfig);
        }
        public static void AddOrUpdateMapping(string solutionPath, Project project, WebResourceItem webResourceItem, Guid organizationId)
        {
            CrmDexExConfig       crmDexExConfig       = GetConfigFile(solutionPath, project.UniqueName, organizationId);
            CrmDevExConfigOrgMap crmDevExConfigOrgMap = GetOrgMap(ref crmDexExConfig, organizationId, project.UniqueName);

            List <CrmDexExConfigWebResource> crmDexExConfigWebResources = crmDevExConfigOrgMap.WebResources;

            if (crmDexExConfigWebResources == null)
            {
                crmDevExConfigOrgMap.WebResources = new List <CrmDexExConfigWebResource>();
            }

            CrmDexExConfigWebResource crmDexExConfigWebResource =
                crmDevExConfigOrgMap.WebResources.FirstOrDefault(w => w.WebResourceId == webResourceItem.WebResourceId);

            if (crmDexExConfigWebResource == null)
            {
                AddMapping(crmDexExConfig, solutionPath, project, webResourceItem, organizationId);
            }
            else
            {
                UpdateMapping(crmDexExConfig, solutionPath, project, webResourceItem, organizationId);
            }
        }
        public static void UpdateConfigFile(string solutionPath, CrmDexExConfig crmDexExConfig)
        {
            string text = JsonConvert.SerializeObject(crmDexExConfig, Formatting.Indented);

            WriteConfigFile(solutionPath, text);
        }
예제 #17
0
        public void GetConfigFile()
        {
            CrmDexExConfig config = ConfigFile.GetConfigFile(_testFilepath);

            Assert.IsNotNull(config);
        }