/// <summary> /// Performs business logic actions specified for this task handler. /// </summary> protected override void PerformActions() { ClearTemporaryDocumentMedia(); DateTime dateToConsider = Utils.Today.Date; TimeSpan ts; if (TimeSpan.TryParse(Utils.GetSystemValue("AgentExecutionTime"), out ts)) { if (Utils.Now < (Utils.Today + ts)) { dateToConsider = dateToConsider.AddDays(-1); } } ProjectUsageHandler.CreatePaymentSummaries(dateToConsider); //Monthly retry process with in the Graceperiod ProjectFinanceHandler.ProcessInvoicesAndPayments(0, dateToConsider, false, 0); // Run CompanyStatusHandler and ProjectStatusHandler in same datacontext using (StageBitzDB dataContext = new StageBitzDB()) { ProjectStatusHandler.UpdateProjectExpirations(dateToConsider, dataContext); CompanyStatusHandler.UpdateCompanyExpirations(dateToConsider, dataContext); dataContext.SaveChanges(); } CompanyStatusHandler.SuspendNoPaymentOptionCompanies(dateToConsider); SendUserEmailNotifications(dateToConsider); SendBookingNotifications(); SendBookingOverdueAndDelayedEmails(dateToConsider.AddDays(1)); DeleteOldExportedZipFiles(); }
/// <summary> /// Clears the temporary document media. /// </summary> private void ClearTemporaryDocumentMedia() { using (StageBitzDB dataContext = new StageBitzDB()) { dataContext.DeleteUnusedDocumentMedia("Company"); } }
public BookingResponse ReleaseItem(BookingDetailInfor bookingDetailInfor) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); ItemBooking itemBooking = inventoryBL.GetItemBooking(bookingDetailInfor.ItemBookingId); BookingResponse bookingResponse = new BookingResponse(); if (itemBooking != null) { if (itemBooking != null && (!(Utils.IsCompanyInventoryAdmin(itemBooking.Item.CompanyId.Value, bookingDetailInfor.UserId) || Utils.IsCompanyInventoryStaffMember(itemBooking.Item.CompanyId.Value, bookingDetailInfor.UserId, itemBooking.Item.LocationId, dataContext)))) { bookingResponse.Status = "NOTOK"; bookingResponse.ErrorCode = (int)ErrorCodes.NoEditPermissionForInventory; bookingResponse.Message = "Could not release the Item."; return(bookingResponse); } bool isSuccess = inventoryBL.RemoveInUseItemFromItemBrief(itemBooking.RelatedId, bookingDetailInfor.UserId); bookingResponse.Status = isSuccess ? "OK" : "NOTOK"; } else { bookingResponse.Status = "NOTOK"; } return(bookingResponse); } }
/// <summary> /// Gets the countries. /// </summary> /// <param name="systemValueName">Name of the system value.</param> /// <returns></returns> public static string GetCountries(string systemValueName) { using (StageBitzDB dataContext = new StageBitzDB()) { return(SystemCache.SystemValues[systemValueName]); } }
/// <summary> /// Gets all initialize data for user. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns></returns> public static MobileInitialData GetAllInitializeDataForUser(int userId) { using (StageBitzDB dataContext = new StageBitzDB()) { MobileInitialData mobileInitialData = new MobileInitialData(); //Get the Companies that the user can access CompanyBL companyBL = new CompanyBL(dataContext); List <CompanyListInfo> companyList = companyBL.GetCompanyList(userId, false, false, true); var extractedcompanyList = (from cl in companyList select new CompanyListOfUser { Id = cl.CompanyId, Name = cl.CompanyName, IsCompanyUser = cl.IsInventoryStaff ? 1 : 0 }).ToList <CompanyListOfUser>(); mobileInitialData.CompanyList = extractedcompanyList; //Get all the system Item Types InventoryBL inventoryBL = new InventoryBL(dataContext); List <ItemTypeData> itemTypeList = inventoryBL.GetAllSystemItemTypes(); mobileInitialData.ItemTypeList = itemTypeList; return(mobileInitialData); } }
/// <summary> /// Gets the country by countryId. /// </summary> /// <param name="countryId">The country identifier.</param> /// <returns></returns> public static Country GetCountryById(int countryId) { using (StageBitzDB dataContext = new StageBitzDB()) { return(SystemCache.Countries.Where(c => c.CountryId == countryId).FirstOrDefault()); } }
/// <summary> /// Determines whether [is company inventory staff member] [the specified company identifier]. /// </summary> /// <param name="companyId">The company identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="locationId">The location identifier.</param> /// <returns></returns> public static bool HasCompanyInventoryStaffMemberPermissions(int companyId, int userId, int?locationId) { using (StageBitzDB dataContext = new StageBitzDB()) { return(IsCompanyInventoryAdmin(companyId, userId) || IsCompanyInventoryStaffMember(companyId, userId, locationId, dataContext)); } }
/// <summary> /// Initializes the code tables. /// </summary> private static void InitializeCodeTables() { using (StageBitzDB dataContext = new StageBitzDB()) { CodeHeadersCacheItem = new Dictionary <string, Dictionary <string, Code> >(); AllCodesCacheItem = new Dictionary <int, Code>(); foreach (Data.CodeHeader dbCodeHeader in dataContext.CodeHeaders) { Dictionary <string, Code> childCodes = new Dictionary <string, Code>(); CodeHeadersCacheItem[dbCodeHeader.Name] = childCodes; foreach (Data.Code dbCode in dbCodeHeader.Codes) { Code code = new Code(); code.CodeId = dbCode.CodeId; code.Value = dbCode.Value; code.Description = dbCode.Description; code.SortOrder = dbCode.SortOrder; childCodes[dbCode.Value] = code; //Add a reference to the global code dictionary as well. AllCodesCacheItem[dbCode.CodeId] = code; } } } }
public ItemBriefDetails GetItemBriefDetails(ItemBriefRequestDetails itemBriefRequestDetails) { ItemBriefDetails itemBriefDetails = new Data.DataTypes.ItemBriefDetails(); using (StageBitzDB dataContext = new StageBitzDB()) { try { ItemBriefBL itemBriefBL = new ItemBriefBL(dataContext); ItemTypesBL itemTypesBL = new ItemTypesBL(dataContext); Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefRequestDetails.ItemBriefId); int projectId = 0; if (itemBrief != null) { projectId = itemBrief.ProjectId; } itemBriefDetails.CountryId = itemBriefBL.GetCountryIdByItemBriefId(itemBrief.ItemBriefId); itemBriefDetails.ItemBriefInfo = itemBriefBL.GetItemBriefInfoByItemBrief(itemBrief); itemBriefDetails.IsReadOnly = Support.IsReadOnlyRightsForProject(projectId, itemBriefRequestDetails.UserId); itemBriefDetails.CanSeeBudgetSummary = Support.CanSeeBudgetSummary(itemBriefRequestDetails.UserId, projectId); int itemTypeId = itemBriefRequestDetails.ItemTypeId.HasValue ? itemBriefRequestDetails.ItemTypeId.Value : itemBriefBL.GetItemBriefType(itemBriefRequestDetails.ItemBriefId).ItemTypeId; itemBriefDetails.DisplayMarkUp = itemTypesBL.GetItemTypeHTML(itemTypeId); itemBriefDetails.ItemBriefValues = itemTypesBL.GetItemBriefFieldValues(itemBriefRequestDetails.ItemBriefId).Select(ibfv => new ValuesInfo { Id = ibfv.ItemBriefValueId, FieldId = ibfv.FieldId, FieldOptionId = ibfv.FieldOptionId, Value = ibfv.Value }).ToList(); int itemId = 0; int userId = 0; ItemBooking itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefRequestDetails.ItemBriefId); if (itemBooking != null) { itemId = itemBooking.ItemId; } userId = itemBriefRequestDetails.UserId; ItemDetails itemDetails = itemTypesBL.GetItemDetails(itemId, itemBriefRequestDetails.ItemBriefId, userId, null, null, null); if (itemDetails != null) { itemBriefDetails.ItemDetails = itemDetails; } } catch (Exception ex) { AgentErrorLog.HandleException(ex); } return(itemBriefDetails); } }
/// <summary> /// Sends the booking delayed emails. /// </summary> /// <param name="dateToConsider">The date to consider.</param> public static void SendBookingDelayedEmails(DateTime dateToConsider) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); int delayedEmailCodeId = Utils.GetCodeIdByCodeValue("EmailTemplateTypeCode", "BOOKINGDELAYED"); string userWebUrl = Utils.GetSystemValue("SBUserWebURL"); var delayedBookings = (from ibs in dataContext.ItemBookings.Where(ibs => dataContext.IsItemBookingDelayedByDate(ibs.ItemBookingId, dateToConsider)) from eh in dataContext.EmailHistories.Where(eh => ibs.ItemBookingId == eh.RelatedId && eh.RelatedTable == "ItemBooking" && eh.EmailTemplateTypeCodeId == delayedEmailCodeId).DefaultIfEmpty().Take(1) join b in dataContext.Bookings on ibs.BookingId equals b.BookingId from ib in dataContext.ItemBriefs.Where(ib => ib.ItemBriefId == ibs.RelatedId && b.RelatedTable == "Project").DefaultIfEmpty().Take(1) from npb in dataContext.NonProjectBookings.Where(npb => npb.NonProjectBookingId == b.RelatedId && b.RelatedTable == "NonProject").DefaultIfEmpty().Take(1) join i in dataContext.Items on ibs.ItemId equals i.ItemId join u in dataContext.Users on ibs.CreatedBy equals u.UserId where eh == null && ibs.IsActive && i.CompanyId.HasValue select new { ItemBrief = ib, NonProjectBooking = npb, CompanyId = i.CompanyId.Value, CreatedBy = u, ItemBooking = ibs, Item = i }).ToList(); foreach (var delayedBooking in delayedBookings) { User locationManager = inventoryBL.GetContactBookingManager(delayedBooking.Item.CompanyId.Value, delayedBooking.Item.LocationId); if (locationManager != null) { Data.EmailHistory emailHistory = new EmailHistory { EmailTemplateTypeCodeId = delayedEmailCodeId, RelatedId = delayedBooking.ItemBooking.ItemBookingId, RelatedTable = "ItemBooking", CreatedDate = Utils.Now }; dataContext.EmailHistories.AddObject(emailHistory); dataContext.SaveChanges(); string inventoryManagerName = string.Concat(locationManager.FirstName, " ", locationManager.LastName); if (delayedBooking.ItemBrief != null) { string url = string.Format("{0}/ItemBrief/ItemBriefDetails.aspx?ItemBriefId={1}&TabId=3", userWebUrl, delayedBooking.ItemBrief.ItemBriefId); EmailSender.SendBookingDelayedEmail(delayedBooking.CreatedBy.Email1, delayedBooking.CreatedBy.FirstName, delayedBooking.ItemBrief.Name, url, inventoryManagerName, locationManager.Email1); } else { EmailSender.SendBookingDelayedEmailForNonProject(delayedBooking.CreatedBy.Email1, delayedBooking.CreatedBy.FirstName, delayedBooking.NonProjectBooking.Name, inventoryManagerName, locationManager.Email1); } } } } }
public List <string> GetCreatedForSearchItems(CreateForSearchRequest reqest) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); return(inventoryBL.GetCreatedForSearchItems(reqest.CompanyId, reqest.Keyword));; } }
public BookingResponse ReturnItem(BookingDetailInfor bookingDetailInfor) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); return(inventoryBL.ReturnItem(bookingDetailInfor.ItemBookingId, bookingDetailInfor.IsSelect, bookingDetailInfor.UserId)); } }
public ItemDetails GetItemDetails(ItemRequestDetails itemRequestDetails) { using (StageBitzDB dataContext = new StageBitzDB()) { ItemTypesBL itemTypesBL = new ItemTypesBL(dataContext); return(itemTypesBL.GetItemDetails(itemRequestDetails.ItemId, itemRequestDetails.ItemBriefId, itemRequestDetails.UserId, itemRequestDetails.ItemTypeId, Utils.GetDatetime(itemRequestDetails.FromDate, false), Utils.GetDatetime(itemRequestDetails.ToDate, false))); } }
public ItemResultObject SaveAndCompleteItemDetails(ItemDetails itemDetails) { using (StageBitzDB dataContext = new StageBitzDB()) { ItemBriefBL itemBriefBL = new ItemBriefBL(dataContext); return(itemBriefBL.CompleteItemBrief(itemDetails)); } }
public ItemBriefResulstObject SaveItemBriefDetails(ItemBriefDetails itemBriefDetails) { using (StageBitzDB dataContext = new StageBitzDB()) { ItemBriefBL itemBriefBL = new ItemBriefBL(dataContext); return(itemBriefBL.SaveItemBrief(itemBriefDetails)); } }
/// <summary> /// To be called by the daily agent /// </summary> public static void UpdateCompanyExpirations(DateTime dateToConsider, StageBitzDB dataContext) { FinanceBL financeBL = new FinanceBL(dataContext); CompanyBL companyBL = new CompanyBL(dataContext); ProjectBL projectBL = new ProjectBL(dataContext); #region SuspendPaymentFailureCompanies int companyGracePeriodStatus = Utils.GetCodeIdByCodeValue("CompanyStatus", "GRACEPERIOD"); int companyPaymentFailedStatus = Utils.GetCodeIdByCodeValue("CompanyStatus", "SUSPENDEDFORPAYMENTFAILED"); int companyActiveStatus = Utils.GetCodeIdByCodeValue("CompanyStatus", "ACTIVE"); int suspendedForNoPaymentPackageStatus = Utils.GetCodeIdByCodeValue("CompanyStatus", "SUSPENDEDFORNOPAYMENTPACKAGE"); int suspendForNoPaymentOptions = Utils.GetCodeIdByCodeValue("CompanyStatus", "SUSPENDEDFORNOPAYMENTOPTIONS"); var companies = from c in dataContext.Companies where (c.CompanyStatusCodeId == companyGracePeriodStatus || c.CompanyStatusCodeId == companyActiveStatus) && c.ExpirationDate != null && dateToConsider >= c.ExpirationDate select c; foreach (Data.Company company in companies) { if (company.CompanyStatusCodeId == companyActiveStatus) { //Get the current Company package to check. CompanyPaymentPackage companyPaymentPackage = financeBL.GetCurrentPaymentPackageFortheCompanyIncludingFreeTrial(company.CompanyId, dateToConsider); DiscountCodeUsage discountCodeUsage = financeBL.GetDiscountCodeUsageByDate(dateToConsider, company.CompanyId); // suspend payment package not setup companies after free trial. if (companyPaymentPackage == null) { company.CompanyStatusCodeId = suspendedForNoPaymentPackageStatus; } else { decimal totalAmount = financeBL.CalculateALLPackageAmountsByPeriod(companyPaymentPackage.ProjectPaymentPackageTypeId, companyPaymentPackage.InventoryPaymentPackageTypeId, companyPaymentPackage.PaymentDurationCodeId); //Check if it is a Free package. if (!companyPaymentPackage.PaymentMethodCodeId.HasValue && ((discountCodeUsage != null && discountCodeUsage.DiscountCode.Discount != 100) || (discountCodeUsage == null && totalAmount != 0))) { company.CompanyStatusCodeId = suspendForNoPaymentOptions; SuspendProjectsForCompany(company.CompanyId, dataContext); } } } //For Grace period companies, if it exceeded the grace period change it to Payment Failed. else if (companyBL.IsCompanyInPaymentFailedGracePeriod(company.CompanyId)) { company.CompanyStatusCodeId = companyPaymentFailedStatus; company.LastUpdatedByUserId = 0; company.LastUpdatedDate = Utils.Now; } company.ExpirationDate = null; } #endregion }
/// <summary> /// Updates the task schedule to to reflect the latest run date and time. /// </summary> private void UpdateLastRunDate() { using (StageBitzDB dataContext = new StageBitzDB()) { SystemTask task = dataContext.SystemTasks.Where(t => t.TaskTypeCodeId == TaskTypeCodeId).FirstOrDefault(); task.LastRunDate = Utils.Now; dataContext.SaveChanges(); } }
public BookingResponse RejectBooking(BookingDetailInfor bookingDetailInfor) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); BookingResponse bookingResponse = inventoryBL.RejectBooking(bookingDetailInfor.ItemBookingId, bookingDetailInfor.UserId); return(bookingResponse); } }
/// <summary> /// Deletes the exported files. /// </summary> private void DeleteExportedFiles() { //Delete unwanted zipped files if they are being there for more than the defined days from its creation date using (StageBitzDB dataContext = new StageBitzDB()) { CompanyBL companyBL = new CompanyBL(dataContext); companyBL.RemoveGeneratedExportFiles(); } }
public ItemResultObject SaveItemDetails(ItemDetails itemDetails) { using (StageBitzDB dataContext = new StageBitzDB()) { ItemTypesBL itemTypesBL = new ItemTypesBL(dataContext); ItemResultObject returnObj = itemTypesBL.SaveItemDetails(itemDetails, false, true); return(returnObj); } }
public BookingDetailsSaveResult SaveBookingDetails(BookingDetailsEditedHeader bookingDetailsEditedHeader) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); BookingDetailsSaveResult bookingDetailsSaveResult = inventoryBL.SaveBookingDetails(bookingDetailsEditedHeader); return(bookingDetailsSaveResult); } }
public MobileImageDetails GetImageDetailsForItem(MobileItemImageRequestDetails mobileItemImageRequestDetails) { string message = string.Empty; string status = string.Empty; bool isValidVersion = true; MobileImageDetails mobileImageDetails = new MobileImageDetails(); try { using (StageBitzDB dataContext = new StageBitzDB()) { isValidVersion = Helper.IsValidAppVersion(mobileItemImageRequestDetails.Version, out status); if (isValidVersion) { //Check the user security int userId = int.Parse(Utils.DecryptStringAES(mobileItemImageRequestDetails.Token)); if (Utils.CanAccessInventory(mobileItemImageRequestDetails.CompanyId, userId)) { UtilityBL utilityBL = new UtilityBL(dataContext); var dm = utilityBL.GetDocumentMedia(mobileItemImageRequestDetails.DocumentMediaId); if (dm != null) { mobileImageDetails.DocumentMediaId = dm.DocumentMediaId; mobileImageDetails.Image = Convert.ToBase64String(dm.Thumbnail); mobileImageDetails.Status = "OK"; } else { mobileImageDetails.Status = "ERROR"; mobileImageDetails.Message = "Oops! Unkown error. Sorry..."; } } else { mobileImageDetails.Status = "NOTOK"; mobileImageDetails.Message = "Check settings with Company Administrator."; } } else { mobileImageDetails.Status = "NOTOK"; mobileImageDetails.Message = "Please update App."; } } } catch (Exception ex) { AgentErrorLog.HandleException(ex); mobileImageDetails.Status = "ERROR"; mobileImageDetails.Message = "Oops! Unkown error. Sorry..."; } return(mobileImageDetails); }
public BookingEdit GetBookingDetails(BookingDetailsEditRequest bookingDetailsEditRequest) { using (StageBitzDB dataContext = new StageBitzDB()) { InventoryBL inventoryBL = new InventoryBL(dataContext); BookingEdit bookingEdit = inventoryBL.GetBookingDetails(bookingDetailsEditRequest); return(bookingEdit); } }
/// <summary> /// Creates the payment summaries. /// This will create payment summaries/Invoice Requests for the repeat payments to be charged at the end of the cycle /// </summary> /// <param name="dateToConsider">The date to consider.</param> public static void CreatePaymentSummaries(DateTime dateToConsider) { using (StageBitzDB dataContext = new StageBitzDB()) { FinanceBL financeBL = new FinanceBL(dataContext); CompanyBL companyBL = new CompanyBL(dataContext); //This will get all the CompanyPaymentPackages that needs to be Charged for considering cycle List <CompanyPaymentPackage> companyPaymentPackages = (from cpp in dataContext.CompanyPaymentPackages join cps in dataContext.CompanyPaymentSummaries on cpp.CompanyId equals cps.CompanyId where cps.IsImmidiateFutureRecordCreated == false && cpp.StartDate <= dateToConsider && (cpp.EndDate > dateToConsider || cpp.EndDate == null) && cps.NextPaymentCycleStartingDate <= dateToConsider select cpp).Distinct().ToList(); foreach (CompanyPaymentPackage companyPaymentPackage in companyPaymentPackages) { Data.Company company = companyPaymentPackage.Company; PaymentSummaryDetails paymentSummaryDetails = new PaymentSummaryDetails() { CompanyPaymentPackage = companyPaymentPackage, CompanyId = companyPaymentPackage.CompanyId, ShouldProcess = !(companyBL.IsCompanySuspended(companyPaymentPackage.CompanyId) || companyBL.HasCompanySuspendedbySBAdmin(companyPaymentPackage.CompanyId)), UserId = 0, PackageStartDate = companyPaymentPackage.StartDate, PaymentMethodCodeId = companyPaymentPackage.PaymentMethodCodeId, HasPackageChanged = false, ProjectPaymentPackageTypeId = companyPaymentPackage.ProjectPaymentPackageTypeId, InventoryPaymentPackageTypeId = companyPaymentPackage.InventoryPaymentPackageTypeId, IsEducationPackage = companyPaymentPackage.IsEducationalPackage, PaymentDurationTypeCodeId = companyPaymentPackage.PaymentDurationCodeId, DiscountCodeUsageToApply = financeBL.GetLatestDiscountCodeUsage(companyPaymentPackage.CompanyId) }; //Get IsImmidiateFutureRecordCreated "False" Future Anual Summary records and make them as "True".(To commit as Processed) var unprocessedFutureSummaries = (from cps in dataContext.CompanyPaymentSummaries where cps.IsImmidiateFutureRecordCreated == false && cps.CompanyId == companyPaymentPackage.CompanyId && cps.ToDate <= dateToConsider select cps).ToList(); foreach (CompanyPaymentSummary cps in unprocessedFutureSummaries) { cps.IsImmidiateFutureRecordCreated = true; cps.LastUpdatedDate = Utils.Today; cps.LastUpdatedBy = 0; } CreateCompanyPaymentSummaries(paymentSummaryDetails, dateToConsider, dataContext); } dataContext.SaveChanges(); } }
/// <summary> /// Deletes the old exported zip files. /// </summary> public void DeleteOldExportedZipFiles() { using (StageBitzDB dataContext = new StageBitzDB()) { string basePath = Utils.GetSystemValue("ExportFileDirectoryLocation"); if (!string.IsNullOrEmpty(basePath)) { ExportFilesHandler fileHandler = new ExportFilesHandler(basePath, dataContext); fileHandler.DeleteOldExportedZipFiles(); } } }
/// <summary> /// Gets the company inventory admin. /// </summary> /// <param name="companyId">The company identifier.</param> /// <returns></returns> public User GetCompanyInventoryAdmin(int companyId) { using (StageBitzDB dataContext = new StageBitzDB()) { int companyPrimaryAdminCodeID = Utils.GetCodeByValue("CompanyUserTypeCode", "INVADMIN").CodeId; return((from cu in dataContext.CompanyUsers join cur in dataContext.CompanyUserRoles on cu.CompanyUserId equals cur.CompanyUserId where cu.CompanyId == companyId && cu.IsActive == true && cur.CompanyUserTypeCodeId == companyPrimaryAdminCodeID && cur.IsActive select cu.User).FirstOrDefault()); } }
/// <summary> /// Creates the payment log. /// </summary> /// <param name="invoiceId">The invoice identifier.</param> /// <param name="dataContext">The data context.</param> /// <returns></returns> public static PaymentLog CreatePaymentLog(int invoiceId, StageBitzDB dataContext) { // Create Payment log record. PaymentLog paymentLog = new PaymentLog(); paymentLog.RelatedTableName = "Invoice"; paymentLog.RelatedId = invoiceId; paymentLog.CreatedByUserId = paymentLog.CreatedByUserId = 0; paymentLog.CreatedDate = paymentLog.LastUpdatedDate = Utils.Now; dataContext.PaymentLogs.AddObject(paymentLog); return(paymentLog); }
/// <summary> /// Generates the export files. /// </summary> private void GenerateExportFiles() { using (StageBitzDB dataContext = new StageBitzDB()) { string basePath = Utils.GetSystemValue("ExportFileDirectoryLocation"); if (!string.IsNullOrEmpty(basePath)) { ExportFilesHandler fileHandler = new ExportFilesHandler(basePath, dataContext); fileHandler.ExportFiles(); } } }
/// <summary> /// Returns the user with the specified id if that user is active /// </summary> private static StageBitz.Data.User GetActiveUserById(int userId, StageBitzDB dataContext) { var user = from u in dataContext.Users where u.UserId == userId && u.IsActive == true select u; if (user.Count <StageBitz.Data.User>() == 1) { return(user.First <StageBitz.Data.User>()); } return(null); }
/// <summary> /// Saves the document media. /// </summary> /// <param name="filePrefix">The file prefix.</param> /// <param name="documentMediaId">The document media identifier.</param> /// <param name="attachmentPath">The attachment path.</param> /// <returns></returns> private async Task SaveDocumentMedia(string filePrefix, int documentMediaId, string attachmentPath) { using (StageBitzDB dataContext = new StageBitzDB()) { UtilityBL utilityBL = new UtilityBL(dataContext); Data.DocumentMedia documentMedia = utilityBL.GetDocumentMedia(documentMediaId); if (documentMedia != null) { string documentMediaFileName = string.Format("{0} {1} - {2}.{3}", filePrefix, documentMedia.DocumentMediaId, Utils.Ellipsize(documentMedia.Name, 50), documentMedia.FileExtension); await FileHandler.SaveFileToDisk(documentMedia.DocumentMediaContent, FileHandler.GetSafeFileName(documentMediaFileName), attachmentPath); } } }