diff --git a/.semver.txt b/.semver.txt
index 9d25b39..2338f84 100644
--- a/.semver.txt
+++ b/.semver.txt
@@ -1 +1 @@
-1.0.89
+1.0.90
diff --git a/src/JiraTimeBot/App.config b/src/JiraTimeBot/App.config
index c107c34..79dcf68 100644
--- a/src/JiraTimeBot/App.config
+++ b/src/JiraTimeBot/App.config
@@ -1,26 +1,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/JiraTimeBot/JiraIntegration/Authentificators/JSessionAuthenticator.cs b/src/JiraTimeBot/JiraIntegration/Authentificators/JSessionAuthenticator.cs
new file mode 100644
index 0000000..ed91dc0
--- /dev/null
+++ b/src/JiraTimeBot/JiraIntegration/Authentificators/JSessionAuthenticator.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using RestSharp;
+using RestSharp.Authenticators;
+
+namespace JiraTimeBot.JiraIntegration.Authentificators
+{
+ public class JSessionAuthenticator : AuthenticatorBase
+ {
+ public JSessionAuthenticator(string jSessionId) : base(jSessionId)
+ {
+
+ }
+
+ protected override Parameter GetAuthenticationParameter(string token)
+ => new Parameter("JSESSIONID", token, ParameterType.Cookie);
+ }
+}
diff --git a/src/JiraTimeBot/JiraIntegration/IJiraApi.cs b/src/JiraTimeBot/JiraIntegration/IJiraApi.cs
new file mode 100644
index 0000000..98e8465
--- /dev/null
+++ b/src/JiraTimeBot/JiraIntegration/IJiraApi.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using Atlassian.Jira;
+using JiraTimeBot.Configuration;
+using JiraTimeBot.TaskTime.Objects;
+
+namespace JiraTimeBot.JiraIntegration
+{
+ public interface IJiraApi
+ {
+ List GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
+ string GetTaskName(string branch, Settings settings);
+ List GetWorkloggedIssuesByDate(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
+ void SetTodayWorklog(List taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default);
+ List GetManuallyWorklogged(List taskTimeItems, Settings settings, DateTime? date, CancellationToken cancellationToken = default);
+ }
+}
\ No newline at end of file
diff --git a/src/JiraTimeBot/JiraIntegration/JiraApi.cs b/src/JiraTimeBot/JiraIntegration/JiraApi.cs
index 355993f..e820c28 100644
--- a/src/JiraTimeBot/JiraIntegration/JiraApi.cs
+++ b/src/JiraTimeBot/JiraIntegration/JiraApi.cs
@@ -6,18 +6,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using JiraTimeBot.JiraIntegration.Authentificators;
+using RestSharp.Authenticators;
namespace JiraTimeBot.JiraIntegration
{
- public interface IJiraApi
- {
- List GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
- string GetTaskName(string branch, Settings settings);
- List GetWorkloggedIssuesByDate(Settings settings, DateTime? date = null, CancellationToken cancellationToken = default);
- void SetTodayWorklog(List taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default);
- List GetManuallyWorklogged(List taskTimeItems, Settings settings, DateTime? date, CancellationToken cancellationToken = default);
- }
-
public class JiraApi : IJiraApi
{
private readonly ILog _log;
@@ -31,9 +24,9 @@ namespace JiraTimeBot.JiraIntegration
public string GetTaskName(string branch, Settings settings)
{
- var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
try
{
+ var jira = GetClient(settings);
var issue = jira.Issues.Queryable.FirstOrDefault(f => f.Key == branch);
return issue?.Summary;
}
@@ -45,7 +38,7 @@ namespace JiraTimeBot.JiraIntegration
public List GetIssuesByJQL(string jql, Settings settings, DateTime? date = null, CancellationToken cancellationToken = default)
{
- var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
+ var jira = GetClient(settings);
date = date.GetValueOrDefault(DateTime.Now.Date);
var userName = settings.JiraUserName;
@@ -127,8 +120,8 @@ namespace JiraTimeBot.JiraIntegration
public void SetTodayWorklog(List taskTimeItems, Settings settings, DateTime? date = null, bool dummy = false, bool addCommentsToWorklog = false, CancellationToken cancellationToken = default)
{
date = date.GetValueOrDefault(DateTime.Now.Date).Date;
- var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
-
+ var jira = GetClient(settings);
+
if (settings.RemoveManuallyAddedWorklogs)
{
//Удаляем добавленные вручную пользователем данные.
@@ -219,5 +212,15 @@ namespace JiraTimeBot.JiraIntegration
}
}
}
+
+ public Jira GetClient(Settings settings)
+ {
+ var jira = Jira.CreateRestClient(settings.JiraUrl, settings.JiraUserName, settings.JiraPassword);
+ if (settings.JiraPassword.Length == 32)
+ {
+ jira.RestClient.RestSharpClient.Authenticator = new JSessionAuthenticator(settings.JiraPassword);
+ }
+ return jira;
+ }
}
}
diff --git a/src/JiraTimeBot/JiraTimeBot.csproj b/src/JiraTimeBot/JiraTimeBot.csproj
index e7abfbf..19bdffa 100644
--- a/src/JiraTimeBot/JiraTimeBot.csproj
+++ b/src/JiraTimeBot/JiraTimeBot.csproj
@@ -1,218 +1,234 @@
-
-
-
-
-
- Debug
- AnyCPU
- {F3B89316-C38C-4CE6-9D88-0B1373CFBA1A}
- WinExe
- JiraTimeBot
- JiraTimeBot
- v4.6.1
- 512
- false
-
-
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- 7.1
- false
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- app.ico
-
-
- JiraTimeBot.Program
-
-
-
- ..\packages\Atlassian.SDK.12.1.1\lib\net452\Atlassian.Jira.dll
-
-
- ..\packages\Autofac.5.1.2\lib\net461\Autofac.dll
-
-
- ..\packages\Autofac.Extras.AggregateService.5.0.0\lib\netstandard2.0\Autofac.Extras.AggregateService.dll
-
-
- ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll
-
-
- ..\packages\LibGit2Sharp.0.26.2\lib\net46\LibGit2Sharp.dll
-
-
- ..\packages\Mercurial.Net.1.1.1.607\lib\net35-Client\Mercurial.Net.dll
-
-
- ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
-
-
- ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\RestSharp.106.10.1\lib\net452\RestSharp.dll
-
-
-
-
-
-
-
-
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
-
-
-
-
-
- ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- frmMain.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
- Form
-
-
- frmSettings.cs
-
-
-
-
-
-
-
-
-
-
- frmMain.cs
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
- True
- Resources.resx
- True
-
-
- frmSettings.cs
-
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
- True
- Settings.settings
- True
-
-
-
-
-
-
-
-
-
-
- False
- Microsoft .NET Framework 4.6.1 %28x86 and x64%29
- true
-
-
- False
- .NET Framework 3.5 SP1
- false
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
+
+
+
+
+
+ Debug
+ AnyCPU
+ {F3B89316-C38C-4CE6-9D88-0B1373CFBA1A}
+ WinExe
+ JiraTimeBot
+ JiraTimeBot
+ v4.6.1
+ 512
+ false
+
+
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ 7.1
+ false
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ app.ico
+
+
+ JiraTimeBot.Program
+
+
+
+ ..\packages\Atlassian.SDK.12.4.0\lib\net452\Atlassian.Jira.dll
+
+
+ ..\packages\Autofac.6.2.0\lib\netstandard2.0\Autofac.dll
+
+
+ ..\packages\Autofac.Extras.AggregateService.6.0.0\lib\netstandard2.0\Autofac.Extras.AggregateService.dll
+
+
+ ..\packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll
+
+
+ ..\packages\LibGit2Sharp.0.26.2\lib\net46\LibGit2Sharp.dll
+
+
+ ..\packages\Mercurial.Net.1.1.1.607\lib\net35-Client\Mercurial.Net.dll
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ ..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll
+
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+
+
+
+ ..\packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll
+
+
+
+
+
+ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll
+
+
+
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ frmMain.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ frmSettings.cs
+
+
+
+
+
+
+
+
+
+
+ frmMain.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+ True
+
+
+ frmSettings.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+
+
+
+ False
+ Microsoft .NET Framework 4.6.1 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
\ No newline at end of file
diff --git a/src/JiraTimeBot/Properties/AssemblyInfo.cs b/src/JiraTimeBot/Properties/AssemblyInfo.cs
index 4942fd0..ac92c4d 100644
--- a/src/JiraTimeBot/Properties/AssemblyInfo.cs
+++ b/src/JiraTimeBot/Properties/AssemblyInfo.cs
@@ -1,31 +1,31 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("JiraTimeBot")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("JiraTimeBot")]
-[assembly: AssemblyCopyright("Copyright © 2020")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// 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.89")]
-[assembly: AssemblyFileVersion("1.0.89")]
-[assembly: AssemblyInformationalVersion("1.0.89")]
+using System.Reflection;
+using System.Runtime.InteropServices;
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("JiraTimeBot")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("JiraTimeBot")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f3b89316-c38c-4ce6-9d88-0b1373cfba1a")]
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// 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.90")]
+[assembly: AssemblyFileVersion("1.0.90")]
+[assembly: AssemblyInformationalVersion("1.0.90")]
diff --git a/src/JiraTimeBot/packages.config b/src/JiraTimeBot/packages.config
index 92730d2..0f59953 100644
--- a/src/JiraTimeBot/packages.config
+++ b/src/JiraTimeBot/packages.config
@@ -1,15 +1,19 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file