Merge pull request #41 from nb-tergen/master

Added functionality to export update schedule for all projects, allow export instances by instance type, add organisation filter for certain exports,enable task bar icon
This commit is contained in:
Tomek Melissa 2019-12-10 01:14:13 +01:00 коммит произвёл GitHub
Родитель 0fdeb59a5b d25bbf955e
Коммит 969bcf8240
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 249 добавлений и 32 удалений

Просмотреть файл

@ -28,6 +28,9 @@
<setting name="autorefresh" serializeAs="String">
<value>False</value>
</setting>
<setting name="projOrgExcl" serializeAs="String">
<value />
</setting>
</LCS.Properties.Settings>
</userSettings>
<runtime>

49
2LCS/Forms/MainForm.Designer.cs сгенерированный
Просмотреть файл

@ -92,6 +92,10 @@
this.exportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportProjectDataToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.exportListOfInstancesForAllProjectsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.allInstancesExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cloudHostedInstancesExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mSHostedInstancesExportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportUpdateScheduleForAllProjectsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.logoutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.cookieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.parametersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -712,7 +716,8 @@
//
this.exportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exportProjectDataToolStripMenuItem1,
this.exportListOfInstancesForAllProjectsToolStripMenuItem});
this.exportListOfInstancesForAllProjectsToolStripMenuItem,
this.exportUpdateScheduleForAllProjectsToolStripMenuItem});
this.exportToolStripMenuItem.Enabled = false;
this.exportToolStripMenuItem.Name = "exportToolStripMenuItem";
this.exportToolStripMenuItem.Size = new System.Drawing.Size(90, 34);
@ -721,16 +726,47 @@
// exportProjectDataToolStripMenuItem1
//
this.exportProjectDataToolStripMenuItem1.Name = "exportProjectDataToolStripMenuItem1";
this.exportProjectDataToolStripMenuItem1.Size = new System.Drawing.Size(477, 40);
this.exportProjectDataToolStripMenuItem1.Size = new System.Drawing.Size(487, 40);
this.exportProjectDataToolStripMenuItem1.Text = "Export project data";
this.exportProjectDataToolStripMenuItem1.Click += new System.EventHandler(this.ExportProjectDataToolStripMenuItem_Click);
//
// exportListOfInstancesForAllProjectsToolStripMenuItem
//
this.exportListOfInstancesForAllProjectsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.allInstancesExportToolStripMenuItem,
this.cloudHostedInstancesExportToolStripMenuItem,
this.mSHostedInstancesExportToolStripMenuItem});
this.exportListOfInstancesForAllProjectsToolStripMenuItem.Name = "exportListOfInstancesForAllProjectsToolStripMenuItem";
this.exportListOfInstancesForAllProjectsToolStripMenuItem.Size = new System.Drawing.Size(477, 40);
this.exportListOfInstancesForAllProjectsToolStripMenuItem.Size = new System.Drawing.Size(487, 40);
this.exportListOfInstancesForAllProjectsToolStripMenuItem.Text = "Export list of instances for all projects";
this.exportListOfInstancesForAllProjectsToolStripMenuItem.Click += new System.EventHandler(this.ExportListOfInstancesForAllProjectsToolStripMenuItem_Click);
//
// allInstancesExportToolStripMenuItem
//
this.allInstancesExportToolStripMenuItem.Name = "allInstancesExportToolStripMenuItem";
this.allInstancesExportToolStripMenuItem.Size = new System.Drawing.Size(315, 40);
this.allInstancesExportToolStripMenuItem.Text = "All instances";
this.allInstancesExportToolStripMenuItem.Click += new System.EventHandler(this.allInstancesExportToolStripMenuItem_Click);
//
// cloudHostedInstancesExportToolStripMenuItem
//
this.cloudHostedInstancesExportToolStripMenuItem.Name = "cloudHostedInstancesExportToolStripMenuItem";
this.cloudHostedInstancesExportToolStripMenuItem.Size = new System.Drawing.Size(315, 40);
this.cloudHostedInstancesExportToolStripMenuItem.Text = "Cloud hosted";
this.cloudHostedInstancesExportToolStripMenuItem.Click += new System.EventHandler(this.cloudHostedInstancesExportToolStripMenuItem_Click);
//
// mSHostedInstancesExportToolStripMenuItem
//
this.mSHostedInstancesExportToolStripMenuItem.Name = "mSHostedInstancesExportToolStripMenuItem";
this.mSHostedInstancesExportToolStripMenuItem.Size = new System.Drawing.Size(315, 40);
this.mSHostedInstancesExportToolStripMenuItem.Text = "MS hosted";
this.mSHostedInstancesExportToolStripMenuItem.Click += new System.EventHandler(this.mSHostedInstancesExportToolStripMenuItem_Click);
//
// exportUpdateScheduleForAllProjectsToolStripMenuItem
//
this.exportUpdateScheduleForAllProjectsToolStripMenuItem.Name = "exportUpdateScheduleForAllProjectsToolStripMenuItem";
this.exportUpdateScheduleForAllProjectsToolStripMenuItem.Size = new System.Drawing.Size(487, 40);
this.exportUpdateScheduleForAllProjectsToolStripMenuItem.Text = "Export update schedule for all projects";
this.exportUpdateScheduleForAllProjectsToolStripMenuItem.Click += new System.EventHandler(this.exportUpdateScheduleForAllProjectsToolStripMenuItem_Click);
//
// logoutToolStripMenuItem
//
@ -1352,7 +1388,6 @@
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MinimumSize = new System.Drawing.Size(725, 410);
this.Name = "MainForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "2LCS - Lifecycle Services companion app";
this.Load += new System.EventHandler(this.MainForm_Load);
@ -1506,6 +1541,10 @@
private System.Windows.Forms.DataGridViewTextBoxColumn saasTopologyType;
private System.Windows.Forms.DataGridViewTextBoxColumn saasTopologyVersion;
private System.Windows.Forms.ToolStripMenuItem saasUpcomingUpdatesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exportUpdateScheduleForAllProjectsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem allInstancesExportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem cloudHostedInstancesExportToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mSHostedInstancesExportToolStripMenuItem;
}
}

Просмотреть файл

@ -703,11 +703,17 @@ namespace LCS.Forms
}
Cursor = Cursors.Default;
}
private void ExportListOfInstancesForAllProjectsToolStripMenuItem_Click(object sender, EventArgs e)
enum LCSEnvironments
{
notifyIcon.BalloonTipText = $"Exporting list of instances for all LCS projects. Please wait...";
notifyIcon.BalloonTipTitle = "Exporting list of instances";
ALL = 0,
CHE = 1,
SAAS = 2
}
private void ExportListOfInstancesForAllProjects(LCSEnvironments _LCSEnvironments)
{
notifyIcon.BalloonTipText = $"Exporting list of {_LCSEnvironments} instances for all LCS projects. Please wait...";
notifyIcon.BalloonTipTitle = $"Exporting list of {_LCSEnvironments} instances";
notifyIcon.ShowBalloonTip(2000); //This setting might be overruled by the OS
@ -716,6 +722,8 @@ namespace LCS.Forms
var exportedInstances = new List<ExportedInstance>();
Projects = _httpClientHelper.GetAllProjects();
Projects = excludeProjectsForOrganisation(Projects); //remove all internal projects for export.
foreach (var _project in Projects)
{
if (_project.RequestPending == true) continue;
@ -725,6 +733,7 @@ namespace LCS.Forms
RefreshChe();
RefreshSaas();
if (_LCSEnvironments == LCSEnvironments.ALL || _LCSEnvironments == LCSEnvironments.SAAS)
if (_saasInstancesList != null && _saasInstancesList.Count > 0)
{
foreach (var _instance in _saasInstancesList)
@ -751,6 +760,7 @@ namespace LCS.Forms
}
}
if (_LCSEnvironments == LCSEnvironments.ALL || _LCSEnvironments == LCSEnvironments.CHE)
if (_cheInstancesList != null && _cheInstancesList.Count > 0)
{
foreach (var _instance in _cheInstancesList)
@ -779,7 +789,7 @@ namespace LCS.Forms
}
SaveFileDialog savefile = new SaveFileDialog
{
FileName = "D365FO instances - 2LCS generated.csv",
FileName = $"D365FO {_LCSEnvironments} instances - 2LCS generated.csv",
Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"
};
@ -2079,7 +2089,102 @@ namespace LCS.Forms
Cursor = Cursors.Default;
}
private List<LcsProject> excludeProjectsForOrganisation(List<LcsProject> _projects)
{
string exclOrg = Properties.Settings.Default.projOrgExcl;
if (string.IsNullOrEmpty(exclOrg))
{
return _projects;
}
else
{
List<LcsProject> projectsLocal = new List<LcsProject>();
foreach (var _project in _projects)
{
if (!_project.OrganizationName.Contains(Properties.Settings.Default.projOrgExcl))
projectsLocal.Add(_project);
}
return projectsLocal;
}
}
private void exportUpdateScheduleForAllProjectsToolStripMenuItem_Click(object sender, EventArgs e)
{
notifyIcon.BalloonTipText = $"Exporting updates for all LCS projects. Please wait...";
notifyIcon.BalloonTipTitle = "Exporting updates list";
notifyIcon.ShowBalloonTip(2000); //This setting might be overruled by the OS
Cursor = Cursors.WaitCursor;
var previousProject = _selectedProject;
var exportedUpdates = new List<Datum>();
Projects = _httpClientHelper.GetAllProjects();
Projects = excludeProjectsForOrganisation(Projects); //remove all internal projects for export.
foreach (var _project in Projects)
{
if (_project.RequestPending == true) continue;
_selectedProject = _project;
_httpClientHelper.ChangeLcsProjectId(_project.Id.ToString());
SetLcsProjectText();
List<Datum> calendar = _httpClientHelper.GetUpcomingCalendars();
if (calendar != null || calendar.Count != 0)
{
foreach (var _updateRow in calendar)
{
exportedUpdates.Add(_updateRow);
}
}
}
Cursor = Cursors.Default;
SaveFileDialog savefile = new SaveFileDialog
{
FileName = "D365FO updates - 2LCS generated.csv",
Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"
};
if (savefile.ShowDialog() == DialogResult.OK)
{
try
{
using (StreamWriter sw = new StreamWriter(savefile.FileName, false, Encoding.Unicode))
{
var csv = new CsvWriter(sw);
csv.WriteRecords(exportedUpdates);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
_selectedProject = previousProject;
_httpClientHelper.ChangeLcsProjectId(_selectedProject.Id.ToString());
SetLcsProjectText();
RefreshChe(false);
RefreshSaas(false);
}
private void allInstancesExportToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportListOfInstancesForAllProjects(LCSEnvironments.ALL);
}
private void cloudHostedInstancesExportToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportListOfInstancesForAllProjects(LCSEnvironments.CHE);
}
private void mSHostedInstancesExportToolStripMenuItem_Click(object sender, EventArgs e)
{
ExportListOfInstancesForAllProjects(LCSEnvironments.SAAS);
}
}
public enum HotfixesType

72
2LCS/Forms/Parameters.Designer.cs сгенерированный
Просмотреть файл

@ -31,47 +31,95 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Parameters));
this.AutoRefreshCheckBox = new System.Windows.Forms.CheckBox();
this.closeButton = new System.Windows.Forms.Button();
this.groupBoxExportConfig = new System.Windows.Forms.GroupBox();
this.labelOrgNameExcl = new System.Windows.Forms.Label();
this.textBoxProjectExcl = new System.Windows.Forms.TextBox();
this.groupBoxUIConfig = new System.Windows.Forms.GroupBox();
this.groupBoxExportConfig.SuspendLayout();
this.groupBoxUIConfig.SuspendLayout();
this.SuspendLayout();
//
// AutoRefreshCheckBox
//
this.AutoRefreshCheckBox.AutoSize = true;
this.AutoRefreshCheckBox.Location = new System.Drawing.Point(12, 12);
this.AutoRefreshCheckBox.Location = new System.Drawing.Point(7, 29);
this.AutoRefreshCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.AutoRefreshCheckBox.Name = "AutoRefreshCheckBox";
this.AutoRefreshCheckBox.Size = new System.Drawing.Size(109, 21);
this.AutoRefreshCheckBox.Size = new System.Drawing.Size(146, 29);
this.AutoRefreshCheckBox.TabIndex = 0;
this.AutoRefreshCheckBox.Text = "Auto-refresh";
this.AutoRefreshCheckBox.UseVisualStyleBackColor = true;
this.AutoRefreshCheckBox.CheckedChanged += new System.EventHandler(this.AutoRefreshCheckBox_CheckedChanged);
//
// closeButton
//
this.closeButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.closeButton.Location = new System.Drawing.Point(28, 171);
this.closeButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.closeButton.Location = new System.Drawing.Point(431, 224);
this.closeButton.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(162, 26);
this.closeButton.Size = new System.Drawing.Size(223, 39);
this.closeButton.TabIndex = 4;
this.closeButton.Text = "Close";
this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.OkButton_Click);
//
// groupBoxExportConfig
//
this.groupBoxExportConfig.Controls.Add(this.labelOrgNameExcl);
this.groupBoxExportConfig.Controls.Add(this.textBoxProjectExcl);
this.groupBoxExportConfig.Location = new System.Drawing.Point(16, 110);
this.groupBoxExportConfig.Name = "groupBoxExportConfig";
this.groupBoxExportConfig.Size = new System.Drawing.Size(637, 85);
this.groupBoxExportConfig.TabIndex = 5;
this.groupBoxExportConfig.TabStop = false;
this.groupBoxExportConfig.Text = "Export instances/updates";
//
// labelOrgNameExcl
//
this.labelOrgNameExcl.AutoSize = true;
this.labelOrgNameExcl.Location = new System.Drawing.Point(6, 38);
this.labelOrgNameExcl.Name = "labelOrgNameExcl";
this.labelOrgNameExcl.Size = new System.Drawing.Size(293, 25);
this.labelOrgNameExcl.TabIndex = 1;
this.labelOrgNameExcl.Text = "Exclude projects for organisation";
//
// textBoxProjectExcl
//
this.textBoxProjectExcl.Location = new System.Drawing.Point(318, 38);
this.textBoxProjectExcl.Name = "textBoxProjectExcl";
this.textBoxProjectExcl.Size = new System.Drawing.Size(307, 29);
this.textBoxProjectExcl.TabIndex = 0;
//
// groupBoxUIConfig
//
this.groupBoxUIConfig.Controls.Add(this.AutoRefreshCheckBox);
this.groupBoxUIConfig.Location = new System.Drawing.Point(16, 12);
this.groupBoxUIConfig.Name = "groupBoxUIConfig";
this.groupBoxUIConfig.Size = new System.Drawing.Size(637, 72);
this.groupBoxUIConfig.TabIndex = 6;
this.groupBoxUIConfig.TabStop = false;
this.groupBoxUIConfig.Text = "UI";
//
// Parameters
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(375, 206);
this.ClientSize = new System.Drawing.Size(667, 275);
this.Controls.Add(this.groupBoxUIConfig);
this.Controls.Add(this.groupBoxExportConfig);
this.Controls.Add(this.closeButton);
this.Controls.Add(this.AutoRefreshCheckBox);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MinimizeBox = false;
this.Name = "Parameters";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Parameters";
this.Load += new System.EventHandler(this.Parameters_Load);
this.groupBoxExportConfig.ResumeLayout(false);
this.groupBoxExportConfig.PerformLayout();
this.groupBoxUIConfig.ResumeLayout(false);
this.groupBoxUIConfig.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -79,5 +127,9 @@
private System.Windows.Forms.CheckBox AutoRefreshCheckBox;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.GroupBox groupBoxExportConfig;
private System.Windows.Forms.Label labelOrgNameExcl;
private System.Windows.Forms.TextBox textBoxProjectExcl;
private System.Windows.Forms.GroupBox groupBoxUIConfig;
}
}

Просмотреть файл

@ -15,12 +15,6 @@ namespace LCS.Forms
public bool Autorefresh { get; private set; }
public bool Cancelled { get; private set; }
private void AutoRefreshCheckBox_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.autorefresh = AutoRefreshCheckBox.Checked;
Properties.Settings.Default.Save();
}
private void CancelButton_Click(object sender, EventArgs e)
{
Close();
@ -28,12 +22,21 @@ namespace LCS.Forms
private void OkButton_Click(object sender, EventArgs e)
{
setParameters();
Close();
}
private void Parameters_Load(object sender, EventArgs e)
{
AutoRefreshCheckBox.Checked = Properties.Settings.Default.autorefresh;
textBoxProjectExcl.Text = Properties.Settings.Default.projOrgExcl;
}
private void setParameters()
{
Properties.Settings.Default.autorefresh = AutoRefreshCheckBox.Checked;
Properties.Settings.Default.projOrgExcl = textBoxProjectExcl.Text;
Properties.Settings.Default.Save();
}
}
}

22
2LCS/Properties/Settings.Designer.cs сгенерированный
Просмотреть файл

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime:4.0.30319.42000
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace LCS.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -94,5 +94,17 @@ namespace LCS.Properties {
this["autorefresh"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string projOrgExcl {
get {
return ((string)(this["projOrgExcl"]));
}
set {
this["projOrgExcl"] = value;
}
}
}
}

Просмотреть файл

@ -20,5 +20,8 @@
<Setting Name="autorefresh" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="projOrgExcl" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>