public void ShouldProcessSimpleBugzillaCustomField()
		{
			const string cfName = "cf name";
			const string cfValue = "cf value";

			var field = new custom_field {cf_name = cfName, cf_value = cfValue};

			var info = new CustomFieldInfo(field);

			info.Name.Should(Be.EqualTo(cfName));
			info.Values.Should(Be.EquivalentTo(new[] {cfValue}));
		}
		public void ShouldProcessCollectionBugzillaCustomField()
		{
			const string cfName = "cf name";
			const string cfValue1 = "cf value1";
			const string cfValue2 = "cf value2";

			var field = new custom_field { cf_name = cfName, cf_type = "Multiple-Selection Box", cf_values = new cf_values{cf_valueCollection = new cf_valueCollection {cfValue1, cfValue2}}};

			var info = new CustomFieldInfo(field);

			info.Name.Should(Be.EqualTo(cfName));
			info.Values.Should(Be.EquivalentTo(new[] { cfValue1, cfValue2 }));
		}
コード例 #3
0
        public void ShouldProcessSimpleBugzillaCustomField()
        {
            const string cfName  = "cf name";
            const string cfValue = "cf value";

            var field = new custom_field {
                cf_name = cfName, cf_value = cfValue
            };

            var info = new CustomFieldInfo(field);

            info.Name.Should(Be.EqualTo(cfName));
            info.Values.Should(Be.EquivalentTo(new[] { cfValue }));
        }
コード例 #4
0
        public void ShouldProcessCollectionBugzillaCustomField()
        {
            const string cfName   = "cf name";
            const string cfValue1 = "cf value1";
            const string cfValue2 = "cf value2";

            var field = new custom_field {
                cf_name = cfName, cf_type = "Multiple-Selection Box", cf_values = new cf_values {
                    cf_valueCollection = new cf_valueCollection {
                        cfValue1, cfValue2
                    }
                }
            };

            var info = new CustomFieldInfo(field);

            info.Name.Should(Be.EqualTo(cfName));
            info.Values.Should(Be.EquivalentTo(new[] { cfValue1, cfValue2 }));
        }
コード例 #5
0
		protected int ReadInSurrogates(int currentModelVersion)
		{
			for (; ; ) // Loop is used to retry if we get a corrupt file and restore backup.
			{
				var fileSize = new FileInfo(ProjectId.Path).Length;
				// This arbitrary length is based on two large databases, one 360M with 474 bytes/object, and one 180M with 541.
				// It's probably not perfect, but we're mainly trying to prevent fragmenting the large object heap
				// by growing it MANY times.
				var estimatedObjectCount = (int)(fileSize/400);
				m_identityMap.ExpectAdditionalObjects(estimatedObjectCount);

				if (!FileUtils.SimilarFileExists(ProjectId.Path))
					throw new InvalidOperationException("System does not exist.");

				try
				{
					// We need to reorder the entire file to be nice to Mercurial,
					// but only if the current version is less than "7000048".

					// Step 0: Get the version number.
					m_startupVersionNumber = GetActualModelVersionNumber(ProjectId.Path);
					var useLocalTempFile = !IsLocalDrive(ProjectId.Path);

					// Step 1:
					if (m_startupVersionNumber < 7000048)
					{
#if DEBUG
						var reorderWatch = new Stopwatch();
						reorderWatch.Start();
#endif
						var tempPathname = useLocalTempFile ? Path.GetTempFileName() : Path.ChangeExtension(ProjectId.Path, "tmp");
						// Rewrite the file in the prescribed order.
						using (var writer = FdoXmlServices.CreateWriter(tempPathname))
						{
							FdoXmlServices.WriteStartElement(writer, m_startupVersionNumber); // Use version from old file, so DM can be done, if needed.

							DataSortingService.SortEntireFile(m_mdcInternal.GetSortableProperties(), writer, ProjectId.Path);

							writer.WriteEndElement(); // 'languageproject'
							writer.Close();
						}

#if DEBUG
						reorderWatch.Stop();
						Debug.WriteLine("Reordering entire file took " + reorderWatch.ElapsedMilliseconds + " ms.");
						//Debug.Assert(false, "Force a stop.");
#endif
						// Copy reordered file to ProjectId.Path.
						CopyTempFileToOriginal(useLocalTempFile, ProjectId.Path, tempPathname);
					}

					// Step 2: Go on one's merry way....
					using (var reader = FdoXmlServices.CreateReader(ProjectId.Path))
					{
						reader.MoveToContent();
						m_needConversion = (m_startupVersionNumber != currentModelVersion);

						// Optional AdditionalFields element.
						if (reader.Read() && reader.LocalName == "AdditionalFields")
						{
							var cfiList = new List<CustomFieldInfo>();
							while (reader.Read() && reader.LocalName == "CustomField")
							{
								if (!reader.IsStartElement())
									continue;

								var cfi = new CustomFieldInfo();
								reader.MoveToAttribute("class");
								cfi.m_classname = reader.Value;
								if (reader.MoveToAttribute("destclass"))
									cfi.m_destinationClass = Int32.Parse(reader.Value);
								if (reader.MoveToAttribute("helpString"))
									cfi.m_fieldHelp = reader.Value;
								if (reader.MoveToAttribute("label"))
									cfi.Label = reader.Value;
								if (reader.MoveToAttribute("listRoot"))
									cfi.m_fieldListRoot = new Guid(reader.Value);
								reader.MoveToAttribute("name");
								cfi.m_fieldname = reader.Value;
								reader.MoveToAttribute("type");
								cfi.m_fieldType = GetFlidTypeFromString(reader.Value);
								if (reader.MoveToAttribute("wsSelector"))
									cfi.m_fieldWs = Int32.Parse(reader.Value);
								reader.MoveToElement();
								cfiList.Add(cfi);
							}
							RegisterOriginalCustomProperties(cfiList);
						}
					}

					Stopwatch watch = new Stopwatch();
					watch.Start();
					using (var er = new ElementReader("<rt ", "</languageproject>", ProjectId.Path, MakeSurrogate))
					{
						er.Run();
					}
					watch.Stop();
					Debug.WriteLine("Making surrogates took " + watch.ElapsedMilliseconds + " ms.");
				}
				catch (ArgumentException e)
				{
					Logger.WriteError(e);
					// Failed to get a version number from the file!
					OfferToRestore(Properties.Resources.kstidInvalidFieldWorksXMLFile);
					continue; // backup restored, if previous call returns.
				}
				catch (XmlException e)
				{
					Logger.WriteError(e);
					// The data is not in the format we expect or not even an XML file
					OfferToRestore(Properties.Resources.kstidInvalidFieldWorksXMLFile);
					continue; // backup restored, if previous call returns.
				}
				catch (IOException e)
				{
					Logger.WriteError(e);
					OfferToRestore(e.Message);
					continue; // backup restored, if previous call returns.
				}
				ReportDuplicateGuidsIfTheyExist();
				return m_startupVersionNumber;
			}
		}
コード例 #6
0
        public MigrationConfiguration(XmlNode section)
        {
            //Convert the XmlNode to an XDocument (for LINQ).
            XDocument xmlDoc = XDocument.Parse(section.OuterXml);

            // **********************************
            // * V1 source connection.
            // **********************************
            var v1Source = from item in xmlDoc.Descendants("V1SourceConnection")
                           select new ConnectionInfo
                           {
                               Url = item.Element("Url").Value,
                               Username = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                               Password = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                               Project = string.IsNullOrEmpty(item.Element("Project").Value) ? string.Empty : item.Element("Project").Value,
                               AuthenticationType = string.IsNullOrEmpty(item.Attribute("authenticationType").Value) ? string.Empty : item.Attribute("authenticationType").Value
                           };
            if (v1Source.Count() == 0)
                throw new ConfigurationErrorsException("Missing V1SourceConnection information in application config file.");
            else
                V1SourceConnection = v1Source.First();

            // **********************************
            // * V1 target connection.
            // **********************************
            var v1Target = from item in xmlDoc.Descendants("V1TargetConnection")
                           select new ConnectionInfo
                           {
                               Url = item.Element("Url").Value,
                               Username = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                               Password = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                               Project = string.IsNullOrEmpty(item.Element("Project").Value) ? string.Empty : item.Element("Project").Value,
                               AuthenticationType = string.IsNullOrEmpty(item.Attribute("authenticationType").Value) ? string.Empty : item.Attribute("authenticationType").Value
                           };
            if (v1Target.Count() == 0)
                throw new ConfigurationErrorsException("Missing V1TargetConnection information in application config file.");
            else
                V1TargetConnection = v1Target.First();

            // **********************************
            // * V1 staging database.
            // **********************************
            var v1Database = from item in xmlDoc.Descendants("V1StagingDatabase")
                             select new StagingDatabaseInfo
                             {
                               Server = item.Element("Server").Value,
                               Database = item.Element("Database").Value,
                               Username = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                               Password = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                               TrustedConnection = System.Convert.ToBoolean(item.Attribute("trustedConnection").Value)
                             };
            if (v1Database.Count() == 0)
                throw new ConfigurationErrorsException("Missing V1StagingDatabase information in application config file.");
            else
                V1StagingDatabase = v1Database.First();

            // **********************************
            // * Rally source connection.
            // **********************************
            var rallySource = from item in xmlDoc.Descendants("RallySourceConnection")
                              select new RallyConnectionInfo
                              {
                                Url = item.Element("url").Value,
                                Username = string.IsNullOrEmpty(item.Element("username").Value) ? string.Empty : item.Element("username").Value,
                                Password = string.IsNullOrEmpty(item.Element("password").Value) ? string.Empty : item.Element("password").Value,
                                ExportFileDirectory = item.Element("exportFileDirectory").Value,
                                UserExportFilePrefix = item.Element("userExportFilePrefix").Value,
                                ProjectExportFilePrefix = item.Element("projectExportFilePrefix").Value,
                                ReleaseExportFilePrefix = item.Element("releaseExportFilePrefix").Value,
                                IterationExportFilePrefix = item.Element("iterationExportFilePrefix").Value,
                                EpicExportFilePrefix = item.Element("epicExportFilePrefix").Value,
                                StoryExportFilePrefix = item.Element("storyExportFilePrefix").Value,
                                DefectExportFilePrefix = item.Element("defectExportFilePrefix").Value,
                                TaskExportFilePrefix = item.Element("taskExportFilePrefix").Value,
                                TestExportFilePrefix = item.Element("testExportFilePrefix").Value,
                                RegressionTestExportFilePrefix = item.Element("regressiontestExportFilePrefix").Value,
                                TestStepExportFilePrefix = item.Element("teststepExportFilePrefix").Value,
                                ConversationExportFilePrefix = item.Element("conversationExportFilePrefix").Value,
                                OrphanedTestProject = item.Element("orphanedTestProject").Value
                              };
            RallySourceConnection = rallySource.First();

            // **********************************
            // * Jira Configuration.
            // **********************************
            var jiraConfig = from item in xmlDoc.Descendants("JiraConfiguration")
                           select new JiraConfigurationInfo
                           {
                               XmlFileName = item.Element("xmlFileName").Value,
                               ProjectName = item.Element("projectName").Value,
                               ProjectDescription = item.Element("projectDescription").Value,
                               DefaultSchedule = item.Element("defaultSchedule").Value,
                               JiraUrl = item.Element("jiraUrl").Value,
                               StoryIssueTypes = string.IsNullOrEmpty(item.Element("storyIssueTypes").Value) ? string.Empty : item.Element("storyIssueTypes").Value,
                               DefectIssueTypes = string.IsNullOrEmpty(item.Element("defectIssueTypes").Value) ? string.Empty : item.Element("defectIssueTypes").Value,
                               EpicIssueTypes = string.IsNullOrEmpty(item.Element("epicIssueTypes").Value) ? string.Empty : item.Element("epicIssueTypes").Value,
                               IssueIssueTypes = string.IsNullOrEmpty(item.Element("issueIssueTypes").Value) ? string.Empty : item.Element("issueIssueTypes").Value,
                               RequestIssueTypes = string.IsNullOrEmpty(item.Element("requestIssueTypes").Value) ? string.Empty : item.Element("requestIssueTypes").Value,
                               TaskIssueTypes = string.IsNullOrEmpty(item.Element("taskIssueTypes").Value) ? string.Empty : item.Element("taskIssueTypes").Value,
                               JiraTeamReference = string.IsNullOrEmpty(item.Element("jiraTeamReference").Value) ? string.Empty : item.Element("jiraTeamReference").Value,
                               JiraBacklogGroupReference = string.IsNullOrEmpty(item.Element("jiraBacklogGroupReference").Value) ? string.Empty : item.Element("jiraBacklogGroupReference").Value,
                               JiraBacklogGoalReference = string.IsNullOrEmpty(item.Element("jiraBacklogGoalReference").Value) ? string.Empty : item.Element("jiraBacklogGoalReference").Value
                           };
            if (jiraConfig.Count() == 0)
                throw new ConfigurationErrorsException("Missing JiraConfiguration information in application config file.");
            else
                JiraConfiguration = jiraConfig.First();

            // **********************************
            // * General configurations.
            // **********************************
            var v1Config = from item in xmlDoc.Descendants("configurations")
                           select new ConfigurationInfo
                           {
                               SourceConnectionToUse = item.Element("sourceConnectionToUse").Value,
                               PerformExport = System.Convert.ToBoolean(item.Element("performExport").Value),
                               PerformImport = System.Convert.ToBoolean(item.Element("performImport").Value),
                               PerformClose = System.Convert.ToBoolean(item.Element("performClose").Value),
                               PerformCleanup = System.Convert.ToBoolean(item.Element("performCleanup").Value),
                               MigrateTemplates = System.Convert.ToBoolean(item.Element("migrateTemplates").Value),
                               MigrateAttachmentBinaries = System.Convert.ToBoolean(item.Element("migrateAttachmentBinaries").Value),
                               MigrateProjectMembership = System.Convert.ToBoolean(item.Element("migrateProjectMembership").Value),
                               MigrateDuplicateSchedules = System.Convert.ToBoolean(item.Element("migrateDuplicateSchedules").Value),
                               UseNPIMasking = System.Convert.ToBoolean(item.Element("useNPIMasking").Value),
                               MergeRootProjects = System.Convert.ToBoolean(item.Element("mergeRootProjects").Value),
                               AddV1IDToTitles = System.Convert.ToBoolean(item.Element("addV1IDToTitles").Value),
                               PageSize = System.Convert.ToInt32(item.Element("pageSize").Value),
                               CustomV1IDField = string.IsNullOrEmpty(item.Element("customV1IDField").Value) ? string.Empty : item.Element("customV1IDField").Value,
                               ImportAttachmentsAsLinksURL = string.IsNullOrEmpty(item.Element("importAttachmentsAsLinksURL").Value) ? string.Empty : item.Element("importAttachmentsAsLinksURL").Value,
                               SetAllMembershipToRoot = System.Convert.ToBoolean(item.Element("setAllMembershipToRoot").Value),
                               SourceListTypeValue = string.IsNullOrEmpty(item.Element("sourceListTypeValue").Value) ? string.Empty : item.Element("sourceListTypeValue").Value,
                               MigrateUnauthoredConversationsAsAdmin = System.Convert.ToBoolean(item.Element("migrateUnauthoredConversationsAsAdmin").Value),
                               LogExceptions = System.Convert.ToBoolean(item.Element("logExceptions").Value)
                           };
            if (v1Config.Count() == 0)
                throw new ConfigurationErrorsException("Missing general configuration information in application config file.");
            else
                V1Configurations = v1Config.First();

            // **********************************
            // * Assets to migrate.
            // **********************************
            var assetData = from item in xmlDoc.Descendants("asset")
                            select item;
            if (assetData.Count() == 0)
                throw new ConfigurationErrorsException("Missing assets to migrate information in application config file.");

            foreach (var asset in assetData)
            {
                AssetInfo assetInfo = new AssetInfo();
                assetInfo.Name = asset.Attribute("name").Value;
                assetInfo.InternalName = asset.Attribute("internalName").Value;
                assetInfo.Enabled = System.Convert.ToBoolean(asset.Attribute("enabled").Value);
                assetInfo.DuplicateCheckField = asset.Attribute("duplicateCheckField").Value;
                assetInfo.EnableCustomFields = System.Convert.ToBoolean(asset.Attribute("enableCustomFields").Value);
                AssetsToMigrate.Add(assetInfo);
            }

            // **********************************
            // * List types to migrate.
            // **********************************
            var listTypeData = from item in xmlDoc.Descendants("listType")
                               select item;
            if (listTypeData.Count() == 0)
                throw new ConfigurationErrorsException("Missing list types to migrate information in application config file.");

            foreach (var listType in listTypeData)
            {
                ListTypeInfo listTypeInfo = new ListTypeInfo();
                listTypeInfo.Name = listType.Attribute("name").Value;
                listTypeInfo.Enabled = System.Convert.ToBoolean(listType.Attribute("enabled").Value);
                ListTypesToMigrate.Add(listTypeInfo);
            }

            // **********************************
            // * List Values
            // **********************************
            var listValueData = from item in xmlDoc.Descendants("listValue") select item;

            foreach (var listValue in listValueData)
            {
                ListValueInfo listValueInfo = new ListValueInfo();
                listValueInfo.AssetType = listValue.Attribute("assetType").Value;
                listValueInfo.FieldName = listValue.Attribute("fieldName").Value;
                listValueInfo.ListName = listValue.Attribute("listName").Value;
                listValueInfo.OldValue = listValue.Attribute("oldValue").Value;
                listValueInfo.NewValue = listValue.Attribute("newValue").Value;
                ListValues.Add(listValueInfo);
            }

            // **********************************
            // * Custom fields to migrate.
            // **********************************
            var customFieldData = from item in xmlDoc.Descendants("customField")
                                  select item;
            if (customFieldData.Count() == 0)
                throw new ConfigurationErrorsException("Missing custom fields to migrate information in application config file.");

            foreach (var customField in customFieldData)
            {
                CustomFieldInfo customFieldInfo = new CustomFieldInfo();
                customFieldInfo.SourceName = customField.Attribute("sourceName").Value;
                customFieldInfo.TargetName = customField.Attribute("targetName").Value;
                customFieldInfo.AssetType = customField.Attribute("assetType").Value;
                customFieldInfo.DataType = customField.Attribute("dataType").Value;
                customFieldInfo.RelationName = customField.Attribute("relationName").Value;
                CustomFieldsToMigrate.Add(customFieldInfo);
            }
        }
コード例 #7
0
        public MigrationConfiguration(XmlNode section)
        {
            //Convert the XmlNode to an XDocument (for LINQ).
            XDocument xmlDoc = XDocument.Parse(section.OuterXml);

            // **********************************
            // * V1 source connection.
            // **********************************
            var v1Source = from item in xmlDoc.Descendants("V1SourceConnection")
                           select new ConnectionInfo
            {
                Url                = item.Element("Url").Value,
                Username           = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                Password           = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                Project            = string.IsNullOrEmpty(item.Element("Project").Value) ? string.Empty : item.Element("Project").Value,
                AuthenticationType = string.IsNullOrEmpty(item.Attribute("authenticationType").Value) ? string.Empty : item.Attribute("authenticationType").Value
            };

            if (v1Source.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing V1SourceConnection information in application config file.");
            }
            else
            {
                V1SourceConnection = v1Source.First();
            }


            // **********************************
            // * V1 target connection.
            // **********************************
            var v1Target = from item in xmlDoc.Descendants("V1TargetConnection")
                           select new ConnectionInfo
            {
                Url                = item.Element("Url").Value,
                Username           = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                Password           = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                Project            = string.IsNullOrEmpty(item.Element("Project").Value) ? string.Empty : item.Element("Project").Value,
                AuthenticationType = string.IsNullOrEmpty(item.Attribute("authenticationType").Value) ? string.Empty : item.Attribute("authenticationType").Value
            };

            if (v1Target.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing V1TargetConnection information in application config file.");
            }
            else
            {
                V1TargetConnection = v1Target.First();
            }

            // **********************************
            // * V1 staging database.
            // **********************************
            var v1Database = from item in xmlDoc.Descendants("V1StagingDatabase")
                             select new StagingDatabaseInfo
            {
                Server            = item.Element("Server").Value,
                Database          = item.Element("Database").Value,
                Username          = string.IsNullOrEmpty(item.Element("Username").Value) ? string.Empty : item.Element("Username").Value,
                Password          = string.IsNullOrEmpty(item.Element("Password").Value) ? string.Empty : item.Element("Password").Value,
                TrustedConnection = System.Convert.ToBoolean(item.Attribute("trustedConnection").Value)
            };

            if (v1Database.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing V1StagingDatabase information in application config file.");
            }
            else
            {
                V1StagingDatabase = v1Database.First();
            }

            // **********************************
            // * Rally source connection.
            // **********************************
            var rallySource = from item in xmlDoc.Descendants("RallySourceConnection")
                              select new RallyConnectionInfo
            {
                Url                            = item.Element("url").Value,
                Username                       = string.IsNullOrEmpty(item.Element("username").Value) ? string.Empty : item.Element("username").Value,
                Password                       = string.IsNullOrEmpty(item.Element("password").Value) ? string.Empty : item.Element("password").Value,
                ExportFileDirectory            = item.Element("exportFileDirectory").Value,
                UserExportFilePrefix           = item.Element("userExportFilePrefix").Value,
                ProjectExportFilePrefix        = item.Element("projectExportFilePrefix").Value,
                ReleaseExportFilePrefix        = item.Element("releaseExportFilePrefix").Value,
                IterationExportFilePrefix      = item.Element("iterationExportFilePrefix").Value,
                EpicExportFilePrefix           = item.Element("epicExportFilePrefix").Value,
                StoryExportFilePrefix          = item.Element("storyExportFilePrefix").Value,
                DefectExportFilePrefix         = item.Element("defectExportFilePrefix").Value,
                TaskExportFilePrefix           = item.Element("taskExportFilePrefix").Value,
                TestExportFilePrefix           = item.Element("testExportFilePrefix").Value,
                RegressionTestExportFilePrefix = item.Element("regressiontestExportFilePrefix").Value,
                TestStepExportFilePrefix       = item.Element("teststepExportFilePrefix").Value,
                ConversationExportFilePrefix   = item.Element("conversationExportFilePrefix").Value,
                OrphanedTestProject            = item.Element("orphanedTestProject").Value
            };

            RallySourceConnection = rallySource.First();

            // **********************************
            // * Jira Configuration.
            // **********************************
            var jiraConfig = from item in xmlDoc.Descendants("JiraConfiguration")
                             select new JiraConfigurationInfo
            {
                XmlFileName        = item.Element("xmlFileName").Value,
                ProjectName        = item.Element("projectName").Value,
                ProjectDescription = item.Element("projectDescription").Value,
                DefaultSchedule    = item.Element("defaultSchedule").Value,
                JiraUrl            = item.Element("jiraUrl").Value
            };

            if (jiraConfig.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing JiraConfiguration information in application config file.");
            }
            else
            {
                JiraConfiguration = jiraConfig.First();
            }


            // **********************************
            // * General configurations.
            // **********************************
            var v1Config = from item in xmlDoc.Descendants("configurations")
                           select new ConfigurationInfo
            {
                SourceConnectionToUse     = item.Element("sourceConnectionToUse").Value,
                PerformExport             = System.Convert.ToBoolean(item.Element("performExport").Value),
                PerformImport             = System.Convert.ToBoolean(item.Element("performImport").Value),
                PerformClose              = System.Convert.ToBoolean(item.Element("performClose").Value),
                PerformCleanup            = System.Convert.ToBoolean(item.Element("performCleanup").Value),
                MigrateTemplates          = System.Convert.ToBoolean(item.Element("migrateTemplates").Value),
                MigrateAttachmentBinaries = System.Convert.ToBoolean(item.Element("migrateAttachmentBinaries").Value),
                MigrateProjectMembership  = System.Convert.ToBoolean(item.Element("migrateProjectMembership").Value),
                MigrateDuplicateSchedules = System.Convert.ToBoolean(item.Element("migrateDuplicateSchedules").Value),
                UseNPIMasking             = System.Convert.ToBoolean(item.Element("useNPIMasking").Value),
                MergeRootProjects         = System.Convert.ToBoolean(item.Element("mergeRootProjects").Value),
                AddV1IDToTitles           = System.Convert.ToBoolean(item.Element("addV1IDToTitles").Value),
                PageSize                              = System.Convert.ToInt32(item.Element("pageSize").Value),
                CustomV1IDField                       = string.IsNullOrEmpty(item.Element("customV1IDField").Value) ? string.Empty : item.Element("customV1IDField").Value,
                ImportAttachmentsAsLinksURL           = string.IsNullOrEmpty(item.Element("importAttachmentsAsLinksURL").Value) ? string.Empty : item.Element("importAttachmentsAsLinksURL").Value,
                SetAllMembershipToRoot                = System.Convert.ToBoolean(item.Element("setAllMembershipToRoot").Value),
                SourceListTypeValue                   = string.IsNullOrEmpty(item.Element("sourceListTypeValue").Value) ? string.Empty : item.Element("sourceListTypeValue").Value,
                MigrateUnauthoredConversationsAsAdmin = System.Convert.ToBoolean(item.Element("migrateUnauthoredConversationsAsAdmin").Value),
                LogExceptions                         = System.Convert.ToBoolean(item.Element("logExceptions").Value)
            };

            if (v1Config.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing general configuration information in application config file.");
            }
            else
            {
                V1Configurations = v1Config.First();
            }

            // **********************************
            // * Assets to migrate.
            // **********************************
            var assetData = from item in xmlDoc.Descendants("asset")
                            select item;

            if (assetData.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing assets to migrate information in application config file.");
            }

            foreach (var asset in assetData)
            {
                AssetInfo assetInfo = new AssetInfo();
                assetInfo.Name                = asset.Attribute("name").Value;
                assetInfo.InternalName        = asset.Attribute("internalName").Value;
                assetInfo.Enabled             = System.Convert.ToBoolean(asset.Attribute("enabled").Value);
                assetInfo.DuplicateCheckField = asset.Attribute("duplicateCheckField").Value;
                assetInfo.EnableCustomFields  = System.Convert.ToBoolean(asset.Attribute("enableCustomFields").Value);
                AssetsToMigrate.Add(assetInfo);
            }

            // **********************************
            // * List types to migrate.
            // **********************************
            var listTypeData = from item in xmlDoc.Descendants("listType")
                               select item;

            if (listTypeData.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing list types to migrate information in application config file.");
            }

            foreach (var listType in listTypeData)
            {
                ListTypeInfo listTypeInfo = new ListTypeInfo();
                listTypeInfo.Name    = listType.Attribute("name").Value;
                listTypeInfo.Enabled = System.Convert.ToBoolean(listType.Attribute("enabled").Value);
                ListTypesToMigrate.Add(listTypeInfo);
            }

            // **********************************
            // * Custom fields to migrate.
            // **********************************
            var customFieldData = from item in xmlDoc.Descendants("customField")
                                  select item;

            if (customFieldData.Count() == 0)
            {
                throw new ConfigurationErrorsException("Missing custom fields to migrate information in application config file.");
            }

            foreach (var customField in customFieldData)
            {
                CustomFieldInfo customFieldInfo = new CustomFieldInfo();
                customFieldInfo.SourceName   = customField.Attribute("sourceName").Value;
                customFieldInfo.TargetName   = customField.Attribute("targetName").Value;
                customFieldInfo.AssetType    = customField.Attribute("assetType").Value;
                customFieldInfo.DataType     = customField.Attribute("dataType").Value;
                customFieldInfo.RelationName = customField.Attribute("relationName").Value;
                CustomFieldsToMigrate.Add(customFieldInfo);
            }
        }
コード例 #8
0
		/// <summary>
		/// Get the custom fields
		/// </summary>
		/// <returns></returns>
		IEnumerable<CustomFieldInfo> IFwMetaDataCacheManagedInternal.GetCustomFields()
		{
			var retval = new List<CustomFieldInfo>();
			foreach (var customMfr in m_customFields)
			{
				var cfi = new CustomFieldInfo
							{
								m_classid = customMfr.m_ownClsid,
								m_classname = m_metaClassRecords[customMfr.m_ownClsid].m_className,
								m_fieldname = customMfr.m_fieldName,
								m_fieldType = (CellarPropertyType) customMfr.m_fieldType,
								m_flid = customMfr.m_flid,
								m_destinationClass = customMfr.m_dstClsid,
								m_fieldWs = customMfr.m_fieldWs,
								m_fieldHelp = customMfr.m_fieldHelp,
								m_fieldListRoot = customMfr.m_fieldListRoot,
								Label = customMfr.m_fieldLabel
							};
				retval.Add(cfi);
			}
			return retval;
		}
コード例 #9
0
        private void button_CreateFields_Click(object sender, EventArgs e)
        {
            Dictionary <int, CustomFieldInfo> fieldsToCreate = new Dictionary <int, CustomFieldInfo>();

            List <string> errors = new List <string>();
            Dictionary <int, CustomFieldInfo> fieldsThatAlreadyExist = new Dictionary <int, CustomFieldInfo>();



            int errorIndex = 0;

            EllieMae.EMLite.ClientServer.IConfigurationManager configMan = EncompassHelper.SessionObjects.ConfigurationManager;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                List <string> rowErrors = new List <string>();

                DataGridViewRow row = dataGridView1.Rows[i];

                if (row.IsNewRow)
                {
                    continue;
                }

                string name = row.Cells[0].Value == null ? string.Empty : row.Cells[0].Value.ToString();
                if (string.IsNullOrEmpty(name))
                {
                    rowErrors.Add($"field id is empty");
                }
                else if (name.Length > 28)
                {
                    rowErrors.Add($"field id has '{name.Length}' characters and has a max of 28");
                }

                string desc = row.Cells[1].Value == null ? string.Empty : row.Cells[1].Value.ToString();
                if (string.IsNullOrEmpty(desc))
                {
                    rowErrors.Add($"description is empty");
                }

                FieldFormat format = Enum.TryParse(row.Cells[2].Value.ToString().ToUpper(), out format) ? format : FieldFormat.NONE;
                if (format == FieldFormat.NONE)
                {
                    var cellValue = row.Cells[2].Value ?? string.Empty;
                    rowErrors.Add($"field format '{cellValue.ToString()}'");
                }

                // we only need a valid 'length' for STRING fields
                int length = 0;
                if (format == FieldFormat.STRING)
                {
                    if (row.Cells[3].Value == null)
                    {
                        rowErrors.Add($"length is required for 'string' field'");
                    }
                    else
                    {
                        if (int.TryParse(row.Cells[3].Value.ToString(), out length) == false)
                        {
                            rowErrors.Add($"error converting length to int for 'string' field");
                        }
                        else if (length == 0)
                        {
                            rowErrors.Add($"'string' field requires length");
                        }
                    }
                }

                if (rowErrors.Any())
                {
                    errorIndex++;
                    errors.Add($"{errorIndex}. Row {i + 1}. {string.Join(", ", rowErrors.ToArray())}");
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                else
                {
                    var fieldToCreate = new CustomFieldInfo(name, desc, format, length, "");

                    var currentField = configMan.GetLoanCustomField(fieldToCreate.FieldID);
                    if (currentField != null)
                    {
                        fieldsThatAlreadyExist.Add(i, currentField);
                    }

                    fieldsToCreate.Add(i, fieldToCreate);
                }
            }

            if (errors.Any())
            {
                textBox_Results.Text = string.Join(Environment.NewLine, errors.ToArray());
                MessageBox.Show($"Error converting '{errors.Count}' rows to fields.");
                return;
            }

            if (fieldsThatAlreadyExist.Any())
            {
                foreach (var item in fieldsThatAlreadyExist)
                {
                    dataGridView1.Rows[item.Key].DefaultCellStyle.BackColor = Color.Yellow;
                }

                string       msg          = $"The fields below already exist, do you wish to overwrite them? {Environment.NewLine + string.Join(Environment.NewLine, fieldsThatAlreadyExist.Select(x => x.Value.FieldID).ToArray())}";
                DialogResult dialogResult = MessageBox.Show(msg, "Overwrite Already existing Fields?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    MessageBox.Show("Creating fields cancelled.");
                    return;
                }
            }


            foreach (var field in fieldsToCreate)
            {
                try
                {
                    configMan.UpdateLoanCustomField(field.Value);
                    dataGridView1.Rows[field.Key].DefaultCellStyle.BackColor = Color.LightGreen;
                }
                catch (Exception ex)
                {
                    errors.Add($"{field.Value.FieldID}. {ex.ToString()}");
                    dataGridView1.Rows[field.Key].DefaultCellStyle.BackColor = Color.Red;
                }
            }

            if (errors.Any())
            {
                MessageBox.Show($"Created '{fieldsToCreate.Count - errors.Count}' fields but had errors with '{errors.Count}'");
                textBox_Results.Text = string.Join(Environment.NewLine, errors.ToArray());
            }
            else
            {
                string msg = $"Created all fields ('{fieldsToCreate.Count}') successfully!";
                MessageBox.Show(msg);
                textBox_Results.Text = msg;
            }
        }