From: Vásáry Dániel Date: Mon, 13 Nov 2017 17:10:02 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=62bb9d97c2a0b89bd1acd83b01a29671529154d1;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30723 --- diff --git a/client/AudioRecorder/AudioRecorder.csproj b/client/AudioRecorder/AudioRecorder.csproj index d2381272..21120b51 100644 --- a/client/AudioRecorder/AudioRecorder.csproj +++ b/client/AudioRecorder/AudioRecorder.csproj @@ -201,7 +201,7 @@ Settings.settings True - + PreserveNewest diff --git a/client/AudioRecorder/Resources/configuration.json b/client/AudioRecorder/Configuration/audiorecorder.json similarity index 52% rename from client/AudioRecorder/Resources/configuration.json rename to client/AudioRecorder/Configuration/audiorecorder.json index e6202afb..4b8317be 100644 --- a/client/AudioRecorder/Resources/configuration.json +++ b/client/AudioRecorder/Configuration/audiorecorder.json @@ -1,9 +1,9 @@ { "audio_device_name": "", - "unc_path": "c:\\temp", + "unc_path": "I:\\", "working_dir": "C:\\temp", - "loud_percent": 10, - "address": "http://10.10.1.28/services/rest/octopus/", + "loud_percent": 30, + "address": "http://10.10.1.27/services/rest/octopus/", "userName": "dani", "password": "dani", "timeout": 1000 diff --git a/client/AudioRecorder/FileNameForm.cs b/client/AudioRecorder/FileNameForm.cs index 8f7169d7..b9f2f603 100644 --- a/client/AudioRecorder/FileNameForm.cs +++ b/client/AudioRecorder/FileNameForm.cs @@ -23,7 +23,7 @@ namespace AudioRecorder { }; } - private void IdChangedEvent(string id, string name) { + private void IdChangedEvent(string id, string name, string text) { //TODO this.id = name; buttonRendben.Enabled = !String.IsNullOrEmpty(id); diff --git a/client/AudioRecorder/MainForm.cs b/client/AudioRecorder/MainForm.cs index 41b19f47..6a4ad3ef 100644 --- a/client/AudioRecorder/MainForm.cs +++ b/client/AudioRecorder/MainForm.cs @@ -16,7 +16,8 @@ namespace AudioRecorder [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam); - private const String CONFIG_FILE = "Resources/configuration.json"; + //private const String CONFIG_FILE = "Resources/configuration.json"; + private const String CONFIG_FILE = "Configuration/audiorecorder.json"; private IRecorder recorder; private ISettings settings; @@ -161,11 +162,29 @@ namespace AudioRecorder private void copyFileToUncPath() { - String wavFileName = new FileInfo(recorder.getCurentWavFilePath()).Name; - String wavUncPath = String.Format("{0}{1}{2}", settings.getUncPath(), Path.DirectorySeparatorChar, wavFileName); + FileInfo fileInfo = new FileInfo(recorder.getCurentWavFilePath()); + String wavFileName = fileInfo.Name; + String wavUncPath = DetermineWorkingDirectory(settings.getUncPath(), fileInfo.Name); + if (!Directory.Exists(wavUncPath)) + Directory.CreateDirectory(wavUncPath); + wavUncPath = Path.Combine(wavUncPath, fileInfo.Name); + //String.Format("{0}{1}{2}", settings.getUncPath(), Path.DirectorySeparatorChar, wavFileName); fileWorker.copy(recorder.getCurentWavFilePath(), wavUncPath); } + protected String DetermineWorkingDirectory(string path, string ID) { + string result = path; + string subDir = ID; + if (ID.Contains("_")) { + subDir = ID.Split('_')[0]; + } + if (ID.Contains(".")) { + subDir = ID.Split('.')[0]; + } + result = Path.Combine(path, subDir); + return result; + } + private void record_Click(object sender, EventArgs e) { FileNameForm nameForm = new FileNameForm(this, settings); diff --git a/client/DxPlay/PlayerForm.cs b/client/DxPlay/PlayerForm.cs index 0dae3df5..f3965e63 100644 --- a/client/DxPlay/PlayerForm.cs +++ b/client/DxPlay/PlayerForm.cs @@ -211,6 +211,8 @@ namespace DxPlay { private void DisableHotKeysDefaults(Control.ControlCollection controls) { foreach (Control control in controls) { + if (control.Equals(dgSegments)) + continue; control.PreviewKeyDown += new PreviewKeyDownEventHandler(PlayerForm_PreviewKeyDown); if (control.HasChildren) DisableHotKeysDefaults(control.Controls); @@ -236,12 +238,14 @@ namespace DxPlay { private void PlayerForm_KeyDown(object sender, KeyEventArgs e) { e.Handled = true; - e.SuppressKeyPress = true; + e.SuppressKeyPress = true; } private bool HandleHotKey(Keys keyCode) { - if (m_play == null) - return false; + Debug.WriteLine("Key pressed " + keyCode); + if (m_play == null || dgSegments.IsCurrentCellInEditMode || (!m_play.IsFullscreen() && !this.ContainsFocus)) + return true; + Debug.WriteLine("Handling " + keyCode); bool result = false; switch (keyCode) { case Keys.Escape: diff --git a/client/Maestro/ArchiveMetadataForm.Designer.cs b/client/Maestro/ArchiveMetadataForm.Designer.cs index ffd26be7..8edd6160 100644 --- a/client/Maestro/ArchiveMetadataForm.Designer.cs +++ b/client/Maestro/ArchiveMetadataForm.Designer.cs @@ -227,7 +227,6 @@ // // ArchiveMetadataForm // - this.AcceptButton = this.btnOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; diff --git a/client/Maestro/Configuration/configuration-playout-ingest.json b/client/Maestro/Configuration/configuration-playout-ingest.json index 2cc6c0d2..aa818ef7 100644 --- a/client/Maestro/Configuration/configuration-playout-ingest.json +++ b/client/Maestro/Configuration/configuration-playout-ingest.json @@ -1,6 +1,6 @@ { "title": "Lebony betöltő", - "active": false, + "active": true, "startInTray": false, "enableCustomMetadataId": true, "player": { @@ -25,6 +25,13 @@ } }, "metadatas": [ + { + "$type": "OctopusMetadata", + "server": { + "address": "http://10.10.1.27/services/rest/octopus/", + "timeout": 1000 + } + }, { "$type": "TrafficMetadata", "server": { diff --git a/client/Maestro/Configuration/configuration-sxs.json b/client/Maestro/Configuration/configuration-sxs.json index 7032fa13..a3a97954 100644 --- a/client/Maestro/Configuration/configuration-sxs.json +++ b/client/Maestro/Configuration/configuration-sxs.json @@ -1,6 +1,6 @@ { "title": "SxS", - "active": true, + "active": false, "startInTray": false, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 56efa401..5a320c8b 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -95,6 +95,11 @@ namespace Maestro { private void OnArchiveMetadataClick(object sender, EventArgs e) { if (archiveMetadata == null) archiveMetadata = GetArchiveMetadata(); + if (archiveMetadata == null || !archiveMetadata.IsFilled) { + MessageBox.Show("Nem található archív metaadat!"); + return; + } + ArchiveMetadataForm form = new ArchiveMetadataForm(archiveMetadata); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK && String.IsNullOrEmpty(textSelectedMetadata.Text)) @@ -203,8 +208,9 @@ namespace Maestro { case MetadataType.MediaCube: result = GetMediaCubeMetadata(); break; + case MetadataType.OctopusStory: case MetadataType.OctopusPlaceHolder: - result = GetOctopusMetadata(); + result = GetOctopusMetadata(metadataType); break; case MetadataType.TrafficMaterial: case MetadataType.TrafficPromo: @@ -256,45 +262,55 @@ namespace Maestro { return result; } - private ArchiveMetadata GetOctopusMetadata() { - ArchiveMetadata result = new ArchiveMetadata(); - string id = SelectedMetadata?.VariantID.ToString(); + private ArchiveMetadata GetOctopusMetadata(MetadataType metadataType) { + string id = SelectedMetadata?.ID.ToString(); if (String.IsNullOrEmpty(id)) return null; OctopusAPI api = octopusIDSelector.GetClient(); - IEnumerable storiesEnum = api.GetStoriesByPlaceHolderId(id); - if (storiesEnum != null) { - List stories = storiesEnum.ToList(); - FillModelFromStories(result, stories, api); + IEnumerable octopusResult = null; + switch (metadataType) { + case MetadataType.OctopusPlaceHolder: + octopusResult = api.GetStoriesByPlaceHolderId(id); + break; + case MetadataType.OctopusStory: + octopusResult = api.GetStoriesByParentStoryId(id); + break; } - return result; + if (octopusResult == null) + return null; + List stories = octopusResult.ToList(); + return GetStoryMetadata(stories); } - private void FillModelFromStories(ArchiveMetadata model, List stories, OctopusAPI api) { + private ArchiveMetadata GetStoryMetadata(List stories) { if (stories == null || stories.Count == 0) - return; + return null; Story story = stories[0]; - if (story.StoryFolders != null && story.StoryFolders.Length > 0) { - IEnumerable storyFoldersEnum = api.GetStoryFoldersByStoryID(story.ID); - if (storyFoldersEnum == null) - return; - List storyFolders = storyFoldersEnum.ToList(); - StoryFolder folder = storyFolders[0]; - model.itemHouseId = folder.ID; - model.itemTitle = folder.Name; - } else if (story.Rundowns != null) { + ArchiveMetadata result = new ArchiveMetadata(); + + OctopusAPI api = octopusIDSelector.GetClient(); + if (story.Rundowns != null && story.Rundowns.Length > 0) { IEnumerable rundownsEnum = api.GetRundownsByStoryID(story.ID); if (rundownsEnum == null) - return; + return null; List rundowns = rundownsEnum.ToList(); Rundown rundown = rundowns[0]; - model.itemHouseId = rundown.ID; - model.itemTitle = rundown.Name; - model.itemDescription = rundown.Start.ToString(); + result.itemHouseId = rundown.ID; + result.itemTitle = rundown.Name; + result.itemDescription = rundown.Start.ToString(); + } else if (story.StoryFolders != null && story.StoryFolders.Length > 0) { + IEnumerable storyFoldersEnum = api.GetStoryFoldersByStoryID(story.ID); + if (storyFoldersEnum == null) + return null; + List storyFolders = storyFoldersEnum.ToList(); + StoryFolder folder = storyFolders[0]; + result.itemHouseId = folder.ID; + result.itemTitle = folder.Name; } - model.mediaHouseId = story.ID; - model.mediaTitle = story.Name; - model.mediaDescription = story.Script; + result.mediaHouseId = story.ID; + result.mediaTitle = story.Name; + result.mediaDescription = story.ScriptContent; + return result; } private void OnMetadataIDChanged(object sender, EventArgs e) { @@ -320,17 +336,18 @@ namespace Maestro { UpdateLookupByMetadataEnabled(); } - private void OnOctopusIDSelected(string id, string name) { + private void OnOctopusIDSelected(string id, string name, string text) { trafficIDSelector.ClearSelection(); archiveMetadata = null; if (id == null) { SelectedMetadata = null; return; } - MetadataType metadataType = GuessMetadataType(id); + MetadataType metadataType = GuessMetadataType(name); SelectedMetadata = new MetadataInfo() { Kind = metadataType, ID = name, + MetadataText = text, VariantID = int.Parse(id) }; } @@ -379,6 +396,10 @@ namespace Maestro { } private void OnLookupByMetadata(object sender, EventArgs e) { + Lookup(SelectedMetadata.ID); + } + + private void Lookup(string id) { MetadataProvider config = null; switch (SelectedMetadata?.Kind) { case MetadataType.TrafficAD: @@ -392,19 +413,17 @@ namespace Maestro { config = Configuration.GetMetadataProvider(); if (config == null) return; - octopusIDSelector.LookupByPlaceHolder(SelectedMetadata.ID); + octopusIDSelector.LookupByPlaceHolder(id); break; case MetadataType.OctopusStory: config = Configuration.GetMetadataProvider(); if (config == null) return; - octopusIDSelector.LookupByStory(SelectedMetadata.ID); + octopusIDSelector.LookupByStory(id); break; } } - - private void UpdateEditArchiveMetadataEnabled() { ctxiModifyArchiveMetadata.Enabled = SelectedSource != null; } diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 7810788c..fd47e852 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -216,22 +216,23 @@ namespace Maestro { } private void OnLookupBySource(object sender, EventArgs e) { - Cursor.Current = Cursors.WaitCursor; - MetadataType metadataType = GuessMetadataType(SelectedSource?.Prefix); - switch (metadataType) { - case MetadataType.TrafficMaterial: - case MetadataType.TrafficPromo: - case MetadataType.TrafficAD: - LookupTraffic(metadataType); - break; - case MetadataType.OctopusPlaceHolder: - LookupOctopus(); - break; - } - trafficIDSelector.ClearSelection(); - octopusIDSelector.ClearSelection(); - - Cursor.Current = Cursors.Default; + Lookup(SelectedMetadata.ID); + //Cursor.Current = Cursors.WaitCursor; + //MetadataType metadataType = GuessMetadataType(SelectedSource?.Prefix); + //switch (metadataType) { + // case MetadataType.TrafficMaterial: + // case MetadataType.TrafficPromo: + // case MetadataType.TrafficAD: + // LookupTraffic(metadataType); + // break; + // case MetadataType.OctopusPlaceHolder: + // LookupOctopus(); + // break; + //} + //trafficIDSelector.ClearSelection(); + //octopusIDSelector.ClearSelection(); + + //Cursor.Current = Cursors.Default; } private void LookupTraffic(MetadataType metadataType) { @@ -282,25 +283,25 @@ namespace Maestro { // Cursor.Current = Cursors.Default; //} - private void LookupOctopus() { - OctopusAPI api = octopusIDSelector.GetClient(); - IEnumerable mosIDs = api.GetMosObjectsByID(SelectedSource?.Prefix); - if (mosIDs == null) { - MessageBox.Show(this, StringResources.NINCS_TALALAT); - return; - } - List mosObjects = mosIDs.ToList(); - if (mosObjects == null || mosObjects.Count == 0) { - MessageBox.Show(this, StringResources.NINCS_TALALAT); - return; - } - if (mosObjects.Count == 1) - OnOctopusIDSelected(mosObjects[0].ID, mosObjects[0].ObjID); - else { - OctopusLookupResultSelector box = new OctopusLookupResultSelector(mosObjects, OnOctopusIDSelected); - box.ShowDialog(); - } - } + //private void LookupOctopus() { + // OctopusAPI api = octopusIDSelector.GetClient(); + // IEnumerable mosIDs = api.GetMosObjectsByID(SelectedSource?.Prefix); + // if (mosIDs == null) { + // MessageBox.Show(this, StringResources.NINCS_TALALAT); + // return; + // } + // List mosObjects = mosIDs.ToList(); + // if (mosObjects == null || mosObjects.Count == 0) { + // MessageBox.Show(this, StringResources.NINCS_TALALAT); + // return; + // } + // if (mosObjects.Count == 1) + // OnOctopusIDSelected(mosObjects[0].ID, mosObjects[0].ObjID); + // else { + // OctopusLookupResultSelector box = new OctopusLookupResultSelector(mosObjects, OnOctopusIDSelected); + // box.ShowDialog(); + // } + //} private void picClearFilter_Click(object sender, EventArgs e) { diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index f35041e9..d16c82ce 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -17,6 +17,7 @@ namespace Maestro { public Target TargetConfig { get; set; } public string InputFileName { get; set; } public string ID { get; set; } + public string MetadataText { get; set; } public List Segments { get; set; } public List MovieSegments { get; set; } public MediaCubeApi MediaCubeApi { get; set; } @@ -157,6 +158,7 @@ namespace Maestro { SourceConfig = Configuration.Source, TargetConfig = target, ID = textSelectedMetadata.Text, + MetadataText = SelectedMetadata?.MetadataText, InputFileName = sourceItem.Name, Segments = segments == null ? null : new List(segments), MovieSegments = movieSegments == null ? null : movieSegments.ToList(), diff --git a/client/Maestro/Metadata/MetaDataInfo.cs b/client/Maestro/Metadata/MetaDataInfo.cs index bf0b4c19..04608efb 100644 --- a/client/Maestro/Metadata/MetaDataInfo.cs +++ b/client/Maestro/Metadata/MetaDataInfo.cs @@ -1,6 +1,7 @@ namespace Maestro.Metadata { public class MetadataInfo { public string ID { get; set; } + public string MetadataText { get; set; } public MetadataType Kind { get; set; } public int VariantID { get; set; } diff --git a/client/Maestro/Program.cs b/client/Maestro/Program.cs index c5240690..e4d849e2 100644 --- a/client/Maestro/Program.cs +++ b/client/Maestro/Program.cs @@ -82,6 +82,7 @@ namespace Maestro { public class TrayApplicationContext : ApplicationContext { private const string GLOBAL_JSON = "global.json"; + private const string AUDIORECORDER_JSON = "audiorecorder.json"; private const string JSON_WILDCARD = "*.json"; private const string CONFIG_ERROR = "Nem található aktív konfiguráció."; private const string SYSCONFIG_ERROR = "Nem található a 'global.json' rendszer konfiguráció."; @@ -113,6 +114,9 @@ namespace Maestro { CheckGlobalConfig(files); foreach (String file in files) { + string audioRecorderFile = Path.Combine(CONFIGURATION_FOLDER, AUDIORECORDER_JSON); + if (file.Equals(audioRecorderFile)) + continue; CreateForm(file); } if (forms.Count == 0) diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index 5664da0d..93a89e8a 100644 --- a/client/Maestro/Properties/AssemblyInfo.cs +++ b/client/Maestro/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.9.8")] -[assembly: AssemblyFileVersion("1.9.8")] +[assembly: AssemblyVersion("1.9.9")] +[assembly: AssemblyFileVersion("1.9.9")] diff --git a/client/Maestro/Resources/installforge-installer-project.ifp b/client/Maestro/Resources/installforge-installer-project.ifp index 480eb59c..899a0df4 100644 Binary files a/client/Maestro/Resources/installforge-installer-project.ifp and b/client/Maestro/Resources/installforge-installer-project.ifp differ diff --git a/client/Maestro/Splash.Designer.cs b/client/Maestro/Splash.Designer.cs index 840c11a0..7a16fb25 100644 --- a/client/Maestro/Splash.Designer.cs +++ b/client/Maestro/Splash.Designer.cs @@ -47,7 +47,6 @@ this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; - this.pictureBox1.Visible = false; // // labelVersion // diff --git a/client/Maestro/Targets/UNCTargetProcessor.cs b/client/Maestro/Targets/UNCTargetProcessor.cs index ba7ce562..2b48519d 100644 --- a/client/Maestro/Targets/UNCTargetProcessor.cs +++ b/client/Maestro/Targets/UNCTargetProcessor.cs @@ -9,6 +9,7 @@ using System.Text; using Maestro.Commons; using Commons; using Maestro.Metadata; +using System.Globalization; namespace Maestro.Targets { @@ -257,7 +258,11 @@ namespace Maestro.Targets { } protected virtual string CreateOutputFileName() { - string nameWithoutExtension = parameters.TargetConfig.OutputFormat.Replace("%ID%", ID).Replace("%SOURCENAME%", Path.GetFileNameWithoutExtension(InputName)); + string nameWithoutExtension = parameters.TargetConfig.OutputFormat + .Replace("%ID%", ID) + .Replace("%TEXT%", parameters.MetadataText) + .Replace("%SOURCENAME%", Path.GetFileNameWithoutExtension(InputName)) + .Replace("%TIMESTAMP%", DateTime.Now.ToString("yyyyMMddhhmmss", CultureInfo.InvariantCulture)); string extension = InputName.Contains(".") ? InputName.Substring(InputName.LastIndexOf(".")) : DEFAULT_EXTENSION; extension = extension.ToUpper(); string result = String.Format(FILENAME, nameWithoutExtension, extension); diff --git a/client/OctopusClient/OctopusAPI.cs b/client/OctopusClient/OctopusAPI.cs index 7e5fee05..793e76e3 100644 --- a/client/OctopusClient/OctopusAPI.cs +++ b/client/OctopusClient/OctopusAPI.cs @@ -23,8 +23,10 @@ namespace OctopusClient { public class Story { public string ID { get; set; } + public string ParentStoryID { get; set; } public string Name { get; set; } public string Script { get; set; } + public string ScriptContent { get; set; } public string Format { get; set; } public MosObject[] MosObjects { get; set; } public StoryFolder[] StoryFolders { get; set; } @@ -136,10 +138,12 @@ namespace OctopusClient { private Story ToStory(JToken d) { return new Story { ID = d["id"]?.ToString(), + ParentStoryID = d["parentStoryId"]?.ToString(), Name = d["name"]?.ToString(), Format = d["format"]?.ToString(), MosObjects = GetMosObjectsFromStory(d)?.ToArray(), Script = d["script"]?.ToString(), + ScriptContent = d["script_content"]?.ToString(), StoryFolders = GetStoryFolderFromStory(d)?.ToArray(), Rundowns = GetRundownFromStory(d)?.ToArray() }; @@ -270,7 +274,32 @@ namespace OctopusClient { public IEnumerable GetStoriesById(String id) { IEnumerable result = null; try { - var request = new RestRequest("getStoriesByIDRegex/{id}", Method.GET); + var request = new RestRequest("getStoriesByID/{id}", Method.GET); + request.AddParameter("id", id, ParameterType.UrlSegment); + var response = client.Execute(request); + if (response.ContentLength == 0) { + if (response.ErrorException != null) + throw new Exception(String.Format("[Octopus] {0}", response.ErrorMessage)); + else return null; + } + JArray resultObject = JArray.Parse(response.Content); + + result = resultObject.Children().Select(d => { + Story r = ToStory(d); + //logger.Debug($"{r}"); + return r; + }); + } + catch (Exception e) { + OnError(e); + } + return result; + } + + public IEnumerable GetStoriesByParentStoryId(String id) { + IEnumerable result = null; + try { + var request = new RestRequest("getStoriesByParentStoryID/{id}", Method.GET); request.AddParameter("id", id, ParameterType.UrlSegment); var response = client.Execute(request); if (response.ContentLength == 0) { diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index 3226f983..39b16776 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -8,7 +8,7 @@ using LinkDotNet.MessageHandling.Contracts; using System.Drawing; namespace OctopusClient { - public delegate void OnSelectedIDChanged(string id, string name); + public delegate void OnSelectedIDChanged(string id, string name, string text); public partial class OctopusIDSelector : UserControl { private static Logger logger = LogManager.GetCurrentClassLogger(); @@ -106,40 +106,6 @@ namespace OctopusClient { //selectedRundownIndex = cbRundowns.SelectedIndex; } - private void AddStories(IEnumerable stories) { - foreach (var story in stories) { - string name = story.Name == null ? OctopusAPI.UNNAMED : story.Name; - string label = story.ID; - if (!String.IsNullOrEmpty(story.Format)) - label += String.Format($" [{story.Format}] {story.Name}"); - else - label += String.Format($" {story.Name}"); - TreeNode storyNode = treeOctopus.Nodes.Add(story.ID, label); - storyNode.Tag = story.ID; - if (configuration.DisableStoryCheck) - HideCheckBox(treeOctopus, storyNode); - else { - if (lookupStoryId != null && lookupStoryId.Equals(story.ID)) - storyNode.Checked = true; - } - - MosObject[] mosObjects = story.MosObjects; - if (mosObjects == null) - continue; - foreach (MosObject mosObject in mosObjects) { - TreeNode placeHolderNode = storyNode.Nodes.Add(mosObject.ObjID, String.Format($"{mosObject.ObjID}")); - // TODO wich? - placeHolderNode.Tag = mosObject.ID; - if (configuration.DisablePlaceHolderCheck) - HideCheckBox(treeOctopus, placeHolderNode); - else { - if (lookupPlaceHolderId != null && lookupPlaceHolderId.Equals(mosObject.ID)) - placeHolderNode.Checked = true; - } - } - } - } - private void comboStoryFolder_SelectedValueChanged(object sender, EventArgs e) { StoryFolder storyFolder = cbStoryFolder.SelectedValue as StoryFolder; if (storyFolder == null) @@ -151,7 +117,7 @@ namespace OctopusClient { var stories = client.GetStoryFolderStories(storyFolder.ID); if (stories == null) return; - AddStories(stories); + AddStories(stories, true); //selectedStoryFolderIndex = cbStoryFolder.SelectedIndex; } @@ -187,15 +153,6 @@ namespace OctopusClient { Cursor.Current = Cursors.Default; } - private void InitCheckID(string id, TreeNodeCollection collection) { - foreach (TreeNode actual in collection) { - if (id.Equals(actual.Tag)) { - actual.Checked = true; - break; - } - } - } - public void ClearSelection() { if (selectedNode == null) return; @@ -203,7 +160,7 @@ namespace OctopusClient { selectedNode.Checked = false; treeOctopus.AfterCheck += OnTreeAfterCheck; selectedNode = null; - IDChangedEvent?.Invoke(null, null); + IDChangedEvent?.Invoke(null, null, null); } private void tabControl1_Selected(object sender, TabControlEventArgs e) { @@ -232,6 +189,43 @@ namespace OctopusClient { //this.OnKeyDown(e); } + private void AddStories(IEnumerable stories, bool isFolderView = false) { + foreach (var story in stories) { + string name = story.Name == null ? OctopusAPI.UNNAMED : story.Name; + String ID = isFolderView ? story.ID : story.ParentStoryID; + string label = ID; + if (!String.IsNullOrEmpty(story.Format)) + label += String.Format($" [{story.Format}] {story.Name}"); + else + label += String.Format($" {story.Name}"); + + TreeNode storyNode = treeOctopus.Nodes.Add(ID, label); + storyNode.Tag = ID; + if (configuration.DisableStoryCheck) + HideCheckBox(treeOctopus, storyNode); + else { + if (lookupStoryId != null && lookupStoryId.Equals(story.ID)) + storyNode.Checked = true; + } + + MosObject[] mosObjects = story.MosObjects; + if (mosObjects == null) + continue; + foreach (MosObject mosObject in mosObjects) { + TreeNode placeHolderNode = storyNode.Nodes.Add(mosObject.ObjID, String.Format($"{mosObject.ObjID}")); + placeHolderNode.Tag = mosObject.ID; + if (configuration.DisablePlaceHolderCheck) + HideCheckBox(treeOctopus, placeHolderNode); + else { + if (lookupPlaceHolderId != null && lookupPlaceHolderId.Equals(mosObject.ObjID)) { + placeHolderNode.Checked = true; + storyNode.Expand(); + } + } + } + } + } + private void OnTreeAfterCheck(object sender, TreeViewEventArgs e) { //logger.Debug("Handling {0} {1} {2}", e.Node.Name, e.Node.Text, e.Node.Checked); @@ -258,9 +252,9 @@ namespace OctopusClient { } if (selectedNode.Checked) - IDChangedEvent?.Invoke(selectedNode.Tag as string, selectedNode.Name); + IDChangedEvent?.Invoke(selectedNode.Tag as string, selectedNode.Name, selectedNode.Text); else - IDChangedEvent?.Invoke(null, null); + IDChangedEvent?.Invoke(null, null, null); } public OctopusAPI GetClient() {