public static string ToDisplayString(this MigrationStatus migrationStatus) { switch (migrationStatus) { case MigrationStatus.New: { return("New"); } case MigrationStatus.NotMigrated: { return("Not migrated"); } case MigrationStatus.MigratedWithoutPassword: { return("Migrated without password"); } case MigrationStatus.MigratedWithPassword: { return("Migrated with password"); } default: { return("Unknown"); } } }
/// <summary> /// Parse file name to migration status. /// </summary> /// <param name="file">File name to parse.</param> /// <returns>MigrationStatus instance.</returns> protected MigrationStatus ParseFileName(string file) { FileInfo info = new FileInfo(file); var name = info.Name; var description = name.Replace(info.Extension, string.Empty).Substring(name.IndexOf("__") + 2).Replace("_", " "); var pathWithoutRootDirectory = file.Replace(MigrationsDirectory, ""); string[] dirs = pathWithoutRootDirectory.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); // Check for mudule as a sub directory of main scripts directory string module = null; // If subfolder exists, using directory name as a module // Split characters contains at least 1 item as file name. if directory exists, dirs array will contain 2 items in array, directory and file name. if (dirs.Length > 1) { // Take first directory level as a module name, no need to go deeper in subdirectories, modules should have unique names module = dirs[0]; } MigrationStatus status = new MigrationStatus() { Version = GetFileVersion(file).ToVersionString(), FileName = name, Path = file, Module = module, Description = description }; return(status); }
public RavenToolState(IDictionary <string, string> runParameters, string endpointName, MigrationStatus migrationStatus) { RunParameters = runParameters; EndpointName = endpointName; Status = migrationStatus; Batches = new List <RavenBatch>(); }
private bool MigrateGameObjectHierarchy(GameObject parent, MigrationStatus status) { bool changedAnyGameObject = false; foreach (var child in parent.GetComponentsInChildren <Transform>(true)) { try { if (migrationHandlerInstance.CanMigrate(child.gameObject)) { changedAnyGameObject = true; migrationHandlerInstance.Migrate(child.gameObject); status.AddToLog($"Successfully migrated {child.gameObject.name} object \n"); } } catch (Exception e) { status.Failures++; status.AddToLog($"{e.Message}: GameObject {child.gameObject.name} could not be migrated \n"); } } return(changedAnyGameObject); }
public void AddToEntityStatistics(string fromEntity, string toEntity, MigrationStatus status) { if (m_entityStatistics == null) { m_entityStatistics = new ArrayList(); } // find if this entity already exist in current list foreach (Detail map in m_entityStatistics) { if (TFStringComparer.WorkItemType.Equals(map.ToEntity, toEntity)) { switch (status) { case MigrationStatus.Passed: map.PassedCount++; break; case MigrationStatus.Failed: map.FailedCount++; break; case MigrationStatus.Warning: map.WarningCount++; break; case MigrationStatus.Skipped: map.SkippedCount++; break; } return; } } // not found this entity.. add it now Detail newMap = new Detail(); newMap.FromEntity = fromEntity; newMap.ToEntity = toEntity; switch (status) { case MigrationStatus.Passed: newMap.PassedCount++; break; case MigrationStatus.Failed: newMap.FailedCount++; break; case MigrationStatus.Warning: newMap.WarningCount++; break; case MigrationStatus.Skipped: newMap.SkippedCount++; break; } m_entityStatistics.Add(newMap); }
public AspToolState(Func <Task <BatchInfo> > getNextBatch, IDictionary <string, string> runParameters, string endpointName, int numberOfBatches, MigrationStatus migrationStatus) { this.getNextBatch = getNextBatch; RunParameters = runParameters; EndpointName = endpointName; NumberOfBatches = numberOfBatches; Status = migrationStatus; }
/// <summary> /// Constructor - Constructs LegacyDataContainerMigrationStatus object of given MigrationStatus, /// by filtering from overall status list provided /// </summary> /// <param name="overallStatusList">overall migration status</param> /// <param name="type">MigrationStatus of the list of stored</param> public LegacyDataContainerMigrationStatus(List <MigrationDataContainerStatus> overallStatusList, MigrationStatus type) { this.StatusList = new List <MigrationDataContainerStatus>(); this.migrationState = type; if (null != overallStatusList) { this.StatusList.AddRange(overallStatusList.FindAll(status => type == status.Status)); } }
/// <summary> /// Constructor - Constructs LegacyDataContainerMigrationStatus object of given MigrationStatus, /// by filtering from overall status list provided /// </summary> /// <param name="overallStatusList">overall migration status</param> /// <param name="type">MigrationStatus of the list of stored</param> public LegacyDataContainerMigrationStatus(List<MigrationDataContainerStatus> overallStatusList, MigrationStatus type) { this.StatusList = new List<MigrationDataContainerStatus>(); this.migrationState = type; if (null != overallStatusList) { this.StatusList.AddRange(overallStatusList.FindAll(status => type == status.Status)); } }
private void LoadCurrentStatusDetails() { string strErrorMessage = String.Empty; if ((_objOrderAddress != null) && (_objOrderAddress.MigrationStatusID.HasValue)) { MigrationStatus objMigrationStatus = new MigrationStatus().GetByPK(_objOrderAddress.MigrationStatusID.Value, out strErrorMessage); lblCurrentMigrationStatusDesc.InnerText = objMigrationStatus.MigrationStatusDesc; lblCurrentMigrationStatusDescExtended.InnerText = objMigrationStatus.MigrationStatusExtendedDescription; } }
public void LoadDDL_MigrationStatus() { string strErrorMessage = String.Empty; List <MigrationStatus> lstOrderAddressStatuses = new MigrationStatus().GetAllRecords(out strErrorMessage); // Iterate over the records and add a corresponding item to the drop down list for (int i = 0; i < lstOrderAddressStatuses.Count; i++) { RadComboBoxItem objItem = new RadComboBoxItem(); objItem.Text = lstOrderAddressStatuses[i].MigrationStatusDesc; objItem.Value = lstOrderAddressStatuses[i].MigrationStatusID.ToString(); ddlMigrationStatuses.Items.Add(objItem); } }
protected override void Execute(MigrationStatus migration) { Console.WriteLine(); Console.WriteLine(string.Format("========== Applying \"{0}\" ==========", migration.FileName)); Console.WriteLine(); var scriptText = File.ReadAllText(migration.Path); using (var connection = new SQLiteConnection(this.ConnectionString)) { connection.Open(); scriptText = Regex.Replace(scriptText, @";", SCRIPT_SPLIT_CHAR); string[] commands = scriptText.Split(new string[] { SCRIPT_SPLIT_CHAR }, StringSplitOptions.RemoveEmptyEntries); foreach (var commandText in commands) { if (!string.IsNullOrEmpty(commandText.Trim())) { Console.WriteLine(commandText); Console.WriteLine(); using (var command = connection.CreateCommand()) { command.CommandText = commandText; command.CommandTimeout = 0; command.ExecuteNonQuery(); } } } #region " Log changeset " using (var command = connection.CreateCommand()) { command.CommandText = Resources.LogMigration; command.Parameters.Clear(); command.Parameters.AddWithValue("version", migration.Version); command.Parameters.AddWithValue("description", migration.Description); command.Parameters.AddWithValue("fileName", migration.FileName); command.Parameters.AddWithValue("module", migration.Module ?? Module); command.ExecuteNonQuery(); } #endregion } }
public void MigrateOnewayAgreement( Services.TpmContext cloudContext, Server.OnewayAgreement serverOnewayAgreement, Server.QualifierIdentity serverSenderBusinessIdentity, Server.QualifierIdentity serverReceiverBusinessIdentity, Services.Agreement cloudAgreement, string onewayAgreementType, out MigrationStatus migrationStatus) { Services.OnewayAgreement cloudOnewayAgreement = new Services.OnewayAgreement(); cloudContext.AddToOnewayAgreements(cloudOnewayAgreement); cloudContext.RelateEntities( cloudOnewayAgreement, cloudAgreement, onewayAgreementType == "OnewayAgreementAToB" ? "AgreementAsAToB" : "AgreementAsBToA", onewayAgreementType, Services.RelationshipCardinality.OneToOne); this.LinkBusinessProfilesToOnewayAgreement( cloudContext, cloudOnewayAgreement, cloudAgreement.BusinessProfileA, cloudAgreement.BusinessProfileB, serverSenderBusinessIdentity, serverReceiverBusinessIdentity, onewayAgreementType); // Migrate send and receive protocol settings Server.ProtocolSettings serverProtocolSettings; switch (cloudAgreement.ProtocolName) { case AppConstants.X12ProtocolName: serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.X12ProtocolSettings>(); break; case AppConstants.AS2ProtocolName: serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.AS2ProtocolSettings>(); break; case AppConstants.EdifactProtocolName: serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.EDIFACTProtocolSettings>(); break; default: throw new NotSupportedException("Migration of X12, AS2, EDIFACT agreements only is supported"); } this.protocolSettingsMigrator.MigrateProtocolSettings(cloudContext, cloudOnewayAgreement, serverProtocolSettings, onewayAgreementType == "OnewayAgreementAToB" ? cloudAgreement.BusinessProfileA : cloudAgreement.BusinessProfileB, cloudAgreement.Name, out migrationStatus); }
private void MigratePrefab(String path, MigrationStatus status) { if (!AssetDatabase.LoadAssetAtPath(path, typeof(GameObject))) { return; } var parent = UnityEditor.PrefabUtility.LoadPrefabContents(path); if (MigrateGameObjectHierarchy(parent, status)) { UnityEditor.PrefabUtility.SaveAsPrefabAsset(parent, path); } PrefabUtility.UnloadPrefabContents(parent); }
public void SetStatus(TEntity item, MigrationStatus status, string statusText) { var serverPartnerItem = item as PartnerMigrationItemViewModel; var certItem = item as Certificate; if (serverPartnerItem != null) { serverPartnerItem.CertificateExportStatus = status; serverPartnerItem.CertificateExportStatusText = statusText; } else { certItem.ExportStatus = status; certItem.ExportStatusText = statusText; } }
public SqlPToolState( string connectionString, SqlDialect dialect, string migrationRunId, IDictionary <string, string> runParameters, string endpointName, int numberOfBatches, MigrationStatus migrationStatus) { this.connectionString = connectionString; this.dialect = dialect; this.migrationRunId = migrationRunId; RunParameters = runParameters; EndpointName = endpointName; NumberOfBatches = numberOfBatches; Status = migrationStatus; }
public void InitCharacter(Character character) { characterName = character.name; relationshipName = character.relationshipName; setJob(character.roleName); migrationStatus = character.migrationStatus; isMale = character.isMale; transform.Find("NameText").GetComponent <Text>().text = characterName; var sprite = Resources.Load <Sprite>(isMale ? "idmale" : "idfemale"); transform.Find("PersonPart").Find("PersonFigure").GetComponent <Image>().sprite = sprite; transform.Find("RolePart").Find("RoleOutline").GetComponent <Image>().sprite = Resources.Load <Sprite>("Role" + (isMale ? "Male" : "Female")); //transform.Find("ProsperityBar").Find("Slider").GetComponent<RectTransform>().anchoredPosition = new Vector2(prosperityOffset, 0.0f); }
public void MigrateOnewayAgreements(Services.TpmContext cloudContext, Server.Agreement serverAgreement, string serverAgreementSenderPartnerName, string serverAgreementReceiverPartnername, Services.Agreement cloudAgreement, out MigrationStatus migrationStatus) { migrationStatus = MigrationStatus.Succeeded; Server.OnewayAgreement serverSendOnewayAgreement = serverAgreement.GetOnewayAgreement(serverAgreementSenderPartnerName, serverAgreementReceiverPartnername); Server.OnewayAgreement serverReceiveOnewayAgreement = serverAgreement.GetOnewayAgreement(serverAgreementReceiverPartnername, serverAgreementSenderPartnerName); var serverSenderBusinessIdentity = serverSendOnewayAgreement.SenderIdentity as Server.QualifierIdentity; var serverReceiverBusinessIdentity = serverSendOnewayAgreement.ReceiverIdentity as Server.QualifierIdentity; MigrationStatus onewayAgreementAToBMigrationStatus = MigrationStatus.Succeeded; this.MigrateOnewayAgreement(cloudContext, serverSendOnewayAgreement, serverSenderBusinessIdentity, serverReceiverBusinessIdentity, cloudAgreement, "OnewayAgreementAToB", out onewayAgreementAToBMigrationStatus); MigrationStatus onewayAgreementBToAMigrationStatus = MigrationStatus.Succeeded; this.MigrateOnewayAgreement(cloudContext, serverReceiveOnewayAgreement, serverReceiverBusinessIdentity, serverSenderBusinessIdentity, cloudAgreement, "OnewayAgreementBToA", out onewayAgreementBToAMigrationStatus); if (onewayAgreementAToBMigrationStatus == MigrationStatus.Partial || onewayAgreementBToAMigrationStatus == MigrationStatus.Partial) { migrationStatus = MigrationStatus.Partial; } }
private void MigrateScene(String path, MigrationStatus status) { if (!AssetDatabase.LoadAssetAtPath(path, typeof(SceneAsset))) { return; } Scene scene = EditorSceneManager.OpenScene(path); bool didAnySceneObjectChange = false; foreach (var parent in scene.GetRootGameObjects()) { didAnySceneObjectChange |= MigrateGameObjectHierarchy(parent, status); } if (didAnySceneObjectChange) { EditorSceneManager.SaveScene(scene); } }
public void UpdateStatus(string agreementName, out MigrationStatus migrationStatus) { migrationStatus = MigrationStatus.Succeeded; var statusBarViewModel = this.applicationContext.GetService <StatusBarViewModel>(); Debug.Assert(statusBarViewModel != null, "StatusBarViewModel has not been initialized in application context"); string statusBarMessage = string.Empty; if (this.isMessageEncrypted == true) { statusBarMessage += string.Format(CultureInfo.InvariantCulture, "Message Encryption settings are not migrated for sender {0}", senderProfileName) + Environment.NewLine; migrationStatus = MigrationStatus.Partial; } if (this.signingThumbprintMissing != null && this.signingThumbprintMissing.Length > 0) { statusBarMessage += string.Format(CultureInfo.InvariantCulture, "Certificate with thumbprint {0} missing in the Sender's {1} profile ", this.signingThumbprintMissing, senderProfileName); migrationStatus = MigrationStatus.Partial; } if (statusBarMessage.Length > 0) { if (agreementName != currentAgreementName) { statusBarViewModel.ShowWarning(Environment.NewLine + agreementName + " (Warning) : " + Environment.NewLine + statusBarMessage); currentAgreementName = agreementName; TraceProvider.WriteLine(statusBarMessage); } else { statusBarViewModel.ShowWarning(Environment.NewLine + statusBarMessage); TraceProvider.WriteLine(statusBarMessage); } } this.isMessageEncrypted = false; this.signingThumbprintMissing = string.Empty; }
public IInventoryStorage GetProvider(UUID userId) { if (!_migrationActive) { return(_cassandraStorage); } lock (_migratedUsers) { if (_migratedUsers.Contains(userId)) { return(_cassandraStorage); } } //nothing in our cache, we need to consult the database MigrationStatus status = _migrationStatusChecker.GetUserMigrationStatus(userId); if (status == MigrationStatus.Migrated) { lock (_migratedUsers) { _migratedUsers.Add(userId); } return(_cassandraStorage); } else if (status == MigrationStatus.InProgress) { throw new InventoryStorageException("Inventory can not be used while a migration is in progress"); } else { return(_legacyStorage); } }
public MigrationStatus GetUserMigrationStatus(UUID userId) { using (ISimpleDB conn = _connFactory.GetConnection()) { const string query = "SELECT status FROM InventoryMigrationStatus WHERE user_id = ?userId"; Dictionary <string, object> parms = new Dictionary <string, object>(); parms.Add("?userId", userId); using (IDataReader reader = conn.QueryAndUseReader(query, parms)) { if (reader.Read()) { short status = Convert.ToInt16(reader["status"]); MigrationStatus retStatus = (MigrationStatus)status; return(retStatus); } else { return(MigrationStatus.Unmigrated); } } } }
protected virtual bool ShouldExecute(MigrationStatus migration) { decimal currentVersion = GetCurrentVersion(migration.Module); return(migration.Version.ToVersion() > currentVersion); }
protected abstract void Execute(MigrationStatus migration);
public void MigrateProtocolSettings(Services.TpmContext cloudContext, Services.OnewayAgreement cloudOnewayAgreement, Server.ProtocolSettings serverProtocolSettings, Services.BusinessProfile senderProfile, string agreementName, out MigrationStatus migrationStatus) { this.envelopeOverridesMigrator = new EnvelopeOverridesMigrator(cloudContext); this.validationOverridesMigrator = new ValidationOverridesMigrator(cloudContext); Services.ProtocolSettings cloudProtocolSettings; switch (serverProtocolSettings.ProtocolName) { case AppConstants.X12ProtocolName: cloudProtocolSettings = CreateX12ProtocolSettings((Server.X12ProtocolSettings)serverProtocolSettings); migrationStatus = MigrationStatus.Succeeded; break; case AppConstants.AS2ProtocolName: cloudProtocolSettings = CreateAS2ProtocolSettings((Server.AS2ProtocolSettings)serverProtocolSettings); CleanAs2ProtocolSettings((Services.AS2ProtocolSettings)cloudProtocolSettings, senderProfile); this.UpdateStatus(agreementName, out migrationStatus); break; case AppConstants.EdifactProtocolName: cloudProtocolSettings = CreateEdifactProtocolSettings((Server.EDIFACTProtocolSettings)serverProtocolSettings); migrationStatus = MigrationStatus.Succeeded; break; default: throw new NotSupportedException(); } cloudContext.AddToProtocolSettings(cloudProtocolSettings); cloudProtocolSettings.OnewayAgreement = cloudOnewayAgreement; cloudContext.SetLink(cloudProtocolSettings, "OnewayAgreement", cloudOnewayAgreement); cloudOnewayAgreement.ProtocolSettings = cloudProtocolSettings; cloudContext.SetLink(cloudOnewayAgreement, "ProtocolSettings", cloudProtocolSettings); var serverX12ProtocolSettings = serverProtocolSettings as Server.X12ProtocolSettings; var cloudX12ProtocolSettings = cloudProtocolSettings as Services.X12ProtocolSettings; if (serverX12ProtocolSettings != null) { this.envelopeOverridesMigrator.MigrateAllX12EnvelopeOverrides(serverX12ProtocolSettings, cloudX12ProtocolSettings); this.validationOverridesMigrator.MigrateAllX12ValidationOverrides(serverX12ProtocolSettings, cloudX12ProtocolSettings); } var serverEdifactProtocolSettings = serverProtocolSettings as Server.EDIFACTProtocolSettings; var cloudEdifactProtocolSettings = cloudProtocolSettings as Services.EDIFACTProtocolSettings; if (serverEdifactProtocolSettings != null) { this.envelopeOverridesMigrator.MigrateAllEdifactEnvelopeOverrides(serverEdifactProtocolSettings, cloudEdifactProtocolSettings); this.validationOverridesMigrator.MigrateAllEdifactValidationOverrides(serverEdifactProtocolSettings, cloudEdifactProtocolSettings); } }
public RavenToolState(IDictionary <string, string> runParameters, string endpointName, IEnumerable <RavenBatch> batches, MigrationStatus migrationStatus) : this(runParameters, endpointName, migrationStatus) { Batches = batches; }
private void bw_MigrationProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.UserState != null) { MigrationStatus status = (MigrationStatus)e.UserState; if (status.Item != null) { ReportServerItem item = (ReportServerItem)status.Item; ListViewItem oItem = new ListViewItem(item.Name); oItem.Checked = true; oItem.Tag = item.Path; oItem.SubItems.Add(item.Path); if (!status.Success) { oItem.SubItems.Add(status.Error.Message); oItem.ForeColor = Color.Red; oItem.ToolTipText = status.Error.Message; this.mSummaryForm.AddFailedItem(item.Path, status.Error.Message); } else { this.mSummaryForm.IncrementSuccessfulItemsCount(); } if (status.Warnings.Length > 0) { string warnings = string.Join("; ", status.Warnings); oItem.SubItems.Add(warnings); oItem.ForeColor = Color.OrangeRed; oItem.ToolTipText = string.Join("\n\r", status.Warnings); } // Assign to proper ListViewGroup if (item.GetType() == typeof(FolderItem)) { oItem.Group = this.lstDestReports.Groups["foldersGroup"]; } else if (item.GetType() == typeof(DataSourceItem)) { oItem.Group = this.lstDestReports.Groups["dataSourcesGroup"]; } else if (item.GetType() == typeof(ReportItem) || item.GetType() == typeof(ReportItemProxy)) { oItem.Group = this.lstDestReports.Groups["reportsGroup"]; } this.lstDestReports.Items.Add(oItem); oItem.EnsureVisible(); progressBar.ToolTipText = item.Name; string msg = string.Format("Migrated item from '{0}' to '{1}'...", status.FromPath, status.ToPath); this.mDebugForm.LogMessage(msg); this.mLogger.Info("MigrationProgressChanged - {0}", msg); this.lblStatus.Text = string.Format("Migrated item '{0}'...", item.Path); this.mSummaryForm.IncrementTotalItemsCount(); } else { this.mLogger.Warn("MigrationProgressChanged - MigrationStatus.Item is NULL for item migrated from '{0}' to '{1}'.", status.FromPath, status.ToPath); } } progressBar.Value = e.ProgressPercentage; progressBar.Maximum = 100; }
public void MigrationWorker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string destinationRootPath = (string)e.Argument; this.mLogger.Debug("MigrationWorker - destinationRootPath: {0}", destinationRootPath); // Stopwatch to track how long the migration takes Stopwatch watch = new Stopwatch(); // Start stopwatch to get how long it takes to get the total number of checked items watch.Start(); IEnumerable <ListViewItem> lvItems = GetListViewItems(this.lstSrcReports).Cast <ListViewItem>(); // Get total count of items in ListView that are checked int totalItems = lvItems.Where(lv => lv.Checked == true).Count(); // Stop stopwatch after getting the total number of checked items, and log how long it took watch.Stop(); this.mLogger.Debug("MigrationWorker - Took {0} seconds to get checked ListView items", watch.Elapsed.TotalSeconds); // Start stopwatch to get how long it takes to migrate everything watch.Start(); int progressCounter = 0; int reportsMigratedCounter = 0; int reportsTotalCount = 0; int foldersMigratedCounter = 0; int foldersTotalCount = 0; int dataSourcesMigratedCounter = 0; int dataSourcesTotalCount = 0; // Export folders // Get path of ListView items in the folder group that are checked. var folderPaths = from lv in lvItems where lv.Group.Name == "foldersGroup" && lv.Checked == true select((FolderItem)lv.Tag).Path; foldersTotalCount = folderPaths.Count(); this.mLogger.Debug("MigrationWorker - Folder migration START!"); this.mLogger.Debug("MigrationWorker - Migrating {0} folders...", foldersTotalCount); foreach (string folderPath in folderPaths) { FolderItem folderItem = null; MigrationStatus status = new MigrationStatus() { Success = false }; if (!string.IsNullOrEmpty(folderPath)) { folderItem = this.mReportServerReader.GetFolder(folderPath); if (folderItem != null) { status.Item = folderItem; status.FromPath = folderItem.Path; this.mLogger.Debug("MigrationWorker - BEFORE FolderItem.FromPath = {0}; SourceRootPath = {1}", status.FromPath, this.mSourceRootPath); this.mLogger.Debug("MigrationWorker - BEFORE FolderItem.FromPath = {0}; DestinationRootPath = {1}", status.FromPath, this.mDestinationRootPath); // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests/Data Sources' to '/SSRSMigrate_AW_Destination/Data Sources' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( this.mSourceRootPath, this.mDestinationRootPath, folderItem.Path); this.mLogger.Debug("MigrationWorker - AFTER FolderItem.FromPath = {0}; destItemPath = {1}", status.FromPath, destItemPath); folderItem.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("MigrationWorker - FolderItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); try { string warning = this.mReportServerWriter.WriteFolder(folderItem); if (!string.IsNullOrEmpty(warning)) { status.Warnings = new string[] { warning } } ; status.Success = true; ++foldersMigratedCounter; if (this.mEngine.Loaded) { try { this.mEngine.CallMethod("OnMigration_FolderItem", folderItem, status); } catch (Exception er) { mLogger.Error(er, "Error calling script"); this.mDebugForm.LogMessage( string.Format("Error calling script when migrating from '{0}' to '{1}': {2}", status.FromPath, status.ToPath, er.Message), er); } } } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Folder item already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Folder can't be migrated from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } } else { this.mLogger.Warn("MigrationWorker - FolderItem for path '{0}' returned NULL.", folderPath); } } // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader. // This will keep the progress bar value from suddenly jumping up several values. if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("MigrationWorker - worker is NULL."); } } this.mLogger.Debug("MigrationWorker - Folder migration END!"); // Export data sources var dataSources = from lv in lvItems where lv.Group.Name == "dataSourcesGroup" && lv.Checked == true select(DataSourceItem) lv.Tag; dataSourcesTotalCount = dataSources.Count(); this.mLogger.Debug("MigrationWorker - DataSource migration START!"); this.mLogger.Debug("MigrationWorker - Migrating {0} datasources...", dataSourcesTotalCount); foreach (DataSourceItem dataSource in dataSources) { string dataSourcePath = dataSource.Path; DataSourceItem dataSourceItem = null; MigrationStatus status = new MigrationStatus() { Success = false }; this.mLogger.Info("MigrationWorker - Start migration of DataSource '{0}'...", dataSourcePath); if (!string.IsNullOrEmpty(dataSourcePath)) { dataSourceItem = this.mReportServerReader.GetDataSource(dataSourcePath); if (dataSourceItem != null) { status.Item = dataSourceItem; status.FromPath = dataSourceItem.Path; // Update the DataSource if it was changed via 'Edit Data Source...' this.mLogger.Debug("MigrationWorker - Checking DataSource equality between source and destination..."); if (!dataSourceItem.Equals(dataSource)) { this.mLogger.Debug("MigrationWorker - DataSources are not equal"); dataSourceItem = dataSource; } else { this.mLogger.Debug("MigrationWorker - DataSources are equal."); } this.mLogger.Debug("MigrationWorker - BEFORE DataSourceItem.FromPath = {0}; SourceRootPath = {1}", status.FromPath, this.mSourceRootPath); this.mLogger.Debug("MigrationWorker - BEFORE DataSourceItem.FromPath = {0}; DestinationRootPath = {1}", status.FromPath, this.mDestinationRootPath); // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests/Data Sources/AWDataSource' to '/SSRSMigrate_AW_Destination/Data Sources/AWDataSource' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( this.mSourceRootPath, this.mDestinationRootPath, dataSourceItem.Path); this.mLogger.Debug("MigrationWorker - AFTER DataSourceItem.FromPath = {0}; destItemPath = {1}", status.FromPath, destItemPath); dataSourceItem.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("MigrationWorker - DataSourceItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); try { string warning = this.mReportServerWriter.WriteDataSource(dataSourceItem); if (!string.IsNullOrEmpty(warning)) { status.Warnings = new string[] { warning } } ; status.Success = true; ++dataSourcesMigratedCounter; try { if (this.mEngine.Loaded) { this.mEngine.CallMethod("OnMigration_DataSourceItem", dataSourceItem, status); } } catch (Exception er) { mLogger.Error(er, "Error calling script"); this.mDebugForm.LogMessage( string.Format("Error calling script when migrating from '{0}' to '{1}': {2}", status.FromPath, status.ToPath, er.Message), er); } } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Data Source item already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Data Source can't be migrated from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } } else { this.mLogger.Warn("MigrationWorker - DataSourceItem for path '{0}' returned NULL.", dataSourcePath); } this.mLogger.Info("MigrationWorker - End migration of DataSource '{0}'...", dataSourcePath); } else { this.mLogger.Warn("MigrationWorker - DataSource.Path is NULL or empty or '{0}'; skipping...", dataSource.Name); } // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader. // This will keep the progress bar value from suddenly jumping up several values. if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("MigrationWorker - worker is NULL."); } } this.mLogger.Debug("MigrationWorker - DataSource migration END!"); // Export reports var reportPaths = from lv in lvItems where lv.Group.Name == "reportsGroup" && lv.Checked == true select((ReportItem)lv.Tag).Path; reportsTotalCount = reportPaths.Count(); this.mLogger.Debug("MigrationWorker - Report migration START!"); this.mLogger.Debug("MigrationWorker - Migrating {0} reports...", reportsTotalCount); foreach (string reportPath in reportPaths) { ReportItem reportItem = null; MigrationStatus status = new MigrationStatus() { Success = false }; if (!string.IsNullOrEmpty(reportPath)) { reportItem = this.mReportServerReader.GetReport(reportPath); if (reportItem != null) { status.Item = reportItem; status.FromPath = reportItem.Path; this.mLogger.Debug( "MigrationWorker - Getting destination path for '{0}' using source path root '{1}' and destination root path '{2}'...", reportItem.Path, this.mSourceRootPath, this.mDestinationRootPath); this.mLogger.Debug("MigrationWorker - BEFORE ReportItem.FromPath = {0}; SourceRootPath = {1}", status.FromPath, this.mSourceRootPath); this.mLogger.Debug("MigrationWorker - BEFORE ReportItem.FromPath = {0}; DestinationRootPath = {1}", status.FromPath, this.mDestinationRootPath); // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests/Reports/Company Sales' to '/SSRSMigrate_AW_Destination/Reports/Company Sales' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( this.mSourceRootPath, this.mDestinationRootPath, reportItem.Path); this.mLogger.Debug("MigrationWorker - AFTER ReportItem.FromPath = {0}; destItemPath = {1}", status.FromPath, destItemPath); reportItem.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("MigrationWorker - ReportItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); reportItem.Definition = SSRSUtil.UpdateReportDefinition( this.mDestinationServerUrl, this.mSourceRootPath, this.mDestinationRootPath, reportItem.Definition); try { string[] warnings = this.mReportServerWriter.WriteReport(reportItem); if (warnings != null) { if (warnings.Length > 0) { status.Warnings = warnings; } } status.Success = true; ++reportsMigratedCounter; try { if (this.mEngine.Loaded) { this.mEngine.CallMethod("OnMigration_ReportItem", reportItem, status); } } catch (Exception er) { mLogger.Error(er, "Error calling script"); this.mDebugForm.LogMessage( string.Format("Error calling script when migrating from '{0}' to '{1}': {2}", status.FromPath, status.ToPath, er.Message), er); } } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Report item already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Report can't be migrated from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } } else { this.mLogger.Warn("MigrationWorker - ReportItem for path '{0}' returned NULL.", reportPath); } } // Always report progress, even if a ListViewItem has an empty path and even if the item isn't retrieved by ReportServerReader. // This will keep the progress bar value from suddenly jumping up several values. if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("MigrationWorker - worker is NULL."); } } this.mLogger.Debug("MigrationWorker - Report migration END!"); // Stop stopwatch and get how long it took for the migration to complete successfully watch.Stop(); double averageItem = watch.Elapsed.TotalSeconds / progressCounter; string result = string.Format("{0}/{1} folders, {2}/{3} data sources, {4}/{5} reports migrated in {6}h {7}m {8}s (@ {9:0.00} items/s)", foldersMigratedCounter, foldersTotalCount, dataSourcesMigratedCounter, dataSourcesTotalCount, reportsMigratedCounter, reportsTotalCount, watch.Elapsed.Hours, watch.Elapsed.Minutes, watch.Elapsed.Seconds, averageItem); this.mLogger.Info("MigrationWorker - {0}", result); e.Result = result; }
public JsonPartner.Rootobject CreatePartners(PartnerMigrationItemViewModel partnerItem) { var partner = partnerItem.MigrationEntity; string partnerName = partner.Name; JsonPartner.Rootobject partnerRootObject = new JsonPartner.Rootobject(); #region Certificates try { if (partner.CertificateName != null && partner.CertificateThumbprint != null) { try { certificateRequired = true; CerificateMigrator <PartnerMigrationItemViewModel> cMigrator = new CerificateMigrator <PartnerMigrationItemViewModel>(thisApplicationContext); cMigrator.CreateCertificates(partner.CertificateName, partner.CertificateThumbprint); succesfullCertificateImport = MigrationStatus.Succeeded; } catch (Exception) { certificateRequired = true; succesfullCertificateImport = MigrationStatus.Failed; } } else { certificateRequired = false; succesfullCertificateImport = MigrationStatus.NotStarted; TraceProvider.WriteLine(string.Format("No certificate is configured with the Partner")); } } catch (Exception ex) { certificateRequired = true; succesfullCertificateImport = MigrationStatus.Failed; TraceProvider.WriteLine(string.Format("Certificate Export to Json Failed:{0}", ExceptionHelper.GetExceptionMessage(ex))); } #endregion #region Partner try { var businessProfile = partner.GetBusinessProfiles().ToList <Server.BusinessProfile>(); List <Microsoft.BizTalk.B2B.PartnerManagement.BusinessIdentity> businessIdentities = new List <Microsoft.BizTalk.B2B.PartnerManagement.BusinessIdentity>(); foreach (var item in businessProfile) { businessIdentities.AddRange(item.GetBusinessIdentities().ToList()); } partnerRootObject = new JsonPartner.Rootobject() { id = "", name = FileOperations.GetFileName(partnerName), type = Resources.JsonPartnerType, properties = new JsonPartner.Properties() { partnerType = Resources.JsonPartnerTypeB2B, content = new JsonPartner.Content() { b2b = new JsonPartner.B2b() { businessIdentities = (businessIdentities.Select(delegate(BizTalk.B2B.PartnerManagement.BusinessIdentity bi) { return(new JsonPartner.Businessidentity() { qualifier = ((Microsoft.BizTalk.B2B.PartnerManagement.QualifierIdentity)bi).Qualifier, value = ((Microsoft.BizTalk.B2B.PartnerManagement.QualifierIdentity)bi).Value }); } )).ToArray() } }, createdTime = DateTime.Now, changedTime = DateTime.Now, metadata = GenerateMetadata(partnerName) } }; string directroyPathForJsonFiles = Resources.JsonPartnerFilesLocalPath; string fileName = string.Format(directroyPathForJsonFiles, FileOperations.GetFileName(partnerName), ".json"); string partnerJsonFileContent = Newtonsoft.Json.JsonConvert.SerializeObject(partnerRootObject); FileOperations.CreateFolder(fileName); System.IO.File.WriteAllText(fileName, partnerJsonFileContent); return(partnerRootObject); } catch (Exception ex) { partnerItem.ImportStatus = MigrationStatus.Failed; partnerItem.ImportStatusText = ex.Message; TraceProvider.WriteLine(string.Format("Partner Export to Json Failed:{0}", ExceptionHelper.GetExceptionMessage(ex))); TraceProvider.WriteLine(); throw ex; } #endregion }
private void ImportWorker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string destinationRootPath = (string)e.Argument; // Get the source root path from the bundle string sourceRootPath = this.mBundleReader.Summary.SourceRootPath; // If the source root path is empty or null, throw an exception if (string.IsNullOrEmpty(sourceRootPath)) { this.mLogger.Fatal("ImportWorker - SourceRootPath is NULL or empty."); throw new Exception("Provided 'SourceRootPath' from bundle is empty."); } this.mLogger.Debug("ImportWorker - SourceRootPath = {0}", sourceRootPath); this.mLogger.Debug("ImportWorker - DestinationRootPath = {0}", this.mDestinationRootPath); // Stopwatch to track how long the import takes Stopwatch watch = new Stopwatch(); // Start stopwatch to get how long it takes to get the total number of checked items watch.Start(); IEnumerable <ListViewItem> lvItems = GetListViewItems(this.lstSrcReports).Cast <ListViewItem>(); // Get total count of items in ListView that are checked int totalItems = lvItems.Where(lv => lv.Checked == true).Count(); // Stop stopwatch after getting the total number of checked items, and log how long it took watch.Stop(); this.mLogger.Debug("ImportWorker - Took {0} seconds to get checked ListView items", watch.Elapsed.TotalSeconds); // Start stopwatch to get how long it takes to import everything watch.Start(); int progressCounter = 0; int reportsImportedCounter = 0; int reportsTotalCount = 0; int foldersImportedCounter = 0; int foldersTotalCount = 0; int dataSourcesImportedCounter = 0; int dataSourcesTotalCount = 0; // Import folders // Get path of ListView items in the folder group that are checked. var folderItems = (from lv in lvItems where lv.Group.Name == "foldersGroup" && lv.Checked == true && lv.Tag != null // We don't want anything with a NULL Tag select new { Item = (FolderItem)lv.Tag, ExtractedTo = lv.SubItems[4].Text }); foldersTotalCount = folderItems.Count(); // Iterate through each item that was checked in the ListView's 'foldersGroup' group foreach (var folderItem in folderItems) { MigrationStatus status = new MigrationStatus() { Success = false, Item = folderItem.Item, FromPath = folderItem.ExtractedTo }; // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests_Destination/Data Sources' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( sourceRootPath, this.mDestinationRootPath, folderItem.Item.Path); this.mLogger.Debug("ImportWorker - Destination path set to '{0}' for folder item '{1}'", destItemPath, folderItem.Item.Path); // Update the FolderItem.Path to be the new destination path folderItem.Item.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("ImportWorker - FolderItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); try { // Write the FolderItem to the server string warning = this.mReportServerWriter.WriteFolder(folderItem.Item); if (!string.IsNullOrEmpty(warning)) { status.Warnings = new string[] { warning } } ; status.Success = true; ++foldersImportedCounter; } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Folder item already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Folder can't be imported from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } // Always report progress if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("ImportWorker - worker is NULL."); } } // Import Data Sources // Get path of ListView items in the data sources group that are checked. var dataSourceItems = (from lv in lvItems where lv.Group.Name == "dataSourcesGroup" && lv.Checked == true && lv.Tag != null // We don't want anything with a NULL Tag select new { Item = (DataSourceItem)lv.Tag, ExtractedTo = lv.SubItems[4].Text }); dataSourcesTotalCount = dataSourceItems.Count(); foreach (var dataSourceItem in dataSourceItems) { MigrationStatus status = new MigrationStatus() { Success = false, Item = dataSourceItem.Item, FromPath = dataSourceItem.ExtractedTo }; // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests_Destination/Data Sources/AWTestDataSource' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( sourceRootPath, this.mDestinationRootPath, dataSourceItem.Item.Path); this.mLogger.Debug("ImportWorker - Destination path set to '{0}' for data source item '{1}'", destItemPath, dataSourceItem.Item.Path); // Update the FolderItem.Path to be the new destination path dataSourceItem.Item.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("ImportWorker - DataSourceItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); try { // Write the DataSourceItem to the server string warning = this.mReportServerWriter.WriteDataSource(dataSourceItem.Item); if (!string.IsNullOrEmpty(warning)) { status.Warnings = new string[] { warning } } ; status.Success = true; ++dataSourcesImportedCounter; } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Data Source already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Data Source can't be imported from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } // Always report progress if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("ImportWorker - worker is NULL."); } } // Import reports // Get path of ListView items in the reports group that are checked. var reportItems = (from lv in lvItems where lv.Group.Name == "reportsGroup" && lv.Checked == true && lv.Tag != null // We don't want anything with a NULL Tag select new { Item = (ReportItem)lv.Tag, ExtractedTo = lv.SubItems[4].Text }); reportsTotalCount = reportItems.Count(); foreach (var reportItem in reportItems) { MigrationStatus status = new MigrationStatus() { Success = false, Item = reportItem.Item, FromPath = reportItem.ExtractedTo }; this.mLogger.Debug( "ImportWorker - Getting destination path for '{0}' using source path root '{1}' and destination root path '{2}'...", reportItem.Item.Path, sourceRootPath, this.mDestinationRootPath); // Get the destination path for this item (e.g. '/SSRSMigrate_AW_Tests_Destination/Reports/Company Sales' string destItemPath = SSRSUtil.GetFullDestinationPathForItem( sourceRootPath, this.mDestinationRootPath, reportItem.Item.Path); this.mLogger.Debug("ImportWorker - Destination path set to '{0}' for report item '{1}'", destItemPath, reportItem.Item.Path); // Update the FolderItem.Path to be the new destination path reportItem.Item.Path = destItemPath; status.ToPath = destItemPath; this.mLogger.Debug("ImportWorker - ReportItem.FromPath = {0}; ToPath = {1}", status.FromPath, status.ToPath); // Update the ReportItem.Definition to point to the new server reportItem.Item.Definition = SSRSUtil.UpdateReportDefinition( this.mDestinationServerUrl, sourceRootPath, this.mDestinationRootPath, reportItem.Item.Definition ); try { // Write ReportItem to server string[] warnings = this.mReportServerWriter.WriteReport(reportItem.Item); if (warnings != null) { if (warnings.Length > 0) { status.Warnings = warnings; } } status.Success = true; ++reportsImportedCounter; } catch (ItemAlreadyExistsException er) { this.mLogger.Error(er, "Report item already exists."); status.Success = false; status.Error = er; this.mDebugForm.LogMessage( string.Format("Report can't be migrated from '{0}' to '{1}', it already exists.", status.FromPath, status.ToPath), er); } // Always report progress if (worker != null) { worker.ReportProgress(((++progressCounter * 100) / totalItems), status); } else { this.mLogger.Warn("ImportWorker - worker is NULL."); } } // Stop stopwatch and get how long it took for the migration to complete successfully watch.Stop(); double averageItem = watch.Elapsed.TotalSeconds / progressCounter; string result = string.Format("{0}/{1} folders, {2}/{3} data sources, {4}/{5} reports imported in {6}h {7}m {8}s (@ {9:0.00} items/s)", foldersImportedCounter, foldersTotalCount, dataSourcesImportedCounter, dataSourcesTotalCount, reportsImportedCounter, reportsTotalCount, watch.Elapsed.Hours, watch.Elapsed.Minutes, watch.Elapsed.Seconds, averageItem); this.mLogger.Info("ImportWorker - {0}", result); e.Result = result; }
public void OnPolicyCard(PolicyCard card) { switch (card.policyType) { case PolicyType.MigrationStatus: { //If you have illegal migration status with N prosperity, gain Documented status - 2 Cards. if (card.policyIndex == 0) { if (migrationStatus == MigrationStatus.undocumented) { if (prosperityCounter > 0) { migrationStatus = MigrationStatus.working; } } } //+n Prosperity if you are illegal, -N prosperity for legal. (vice versa) - 2 Cards. else if (card.policyIndex == 1) { if (migrationStatus == MigrationStatus.undocumented) { IncrementCounter(card.ammount); } else { IncrementCounter(-card.ammount); } } //Lose job if illegal with -n prosperity, legals get +N prosperity. (after 3 turns) - 2 Cards else if (card.policyIndex == 2) { if (migrationStatus == MigrationStatus.undocumented) { if (prosperityCounter < 0) { setJob("Unemployed"); } } else { IncrementCounter(card.ammount); } } break; } case PolicyType.Occupation: { //If you are of X profession +-n. - one card for each profession = 7 cards (any duplicates?) if (card.policyIndex == 0) { if (jobTier == JobTier.tierOne) { if (card.professionName == proffession) { IncrementCounter(card.ammount); } } } //If you are of -N prosperity as X profession +n else -n. - 7 cards else if (card.policyIndex == 1) { if (jobTier == JobTier.tierOne && prosperityCounter < 0) { if (card.professionName == proffession) { IncrementCounter(card.ammount); } } } //If your prosperity is +n you get a promotion in your job, (if you are legal) (after n turns) - 7 cards. else if (card.policyIndex == 2) { if (migrationStatus != MigrationStatus.undocumented) { if (jobTier != JobTier.tierThree) { if (prosperityCounter > 0) { if (jobTier == JobTier.tierOne) { setJob(Characters.tierTwoJobs[Random.Range(0, Characters.tierTwoJobs.Length)]); } } } } } //Gain +N prosperity for X profession, lose -n prosperity for Z profession. - 4P2 = 12cards, only the first four occupation group. else if (card.policyIndex == 3) { if (card.professionName == proffession) { IncrementCounter(card.ammount); } else if (card.professionName2 == proffession) { IncrementCounter(-card.ammount); } } break; } case PolicyType.OccupationHierarchy: { //Tier X workers can gain +n prosperity but tier Z workers will lose -n Prosperity (Vice Versa.) - 3P2 = 6 cards. if (card.policyIndex == 0) { if (jobTier == JobTier.tierOne) { IncrementCounter(card.ammount); } else { IncrementCounter(-card.ammount); } } //Tier X workers can change jobs or promote, if positive prosperity. - 3 Cards. else if (card.policyIndex == 1) { if (prosperityCounter > 0) { setJob(Characters.tierTwoJobs[Random.Range(0, Characters.tierTwoJobs.Length)]); } } break; } } }