public ServiceResult IsValid(ExcelProperties properties, string contentType, string production) { if (properties == null) { throw new ArgumentNullException(nameof(properties)); } if (!ArePropertiesValid(properties)) { var result = new ServiceResult(false); result.AddError(PropertiesInvalidMessage); return(result); } if (!IsContentTypeValid(properties, contentType)) { var result = new ServiceResult(false); result.AddError($"Expected Content Type '{contentType}' but found '{properties[core.Constants.BudgetFormExcelPropertyNames.ContentType]}'."); return(result); } if (IsAnyProductionContentType(properties[core.Constants.BudgetFormExcelPropertyNames.ContentType])) { return(new ServiceResult(true)); } if (!IsProductionValid(properties, contentType, production)) { var result = new ServiceResult(false); result.AddError($"Expected '{production}' but found '{properties[core.Constants.BudgetFormExcelPropertyNames.Production]}'."); return(result); } return(new ServiceResult(true)); }
protected override void Print() { string path = Properties.Settings.Default.ClassesTemplate; ExcelProperties props = new ExcelProperties(2, 1, false); ClassesReport report = new ClassesReport(Contracts.ToList(), path, props); report.Print(); }
protected override void Print() { string path = Properties.Settings.Default.DocFollowTemplate; if (string.IsNullOrEmpty(path)) { string msg = "يجب تحديد مسار تقرير المتابعة"; Helper.ShowMessage(msg); return; } try { DocRecord currentDoc = null; using (IUnitOfWork unit = new UnitOfWork()) { currentDoc = unit.DocRecords.GetById(DocId); } if (currentDoc != null) { List <DocFollowsReport> source = new List <DocFollowsReport>(); if (currentDoc.DocRecordFollows.Count > 0) { var follows = currentDoc.DocRecordFollows.OrderBy(x => x.FollowDate); foreach (var follow in follows) { DocFollowsReport row = new DocFollowsReport(); row.DocId = currentDoc.Id; row.DocDate = currentDoc.DocDate; row.Destination = currentDoc.Destination.Description; row.Subject = currentDoc.Subject; row.DocStatus = currentDoc.DocStatus; row.FollowDate = follow.FollowDate; row.FollowContent = follow.FollowContent; source.Add(row); } } else { DocFollowsReport header = new DocFollowsReport(); header.DocId = currentDoc.Id; header.DocDate = currentDoc.DocDate; header.Destination = currentDoc.Destination.Description; header.Subject = currentDoc.Subject; header.DocStatus = currentDoc.DocStatus; source.Add(header); } ExcelProperties excelProp = new ExcelProperties(2, 1, false); DocRecordFollowPrintReport report = new DocRecordFollowPrintReport(source, path, excelProp); report.Print(); } } catch (Exception ex) { Helper.LogShowError(ex); } }
private static bool IsProductionValid(ExcelProperties properties, string contentType, string production) { if (string.Compare(contentType, Constants.ContentType.Video, StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(production, Constants.ProductionType.CgiAnimation, StringComparison.OrdinalIgnoreCase) == 0) { production = Constants.ProductionType.PostProductionOnly; //For Video & CGI, use the Post Production mappings } return(string.Compare(production, properties[core.Constants.BudgetFormExcelPropertyNames.Production], StringComparison.OrdinalIgnoreCase) == 0); }
private Task PrintAsync(string path) { Task task = Task.Run(() => { var source = DocRecordReport.ToList(); ExcelProperties excelProp = new ExcelProperties(2, 1, false); DocRecordFollowPrintReport report = new DocRecordFollowPrintReport(source, path, excelProp); report.ReportProgress += Report_ReportProgress; report.Print(); }); return(task); }
public IRestResponse GetResponseFromApi(ExcelProperties excelProperties) { RestClient client = new RestClient(excelProperties.RestClient); RestRequest request = new RestRequest(excelProperties.RestRequest, HTTPMethods.ApiMethod(excelProperties.RequestMethod.ToString())); if (excelProperties.RequestMethod == Method.POST.ToString() || excelProperties.RequestMethod == Method.PUT.ToString()) { request.AddParameter("application/json; charset=utf-8", excelProperties.JsonRequest, ParameterType.RequestBody); request.RequestFormat = DataFormat.Json; } IRestResponse response = client.Execute(request); return(response); }
protected override void Print() { var source = FillData().ToList(); int caseNo = CaseNo; var appoint = LegalCase.CaseAppointments.LastOrDefault(); string nextAppoint = ""; if (appoint != null) { nextAppoint = appoint.AppointmentDate; } string defendant = LegalCase.Defendant; ExcelProperties excelProp = new ExcelProperties(4, 1, false); string path = @"C:\BaMusaSoft\JeddahStationProject\Templates\CaseFollowings.xltx"; FollowingsReport report = new FollowingsReport(source, caseNo, defendant, nextAppoint, path, excelProp); report.Print(); }
// Return ExcelData for specific test case public ExcelProperties GetExcelDataRelativeToTc(DataTable dt) { var excelProperties = new ExcelProperties(); foreach (DataRow row in dt.Rows) { if (_TestCaseName == row[ExcelColumnsEnum.Name.ToString()].ToString().Replace(" ", "")) { excelProperties.Name = row[ExcelColumnsEnum.Name.ToString()].ToString(); excelProperties.RestClient = row[ExcelColumnsEnum.RestClient.ToString()].ToString(); excelProperties.RestRequest = row[ExcelColumnsEnum.RestRequest.ToString()].ToString(); excelProperties.RequestMethod = row[ExcelColumnsEnum.RequestMethod.ToString()].ToString(); excelProperties.JsonRequest = row[ExcelColumnsEnum.JsonRequest.ToString()].ToString(); excelProperties.ExpectedResponseJson = row[ExcelColumnsEnum.ExpectedResponseJson.ToString()].ToString(); excelProperties.ExpectedResponseCode = Convert.ToInt32(row[ExcelColumnsEnum.ExpectedResponseCode.ToString()]); excelProperties.RunFlag = Convert.ToBoolean(row[ExcelColumnsEnum.RunFlag.ToString()].ToString()); break; } } return(excelProperties); }
public void Unsupported_ContentType_Return_Failure() { //Arrange var excelProperties = new ExcelProperties { [core.Constants.BudgetFormExcelPropertyNames.LookupGroup] = "LookupGroup", [core.Constants.BudgetFormExcelPropertyNames.ContentType] = "Audio", [core.Constants.BudgetFormExcelPropertyNames.Production] = "Full Production" }; var contentType = "Unsupported"; const string production = Constants.ProductionType.FullProduction; var target = new BudgetFormPropertyValidator(); //Act var result = target.IsValid(excelProperties, contentType, production); //Assert result.Should().NotBeNull(); result.Success.Should().BeFalse(); }
public void CGIAnimation_For_Video_Return_Success() { //Arrange var excelProperties = new ExcelProperties { [core.Constants.BudgetFormExcelPropertyNames.LookupGroup] = "LookupGroup", [core.Constants.BudgetFormExcelPropertyNames.ContentType] = "Video", [core.Constants.BudgetFormExcelPropertyNames.Production] = "post production only" }; var contentType = Constants.ContentType.Video; const string production = Constants.ProductionType.CgiAnimation; var target = new BudgetFormPropertyValidator(); //Act var result = target.IsValid(excelProperties, contentType, production); //Assert result.Should().NotBeNull(); result.Success.Should().BeTrue(); }
public void AnyProduction_For_Photography_Return_Success() { //Arrange var excelProperties = new ExcelProperties { [core.Constants.BudgetFormExcelPropertyNames.LookupGroup] = "LookupGroup", [core.Constants.BudgetFormExcelPropertyNames.ContentType] = "Photography", [core.Constants.BudgetFormExcelPropertyNames.Production] = "Does not matter" }; var contentType = Constants.ContentType.Photography; const string production = Constants.ProductionType.FullProduction; var target = new BudgetFormPropertyValidator(); //Act var result = target.IsValid(excelProperties, contentType, production); //Assert result.Should().NotBeNull(); result.Success.Should().BeTrue(); }
public void Null_ExcelProperties_Throw_Exception() { //Arrange ExcelProperties excelProperties = null; const string contentType = "Audio"; const string production = "Full Production"; var target = new BudgetFormPropertyValidator(); //Act try { target.IsValid(excelProperties, contentType, production); } catch (ArgumentNullException) { return; } //Assert Assert.Fail(); //Should not reach here }
private bool ArePropertiesValid(ExcelProperties properties) { if (properties.Count == 0) { return(false); } if (!properties.ContainsKey(core.Constants.BudgetFormExcelPropertyNames.LookupGroup)) { return(false); } if (!properties.ContainsKey(core.Constants.BudgetFormExcelPropertyNames.ContentType)) { return(false); } if (!properties.ContainsKey(core.Constants.BudgetFormExcelPropertyNames.Production)) { return(false); } return(true); }
protected override void Print() { try { if (ShowMaint) { string path = Properties.Settings.Default.MaintTemplatePath; ExcelProperties props = new ExcelProperties(2, 1, false); MaintReport report = new MaintReport(MaintReports.ToList(), path, props); report.Print(); } else { string path = Properties.Settings.Default.RentTempatePath; ExcelProperties props = new ExcelProperties(2, 1, false); RentReport report = new RentReport(RentReports.ToList(), path, props); report.Print(); } } catch (Exception ex) { Helper.LogShowError(ex); } }
private static bool IsContentTypeValid(ExcelProperties properties, string contentType) { return(string.Compare(contentType, properties[core.Constants.BudgetFormExcelPropertyNames.ContentType], StringComparison.OrdinalIgnoreCase) == 0); }