From: Bellai Ádám Date: Wed, 27 Sep 2017 13:35:43 +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=911bf557617d460033d58d7efad7599c2289c8f7;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30474 --- diff --git a/client/Maestro/ArchiveMetadata.Designer.cs b/client/Maestro/ArchiveMetadata.Designer.cs new file mode 100644 index 00000000..16e2fda1 --- /dev/null +++ b/client/Maestro/ArchiveMetadata.Designer.cs @@ -0,0 +1,206 @@ +namespace Maestro { + partial class ArchiveMetadata { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label_stuffID = new System.Windows.Forms.Label(); + this.label_stuffTitle = new System.Windows.Forms.Label(); + this.label_stuffDescription = new System.Windows.Forms.Label(); + this.label_mediaID = new System.Windows.Forms.Label(); + this.label_mediaTitle = new System.Windows.Forms.Label(); + this.label_mediaDescription = new System.Windows.Forms.Label(); + this.textBox_stuffID = new System.Windows.Forms.TextBox(); + this.textBox_stuffTitle = new System.Windows.Forms.TextBox(); + this.textBox_stuffDescription = new System.Windows.Forms.TextBox(); + this.textBox_mediaID = new System.Windows.Forms.TextBox(); + this.textBox_mediaTitle = new System.Windows.Forms.TextBox(); + this.textBox_mediaDescription = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.55975F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70.44025F)); + this.tableLayoutPanel1.Controls.Add(this.label_stuffID, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label_stuffDescription, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.label_mediaID, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.label_mediaTitle, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.label_mediaDescription, 0, 5); + this.tableLayoutPanel1.Controls.Add(this.textBox_stuffID, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.textBox_stuffTitle, 1, 1); + this.tableLayoutPanel1.Controls.Add(this.textBox_stuffDescription, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.textBox_mediaID, 1, 3); + this.tableLayoutPanel1.Controls.Add(this.textBox_mediaTitle, 1, 4); + this.tableLayoutPanel1.Controls.Add(this.textBox_mediaDescription, 1, 5); + this.tableLayoutPanel1.Controls.Add(this.label_stuffTitle, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 6; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(318, 330); + this.tableLayoutPanel1.TabIndex = 0; + // + // label_stuffID + // + this.label_stuffID.AutoSize = true; + this.label_stuffID.Dock = System.Windows.Forms.DockStyle.Top; + this.label_stuffID.Location = new System.Drawing.Point(3, 0); + this.label_stuffID.Name = "label_stuffID"; + this.label_stuffID.Size = new System.Drawing.Size(87, 13); + this.label_stuffID.TabIndex = 0; + this.label_stuffID.Text = "Anyag azonosító"; + // + // label_stuffTitle + // + this.label_stuffTitle.AutoSize = true; + this.label_stuffTitle.Location = new System.Drawing.Point(3, 55); + this.label_stuffTitle.Name = "label_stuffTitle"; + this.label_stuffTitle.Size = new System.Drawing.Size(58, 13); + this.label_stuffTitle.TabIndex = 1; + this.label_stuffTitle.Text = "Anyag cím"; + // + // label_stuffDescription + // + this.label_stuffDescription.AutoSize = true; + this.label_stuffDescription.Location = new System.Drawing.Point(3, 110); + this.label_stuffDescription.Name = "label_stuffDescription"; + this.label_stuffDescription.Size = new System.Drawing.Size(66, 13); + this.label_stuffDescription.TabIndex = 2; + this.label_stuffDescription.Text = "Anyag leírás"; + // + // label_mediaID + // + this.label_mediaID.AutoSize = true; + this.label_mediaID.Location = new System.Drawing.Point(3, 165); + this.label_mediaID.Name = "label_mediaID"; + this.label_mediaID.Size = new System.Drawing.Size(86, 13); + this.label_mediaID.TabIndex = 3; + this.label_mediaID.Text = "Média azonosító"; + // + // label_mediaTitle + // + this.label_mediaTitle.AutoSize = true; + this.label_mediaTitle.Location = new System.Drawing.Point(3, 220); + this.label_mediaTitle.Name = "label_mediaTitle"; + this.label_mediaTitle.Size = new System.Drawing.Size(57, 13); + this.label_mediaTitle.TabIndex = 4; + this.label_mediaTitle.Text = "Média cím"; + // + // label_mediaDescription + // + this.label_mediaDescription.AutoSize = true; + this.label_mediaDescription.Location = new System.Drawing.Point(3, 275); + this.label_mediaDescription.Name = "label_mediaDescription"; + this.label_mediaDescription.Size = new System.Drawing.Size(65, 13); + this.label_mediaDescription.TabIndex = 5; + this.label_mediaDescription.Text = "Média leírás"; + // + // textBox_stuffID + // + this.textBox_stuffID.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_stuffID.Location = new System.Drawing.Point(96, 3); + this.textBox_stuffID.Name = "textBox_stuffID"; + this.textBox_stuffID.Size = new System.Drawing.Size(219, 20); + this.textBox_stuffID.TabIndex = 6; + // + // textBox_stuffTitle + // + this.textBox_stuffTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_stuffTitle.Location = new System.Drawing.Point(96, 58); + this.textBox_stuffTitle.Name = "textBox_stuffTitle"; + this.textBox_stuffTitle.Size = new System.Drawing.Size(219, 20); + this.textBox_stuffTitle.TabIndex = 7; + // + // textBox_stuffDescription + // + this.textBox_stuffDescription.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_stuffDescription.Location = new System.Drawing.Point(96, 113); + this.textBox_stuffDescription.Name = "textBox_stuffDescription"; + this.textBox_stuffDescription.Size = new System.Drawing.Size(219, 20); + this.textBox_stuffDescription.TabIndex = 8; + // + // textBox_mediaID + // + this.textBox_mediaID.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_mediaID.Location = new System.Drawing.Point(96, 168); + this.textBox_mediaID.Name = "textBox_mediaID"; + this.textBox_mediaID.Size = new System.Drawing.Size(219, 20); + this.textBox_mediaID.TabIndex = 9; + // + // textBox_mediaTitle + // + this.textBox_mediaTitle.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_mediaTitle.Location = new System.Drawing.Point(96, 223); + this.textBox_mediaTitle.Name = "textBox_mediaTitle"; + this.textBox_mediaTitle.Size = new System.Drawing.Size(219, 20); + this.textBox_mediaTitle.TabIndex = 10; + // + // textBox_mediaDescription + // + this.textBox_mediaDescription.Dock = System.Windows.Forms.DockStyle.Top; + this.textBox_mediaDescription.Location = new System.Drawing.Point(96, 278); + this.textBox_mediaDescription.Name = "textBox_mediaDescription"; + this.textBox_mediaDescription.Size = new System.Drawing.Size(219, 20); + this.textBox_mediaDescription.TabIndex = 11; + // + // ArchiveMetadata + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(318, 330); + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "ArchiveMetadata"; + this.Text = "ArchiveMetadata"; + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + private System.ComponentModel.BackgroundWorker backgroundWorker1; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label_stuffTitle; + private System.Windows.Forms.Label label_stuffID; + private System.Windows.Forms.Label label_stuffDescription; + private System.Windows.Forms.Label label_mediaID; + private System.Windows.Forms.Label label_mediaTitle; + private System.Windows.Forms.Label label_mediaDescription; + private System.Windows.Forms.TextBox textBox_stuffID; + private System.Windows.Forms.TextBox textBox_stuffTitle; + private System.Windows.Forms.TextBox textBox_stuffDescription; + private System.Windows.Forms.TextBox textBox_mediaID; + private System.Windows.Forms.TextBox textBox_mediaTitle; + private System.Windows.Forms.TextBox textBox_mediaDescription; + } +} \ No newline at end of file diff --git a/client/Maestro/ArchiveMetadata.cs b/client/Maestro/ArchiveMetadata.cs new file mode 100644 index 00000000..cdf02682 --- /dev/null +++ b/client/Maestro/ArchiveMetadata.cs @@ -0,0 +1,27 @@ +using System.Windows.Forms; +using Maestro.Metadata; + +namespace Maestro { + public partial class ArchiveMetadata : Form { + + private ArchiveMetadataModel model; + + public ArchiveMetadata(ArchiveMetadataModel model) : this() { + this.model = model; + } + + public ArchiveMetadata() { + InitializeComponent(); + FillTheTextBoxes(); + } + + private void FillTheTextBoxes() { + textBox_stuffID.Text = model.StuffID; + textBox_stuffTitle.Text = model.StuffTitle; + textBox_stuffDescription.Text = model.StuffDescription; + textBox_mediaID.Text = model.MediaID; + textBox_mediaTitle.Text = model.MediaTitle; + textBox_mediaDescription.Text = model.MediaDescription; + } + } +} diff --git a/client/Maestro/ArchiveMetadata.resx b/client/Maestro/ArchiveMetadata.resx new file mode 100644 index 00000000..ac1dbed9 --- /dev/null +++ b/client/Maestro/ArchiveMetadata.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 25 + + \ No newline at end of file diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 839e5c5e..300d80af 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -101,6 +101,12 @@ + + Form + + + ArchiveMetadata.cs + @@ -112,6 +118,7 @@ Form + Component @@ -156,6 +163,9 @@ + + ArchiveMetadata.cs + MaestroForm.cs Designer diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index 1c2301e6..f5b7787f 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -259,6 +259,7 @@ namespace Maestro { this.ctxiModifyArchiveMetadata.Name = "ctxiModifyArchiveMetadata"; this.ctxiModifyArchiveMetadata.Size = new System.Drawing.Size(206, 22); this.ctxiModifyArchiveMetadata.Text = "Modify archive metadata"; + this.ctxiModifyArchiveMetadata.Click += new System.EventHandler(this.ModifyArchiveMetadataClick); // // splitContainer1 // diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 87d15854..33a4b0aa 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using TrafficClient; using System.Collections.Generic; using System.ComponentModel; +using System.Text.RegularExpressions; namespace Maestro { public partial class MaestroForm { @@ -63,6 +64,62 @@ namespace Maestro { }; } + private void ModifyArchiveMetadataClick(object sender, EventArgs e) { + ArchiveMetadata form = null; + IDTypes idType = GetTypeOfSelectedMetadata(); + ArchiveMetadataModel model = new ArchiveMetadataModel(); + if (idType == IDTypes.OctopusID) + FillTheModelFromOctopus(model); + else if (idType == IDTypes.TrafficID) + FillTheModelFromTraffic(model); + //form = new ArchiveMetadata(model); + //form.ShowDialog(); + } + + private void FillTheModelFromTraffic(ArchiveMetadataModel model) { + throw new NotImplementedException(); + } + + private void FillTheModelFromOctopus(ArchiveMetadataModel model) { + string id = selectedMetadata.ID; + OctopusAPI api = octopusIDSelector.GetClient(); + List stories = api.GetStoriesById(id).ToList(); + Story story = stories[0]; + if (story.StoryFolders != null) { + List storyFolders = api.GetStoryFoldersByStoryID(id).ToList(); + //lehet több mappában is a story? + StoryFolder folder = storyFolders[0]; + model.StuffID = folder.ID; + model.StuffTitle = folder.Name; + } else if (story.Rundowns != null) { + List rundowns = api.GetRundownsByStoryID(id).ToList(); + Rundown rundown = rundowns[0]; + model.StuffID = rundown.ID; + model.StuffTitle = rundown.Name; + model.StuffDescription = rundown.Start; + } + model.MediaID = story.ID; + model.MediaTitle = story.Name; + model.MediaDescription = story.Script; + + } + + private IDTypes GetTypeOfSelectedMetadata() { + IDTypes result = IDTypes.None; + if (String.IsNullOrEmpty(selectedMetadata.ID)) + return IDTypes.None; + string pattern = "[A-Z]{1}[0-9]{6}[A-Z]{1}"; + Match match = Regex.Match(selectedMetadata.ID, pattern); + if (match.Success) { + result = IDTypes.TrafficID; + } else { + pattern = "[0-9]{7}"; + match = Regex.Match(selectedMetadata.ID, pattern); + result = match.Success ? IDTypes.OctopusID : IDTypes.None; + } + return result; + } + private void OnDefineSegmentsClick(object sender, EventArgs e) { if (SelectedSource?.FileInfo == null) return; diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 75e33bf7..d3488845 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -141,12 +141,12 @@ namespace Maestro { SetStartingName(checkBox); if (selectedSources == null || selectedSources.Count == 0) { buttonMetadata.Enabled = false; - IsSelectedIDTrafficID(); + IsSelectedFileAnID(); return; } if (selectedSources.Count == 1) { buttonMetadata.Enabled = true; - IsSelectedIDTrafficID(); + IsSelectedFileAnID(); return; } @@ -160,7 +160,7 @@ namespace Maestro { } } buttonMetadata.Enabled = true; - IsSelectedIDTrafficID(); + IsSelectedFileAnID(); } private void SetStartingName(bool checkBox) { @@ -187,6 +187,7 @@ namespace Maestro { } private void SetSelectedSourceFileInfo(SourceInfo selectedSource) { + //todo ha nexio-s akkor null a fileinfo if (selectedSources.Count == 1) { Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, selectedSources[0])); selectedSource.FileInfo = new System.IO.FileInfo(inputUri.LocalPath); diff --git a/client/Maestro/MaestroForm.Target.cs b/client/Maestro/MaestroForm.Target.cs index 703c0640..85b168e7 100644 --- a/client/Maestro/MaestroForm.Target.cs +++ b/client/Maestro/MaestroForm.Target.cs @@ -106,17 +106,16 @@ namespace Maestro { ChangeProcessButtonsState(false); } + ctxiModifyArchiveMetadata.Enabled = selectedMetadata != null; if (Configuration.Player != null) ctxiDefineSegments.Enabled = SelectedSource?.FileInfo != null && Configuration.Player.SegmentEditor && MetadataType.Traffic.Equals(SelectedMetadata?.Kind); - IsSelectedIDTrafficID(); + IsSelectedFileAnID(); } - private void IsSelectedIDTrafficID() { + private void IsSelectedFileAnID() { if (String.IsNullOrEmpty(startingName)) return; - - //kisbetük kellenek? string pattern = "[A-Z]{1}[0-9]{6}[A-Z]{1}"; Match match = Regex.Match(startingName, pattern); if (match.Success) { diff --git a/client/Maestro/MaestroForm.cs b/client/Maestro/MaestroForm.cs index b1fa0d3f..5ad63c9c 100644 --- a/client/Maestro/MaestroForm.cs +++ b/client/Maestro/MaestroForm.cs @@ -170,7 +170,7 @@ namespace Maestro { } private void buttonMetadata_Click(object sender, EventArgs e) { - IsSelectedIDTrafficID(); + IsSelectedFileAnID(); switch (IDType) { case Metadata.IDTypes.TrafficID: SetTrafficIDToMetadataText(); diff --git a/client/Maestro/Metadata/ArchiveMetadata.cs b/client/Maestro/Metadata/ArchiveMetadata.cs new file mode 100644 index 00000000..92227c8e --- /dev/null +++ b/client/Maestro/Metadata/ArchiveMetadata.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Maestro.Metadata { + public class ArchiveMetadataModel { + + //todo rename a Stuffra?? + public string StuffID { get; set; } + public string StuffTitle { get; set; } + public string StuffDescription { get; set; } + public string MediaID { get; set; } + public string MediaTitle { get; set; } + public string MediaDescription { get; set; } + } +} diff --git a/client/OctopusClient/OctopusAPI.cs b/client/OctopusClient/OctopusAPI.cs index 20ce71ff..d4a50db0 100644 --- a/client/OctopusClient/OctopusAPI.cs +++ b/client/OctopusClient/OctopusAPI.cs @@ -7,37 +7,38 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -namespace OctopusClient -{ +namespace OctopusClient { - public class Rundown - { + public class Rundown { public string ID { get; set; } public string Name { get; set; } public string Start { get; set; } - public override String ToString() - { + public override String ToString() { string displayName = string.IsNullOrEmpty(Name) ? OctopusAPI.UNNAMED : Name; string result = ID.Equals("0") ? displayName : String.Format($"{Start} | {displayName} "); return result; } } - public class Story - { + public class Story { public string ID { get; set; } public string Name { get; set; } - public MosObject[] MosObjects{ get; set; } - public override String ToString() - { + public MosObject[] MosObjects { get; set; } + + public string Script { get; set; } + + public StoryFolder[] StoryFolders { get; set; } + + public Rundown[] Rundowns { get; set; } + + public override String ToString() { string displayName = string.IsNullOrEmpty(Name) ? OctopusAPI.UNNAMED : Name; string result = ID.Equals("0") ? displayName : String.Format($"{ID} | {displayName} "); return result; } } - public class MosObject - { + public class MosObject { public string MosID { get; set; } public string ObjID { get; set; } public string ObjectType { get; set; } @@ -46,23 +47,20 @@ namespace OctopusClient public string GlobalID { get; set; } } - public class StoryFolder - { + public class StoryFolder { public string ID { get; set; } public string Name { get; set; } - public override String ToString() - { + public override String ToString() { string displayName = string.IsNullOrEmpty(Name) ? OctopusAPI.UNNAMED : Name; string result = ID.Equals("0") ? displayName : String.Format($"{ID} | {displayName} "); return result; } } - public class OctopusAPI - { + public class OctopusAPI { public const string UNNAMED = ""; private static Logger logger = LogManager.GetCurrentClassLogger(); @@ -70,22 +68,18 @@ namespace OctopusClient private string user; private string pwd; - public OctopusAPI(string address, string user, string pwd, int timeout) - { + public OctopusAPI(string address, string user, string pwd, int timeout) { this.user = user; this.pwd = pwd; - client = new RestClient(address) - { + client = new RestClient(address) { Authenticator = new HttpBasicAuthenticator(user, pwd), Timeout = timeout }; } - public IEnumerable GetRundowns(DateTime scheduledDate) - { + public IEnumerable GetRundowns(DateTime scheduledDate) { IEnumerable result = null; - try - { + try { var request = new RestRequest("rundowns/{scheduledDate}", Method.GET); var dt = scheduledDate.ToUniversalTime().ToString("s", CultureInfo.InvariantCulture); request.AddParameter("scheduledDate", dt, ParameterType.UrlSegment); @@ -94,10 +88,8 @@ namespace OctopusClient return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { - Rundown r = new Rundown - { + result = resultObject.Children().Select(d => { + Rundown r = new Rundown { ID = d["id"].ToString(), Name = d["name"].ToString(), Start = d["scheduledStart"].ToString() @@ -106,18 +98,15 @@ namespace OctopusClient return r; }); } - catch (Exception e) - { + catch (Exception e) { //log e.Message ?? } return result; } - public IEnumerable GetStories(string rundownID) - { + public IEnumerable GetStories(string rundownID) { IEnumerable result = null; - try - { + try { var request = new RestRequest("stories/{rundownID}", Method.GET); request.AddParameter("rundownID", rundownID, ParameterType.UrlSegment); var response = client.Execute(request); @@ -125,19 +114,22 @@ namespace OctopusClient return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { + result = resultObject.Children().Select(d => { List objs = GetMosObjectsFromStory(d); - Story r = new Story - { + Story r = new Story { ID = d["id"].ToString(), Name = d["name"].ToString(), MosObjects = objs.ToArray() }; + if (d["script"] != null) + r.Script = d["script"].ToString(); + if (d["story_folder"] != null) + r.StoryFolders = GetStoryFolderFromStory(d).ToArray(); + if (d["rundown"] != null) + r.Rundowns = GetRundownFromStory(d).ToArray(); logger.Debug($"{r}"); return r; - }).OrderBy(r => - { + }).OrderBy(r => { return r.ID; }); } @@ -145,11 +137,9 @@ namespace OctopusClient return result; } - public IEnumerable GetStoriesByStoryFolderID(string storyFolderID) - { + public IEnumerable GetStoriesByStoryFolderID(string storyFolderID) { IEnumerable result = null; - try - { + try { var request = new RestRequest("storiesByStoryFolderID/{storyFolderID}", Method.GET); request.AddParameter("storyFolderID", storyFolderID, ParameterType.UrlSegment); var response = client.Execute(request); @@ -157,20 +147,23 @@ namespace OctopusClient return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { + result = resultObject.Children().Select(d => { List objs = GetMosObjectsFromStory(d); - Story r = new Story - { + Story r = new Story { ID = d["id"].ToString(), Name = d["name"].ToString(), MosObjects = objs.ToArray() - }; - + }; + if (d["script"] != null) { + r.Script = d["script"].ToString(); + } + if (d["story_folder"] != null) + r.StoryFolders = GetStoryFolderFromStory(d).ToArray(); + if (d["rundown"] != null) + r.Rundowns = GetRundownFromStory(d).ToArray(); logger.Debug($"{r}"); return r; - }).OrderBy(r => - { + }).OrderBy(r => { return r.ID; }); } @@ -178,15 +171,31 @@ namespace OctopusClient return result; } - private List GetMosObjectsFromStory(JToken d) - { + private List GetRundownFromStory(JToken d) { + JToken[] array = d["rundown"].ToArray(); + List objs = new List(); + foreach (JToken token in array) { + Rundown folder = new Rundown() { ID = token["id"].ToString() }; + objs.Add(folder); + } + return objs; + } + + private List GetStoryFolderFromStory(JToken d) { + JToken[] array = d["story_folder"].ToArray(); + List objs = new List(); + foreach (JToken token in array) { + StoryFolder folder = new StoryFolder() { ID = token["id"].ToString() }; + objs.Add(folder); + } + return objs; + } + + private List GetMosObjectsFromStory(JToken d) { JToken[] array = d["mosObjects"].ToArray(); List objs = new List(); - foreach (JToken token in array) - { - Console.WriteLine(token["id"]); - MosObject mosObject = new MosObject() - { + foreach (JToken token in array) { + MosObject mosObject = new MosObject() { GlobalID = token["globalId"].ToString(), ID = token["id"].ToString(), Modified = token["modified"].ToString(), @@ -199,21 +208,17 @@ namespace OctopusClient return objs; } - public IEnumerable getStoryFolders() - { + public IEnumerable getStoryFolders() { IEnumerable result = null; - try - { + try { var request = new RestRequest("storyfolders", Method.GET); var response = client.Execute(request); if (response.ContentLength == 0) return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { - StoryFolder r = new StoryFolder - { + result = resultObject.Children().Select(d => { + StoryFolder r = new StoryFolder { ID = d["id"].ToString(), Name = d["name"].ToString() }; @@ -225,24 +230,26 @@ namespace OctopusClient return result; } - public IEnumerable GetStories() - { + public IEnumerable GetStories() { IEnumerable result = null; - try - { + try { var request = new RestRequest("stories", Method.GET); var response = client.Execute(request); if (response.ContentLength == 0) return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { - Story r = new Story - { + result = resultObject.Children().Select(d => { + Story r = new Story { ID = d["id"].ToString(), Name = d["name"].ToString() }; + if (d["script"] != null) + r.Script = d["script"].ToString(); + if (d["story_folder"] != null) + r.StoryFolders = GetStoryFolderFromStory(d).ToArray(); + if (d["rundown"] != null) + r.Rundowns = GetRundownFromStory(d).ToArray(); logger.Debug($"{r}"); return r; }); @@ -251,11 +258,9 @@ namespace OctopusClient return result; } - public IEnumerable GetStoriesById(String id) - { + public IEnumerable GetStoriesById(String id) { IEnumerable result = null; - try - { + try { var request = new RestRequest("getStoriesByIDRegex/{id}", Method.GET); request.AddParameter("id", id, ParameterType.UrlSegment); var response = client.Execute(request); @@ -263,13 +268,17 @@ namespace OctopusClient return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => - { - Story r = new Story - { + result = resultObject.Children().Select(d => { + Story r = new Story { ID = d["id"].ToString(), Name = String.IsNullOrEmpty(d["name"].ToString()) ? OctopusAPI.UNNAMED : d["name"].ToString() }; + if (d["script"] != null) + r.Script = d["script"].ToString(); + if (d["story_folder"] != null) + r.StoryFolders = GetStoryFolderFromStory(d).ToArray(); + if (d["rundown"] != null) + r.Rundowns = GetRundownFromStory(d).ToArray(); logger.Debug($"{r}"); return r; }); @@ -278,6 +287,56 @@ namespace OctopusClient return result; } + public IEnumerable GetStoryFoldersByStoryID(String id) { + IEnumerable result = null; + try { + var request = new RestRequest("getStoryFolders/{id}", Method.GET); + request.AddParameter("id", id, ParameterType.UrlSegment); + var response = client.Execute(request); + if (response.ContentLength == 0) + return null; + JArray resultObject = JArray.Parse(response.Content); + + result = resultObject.Children().Select(d => { + StoryFolder r = new StoryFolder { + ID = d["id"].ToString(), + Name = String.IsNullOrEmpty(d["name"].ToString()) ? OctopusAPI.UNNAMED : d["name"].ToString() + }; + + logger.Debug($"{r}"); + return r; + }); + } + catch (Exception e) { } + return result; + } + + public IEnumerable GetRundownsByStoryID(String id) { + IEnumerable result = null; + try { + var request = new RestRequest("getRundownByStoryID/{id}", Method.GET); + request.AddParameter("id", id, ParameterType.UrlSegment); + var response = client.Execute(request); + if (response.ContentLength == 0) + return null; + JArray resultObject = JArray.Parse(response.Content); + + result = resultObject.Children().Select(d => { + Rundown r = new Rundown { + ID = d["id"].ToString(), + Name = String.IsNullOrEmpty(d["name"].ToString()) ? OctopusAPI.UNNAMED : d["name"].ToString(), + Start = d["scheduledStart"].ToString() + }; + + logger.Debug($"{r}"); + return r; + }); + } + catch (Exception e) { } + return result; + } + + public IEnumerable GetMosObjectsByID(String id) { IEnumerable result = null; try { diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 5c74b9f7..82def78a 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -27,15 +27,14 @@ namespace TrafficClient { copiaCheckBox.Text = Resources.HIANYZO_KOPIA; dataGridView1.AutoGenerateColumns = false; - // dataGridView1.Columns.AddRange(new DataGridViewCheckBoxColumn()); dataGridView1.Columns.AddRange( new DataGridViewColumn[] { new DataGridViewCheckBoxColumn(){ - AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill, + AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, DataPropertyName = "Selected" }, new DataGridViewTextBoxColumn() { - AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader, + AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells, DataPropertyName = "MediaID", HeaderText = Resources.TRAFFIC_ID }, diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java index 16793baf..857e8a27 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java @@ -181,4 +181,39 @@ public class OctopusRESTService { logger.trace("Exit"); return result; } + + @GET + @Path("/getStoryFolders/{id}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public Response getStoryFoldersByStoryID(@PathParam("id") String id) { + logger.trace("Entry"); + Response result = null; + try { + List stories = octopusService.getStoryFolders(Long.parseLong(id)); + result = Response.ok(stories).build(); + } catch (Exception e) { + result = createErrorResponse(e); + } + logger.trace("Exit"); + return result; + } + + @GET + @Path("/getRundownByStoryID/{id}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public Response getRundownByStoryID(@PathParam("id") String id) { + logger.trace("Entry"); + Response result = null; + try { + List stories = octopusService.getRundownByStoryID(Long.parseLong(id)); + result = Response.ok(stories).build(); + } catch (Exception e) { + result = createErrorResponse(e); + } + logger.trace("Exit"); + return result; + } + } \ No newline at end of file