109 lines
4.2 KiB
C#
109 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Taloyhtio.ReimariIntegration.CodeFiles;
|
|
using Taloyhtio.ReimariIntegration.CodeFiles.DataAccess;
|
|
|
|
namespace ReimariTasksTest
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
{
|
|
Console.WriteLine("Usage: exe {vatCode}");
|
|
return;
|
|
}
|
|
|
|
var logger = new Logger(Constants.LOG_FILE_TASKS);
|
|
string connStr = ConfigurationManager.ConnectionStrings["REIM_Intra"].ConnectionString;
|
|
var r = new TasksRepository(connStr, logger);
|
|
//var tasks = GetTasks(args[0], null, connStr, logger);
|
|
var tasks = r.GetTasks(args[0], null);
|
|
if (tasks == null || tasks.Count == 0)
|
|
{
|
|
logger.Log("Tasks are empty");
|
|
return;
|
|
}
|
|
|
|
logger.Log("Tasks count: {0}", tasks.Count);
|
|
foreach (var task in tasks)
|
|
{
|
|
logger.Log("{0}: {1}", task.Id, task.Description);
|
|
}
|
|
}
|
|
|
|
// public static List<TaskInfo> GetTasks(string condoVAT, string status, string connStr, Logger logger)
|
|
// {
|
|
// try
|
|
// {
|
|
// var tasks = new List<TaskInfo>();
|
|
// using (var ctx = new DataModelReim(connStr))
|
|
// {
|
|
// var company = ctx.tblCompanies.FirstOrDefault(c => c.companiesVATCode == condoVAT);
|
|
// if (company == null)
|
|
// {
|
|
// // todo: log
|
|
// return new List<TaskInfo>();
|
|
// }
|
|
// string tampuuriId = company.companiesTampuuriID;
|
|
// if (string.IsNullOrEmpty(tampuuriId))
|
|
// {
|
|
// // todo: log
|
|
// return new List<TaskInfo>();
|
|
// }
|
|
//
|
|
// foreach (var task in ctx.tblCustomerTasks.Where(t => t.cTaskCustomerID == tampuuriId))
|
|
// {
|
|
// tasks.Add(new TaskInfo
|
|
// {
|
|
// Id = task.cTaskID,
|
|
// Title = task.cTaskTitle,
|
|
// Description = task.cTaskDesc,
|
|
// Created = task.cTaskCreated,
|
|
// DueDate = task.cTaskDueDate,
|
|
// ResponsibleCompany = task.cTaskResponsibleCompany,
|
|
// Status = task.cTaskStatusID,
|
|
// Apartment = task.cTaskApartment,
|
|
// Comment = task.cTaskClosingMessage,
|
|
// Orderer = task.cTaskOrderer,
|
|
// IsPrivateOrder = task.cTaskIlmoittajaTurvakielto == "1"
|
|
// });
|
|
// }
|
|
// }
|
|
//
|
|
// if (tasks.IsNullOrEmpty())
|
|
// {
|
|
// return new List<TaskInfo>();
|
|
// }
|
|
//
|
|
// // show tasks created after 1.1.2018 and which are not from private order
|
|
// var dt = new DateTime(2018, 1, 1);
|
|
// tasks = tasks.Where(t => t.Created != null && t.Created >= dt && !t.IsPrivateOrder).ToList();
|
|
//
|
|
// if (string.IsNullOrEmpty(status))
|
|
// {
|
|
// return tasks.OrderByDescending(t => t.Created).ToList();
|
|
// }
|
|
// else
|
|
// {
|
|
// return tasks.Where(t => string.Compare(t.Status, status, true) == 0).OrderByDescending(t => t.Created).ToList();
|
|
// }
|
|
// }
|
|
// catch (Exception x)
|
|
// {
|
|
// logger.Log("Error occured when try to get open tasks: {0}\n{1}", x.Message, x.StackTrace);
|
|
// if (x.InnerException != null)
|
|
// {
|
|
// logger.Log("Inner exception: {0}\n{1}", x.InnerException.Message, x.InnerException.StackTrace);
|
|
// }
|
|
// return new List<TaskInfo>();
|
|
// }
|
|
// }
|
|
}
|
|
}
|