Еще рефакторинга
This commit is contained in:
@@ -6,11 +6,11 @@ namespace JiraTimeBotForm.Configuration
|
||||
{
|
||||
public class PasswordEncryptionClass
|
||||
{
|
||||
private byte[] GetEntropy(string EntropyString)
|
||||
private byte[] GetEntropy(string entropyString)
|
||||
{
|
||||
|
||||
MD5 md5 = MD5.Create();
|
||||
return md5.ComputeHash(Encoding.UTF8.GetBytes(EntropyString));
|
||||
return md5.ComputeHash(Encoding.UTF8.GetBytes(entropyString));
|
||||
}
|
||||
|
||||
public string Encrypt(string username, string password, string address)
|
||||
|
||||
@@ -32,11 +32,13 @@ namespace JiraTimeBotForm.DI
|
||||
_builder.RegisterType<MeetingProcessor>().AsSelf().As<ITasksProcessor>();
|
||||
_builder.RegisterAggregateService<ITasksProcessors>();
|
||||
|
||||
_builder.Register(c => new JiraApi(c.Resolve<ILog>())).AsSelf().AsImplementedInterfaces();
|
||||
_builder.RegisterType<JiraDescriptionSource>().AsSelf().As<IJiraDescriptionSource>();
|
||||
_builder.RegisterType<JiraApi>().AsSelf().AsImplementedInterfaces();
|
||||
|
||||
_builder.Register(c => new Job(c.Resolve<IMercurialLog>(), c.Resolve<ITaskTimeDiscoverer>(), c.Resolve<ILog>())).AsSelf();
|
||||
|
||||
return _builder.Build();
|
||||
|
||||
var container = _builder.Build();
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration
|
||||
{
|
||||
public interface IJiraDescriptionSource
|
||||
{
|
||||
string GetDescription(TaskTimeItem item, bool addCommentsToWorklog);
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,12 @@ namespace JiraTimeBotForm.JiraIntegration
|
||||
public class JiraApi
|
||||
{
|
||||
private readonly ILog _log;
|
||||
private readonly IJiraDescriptionSource _descriptionSource;
|
||||
|
||||
private readonly List<string> _dummyComments = new List<string>
|
||||
{
|
||||
"Написание кода", "написание кода", "программирование", "реализация задачи", "кодинг", "код + тесты",
|
||||
"кодинг", "написание кода и тестов"
|
||||
};
|
||||
|
||||
public JiraApi(ILog log = null)
|
||||
public JiraApi(ILog log, IJiraDescriptionSource descriptionSource)
|
||||
{
|
||||
_log = log;
|
||||
_descriptionSource = descriptionSource;
|
||||
}
|
||||
|
||||
public string GetTaskName(string branch, Settings settings)
|
||||
@@ -46,7 +42,7 @@ namespace JiraTimeBotForm.JiraIntegration
|
||||
}
|
||||
date = date.Value.Date;
|
||||
|
||||
foreach (var taskTimeItem in taskTimeItems)
|
||||
foreach (TaskTimeItem taskTimeItem in taskTimeItems)
|
||||
{
|
||||
Issue issue = null;
|
||||
try
|
||||
@@ -91,12 +87,8 @@ namespace JiraTimeBotForm.JiraIntegration
|
||||
if (!hasTodayWorklog)
|
||||
{
|
||||
var timeSpentJira = $"{taskTimeItem.Time.TotalMinutes}m";
|
||||
|
||||
var comment = _dummyComments.OrderBy(f=>Guid.NewGuid()).FirstOrDefault();
|
||||
if (addCommentsToWorklog)
|
||||
{
|
||||
comment = taskTimeItem.Description;
|
||||
}
|
||||
|
||||
var comment = _descriptionSource.GetDescription(taskTimeItem, addCommentsToWorklog);
|
||||
|
||||
Worklog workLogToAdd = new Worklog(timeSpentJira, date.Value, comment);
|
||||
if (!dummy)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
|
||||
namespace JiraTimeBotForm.JiraIntegration
|
||||
{
|
||||
public class JiraDescriptionSource : IJiraDescriptionSource
|
||||
{
|
||||
private readonly List<string> _dummyComments = new List<string>
|
||||
{
|
||||
"Написание кода", "написание кода", "программирование", "реализация задачи", "кодинг", "код + тесты",
|
||||
"кодинг", "написание кода и тестов"
|
||||
};
|
||||
|
||||
public string GetDescription(TaskTimeItem taskTimeItem, bool addCommentsToWorklog)
|
||||
{
|
||||
var comment = _dummyComments.OrderBy(f=>Guid.NewGuid()).FirstOrDefault();
|
||||
if (addCommentsToWorklog)
|
||||
{
|
||||
comment = taskTimeItem.Description;
|
||||
}
|
||||
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DI\ContainerBuilder.cs" />
|
||||
<Compile Include="Extensions\Extensions.cs" />
|
||||
<Compile Include="JiraIntegration\IJiraDescriptionSource.cs" />
|
||||
<Compile Include="JiraIntegration\JiraDescriptionSource.cs" />
|
||||
<Compile Include="Job.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Configuration\Settings.cs" />
|
||||
|
||||
@@ -56,11 +56,16 @@ namespace JiraTimeBotForm.TaskTime
|
||||
|
||||
workTimeItems.Add(taskTimeItem);
|
||||
}
|
||||
if (!workTimeItems.Any())
|
||||
{
|
||||
return new List<TaskTimeItem>();
|
||||
}
|
||||
|
||||
if (remainMinutes != 0)
|
||||
{
|
||||
_log.Trace($"Погрешность распределения времени: {remainMinutes}. Добавляю к первой задаче.");
|
||||
}
|
||||
|
||||
//если переборщили или не достаточно добавили до 8 часов - скореектируем остаток в первой задаче (она самая трудозатратная).
|
||||
workTimeItems.First().Time += TimeSpan.FromMinutes(remainMinutes);
|
||||
|
||||
|
||||
@@ -7,11 +7,8 @@ using System.Windows.Forms;
|
||||
using Autofac;
|
||||
using JiraTimeBotForm.Configuration;
|
||||
using JiraTimeBotForm.DI;
|
||||
using JiraTimeBotForm.Mercurial;
|
||||
using JiraTimeBotForm.TasksProcessors;
|
||||
using JiraTimeBotForm.TaskTime;
|
||||
using JiraTimeBotForm.UI;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
// This is the code for your desktop app.
|
||||
// Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
|
||||
|
||||
Reference in New Issue
Block a user