blob: 5c68db1bcc8fad3a5f2b45d1f2a33351f6f7ad69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
using Gestor.Application;
using Gestor.Common.Helpers;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Gestor.Application.Helpers
{
public class Instancia
{
public static string Conexao;
public static Gestor.Application.App App
{
get;
set;
}
public static UnitOfWork Commited
{
get
{
return Instancia.UnitOfWork(true);
}
}
public static UnitOfWork Read
{
get
{
return Instancia.UnitOfWork(false);
}
}
public Instancia()
{
}
public static void DeleteCfg()
{
string str = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");
string str1 = string.Concat(Connection.Catalog, ".cfg");
if (File.Exists(string.Concat(str, str1)))
{
File.Delete(string.Concat(str, str1));
}
}
public static void ExcluirCfg()
{
File.Delete(string.Concat("Data_", Connection.Catalog, ".cfg"));
File.Delete(string.Concat("File_", Connection.Catalog, ".cfg"));
File.Delete(string.Concat("Sign_", Connection.Catalog, ".cfg"));
}
private static UnitOfWork UnitOfWork(bool withTransaction = true)
{
DataBaseParameters.set_NovoGestor(true);
Instancia.Conexao = Instancia.Conexao ?? Connection.GetConnection(true);
if (Instancia.Conexao == null)
{
return Instancia.App.ConnectionRetry().Result;
}
UnitOfWork unitOfWork = new UnitOfWork(Instancia.Conexao, withTransaction);
if (unitOfWork.get_HasSession())
{
return unitOfWork;
}
return Instancia.App.ConnectionRetry().Result;
}
}
}
|