crm: refactoring
This commit is contained in:
parent
401c8ca2e2
commit
a9a7c0a4b7
@ -48,10 +48,10 @@ namespace ASC.CRM.Api
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebItemSecurity WebItemSecurity { get; }
|
private WebItemSecurity _webItemSecurity;
|
||||||
public DaoFactory DaoFactory { get; }
|
private DaoFactory _daoFactory;
|
||||||
public TenantManager TenantManager { get; }
|
private TenantManager _tenantManager;
|
||||||
public TenantUtil TenantUtil { get; }
|
private TenantUtil _tenantUtil;
|
||||||
|
|
||||||
public CrmCalendar(WebItemSecurity webItemSecurity,
|
public CrmCalendar(WebItemSecurity webItemSecurity,
|
||||||
DaoFactory daoFactory,
|
DaoFactory daoFactory,
|
||||||
@ -61,10 +61,10 @@ namespace ASC.CRM.Api
|
|||||||
TenantUtil tenantUtil
|
TenantUtil tenantUtil
|
||||||
) : base(authContext, timeZoneConverter)
|
) : base(authContext, timeZoneConverter)
|
||||||
{
|
{
|
||||||
TenantUtil = tenantUtil;
|
_tenantUtil = tenantUtil;
|
||||||
TenantManager = tenantManager;
|
_tenantManager = tenantManager;
|
||||||
WebItemSecurity = webItemSecurity;
|
_webItemSecurity = webItemSecurity;
|
||||||
DaoFactory = daoFactory;
|
_daoFactory = daoFactory;
|
||||||
|
|
||||||
Context.HtmlBackgroundColor = "";
|
Context.HtmlBackgroundColor = "";
|
||||||
Context.HtmlTextColor = "";
|
Context.HtmlTextColor = "";
|
||||||
@ -84,12 +84,12 @@ namespace ASC.CRM.Api
|
|||||||
var events = new List<IEvent>();
|
var events = new List<IEvent>();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!WebItemSecurity.IsAvailableForMe(WebItemManager.CRMProductID))
|
!_webItemSecurity.IsAvailableForMe(WebItemManager.CRMProductID))
|
||||||
{
|
{
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tasks = DaoFactory.GetTaskDao().GetTasks(String.Empty, userId, 0, false, DateTime.MinValue,
|
var tasks = _daoFactory.GetTaskDao().GetTasks(String.Empty, userId, 0, false, DateTime.MinValue,
|
||||||
DateTime.MinValue, EntityType.Any, 0, 0, 0, null);
|
DateTime.MinValue, EntityType.Any, 0, 0, 0, null);
|
||||||
|
|
||||||
foreach (var t in tasks)
|
foreach (var t in tasks)
|
||||||
@ -97,7 +97,7 @@ namespace ASC.CRM.Api
|
|||||||
if (t.DeadLine == DateTime.MinValue) continue;
|
if (t.DeadLine == DateTime.MinValue) continue;
|
||||||
|
|
||||||
var allDayEvent = t.DeadLine.Hour == 0 && t.DeadLine.Minute == 0;
|
var allDayEvent = t.DeadLine.Hour == 0 && t.DeadLine.Minute == 0;
|
||||||
var utcDate = allDayEvent ? t.DeadLine.Date : TenantUtil.DateTimeToUtc(t.DeadLine);
|
var utcDate = allDayEvent ? t.DeadLine.Date : _tenantUtil.DateTimeToUtc(t.DeadLine);
|
||||||
|
|
||||||
var e = new Event
|
var e = new Event
|
||||||
{
|
{
|
||||||
@ -121,7 +121,7 @@ namespace ASC.CRM.Api
|
|||||||
|
|
||||||
public override TimeZoneInfo TimeZone
|
public override TimeZoneInfo TimeZone
|
||||||
{
|
{
|
||||||
get { return TimeZoneInfo.FindSystemTimeZoneById(TenantManager.GetCurrentTenant().TimeZone); }
|
get { return TimeZoneInfo.FindSystemTimeZoneById(_tenantManager.GetCurrentTenant().TimeZone); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsVisibleEvent(DateTime startDate, DateTime endDate, DateTime eventStartDate, DateTime eventEndDate)
|
private bool IsVisibleEvent(DateTime startDate, DateTime endDate, DateTime eventStartDate, DateTime eventEndDate)
|
||||||
|
@ -49,6 +49,16 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private IConfiguration _configuration;
|
||||||
|
private SettingsManager _settingsManager;
|
||||||
|
protected int _tenantID;
|
||||||
|
private FilesLinkUtility _filesLinkUtility;
|
||||||
|
private SetupInfo _setupInfo;
|
||||||
|
private SecurityContext _securityContext;
|
||||||
|
private StorageFactory _storageFactory;
|
||||||
|
private CrmSecurity _crmSecurity;
|
||||||
|
|
||||||
public Global(StorageFactory storageFactory,
|
public Global(StorageFactory storageFactory,
|
||||||
SecurityContext securityContext,
|
SecurityContext securityContext,
|
||||||
SetupInfo setupInfo,
|
SetupInfo setupInfo,
|
||||||
@ -59,19 +69,16 @@ namespace ASC.Web.CRM.Classes
|
|||||||
IConfiguration configuration
|
IConfiguration configuration
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
StorageFactory = storageFactory;
|
_storageFactory = storageFactory;
|
||||||
FilesLinkUtility = filesLinkUtility;
|
_filesLinkUtility = filesLinkUtility;
|
||||||
SetupInfo = setupInfo;
|
_setupInfo = setupInfo;
|
||||||
SecurityContext = securityContext;
|
_securityContext = securityContext;
|
||||||
CRMSecurity = crmSecurity;
|
_crmSecurity = crmSecurity;
|
||||||
TenantID = tenantManager.GetCurrentTenant().TenantId;
|
_tenantID = tenantManager.GetCurrentTenant().TenantId;
|
||||||
SettingsManager = settingsManager;
|
_settingsManager = settingsManager;
|
||||||
Configuration = configuration;
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
|
||||||
|
|
||||||
public SettingsManager SettingsManager { get; }
|
|
||||||
|
|
||||||
public static readonly int EntryCountOnPage = 25;
|
public static readonly int EntryCountOnPage = 25;
|
||||||
public static readonly int VisiblePageCount = 10;
|
public static readonly int VisiblePageCount = 10;
|
||||||
@ -87,25 +94,15 @@ namespace ASC.Web.CRM.Classes
|
|||||||
public static readonly int MaxHistoryEventCharacters = 65000;
|
public static readonly int MaxHistoryEventCharacters = 65000;
|
||||||
public static readonly decimal MaxInvoiceItemPrice = (decimal)99999999.99;
|
public static readonly decimal MaxInvoiceItemPrice = (decimal)99999999.99;
|
||||||
|
|
||||||
protected int TenantID { get; private set; }
|
|
||||||
|
|
||||||
public FilesLinkUtility FilesLinkUtility { get; }
|
|
||||||
|
|
||||||
public SetupInfo SetupInfo { get; }
|
|
||||||
public SecurityContext SecurityContext { get; }
|
|
||||||
|
|
||||||
public StorageFactory StorageFactory { get; }
|
|
||||||
|
|
||||||
public CrmSecurity CRMSecurity { get; }
|
|
||||||
|
|
||||||
public IDataStore GetStore()
|
public IDataStore GetStore()
|
||||||
{
|
{
|
||||||
return StorageFactory.GetStorage(TenantID.ToString(), "crm");
|
return _storageFactory.GetStorage(_tenantID.ToString(), "crm");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDataStore GetStoreTemplate()
|
public IDataStore GetStoreTemplate()
|
||||||
{
|
{
|
||||||
return StorageFactory.GetStorage(String.Empty, "crm_template");
|
return _storageFactory.GetStorage(String.Empty, "crm_template");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanCreateProjects()
|
public bool CanCreateProjects()
|
||||||
@ -150,12 +147,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var value = Configuration["crm:invoice:download:enable"];
|
var value = _configuration["crm:invoice:download:enable"];
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(value)) return false;
|
if (string.IsNullOrEmpty(value)) return false;
|
||||||
|
|
||||||
bool canDownloadFiles = Convert.ToBoolean(value);
|
bool canDownloadFiles = Convert.ToBoolean(value);
|
||||||
if (canDownloadFiles && string.IsNullOrEmpty(FilesLinkUtility.DocServiceConverterUrl))
|
if (canDownloadFiles && string.IsNullOrEmpty(_filesLinkUtility.DocServiceConverterUrl))
|
||||||
{
|
{
|
||||||
canDownloadFiles = false;
|
canDownloadFiles = false;
|
||||||
}
|
}
|
||||||
@ -168,16 +165,16 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return !string.IsNullOrEmpty(FilesLinkUtility.DocServiceDocbuilderUrl) && CRMSecurity.IsAdmin;
|
return !string.IsNullOrEmpty(_filesLinkUtility.DocServiceDocbuilderUrl) && _crmSecurity.IsAdmin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveDefaultCurrencySettings(CurrencyInfo currency)
|
public void SaveDefaultCurrencySettings(CurrencyInfo currency)
|
||||||
{
|
{
|
||||||
var tenantSettings = SettingsManager.Load<CrmSettings>();
|
var tenantSettings = _settingsManager.Load<CrmSettings>();
|
||||||
|
|
||||||
tenantSettings.DefaultCurrency = currency.Abbreviation;
|
tenantSettings.DefaultCurrency = currency.Abbreviation;
|
||||||
SettingsManager.Save<CrmSettings>(tenantSettings);
|
_settingsManager.Save<CrmSettings>(tenantSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,24 +43,24 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class ImportFromCSVManager
|
public class ImportFromCSVManager
|
||||||
{
|
{
|
||||||
|
private MessageService _messageService;
|
||||||
|
private ImportFromCSV _importFromCSV;
|
||||||
|
private Global _global;
|
||||||
|
|
||||||
public ImportFromCSVManager(Global global,
|
public ImportFromCSVManager(Global global,
|
||||||
ImportFromCSV importFromCSV,
|
ImportFromCSV importFromCSV,
|
||||||
MessageService messageService)
|
MessageService messageService)
|
||||||
{
|
{
|
||||||
Global = global;
|
_global = global;
|
||||||
ImportFromCSV = importFromCSV;
|
_importFromCSV = importFromCSV;
|
||||||
MessageService = messageService;
|
_messageService = messageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageService MessageService { get; }
|
|
||||||
public ImportFromCSV ImportFromCSV { get; }
|
|
||||||
public Global Global { get; }
|
|
||||||
|
|
||||||
public void StartImport(EntityType entityType, String CSVFileURI, String importSettingsJSON)
|
public void StartImport(EntityType entityType, String CSVFileURI, String importSettingsJSON)
|
||||||
{
|
{
|
||||||
ImportFromCSV.Start(entityType, CSVFileURI, importSettingsJSON);
|
_importFromCSV.Start(entityType, CSVFileURI, importSettingsJSON);
|
||||||
|
|
||||||
MessageService.Send(GetMessageAction(entityType));
|
_messageService.Send(GetMessageAction(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileUploadResult ProcessUploadFake(string fileTemp, string importSettingsJSON)
|
public FileUploadResult ProcessUploadFake(string fileTemp, string importSettingsJSON)
|
||||||
@ -69,12 +69,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
if (String.IsNullOrEmpty(fileTemp) || String.IsNullOrEmpty(importSettingsJSON)) return fileUploadResult;
|
if (String.IsNullOrEmpty(fileTemp) || String.IsNullOrEmpty(importSettingsJSON)) return fileUploadResult;
|
||||||
|
|
||||||
if (!Global.GetStore().IsFile("temp", fileTemp)) return fileUploadResult;
|
if (!_global.GetStore().IsFile("temp", fileTemp)) return fileUploadResult;
|
||||||
|
|
||||||
JsonDocument jObject;
|
JsonDocument jObject;
|
||||||
|
|
||||||
//Read contents
|
//Read contents
|
||||||
using (Stream storeStream = Global.GetStore().GetReadStream("temp", fileTemp))
|
using (Stream storeStream = _global.GetStore().GetReadStream("temp", fileTemp))
|
||||||
{
|
{
|
||||||
using (var CSVFileStream = new MemoryStream())
|
using (var CSVFileStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
CSVFileStream.Position = 0;
|
CSVFileStream.Position = 0;
|
||||||
|
|
||||||
jObject = ImportFromCSV.GetInfo(CSVFileStream, importSettingsJSON);
|
jObject = _importFromCSV.GetInfo(CSVFileStream, importSettingsJSON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,16 +42,16 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class InvoiceFormattedData
|
public class InvoiceFormattedData
|
||||||
{
|
{
|
||||||
|
private OrganisationLogoManager _organisationLogoManager;
|
||||||
|
private DaoFactory _daoFactory;
|
||||||
|
|
||||||
public InvoiceFormattedData(DaoFactory daoFactory,
|
public InvoiceFormattedData(DaoFactory daoFactory,
|
||||||
OrganisationLogoManager organisationLogoManager)
|
OrganisationLogoManager organisationLogoManager)
|
||||||
{
|
{
|
||||||
DaoFactory = daoFactory;
|
_daoFactory = daoFactory;
|
||||||
OrganisationLogoManager = organisationLogoManager;
|
_organisationLogoManager = organisationLogoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrganisationLogoManager OrganisationLogoManager { get; }
|
|
||||||
|
|
||||||
public DaoFactory DaoFactory { get; }
|
|
||||||
|
|
||||||
public int TemplateType { get; set; }
|
public int TemplateType { get; set; }
|
||||||
public Tuple<string, string> Seller { get; set; }
|
public Tuple<string, string> Seller { get; set; }
|
||||||
@ -92,7 +92,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
private InvoiceFormattedData CreateData(Invoice invoice, int billingAddressID, int deliveryAddressID)
|
private InvoiceFormattedData CreateData(Invoice invoice, int billingAddressID, int deliveryAddressID)
|
||||||
{
|
{
|
||||||
var data = new InvoiceFormattedData(DaoFactory, OrganisationLogoManager);
|
var data = new InvoiceFormattedData(_daoFactory, _organisationLogoManager);
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
var cultureInfo = string.IsNullOrEmpty(invoice.Language)
|
var cultureInfo = string.IsNullOrEmpty(invoice.Language)
|
||||||
@ -107,7 +107,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
#region Seller, LogoBase64, LogoSrcFormat
|
#region Seller, LogoBase64, LogoSrcFormat
|
||||||
|
|
||||||
var invoiceSettings = DaoFactory.GetInvoiceDao().GetSettings();
|
var invoiceSettings = _daoFactory.GetInvoiceDao().GetSettings();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(invoiceSettings.CompanyName))
|
if (!string.IsNullOrEmpty(invoiceSettings.CompanyName))
|
||||||
{
|
{
|
||||||
@ -153,7 +153,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
data.LogoBase64Id = invoiceSettings.CompanyLogoID;
|
data.LogoBase64Id = invoiceSettings.CompanyLogoID;
|
||||||
//data.LogoBase64 = OrganisationLogoManager.GetOrganisationLogoBase64(invoiceSettings.CompanyLogoID);
|
//data.LogoBase64 = OrganisationLogoManager.GetOrganisationLogoBase64(invoiceSettings.CompanyLogoID);
|
||||||
data.LogoSrcFormat = OrganisationLogoManager.OrganisationLogoSrcFormat;
|
data.LogoSrcFormat = _organisationLogoManager.OrganisationLogoSrcFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -190,7 +190,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
#region Customer
|
#region Customer
|
||||||
|
|
||||||
var customer = DaoFactory.GetContactDao().GetByID(invoice.ContactID);
|
var customer = _daoFactory.GetContactDao().GetByID(invoice.ContactID);
|
||||||
|
|
||||||
if (customer != null)
|
if (customer != null)
|
||||||
{
|
{
|
||||||
@ -199,7 +199,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
sb.Append(customer.GetTitle());
|
sb.Append(customer.GetTitle());
|
||||||
|
|
||||||
var billingAddress = billingAddressID != 0
|
var billingAddress = billingAddressID != 0
|
||||||
? DaoFactory.GetContactInfoDao().GetByID(billingAddressID)
|
? _daoFactory.GetContactInfoDao().GetByID(billingAddressID)
|
||||||
: null;
|
: null;
|
||||||
if (billingAddress != null && billingAddress.InfoType == ContactInfoType.Address &&
|
if (billingAddress != null && billingAddress.InfoType == ContactInfoType.Address &&
|
||||||
billingAddress.Category == (int)AddressCategory.Billing)
|
billingAddress.Category == (int)AddressCategory.Billing)
|
||||||
@ -258,7 +258,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
data.TableBodyRows = new List<List<string>>();
|
data.TableBodyRows = new List<List<string>>();
|
||||||
|
|
||||||
var invoiceLines = invoice.GetInvoiceLines(DaoFactory);
|
var invoiceLines = invoice.GetInvoiceLines(_daoFactory);
|
||||||
var invoiceTaxes = new Dictionary<int, decimal>();
|
var invoiceTaxes = new Dictionary<int, decimal>();
|
||||||
|
|
||||||
decimal subtotal = 0;
|
decimal subtotal = 0;
|
||||||
@ -267,12 +267,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
foreach (var line in invoiceLines)
|
foreach (var line in invoiceLines)
|
||||||
{
|
{
|
||||||
var item = DaoFactory.GetInvoiceItemDao().GetByID(line.InvoiceItemID);
|
var item = _daoFactory.GetInvoiceItemDao().GetByID(line.InvoiceItemID);
|
||||||
var tax1 = line.InvoiceTax1ID > 0
|
var tax1 = line.InvoiceTax1ID > 0
|
||||||
? DaoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax1ID)
|
? _daoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax1ID)
|
||||||
: null;
|
: null;
|
||||||
var tax2 = line.InvoiceTax2ID > 0
|
var tax2 = line.InvoiceTax2ID > 0
|
||||||
? DaoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax2ID)
|
? _daoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax2ID)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var subtotalValue = Math.Round(line.Quantity * line.Price, 2);
|
var subtotalValue = Math.Round(line.Quantity * line.Price, 2);
|
||||||
@ -332,7 +332,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
foreach (var invoiceTax in invoiceTaxes)
|
foreach (var invoiceTax in invoiceTaxes)
|
||||||
{
|
{
|
||||||
var iTax = DaoFactory.GetInvoiceTaxDao().GetByID(invoiceTax.Key);
|
var iTax = _daoFactory.GetInvoiceTaxDao().GetByID(invoiceTax.Key);
|
||||||
data.TableFooterRows.Add(new Tuple<string, string>(
|
data.TableFooterRows.Add(new Tuple<string, string>(
|
||||||
string.Format("{0} ({1}%)", iTax.Name, iTax.Rate),
|
string.Format("{0} ({1}%)", iTax.Name, iTax.Rate),
|
||||||
invoiceTax.Value.ToString(CultureInfo.InvariantCulture)));
|
invoiceTax.Value.ToString(CultureInfo.InvariantCulture)));
|
||||||
@ -373,7 +373,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
#region Consignee
|
#region Consignee
|
||||||
|
|
||||||
var consignee = DaoFactory.GetContactDao().GetByID(invoice.ConsigneeID);
|
var consignee = _daoFactory.GetContactDao().GetByID(invoice.ConsigneeID);
|
||||||
|
|
||||||
if (consignee != null)
|
if (consignee != null)
|
||||||
{
|
{
|
||||||
@ -382,7 +382,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
sb.Append(consignee.GetTitle());
|
sb.Append(consignee.GetTitle());
|
||||||
|
|
||||||
var deliveryAddress = deliveryAddressID != 0
|
var deliveryAddress = deliveryAddressID != 0
|
||||||
? DaoFactory.GetContactInfoDao().GetByID(deliveryAddressID)
|
? _daoFactory.GetContactInfoDao().GetByID(deliveryAddressID)
|
||||||
: null;
|
: null;
|
||||||
if (deliveryAddress != null && deliveryAddress.InfoType == ContactInfoType.Address &&
|
if (deliveryAddress != null && deliveryAddress.InfoType == ContactInfoType.Address &&
|
||||||
deliveryAddress.Category == (int)AddressCategory.Postal)
|
deliveryAddress.Category == (int)AddressCategory.Postal)
|
||||||
@ -438,7 +438,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
private InvoiceFormattedData ReadData(string jsonData)
|
private InvoiceFormattedData ReadData(string jsonData)
|
||||||
{
|
{
|
||||||
var data = new InvoiceFormattedData(DaoFactory, OrganisationLogoManager);
|
var data = new InvoiceFormattedData(_daoFactory, _organisationLogoManager);
|
||||||
var jsonObj = JsonDocument.Parse(jsonData).RootElement;
|
var jsonObj = JsonDocument.Parse(jsonData).RootElement;
|
||||||
|
|
||||||
#region TemplateType
|
#region TemplateType
|
||||||
@ -461,7 +461,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(data.LogoBase64) && data.LogoBase64Id != 0)
|
if (string.IsNullOrEmpty(data.LogoBase64) && data.LogoBase64Id != 0)
|
||||||
{
|
{
|
||||||
data.LogoBase64 = OrganisationLogoManager.GetOrganisationLogoBase64(data.LogoBase64Id);
|
data.LogoBase64 = _organisationLogoManager.GetOrganisationLogoBase64(data.LogoBase64Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,7 +588,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
data.TableBodyRows = new List<List<string>>();
|
data.TableBodyRows = new List<List<string>>();
|
||||||
|
|
||||||
var invoiceLines = invoice.GetInvoiceLines(DaoFactory);
|
var invoiceLines = invoice.GetInvoiceLines(_daoFactory);
|
||||||
var invoiceTaxes = new Dictionary<int, decimal>();
|
var invoiceTaxes = new Dictionary<int, decimal>();
|
||||||
|
|
||||||
decimal subtotal = 0;
|
decimal subtotal = 0;
|
||||||
@ -597,12 +597,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
foreach (var line in invoiceLines)
|
foreach (var line in invoiceLines)
|
||||||
{
|
{
|
||||||
var item = DaoFactory.GetInvoiceItemDao().GetByID(line.InvoiceItemID);
|
var item = _daoFactory.GetInvoiceItemDao().GetByID(line.InvoiceItemID);
|
||||||
var tax1 = line.InvoiceTax1ID > 0
|
var tax1 = line.InvoiceTax1ID > 0
|
||||||
? DaoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax1ID)
|
? _daoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax1ID)
|
||||||
: null;
|
: null;
|
||||||
var tax2 = line.InvoiceTax2ID > 0
|
var tax2 = line.InvoiceTax2ID > 0
|
||||||
? DaoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax2ID)
|
? _daoFactory.GetInvoiceTaxDao().GetByID(line.InvoiceTax2ID)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var subtotalValue = Math.Round(line.Quantity * line.Price, 2);
|
var subtotalValue = Math.Round(line.Quantity * line.Price, 2);
|
||||||
@ -662,7 +662,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
foreach (var invoiceTax in invoiceTaxes)
|
foreach (var invoiceTax in invoiceTaxes)
|
||||||
{
|
{
|
||||||
var iTax = DaoFactory.GetInvoiceTaxDao().GetByID(invoiceTax.Key);
|
var iTax = _daoFactory.GetInvoiceTaxDao().GetByID(invoiceTax.Key);
|
||||||
data.TableFooterRows.Add(new Tuple<string, string>(
|
data.TableFooterRows.Add(new Tuple<string, string>(
|
||||||
string.Format("{0} ({1}%)", iTax.Name, iTax.Rate),
|
string.Format("{0} ({1}%)", iTax.Name, iTax.Rate),
|
||||||
invoiceTax.Value.ToString(CultureInfo.InvariantCulture)));
|
invoiceTax.Value.ToString(CultureInfo.InvariantCulture)));
|
||||||
|
@ -44,23 +44,22 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class OrganisationLogoManager
|
public class OrganisationLogoManager
|
||||||
{
|
{
|
||||||
|
private DaoFactory _daoFactory;
|
||||||
|
private ILog _logger;
|
||||||
|
private Global _global;
|
||||||
|
private WebImageSupplier _webImageSupplier;
|
||||||
|
|
||||||
public OrganisationLogoManager(WebImageSupplier webImageSupplier,
|
public OrganisationLogoManager(WebImageSupplier webImageSupplier,
|
||||||
Global global,
|
Global global,
|
||||||
IOptionsMonitor<ILog> logger,
|
IOptionsMonitor<ILog> logger,
|
||||||
DaoFactory daoFactory)
|
DaoFactory daoFactory)
|
||||||
{
|
{
|
||||||
WebImageSupplier = webImageSupplier;
|
_webImageSupplier = webImageSupplier;
|
||||||
Global = global;
|
_global = global;
|
||||||
Logger = logger.Get("ASC.CRM");
|
_logger = logger.Get("ASC.CRM");
|
||||||
DaoFactory = daoFactory;
|
_daoFactory = daoFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaoFactory DaoFactory { get; }
|
|
||||||
public ILog Logger { get; }
|
|
||||||
|
|
||||||
public Global Global { get; }
|
|
||||||
|
|
||||||
public WebImageSupplier WebImageSupplier { get; }
|
|
||||||
|
|
||||||
#region Members
|
#region Members
|
||||||
|
|
||||||
@ -120,14 +119,14 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
public String GetDefaultLogoUrl()
|
public String GetDefaultLogoUrl()
|
||||||
{
|
{
|
||||||
return WebImageSupplier.GetAbsoluteWebPath("org_logo_default.png", ProductEntryPoint.ID);
|
return _webImageSupplier.GetAbsoluteWebPath("org_logo_default.png", ProductEntryPoint.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetOrganisationLogoBase64(int logoID)
|
public String GetOrganisationLogoBase64(int logoID)
|
||||||
{
|
{
|
||||||
if (logoID <= 0) { return ""; }
|
if (logoID <= 0) { return ""; }
|
||||||
|
|
||||||
return DaoFactory.GetInvoiceDao().GetOrganisationLogoBase64(logoID);
|
return _daoFactory.GetInvoiceDao().GetOrganisationLogoBase64(logoID);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
public void DeletePhoto(bool recursive)
|
public void DeletePhoto(bool recursive)
|
||||||
{
|
{
|
||||||
var photoDirectory = BuildFileDirectory();
|
var photoDirectory = BuildFileDirectory();
|
||||||
var store = Global.GetStore();
|
var store = _global.GetStore();
|
||||||
|
|
||||||
lock (_synchronizedObj)
|
lock (_synchronizedObj)
|
||||||
{
|
{
|
||||||
@ -159,14 +158,14 @@ namespace ASC.Web.CRM.Classes
|
|||||||
public int TryUploadOrganisationLogoFromTmp(DaoFactory factory)
|
public int TryUploadOrganisationLogoFromTmp(DaoFactory factory)
|
||||||
{
|
{
|
||||||
var directoryPath = BuildFileDirectory();
|
var directoryPath = BuildFileDirectory();
|
||||||
var dataStore = Global.GetStore();
|
var dataStore = _global.GetStore();
|
||||||
|
|
||||||
if (!dataStore.IsDirectory(directoryPath))
|
if (!dataStore.IsDirectory(directoryPath))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var photoPaths = Global.GetStore().ListFilesRelative("", directoryPath, OrganisationLogoImgName + "*", false);
|
var photoPaths = _global.GetStore().ListFilesRelative("", directoryPath, OrganisationLogoImgName + "*", false);
|
||||||
if (photoPaths.Length == 0)
|
if (photoPaths.Length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -183,7 +182,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.ErrorFormat("TryUploadOrganisationLogoFromTmp failed with error: {0}", ex);
|
_logger.ErrorFormat("TryUploadOrganisationLogoFromTmp failed with error: {0}", ex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -193,7 +192,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
var photoPath = BuildFilePath("." + Global.GetImgFormatName(imageFormat));
|
var photoPath = BuildFilePath("." + Global.GetImgFormatName(imageFormat));
|
||||||
|
|
||||||
return ExecResizeImage(imageData, OrganisationLogoSize, Global.GetStore(), photoPath);
|
return ExecResizeImage(imageData, OrganisationLogoSize, _global.GetStore(), photoPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,19 +41,19 @@ namespace ASC.Web.CRM
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class PathProvider
|
public class PathProvider
|
||||||
{
|
{
|
||||||
|
private HttpContext _httpContext;
|
||||||
|
private CommonLinkUtility _commonLinkUtility;
|
||||||
|
private WebPath _webPath;
|
||||||
|
|
||||||
public PathProvider(IHttpContextAccessor httpContextAccessor,
|
public PathProvider(IHttpContextAccessor httpContextAccessor,
|
||||||
CommonLinkUtility commonLinkUtility)
|
CommonLinkUtility commonLinkUtility)
|
||||||
{
|
{
|
||||||
CommonLinkUtility = commonLinkUtility;
|
_commonLinkUtility = commonLinkUtility;
|
||||||
HttpContext = httpContextAccessor.HttpContext;
|
_httpContext = httpContextAccessor.HttpContext;
|
||||||
|
|
||||||
BaseAbsolutePath = CommonLinkUtility.ToAbsolute(BaseVirtualPath);
|
BaseAbsolutePath = _commonLinkUtility.ToAbsolute(BaseVirtualPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpContext HttpContext { get; }
|
|
||||||
|
|
||||||
public CommonLinkUtility CommonLinkUtility { get; }
|
|
||||||
public WebPath WebPath { get; }
|
|
||||||
|
|
||||||
public readonly String BaseVirtualPath = "~/Products/CRM/";
|
public readonly String BaseVirtualPath = "~/Products/CRM/";
|
||||||
public readonly String BaseAbsolutePath;
|
public readonly String BaseAbsolutePath;
|
||||||
|
@ -36,38 +36,38 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
private readonly string numberId;
|
private readonly string numberId;
|
||||||
|
|
||||||
public SignalrServiceClient SignalrServiceClient { get; }
|
private SignalrServiceClient _signalrServiceClient;
|
||||||
|
|
||||||
public SignalRHelper(string numberId,
|
public SignalRHelper(string numberId,
|
||||||
SignalrServiceClient signalrServiceClient)
|
SignalrServiceClient signalrServiceClient)
|
||||||
{
|
{
|
||||||
SignalrServiceClient = signalrServiceClient;
|
_signalrServiceClient = signalrServiceClient;
|
||||||
this.numberId = numberId.TrimStart('+');
|
this.numberId = numberId.TrimStart('+');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Enqueue(string call, string agent)
|
public void Enqueue(string call, string agent)
|
||||||
{
|
{
|
||||||
SignalrServiceClient.EnqueueCall(numberId, call, agent);
|
_signalrServiceClient.EnqueueCall(numberId, call, agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Incoming(string call, string agent)
|
public void Incoming(string call, string agent)
|
||||||
{
|
{
|
||||||
SignalrServiceClient.IncomingCall(call, agent);
|
_signalrServiceClient.IncomingCall(call, agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MissCall(string call, string agent)
|
public void MissCall(string call, string agent)
|
||||||
{
|
{
|
||||||
SignalrServiceClient.MissCall(numberId, call, agent);
|
_signalrServiceClient.MissCall(numberId, call, agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reload(string agentId = null)
|
public void Reload(string agentId = null)
|
||||||
{
|
{
|
||||||
SignalrServiceClient.Reload(numberId, agentId);
|
_signalrServiceClient.Reload(numberId, agentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tuple<Agent, bool> GetAgent(List<Guid> contactsResponsibles)
|
public Tuple<Agent, bool> GetAgent(List<Guid> contactsResponsibles)
|
||||||
{
|
{
|
||||||
return SignalrServiceClient.GetAgent<Tuple<Agent, bool>>(numberId, contactsResponsibles);
|
return _signalrServiceClient.GetAgent<Tuple<Agent, bool>>(numberId, contactsResponsibles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -49,13 +49,14 @@ namespace ASC.Web.CRM
|
|||||||
private readonly Guid _importCompleted = new Guid("{6A717AAD-16AE-4713-A782-B887766BEB9F}");
|
private readonly Guid _importCompleted = new Guid("{6A717AAD-16AE-4713-A782-B887766BEB9F}");
|
||||||
private readonly Guid _createNewContact = new Guid("{ADAC1E70-4163-41c1-8968-67A44E4D24E7}");
|
private readonly Guid _createNewContact = new Guid("{ADAC1E70-4163-41c1-8968-67A44E4D24E7}");
|
||||||
|
|
||||||
|
private CoreBaseSettings _coreBaseSettings;
|
||||||
|
|
||||||
public ProductSubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource)
|
public ProductSubscriptionManager(CoreBaseSettings coreBaseSettings, NotifySource notifySource)
|
||||||
{
|
{
|
||||||
CoreBaseSettings = coreBaseSettings;
|
_coreBaseSettings = coreBaseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotifySource NotifySource { get; }
|
public NotifySource NotifySource { get; }
|
||||||
public CoreBaseSettings CoreBaseSettings { get; }
|
|
||||||
|
|
||||||
public List<SubscriptionObject> GetSubscriptionObjects(Guid subItem)
|
public List<SubscriptionObject> GetSubscriptionObjects(Guid subItem)
|
||||||
{
|
{
|
||||||
@ -102,7 +103,7 @@ namespace ASC.Web.CRM
|
|||||||
{
|
{
|
||||||
ID = _exportCompleted,
|
ID = _exportCompleted,
|
||||||
Name = CRMCommonResource.SubscriptionType_ExportCompleted,
|
Name = CRMCommonResource.SubscriptionType_ExportCompleted,
|
||||||
NotifyAction = CoreBaseSettings.CustomMode ? NotifyConstants.Event_ExportCompletedCustomMode : NotifyConstants.Event_ExportCompleted,
|
NotifyAction = _coreBaseSettings.CustomMode ? NotifyConstants.Event_ExportCompletedCustomMode : NotifyConstants.Event_ExportCompleted,
|
||||||
Single = true,
|
Single = true,
|
||||||
CanSubscribe = true
|
CanSubscribe = true
|
||||||
},
|
},
|
||||||
@ -110,7 +111,7 @@ namespace ASC.Web.CRM
|
|||||||
{
|
{
|
||||||
ID = _importCompleted,
|
ID = _importCompleted,
|
||||||
Name = CRMCommonResource.SubscriptionType_ImportCompleted,
|
Name = CRMCommonResource.SubscriptionType_ImportCompleted,
|
||||||
NotifyAction = CoreBaseSettings.CustomMode ? NotifyConstants.Event_ImportCompletedCustomMode : NotifyConstants.Event_ImportCompleted,
|
NotifyAction = _coreBaseSettings.CustomMode ? NotifyConstants.Event_ImportCompletedCustomMode : NotifyConstants.Event_ImportCompleted,
|
||||||
Single = true,
|
Single = true,
|
||||||
CanSubscribe = true
|
CanSubscribe = true
|
||||||
},
|
},
|
||||||
|
@ -44,31 +44,32 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class CrmSpaceUsageStatManager : SpaceUsageStatManager
|
public class CrmSpaceUsageStatManager : SpaceUsageStatManager
|
||||||
{
|
{
|
||||||
|
private int _tenantId;
|
||||||
|
private FilesDbContext _filesDbContext;
|
||||||
|
private PathProvider _pathProvider;
|
||||||
|
|
||||||
public CrmSpaceUsageStatManager(DbContextManager<FilesDbContext> filesDbContext,
|
public CrmSpaceUsageStatManager(DbContextManager<FilesDbContext> filesDbContext,
|
||||||
PathProvider pathProvider,
|
PathProvider pathProvider,
|
||||||
TenantManager tenantManager)
|
TenantManager tenantManager)
|
||||||
{
|
{
|
||||||
PathProvider = pathProvider;
|
_pathProvider = pathProvider;
|
||||||
FilesDbContext = filesDbContext.Value;
|
_filesDbContext = filesDbContext.Value;
|
||||||
TenantId = tenantManager.GetCurrentTenant().TenantId;
|
_tenantId = tenantManager.GetCurrentTenant().TenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TenantId { get; }
|
|
||||||
public FilesDbContext FilesDbContext { get; }
|
|
||||||
public PathProvider PathProvider { get; }
|
|
||||||
|
|
||||||
public override List<UsageSpaceStatItem> GetStatData()
|
public override List<UsageSpaceStatItem> GetStatData()
|
||||||
{
|
{
|
||||||
var spaceUsage = FilesDbContext.Files.Join(FilesDbContext.Tree,
|
var spaceUsage = _filesDbContext.Files.Join(_filesDbContext.Tree,
|
||||||
x => x.FolderId,
|
x => x.FolderId,
|
||||||
y => y.FolderId,
|
y => y.FolderId,
|
||||||
(x, y) => new { x, y }
|
(x, y) => new { x, y }
|
||||||
)
|
)
|
||||||
.Join(FilesDbContext.BunchObjects,
|
.Join(_filesDbContext.BunchObjects,
|
||||||
x => x.y.ParentId,
|
x => x.y.ParentId,
|
||||||
y => Convert.ToInt32(y.LeftNode),
|
y => Convert.ToInt32(y.LeftNode),
|
||||||
(x, y) => new { x, y })
|
(x, y) => new { x, y })
|
||||||
.Where(x => x.y.TenantId == TenantId &&
|
.Where(x => x.y.TenantId == _tenantId &&
|
||||||
Microsoft.EntityFrameworkCore.EF.Functions.Like(x.y.RightNode, "crm/crm_common/%"))
|
Microsoft.EntityFrameworkCore.EF.Functions.Like(x.y.RightNode, "crm/crm_common/%"))
|
||||||
.Sum(x => x.x.x.ContentLength);
|
.Sum(x => x.x.x.ContentLength);
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
|
|
||||||
Name = CRMCommonResource.WholeCRMModule,
|
Name = CRMCommonResource.WholeCRMModule,
|
||||||
SpaceUsage = spaceUsage,
|
SpaceUsage = spaceUsage,
|
||||||
Url = VirtualPathUtility.ToAbsolute(PathProvider.StartURL())
|
Url = VirtualPathUtility.ToAbsolute(_pathProvider.StartURL())
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -48,23 +48,24 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class ProductEntryPoint : Product
|
public class ProductEntryPoint : Product
|
||||||
{
|
{
|
||||||
|
private ProductContext _context;
|
||||||
|
private FilesIntegration _filesIntegration;
|
||||||
|
private PathProvider _pathProvider;
|
||||||
|
private SecurityContext _securityContext;
|
||||||
|
private UserManager _userManager;
|
||||||
|
|
||||||
public ProductEntryPoint(SecurityContext securityContext,
|
public ProductEntryPoint(SecurityContext securityContext,
|
||||||
UserManager userManager,
|
UserManager userManager,
|
||||||
PathProvider pathProvider,
|
PathProvider pathProvider,
|
||||||
FilesIntegration filesIntegration)
|
FilesIntegration filesIntegration)
|
||||||
{
|
{
|
||||||
SecurityContext = securityContext;
|
_securityContext = securityContext;
|
||||||
UserManager = userManager;
|
_userManager = userManager;
|
||||||
PathProvider = pathProvider;
|
_pathProvider = pathProvider;
|
||||||
FilesIntegration = filesIntegration;
|
_filesIntegration = filesIntegration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly Guid ID = WebItemManager.CRMProductID;
|
public static readonly Guid ID = WebItemManager.CRMProductID;
|
||||||
private ProductContext _context;
|
|
||||||
public FilesIntegration FilesIntegration { get; }
|
|
||||||
public PathProvider PathProvider { get; }
|
|
||||||
public SecurityContext SecurityContext { get; }
|
|
||||||
public UserManager UserManager { get; }
|
|
||||||
public override string ApiURL
|
public override string ApiURL
|
||||||
{
|
{
|
||||||
get => "api/2.0/crm/info.json";
|
get => "api/2.0/crm/info.json";
|
||||||
@ -75,17 +76,17 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var id = SecurityContext.CurrentAccount.ID;
|
var id = _securityContext.CurrentAccount.ID;
|
||||||
|
|
||||||
if (UserManager.IsUserInGroup(id, ASC.Core.Users.Constants.GroupAdmin.ID) || UserManager.IsUserInGroup(id, ID))
|
if (_userManager.IsUserInGroup(id, ASC.Core.Users.Constants.GroupAdmin.ID) || _userManager.IsUserInGroup(id, ID))
|
||||||
return CRMCommonResource.ProductDescriptionEx;
|
return CRMCommonResource.ProductDescriptionEx;
|
||||||
|
|
||||||
return CRMCommonResource.ProductDescription;
|
return CRMCommonResource.ProductDescription;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string StartURL { get { return PathProvider.StartURL(); } }
|
public override string StartURL { get { return _pathProvider.StartURL(); } }
|
||||||
public override string HelpURL { get { return string.Concat(PathProvider.BaseVirtualPath, "help.aspx"); } }
|
public override string HelpURL { get { return string.Concat(_pathProvider.BaseVirtualPath, "help.aspx"); } }
|
||||||
public override string ProductClassName { get { return "crm"; } }
|
public override string ProductClassName { get { return "crm"; } }
|
||||||
public override bool Visible { get { return true; } }
|
public override bool Visible { get { return true; } }
|
||||||
public override ProductContext Context { get { return _context; } }
|
public override ProductContext Context { get { return _context; } }
|
||||||
|
@ -36,15 +36,16 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
[WebZone(WebZoneType.CustomProductList)]
|
[WebZone(WebZoneType.CustomProductList)]
|
||||||
public class VoipModule : IAddon
|
public class VoipModule : IAddon
|
||||||
{
|
{
|
||||||
|
private PathProvider _pathProvider;
|
||||||
|
private SetupInfo _setupInfo;
|
||||||
|
|
||||||
public VoipModule(PathProvider pathProvider,
|
public VoipModule(PathProvider pathProvider,
|
||||||
SetupInfo setupInfo)
|
SetupInfo setupInfo)
|
||||||
{
|
{
|
||||||
PathProvider = pathProvider;
|
_pathProvider = pathProvider;
|
||||||
SetupInfo = setupInfo;
|
_setupInfo = setupInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PathProvider PathProvider { get; }
|
|
||||||
public SetupInfo SetupInfo { get; }
|
|
||||||
|
|
||||||
public Guid ID
|
public Guid ID
|
||||||
{
|
{
|
||||||
@ -63,7 +64,7 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
|
|
||||||
public string StartURL
|
public string StartURL
|
||||||
{
|
{
|
||||||
get { return PathProvider.StartURL() + "settings.aspx?type=voip.common&sysname=/modules/voip"; }
|
get { return _pathProvider.StartURL() + "settings.aspx?type=voip.common&sysname=/modules/voip"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string HelpURL
|
public string HelpURL
|
||||||
@ -73,7 +74,7 @@ namespace ASC.Web.CRM.Configuration
|
|||||||
|
|
||||||
public string ProductClassName { get { return "voip"; } }
|
public string ProductClassName { get { return "voip"; } }
|
||||||
|
|
||||||
public bool Visible { get { return SetupInfo.VoipEnabled; } }
|
public bool Visible { get { return _setupInfo.VoipEnabled; } }
|
||||||
|
|
||||||
public AddonContext Context { get; private set; }
|
public AddonContext Context { get; private set; }
|
||||||
|
|
||||||
|
@ -54,20 +54,20 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class NotifyClient
|
public class NotifyClient
|
||||||
{
|
{
|
||||||
|
private IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
public NotifyClient(IServiceProvider serviceProvider)
|
public NotifyClient(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
ServiceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IServiceProvider ServiceProvider { get; }
|
|
||||||
|
|
||||||
public void SendAboutCreateNewContact(List<Guid> recipientID,
|
public void SendAboutCreateNewContact(List<Guid> recipientID,
|
||||||
int contactID,
|
int contactID,
|
||||||
string contactTitle, NameValueCollection fields)
|
string contactTitle, NameValueCollection fields)
|
||||||
{
|
{
|
||||||
if ((recipientID.Count == 0) || String.IsNullOrEmpty(contactTitle)) return;
|
if ((recipientID.Count == 0) || String.IsNullOrEmpty(contactTitle)) return;
|
||||||
|
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
{
|
{
|
||||||
if (userID.Length == 0) return;
|
if (userID.Length == 0) return;
|
||||||
|
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
|
|
||||||
private NameValueCollection ExtractBaseDataFrom(EntityType entityType, int entityID, DaoFactory daoFactory)
|
private NameValueCollection ExtractBaseDataFrom(EntityType entityType, int entityID, DaoFactory daoFactory)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var pathProvider = scope.ServiceProvider.GetService<PathProvider>();
|
var pathProvider = scope.ServiceProvider.GetService<PathProvider>();
|
||||||
|
|
||||||
var result = new NameValueCollection();
|
var result = new NameValueCollection();
|
||||||
@ -154,7 +154,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
{
|
{
|
||||||
if (userID.Length == 0) return;
|
if (userID.Length == 0) return;
|
||||||
|
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var pathProvider = scope.ServiceProvider.GetService<PathProvider>();
|
var pathProvider = scope.ServiceProvider.GetService<PathProvider>();
|
||||||
var securityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
var securityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
||||||
@ -219,7 +219,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
{
|
{
|
||||||
if (recipientID == Guid.Empty) return;
|
if (recipientID == Guid.Empty) return;
|
||||||
|
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var coreBaseSettings = scope.ServiceProvider.GetService<CoreBaseSettings>();
|
var coreBaseSettings = scope.ServiceProvider.GetService<CoreBaseSettings>();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
@ -239,7 +239,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
{
|
{
|
||||||
if (recipientID == Guid.Empty) return;
|
if (recipientID == Guid.Empty) return;
|
||||||
|
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var coreBaseSettings = scope.ServiceProvider.GetService<CoreBaseSettings>();
|
var coreBaseSettings = scope.ServiceProvider.GetService<CoreBaseSettings>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
@ -282,7 +282,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
|
|
||||||
public void SendAutoReminderAboutTask(DateTime scheduleDate)
|
public void SendAutoReminderAboutTask(DateTime scheduleDate)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
|
|
||||||
var defaultDao = scope.ServiceProvider.GetService<DaoFactory>();
|
var defaultDao = scope.ServiceProvider.GetService<DaoFactory>();
|
||||||
var tenantManager = scope.ServiceProvider.GetService<TenantManager>();
|
var tenantManager = scope.ServiceProvider.GetService<TenantManager>();
|
||||||
@ -379,7 +379,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
|
|
||||||
public void SendTaskReminder(Task task, String taskCategoryTitle, Contact taskContact, ASC.CRM.Core.Entities.Cases taskCase, ASC.CRM.Core.Entities.Deal taskDeal)
|
public void SendTaskReminder(Task task, String taskCategoryTitle, Contact taskContact, ASC.CRM.Core.Entities.Cases taskCase, ASC.CRM.Core.Entities.Deal taskDeal)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
|
|
||||||
public void SendAboutResponsibleByTask(Task task, String taskCategoryTitle, Contact taskContact, Cases taskCase, ASC.CRM.Core.Entities.Deal taskDeal, Hashtable fileListInfoHashtable)
|
public void SendAboutResponsibleByTask(Task task, String taskCategoryTitle, Contact taskContact, Cases taskCase, ASC.CRM.Core.Entities.Deal taskDeal, Hashtable fileListInfoHashtable)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
var tenantUtil = scope.ServiceProvider.GetService<TenantUtil>();
|
var tenantUtil = scope.ServiceProvider.GetService<TenantUtil>();
|
||||||
@ -518,7 +518,7 @@ namespace ASC.Web.CRM.Services.NotifyService
|
|||||||
|
|
||||||
public void SendAboutResponsibleForOpportunity(Deal deal)
|
public void SendAboutResponsibleForOpportunity(Deal deal)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = _serviceProvider.CreateScope();
|
||||||
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
var notifySource = scope.ServiceProvider.GetService<NotifySource>();
|
||||||
var securityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
var securityContext = scope.ServiceProvider.GetService<SecurityContext>();
|
||||||
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
var client = WorkContext.NotifyContext.NotifyService.RegisterClient(notifySource, scope);
|
||||||
|
@ -47,7 +47,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
private void ImportCaseData(DaoFactory _daoFactory)
|
private void ImportCaseData(DaoFactory _daoFactory)
|
||||||
{
|
{
|
||||||
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
||||||
using (CsvReader csv = ImportFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
using (CsvReader csv = _importFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
||||||
{
|
{
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
findedCases.Add(objCases);
|
findedCases.Add(objCases);
|
||||||
|
|
||||||
if (currentIndex + 1 > ImportFromCSV.MaxRoxCount) break;
|
if (currentIndex + 1 > _importFromCSV.MaxRoxCount) break;
|
||||||
|
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
#region Read csv
|
#region Read csv
|
||||||
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
||||||
{
|
{
|
||||||
CsvReader csv = ImportFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings);
|
CsvReader csv = _importFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings);
|
||||||
|
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
if (currentIndex + 1 > ImportFromCSV.MaxRoxCount) break;
|
if (currentIndex + 1 > _importFromCSV.MaxRoxCount) break;
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
if (String.IsNullOrEmpty(firstName) && String.IsNullOrEmpty(lastName) && String.IsNullOrEmpty(companyName))
|
if (String.IsNullOrEmpty(firstName) && String.IsNullOrEmpty(lastName) && String.IsNullOrEmpty(companyName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Percentage += 1.0 * 100 / (ImportFromCSV.MaxRoxCount * 3);
|
Percentage += 1.0 * 100 / (_importFromCSV.MaxRoxCount * 3);
|
||||||
PublishChanges();
|
PublishChanges();
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,15 +61,15 @@ namespace ASC.Web.CRM.Classes
|
|||||||
private string[] _columns;
|
private string[] _columns;
|
||||||
private bool _IsConfigure;
|
private bool _IsConfigure;
|
||||||
|
|
||||||
public readonly CurrencyProvider _currencyProvider;
|
private readonly CurrencyProvider _currencyProvider;
|
||||||
public readonly NotifyClient _notifyClient;
|
private readonly NotifyClient _notifyClient;
|
||||||
public readonly SettingsManager _settingsManager;
|
private readonly SettingsManager _settingsManager;
|
||||||
public readonly CrmSecurity _crmSecurity;
|
private readonly CrmSecurity _crmSecurity;
|
||||||
public readonly TenantManager _tenantManager;
|
private readonly TenantManager _tenantManager;
|
||||||
public readonly SecurityContext _securityContext;
|
private readonly SecurityContext _securityContext;
|
||||||
public readonly UserManager _userManager;
|
private readonly UserManager _userManager;
|
||||||
public readonly DaoFactory _daoFactory;
|
private readonly DaoFactory _daoFactory;
|
||||||
public readonly ILog _logManager;
|
private readonly ILog _logManager;
|
||||||
|
|
||||||
public ImportDataOperation(Global global,
|
public ImportDataOperation(Global global,
|
||||||
TenantManager tenantManager,
|
TenantManager tenantManager,
|
||||||
|
@ -51,7 +51,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
var allUsers = _userManager.GetUsers(EmployeeStatus.All).ToList();
|
var allUsers = _userManager.GetUsers(EmployeeStatus.All).ToList();
|
||||||
|
|
||||||
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
||||||
using (CsvReader csv = ImportFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
using (CsvReader csv = _importFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
||||||
{
|
{
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
obj.Description = GetPropertyValue("description");
|
obj.Description = GetPropertyValue("description");
|
||||||
|
|
||||||
var csvResponsibleValue = GetPropertyValue("responsible");
|
var csvResponsibleValue = GetPropertyValue("responsible");
|
||||||
var responsible = allUsers.Where(n => n.DisplayUserName(DisplayUserSettingsHelper).Equals(csvResponsibleValue)).FirstOrDefault();
|
var responsible = allUsers.Where(n => n.DisplayUserName(_displayUserSettingsHelper).Equals(csvResponsibleValue)).FirstOrDefault();
|
||||||
|
|
||||||
if (responsible != null)
|
if (responsible != null)
|
||||||
obj.ResponsibleID = responsible.ID;
|
obj.ResponsibleID = responsible.ID;
|
||||||
@ -261,12 +261,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Percentage += 1.0 * 100 / (ImportFromCSV.MaxRoxCount * 2);
|
Percentage += 1.0 * 100 / (_importFromCSV.MaxRoxCount * 2);
|
||||||
PublishChanges();
|
PublishChanges();
|
||||||
|
|
||||||
findedDeals.Add(obj);
|
findedDeals.Add(obj);
|
||||||
|
|
||||||
if (currentIndex + 1 > ImportFromCSV.MaxRoxCount) break;
|
if (currentIndex + 1 > _importFromCSV.MaxRoxCount) break;
|
||||||
|
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
|
|
||||||
|
@ -44,6 +44,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class ImportFromCSV
|
public class ImportFromCSV
|
||||||
{
|
{
|
||||||
|
private readonly ImportDataOperation _importDataOperation;
|
||||||
|
private readonly int _tenantId;
|
||||||
|
private readonly object _syncObj = new object();
|
||||||
|
private readonly DistributedTaskQueue _importQueue;
|
||||||
|
public readonly int MaxRoxCount = 10000;
|
||||||
|
|
||||||
public ImportFromCSV(TenantManager tenantProvider,
|
public ImportFromCSV(TenantManager tenantProvider,
|
||||||
DistributedTaskQueueOptionsManager progressQueueOptionsManager,
|
DistributedTaskQueueOptionsManager progressQueueOptionsManager,
|
||||||
ImportDataOperation importDataOperation)
|
ImportDataOperation importDataOperation)
|
||||||
@ -53,11 +59,6 @@ namespace ASC.Web.CRM.Classes
|
|||||||
_importDataOperation = importDataOperation;
|
_importDataOperation = importDataOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ImportDataOperation _importDataOperation;
|
|
||||||
private readonly int _tenantId;
|
|
||||||
private readonly object _syncObj = new object();
|
|
||||||
private readonly DistributedTaskQueue _importQueue;
|
|
||||||
public readonly int MaxRoxCount = 10000;
|
|
||||||
|
|
||||||
public int GetQuotas()
|
public int GetQuotas()
|
||||||
{
|
{
|
||||||
|
@ -47,23 +47,23 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
public partial class ImportDataOperation
|
public partial class ImportDataOperation
|
||||||
{
|
{
|
||||||
|
private ImportFromCSV _importFromCSV;
|
||||||
|
private TenantUtil _tenantUtil;
|
||||||
|
private DisplayUserSettingsHelper _displayUserSettingsHelper;
|
||||||
|
|
||||||
public ImportDataOperation(TenantUtil tenantUtil,
|
public ImportDataOperation(TenantUtil tenantUtil,
|
||||||
ImportFromCSV importFromCSV,
|
ImportFromCSV importFromCSV,
|
||||||
DisplayUserSettingsHelper displayUserSettingsHelper)
|
DisplayUserSettingsHelper displayUserSettingsHelper)
|
||||||
{
|
{
|
||||||
TenantUtil = tenantUtil;
|
_tenantUtil = tenantUtil;
|
||||||
ImportFromCSV = importFromCSV;
|
_importFromCSV = importFromCSV;
|
||||||
DisplayUserSettingsHelper = displayUserSettingsHelper;
|
_displayUserSettingsHelper = displayUserSettingsHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImportFromCSV ImportFromCSV { get; }
|
|
||||||
public TenantUtil TenantUtil { get; }
|
|
||||||
public DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
|
|
||||||
|
|
||||||
private void ImportTaskData(DaoFactory _daoFactory)
|
private void ImportTaskData(DaoFactory _daoFactory)
|
||||||
{
|
{
|
||||||
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
using (var CSVFileStream = _dataStore.GetReadStream("temp", _csvFileURI))
|
||||||
using (CsvReader csv = ImportFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
using (CsvReader csv = _importFromCSV.CreateCsvReaderInstance(CSVFileStream, _importSettings))
|
||||||
{
|
{
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@ -95,10 +95,10 @@ namespace ASC.Web.CRM.Classes
|
|||||||
if (DateTime.TryParse(GetPropertyValue("due_date"), out deadline))
|
if (DateTime.TryParse(GetPropertyValue("due_date"), out deadline))
|
||||||
obj.DeadLine = deadline;
|
obj.DeadLine = deadline;
|
||||||
else
|
else
|
||||||
obj.DeadLine = TenantUtil.DateTimeNow();
|
obj.DeadLine = _tenantUtil.DateTimeNow();
|
||||||
|
|
||||||
var csvResponsibleValue = GetPropertyValue("responsible");
|
var csvResponsibleValue = GetPropertyValue("responsible");
|
||||||
var responsible = allUsers.Where(n => n.DisplayUserName(DisplayUserSettingsHelper).Equals(csvResponsibleValue)).FirstOrDefault();
|
var responsible = allUsers.Where(n => n.DisplayUserName(_displayUserSettingsHelper).Equals(csvResponsibleValue)).FirstOrDefault();
|
||||||
|
|
||||||
if (responsible != null)
|
if (responsible != null)
|
||||||
obj.ResponsibleID = responsible.ID;
|
obj.ResponsibleID = responsible.ID;
|
||||||
@ -163,7 +163,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
findedTasks.Add(obj);
|
findedTasks.Add(obj);
|
||||||
|
|
||||||
if ((currentIndex + 1) > ImportFromCSV.MaxRoxCount) break;
|
if ((currentIndex + 1) > _importFromCSV.MaxRoxCount) break;
|
||||||
|
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
|
|
||||||
|
@ -94,7 +94,6 @@ namespace ASC.Web.CRM.Classes
|
|||||||
private SecurityContext _securityContext;
|
private SecurityContext _securityContext;
|
||||||
private TenantUtil _tenantUtil;
|
private TenantUtil _tenantUtil;
|
||||||
|
|
||||||
|
|
||||||
public object Error { get; set; }
|
public object Error { get; set; }
|
||||||
|
|
||||||
private SendBatchEmailsOperation()
|
private SendBatchEmailsOperation()
|
||||||
|
@ -49,6 +49,15 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class PdfCreator
|
public class PdfCreator
|
||||||
{
|
{
|
||||||
|
private InvoiceFormattedData _invoiceFormattedData;
|
||||||
|
private DaoFactory _daoFactory;
|
||||||
|
private IServiceProvider _serviceProvider;
|
||||||
|
private DocumentServiceConnector _documentServiceConnector;
|
||||||
|
private OrganisationLogoManager _organisationLogoManager;
|
||||||
|
private Files.Classes.PathProvider _filesPathProvider;
|
||||||
|
private ILog _logger;
|
||||||
|
|
||||||
|
|
||||||
public PdfCreator(IOptionsMonitor<ILog> logger,
|
public PdfCreator(IOptionsMonitor<ILog> logger,
|
||||||
Files.Classes.PathProvider filesPathProvider,
|
Files.Classes.PathProvider filesPathProvider,
|
||||||
DocumentServiceConnector documentServiceConnector,
|
DocumentServiceConnector documentServiceConnector,
|
||||||
@ -57,20 +66,17 @@ namespace ASC.Web.CRM.Classes
|
|||||||
DaoFactory daoFactory,
|
DaoFactory daoFactory,
|
||||||
InvoiceFormattedData invoiceFormattedData)
|
InvoiceFormattedData invoiceFormattedData)
|
||||||
{
|
{
|
||||||
FilesPathProvider = filesPathProvider;
|
_filesPathProvider = filesPathProvider;
|
||||||
|
|
||||||
Logger = logger.Get("ASC.CRM");
|
_logger = logger.Get("ASC.CRM");
|
||||||
|
|
||||||
DocumentServiceConnector = documentServiceConnector;
|
_documentServiceConnector = documentServiceConnector;
|
||||||
ServiceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
OrganisationLogoManager = organisationLogoManager;
|
_organisationLogoManager = organisationLogoManager;
|
||||||
DaoFactory = daoFactory;
|
_daoFactory = daoFactory;
|
||||||
InvoiceFormattedData = invoiceFormattedData;
|
_invoiceFormattedData = invoiceFormattedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvoiceFormattedData InvoiceFormattedData { get; }
|
|
||||||
|
|
||||||
public DaoFactory DaoFactory { get; }
|
|
||||||
|
|
||||||
private Stream Template
|
private Stream Template
|
||||||
{
|
{
|
||||||
@ -81,12 +87,6 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IServiceProvider ServiceProvider { get; }
|
|
||||||
public DocumentServiceConnector DocumentServiceConnector { get; }
|
|
||||||
public OrganisationLogoManager OrganisationLogoManager { get; }
|
|
||||||
public Files.Classes.PathProvider FilesPathProvider { get; }
|
|
||||||
|
|
||||||
public ILog Logger { get; }
|
|
||||||
|
|
||||||
private const string FormatPdf = ".pdf";
|
private const string FormatPdf = ".pdf";
|
||||||
private const string FormatDocx = ".docx";
|
private const string FormatDocx = ".docx";
|
||||||
@ -95,20 +95,20 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
public void CreateAndSaveFile(int invoiceId)
|
public void CreateAndSaveFile(int invoiceId)
|
||||||
{
|
{
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}", invoiceId);
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}", invoiceId);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var invoice = DaoFactory.GetInvoiceDao().GetByID(invoiceId);
|
var invoice = _daoFactory.GetInvoiceDao().GetByID(invoiceId);
|
||||||
|
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
{
|
{
|
||||||
Logger.Warn(CRMErrorsResource.InvoiceNotFound + ". Invoice ID = " + invoiceId);
|
_logger.Warn(CRMErrorsResource.InvoiceNotFound + ". Invoice ID = " + invoiceId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. Convertation", invoiceId);
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. Convertation", invoiceId);
|
||||||
|
|
||||||
string urlToFile;
|
string urlToFile;
|
||||||
|
|
||||||
@ -117,13 +117,13 @@ namespace ASC.Web.CRM.Classes
|
|||||||
urlToFile = GetUrlToFile(docxStream);
|
urlToFile = GetUrlToFile(docxStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. UrlToFile = {1}", invoiceId,
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. UrlToFile = {1}", invoiceId,
|
||||||
urlToFile);
|
urlToFile);
|
||||||
|
|
||||||
var file = ServiceProvider.GetService<File<int>>();
|
var file = _serviceProvider.GetService<File<int>>();
|
||||||
|
|
||||||
file.Title = string.Format("{0}{1}", invoice.Number, FormatPdf);
|
file.Title = string.Format("{0}{1}", invoice.Number, FormatPdf);
|
||||||
file.FolderID = DaoFactory.GetFileDao().GetRoot();
|
file.FolderID = _daoFactory.GetFileDao().GetRoot();
|
||||||
|
|
||||||
var request = WebRequest.Create(urlToFile);
|
var request = WebRequest.Create(urlToFile);
|
||||||
|
|
||||||
@ -132,8 +132,8 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
file.ContentLength = response.ContentLength;
|
file.ContentLength = response.ContentLength;
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. SaveFile", invoiceId);
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. SaveFile", invoiceId);
|
||||||
file = DaoFactory.GetFileDao().SaveFile(file, stream);
|
file = _daoFactory.GetFileDao().SaveFile(file, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file == null)
|
if (file == null)
|
||||||
@ -143,17 +143,17 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
invoice.FileID = Int32.Parse(file.ID.ToString());
|
invoice.FileID = Int32.Parse(file.ID.ToString());
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. UpdateInvoiceFileID. FileID = {1}", invoiceId, file.ID);
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. UpdateInvoiceFileID. FileID = {1}", invoiceId, file.ID);
|
||||||
|
|
||||||
DaoFactory.GetInvoiceDao().UpdateInvoiceFileID(invoice.ID, invoice.FileID);
|
_daoFactory.GetInvoiceDao().UpdateInvoiceFileID(invoice.ID, invoice.FileID);
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. AttachFiles. FileID = {1}", invoiceId, file.ID);
|
_logger.DebugFormat("PdfCreator. CreateAndSaveFile. Invoice ID = {0}. AttachFiles. FileID = {1}", invoiceId, file.ID);
|
||||||
|
|
||||||
DaoFactory.GetRelationshipEventDao().AttachFiles(invoice.ContactID, invoice.EntityType, invoice.EntityID, new[] { invoice.FileID });
|
_daoFactory.GetRelationshipEventDao().AttachFiles(invoice.ContactID, invoice.EntityType, invoice.EntityID, new[] { invoice.FileID });
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error(e);
|
_logger.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error(e);
|
_logger.Error(e);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
@ -178,19 +178,19 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
private string GetUrlToFile(Stream docxStream)
|
private string GetUrlToFile(Stream docxStream)
|
||||||
{
|
{
|
||||||
var externalUri = FilesPathProvider.GetTempUrl(docxStream, FormatDocx);
|
var externalUri = _filesPathProvider.GetTempUrl(docxStream, FormatDocx);
|
||||||
|
|
||||||
externalUri = DocumentServiceConnector.ReplaceCommunityAdress(externalUri);
|
externalUri = _documentServiceConnector.ReplaceCommunityAdress(externalUri);
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. GetUrlToFile. externalUri = {0}", externalUri);
|
_logger.DebugFormat("PdfCreator. GetUrlToFile. externalUri = {0}", externalUri);
|
||||||
|
|
||||||
var revisionId = DocumentServiceConnector.GenerateRevisionId(Guid.NewGuid().ToString());
|
var revisionId = DocumentServiceConnector.GenerateRevisionId(Guid.NewGuid().ToString());
|
||||||
|
|
||||||
string urlToFile;
|
string urlToFile;
|
||||||
|
|
||||||
DocumentServiceConnector.GetConvertedUri(externalUri, FormatDocx, FormatPdf, revisionId, null, false, out urlToFile);
|
_documentServiceConnector.GetConvertedUri(externalUri, FormatDocx, FormatPdf, revisionId, null, false, out urlToFile);
|
||||||
|
|
||||||
Logger.DebugFormat("PdfCreator. GetUrlToFile. urlToFile = {0}", urlToFile);
|
_logger.DebugFormat("PdfCreator. GetUrlToFile. urlToFile = {0}", urlToFile);
|
||||||
|
|
||||||
return urlToFile;
|
return urlToFile;
|
||||||
|
|
||||||
@ -200,15 +200,15 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
using (var docxStream = GetStreamDocx(data))
|
using (var docxStream = GetStreamDocx(data))
|
||||||
{
|
{
|
||||||
var externalUri = FilesPathProvider.GetTempUrl(docxStream, FormatDocx);
|
var externalUri = _filesPathProvider.GetTempUrl(docxStream, FormatDocx);
|
||||||
|
|
||||||
externalUri = DocumentServiceConnector.ReplaceCommunityAdress(externalUri);
|
externalUri = _documentServiceConnector.ReplaceCommunityAdress(externalUri);
|
||||||
|
|
||||||
var revisionId = DocumentServiceConnector.GenerateRevisionId(Guid.NewGuid().ToString());
|
var revisionId = DocumentServiceConnector.GenerateRevisionId(Guid.NewGuid().ToString());
|
||||||
|
|
||||||
string urlToFile;
|
string urlToFile;
|
||||||
|
|
||||||
DocumentServiceConnector.GetConvertedUri(externalUri, FormatDocx, FormatPdf, revisionId, null, true, out urlToFile);
|
_documentServiceConnector.GetConvertedUri(externalUri, FormatDocx, FormatPdf, revisionId, null, true, out urlToFile);
|
||||||
|
|
||||||
return new ConverterData
|
return new ConverterData
|
||||||
{
|
{
|
||||||
@ -228,14 +228,14 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
string urlToFile;
|
string urlToFile;
|
||||||
|
|
||||||
DocumentServiceConnector.GetConvertedUri(data.StorageUrl, FormatDocx, FormatPdf, data.RevisionId, null, true, out urlToFile);
|
_documentServiceConnector.GetConvertedUri(data.StorageUrl, FormatDocx, FormatPdf, data.RevisionId, null, true, out urlToFile);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(urlToFile))
|
if (string.IsNullOrEmpty(urlToFile))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var invoice = DaoFactory.GetInvoiceDao().GetByID(data.InvoiceId);
|
var invoice = _daoFactory.GetInvoiceDao().GetByID(data.InvoiceId);
|
||||||
|
|
||||||
return SaveFile(invoice, urlToFile, daoFactory);
|
return SaveFile(invoice, urlToFile, daoFactory);
|
||||||
}
|
}
|
||||||
@ -252,10 +252,10 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
var document = ServiceProvider.GetService<File<int>>();
|
var document = _serviceProvider.GetService<File<int>>();
|
||||||
|
|
||||||
document.Title = string.Format("{0}{1}", data.Number, FormatPdf);
|
document.Title = string.Format("{0}{1}", data.Number, FormatPdf);
|
||||||
document.FolderID = DaoFactory.GetFileDao().GetRoot();
|
document.FolderID = _daoFactory.GetFileDao().GetRoot();
|
||||||
document.ContentLength = response.ContentLength;
|
document.ContentLength = response.ContentLength;
|
||||||
|
|
||||||
if (data.GetInvoiceFile(daoFactory) != null)
|
if (data.GetInvoiceFile(daoFactory) != null)
|
||||||
@ -263,7 +263,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
document.ID = data.FileID;
|
document.ID = data.FileID;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = DaoFactory.GetFileDao().SaveFile(document, stream);
|
file = _daoFactory.GetFileDao().SaveFile(document, stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,7 +273,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
private Stream GetStreamDocx(Invoice data)
|
private Stream GetStreamDocx(Invoice data)
|
||||||
{
|
{
|
||||||
var invoiceData = InvoiceFormattedData.GetData(data, 0, 0);
|
var invoiceData = _invoiceFormattedData.GetData(data, 0, 0);
|
||||||
var logo = new byte[] { };
|
var logo = new byte[] { };
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(invoiceData.LogoBase64))
|
if (!string.IsNullOrEmpty(invoiceData.LogoBase64))
|
||||||
@ -282,7 +282,7 @@ namespace ASC.Web.CRM.Classes
|
|||||||
}
|
}
|
||||||
else if (invoiceData.LogoBase64Id != 0)
|
else if (invoiceData.LogoBase64Id != 0)
|
||||||
{
|
{
|
||||||
logo = Convert.FromBase64String(OrganisationLogoManager.GetOrganisationLogoBase64(invoiceData.LogoBase64Id));
|
logo = Convert.FromBase64String(_organisationLogoManager.GetOrganisationLogoBase64(invoiceData.LogoBase64Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new MemoryStream();
|
var result = new MemoryStream();
|
||||||
|
@ -48,23 +48,23 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Transient]
|
[Transient]
|
||||||
public class PdfQueueWorker
|
public class PdfQueueWorker
|
||||||
{
|
{
|
||||||
private readonly DistributedTaskQueue Queue;
|
private readonly DistributedTaskQueue _queue;
|
||||||
private readonly int tenantId;
|
private readonly int _tenantId;
|
||||||
private readonly Guid userId;
|
private readonly Guid _userId;
|
||||||
private readonly object Locker = new object();
|
private readonly object Locker = new object();
|
||||||
|
private PdfProgressItem _pdfProgressItem;
|
||||||
|
|
||||||
public PdfQueueWorker(DistributedTaskQueueOptionsManager queueOptions,
|
public PdfQueueWorker(DistributedTaskQueueOptionsManager queueOptions,
|
||||||
PdfProgressItem pdfProgressItem,
|
PdfProgressItem pdfProgressItem,
|
||||||
TenantManager tenantProvider,
|
TenantManager tenantProvider,
|
||||||
SecurityContext securityContext)
|
SecurityContext securityContext)
|
||||||
{
|
{
|
||||||
Queue = queueOptions.Get<PdfProgressItem>();
|
_queue = queueOptions.Get<PdfProgressItem>();
|
||||||
PdfProgressItem = pdfProgressItem;
|
_pdfProgressItem = pdfProgressItem;
|
||||||
tenantId = tenantProvider.GetCurrentTenant().TenantId;
|
_tenantId = tenantProvider.GetCurrentTenant().TenantId;
|
||||||
userId = securityContext.CurrentAccount.ID;
|
_userId = securityContext.CurrentAccount.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PdfProgressItem PdfProgressItem { get; }
|
|
||||||
|
|
||||||
public string GetTaskId(int tenantId, int invoiceId)
|
public string GetTaskId(int tenantId, int invoiceId)
|
||||||
{
|
{
|
||||||
@ -75,35 +75,35 @@ namespace ASC.Web.CRM.Classes
|
|||||||
{
|
{
|
||||||
var id = GetTaskId(tenantId, invoiceId);
|
var id = GetTaskId(tenantId, invoiceId);
|
||||||
|
|
||||||
var findedItem = Queue.GetTasks<PdfProgressItem>().FirstOrDefault(x => x.Id == id);
|
var findedItem = _queue.GetTasks<PdfProgressItem>().FirstOrDefault(x => x.Id == id);
|
||||||
|
|
||||||
return findedItem;
|
return findedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TerminateTask(int invoiceId)
|
public void TerminateTask(int invoiceId)
|
||||||
{
|
{
|
||||||
var item = GetTaskStatus(tenantId, invoiceId);
|
var item = GetTaskStatus(_tenantId, invoiceId);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
Queue.RemoveTask(item.Id);
|
_queue.RemoveTask(item.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PdfProgressItem StartTask(int invoiceId)
|
public PdfProgressItem StartTask(int invoiceId)
|
||||||
{
|
{
|
||||||
lock (Locker)
|
lock (Locker)
|
||||||
{
|
{
|
||||||
var task = GetTaskStatus(tenantId, invoiceId);
|
var task = GetTaskStatus(_tenantId, invoiceId);
|
||||||
|
|
||||||
if (task != null && task.IsCompleted)
|
if (task != null && task.IsCompleted)
|
||||||
{
|
{
|
||||||
Queue.RemoveTask(task.Id);
|
_queue.RemoveTask(task.Id);
|
||||||
task = null;
|
task = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (task == null)
|
if (task == null)
|
||||||
{
|
{
|
||||||
PdfProgressItem.Configure(GetTaskId(tenantId, invoiceId), tenantId, userId, invoiceId);
|
_pdfProgressItem.Configure(GetTaskId(_tenantId, invoiceId), _tenantId, _userId, invoiceId);
|
||||||
Queue.QueueTask(PdfProgressItem);
|
_queue.QueueTask(_pdfProgressItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,17 @@ namespace ASC.Web.CRM.Classes
|
|||||||
[Scope]
|
[Scope]
|
||||||
public class ReportHelper
|
public class ReportHelper
|
||||||
{
|
{
|
||||||
|
private CurrencyProvider _currencyProvider;
|
||||||
|
private IHttpContextAccessor _httpContext;
|
||||||
|
private SecurityContext _securityContext;
|
||||||
|
private DocbuilderReportsUtilityHelper _docbuilderReportsUtilityHelper;
|
||||||
|
private DaoFactory _daoFactory;
|
||||||
|
private IServiceProvider _serviceProvider;
|
||||||
|
private Global _global;
|
||||||
|
private SettingsManager _settingsManager;
|
||||||
|
private TenantUtil _tenantUtil;
|
||||||
|
private TenantManager _tenantManager;
|
||||||
|
|
||||||
public ReportHelper(TenantManager tenantManager,
|
public ReportHelper(TenantManager tenantManager,
|
||||||
TenantUtil tenantUtil,
|
TenantUtil tenantUtil,
|
||||||
Global global,
|
Global global,
|
||||||
@ -59,29 +70,18 @@ namespace ASC.Web.CRM.Classes
|
|||||||
CurrencyProvider currencyProvider
|
CurrencyProvider currencyProvider
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
TenantManager = tenantManager;
|
_tenantManager = tenantManager;
|
||||||
TenantUtil = tenantUtil;
|
_tenantUtil = tenantUtil;
|
||||||
Global = global;
|
_global = global;
|
||||||
SettingsManager = settingsManager;
|
_settingsManager = settingsManager;
|
||||||
ServiceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
DaoFactory = daoFactory;
|
_daoFactory = daoFactory;
|
||||||
DocbuilderReportsUtilityHelper = docbuilderReportsUtilityHelper;
|
_docbuilderReportsUtilityHelper = docbuilderReportsUtilityHelper;
|
||||||
SecurityContext = securityContext;
|
_securityContext = securityContext;
|
||||||
HttpContext = httpContextAccessor;
|
_httpContext = httpContextAccessor;
|
||||||
CurrencyProvider = currencyProvider;
|
_currencyProvider = currencyProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CurrencyProvider CurrencyProvider { get; }
|
|
||||||
public IHttpContextAccessor HttpContext { get; }
|
|
||||||
public SecurityContext SecurityContext { get; }
|
|
||||||
public DocbuilderReportsUtilityHelper DocbuilderReportsUtilityHelper { get; }
|
|
||||||
public DaoFactory DaoFactory { get; }
|
|
||||||
public IServiceProvider ServiceProvider { get; }
|
|
||||||
|
|
||||||
public Global Global { get; }
|
|
||||||
public SettingsManager SettingsManager { get; }
|
|
||||||
public TenantUtil TenantUtil { get; }
|
|
||||||
public TenantManager TenantManager { get; }
|
|
||||||
private string GetFileName(ReportType reportType)
|
private string GetFileName(ReportType reportType)
|
||||||
{
|
{
|
||||||
string reportName;
|
string reportName;
|
||||||
@ -125,13 +125,13 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
return string.Format("{0} ({1} {2}).xlsx",
|
return string.Format("{0} ({1} {2}).xlsx",
|
||||||
reportName,
|
reportName,
|
||||||
TenantUtil.DateTimeNow().ToShortDateString(),
|
_tenantUtil.DateTimeNow().ToShortDateString(),
|
||||||
TenantUtil.DateTimeNow().ToShortTimeString());
|
_tenantUtil.DateTimeNow().ToShortTimeString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckReportData(ReportType reportType, ReportTimePeriod timePeriod, Guid[] managers)
|
public bool CheckReportData(ReportType reportType, ReportTimePeriod timePeriod, Guid[] managers)
|
||||||
{
|
{
|
||||||
var reportDao = DaoFactory.GetReportDao();
|
var reportDao = _daoFactory.GetReportDao();
|
||||||
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
@ -164,23 +164,23 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
public List<string> GetMissingRates(ReportType reportType)
|
public List<string> GetMissingRates(ReportType reportType)
|
||||||
{
|
{
|
||||||
var reportDao = DaoFactory.GetReportDao();
|
var reportDao = _daoFactory.GetReportDao();
|
||||||
|
|
||||||
if (reportType == ReportType.WorkloadByTasks || reportType == ReportType.WorkloadByInvoices ||
|
if (reportType == ReportType.WorkloadByTasks || reportType == ReportType.WorkloadByInvoices ||
|
||||||
reportType == ReportType.WorkloadByContacts || reportType == ReportType.WorkloadByVoip) return null;
|
reportType == ReportType.WorkloadByContacts || reportType == ReportType.WorkloadByVoip) return null;
|
||||||
|
|
||||||
var crmSettings = SettingsManager.Load<CrmSettings>();
|
var crmSettings = _settingsManager.Load<CrmSettings>();
|
||||||
var defaultCurrency = CurrencyProvider.Get(crmSettings.DefaultCurrency);
|
var defaultCurrency = _currencyProvider.Get(crmSettings.DefaultCurrency);
|
||||||
|
|
||||||
return reportDao.GetMissingRates(defaultCurrency.Abbreviation);
|
return reportDao.GetMissingRates(defaultCurrency.Abbreviation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private object GetReportData(ReportType reportType, ReportTimePeriod timePeriod, Guid[] managers)
|
private object GetReportData(ReportType reportType, ReportTimePeriod timePeriod, Guid[] managers)
|
||||||
{
|
{
|
||||||
var crmSettings = SettingsManager.Load<CrmSettings>();
|
var crmSettings = _settingsManager.Load<CrmSettings>();
|
||||||
|
|
||||||
var reportDao = DaoFactory.GetReportDao();
|
var reportDao = _daoFactory.GetReportDao();
|
||||||
var defaultCurrency = CurrencyProvider.Get(crmSettings.DefaultCurrency).Abbreviation;
|
var defaultCurrency = _currencyProvider.Get(crmSettings.DefaultCurrency).Abbreviation;
|
||||||
|
|
||||||
switch (reportType)
|
switch (reportType)
|
||||||
{
|
{
|
||||||
@ -227,15 +227,15 @@ namespace ASC.Web.CRM.Classes
|
|||||||
|
|
||||||
using (var stream = new System.IO.MemoryStream(data))
|
using (var stream = new System.IO.MemoryStream(data))
|
||||||
{
|
{
|
||||||
var document = ServiceProvider.GetService<File<int>>();
|
var document = _serviceProvider.GetService<File<int>>();
|
||||||
|
|
||||||
document.Title = state.FileName;
|
document.Title = state.FileName;
|
||||||
document.FolderID = DaoFactory.GetFileDao().GetRoot();
|
document.FolderID = _daoFactory.GetFileDao().GetRoot();
|
||||||
document.ContentLength = stream.Length;
|
document.ContentLength = stream.Length;
|
||||||
|
|
||||||
var file = DaoFactory.GetFileDao().SaveFile(document, stream);
|
var file = _daoFactory.GetFileDao().SaveFile(document, stream);
|
||||||
|
|
||||||
DaoFactory.GetReportDao().SaveFile((int)file.ID, state.ReportType);
|
_daoFactory.GetReportDao().SaveFile((int)file.ID, state.ReportType);
|
||||||
|
|
||||||
state.FileId = (int)file.ID;
|
state.FileId = (int)file.ID;
|
||||||
}
|
}
|
||||||
@ -264,12 +264,12 @@ namespace ASC.Web.CRM.Classes
|
|||||||
ReportOrigin.CRM,
|
ReportOrigin.CRM,
|
||||||
SaveReportFile,
|
SaveReportFile,
|
||||||
null,
|
null,
|
||||||
TenantManager.GetCurrentTenant().TenantId,
|
_tenantManager.GetCurrentTenant().TenantId,
|
||||||
SecurityContext.CurrentAccount.ID);
|
_securityContext.CurrentAccount.ID);
|
||||||
|
|
||||||
var state = new ReportState(ServiceProvider, reportStateData, HttpContext);
|
var state = new ReportState(_serviceProvider, reportStateData, _httpContext);
|
||||||
|
|
||||||
DocbuilderReportsUtilityHelper.Enqueue(state);
|
_docbuilderReportsUtilityHelper.Enqueue(state);
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user