private DalManager() { // _manager = new StubDalManager(); //_manager = new SQLDalManager(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="+ Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\")) + @"zzdb.mdf;Integrated Security=True;Connect Timeout=30"); // elegant solution doesnt work when called from other place than root directory of project ( ex : unit tests) _manager = new SQLDalManager(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=H:\Travail\zz2\Service Web\throne_of_zz\zzdb.mdf;Integrated Security=True;Connect Timeout=30"); }
public static IDalManager GetDalManager(string type, params string[] parameters) { IDalManager dalManager = null; switch (type) { case "AzureStorage": if (parameters == null || parameters.Length != 2) { string errorMessage = "There must be two parameters for the \"AzureStorage\" DAL type"; LoggerFactory.Logger.Error("DalManagerFactory.GetDalManager", EventId.DALGetManager, errorMessage); throw new ArgumentException(errorMessage, "parameters"); } string storageAccountConnectionString = parameters[0]; string containerName = parameters[1]; dalManager = new AzureDalManager(storageAccountConnectionString, containerName); break; case "FileSystem": case "UnitTest": case "DB": throw new NotImplementedException(); } return(dalManager); }
public BaseCommerceDal(IDalManager manager, CloudStorageAccount account, string tableName) { this.manager = manager; tableClient = account.CreateCloudTableClient(); tableClient.CreateTableIfNotExist(tableName); this.tableContext = tableClient.GetDataServiceContext(); }
public IRepository <T> GetRepository <T>(IDalManager dalManager) where T : DomainObject { if (Repositories.TryGetValue(typeof(T), out var repositoryType)) { return(Activator.CreateInstance(repositoryType, dalManager) as IRepository <T>); } throw new ArgumentException("Не существует репозитория для заданного доменного объекта."); }
public DalUsageEvent(IDalManager manager, CloudStorageAccount account) : base(manager, account, RawUsageTableName) { this.tableClient.CreateTableIfNotExist(AggregateUsageTableName); this.aggregateTableServiceContext = tableClient.GetDataServiceContext(); this.tableClient.CreateTableIfNotExist(AggregatePerUserUsageTableName); this.aggregatePerUserTableServiceContext = tableClient.GetDataServiceContext(); }
public static List <BizRuleCertMetadata> GetBizRulesList(IDalManager dalManager) { if (GCValidatorHelper.AddDummyDataForCertValidation) { List <BizRuleCertMetadata> bizRuleCerts = new List <BizRuleCertMetadata>(); bizRuleCerts.Add(new BizRuleCertMetadata() { TradingPartnerName = "3M", RuleCertFileName = "3M - Biz Rule - X12 810-856-850.xlsx" }); bizRuleCerts.Add(new BizRuleCertMetadata() { TradingPartnerName = "Global", RuleCertFileName = "Global - Biz Rule - X12 810-856-850.xlsx" }); return(bizRuleCerts); } return(dalManager.GetBizRuleCertFileList()); }
private static DocumentPlugValidationInfo GetDocumentPlugValidationInfo(ZipFileEntry fileEntry, IDalManager dalManager) { string specCertName = Path.ChangeExtension(fileEntry.FileName, "xlsx"); DocumentPlugValidationInfo documentPlugValidationInfo = new DocumentPlugValidationInfo() { SpecCertName = specCertName, FileContents = fileEntry.Content, FileName = fileEntry.FileName, }; TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata = new TradingPartnerSpecCertMetadata(); List <string> errors = tradingPartnerSpecCertMetadata.Initialize(specCertName); if (errors == null || errors.Count == 0) { try { documentPlugValidationInfo.DocumentPlug = SchemaCache.GetDocumentPlug(tradingPartnerSpecCertMetadata, dalManager); } catch (Exception) { // Ignore error here as we want to add EdiValidationResult error during ValidateEdi call. } } return(documentPlugValidationInfo); }
private static void AddUsageEvent(string userName, string homeOrg, BizRulesValidationResult bizRulesValidationResult, IDalManager dal) { if (bizRulesValidationResult == null) { return; } if (bizRulesValidationResult.EdiValidationResults != null) { string validationStatus = "Error"; if (bizRulesValidationResult.BizRuleValidationResults != null) { validationStatus = bizRulesValidationResult.GetAggregatedResult().ToString(); } string bizRuleCertFileName = Path.GetFileNameWithoutExtension(bizRulesValidationResult.BizRuleCertName); foreach (EDIValidationResult result in bizRulesValidationResult.EdiValidationResults) { string fileName = result.FileName; string partnerName = result.FileName.Substring(0, result.FileName.IndexOf(" - ")); GCValidatorHelper.AddUsageEvent(userName, homeOrg, partnerName, result.DisplayName, result, result.ExecutionTime, fileName, "Biz Rule", dal); // We add usage event for each ST-SE segment in above AddUsageEvent call // however for bizRule validation we currently support only one ST-SE segment. // Add another usage event for each edi file for biz rule validations if (bizRulesValidationResult.BizRuleValidationResults != null) { fileName = string.Format("{0} + {1}", fileName, bizRulesValidationResult.BizRuleCertName); GCValidatorHelper.AddUsageEvent(userName, homeOrg, partnerName, bizRuleCertFileName, validationStatus, bizRulesValidationResult.BizRuleValidationExecutionTime, fileName, "Biz Rule", dal); } } } }
public ServiceRepository(IDalManager dalManager) { this.dalManager = dalManager; }
public DalBillingCycle(IDalManager manager, CloudStorageAccount account) : base(manager, account, BillingCycleTableName) { }
public OrderRepository(IDalManager dalManager) { this.dalManager = dalManager; }
public DalOffer(IDalManager manager, CloudStorageAccount account) : base(manager, account, OfferTableName) { }
public CompletedOrderRepository(IDalManager dalManager) { this.dalManager = dalManager; }
public CustomerRepository(IDalManager dalManager) { this.dalManager = dalManager; }
// Should we always overwrite the existing one? public static void UploadBizRuleCert(string certFileName, Stream certFileStream, string userName, IDalManager dalManager) { if (GCValidatorHelper.AddDummyDataForCertValidation) { return; } BizRuleCertMetadata bizRuleCertMetadata = new BizRuleCertMetadata(); // Purposely ignoring Initialize function return type (errors) since I don't expect errors here. bizRuleCertMetadata.Initialize(certFileName, userName, DateTime.UtcNow); dalManager.SaveBizRuleCert(certFileStream, bizRuleCertMetadata); dalManager.SaveBizRuleCertMetadata(bizRuleCertMetadata); SchemaCache.RemoveBizRuleCert(bizRuleCertMetadata.RuleCertFileName); }
public static BizRuleCertValidationResult ValidateBizRuleCert(string certFileName, Stream certFileStream, IDalManager dalManager) { if (GCValidatorHelper.AddDummyDataForCertValidation) { BizRuleCertValidationResult bizRuleCertValidationResult = new BizRuleCertValidationResult(); bizRuleCertValidationResult.RuleDefinitionValidationResults = new List <RuleDefinitionValidationResult>(); bizRuleCertValidationResult.RuleDefinitionValidationResults.Add(new RuleDefinitionValidationResult() { Type = ResultType.Warning, ColumnIndex = "D", RowIndex = 1, Description = "Invalid message domain id." }); bizRuleCertValidationResult.RuleDefinitionValidationResults.Add(new RuleDefinitionValidationResult() { Type = ResultType.Error, ColumnIndex = "B", RowIndex = 5, Description = "Invalid value for \"Rule Matching Option\"." }); return(bizRuleCertValidationResult); } GCExcelToBizRuleSet gcExcelToBizRuleSet = new GCExcelToBizRuleSet(); try { BizRuleCertMetadata bizRuleCertMetadata = new BizRuleCertMetadata(); List <string> errors = bizRuleCertMetadata.Initialize(certFileName); if (errors.Count == 0) { // Check if this cert file already exist List <BizRuleCertMetadata> bizRuleCertMetadataList = dalManager.GetBizRuleCertFileList(bizRuleCertMetadata.TradingPartnerName); if (bizRuleCertMetadataList.Any(t => t.TradingPartnerName == bizRuleCertMetadata.TradingPartnerName && t.RuleCertFileName == bizRuleCertMetadata.RuleCertFileName)) { gcExcelToBizRuleSet.BizRuleCertValidationResult.RuleDefinitionValidationResults.Add(new RuleDefinitionValidationResult() { ColumnIndex = "N/A", RowIndex = -1, Type = ResultType.Warning, Description = "Cert file already exist." }); } gcExcelToBizRuleSet.GenerateBizRuleSet(certFileStream); } else { foreach (string error in errors) { gcExcelToBizRuleSet.BizRuleCertValidationResult.RuleDefinitionValidationResults.Add(new RuleDefinitionValidationResult() { ColumnIndex = "N/A", RowIndex = -1, Type = ResultType.Error, Description = string.Format("Cert file name error: {0}", error) }); } } } catch (Exception ex) { gcExcelToBizRuleSet.BizRuleCertValidationResult.RuleDefinitionValidationResults.Add(new RuleDefinitionValidationResult() { ColumnIndex = "N/A", RowIndex = -1, Type = ResultType.Error, Description = string.Format("Unknown error occured ({0}), please contact Maarg", ex.Message) }); } return(gcExcelToBizRuleSet.BizRuleCertValidationResult); }
public DalTimeoffset(IDalManager manager, CloudStorageAccount account) : base(manager, account, TimeOffsetTableName) { }
public static void DeleteTradingPartnerSpecCertWithMetadata(BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager) { if (GCValidatorHelper.AddDummyDataForCertValidation) { return; } // TODO: Ideally we should keep audit trail of delete // Following function will remove the table entry altogether. dalManager.DeleteBizRuleCertMetadata(bizRuleCertMetadata); dalManager.DeleteBizRuleCert(bizRuleCertMetadata); SchemaCache.RemoveBizRuleCert(bizRuleCertMetadata.RuleCertFileName); }
public static Stream DownloadTradingPartnerSpecCert(BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager) { if (GCValidatorHelper.AddDummyDataForCertValidation) { throw new NotImplementedException(); } return(dalManager.GetBizRuleCert(bizRuleCertMetadata)); }
public static IDocumentPlug GetDocumentPlug(TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata, IDalManager dalManager) { IDocumentPlug documentPlug = gcSpecCertCache.GetObject(tradingPartnerSpecCertMetadata.SchemaFileName) as IDocumentPlug; if (documentPlug == null) { Stream schemaStream = dalManager.GetTradingPartnerSpecCert(tradingPartnerSpecCertMetadata); if (schemaStream == null) { throw new GCEdiValidatorException(string.Format("{0} Schema not found.", tradingPartnerSpecCertMetadata.SchemaFileName)); } GCExcelToDocumentPlug gcExcelToDocumentPlug = GCExcelToDocumentPlug.CreateInstance((SpecCertFileType)tradingPartnerSpecCertMetadata.FileType); documentPlug = gcExcelToDocumentPlug.GenerateDocumentPlug(schemaStream, tradingPartnerSpecCertMetadata.TradingPartnerName, tradingPartnerSpecCertMetadata.DocumentType, tradingPartnerSpecCertMetadata.Direction, (SpecCertFileType)tradingPartnerSpecCertMetadata.FileType); gcSpecCertCache.AddObject(tradingPartnerSpecCertMetadata.SchemaFileName, documentPlug); } return(documentPlug); }
public static BizRuleSet GetBizRuleSet(BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager) { BizRuleSet bizRuleSet = gcSpecCertCache.GetObject(bizRuleCertMetadata.RuleCertFileName) as BizRuleSet; if (bizRuleSet == null) { Stream bizRuleStream = dalManager.GetBizRuleCert(bizRuleCertMetadata); if (bizRuleStream == null) { throw new GCEdiValidatorException(string.Format("{0} BizRule not found.", bizRuleCertMetadata.RuleCertFileName)); } GCExcelToBizRuleSet gcExcelToBizRuleSet = new GCExcelToBizRuleSet(); bizRuleSet = gcExcelToBizRuleSet.GenerateBizRuleSet(bizRuleStream); gcBizRuleCertCache.AddObject(bizRuleCertMetadata.RuleCertFileName, bizRuleSet); } return(bizRuleSet); }
public ChartManager(IDalManager dalManager) { _dalManager = dalManager; }
/// <summary> Wrapper over EDIReader for GC validation feature (Based on spec cert). </summary> /// <param name="ediData">EDI text data (edi file content)</param> /// <param name="ediFileName">This is for record keeping only, not used by EDIReader</param> /// <param name="certFileFullName">Spec cert file (relative path)</param> /// <param name="dalManager">To retrieve schema</param> /// <returns></returns> public static EDIValidationResult ValidateEdi(string ediData, string ediFileName, string certFileFullName, IDalManager dalManager) { if (string.IsNullOrWhiteSpace(ediData)) { throw new ArgumentNullException("ediData", "Edi file content cannot be empty"); } if (string.IsNullOrWhiteSpace(certFileFullName)) { throw new ArgumentNullException("certFileFullName", "certFileFullName cannot be empty"); } if (dalManager == null) { throw new ArgumentNullException("dalManager", "dalManager cannot be null"); } TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata = new TradingPartnerSpecCertMetadata(); // Purposely ignoring Initialize function return type (errors) since I don't expect errors here. // Spec cert is uploaded only after validation. tradingPartnerSpecCertMetadata.Initialize(certFileFullName, null, DateTime.MinValue); EDIValidationResult ediValidationResult = new EDIValidationResult() { FileName = ediFileName, SchemaName = tradingPartnerSpecCertMetadata.SchemaFileName, SegmentValidationResults = new List <SegmentValidationResult>(), TransactionNumbers = new List <string>(), DisplayName = tradingPartnerSpecCertMetadata.GetCertFileDisplayName(), Type = tradingPartnerSpecCertMetadata.Type, }; try { IDocumentPlug documentPlug = SchemaCache.GetDocumentPlug(tradingPartnerSpecCertMetadata, dalManager); IFatpipeDocument fatpipeDocument; ediValidationResult = ValidateEdi(ediData, ediFileName, certFileFullName, documentPlug, out fatpipeDocument); } catch (Exception ex) { ediValidationResult.SegmentValidationResults.Add( new SegmentValidationResult() { Type = ResultType.Error, SequenceNumber = -1, Name = "N/A", Description = "Internal error occurred", //ex.Message, StartIndex = -1, EndIndex = -1, } ); } return(ediValidationResult); }
public LawyerRepository(IDalManager dalManager) { this.dalManager = dalManager; }
public static void AddUsageEvent(string userName, string homeOrgName, string partnerName, string certFile, EDIValidationResult result, TimeSpan executionTime, string testFileName, string service, IDalManager dal) { string validationStatus = "Success"; if (result != null) { if (!result.IsValid) { validationStatus = "Error"; } else if (result.SegmentValidationResults != null && result.SegmentValidationResults.Count > 0) { validationStatus = "Warning"; } } List <string> transactionNumbers = result.TransactionNumbers; if (transactionNumbers == null) { transactionNumbers = new List <string>(); } if (transactionNumbers.Count == 0) { transactionNumbers.Add(string.Empty); } string instanceFileName; foreach (string transactionNumber in transactionNumbers) { instanceFileName = testFileName; if (string.IsNullOrWhiteSpace(transactionNumber) == false) { instanceFileName += " - " + transactionNumber; } AddUsageEvent(userName, homeOrgName, partnerName, certFile, validationStatus, executionTime, instanceFileName, service, dal); } }
// This function is invoked from Ux public static BizRulesValidationResult ValidateBizRules(string userName, string homeOrg, ZipArchive zipArchive, BizRuleCertMetadata bizRuleCertMetadata, IDalManager dalManager) { if (zipArchive == null) { throw new ArgumentNullException("zipArchive", "zipFile cannot be empty"); } if (bizRuleCertMetadata == null) { throw new ArgumentNullException("bizRuleCertMetadata", "bizRuleCertMetadata cannot be empty"); } if (dalManager == null) { throw new ArgumentNullException("dalManager", "dalManager cannot be null"); } #region DummyCode if (GCValidatorHelper.AddDummyDataForInstanceValidation) { List <BizRuleInfo> ruleInfo1 = new List <BizRuleInfo>(); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "BIG->BIG03", Value = "1/2/2014" }); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF04", Value = "1/3/2014" }); ruleInfo1.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG05", Value = "1/2/2014" }); List <BizRuleInfo> ruleInfo2 = new List <BizRuleInfo>(); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send", SegmentPath = "BIG->BIG04", Value = "122014" }); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "PRF->PRF01", Value = "122014" }); ruleInfo2.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "BEG->BEG03", Value = "122014" }); List <BizRuleInfo> ruleInfo3 = new List <BizRuleInfo>(); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SegmentPath = "IT1->IT101", Value = "123" }); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SegmentPath = "LIN->LIN01", Value = "234" }); ruleInfo3.Add(new BizRuleInfo() { FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SegmentPath = "PO1->PO1O1", Value = "345" }); BizRulesValidationResult bizRulesValidationResultDummy = new BizRulesValidationResult() { BizRuleCertName = "3M - Biz Rule - X12 810-856-850" }; bizRulesValidationResultDummy.BizRuleValidationResults = new List <BizRuleValidationResult>(); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Purchase Order Date", Type = ResultType.Error, RuleInfo = ruleInfo1 }); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Purchase Order Number", Type = ResultType.Success, RuleInfo = ruleInfo2 }); bizRulesValidationResultDummy.BizRuleValidationResults.Add(new BizRuleValidationResult() { RuleName = "Assigned Identification", Type = ResultType.Warning, RuleInfo = ruleInfo3 }); bizRulesValidationResultDummy.EdiValidationResults = new List <EDIValidationResult>(); List <SegmentValidationResult> segmentValidationResult = new List <SegmentValidationResult>(); segmentValidationResult.Add(new SegmentValidationResult() { Description = "Invalid Segment XYZ", Name = "XYZ", SequenceNumber = 5, Type = ResultType.Error, StartIndex = 300, EndIndex = 305, }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corp - Spec Cert - 810 - Send.dat", SchemaName = "Delphi Corp - Spec Cert - 810 - Send", SegmentValidationResults = new List <SegmentValidationResult>(), // No validation failures TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corp - 810 - Send", Type = "X12_810" }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corporation - Spec Cert - 4010 - 850 - send - Comments.dat", SchemaName = "Delphi Corporation - Spec Cert - 4010 - 850 - send", SegmentValidationResults = segmentValidationResult, TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corporation - 850 - send", Type = "X12_850" }); bizRulesValidationResultDummy.EdiValidationResults.Add(new EDIValidationResult() { BeautifiedOriginalPayload = "EDI File Contents", FileName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive - Comments.dat", SchemaName = "Delphi Corporation - Spec Cert - 4010 - 856 - receive", SegmentValidationResults = new List <SegmentValidationResult>(), // No validation failures TransactionNumbers = new List <string> { "1" }, DisplayName = "Delphi Corporation - 856 - receive", Type = "X12_856" }); return(bizRulesValidationResultDummy); } #endregion BizRulesValidationResult bizRulesValidationResult = null; string errorMessage = null; try { BizRuleSet bizRuleSet = SchemaCache.GetBizRuleSet(bizRuleCertMetadata, dalManager); List <ZipFileEntry> fileEntries = ZipFileUtil.GetFileEntries(zipArchive); List <DocumentPlugValidationInfo> documentPlugValidationInfoList = new List <DocumentPlugValidationInfo>(); foreach (ZipFileEntry fileEntry in fileEntries) { documentPlugValidationInfoList.Add(GetDocumentPlugValidationInfo(fileEntry, dalManager)); } bizRulesValidationResult = ValidateBizRules(userName, homeOrg, bizRuleCertMetadata.RuleCertFileName, bizRuleSet, documentPlugValidationInfoList, dalManager); } catch (GCEdiValidatorException gcException) { errorMessage = gcException.Message; } catch (Exception) { errorMessage = "Internal error occurred, please contact Maarg"; } if (errorMessage != null) { // TODO: Add generic error } return(bizRulesValidationResult); }
public UnitTest2() { manager = new DalManagerSQL(); }
// This function does not need DalManager and extracted from above method for unit testing purpose. public static BizRulesValidationResult ValidateBizRules(string userName, string homeOrg, string ruleCertFileName, BizRuleSet bizRuleSet, List <DocumentPlugValidationInfo> documentPlugValidationInfoList, IDalManager dal) { BizRulesValidationResult bizRulesValidationResult = new BizRulesValidationResult(); bizRulesValidationResult.BizRuleCertName = ruleCertFileName; // Validate All Edi if DocumentPlug is not null, if it is null then add error bizRulesValidationResult.EdiValidationResults = ValidateEdi(documentPlugValidationInfoList); Stopwatch sw = new Stopwatch(); sw.Start(); bizRulesValidationResult.BizRuleValidationResults = ValidateBizRules(bizRuleSet, documentPlugValidationInfoList); sw.Stop(); bizRulesValidationResult.BizRuleValidationExecutionTime = sw.Elapsed; AddUsageEvent(userName, homeOrg, bizRulesValidationResult, dal); return(bizRulesValidationResult); }
// Should we always overwrite the existing one? public static void UploadSpecCert(string certFileName, Stream certFileStream, string userName, IDalManager dalManager) { TradingPartnerSpecCertMetadata tradingPartnerSpecCertMetadata = new TradingPartnerSpecCertMetadata(); // Purposely ignoring Initialize function return type (errors) since I don't expect errors here. tradingPartnerSpecCertMetadata.Initialize(certFileName, userName, DateTime.UtcNow); dalManager.SaveTradingPartnerSpecCert(certFileStream, tradingPartnerSpecCertMetadata); dalManager.SaveTradingPartnerSpecCertMetadata(tradingPartnerSpecCertMetadata); SchemaCache.RemoveDocumentPlug(tradingPartnerSpecCertMetadata.SchemaFileName); }
public static void AddUsageEvent(string userName, string homeOrgName, string partnerName, string certFile, string validationStatus, TimeSpan executionTime, string testFileName, string service, IDalManager dal) { // Hardcoded order since we don't create order during sign up yet. Order order = new Order() { Id = Guid.Parse("75654e42-c3fe-482b-b52a-024d073e1ea7"), OfferId = Guid.Parse("5ddd32f3-1783-4bbe-854f-4c5d5955df7f"), SeatCount = 1, TenantId = "GCom", UserId = userName, }; UsageEvent usageEvent = new UsageEvent() { Id = Guid.NewGuid(), OrderId = order.Id, ResourceId = "EdiValidation", TenantId = order.TenantId, Timestamp = DateTime.UtcNow, WhenConsumed = DateTime.UtcNow, UserId = order.UserId, AmountConsumed = 1.0d, HomeOrgName = homeOrgName, PartnerName = partnerName, SpecCertName = certFile, InstanceFileName = testFileName, ValidationStatus = validationStatus, TimeOfValidationInMs = (int)executionTime.TotalMilliseconds, Service = service, }; // For unit tests dal will be null if (dal != null) { dal.TrackUsage(usageEvent); } }