#ismcagdas thanks
1 Step :
private async void ProcessReceiptTransfer(VoucherPostingDto input)
{
var receiptHeader = _porecHeaderRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId
&& o.DocNo >= input.FromDoc && o.DocNo <= input.ToDoc && o.Posted == false).ToList();
foreach (var item in receiptHeader)
{
CreateOrEditPORECHeaderDto receipt = new CreateOrEditPORECHeaderDto()
{
Id = item.Id
};
await _receiptEntryAppService.ProcessReceiptEntry(receipt);
}
}
2 Step:
public async Task<string> ProcessReceiptEntry(CreateOrEditPORECHeaderDto input)
{
var alertMsg = "";
var currency = _voucherEntryAppService.GetBaseCurrency();
var user = _userRepository.GetAll().Where(o => o.Id == AbpSession.UserId).SingleOrDefault().UserName;
var transBook = _icSetupRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId).SingleOrDefault().TRBookID;
var receiptHeader = _porecHeaderRepository.FirstOrDefault(o => o.TenantId == AbpSession.TenantId && o.Id == input.Id);
var receiptDetail = _porecDetailRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId && o.DetID == input.Id);
var icItem = _itemRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId);
string narration = receiptHeader.Narration;
var additionalData = _icrecaExpRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId && o.LocID == input.LocID && o.DocNo == input.DocNo);
List<CreateOrEditGLTRDetailDto> gltrdetailsList = new List<CreateOrEditGLTRDetailDto>();
var transferDetailList = from o in receiptDetail
join i in icItem on new { A = o.ItemID, B = o.TenantId } equals new { A = i.ItemId, B = i.TenantId }
group o by new { i.Seg1Id } into gd
select new PORECDetailDto
{
Amount = gd.Sum(x => x.Amount),
ItemID = gd.Key.Seg1Id,
};
foreach (var item in transferDetailList)
{
var caID = _inventoryGlLinkRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId && o.LocID == receiptHeader.LocID && o.SegID == item.ItemID).FirstOrDefault().AccRec;
var daID = _inventoryGlLinkRepository.GetAll().Where(o => o.TenantId == AbpSession.TenantId && o.LocID == receiptHeader.LocID && o.SegID == item.ItemID).FirstOrDefault().AccRec;
//Credit Amount
gltrdetailsList.Add(new CreateOrEditGLTRDetailDto
{
Amount = -Convert.ToDouble(item.Amount),
AccountID = caID,
Narration = narration,
SubAccID = 0,
LocId = receiptHeader.LocID,
IsAuto = true
});
//Debit Amount
gltrdetailsList.Add(new CreateOrEditGLTRDetailDto
{
Amount = Convert.ToDouble(item.Amount),
AccountID = daID,
Narration = narration,
SubAccID = 0,
LocId = Convert.ToInt32(receiptHeader.LocID),
IsAuto = false
});
}
foreach (var item in additionalData)
{
//Debit Amount
gltrdetailsList.Add(new CreateOrEditGLTRDetailDto
{
Amount = Convert.ToDouble(item.Amount),
AccountID = item.AccountID,
Narration = narration,
SubAccID = 0,
LocId = Convert.ToInt32(item.LocID),
IsAuto = false
});
}
VoucherEntryDto autoEntry = new VoucherEntryDto()
{
GLTRHeader = new CreateOrEditGLTRHeaderDto
{
BookID = transBook,
NARRATION = narration,
DocDate = Convert.ToDateTime(receiptHeader.DocDate),
DocMonth = Convert.ToDateTime(receiptHeader.DocDate).Month,
Approved = true,
AprovedBy = user,
AprovedDate = DateTime.Now,
Posted = false,
LocId = receiptHeader.LocID,
CreatedBy = user,
CreatedOn = DateTime.Now,
AuditUser = user,
AuditTime = DateTime.Now,
CURID = currency.Id,
CURRATE = currency.CurrRate,
ConfigID = 0
},
GLTRDetail = gltrdetailsList
};
if (autoEntry.GLTRDetail.Count() > 0 && autoEntry.GLTRHeader != null)
{
var voucher = await _voucherEntryAppService.ProcessVoucherEntry(autoEntry);
receiptHeader.Posted = true;
//receiptHeader.PostedBy = user;
// receiptHeader.PostedDate = DateTime.Now;
receiptHeader.LinkDetID = voucher[0].Id;
var transh = await _porecHeaderRepository.FirstOrDefaultAsync((int)receiptHeader.Id);
ObjectMapper.Map(receiptHeader, transh);
alertMsg = "Save";
}
else
{
alertMsg = "NoRecord";
}
return alertMsg;
}
3 Step:
public async Task<List<GLTRHeaderDto>> ProcessVoucherEntry(VoucherEntryDto input)
{
var gltrHeader = ObjectMapper.Map<GLTRHeader>(input.GLTRHeader);
if (AbpSession.TenantId != null)
{
gltrHeader.TenantId = (int)AbpSession.TenantId;
}
gltrHeader.DocNo = GetMaxDocId(input.GLTRHeader.BookID);
var getGenratedId = await _gltrHeaderRepository.InsertAndGetIdAsync(gltrHeader);
foreach (var item in input.GLTRDetail)
{
var gltrDetail = ObjectMapper.Map<GLTRDetail>(item);
if (AbpSession.TenantId != null)
{
gltrDetail.TenantId = (int)AbpSession.TenantId;
}
gltrDetail.LocId = input.GLTRHeader.LocId;
gltrDetail.DetID = getGenratedId;
await _gltrDetailRepository.InsertAsync(gltrDetail);
}
List<GLTRHeaderDto> returnList = new List<GLTRHeaderDto>();
returnList.Add(new GLTRHeaderDto
{
Id=getGenratedId,
DocNo = gltrHeader.DocNo,
LocId=gltrHeader.LocId
});
return returnList;
}
.net core and angular
There is a problem when we are running different transactions and jumping from one appservice to the other but some how following error arises with in the transactions: : 'Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'ERPDbContext'.' Please explain
i have report module in which a component reportview uses the ssrs-reportviewer custom element tag. in report module everything work fine but when i switch to other module and try to access reportview component from report module errror occurred . i am using asp.net core and angular 7 plz check the error in picture
@maliming thanks . :)
when i upload custom logo (logo display perfactly ) but browser console window shows error(GET http://localhost:4200/undefined/TenantCustomization/GetTenantLogo?skin=dark&tenantId=39&id=3c2eb6e1-49eb-9ea5-2641-39f1c41c8d13 404 (Not Found))
After uploading application logo this error occurred.
Failed to load resource: the server responded with a status of 404 (Not Found)
Funtion GetTenantLogo API http://localhost:4200/undefined/TenantCustomization/GetTenantLogo?skin=dark&tenantId=39&id=3c2eb6e1-49eb-9ea5-2641-39f1c41c8d13
i see the demo .. here is my code
public class DbPerTenantConnectionStringResolver : DefaultConnectionStringResolver
{
private readonly ICurrentUnitOfWorkProvider _currentUnitOfWorkProvider;
private readonly IConfigurationRoot _appConfiguration;
private readonly IDBPerTenantAppService _IDBPerTenantAppService;
public IAbpSession AbpSession { get; set; }
public DbPerTenantConnectionStringResolver(ICurrentUnitOfWorkProvider currentUnitOfWorkProvider, IDBPerTenantAppService iDBPerTenantAppService, IAbpStartupConfiguration configuration, IHostingEnvironment hostingEnvironment)
: base(configuration)
{
_currentUnitOfWorkProvider = currentUnitOfWorkProvider;
_IDBPerTenantAppService = iDBPerTenantAppService;
AbpSession = NullAbpSession.Instance;
_appConfiguration =
AppConfigurations.Get(hostingEnvironment.ContentRootPath, hostingEnvironment.EnvironmentName);
}
public override string GetNameOrConnectionString(ConnectionStringResolveArgs args)
{
if (args["DbContextConcreteType"] as Type == typeof(INVDbContext))
{
var connctions = _IDBPerTenantAppService.GetAllConnections((int)GetCurrentTenantId(), "INV");
return connctions.Result.Items[0].VConnectionString; //_appConfiguration.GetConnectionString(ERPConsts.SecondDbConnectionStringName);
}
return base.GetNameOrConnectionString(args);
}
protected virtual int? GetCurrentTenantId()
{
return _currentUnitOfWorkProvider.Current != null
? _currentUnitOfWorkProvider.Current.GetTenantId()
: AbpSession.TenantId;
}
}
i have seperate databases for according to module (InventoryDb, PayrolDb, FinanceDb) and im getting the connectionstring from database table(abpConnection) . it works good. @maliming see the code for better suggestion.
i have two or more databases on different servers . server and database information saved in tenant table .. i want to change db context dynamically according to tenant at run time . i see this #4838 issue . but i can't understand how can i achieve this.