internal static void AddToQueue(Rename rename) { queue.Enqueue(rename); if (currentCommand != null) return; currentCommand = rename; var doc = PluginBase.MainForm.CurrentDocument; startState = new StartState { FileName = doc.FileName, CursorPosition = doc.SciControl.CurrentPos, Commands = new[] { rename, null, null } }; var target = rename.Target; bool outputResults = rename.OutputResults; if (HasGetterSetter(target)) { string oldName = rename.OldName; string newName = rename.NewName; var list = target.Member.Parameters; if (list[0].Name == ParamGetter) startState.Commands[1] = RenameMember(target, PrefixGetter + oldName, PrefixGetter + newName, outputResults); if (list[1].Name == ParamSetter) startState.Commands[2] = RenameMember(target, PrefixSetter + oldName, PrefixSetter + newName, outputResults); } else if ((RefactoringHelper.GetRefactoringTarget(target).Flags & (FlagType.Constructor | FlagType.Class)) > 0) { var ext = Path.GetExtension(startState.FileName); startState.FileName = startState.FileName.Replace(rename.OldName + ext, rename.NewName + ext); } if (outputResults) PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ClearResults"); ExecuteFirst(); }
IEnumerable<Event> Handle(Rename cmd) { CheckIsActive(); if (string.IsNullOrEmpty(cmd.NewName)) throw new ArgumentException("Inventory item name cannot be null or empty"); yield return new InventoryItemRenamed(name, cmd.NewName); }
public Response DispatchCommand() { var cmdName = Parameters["cmd"]; if (string.IsNullOrEmpty(cmdName)) { return new ErrorResponse("Command not set"); } ICommand cmd = null; switch (cmdName) { case "open": if (!string.IsNullOrEmpty(Parameters["init"]) && Parameters["init"] == "true") cmd = new Init(); else { cmd = new Open(Parameters["target"]); } break; case "mkdir": cmd = new MkDir(Parameters["current"], Parameters["name"]); break; case "rm": cmd = new Rm(Parameters["current"], Parameters["targets[]"]); break; case "rename": cmd = new Rename(Parameters["current"], Parameters["target"], Parameters["name"]); break; case "upload": cmd = new Upload(Parameters["current"], Files); break; case "ping": cmd = new Ping(); break; case "duplicate": cmd = new Duplicate(Parameters["current"], Parameters["target"]); break; case "paste": cmd = new Paste(Parameters["src"], Parameters["dst"], Parameters["targets[]"], Parameters["cut"]); break; } if (cmd == null) { return new ErrorResponse("Unknown command"); } return cmd.Execute(); return new ErrorResponse("Unknown error"); }
public override void Down() { Delete.ForeignKey("FK_RecentBooks_Accounts_AccountId").OnTable(Tables.RecentBooks).InSchema(Schemas.Dbo); Delete.ForeignKey("FK_FavoriteBooks_Accounts_AccountId").OnTable(Tables.FavoriteBooks).InSchema(Schemas.Dbo); Delete.ForeignKey("FK_BookShelf_Accounts_AccountId").OnTable(Tables.BookShelf).InSchema(Schemas.Dbo); Delete.ForeignKey("FK_BookPage_Accounts_AccountId").OnTable(Tables.BookPage).InSchema(Schemas.Dbo); Rename.Column("AccountId").OnTable(Tables.RecentBooks).InSchema(Schemas.Dbo) .To("UserId"); Rename.Column("AccountId").OnTable(Tables.FavoriteBooks).InSchema(Schemas.Dbo) .To("UserId"); Rename.Column("AccountId").OnTable(Tables.BookShelf).InSchema(Schemas.Dbo) .To("UserId"); Rename.Column("AccountId").OnTable(Tables.BookPage).InSchema(Schemas.Dbo) .To("UserId"); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Rename rename = target as Rename; rename.mNewName = EditorGUILayout.TextField("NewName", rename.mNewName); if (rename.mAddNumber = EditorGUILayout.Toggle("AddNumber", rename.mAddNumber)) { rename.mZeroFill = EditorGUILayout.Toggle("ZeroFill?(from 01)", rename.mZeroFill); } if (GUILayout.Button("Change Name")) { rename.RenameStart(); } }
public override void Up() { Rename.Column("character").OnTable("character_jobs").To("characterId"); Delete.ForeignKey("character_job_character_id_fk").OnTable("character_jobs"); Delete.Index("character_job_character_job_uindex").OnTable("character_jobs"); Create.PrimaryKey("PRIMARY2").OnTable("character_jobs") .Columns("jobId", "characterId"); Create.Index("IX_character_jobs_characterId") .OnTable("character_jobs").OnColumn("characterId"); Create.ForeignKey("FK_character_jobs_characterId_characters_id") .FromTable("character_jobs").ForeignColumn("characterId") .ToTable("characters").PrimaryColumn("id"); }
public override void Up() { Create.Column("TerminalTableScreenId").OnTable("Departments").AsInt32().WithDefaultValue(0); Create.Column("TableScreenId").OnTable("Departments").AsInt32().WithDefaultValue(0); Create.Column("ScreenMenuId").OnTable("Departments").AsInt32().WithDefaultValue(0); Create.Column("TerminalScreenMenuId").OnTable("Departments").AsInt32().WithDefaultValue(0); Create.Column("PageCount").OnTable("ScreenMenuCategories").AsInt32().WithDefaultValue(1); Create.Column("PageCount").OnTable("TableScreens").AsInt32().WithDefaultValue(1); Create.Column("ColumnCount").OnTable("TableScreens").AsInt32().WithDefaultValue(0); Create.Column("ButtonHeight").OnTable("TableScreens").AsInt32().WithDefaultValue(80); Create.Column("CharsPerLine").OnTable("Printers").AsInt32().WithDefaultValue(42); Create.Column("CodePage").OnTable("Printers").AsInt32().WithDefaultValue(857); Rename.Column("AlaCarte").OnTable("Departments").To("IsAlaCarte"); Rename.Column("FastFood").OnTable("Departments").To("IsFastFood"); Rename.Column("TakeAway").OnTable("Departments").To("IsTakeAway"); }
private static void ExecuteFirst() { try { currentCommand = queue.Dequeue(); currentCommand.OnRefactorComplete += OnRefactorComplete; currentCommand.Execute(); } catch (Exception ex) { queue.Clear(); currentCommand = null; startState = null; ErrorManager.ShowError(ex); } }
static void ExecuteFirst() { try { currentCommand = queue[0]; queue.Remove(currentCommand); currentCommand.OnRefactorComplete += OnRefactorComplete; currentCommand.Execute(); } catch (Exception ex) { queue.Clear(); currentCommand = null; ErrorManager.ShowError(ex); } }
public override void Down() { Delete.Column("TerminalTableScreenId").FromTable("Departments"); Delete.Column("TableScreenId").FromTable("Departments"); Delete.Column("ScreenMenuId").FromTable("Departments"); Delete.Column("TerminalScreenMenuId").FromTable("Departments"); Delete.Column("PageCount").FromTable("ScreenMenuCategories"); Delete.Column("PageCount").FromTable("TableScreens"); Delete.Column("ColumnCount").FromTable("TableScreens"); Delete.Column("ButtonHeight").FromTable("TableScreens"); Delete.Column("CodePage").FromTable("Printers"); Delete.Column("CharsPerLine").FromTable("Printers"); Rename.Column("IsAlaCarte").OnTable("Departments").To("AlaCarte"); Rename.Column("IsFastFood").OnTable("Departments").To("FastFood"); Rename.Column("IsTakeAway").OnTable("Departments").To("TakeAway"); }
public override void Up() { LogProvider.Log.Info("Preparing migration #24."); try { if (Schema.Table(playerNotesTempTableName).Exists()) { Delete.Table(playerNotesTempTableName); } if (Schema.Table(playerNotesTableName).Exists()) { if (Schema.Table(playerNotesTableName).Index(playerNotesIndexName).Exists()) { Delete.Index(playerNotesIndexName).OnTable(playerNotesTableName); } Rename.Table(playerNotesTableName).To(playerNotesTempTableName); } Create.Table(playerNotesTableName) .WithColumn("PlayerNoteId").AsInt32().PrimaryKey().NotNullable() .WithColumn("PlayerId").AsInt32().NotNullable() .WithColumn("Note").AsString().NotNullable() .WithColumn("CardRange").AsString().Nullable() .WithColumn("Timestamp").AsDateTime().Nullable() .WithColumn("IsAutoNote").AsBoolean().NotNullable().WithDefaultValue(false) .WithColumn("GameNumber").AsInt64().Nullable() .WithColumn("PokerSiteId").AsInt32().NotNullable(); Create.Index(playerNotesIndexName).OnTable(playerNotesTableName).OnColumn("PlayerId"); if (Schema.Table(playerNotesTempTableName).Exists()) { Execute.Sql($"INSERT INTO {playerNotesTableName} (PlayerNoteId, PlayerId, Note, PokerSiteId) SELECT PlayerNoteId, PlayerId, Note, PokerSiteId FROM {playerNotesTempTableName} WHERE Note is not null"); Delete.Table(playerNotesTempTableName); } } catch (Exception e) { LogProvider.Log.Error(this, "Migration #24 failed.", e); throw; } LogProvider.Log.Info("Migration #24 executed."); }
private void ConvertLinkedTableToUuid( string tableName, string foreignKey, string columnName, string newColumnName, string targetTableName, string targetColumnName, string?previousIndexName, bool nullable = false ) { Alter.Table(tableName).AddColumn("tmpUuid").AsCustom("CHAR(36) CHARACTER SET ascii").Nullable(); Execute.Sql($"UPDATE `{tableName}` SET `tmpUuid` = (SELECT `tmpBaseUuid` FROM `{targetTableName}` WHERE `{tableName}`.`{columnName}` = `{targetTableName}`.`{targetColumnName}`)"); Delete.ForeignKey(foreignKey).OnTable(tableName); Alter.Column(columnName).OnTable(tableName).AsCustom("CHAR(36) CHARACTER SET ascii").Nullable(); Execute.Sql($"UPDATE `{tableName}` SET `{columnName}` = `tmpUuid`"); Delete.Column("tmpUuid").FromTable(tableName); Rename.Column(columnName).OnTable(tableName).To(newColumnName); if (nullable) { Alter.Column(newColumnName).OnTable(tableName).AsCustom("CHAR(36) CHARACTER SET ascii").Nullable(); } else { Alter.Column(newColumnName).OnTable(tableName).AsCustom("CHAR(36) CHARACTER SET ascii").NotNullable(); } if (!string.IsNullOrEmpty(previousIndexName)) { Delete.Index(previousIndexName).OnTable(tableName); } Create.Index("IX_" + tableName + "_" + newColumnName).OnTable(tableName).OnColumn(newColumnName); var foreignKeyName = "FK_" + tableName + "_" + newColumnName + "_" + targetTableName + "_" + targetColumnName; if (foreignKeyName.Length > 64) { foreignKeyName = "FK_" + tableName + "_" + newColumnName; } Create.ForeignKey(foreignKeyName) .FromTable(tableName).ForeignColumn(newColumnName) .ToTable(targetTableName).PrimaryColumn("tmpBaseUuid") .OnDeleteOrUpdate(Rule.None); }
public void Edit(List <string> list, string m) { Console.Write("\n\nВведите номер объекта (1 - 5), которого хотите изменить: "); int number = Convert.ToInt32(Console.ReadLine()); if (number > 0 && number < list.Count) { Console.Write("Введите новый объект: "); string name = Console.ReadLine(); list[number - 1] = name; Rename?.Invoke(list, "Изменение прошло успешно\nНовый список объектов:"); } else { throw new Exception("Неверно задан номер объекта в методе Programmer.Edit"); } }
public override void Up() { Rename.Table("AppointmentTypes").To("ActivityTypes"); Delete.ForeignKey("FK_LearningLogItems_AdminUsers").OnTable("LearningLogItems"); Rename.Column("ApptTypeID").OnTable("ActivityTypes").To("ID"); Alter.Table("LearningLogItems") .AlterColumn("ActivityTypeID").AsInt32().NotNullable() .ForeignKey("ActivityTypes", "ID"); Execute.Sql(@"INSERT INTO ActivityTypes (TypeLabel, TypeCaption, SchedulerOrderNum) VALUES ('Learning Hub Resource', 'Learning Hub Resource', (SELECT Max(SchedulerOrderNum)+1 FROM ActivityTypes))"); }
public void GivenTodoItem_TitleChanged() { var context = new InMemoryContext(); var gateway = new InMemoryItemGateway(context); var responseHandler = new ResponseHandler(); var entitiesFactory = new DefaultEntitiesFactory(); var todo = new Core.UseCases.Todo(responseHandler, gateway, entitiesFactory); todo.Execute(new Core.Boundaries.Todo.Request("My Title")); var request = new Request(responseHandler.TodoItems[0].ItemId.ToString(), "New Title"); var updatedTitle = new Rename(gateway); Exception ex = Record.Exception(() => updatedTitle.Execute(request)); Assert.Null(ex); }
public static T Parameter <T>( IParameterSymbol from, IParameterSymbol to, T node, SemanticModel semanticModel, CancellationToken cancellationToken) where T : SyntaxNode { if (from.Name == to.Name) { return(node); } var rename = new Rename(@from, to, semanticModel, cancellationToken); return((T)rename.Visit(node)); }
private void button3_Click(object sender, EventArgs e) { try { int step = listBox1.SelectedIndex; Rename form_new3 = new Rename(array_human[step]); form_new3.ShowDialog(); } catch (Exception) { MessageBox.Show("Не выделенно поле для действия"); } Up_f(); }
private void CopyTagNameToId(string tableName, string foreignKeyColumnName, bool nullable = false) { var tagNameColumn = string.Format("{0}Name", foreignKeyColumnName); Rename.Column(foreignKeyColumnName).OnTable(tableName).To(tagNameColumn); Create.Column(foreignKeyColumnName).OnTable(tableName).AsInt32().Nullable(); // Ex. UPDATE SongTagUsages SET SongTagUsages.Tag = Tags.Id FROM SongTagUsages INNER JOIN Tags ON (SongTagUsages.TagName = Tags.Name) Execute.Sql(string.Format("UPDATE {0} SET {0}.{1} = SourceTable.Id FROM {0} INNER JOIN {2} SourceTable ON ({0}.{3} = SourceTable.Name)", tableName, foreignKeyColumnName, TableNames.Tags, tagNameColumn)); if (!nullable) { Alter.Column(foreignKeyColumnName).OnTable(tableName).AsInt32().NotNullable(); } Delete.Column(tagNameColumn).FromTable(tableName); }
public override void Up() { using var sql = new SqlConnection(ConnectionString); using var command = sql.CreateCommand(); command.CommandText = "SELECT * FROM INFORMATION_SCHEMA.TABLES;"; sql.Open(); using var reader = command.ExecuteReader(); while (reader.Read()) { var table = reader[2].ToString(); if (table.Contains("OrderLog")) { Rename.Column("FulfillmentDate").OnTable(table).To("FulFilled"); } } sql.Close(); }
internal static void AddToQueue(Rename rename) { queue.Enqueue(rename); if (currentCommand != null) { return; } currentCommand = rename; var doc = PluginBase.MainForm.CurrentDocument; startState = new StartState { FileName = doc.FileName, CursorPosition = doc.SciControl.CurrentPos, Commands = new[] { rename, null, null } }; var target = rename.Target; bool outputResults = rename.OutputResults; if (HasGetterSetter(target)) { string oldName = rename.OldName; string newName = rename.NewName; var list = target.Member.Parameters; if (list[0].Name == ParamGetter) { startState.Commands[1] = RenameMember(target, PrefixGetter + oldName, PrefixGetter + newName, outputResults); } if (list[1].Name == ParamSetter) { startState.Commands[2] = RenameMember(target, PrefixSetter + oldName, PrefixSetter + newName, outputResults); } } if (outputResults) { PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ClearResults"); } ExecuteFirst(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.sheetRenameAuthenticator, null); _issuerLayout = view.FindViewById <TextInputLayout>(Resource.Id.editIssuerLayout); _issuerText = view.FindViewById <TextInputEditText>(Resource.Id.editIssuer); _usernameText = view.FindViewById <TextInputEditText>(Resource.Id.editUsername); _issuerText.Text = _issuer; _usernameText.Text = _username; var cancelButton = view.FindViewById <MaterialButton>(Resource.Id.buttonCancel); cancelButton.Click += (s, e) => { Dismiss(); }; var renameButton = view.FindViewById <MaterialButton>(Resource.Id.buttonRename); renameButton.Click += (s, e) => { var issuer = _issuerText.Text.Trim(); if (issuer == "") { _issuerLayout.Error = GetString(Resource.String.noIssuer); return; } var args = new RenameEventArgs(_itemPosition, issuer, _usernameText.Text); Rename?.Invoke(this, args); Dismiss(); }; _usernameText.EditorAction += (sender, args) => { if (args.ActionId == ImeAction.Done) { renameButton.PerformClick(); } }; return(view); }
static void RenameRepository() { ListRepositories(); Console.Write("Write the name of the repository to rename: "); string repository = Console.ReadLine(); Console.Write(string.Format("Write a new name for {0}: ", repository)); string newName = Console.ReadLine(); Rename action = new Rename() { Name = newName }; Repository renamedRepo = ApiUtils.RenameRepository(repository, action).Result; Console.Write(string.Format("Repository {0} successfully renamed to {1}.", repository, renamedRepo.Name)); }
private void ConversationListContainer_AddConversation(object sender, EventArgs e) { _parent.Darkened = true; Rename addConversation = new Rename(); addConversation.CancelButtonClicked += (s, ea) => { _parent.Darkened = false; _parent.mainCanvas.Children.Remove(addConversation); }; addConversation.ReadyButtonClicked += (s, ea) => { _parent.Client.AddNewConversation(addConversation.NewName); _parent.Darkened = false; _parent.mainCanvas.Children.Remove(addConversation); }; _parent.mainCanvas.Children.Add(addConversation); }
public void EvaluateFolderNamePattern() { Rename.EvaluateFolderNamePattern("pre_{name:0,2}_{name:2,2}_post", folder) .Should().Be($"pre_te_st_post"); Rename.EvaluateFolderNamePattern("pre_{cdate:yyyy}_{cdate:MM}_{cdate:dd}_post", folder) .Should().Be($"pre_2001_02_03_post"); Rename.EvaluateFolderNamePattern("pre_{mdate:yyyy}_{mdate:MM}_{mdate:dd}_post", folder) .Should().Be($"pre_2004_05_06_post"); var date = DateTime.Now; Rename.EvaluateFolderNamePattern("pre_{now:yyyy}_{now:MM}_{now:dd}_post", null) .Should().Be($"pre_{date:yyyy}_{date:MM}_{date:dd}_post"); Rename.EvaluateFolderNamePattern("pre_{pfolder:0,2}_{pfolder:2,2}_post", folder) .Should().Be($"pre_te_mp_post"); }
private void Parent_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (string.IsNullOrEmpty(e.PropertyName) || e.PropertyName == nameof(SelectedStyle)) { if (selectedStyle != null) { selectedStyle.PropertyChanged -= SelectedStyle_PropertyChanged; } selectedStyle = parent.SelectedStyle; if (selectedStyle != null) { selectedStyle.PropertyChanged += SelectedStyle_PropertyChanged; selectedIndex = parent.Styles.IndexOf(selectedStyle); RaisePropertyChanged(""); } newName = null; Delete.RaiseCanExecuteChanged(); Rename.RaiseCanExecuteChanged(); } }
public override void Up() { Rename.Table("SubNode").To("Port"); Rename.Column("subNodeId").OnTable("Port").To("portId"); Alter.Column("pulseCount").OnTable("Port").AsInt32().Nullable(); Alter.Table("Port") .AddColumn("direction").AsFixedLengthAnsiString(1) .AddColumn("type").AsFixedLengthAnsiString(1) .AddColumn("state").AsBoolean().Nullable() .AddColumn("value").AsInt16().Nullable(); Update.Table("Port").Set(new { direction = "S", type = "P" }).AllRows(); Alter.Column("direction").OnTable("Port").AsFixedLengthAnsiString(1).NotNullable(); Alter.Column("type").OnTable("Port").AsFixedLengthAnsiString(1).NotNullable(); Create.UniqueConstraint("UC_nodeId_number").OnTable("Port").Columns("nodeId", "number"); Create.Index("IX_nodeId_number").OnTable("Port").OnColumn("nodeId").Ascending().OnColumn("number").Ascending(); }
} // end HandleAction public static bool HandleAction(Connection connection, string sUserId, ActionTypes actionType, string sArg3) { int iArg3; switch (actionType) { case SandsOfTime.Actions.ActionTypes.Start: return (Start.Execute(connection, sUserId, sArg3) > 0); case SandsOfTime.Actions.ActionTypes.Stop: return (Stop.Execute(connection, sUserId) > 0); case SandsOfTime.Actions.ActionTypes.Resume: return (Resume.Execute(connection, sUserId, sArg3) > 0); case SandsOfTime.Actions.ActionTypes.Rename: return (Rename.Execute(connection, sUserId, sArg3) > 0); case SandsOfTime.Actions.ActionTypes.List: return (List.Execute(connection, sUserId, int.TryParse(sArg3, out iArg3) ? iArg3 : 0) > 0); default: return (false); } // end switch } // end HandleAction
protected override void MainDbUpgrade() { Alter.Table("PendingReleases").AddColumn("Reason").AsInt32().WithDefaultValue(0); Rename.Column("IndexerId").OnTable("IndexerStatus").To("ProviderId"); Rename.Column("EnableSearch").OnTable("Indexers").To("EnableAutomaticSearch"); Alter.Table("Indexers").AddColumn("EnableInteractiveSearch").AsBoolean().Nullable(); Execute.Sql("UPDATE Indexers SET EnableInteractiveSearch = EnableAutomaticSearch"); Alter.Table("Indexers").AlterColumn("EnableInteractiveSearch").AsBoolean().NotNullable(); Create.TableForModel("DownloadClientStatus") .WithColumn("ProviderId").AsInt32().NotNullable().Unique() .WithColumn("InitialFailure").AsDateTime().Nullable() .WithColumn("MostRecentFailure").AsDateTime().Nullable() .WithColumn("EscalationLevel").AsInt32().NotNullable() .WithColumn("DisabledTill").AsDateTime().Nullable(); }
public override void Migrate() { Rename.Table("cmsMedia").To(Constants.DatabaseSchema.Tables.MediaVersion).Do(); // that is not supported on SqlCE //Rename.Column("versionId").OnTable(Constants.DatabaseSchema.Tables.MediaVersion).To("id").Do(); AddColumn <MediaVersionDto>("id", out var sqls); // SQLCE does not support UPDATE...FROM var temp2 = Database.Fetch <dynamic>($@"SELECT v.versionId, v.id FROM cmsContentVersion v JOIN umbracoNode n on v.contentId=n.id WHERE n.nodeObjectType='{Constants.ObjectTypes.Media}'"); foreach (var t in temp2) { Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.MediaVersion} SET id={t.id} WHERE versionId='{t.versionId}'").Do(); } foreach (var sql in sqls) { Execute.Sql(sql).Do(); } AddColumn <MediaVersionDto>("path", out sqls); Execute.Sql($"UPDATE {Constants.DatabaseSchema.Tables.MediaVersion} SET path=mediaPath").Do(); foreach (var sql in sqls) { Execute.Sql(sql).Do(); } // we had to run sqls to get the NULL constraints, but we need to get rid of most Delete.KeysAndIndexes(Constants.DatabaseSchema.Tables.MediaVersion).Do(); Delete.Column("mediaPath").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do(); Delete.Column("versionId").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do(); Delete.Column("nodeId").FromTable(Constants.DatabaseSchema.Tables.MediaVersion).Do(); }
public override void Down() { Execute.Sql("UPDATE LearningLogItems SET LoggedByID = 0 WHERE LoggedByID IS NULL"); Execute.Sql("UPDATE LearningLogItems SET LinkedCustomisationID = 0 WHERE LinkedCustomisationID IS NULL"); Execute.Sql("UPDATE LearningLogItems SET LoggedByAdminID = 0 WHERE LoggedByAdminID IS NULL"); Delete.Column("LastAccessedDate").FromTable("LearningLogItems"); Delete.ForeignKey("FK_LearningLogItems_LinkedCompetencyLearningResourceID_CompetencyLearningResources_ID").OnTable("LearningLogItems"); Delete.Column("LinkedCompetencyLearningResourceID").FromTable("LearningLogItems"); Rename.Column("Activity").OnTable("LearningLogItems").To("Topic"); Rename.Column("ActivityTypeID").OnTable("LearningLogItems").To("AppointmentTypeID"); Rename.Column("ExternalUri").OnTable("LearningLogItems").To("CallUri"); Alter.Table("LearningLogItems") .AddColumn("MethodID").AsInt32().Nullable().ForeignKey("FK_LearningLogItems_Methods", "Methods", "MethodID") .AddColumn("MethodOther").AsString(255).Nullable() .AlterColumn("LoggedByID").AsInt32().NotNullable() .AlterColumn("LinkedCustomisationID").AsInt32().NotNullable() .AlterColumn("LoggedByAdminID").AsInt32().NotNullable(); }
private static void OnRefactorComplete(object sender, RefactorCompleteEventArgs <IDictionary <string, List <SearchMatch> > > e) { currentCommand.OnRefactorComplete -= OnRefactorComplete; if (queue.Count == 0) { //if (currentCommand.OutputResults) //{ // PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); //} if (startState != null) { RestoreStartState(); } currentCommand = null; startState = null; } else { ExecuteFirst(); } }
protected override void MainDbUpgrade() { Rename.Table("QualityProfiles").To("Profiles"); Alter.Table("Profiles").AddColumn("Language").AsInt32().Nullable(); Alter.Table("Profiles").AddColumn("GrabDelay").AsInt32().Nullable(); Alter.Table("Profiles").AddColumn("GrabDelayMode").AsInt32().Nullable(); Execute.Sql("UPDATE Profiles SET Language = 1, GrabDelay = 0, GrabDelayMode = 0"); //Rename QualityProfileId in Series Alter.Table("Series").AddColumn("ProfileId").AsInt32().Nullable(); Execute.Sql("UPDATE Series SET ProfileId = QualityProfileId"); //Add HeldReleases Create.TableForModel("PendingReleases") .WithColumn("SeriesId").AsInt32() .WithColumn("Title").AsString() .WithColumn("Added").AsDateTime() .WithColumn("ParsedEpisodeInfo").AsString() .WithColumn("Release").AsString(); }
public override void Up() { Rename.Column("RHI5").OnTable("Sites").InSchema("Sites").To("ComputedRHI5"); Rename.Column("RHI10").OnTable("Sites").InSchema("Sites").To("ComputedRHI10"); Rename.Column("RHI20").OnTable("Sites").InSchema("Sites").To("ComputedRHI20"); Rename.Column("RGI5").OnTable("Sites").InSchema("Sites").To("ComputedRGI5"); Rename.Column("RGI10").OnTable("Sites").InSchema("Sites").To("ComputedRGI10"); Rename.Column("RGI20").OnTable("Sites").InSchema("Sites").To("ComputedRGI20"); Create.Column("ComputedTreesMeasuredCount").OnTable("Sites").InSchema("Sites").AsInt32().Nullable(); Rename.Column("LastVisited").OnTable("Sites").InSchema("Sites").To("ComputedLastMeasurementDate"); Alter.Column("ComputedLastMeasurementDate").OnTable("Sites").InSchema("Sites").AsDate().Nullable(); Create.Column("ComputedContainsEntityWithCoordinates").OnTable("Sites").InSchema("Sites").AsBoolean().Nullable(); Create.Column("AreMetricsStale").OnTable("Sites").InSchema("Sites").AsBoolean().WithDefaultValue(true); Create.Column("LastMetricsUpdateTimestamp").OnTable("Sites").InSchema("Sites").AsDateTime().Nullable(); Rename.Column("RHI5").OnTable("Subsites").InSchema("Sites").To("ComputedRHI5"); Rename.Column("RHI10").OnTable("Subsites").InSchema("Sites").To("ComputedRHI10"); Rename.Column("RHI20").OnTable("Subsites").InSchema("Sites").To("ComputedRHI20"); Rename.Column("RGI5").OnTable("Subsites").InSchema("Sites").To("ComputedRGI5"); Rename.Column("RGI10").OnTable("Subsites").InSchema("Sites").To("ComputedRGI10"); Rename.Column("RGI20").OnTable("Subsites").InSchema("Sites").To("ComputedRGI20"); Create.Column("ComputedTreesMeasuredCount").OnTable("Subsites").InSchema("Sites").AsInt32().Nullable(); Rename.Column("LastVisited").OnTable("Subsites").InSchema("Sites").To("ComputedLastMeasurementDate"); Alter.Column("ComputedLastMeasurementDate").OnTable("Subsites").InSchema("Sites").AsDate().Nullable(); Create.Column("ComputedContainsEntityWithCoordinates").OnTable("Subsites").InSchema("Sites").AsBoolean().Nullable(); Create.Column("AreMetricsStale").OnTable("Subsites").InSchema("Sites").AsBoolean().WithDefaultValue(true); Create.Column("LastMetricsUpdateTimestamp").OnTable("Subsites").InSchema("Sites").AsDateTime().Nullable(); Create.Column("ComputedRHI5").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedRHI10").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedRHI20").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedRGI5").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedRGI10").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedRGI20").OnTable("States").InSchema("Locations").AsFloat().Nullable(); Create.Column("ComputedTreesMeasuredCount").OnTable("States").InSchema("Locations").AsInt32().Nullable(); Create.Column("ComputedLastMeasurementDate").OnTable("States").InSchema("Locations").AsDate().Nullable(); Create.Column("ComputedContainsEntityWithCoordinates").OnTable("States").InSchema("Locations").AsBoolean().Nullable(); Create.Column("AreMetricsStale").OnTable("States").InSchema("Locations").AsBoolean().WithDefaultValue(true); Create.Column("LastMetricsUpdateTimestamp").OnTable("States").InSchema("Locations").AsDateTime().Nullable(); }
private bool ApplyClassRename(Rename ren) { var classToRename = _classCollection.GetClassMetadata(ren.rFrom); if (classToRename == null) { return false; } var existing = _classCollection.GetClassMetadata(ren.rTo); if (existing != null) { LogMsg(9, "class " + ren.rTo); return false; } classToRename.SetName(ren.rTo); CommitRenameFor(ren, classToRename); return true; }
private void RenameFiles(Rename renameDelegate) { this.Enabled = false; if (!(string.IsNullOrEmpty(this.m_directoryText.Text)) && System.IO.Directory.Exists(this.m_directoryText.Text)) { this.m_outputText.Text = string.Empty; System.Text.StringBuilder output = new StringBuilder(); string FileFormat = "{0}\\{1}", File; System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(this.m_directoryText.Text); string tempFolderName = System.Guid.NewGuid().ToString(); string moveTo = string.Format("{0}\\{1}", di.FullName, tempFolderName); System.IO.Directory.CreateDirectory(moveTo); string moveBack = this.m_directoryText.Text; foreach (System.IO.FileInfo fi in di.GetFiles(this.m_maskText.Text)) { try { string to = string.Format(FileFormat, moveTo, fi.Name); fi.MoveTo(to); File = renameDelegate(fi.Name); File = string.Format(FileFormat , di.FullName , File); if (File != fi.FullName) { File = File.Replace(tempFolderName, string.Empty); File.Replace("\\\\", "\\"); output.AppendFormat("{0}->{1}{2}", fi.FullName, File, System.Environment.NewLine); fi.MoveTo(File); output.Append("Success."); output.Append(System.Environment.NewLine); } else { output.AppendFormat("Name Won't Change: {0}", fi.FullName); output.Append(System.Environment.NewLine); } } catch (System.Exception ex) { output.AppendFormat("Failure.{0}{1}{0}" , System.Environment.NewLine , ex.Message); } } System.IO.Directory.Delete(moveTo); this.m_outputText.Text = output.ToString(); } this.Enabled = true; }
private bool ApplyFieldRename(Rename ren) { var parentClass = _classCollection.GetClassMetadata(ren.rClass); if (parentClass == null) { return false; } if (!parentClass.RenameField(ren.rFrom, ren.rTo)) { return false; } CommitRenameFor(ren, parentClass); return true; }
private void CommitRenameFor(Rename rename, ClassMetadata classMetadata) { SetDirtyInSystemTransaction(classMetadata); LogMsg(8, rename.rFrom + " to " + rename.rTo); DeleteInverseRenames(rename); // store the rename, so we only do it once Store(SystemTransaction(), rename); }
public static Rename ForInverseQBE(Rename ren) { return new Rename(ren.rClass, null, ren.rFrom); }
/// <summary> /// Invoked when the user selects the "Rename" command /// </summary> private void RenameClicked(Object sender, EventArgs e) { try { Rename command = new Rename(true); command.Execute(); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
private bool AlreadyApplied(Rename ren) { return QueryByExample(SystemTransaction(), ren).Count != 0; }
public void Execute(IArray paramvalues, ITrackCancel trackcancel, IGPEnvironmentManager envMgr, IGPMessages messages) { // Remember the original GP environment settings and temporarily override these settings var gpSettings = envMgr as IGeoProcessorSettings; bool origAddOutputsToMapSetting = gpSettings.AddOutputsToMap; bool origLogHistorySetting = gpSettings.LogHistory; gpSettings.AddOutputsToMap = false; gpSettings.LogHistory = false; // Create the Geoprocessor Geoprocessor gp = new Geoprocessor(); try { // Validate our values IGPMessages validateMessages = ((IGPFunction2)this).Validate(paramvalues, false, envMgr); if ((validateMessages as IGPMessage).IsError()) { messages.AddError(1, "Validate failed"); return; } // Unpack values IGPParameter gpParam = paramvalues.get_Element(InputAETable) as IGPParameter; IGPValue inputAETableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputAdminAreaFeatureClasses) as IGPParameter; var inputAdminAreaFeatureClassesMultiValue = m_gpUtils.UnpackGPValue(gpParam) as IGPMultiValue; gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter; IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTATable) as IGPParameter; IGPValue inputTATableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputNWFeatureClass) as IGPParameter; IGPValue inputNWFeatureClassValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTimeZoneIDBaseFieldName) as IGPParameter; IGPValue inputTimeZoneIDBaseFieldNameValue = m_gpUtils.UnpackGPValue(gpParam); if (inputTATableValue.IsEmpty() ^ inputNWFeatureClassValue.IsEmpty()) { messages.AddError(1, "The TA table and NW feature class must be specified together."); return; } bool processStreetsFC = (!(inputNWFeatureClassValue.IsEmpty())); string timeZoneIDBaseFieldName = ""; if (!(inputTimeZoneIDBaseFieldNameValue.IsEmpty())) timeZoneIDBaseFieldName = inputTimeZoneIDBaseFieldNameValue.GetAsText(); // Get the path to the output file GDB string outputFileGdbPath = outputFileGDBValue.GetAsText(); // Create the new file geodatabase AddMessage("Creating the file geodatabase...", messages, trackcancel); int lastBackslash = outputFileGdbPath.LastIndexOf("\\"); CreateFileGDB createFGDBTool = new CreateFileGDB(); createFGDBTool.out_folder_path = outputFileGdbPath.Remove(lastBackslash); createFGDBTool.out_name = outputFileGdbPath.Substring(lastBackslash + 1); gp.Execute(createFGDBTool, trackcancel); // Copy the admin area feature classes int numAdminAreaFCs = inputAdminAreaFeatureClassesMultiValue.Count; string mergeToolInputs = ""; for (int i = 0; i < numAdminAreaFCs; i++) { AddMessage("Copying the Administrative Area feature classes (" + Convert.ToString(i+1) + " of " + Convert.ToString(numAdminAreaFCs) + ")...", messages, trackcancel); string origAdminFCPath = inputAdminAreaFeatureClassesMultiValue.get_Value(i).GetAsText(); FeatureClassToFeatureClass importFCTool = new FeatureClassToFeatureClass(); importFCTool.in_features = origAdminFCPath; importFCTool.out_path = outputFileGdbPath; importFCTool.out_name = "Admin" + Convert.ToString(i, System.Globalization.CultureInfo.InvariantCulture); importFCTool.field_mapping = "ID \"ID\" true true false 8 Double 0 0 ,First,#," + origAdminFCPath + ",ID,-1,-1;" + "FEATTYP \"FEATTYP\" true true false 2 Short 0 0 ,First,#," + origAdminFCPath + ",FEATTYP,-1,-1;" + "ORDER00 \"ORDER00\" true true false 3 Text 0 0 ,First,#," + origAdminFCPath + ",ORDER00,-1,-1;" + "NAME \"NAME\" true true false 100 Text 0 0 ,First,#," + origAdminFCPath + ",NAME,-1,-1;" + "NAMELC \"NAMELC\" true true false 3 Text 0 0 ,First,#," + origAdminFCPath + ",NAMELC,-1,-1"; gp.Execute(importFCTool, trackcancel); mergeToolInputs = mergeToolInputs + outputFileGdbPath + "\\Admin" + Convert.ToString(i, System.Globalization.CultureInfo.InvariantCulture) + ";"; } mergeToolInputs = mergeToolInputs.Remove(mergeToolInputs.Length - 1); // Merge the admin area feature classes together into one feature class AddMessage("Merging the Administrative Area feature classes...", messages, trackcancel); string adminFCPath = outputFileGdbPath + "\\AdminFC"; Merge mergeTool = new Merge(); mergeTool.inputs = mergeToolInputs; mergeTool.output = adminFCPath; gp.Execute(mergeTool, trackcancel); Delete deleteTool = null; for (int i = 0; i < numAdminAreaFCs; i++) { deleteTool = new Delete(); deleteTool.in_data = outputFileGdbPath + "\\Admin" + Convert.ToString(i, System.Globalization.CultureInfo.InvariantCulture); gp.Execute(deleteTool, trackcancel); } // Extract the time zone information and index it AddMessage("Extracting the time zone information...", messages, trackcancel); string tzTablePath = outputFileGdbPath + "\\TZ"; TableSelect tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputAETableValue.GetAsText(); tableSelectTool.out_table = tzTablePath; tableSelectTool.where_clause = "ATTTYP = 'TZ'"; gp.Execute(tableSelectTool, trackcancel); AddIndex addIndexTool = new AddIndex(); addIndexTool.in_table = tzTablePath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); // Add the UTCOffset field and calculate it AddField addFieldTool = new AddField(); addFieldTool.in_table = adminFCPath; addFieldTool.field_name = "UTCOffset"; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); MakeFeatureLayer makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = adminFCPath; makeFeatureLayerTool.out_layer = "AdminFC_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); AddJoin addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "AdminFC_Layer"; addJoinTool.in_field = "ID"; addJoinTool.join_table = tzTablePath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the UTCOffset information on the Administrative Area feature class...", messages, trackcancel); CalculateField calcFieldTool = new CalculateField(); calcFieldTool.in_table = "AdminFC_Layer"; calcFieldTool.field = "AdminFC.UTCOffset"; calcFieldTool.code_block = "u = Null\ns = Trim([TZ.ATTVALUE])\nIf Not IsNull(s) Then\n" + " sign = 1\n If Left(s, 1) = \"-\" Then sign = -1\n" + " u = sign * ( (60 * Abs(CInt(Mid(s, 1, Len(s) - 3)))) + CInt(Right(s, 2)) )\n" + "End If"; calcFieldTool.expression = "u"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); RemoveJoin removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "AdminFC_Layer"; removeJoinTool.join_name = "TZ"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "AdminFC_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = tzTablePath; gp.Execute(deleteTool, trackcancel); // Extract out only the admin areas that have time zone information AddMessage("Extracting Administrative Areas with time zone information...", messages, trackcancel); string adminTZFCPath = outputFileGdbPath + "\\AdminFCwTZ"; Select selectTool = new Select(); selectTool.in_features = adminFCPath; selectTool.out_feature_class = adminTZFCPath; selectTool.where_clause = "NOT UTCOffset IS NULL"; gp.Execute(selectTool, trackcancel); // Extract the daylight saving time information and index it AddMessage("Extracting the daylight saving time information...", messages, trackcancel); string suTablePath = outputFileGdbPath + "\\SU"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputAETableValue.GetAsText(); tableSelectTool.out_table = suTablePath; tableSelectTool.where_clause = "ATTTYP = 'SU'"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = suTablePath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); // Add the daylight saving field and calculate it addFieldTool = new AddField(); addFieldTool.in_table = adminTZFCPath; addFieldTool.field_name = "DST"; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = adminTZFCPath; makeFeatureLayerTool.out_layer = "AdminFCwTZ_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "AdminFCwTZ_Layer"; addJoinTool.in_field = "ID"; addJoinTool.join_table = suTablePath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_ALL"; gp.Execute(addJoinTool, trackcancel); AddMessage("Copying the DST information to the Administrative Area feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "AdminFCwTZ_Layer"; calcFieldTool.field = "AdminFCwTZ.DST"; calcFieldTool.code_block = "s = 0\nIf Not IsNull( [SU.ATTVALUE] ) Then s = CInt( [SU.ATTVALUE] )"; calcFieldTool.expression = "s"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "AdminFCwTZ_Layer"; removeJoinTool.join_name = "SU"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "AdminFCwTZ_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = suTablePath; gp.Execute(deleteTool, trackcancel); // Create and calculate the sortable MSTIMEZONE field addFieldTool = new AddField(); addFieldTool.in_table = adminTZFCPath; addFieldTool.field_name = "SortableMSTIMEZONE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 60; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = adminTZFCPath; calcFieldTool.field = "SortableMSTIMEZONE"; calcFieldTool.code_block = TimeZoneUtilities.MakeSortableMSTIMEZONECode("ORDER00"); calcFieldTool.expression = "z"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); Rename renameTool = new Rename(); renameTool.in_data = adminTZFCPath; renameTool.out_data = adminTZFCPath + "wNulls"; gp.Execute(renameTool, trackcancel); selectTool = new Select(); selectTool.in_features = adminTZFCPath + "wNulls"; selectTool.out_feature_class = adminTZFCPath; selectTool.where_clause = "NOT SortableMSTIMEZONE IS NULL"; gp.Execute(selectTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = adminTZFCPath + "wNulls"; gp.Execute(deleteTool, trackcancel); // Dissolve the time zone polygons together AddMessage("Dissolving the time zones...", messages, trackcancel); string timeZoneFCPath = outputFileGdbPath + "\\" + TimeZoneFCName; Dissolve dissolveTool = new Dissolve(); dissolveTool.in_features = adminTZFCPath; dissolveTool.out_feature_class = timeZoneFCPath; dissolveTool.dissolve_field = "SortableMSTIMEZONE"; dissolveTool.multi_part = "MULTI_PART"; gp.Execute(dissolveTool, trackcancel); // Create and calculate the MSTIMEZONE field addFieldTool = new AddField(); addFieldTool.in_table = timeZoneFCPath; addFieldTool.field_name = "MSTIMEZONE"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 50; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = timeZoneFCPath; calcFieldTool.field = "MSTIMEZONE"; calcFieldTool.expression = "Mid([SortableMSTIMEZONE], 7)"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Delete the old sortable MSTIMEZONE field DeleteField deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = timeZoneFCPath; deleteFieldTool.drop_field = "SortableMSTIMEZONE"; gp.Execute(deleteFieldTool, trackcancel); if (processStreetsFC) { // Create the network dataset time zone table AddMessage("Creating the time zones table...", messages, trackcancel); TableToTable importTableTool = new TableToTable(); importTableTool.in_rows = timeZoneFCPath; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = TimeZonesTableName; importTableTool.field_mapping = "MSTIMEZONE \"MSTIMEZONE\" true true false 50 Text 0 0 ,First,#," + timeZoneFCPath + ",MSTIMEZONE,-1,-1"; gp.Execute(importTableTool, trackcancel); // Import the NW feature class to the file geodatabase AddMessage("Copying the NW feature class to the geodatabase...", messages, trackcancel); FeatureClassToFeatureClass importFCTool = new FeatureClassToFeatureClass(); importFCTool.in_features = inputNWFeatureClassValue.GetAsText(); importFCTool.out_path = outputFileGdbPath; importFCTool.out_name = "nw"; gp.Execute(importFCTool, trackcancel); string pathToLocalNW = outputFileGdbPath + "\\nw"; // Create Join polygon feature class AddMessage("Creating the join polygon feature class...", messages, trackcancel); string joinPolygonFCPath = outputFileGdbPath + "\\JoinPolygonFC"; MultipartToSinglepart multipartToSinglepartTool = new MultipartToSinglepart(); multipartToSinglepartTool.in_features = timeZoneFCPath; multipartToSinglepartTool.out_feature_class = joinPolygonFCPath; gp.Execute(multipartToSinglepartTool, trackcancel); // Add and calculate the time zone ID fields to the join polygons addFieldTool = new AddField(); addFieldTool.in_table = joinPolygonFCPath; addFieldTool.field_type = "SHORT"; addFieldTool.field_name = "FT_" + timeZoneIDBaseFieldName; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "TF_" + timeZoneIDBaseFieldName; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the FT_" + timeZoneIDBaseFieldName + " field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = joinPolygonFCPath; calcFieldTool.field = "FT_" + timeZoneIDBaseFieldName; calcFieldTool.expression = "[ORIG_FID]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the TF_" + timeZoneIDBaseFieldName + " field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = joinPolygonFCPath; calcFieldTool.field = "TF_" + timeZoneIDBaseFieldName; calcFieldTool.expression = "[ORIG_FID]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Delete the MSTIMEZONE and ORIG_FID fields from the join polygon FC deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = joinPolygonFCPath; deleteFieldTool.drop_field = "MSTIMEZONE;ORIG_FID"; gp.Execute(deleteFieldTool, trackcancel); // Perform a spatial join between the Streets and the join polygons AddMessage("Creating Streets feature class with time zone ID fields...", messages, trackcancel); string outputStreetsFCPath = outputFileGdbPath + "\\" + StreetsFCName; SpatialJoin spatialJoinTool = new SpatialJoin(); spatialJoinTool.target_features = pathToLocalNW; spatialJoinTool.join_features = joinPolygonFCPath; spatialJoinTool.out_feature_class = outputStreetsFCPath; spatialJoinTool.match_option = "IS_WITHIN"; gp.Execute(spatialJoinTool, trackcancel); // Delete the extraneous fields deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = outputStreetsFCPath; deleteFieldTool.drop_field = "Join_Count;TARGET_FID;Shape_Length_1"; gp.Execute(deleteFieldTool, trackcancel); // Delete the temporary NW and Join feature classes deleteTool = new Delete(); deleteTool.in_data = pathToLocalNW; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = joinPolygonFCPath; gp.Execute(deleteTool, trackcancel); // Extract the drive side information and index it AddMessage("Extracting the drive side information...", messages, trackcancel); string driveSideTablePath = outputFileGdbPath + "\\DriveSide"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputAETableValue.GetAsText(); tableSelectTool.out_table = driveSideTablePath; tableSelectTool.where_clause = "ATTTYP = '3D'"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = driveSideTablePath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); // Add the DriveSide field and calculate it addFieldTool = new AddField(); addFieldTool.in_table = adminFCPath; addFieldTool.field_name = "DriveSide"; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = adminFCPath; makeFeatureLayerTool.out_layer = "AdminFC_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "AdminFC_Layer"; addJoinTool.in_field = "ID"; addJoinTool.join_table = driveSideTablePath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Copying the drive side information to the Administrative Area feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "AdminFC_Layer"; calcFieldTool.field = "AdminFC.DriveSide"; calcFieldTool.expression = "CInt( [DriveSide.ATTVALUE] )"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "AdminFC_Layer"; removeJoinTool.join_name = "DriveSide"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "AdminFC_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = driveSideTablePath; gp.Execute(deleteTool, trackcancel); // Extract out only the admin areas that have drive side information and index the ORDER00 field AddMessage("Extracting Administrative Areas with drive side information...", messages, trackcancel); string adminFCwDriveSidePath = outputFileGdbPath + "\\AdminFCwDriveSide"; selectTool = new Select(); selectTool.in_features = adminFCPath; selectTool.out_feature_class = adminFCwDriveSidePath; selectTool.where_clause = "NOT DriveSide IS NULL"; gp.Execute(selectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = adminFCwDriveSidePath; addIndexTool.fields = "ORDER00"; addIndexTool.index_name = "ORDER00"; gp.Execute(addIndexTool, trackcancel); // Add the DriveSide field to the AdminFCwTZ feature class and calculate it. addFieldTool = new AddField(); addFieldTool.in_table = adminTZFCPath; addFieldTool.field_name = "DriveSide"; addFieldTool.field_type = "SHORT"; gp.Execute(addFieldTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = adminTZFCPath; makeFeatureLayerTool.out_layer = "AdminFCwTZ_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "AdminFCwTZ_Layer"; addJoinTool.in_field = "ORDER00"; addJoinTool.join_table = adminFCwDriveSidePath; addJoinTool.join_field = "ORDER00"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the DriveSide field on the AdminFCwTZ feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "AdminFCwTZ_Layer"; calcFieldTool.field = "AdminFCwTZ.DriveSide"; calcFieldTool.expression = "[AdminFCwDriveSide.DriveSide]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "AdminFCwTZ_Layer"; removeJoinTool.join_name = "AdminFCwDriveSide"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "AdminFCwTZ_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = adminFCwDriveSidePath; gp.Execute(deleteTool, trackcancel); // Extract the information for boundary roads AddMessage("Extracting the information for boundary roads...", messages, trackcancel); string taTablePath = outputFileGdbPath + "\\TA"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputTATableValue.GetAsText(); tableSelectTool.out_table = taTablePath; tableSelectTool.where_clause = "ARETYP <= 1120 AND SOL > 0"; gp.Execute(tableSelectTool, trackcancel); // Join the boundary road information with the AdminFCwTZ feature class to // create the FT_BoundaryTimeZones and TF_BoundaryTimeZones join tables addIndexTool = new AddIndex(); addIndexTool.in_table = adminTZFCPath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); MakeTableView makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = taTablePath; makeTableViewTool.out_view = "TA_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "TA_View"; addJoinTool.in_field = "AREID"; addJoinTool.join_table = adminTZFCPath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Extracting the boundary FT time zones...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = "TA_View"; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "FT_BoundaryTimeZones"; importTableTool.where_clause = "TA.SOL = AdminFCwTZ.DriveSide"; importTableTool.field_mapping = "ID \"ID\" true true false 8 Double 0 0 ,First,#," + taTablePath + ",TA.ID,-1,-1;" + "SortableMSTIMEZONE \"SortableMSTIMEZONE\" true true false 60 Text 0 0 ,First,#," + adminTZFCPath + ",AdminFCwTZ.SortableMSTIMEZONE,-1,-1"; gp.Execute(importTableTool, trackcancel); string ftBoundaryTimeZonesPath = outputFileGdbPath + "\\FT_BoundaryTimeZones"; addIndexTool = new AddIndex(); addIndexTool.in_table = ftBoundaryTimeZonesPath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); AddMessage("Extracting the boundary TF time zones...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = "TA_View"; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "TF_BoundaryTimeZones"; importTableTool.where_clause = "TA.SOL <> AdminFCwTZ.DriveSide"; importTableTool.field_mapping = "ID \"ID\" true true false 8 Double 0 0 ,First,#," + taTablePath + ",TA.ID,-1,-1;" + "SortableMSTIMEZONE \"SortableMSTIMEZONE\" true true false 60 Text 0 0 ,First,#," + adminTZFCPath + ",AdminFCwTZ.SortableMSTIMEZONE,-1,-1"; gp.Execute(importTableTool, trackcancel); string tfBoundaryTimeZonesPath = outputFileGdbPath + "\\TF_BoundaryTimeZones"; addIndexTool = new AddIndex(); addIndexTool.in_table = tfBoundaryTimeZonesPath; addIndexTool.fields = "ID"; addIndexTool.index_name = "ID"; gp.Execute(addIndexTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "TA_View"; removeJoinTool.join_name = "AdminFCwTZ"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "TA_View"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = taTablePath; gp.Execute(deleteTool, trackcancel); // Calculate the boundary time zone ID values makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = outputStreetsFCPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "ID"; addJoinTool.join_table = ftBoundaryTimeZonesPath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the boundary FT time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".FT_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "FT_BoundaryTimeZones.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "FT_BoundaryTimeZones"; gp.Execute(removeJoinTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "ID"; addJoinTool.join_table = tfBoundaryTimeZonesPath; addJoinTool.join_field = "ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the boundary TF time zones...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".TF_" + timeZoneIDBaseFieldName; calcFieldTool.code_block = TimeZoneUtilities.MakeTimeZoneIDCode(outputFileGdbPath, TimeZonesTableName, "TF_BoundaryTimeZones.SortableMSTIMEZONE"); calcFieldTool.expression = "tzID"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "TF_BoundaryTimeZones"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = ftBoundaryTimeZonesPath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = tfBoundaryTimeZonesPath; gp.Execute(deleteTool, trackcancel); } else { // Create a dummy TimeZones table and a dummy Streets feature class CreateTable createTableTool = new CreateTable(); createTableTool.out_path = outputFileGdbPath; createTableTool.out_name = TimeZonesTableName; gp.Execute(createTableTool, trackcancel); CreateFeatureclass createFCTool = new CreateFeatureclass(); createFCTool.out_path = outputFileGdbPath; createFCTool.out_name = StreetsFCName; createFCTool.geometry_type = "POLYLINE"; gp.Execute(createFCTool, trackcancel); } deleteTool = new Delete(); deleteTool.in_data = adminFCPath; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = adminTZFCPath; gp.Execute(deleteTool, trackcancel); // Compact the output file geodatabase AddMessage("Compacting the output file geodatabase...", messages, trackcancel); Compact compactTool = new Compact(); compactTool.in_workspace = outputFileGdbPath; gp.Execute(compactTool, trackcancel); } catch (Exception e) { if (gp.MaxSeverity == 2) { object missing = System.Type.Missing; messages.AddError(1, gp.GetMessages(ref missing)); } messages.AddError(1, e.Message); messages.AddError(1, e.StackTrace); } finally { // Restore the original GP environment settings gpSettings.AddOutputsToMap = origAddOutputsToMapSetting; gpSettings.LogHistory = origLogHistorySetting; } GC.Collect(); return; }
public void Execute(IArray paramvalues, ITrackCancel trackcancel, IGPEnvironmentManager envMgr, IGPMessages messages) { // Remember the original GP environment settings and temporarily override these settings var gpSettings = envMgr as IGeoProcessorSettings; bool origAddOutputsToMapSetting = gpSettings.AddOutputsToMap; bool origLogHistorySetting = gpSettings.LogHistory; gpSettings.AddOutputsToMap = false; gpSettings.LogHistory = false; // Create the Geoprocessor Geoprocessor gp = new Geoprocessor(); try { // Validate our values IGPMessages validateMessages = ((IGPFunction2)this).Validate(paramvalues, false, envMgr); if ((validateMessages as IGPMessage).IsError()) { messages.AddError(1, "Validate failed"); return; } // Unpack values IGPParameter gpParam = paramvalues.get_Element(InputStreetsFeatureClass) as IGPParameter; IGPValue inputStreetsFeatureClassValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputAltStreetsFeatureClass) as IGPParameter; IGPValue inputAltStreetsFeatureClassValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputZLevelsFeatureClass) as IGPParameter; IGPValue inputZLevelsFeatureClassValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputCdmsTable) as IGPParameter; IGPValue inputCdmsTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputRdmsTable) as IGPParameter; IGPValue inputRdmsTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputSignsTable) as IGPParameter; IGPValue inputSignsTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(OutputFileGDB) as IGPParameter; IGPValue outputFileGDBValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(OutputFileGDBVersion) as IGPParameter; IGPValue outputFileGDBVersionValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputFeatureDatasetName) as IGPParameter; IGPValue inputFeatureDatasetNameValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputNetworkDatasetName) as IGPParameter; IGPValue inputNetworkDatasetNameValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputCreateNetworkAttributesInMetric) as IGPParameter; IGPValue inputCreateNetworkAttributeInMetricValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputCreateArcGISOnlineNetworkAttributes) as IGPParameter; IGPValue inputCreateArcGISOnlineNetworkAttributesValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTimeZoneIDBaseFieldName) as IGPParameter; IGPValue inputTimeZoneIDBaseFieldNameValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTimeZoneTable) as IGPParameter; IGPValue inputTimeZoneTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputCommonTimeZoneForTheEntireDataset) as IGPParameter; IGPValue inputCommonTimeZoneForTheEntireDatasetValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTrafficTable) as IGPParameter; IGPValue inputTrafficTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLinkReferenceFileFC14) as IGPParameter; IGPValue inputLinkReferenceFileFC14Value = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLinkReferenceFileFC5) as IGPParameter; IGPValue inputLinkReferenceFileFC5Value = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputTMCReferenceFile) as IGPParameter; IGPValue inputTMCReferenceFileValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputSPDFile) as IGPParameter; IGPValue inputSPDFileValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLiveTrafficFeedFolder) as IGPParameter; IGPValue inputLiveTrafficFeedFolderValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLiveTrafficFeedArcGISServerConnection) as IGPParameter; IGPValue inputLiveTrafficFeedArcGISServerConnectionValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLiveTrafficFeedGeoprocessingServiceName) as IGPParameter; IGPValue inputLiveTrafficFeedGeoprocessingServiceNameValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputLiveTrafficFeedGeoprocessingTaskName) as IGPParameter; IGPValue inputLiveTrafficFeedGeoprocessingTaskNameValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputUSCndModTable) as IGPParameter; IGPValue inputUSCndModTableValue = m_gpUtils.UnpackGPValue(gpParam); gpParam = paramvalues.get_Element(InputNonUSCndModTable) as IGPParameter; IGPValue inputNonUSCndModTableValue = m_gpUtils.UnpackGPValue(gpParam); double fgdbVersion = 0.0; if (!(outputFileGDBVersionValue.IsEmpty())) fgdbVersion = Convert.ToDouble(outputFileGDBVersionValue.GetAsText(), System.Globalization.CultureInfo.InvariantCulture); bool createNetworkAttributesInMetric = false; if (!(inputCreateNetworkAttributeInMetricValue.IsEmpty())) createNetworkAttributesInMetric = ((inputCreateNetworkAttributeInMetricValue.GetAsText()).ToUpper() == "TRUE"); bool createArcGISOnlineNetworkAttributes = false; if (!(inputCreateArcGISOnlineNetworkAttributesValue.IsEmpty())) createArcGISOnlineNetworkAttributes = ((inputCreateArcGISOnlineNetworkAttributesValue.GetAsText()).ToUpper() == "TRUE"); if (inputTimeZoneIDBaseFieldNameValue.IsEmpty() ^ inputTimeZoneTableValue.IsEmpty()) { messages.AddError(1, "The Time Zone ID Base Field Name and the Time Zone Table must be specified together."); return; } string timeZoneIDBaseFieldName = ""; bool directedTimeZoneIDFields = false; if (!(inputTimeZoneIDBaseFieldNameValue.IsEmpty())) { timeZoneIDBaseFieldName = inputTimeZoneIDBaseFieldNameValue.GetAsText(); IDETable inputTable = m_gpUtils.DecodeDETable(inputStreetsFeatureClassValue); if (inputTable.Fields.FindField(timeZoneIDBaseFieldName) == -1) { directedTimeZoneIDFields = true; if (((inputTable.Fields.FindField("FT_" + timeZoneIDBaseFieldName) == -1) || (inputTable.Fields.FindField("TF_" + timeZoneIDBaseFieldName) == -1))) { messages.AddError(1, "Field named " + timeZoneIDBaseFieldName + " does not exist, nor the pair of fields with FT_ and TF_ prefixing " + timeZoneIDBaseFieldName + " does not exist."); return; } } } string commonTimeZone = ""; if (!(inputCommonTimeZoneForTheEntireDatasetValue.IsEmpty())) commonTimeZone = inputCommonTimeZoneForTheEntireDatasetValue.GetAsText(); if (inputLinkReferenceFileFC14Value.IsEmpty() ^ inputLinkReferenceFileFC5Value.IsEmpty()) { messages.AddError(1, "Both Traffic Patterns Link Reference .csv files must be specified together."); return; } bool usesHistoricalTraffic = !(inputSPDFileValue.IsEmpty()); bool usesNTPFullCoverage = !(inputLinkReferenceFileFC5Value.IsEmpty()); if ((inputTMCReferenceFileValue.IsEmpty() & !usesNTPFullCoverage) ^ inputSPDFileValue.IsEmpty()) { messages.AddError(1, "The Traffic Patterns SPD .csv file must be specified with the Traffic Patterns Link/TMC Reference .csv file(s)."); return; } if (inputTrafficTableValue.IsEmpty() & !inputTMCReferenceFileValue.IsEmpty()) { messages.AddError(1, "If the TMC Reference .csv file is specified, then the Traffic table must also be specified."); return; } bool agsConnectionIsEmpty = inputLiveTrafficFeedArcGISServerConnectionValue.IsEmpty(); bool gpServiceNameIsEmpty = inputLiveTrafficFeedGeoprocessingServiceNameValue.IsEmpty(); bool gpTaskNameIsEmpty = inputLiveTrafficFeedGeoprocessingTaskNameValue.IsEmpty(); if ((agsConnectionIsEmpty | gpServiceNameIsEmpty | gpTaskNameIsEmpty) ^ (agsConnectionIsEmpty & gpServiceNameIsEmpty & gpTaskNameIsEmpty)) { messages.AddError(1, "The ArcGIS Server Connection, Geoprocessing Service Name, and Geoprocessing Task Name must all be specified together."); return; } bool feedFolderIsEmpty = inputLiveTrafficFeedFolderValue.IsEmpty(); if (!(feedFolderIsEmpty | agsConnectionIsEmpty)) { messages.AddError(1, "The live traffic feed folder and live traffic feed connection cannot be specified together."); return; } if (inputTrafficTableValue.IsEmpty() & !(feedFolderIsEmpty & agsConnectionIsEmpty)) { messages.AddError(1, "The Traffic table must be specified to use Live Traffic."); return; } bool usesTransport = true; if (inputUSCndModTableValue.IsEmpty() && inputNonUSCndModTableValue.IsEmpty()) usesTransport = false; ITrafficFeedLocation trafficFeedLocation = null; if (!agsConnectionIsEmpty) { // We're using an ArcGIS Server Connection and Geoprocessing Service/Task ITrafficFeedGPService tfgps = new TrafficFeedGPServiceClass(); IName trafficFeedGPServiceName = m_gpUtils.GetNameObject(inputLiveTrafficFeedArcGISServerConnectionValue as IDataElement); tfgps.ConnectionProperties = ((IAGSServerConnectionName)trafficFeedGPServiceName).ConnectionProperties; tfgps.ServiceName = inputLiveTrafficFeedGeoprocessingServiceNameValue.GetAsText(); tfgps.TaskName = inputLiveTrafficFeedGeoprocessingTaskNameValue.GetAsText(); trafficFeedLocation = tfgps as ITrafficFeedLocation; } else if (!feedFolderIsEmpty) { // We're using a Traffic Feed Folder ITrafficFeedDirectory tfd = new TrafficFeedDirectoryClass(); tfd.TrafficDirectory = inputLiveTrafficFeedFolderValue.GetAsText(); trafficFeedLocation = tfd as ITrafficFeedLocation; } // Get the path to the output file GDB, and feature dataset and network dataset names string outputFileGdbPath = outputFileGDBValue.GetAsText(); string fdsName = inputFeatureDatasetNameValue.GetAsText(); string ndsName = inputNetworkDatasetNameValue.GetAsText(); // Create the new file geodatabase and feature dataset AddMessage("Creating the file geodatabase and feature dataset...", messages, trackcancel); int lastBackslash = outputFileGdbPath.LastIndexOf("\\"); CreateFileGDB createFGDBTool = new CreateFileGDB(); createFGDBTool.out_folder_path = outputFileGdbPath.Remove(lastBackslash); createFGDBTool.out_name = outputFileGdbPath.Substring(lastBackslash + 1); createFGDBTool.out_version = "9.3"; gp.Execute(createFGDBTool, trackcancel); CreateFeatureDataset createFDSTool = new CreateFeatureDataset(); createFDSTool.out_dataset_path = outputFileGdbPath; createFDSTool.out_name = fdsName; createFDSTool.spatial_reference = inputStreetsFeatureClassValue.GetAsText(); gp.Execute(createFDSTool, trackcancel); // Import the Streets feature class to the file geodatabase // If we're using ArcInfo, also sort the feature class string pathToFds = outputFileGdbPath + "\\" + fdsName; string streetsFeatureClassPath = pathToFds + "\\" + StreetsFCName; IAoInitialize aoi = new AoInitializeClass(); if (aoi.InitializedProduct() == esriLicenseProductCode.esriLicenseProductCodeAdvanced) { AddMessage("Importing and spatially sorting the Streets feature class...", messages, trackcancel); Sort sortTool = new Sort(); sortTool.in_dataset = inputStreetsFeatureClassValue.GetAsText(); sortTool.out_dataset = streetsFeatureClassPath; sortTool.sort_field = "Shape"; sortTool.spatial_sort_method = "PEANO"; gp.Execute(sortTool, trackcancel); } else { AddMessage("Importing the Streets feature class...", messages, trackcancel); FeatureClassToFeatureClass importFCTool = new FeatureClassToFeatureClass(); importFCTool.in_features = inputStreetsFeatureClassValue.GetAsText(); importFCTool.out_path = pathToFds; importFCTool.out_name = StreetsFCName; gp.Execute(importFCTool, trackcancel); } // Add an index to the Streets feature class's LINK_ID field AddMessage("Indexing the LINK_ID field...", messages, trackcancel); AddIndex addIndexTool = new AddIndex(); addIndexTool.in_table = streetsFeatureClassPath; addIndexTool.fields = "LINK_ID"; addIndexTool.index_name = "LINK_ID"; gp.Execute(addIndexTool, trackcancel); // Add the alternate street name fields to the Streets feature class AddMessage("Creating fields on the Streets feature class for the alternate street names...", messages, trackcancel); AddField addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 240; addFieldTool.field_name = "ST_NAME_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 3; addFieldTool.field_name = "ST_LANGCD_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 6; addFieldTool.field_name = "ST_NM_PREF_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 90; addFieldTool.field_name = "ST_TYP_BEF_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 105; addFieldTool.field_name = "ST_NM_BASE_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 6; addFieldTool.field_name = "ST_NM_SUFF_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 90; addFieldTool.field_name = "ST_TYP_AFT_Alt"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_length = 1; addFieldTool.field_name = "DIRONSIGN_Alt"; gp.Execute(addFieldTool, trackcancel); // Extract the explicatable street names string ExplicatblTablePath = outputFileGdbPath + "\\Explicatbl"; AddMessage("Extracting the explicatable street names...", messages, trackcancel); TableSelect tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputAltStreetsFeatureClassValue.GetAsText(); tableSelectTool.out_table = ExplicatblTablePath; tableSelectTool.where_clause = "EXPLICATBL = 'Y'"; gp.Execute(tableSelectTool, trackcancel); // Determine which explicatable names are alternate names and extract them MakeTableView makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = ExplicatblTablePath; makeTableViewTool.out_view = "Explicatbl_View"; gp.Execute(makeTableViewTool, trackcancel); AddJoin addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Explicatbl_View"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = streetsFeatureClassPath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); AddMessage("Extracting the alternate street names...", messages, trackcancel); TableToTable importTableTool = new TableToTable(); importTableTool.in_rows = "Explicatbl_View"; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "AltNames"; importTableTool.where_clause = "Explicatbl.ST_TYP_BEF <> " + StreetsFCName + ".ST_TYP_BEF OR " + "Explicatbl.ST_NM_BASE <> " + StreetsFCName + ".ST_NM_BASE OR " + "Explicatbl.ST_TYP_AFT <> " + StreetsFCName + ".ST_TYP_AFT"; importTableTool.field_mapping = "LINK_ID \"LINK_ID\" true true false 4 Long 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.LINK_ID,-1,-1;" + "ST_NAME \"ST_NAME\" true true false 240 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_NAME,-1,-1;" + "ST_LANGCD \"ST_LANGCD\" true true false 3 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_LANGCD,-1,-1;" + "ST_NM_PREF \"ST_NM_PREF\" true true false 6 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_NM_PREF,-1,-1;" + "ST_TYP_BEF \"ST_TYP_BEF\" true true false 90 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_TYP_BEF,-1,-1;" + "ST_NM_BASE \"ST_NM_BASE\" true true false 105 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_NM_BASE,-1,-1;" + "ST_NM_SUFF \"ST_NM_SUFF\" true true false 6 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_NM_SUFF,-1,-1;" + "ST_TYP_AFT \"ST_TYP_AFT\" true true false 90 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.ST_TYP_AFT,-1,-1;" + "DIRONSIGN \"DIRONSIGN\" true true false 1 Text 0 0 ,First,#," + ExplicatblTablePath + ",Explicatbl.DIRONSIGN,-1,-1"; gp.Execute(importTableTool, trackcancel); RemoveJoin removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Explicatbl_View"; removeJoinTool.join_name = StreetsFCName; gp.Execute(removeJoinTool, trackcancel); Delete deleteTool = new Delete(); deleteTool.in_data = "Explicatbl_View"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = ExplicatblTablePath; gp.Execute(deleteTool, trackcancel); string AltNamesTablePath = outputFileGdbPath + "\\AltNames"; addIndexTool = new AddIndex(); addIndexTool.in_table = AltNamesTablePath; addIndexTool.fields = "LINK_ID"; addIndexTool.index_name = "LINK_ID"; gp.Execute(addIndexTool, trackcancel); // Calculate the alternate street name fields MakeFeatureLayer makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = streetsFeatureClassPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = AltNamesTablePath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); AddMessage("Copying over the alternate ST_NAME values...", messages, trackcancel); CalculateField calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.expression_type = "VB"; calcFieldTool.field = StreetsFCName + ".ST_NAME_Alt"; calcFieldTool.expression = "[AltNames.ST_NAME]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_LANGCD values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_LANGCD_Alt"; calcFieldTool.expression = "[AltNames.ST_LANGCD]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_NM_PREF values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_NM_PREF_Alt"; calcFieldTool.expression = "[AltNames.ST_NM_PREF]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_TYP_BEF values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_TYP_BEF_Alt"; calcFieldTool.expression = "[AltNames.ST_TYP_BEF]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_NM_BASE values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_NM_BASE_Alt"; calcFieldTool.expression = "[AltNames.ST_NM_BASE]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_NM_SUFF values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_NM_SUFF_Alt"; calcFieldTool.expression = "[AltNames.ST_NM_SUFF]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate ST_TYP_AFT values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".ST_TYP_AFT_Alt"; calcFieldTool.expression = "[AltNames.ST_TYP_AFT]"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Copying over the alternate DIRONSIGN values...", messages, trackcancel); calcFieldTool.field = StreetsFCName + ".DIRONSIGN_Alt"; calcFieldTool.expression = "[AltNames.DIRONSIGN]"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "AltNames"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = AltNamesTablePath; gp.Execute(deleteTool, trackcancel); // Add fields for the Z-Level values to the Streets feature class AddMessage("Creating fields on the Streets feature class for the Z-Level values...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "SHORT"; addFieldTool.field_name = "F_ZLEV"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "T_ZLEV"; gp.Execute(addFieldTool, trackcancel); // Separate out the From and To Z-Level values into separate tables and index the LINK_ID fields string FromZsTablePath = outputFileGdbPath + "\\FromZs"; string ToZsTablePath = outputFileGdbPath + "\\ToZs"; AddMessage("Extracting the From Z-Level information...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputZLevelsFeatureClassValue.GetAsText(); tableSelectTool.out_table = FromZsTablePath; tableSelectTool.where_clause = "INTRSECT = 'Y' AND POINT_NUM = 1"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Extracting the To Z-Level information...", messages, trackcancel); tableSelectTool.out_table = ToZsTablePath; tableSelectTool.where_clause = "INTRSECT = 'Y' AND POINT_NUM > 1"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Analyzing the Z-Level information...", messages, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = FromZsTablePath; addIndexTool.fields = "LINK_ID"; addIndexTool.index_name = "LINK_ID"; gp.Execute(addIndexTool, trackcancel); addIndexTool.in_table = ToZsTablePath; gp.Execute(addIndexTool, trackcancel); // Calculate the Z-Level fields makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = streetsFeatureClassPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = FromZsTablePath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); AddMessage("Copying over the F_ZLEV values...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".F_ZLEV"; calcFieldTool.expression = "[FromZs.Z_LEVEL]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "FromZs"; gp.Execute(removeJoinTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = ToZsTablePath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); AddMessage("Copying over the T_ZLEV values...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = StreetsFCName + ".T_ZLEV"; calcFieldTool.expression = "[ToZs.Z_LEVEL]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "ToZs"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = FromZsTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = ToZsTablePath; gp.Execute(deleteTool, trackcancel); // Add fields for the distance (Meters), language, and speed (KPH) values to the Streets feature class AddMessage("Creating fields on the Streets feature class for distance, speed, and language...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "DOUBLE"; addFieldTool.field_name = "Meters"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "KPH"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "TEXT"; addFieldTool.field_name = "Language"; addFieldTool.field_length = 2; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "TEXT"; addFieldTool.field_name = "Language_Alt"; addFieldTool.field_length = 2; gp.Execute(addFieldTool, trackcancel); // Calculate the distance (Meters), language, and speed (KPH) fields AddMessage("Calculating the distance, speed, and language fields...", messages, trackcancel); CalculateMetersKPHAndLanguageFields(outputFileGdbPath); if (createArcGISOnlineNetworkAttributes) { CreateAndPopulateDirectionalVehicleAccessFields("AR_AUTO", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_BUS", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_TAXIS", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_TRUCKS", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_DELIV", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_EMERVEH", streetsFeatureClassPath, gp, messages, trackcancel); CreateAndPopulateDirectionalVehicleAccessFields("AR_MOTOR", streetsFeatureClassPath, gp, messages, trackcancel); } // Add a field to the Streets feature class indicating roads closed for construction AddMessage("Creating the ClosedForConstruction field on the Streets feature class...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "TEXT"; addFieldTool.field_name = "ClosedForConstruction"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); // Create a table for looking up roads closed for construction AddMessage("Creating and indexing the table containing roads closed for construction...", messages, trackcancel); string closedForConstructionTablePath = outputFileGdbPath + "\\ClosedForConstruction"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputCdmsTableValue.GetAsText(); tableSelectTool.out_table = closedForConstructionTablePath; tableSelectTool.where_clause = "COND_TYPE = 3"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = closedForConstructionTablePath; addIndexTool.fields = "LINK_ID"; addIndexTool.index_name = "LINK_ID"; gp.Execute(addIndexTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = streetsFeatureClassPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = closedForConstructionTablePath; addJoinTool.join_field = "LINK_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the ClosedForConstruction field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = "Streets.ClosedForConstruction"; calcFieldTool.expression = "\"Y\""; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "ClosedForConstruction"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = closedForConstructionTablePath; gp.Execute(deleteTool, trackcancel); // Add fields to the Streets feature class indicating roads with usage fees string[] arFieldSuffixes = new string[] { "AUTO", "BUS", "TAXIS", "CARPOOL", "PEDSTRN", "TRUCKS", "THRUTR", "DELIVER", "EMERVEH", "MOTOR" }; AddMessage("Creating the UFR fields on the Streets feature class...", messages, trackcancel); foreach (string arFieldSuffix in arFieldSuffixes) { addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_name = "UFR_" + arFieldSuffix; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); } // Create a table for looking up roads with usage fees AddMessage("Creating and indexing the table containing roads with usage fees...", messages, trackcancel); string usageFeeRequiredTablePath = outputFileGdbPath + "\\UsageFeeRequired"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputCdmsTableValue.GetAsText(); tableSelectTool.out_table = usageFeeRequiredTablePath; tableSelectTool.where_clause = "COND_TYPE = 12"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = usageFeeRequiredTablePath; addIndexTool.fields = "LINK_ID"; addIndexTool.index_name = "LINK_ID"; gp.Execute(addIndexTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = streetsFeatureClassPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Layer"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = usageFeeRequiredTablePath; addJoinTool.join_field = "LINK_ID"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the ClosedForConstruction field...", messages, trackcancel); foreach (string arFieldSuffix in arFieldSuffixes) { AddMessage("Calculating the UFR_" + arFieldSuffix + " field on the Streets feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Layer"; calcFieldTool.field = "Streets.UFR_" + arFieldSuffix; calcFieldTool.expression = "[UsageFeeRequired.AR_" + arFieldSuffix + "]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Layer"; removeJoinTool.join_name = "UsageFeeRequired"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = usageFeeRequiredTablePath; gp.Execute(deleteTool, trackcancel); // Copy the time zones table to the file geodatabase if (timeZoneIDBaseFieldName != "") { AddMessage("Copying the TimeZones table...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputTimeZoneTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "TimeZones"; gp.Execute(importTableTool, trackcancel); } #region Process Historical Traffic Tables if (usesHistoricalTraffic) { // Create the Patterns table and index its PatternID field AddMessage("Creating the Patterns table...", messages, trackcancel); string listOfConstantPatterns = CreatePatternsTable(inputSPDFileValue.GetAsText(), outputFileGdbPath, fgdbVersion); string patternsTablePath = outputFileGdbPath + "\\" + ProfilesTableName; addIndexTool = new AddIndex(); addIndexTool.in_table = patternsTablePath; addIndexTool.fields = "PatternID"; addIndexTool.index_name = "PatternID"; gp.Execute(addIndexTool, trackcancel); string histTrafficJoinTablePath = outputFileGdbPath + "\\" + HistTrafficJoinTableName; // Add fields for the average speeds to the Streets feature class AddMessage("Creating fields for the average speeds and travel times...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "FT_AverageSpeed"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "TF_AverageSpeed"; gp.Execute(addFieldTool, trackcancel); if (usesNTPFullCoverage) { // Convert the Link Reference files to a FileGDB table AddMessage("Converting the Link Reference files to a table...", messages, trackcancel); ConvertLinkReferenceFilesToFGDBTable(inputLinkReferenceFileFC14Value.GetAsText(), inputLinkReferenceFileFC5Value.GetAsText(), outputFileGdbPath); string referenceTablePath = outputFileGdbPath + "\\TempRefTable"; // Extract out the rows we want in our historical traffic table AddMessage("Creating the historical traffic join table...", messages, trackcancel); if (listOfConstantPatterns == "") { Rename renameTool = new Rename(); renameTool.in_data = referenceTablePath; renameTool.out_data = histTrafficJoinTablePath; gp.Execute(renameTool, trackcancel); } else { tableSelectTool = new TableSelect(); tableSelectTool.in_table = referenceTablePath; tableSelectTool.out_table = histTrafficJoinTablePath; tableSelectTool.where_clause = "NOT ( IS_FC5 = 'Y' AND U IN (" + listOfConstantPatterns + ") AND U = M AND M = T AND T = W AND W = R AND R = F AND F = S )"; gp.Execute(tableSelectTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = referenceTablePath; gp.Execute(deleteTool, trackcancel); } } else { // Convert the TMC Reference file to a FileGDB table and index its TMC field AddMessage("Converting the TMC Reference file to a table...", messages, trackcancel); ConvertTMCReferenceFileToFGDBTable(inputTMCReferenceFileValue.GetAsText(), outputFileGdbPath); string referenceTablePath = outputFileGdbPath + "\\TempRefTable"; addIndexTool = new AddIndex(); addIndexTool.in_table = referenceTablePath; addIndexTool.fields = "TMC"; addIndexTool.index_name = "TMC"; gp.Execute(addIndexTool, trackcancel); // Copy over the Traffic table to the file geodatabase AddMessage("Copying Traffic table to the file geodatabase...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputTrafficTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "Street"; gp.Execute(importTableTool, trackcancel); string trafficTablePath = outputFileGdbPath + "\\Street"; // Add the TMC field and calculate it AddMessage("Calculating TMC values for historical traffic...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = trafficTablePath; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 9; addFieldTool.field_name = "TMC"; gp.Execute(addFieldTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = trafficTablePath; calcFieldTool.field = "TMC"; calcFieldTool.expression = "Replace(Replace(Right([TRAFFIC_CD], 9), \"+\", \"P\"), \"-\", \"N\")"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Creating the historical traffic join table...", messages, trackcancel); // Join the Traffic table to the Reference table... makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = trafficTablePath; makeTableViewTool.out_view = "Traffic_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Traffic_View"; addJoinTool.in_field = "TMC"; addJoinTool.join_table = referenceTablePath; addJoinTool.join_field = "TMC"; addJoinTool.join_type = "KEEP_COMMON"; gp.Execute(addJoinTool, trackcancel); // ...then create the Streets_Patterns table by copying out the joined rows importTableTool = new TableToTable(); importTableTool.in_rows = "Traffic_View"; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = HistTrafficJoinTableName; importTableTool.field_mapping = "LINK_ID \"LINK_ID\" true true false 4 Long 0 0 ,First,#," + trafficTablePath + ",Street.LINK_ID,-1,-1;" + "TRAFFIC_CD \"TRAFFIC_CD\" true true false 10 Text 0 0 ,First,#," + trafficTablePath + ",Street.TRAFFIC_CD,-1,-1;" + "TMC \"TMC\" true true false 9 Text 0 0 ,First,#," + trafficTablePath + ",Street.TMC,-1,-1;" + "U \"U\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.U,-1,-1;" + "M \"M\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.M,-1,-1;" + "T \"T\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.T,-1,-1;" + "W \"W\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.W,-1,-1;" + "R \"R\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.R,-1,-1;" + "F \"F\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.F,-1,-1;" + "S \"S\" true true false 2 Short 0 0 ,First,#," + trafficTablePath + ",TempRefTable.S,-1,-1"; gp.Execute(importTableTool, trackcancel); // Delete the join, view, and temporary tables removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Traffic_View"; removeJoinTool.join_name = "TempRefTable"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Traffic_View"; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = referenceTablePath; gp.Execute(deleteTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = trafficTablePath; gp.Execute(deleteTool, trackcancel); } AddMessage("Creating fields on the historical traffic join table...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = histTrafficJoinTablePath; // Add FCID, FID, position, AverageSpeed[_X], and BaseSpeed[_X] fields to the Streets_Patterns table addFieldTool.field_type = "LONG"; addFieldTool.field_name = "EdgeFCID"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "EdgeFID"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "DOUBLE"; addFieldTool.field_name = "EdgeFrmPos"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "EdgeToPos"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "AverageSpeed"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_U"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_M"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_T"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_W"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_R"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_F"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "AverageSpeed_S"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "BaseSpeed"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_U"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_M"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_T"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_W"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_R"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_F"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "BaseSpeed_S"; gp.Execute(addFieldTool, trackcancel); // If we're creating 10.0, then we also need to create the BaseMinutes field if (fgdbVersion == 10.0) { addFieldTool.field_type = "DOUBLE"; addFieldTool.field_name = "BaseMinutes"; gp.Execute(addFieldTool, trackcancel); } // Populate the AverageSpeed_X and BaseSpeed_X fields makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = histTrafficJoinTablePath; makeTableViewTool.out_view = "Streets_Patterns_View"; gp.Execute(makeTableViewTool, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "U", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "M", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "T", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "W", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "R", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "F", gp, messages, trackcancel); PopulateAverageSpeedAndBaseSpeedFields(patternsTablePath, "S", gp, messages, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Patterns_View"; gp.Execute(deleteTool, trackcancel); // Calculate the AverageSpeed and BaseSpeed fields AddMessage("Calculating the AverageSpeed field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = histTrafficJoinTablePath; calcFieldTool.field = "AverageSpeed"; calcFieldTool.expression = "( (1/[AverageSpeed_U]) + (1/[AverageSpeed_M]) + (1/[AverageSpeed_T]) + (1/[AverageSpeed_W]) + (1/[AverageSpeed_R]) + (1/[AverageSpeed_F]) + (1/[AverageSpeed_S]) ) / " + "( (1/[AverageSpeed_U]/[AverageSpeed_U]) + (1/[AverageSpeed_M]/[AverageSpeed_M]) + (1/[AverageSpeed_T]/[AverageSpeed_T]) + (1/[AverageSpeed_W]/[AverageSpeed_W]) + (1/[AverageSpeed_R]/[AverageSpeed_R]) + (1/[AverageSpeed_F]/[AverageSpeed_F]) + (1/[AverageSpeed_S]/[AverageSpeed_S]) )"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the BaseSpeed field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = histTrafficJoinTablePath; calcFieldTool.field = "BaseSpeed"; calcFieldTool.expression = "( (1/[BaseSpeed_U]) + (1/[BaseSpeed_M]) + (1/[BaseSpeed_T]) + (1/[BaseSpeed_W]) + (1/[BaseSpeed_R]) + (1/[BaseSpeed_F]) + (1/[BaseSpeed_S]) ) / " + "( (1/[BaseSpeed_U]/[BaseSpeed_U]) + (1/[BaseSpeed_M]/[BaseSpeed_M]) + (1/[BaseSpeed_T]/[BaseSpeed_T]) + (1/[BaseSpeed_W]/[BaseSpeed_W]) + (1/[BaseSpeed_R]/[BaseSpeed_R]) + (1/[BaseSpeed_F]/[BaseSpeed_F]) + (1/[BaseSpeed_S]/[BaseSpeed_S]) )"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); DeleteField deleteFieldTool = new DeleteField(); deleteFieldTool.in_table = histTrafficJoinTablePath; deleteFieldTool.drop_field = "AverageSpeed_U;AverageSpeed_M;AverageSpeed_T;AverageSpeed_W;AverageSpeed_R;AverageSpeed_F;AverageSpeed_S;BaseSpeed_U;BaseSpeed_M;BaseSpeed_T;BaseSpeed_W;BaseSpeed_R;BaseSpeed_F;BaseSpeed_S"; gp.Execute(deleteFieldTool, trackcancel); makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = histTrafficJoinTablePath; makeTableViewTool.out_view = "Streets_Patterns_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Patterns_View"; addJoinTool.in_field = (usesNTPFullCoverage ? "LINK_PVID" : "LINK_ID"); addJoinTool.join_table = streetsFeatureClassPath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); // Calculate the BaseMinutes field (if 10.0) if (fgdbVersion == 10.0) { AddMessage("Calculating the BaseMinutes field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Patterns_View"; calcFieldTool.field = HistTrafficJoinTableName + ".BaseMinutes"; calcFieldTool.expression = "[" + StreetsFCName + ".Meters] * 0.06 / [" + HistTrafficJoinTableName + ".BaseSpeed]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } // Calculate the FCID, FID, and position fields AddMessage("Calculating the EdgeFID field for historical traffic...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Patterns_View"; calcFieldTool.field = HistTrafficJoinTableName + ".EdgeFID"; calcFieldTool.expression = "[" + StreetsFCName + ".OBJECTID]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Patterns_View"; removeJoinTool.join_name = StreetsFCName; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Patterns_View"; gp.Execute(deleteTool, trackcancel); AddMessage("Calculating the EdgeFCID field for historical traffic...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = histTrafficJoinTablePath; calcFieldTool.field = "EdgeFCID"; calcFieldTool.expression = "1"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the EdgeFrmPos field for historical traffic...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = histTrafficJoinTablePath; calcFieldTool.field = "EdgeFrmPos"; calcFieldTool.expression = "x"; calcFieldTool.code_block = (usesNTPFullCoverage ? "Select Case [TRAVEL_DIRECTION]\n Case \"F\": x = 0\n Case \"T\": x = 1\nEnd Select" : "Select Case Left([TRAFFIC_CD], 1)\n Case \"+\": x = 0\n Case \"-\": x = 1\nEnd Select"); calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the EdgeToPos field for historical traffic...", messages, trackcancel); calcFieldTool.field = "EdgeToPos"; calcFieldTool.expression = "x"; calcFieldTool.code_block = (usesNTPFullCoverage ? "Select Case [TRAVEL_DIRECTION]\n Case \"T\": x = 0\n Case \"F\": x = 1\nEnd Select" : "Select Case Left([TRAFFIC_CD], 1)\n Case \"-\": x = 0\n Case \"+\": x = 1\nEnd Select"); calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Write the average speeds to the streets feature class WriteAverageSpeedsToStreets(outputFileGdbPath, streetsFeatureClassPath, usesNTPFullCoverage, gp, messages, trackcancel); // Add fields for the average travel times to the Streets feature class AddMessage("Creating fields for the average travel times...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "FT_Minutes"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "TF_Minutes"; gp.Execute(addFieldTool, trackcancel); // Calculate the average travel time fields AddMessage("Calculating the FT travel times...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = streetsFeatureClassPath; calcFieldTool.field = "FT_Minutes"; calcFieldTool.expression = "[Meters] * 0.06 / s"; calcFieldTool.code_block = "s = [FT_AverageSpeed]\nIf IsNull(s) Then s = [KPH]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the TF travel times...", messages, trackcancel); calcFieldTool.field = "TF_Minutes"; calcFieldTool.expression = "[Meters] * 0.06 / s"; calcFieldTool.code_block = "s = [TF_AverageSpeed]\nIf IsNull(s) Then s = [KPH]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Offset the daily pattern fields (U,M,T,W,R,F,S) on the historical traffic join table OffsetDailyPatternFields(histTrafficJoinTablePath, patternsTablePath); // Add an index to the Streets feature class's FUNC_CLASS field AddMessage("Indexing the FUNC_CLASS field...", messages, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = streetsFeatureClassPath; addIndexTool.fields = "FUNC_CLASS"; addIndexTool.index_name = "FUNC_CLASS"; gp.Execute(addIndexTool, trackcancel); } else { // Create and calculate the generic Minutes field from speed categories addFieldTool = new AddField(); addFieldTool.in_table = streetsFeatureClassPath; addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "Minutes"; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating the Minutes field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = streetsFeatureClassPath; calcFieldTool.field = "Minutes"; calcFieldTool.expression = "[Meters] * 0.06 / [KPH]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } #endregion #region Process Live Traffic Table // Create the live traffic table (for 10.1 or later) if (fgdbVersion >= 10.1 && !inputTrafficTableValue.IsEmpty()) { // Copy over the Traffic table to the file geodatabase AddMessage("Copying Traffic table to the file geodatabase...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputTrafficTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = TMCJoinTableName; gp.Execute(importTableTool, trackcancel); string TMCJoinTablePath = outputFileGdbPath + "\\" + TMCJoinTableName; // Add the TMC field and calculate it AddMessage("Calculating TMC values for live traffic...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = TMCJoinTablePath; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 9; addFieldTool.field_name = "TMC"; gp.Execute(addFieldTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = TMCJoinTablePath; calcFieldTool.field = "TMC"; calcFieldTool.expression = "Right([TRAFFIC_CD], 9)"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Creating the live traffic join table...", messages, trackcancel); // Add FCID, FID, and position fields to the Streets_TMC table AddMessage("Creating fields on the live traffic join table...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = TMCJoinTablePath; addFieldTool.field_type = "LONG"; addFieldTool.field_name = "EdgeFCID"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "EdgeFID"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_type = "DOUBLE"; addFieldTool.field_name = "EdgeFrmPos"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "EdgeToPos"; gp.Execute(addFieldTool, trackcancel); // Calculate the fields AddMessage("Calculating the EdgeFrmPos field for live traffic...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = TMCJoinTablePath; calcFieldTool.field = "EdgeFrmPos"; calcFieldTool.expression = "x"; calcFieldTool.code_block = "Select Case Left([TRAFFIC_CD], 1)\n Case \"+\": x = 0\n Case \"-\": x = 1\nEnd Select"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the EdgeToPos field for live traffic...", messages, trackcancel); calcFieldTool.field = "EdgeToPos"; calcFieldTool.expression = "x"; calcFieldTool.code_block = "Select Case Left([TRAFFIC_CD], 1)\n Case \"-\": x = 0\n Case \"+\": x = 1\nEnd Select"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the EdgeFCID field for live traffic...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = TMCJoinTablePath; calcFieldTool.field = "EdgeFCID"; calcFieldTool.expression = "1"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); AddMessage("Calculating the EdgeFID field for live traffic...", messages, trackcancel); makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = TMCJoinTablePath; makeTableViewTool.out_view = "Streets_TMC_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_TMC_View"; addJoinTool.in_field = "LINK_ID"; addJoinTool.join_table = streetsFeatureClassPath; addJoinTool.join_field = "LINK_ID"; gp.Execute(addJoinTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_TMC_View"; calcFieldTool.field = TMCJoinTableName + ".EdgeFID"; calcFieldTool.expression = "[" + StreetsFCName + ".OBJECTID]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_TMC_View"; removeJoinTool.join_name = StreetsFCName; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_TMC_View"; gp.Execute(deleteTool, trackcancel); // If Historical Traffic is not being used, then we need to create placeholder historical traffic tables if (!usesHistoricalTraffic) { // Create the Streets_Patterns table by starting with a copy of the Streets_TMC table AddMessage("Creating the historical traffic join table...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = TMCJoinTablePath; importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = HistTrafficJoinTableName; gp.Execute(importTableTool, trackcancel); string histTrafficJoinTablePath = outputFileGdbPath + "\\" + HistTrafficJoinTableName; AddMessage("Creating and calculating the KPH field on the historical traffic join table...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = histTrafficJoinTablePath; addFieldTool.field_type = "FLOAT"; addFieldTool.field_name = "KPH"; gp.Execute(addFieldTool, trackcancel); makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = histTrafficJoinTablePath; makeTableViewTool.out_view = "Streets_Patterns_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Streets_Patterns_View"; addJoinTool.in_field = "EdgeFID"; addJoinTool.join_table = streetsFeatureClassPath; addJoinTool.join_field = "OBJECTID"; gp.Execute(addJoinTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Streets_Patterns_View"; calcFieldTool.field = HistTrafficJoinTableName + ".KPH"; calcFieldTool.expression = "[" + StreetsFCName + ".KPH]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Streets_Patterns_View"; removeJoinTool.join_name = StreetsFCName; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Patterns_View"; gp.Execute(deleteTool, trackcancel); AddMessage("Creating and calculating the daily patterns fields on the historical traffic join table...", messages, trackcancel); string[] fieldNames = new string[] { "S", "M", "T", "W", "R", "F", "S" }; foreach (string f in fieldNames) { addFieldTool = new AddField(); addFieldTool.in_table = histTrafficJoinTablePath; addFieldTool.field_type = "SHORT"; addFieldTool.field_name = f; gp.Execute(addFieldTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = histTrafficJoinTablePath; calcFieldTool.field = f; calcFieldTool.expression = "1"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } // Create the Patterns table CreateNonHistoricalPatternsTable(outputFileGdbPath); } } #endregion // Copy the Cdms table to the file geodatabase AddMessage("Copying the Condition/Driving Manoeuvres (CDMS) table and indexing...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputCdmsTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "Cdms"; gp.Execute(importTableTool, trackcancel); string cdmsTablePath = outputFileGdbPath + "\\Cdms"; addIndexTool = new AddIndex(); addIndexTool.in_table = cdmsTablePath; addIndexTool.fields = "COND_ID"; addIndexTool.index_name = "COND_ID"; gp.Execute(addIndexTool, trackcancel); // Copy the Rdms table to the file geodatabase AddMessage("Copying the Restricted Driving Manoeuvres (RDMS) table...", messages, trackcancel); importTableTool = new TableToTable(); importTableTool.in_rows = inputRdmsTableValue.GetAsText(); importTableTool.out_path = outputFileGdbPath; importTableTool.out_name = "Rdms"; gp.Execute(importTableTool, trackcancel); string rdmsTablePath = outputFileGdbPath + "\\Rdms"; // Add and calculate the end of link and condition type fields to the Rdms table AddMessage("Creating and calculating fields for the manoeuvre types and ends of link...", messages, trackcancel); addFieldTool = new AddField(); addFieldTool.in_table = rdmsTablePath; addFieldTool.field_name = "COND_TYPE"; addFieldTool.field_type = "LONG"; gp.Execute(addFieldTool, trackcancel); addFieldTool.field_name = "END_OF_LK"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); makeTableViewTool = new MakeTableView(); makeTableViewTool.in_table = rdmsTablePath; makeTableViewTool.out_view = "Rdms_View"; gp.Execute(makeTableViewTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Rdms_View"; addJoinTool.in_field = "COND_ID"; addJoinTool.join_table = cdmsTablePath; addJoinTool.join_field = "COND_ID"; gp.Execute(addJoinTool, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Rdms_View"; calcFieldTool.field = "Rdms.COND_TYPE"; calcFieldTool.expression = "[Cdms.COND_TYPE]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); calcFieldTool.field = "Rdms.END_OF_LK"; calcFieldTool.expression = "[Cdms.END_OF_LK]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Rdms_View"; removeJoinTool.join_name = "Cdms"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Rdms_View"; gp.Execute(deleteTool, trackcancel); // Extract only the gates (condition type 4) and prohibitied manoeuvres (condition type 7) // If using Transport, also extract the Transport manoeuvres (condition type 26) AddMessage("Extracting restricted driving manoeuvres...", messages, trackcancel); string prohibRdmsWEndOfLkTablePath = outputFileGdbPath + "\\ProhibRdmsWEndOfLk"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = rdmsTablePath; tableSelectTool.out_table = prohibRdmsWEndOfLkTablePath; if (usesTransport) tableSelectTool.where_clause = "COND_TYPE IN (4, 7, 26)"; else tableSelectTool.where_clause = "COND_TYPE IN (4, 7)"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Creating turn feature class...", messages, trackcancel); // Create the turn feature class string tempStatsTablePath = outputFileGdbPath + "\\tempStatsTable"; Statistics statsTool = new Statistics(); statsTool.in_table = prohibRdmsWEndOfLkTablePath; statsTool.out_table = tempStatsTablePath; statsTool.statistics_fields = "SEQ_NUMBER MAX"; gp.Execute(statsTool, null); CreateAndPopulateTurnFeatureClass(outputFileGdbPath, fdsName, "ProhibRdmsWEndOfLk", "tempStatsTable", messages, trackcancel); deleteTool = new Delete(); deleteTool.in_data = tempStatsTablePath; gp.Execute(deleteTool, trackcancel); string pathToTurnFC = pathToFds + "\\" + TurnFCName; // Create and calculate condition type and access restriction fields on the turn feature class addFieldTool = new AddField(); addFieldTool.in_table = pathToTurnFC; addFieldTool.field_name = "COND_TYPE"; addFieldTool.field_type = "LONG"; gp.Execute(addFieldTool, trackcancel); AddMessage("Creating access restriction fields on the turn feature class...", messages, trackcancel); foreach (string arFieldSuffix in arFieldSuffixes) { addFieldTool = new AddField(); addFieldTool.in_table = pathToTurnFC; addFieldTool.field_name = "AR_" + arFieldSuffix; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); } makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = pathToTurnFC; makeFeatureLayerTool.out_layer = "Turn_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); addJoinTool = new AddJoin(); addJoinTool.in_layer_or_view = "Turn_Layer"; addJoinTool.in_field = "COND_ID"; addJoinTool.join_table = cdmsTablePath; addJoinTool.join_field = "COND_ID"; gp.Execute(addJoinTool, trackcancel); AddMessage("Calculating the COND_TYPE field on the turn feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Turn_Layer"; calcFieldTool.field = TurnFCName + ".COND_TYPE"; calcFieldTool.expression = "[Cdms.COND_TYPE]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); foreach (string arFieldSuffix in arFieldSuffixes) { AddMessage("Calculating the AR_" + arFieldSuffix + " field on the turn feature class...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "Turn_Layer"; calcFieldTool.field = TurnFCName + ".AR_" + arFieldSuffix; calcFieldTool.expression = "[Cdms.AR_" + arFieldSuffix + "]"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } removeJoinTool = new RemoveJoin(); removeJoinTool.in_layer_or_view = "Turn_Layer"; removeJoinTool.join_name = "Cdms"; gp.Execute(removeJoinTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Turn_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = cdmsTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = prohibRdmsWEndOfLkTablePath; gp.Execute(deleteTool, trackcancel); GC.Collect(); #region Process Transport Tables if (usesTransport) { string nonDimensionalCndModTablePath = outputFileGdbPath + "\\nonDimensionalCndMod"; string dimensionalCndModTablePath = outputFileGdbPath + "\\dimensionalCndMod"; if (!(inputUSCndModTableValue.IsEmpty())) { // Extract the Transport information for the US AddMessage("Extracting the US non-dimensional conditions...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputUSCndModTableValue.GetAsText(); tableSelectTool.out_table = nonDimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (38, 39, 46, 49, 60, 75)"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Extracting the US dimensional conditions...", messages, trackcancel); tableSelectTool.out_table = dimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (41, 42, 43, 44, 45, 48, 81)"; gp.Execute(tableSelectTool, trackcancel); // Create a new field to hold the dimension in a common unit (m or kg or KPH) addFieldTool = new AddField(); addFieldTool.in_table = dimensionalCndModTablePath; addFieldTool.field_name = "MetersOrKilogramsOrKPH"; addFieldTool.field_type = "DOUBLE"; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating common units of measure...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = dimensionalCndModTablePath; calcFieldTool.field = "MetersOrKilogramsOrKPH"; calcFieldTool.code_block = "x = CLng([MOD_VAL])\nSelect Case [MOD_TYPE]\n" + " Case 41, 44, 45, 81: x = x * 0.0254\n" + " Case 42, 43: x = x * 0.45359237\n" + " Case 48: x = x * 1.609344\nEnd Select"; calcFieldTool.expression = "x"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); if (!(inputNonUSCndModTableValue.IsEmpty())) { string tempNonDimensionalCndModTablePath = outputFileGdbPath + "\\tempNonDimensionalCndMod"; string tempDimensionalCndModTablePath = outputFileGdbPath + "\\tempDimensionalCndMod"; // Extract the Transport information for outside the US to temporary tables AddMessage("Extracting the non-US non-dimensional conditions...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputNonUSCndModTableValue.GetAsText(); tableSelectTool.out_table = tempNonDimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (38, 39, 46, 49, 60, 75)"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Extracting the non-US dimensional conditions...", messages, trackcancel); tableSelectTool.out_table = tempDimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (41, 42, 43, 44, 45, 48, 81)"; gp.Execute(tableSelectTool, trackcancel); // Create a new field to hold the dimension in a common unit (m or kg) addFieldTool = new AddField(); addFieldTool.in_table = tempDimensionalCndModTablePath; addFieldTool.field_name = "MetersOrKilogramsOrKPH"; addFieldTool.field_type = "DOUBLE"; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating common units of measure...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = dimensionalCndModTablePath; calcFieldTool.field = "MetersOrKilogramsOrKPH"; calcFieldTool.code_block = "x = CLng([MOD_VAL])\nSelect Case [MOD_TYPE]\n" + " Case 41, 44, 45, 81: x = x * 0.01\nEnd Select"; calcFieldTool.expression = "x"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); // Append the temporary tables to the main table containing US attributes Append appendTool = new Append(); appendTool.inputs = tempNonDimensionalCndModTablePath; appendTool.target = nonDimensionalCndModTablePath; gp.Execute(appendTool, trackcancel); appendTool.inputs = tempDimensionalCndModTablePath; appendTool.target = dimensionalCndModTablePath; gp.Execute(appendTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = tempNonDimensionalCndModTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = tempDimensionalCndModTablePath; gp.Execute(deleteTool, trackcancel); } } else { // Extract the Transport information for outside the US AddMessage("Extracting the non-US non-dimensional conditions...", messages, trackcancel); tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputNonUSCndModTableValue.GetAsText(); tableSelectTool.out_table = nonDimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (38, 39, 46, 49, 60, 75)"; gp.Execute(tableSelectTool, trackcancel); AddMessage("Extracting the non-US dimensional conditions...", messages, trackcancel); tableSelectTool.out_table = dimensionalCndModTablePath; tableSelectTool.where_clause = "MOD_TYPE IN (41, 42, 43, 44, 45, 48, 81)"; gp.Execute(tableSelectTool, trackcancel); // Create a new field to hold the dimension in a common unit (m or kg) addFieldTool = new AddField(); addFieldTool.in_table = dimensionalCndModTablePath; addFieldTool.field_name = "MetersOrKilogramsOrKPH"; addFieldTool.field_type = "DOUBLE"; gp.Execute(addFieldTool, trackcancel); AddMessage("Calculating common units of measure...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = dimensionalCndModTablePath; calcFieldTool.field = "MetersOrKilogramsOrKPH"; calcFieldTool.code_block = "x = CLng([MOD_VAL])\nSelect Case [MOD_TYPE]\n" + " Case 41, 44, 45, 81: x = x * 0.01\nEnd Select"; calcFieldTool.expression = "x"; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); } // Create a table for looking up LINK_IDs from COND_IDs AddMessage("Creating and indexing LINK_ID/COND_ID look-up table for preferred roads...", messages, trackcancel); string preferredLinkIDLookupTablePath = outputFileGdbPath + "\\preferredLinkIDLookupTable"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputCdmsTableValue.GetAsText(); tableSelectTool.out_table = preferredLinkIDLookupTablePath; tableSelectTool.where_clause = "COND_TYPE = 27"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = preferredLinkIDLookupTablePath; addIndexTool.fields = "COND_ID"; addIndexTool.index_name = "COND_ID"; gp.Execute(addIndexTool, trackcancel); // Create a table for looking up the condition's direction AddMessage("Creating and indexing direction look-up table for preferred roads...", messages, trackcancel); string preferredDirectionLookupTablePath = outputFileGdbPath + "\\preferredDirectionLookupTable"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = nonDimensionalCndModTablePath; tableSelectTool.out_table = preferredDirectionLookupTablePath; tableSelectTool.where_clause = "MOD_TYPE = 60"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = preferredDirectionLookupTablePath; addIndexTool.fields = "COND_ID"; addIndexTool.index_name = "COND_ID"; gp.Execute(addIndexTool, trackcancel); // Create a table for looking up LINK_IDs from COND_IDs AddMessage("Creating and indexing LINK_ID/COND_ID look-up table for restrictions...", messages, trackcancel); string restrictionLinkIDLookupTablePath = outputFileGdbPath + "\\restrictionLinkIDLookupTable"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = inputCdmsTableValue.GetAsText(); tableSelectTool.out_table = restrictionLinkIDLookupTablePath; tableSelectTool.where_clause = "COND_TYPE = 23"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = restrictionLinkIDLookupTablePath; addIndexTool.fields = "COND_ID"; addIndexTool.index_name = "COND_ID"; gp.Execute(addIndexTool, trackcancel); // Create a table for looking up the condition's direction AddMessage("Creating and indexing direction look-up table for restrictions...", messages, trackcancel); string restrictionDirectionLookupTablePath = outputFileGdbPath + "\\restrictionDirectionLookupTable"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = nonDimensionalCndModTablePath; tableSelectTool.out_table = restrictionDirectionLookupTablePath; tableSelectTool.where_clause = "MOD_TYPE = 38"; gp.Execute(tableSelectTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = restrictionDirectionLookupTablePath; addIndexTool.fields = "COND_ID"; addIndexTool.index_name = "COND_ID"; gp.Execute(addIndexTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = streetsFeatureClassPath; makeFeatureLayerTool.out_layer = "Streets_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); CreateAndPopulateTruckFCOverrideField(outputFileGdbPath, gp, messages, trackcancel); if (fgdbVersion >= 10.1) { // Create and calculate the preferred fields for Streets CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "STAAPreferred", "MOD_TYPE = 49 AND MOD_VAL = '1'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "TruckDesignatedPreferred", "MOD_TYPE = 49 AND MOD_VAL = '2'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "NRHMPreferred", "MOD_TYPE = 49 AND MOD_VAL = '3'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "ExplosivesPreferred", "MOD_TYPE = 49 AND MOD_VAL = '4'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "PIHPreferred", "MOD_TYPE = 49 AND MOD_VAL = '5'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "MedicalWastePreferred", "MOD_TYPE = 49 AND MOD_VAL = '6'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "RadioactivePreferred", "MOD_TYPE = 49 AND MOD_VAL = '7'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "HazmatPreferred", "MOD_TYPE = 49 AND MOD_VAL = '8'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, true, "LocallyPreferred", "MOD_TYPE = 49 AND MOD_VAL = '9'", gp, messages, trackcancel); if (createArcGISOnlineNetworkAttributes) { CreateAndPopulateAGOLTextTransportFieldsOnStreets(outputFileGdbPath, "PreferredTruckRoute", new string[] { "STAAPreferred", "TruckDesignatedPreferred", "LocallyPreferred" }, gp, messages, trackcancel); CreateAndPopulateAGOLTextTransportFieldsOnStreets(outputFileGdbPath, "PreferredHazmatRoute", new string[] { "NRHMPreferred", "ExplosivesPreferred", "PIHPreferred", "MedicalWastePreferred", "RadioactivePreferred", "HazmatPreferred" }, gp, messages, trackcancel); } } // Create and calculate the HazMat restriction fields for Streets CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "ExplosivesProhibited", "MOD_TYPE = 39 AND MOD_VAL = '1'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "GasProhibited", "MOD_TYPE = 39 AND MOD_VAL = '2'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "FlammableProhibited", "MOD_TYPE = 39 AND MOD_VAL = '3'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "CombustibleProhibited", "MOD_TYPE = 39 AND MOD_VAL = '4'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "OrganicProhibited", "MOD_TYPE = 39 AND MOD_VAL = '5'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "PoisonProhibited", "MOD_TYPE = 39 AND MOD_VAL = '6'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "RadioactiveProhibited", "MOD_TYPE = 39 AND MOD_VAL = '7'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "CorrosiveProhibited", "MOD_TYPE = 39 AND MOD_VAL = '8'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "OtherHazmatProhibited", "MOD_TYPE = 39 AND MOD_VAL = '9'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "AnyHazmatProhibited", "MOD_TYPE = 39 AND MOD_VAL = '20'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "PIHProhibited", "MOD_TYPE = 39 AND MOD_VAL = '21'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "HarmfulToWaterProhibited", "MOD_TYPE = 39 AND MOD_VAL = '22'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "ExplosiveAndFlammableProhibited", "MOD_TYPE = 39 AND MOD_VAL = '23'", gp, messages, trackcancel); if (createArcGISOnlineNetworkAttributes) { CreateAndPopulateAGOLTextTransportFieldsOnStreets(outputFileGdbPath, "AGOL_AnyHazmatProhibited", new string[] { "ExplosivesProhibited", "GasProhibited", "FlammableProhibited", "CombustibleProhibited", "OrganicProhibited", "PoisonProhibited", "RadioactiveProhibited", "CorrosiveProhibited", "OtherHazmatProhibited", "AnyHazmatProhibited", "PIHProhibited", "HarmfulToWaterProhibited", "ExplosiveAndFlammableProhibited" }, gp, messages, trackcancel); } // Create and calculate the other restriction fields for Streets CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "HeightLimit_Meters", "MOD_TYPE = 41", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "WeightLimit_Kilograms", "MOD_TYPE = 42", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "WeightLimitPerAxle_Kilograms", "MOD_TYPE = 43", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "LengthLimit_Meters", "MOD_TYPE = 44", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "WidthLimit_Meters", "MOD_TYPE = 45", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, true, false, "MaxTrailersAllowedOnTruck", "MOD_TYPE = 46 AND MOD_VAL IN ('1', '2', '3')", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "SemiOrTractorWOneOrMoreTrailersProhibited", "MOD_TYPE = 46 AND MOD_VAL = '4'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, true, false, "MaxAxlesAllowed", "MOD_TYPE = 75 AND MOD_VAL IN ('1', '2', '3', '4', '5')", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "SingleAxleProhibited", "MOD_TYPE = 75 AND MOD_VAL = '6'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, false, false, false, "TandemAxleProhibited", "MOD_TYPE = 75 AND MOD_VAL = '7'", gp, messages, trackcancel); CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, false, "KingpinToRearAxleLengthLimit_Meters", "MOD_TYPE = 81", gp, messages, trackcancel); // Create and calculate the truck speed fields for Streets CreateAndPopulateTransportFieldsOnStreets(outputFileGdbPath, true, false, true, "TruckKPH", "MOD_TYPE = 48", gp, messages, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "Streets_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = preferredLinkIDLookupTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = preferredDirectionLookupTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = restrictionLinkIDLookupTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = restrictionDirectionLookupTablePath; gp.Execute(deleteTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = pathToTurnFC; makeFeatureLayerTool.out_layer = "RestrictedTurns_Layer"; gp.Execute(makeFeatureLayerTool, trackcancel); // Create and calculate the HazMat restriction fields for RestrictedTurns CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "ExplosivesProhibited", "MOD_TYPE = 39 AND MOD_VAL = '1'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "GasProhibited", "MOD_TYPE = 39 AND MOD_VAL = '2'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "FlammableProhibited", "MOD_TYPE = 39 AND MOD_VAL = '3'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "CombustibleProhibited", "MOD_TYPE = 39 AND MOD_VAL = '4'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "OrganicProhibited", "MOD_TYPE = 39 AND MOD_VAL = '5'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "PoisonProhibited", "MOD_TYPE = 39 AND MOD_VAL = '6'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "RadioactiveProhibited", "MOD_TYPE = 39 AND MOD_VAL = '7'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "CorrosiveProhibited", "MOD_TYPE = 39 AND MOD_VAL = '8'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "OtherHazmatProhibited", "MOD_TYPE = 39 AND MOD_VAL = '9'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "AnyHazmatProhibited", "MOD_TYPE = 39 AND MOD_VAL = '20'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "PIHProhibited", "MOD_TYPE = 39 AND MOD_VAL = '21'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "HarmfulToWaterProhibited", "MOD_TYPE = 39 AND MOD_VAL = '22'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "ExplosiveAndFlammableProhibited", "MOD_TYPE = 39 AND MOD_VAL = '23'", gp, messages, trackcancel); if (createArcGISOnlineNetworkAttributes) { CreateAndPopulateAGOLTextTransportFieldOnTurns(outputFileGdbPath, "AGOL_AnyHazmatProhibited", new string[] { "ExplosivesProhibited", "GasProhibited", "FlammableProhibited", "CombustibleProhibited", "OrganicProhibited", "PoisonProhibited", "RadioactiveProhibited", "CorrosiveProhibited", "OtherHazmatProhibited", "AnyHazmatProhibited", "PIHProhibited", "HarmfulToWaterProhibited", "ExplosiveAndFlammableProhibited" }, gp, messages, trackcancel); } // Create and calculate the other restriction fields for RestrictedTurns CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "HeightLimit_Meters", "MOD_TYPE = 41", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "WeightLimit_Kilograms", "MOD_TYPE = 42", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "WeightLimitPerAxle_Kilograms", "MOD_TYPE = 43", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "LengthLimit_Meters", "MOD_TYPE = 44", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "WidthLimit_Meters", "MOD_TYPE = 45", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, true, "MaxTrailersAllowedOnTruck", "MOD_TYPE = 46 AND MOD_VAL IN ('1', '2', '3')", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "SemiOrTractorWOneOrMoreTrailersProhibited", "MOD_TYPE = 46 AND MOD_VAL = '4'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, true, "MaxAxlesAllowed", "MOD_TYPE = 75 AND MOD_VAL IN ('1', '2', '3', '4', '5')", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "SingleAxleProhibited", "MOD_TYPE = 75 AND MOD_VAL = '6'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, false, false, "TandemAxleProhibited", "MOD_TYPE = 75 AND MOD_VAL = '7'", gp, messages, trackcancel); CreateAndPopulateTransportFieldOnTurns(outputFileGdbPath, true, false, "KingpinToRearAxleLengthLimit_Meters", "MOD_TYPE = 81", gp, messages, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "RestrictedTurns_Layer"; gp.Execute(deleteTool, trackcancel); // Create and calculate the AllTransportProhibited field addFieldTool = new AddField(); addFieldTool.in_table = pathToTurnFC; addFieldTool.field_name = "AllTransportProhibited"; addFieldTool.field_type = "TEXT"; addFieldTool.field_length = 1; gp.Execute(addFieldTool, trackcancel); makeFeatureLayerTool = new MakeFeatureLayer(); makeFeatureLayerTool.in_features = pathToTurnFC; makeFeatureLayerTool.out_layer = "RestrictedTurns_Layer"; makeFeatureLayerTool.where_clause = "COND_TYPE = 26 AND ExplosivesProhibited IS NULL AND GasProhibited IS NULL AND " + "FlammableProhibited IS NULL AND CombustibleProhibited IS NULL AND OrganicProhibited IS NULL AND " + "PoisonProhibited IS NULL AND RadioactiveProhibited IS NULL AND CorrosiveProhibited IS NULL AND " + "OtherHazmatProhibited IS NULL AND AnyHazmatProhibited IS NULL AND PIHProhibited IS NULL AND " + "HarmfulToWaterProhibited IS NULL AND ExplosiveAndFlammableProhibited IS NULL AND " + "HeightLimit_Meters IS NULL AND WeightLimit_Kilograms IS NULL AND WeightLimitPerAxle_Kilograms IS NULL AND " + "LengthLimit_Meters IS NULL AND WidthLimit_Meters IS NULL AND MaxTrailersAllowedOnTruck IS NULL AND " + "SemiOrTractorWOneOrMoreTrailersProhibited IS NULL AND MaxAxlesAllowed IS NULL AND " + "SingleAxleProhibited IS NULL AND TandemAxleProhibited IS NULL AND KingpinToRearAxleLengthLimit_Meters IS NULL"; gp.Execute(makeFeatureLayerTool, trackcancel); AddMessage("Calculating the AllTransportProhibited field...", messages, trackcancel); calcFieldTool = new CalculateField(); calcFieldTool.in_table = "RestrictedTurns_Layer"; calcFieldTool.field = "AllTransportProhibited"; calcFieldTool.expression = "\"Y\""; calcFieldTool.expression_type = "VB"; gp.Execute(calcFieldTool, trackcancel); deleteTool = new Delete(); deleteTool.in_data = "RestrictedTurns_Layer"; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = nonDimensionalCndModTablePath; gp.Execute(deleteTool, trackcancel); deleteTool.in_data = dimensionalCndModTablePath; gp.Execute(deleteTool, trackcancel); GC.Collect(); } #endregion // Extract the special explications (condition type 9) from the Rdms Table and create RoadSplits table AddMessage("Creating RoadSplits table...", messages, trackcancel); string specialExplicationRdmsWEndOfLkTablePath = outputFileGdbPath + "\\SpecialExplicationRdmsWEndOfLk"; tableSelectTool = new TableSelect(); tableSelectTool.in_table = rdmsTablePath; tableSelectTool.out_table = specialExplicationRdmsWEndOfLkTablePath; tableSelectTool.where_clause = "COND_TYPE = 9"; gp.Execute(tableSelectTool, trackcancel); deleteTool.in_data = rdmsTablePath; gp.Execute(deleteTool, trackcancel); CreateRoadSplitsTable("SpecialExplicationRdmsWEndOfLk", outputFileGdbPath, messages, trackcancel); deleteTool.in_data = specialExplicationRdmsWEndOfLkTablePath; gp.Execute(deleteTool, trackcancel); // Create Signpost feature class and table AddMessage("Creating signpost feature class and table...", messages, trackcancel); CreateSignposts(inputSignsTableValue.GetAsText(), outputFileGdbPath, messages, trackcancel); AddSpatialIndex addSpatialIndexTool = new AddSpatialIndex(); addSpatialIndexTool.in_features = pathToFds + "\\" + SignpostFCName; gp.Execute(addSpatialIndexTool, trackcancel); addIndexTool = new AddIndex(); addIndexTool.in_table = outputFileGdbPath + "\\" + SignpostJoinTableName; addIndexTool.fields = "SignpostID"; addIndexTool.index_name = "SignpostID"; gp.Execute(addIndexTool, trackcancel); addIndexTool.fields = "Sequence"; addIndexTool.index_name = "Sequence"; gp.Execute(addIndexTool, trackcancel); addIndexTool.fields = "EdgeFCID"; addIndexTool.index_name = "EdgeFCID"; gp.Execute(addIndexTool, trackcancel); addIndexTool.fields = "EdgeFID"; addIndexTool.index_name = "EdgeFID"; gp.Execute(addIndexTool, trackcancel); GC.Collect(); // Upgrade the geodatabase (if not 9.3) if (fgdbVersion > 9.3) { UpgradeGDB upgradeGdbTool = new UpgradeGDB(); upgradeGdbTool.input_workspace = outputFileGdbPath; gp.Execute(upgradeGdbTool, trackcancel); } // Create and build the network dataset, then pack it in a GPValue AddMessage("Creating and building the network dataset...", messages, trackcancel); CreateAndBuildNetworkDataset(outputFileGdbPath, fgdbVersion, fdsName, ndsName, createNetworkAttributesInMetric, createArcGISOnlineNetworkAttributes, timeZoneIDBaseFieldName, directedTimeZoneIDFields, commonTimeZone, usesHistoricalTraffic, trafficFeedLocation, usesTransport); // Write the build errors to the turn feature class TurnGeometryUtilities.WriteBuildErrorsToTurnFC(outputFileGdbPath, fdsName, TurnFCName, messages, trackcancel); // Compact the output file geodatabase AddMessage("Compacting the output file geodatabase...", messages, trackcancel); Compact compactTool = new Compact(); compactTool.in_workspace = outputFileGdbPath; gp.Execute(compactTool, trackcancel); } catch (Exception e) { if (gp.MaxSeverity == 2) { object missing = System.Type.Missing; messages.AddError(1, gp.GetMessages(ref missing)); } messages.AddError(1, e.Message); messages.AddError(1, e.StackTrace); } finally { // Restore the original GP environment settings gpSettings.AddOutputsToMap = origAddOutputsToMapSetting; gpSettings.LogHistory = origLogHistorySetting; } GC.Collect(); return; }
internal void Rename(Rename a_rename) { var renameCollection = Rename(); if (renameCollection == null) { renameCollection = new Collection4(); _config.Put(RenameKey, renameCollection); } renameCollection.Add(a_rename); }
private static void GetOffset(Rename command, ref int pos) { if (command != null) { foreach (var entry in command.Results) { if (entry.Key == startState.FileName) { int offset = command.NewName.Length - command.TargetName.Length; foreach (var match in entry.Value) { if (pos > match.Index) { pos += offset; } else break; // Assuming the results are sorted in ascending order of Index. Basically all rename (and many other refactoring) operations have this assumption. } break; } } } }
private bool ApplyRename(Rename ren) { if (ren.IsField()) { return ApplyFieldRename(ren); } return ApplyClassRename(ren); }
private IObjectSet QueryInverseRenames(Rename ren) { return QueryByExample(SystemTransaction(), Renames.ForInverseQBE(ren)); }
private void DeleteInverseRenames(Rename rename) { // delete all that rename from the new name // to allow future backswitching var inverseRenames = QueryInverseRenames(rename); while (inverseRenames.HasNext()) { Delete(SystemTransaction(), inverseRenames.Next()); } }
private static void OnRefactorComplete(object sender, RefactorCompleteEventArgs<IDictionary<string, List<SearchMatch>>> e) { currentCommand.OnRefactorComplete -= OnRefactorComplete; if (queue.Count == 0) { //if (currentCommand.OutputResults) //{ // PluginBase.MainForm.CallCommand("PluginCommand", "ResultsPanel.ShowResults"); //} if (startState != null) RestoreStartState(); currentCommand = null; startState = null; } else ExecuteFirst(); }
static void OnRefactorComplete(object sender, RefactorCompleteEventArgs<IDictionary<string, List<SearchMatch>>> e) { if (queue.Count > 0) ExecuteFirst(); else currentCommand = null; }