public void Process(ReportEntity reportEntity, RepositoryCoverageEntity coverageEntity) { if (this._fileHelper.Exists(reportEntity.FilePath) == false) { Console.WriteLine($"File Not Found: {reportEntity.FilePath}"); throw new FileNotFoundException("File Not Found!", reportEntity.FilePath); } //// Parser Console.WriteLine("* Parser"); var methodList = this._reportParser.Parser(coverageEntity, reportEntity); //// Update Console.WriteLine("* Update"); var updateMethodList = this._coverageUpdater.Update(coverageEntity, methodList); //// Notify Console.WriteLine("* Notify"); if (IsSendSlack()) { this.GetSlackNotifyer().Notify(coverageEntity, updateMethodList); } this.GetEmailNotifyer().Notify(coverageEntity, updateMethodList); //// Log Console.WriteLine("* Log"); this._coverageLogger.Log(updateMethodList); }
public override string SetNewData(XtraReport report, string defaultUrl) { // Save a report to the storage under a new URL. // The defaultUrl parameter contains the report display name specified by a user. if (CanSetData(defaultUrl)) { SetData(report, defaultUrl); } else { using (var session = SessionFactory.Create()) { MemoryStream ms = new MemoryStream(); report.SaveLayout(ms); var reportEntity = new ReportEntity(session) { Url = defaultUrl, Layout = ms.ToArray() }; session.CommitChanges(); } } return(defaultUrl); }
public static ReEntity CreateReportList(List <OrderEntity> list, bool isContainDeliverPlan = false) { ReEntity reEntity = new ReEntity(); if (list != null && list.Count > 0) { List <ReportEntity> reportList = new List <ReportEntity>(); int i = 1; foreach (OrderEntity entity in list) { ReportEntity rEntity = new ReportEntity(); //序号 订单编号 订单属性 订单归属 发货仓库 供应商 下单日期 收货方 收货地址 货物重量 配送数量 应收总额 应付总额 利润 rEntity.ID = i++; rEntity.OrderNo = entity.OrderNo; rEntity.OrderType = entity.OrderTypeDesc; rEntity.OrderOwner = entity.customer != null ? entity.customer.CustomerName : ""; rEntity.SendStorageName = entity.sendstorage != null ? entity.sendstorage.StorageName : ""; rEntity.CarrierName = entity.carrier != null ? entity.carrier.CarrierName : ""; rEntity.OrderDate = DateTime.Parse(entity.OrderDate); rEntity.ReceiverName = entity.contact != null ? entity.contact.name : ""; rEntity.ReceiverAddress = entity.contact != null ? entity.contact.address : ""; rEntity.Weight = TotalWeight(entity.orderDetailList); rEntity.Quantity = TotalQuantity(entity.orderDetailList); //应收 rEntity.TotalReceiverFee = entity.configPrice + entity.configHandInAmt + entity.configSortPrice; rEntity.configPrice = entity.configPrice; rEntity.configHandInAmt = entity.configHandInAmt; rEntity.configSortPrice = entity.configSortPrice; //应付 rEntity.TotalPayFee = entity.configCosting + entity.configHandOutAmt + entity.configSortCosting; rEntity.configCosting = entity.configCosting; rEntity.configHandOutAmt = entity.configHandOutAmt; rEntity.configSortCosting = entity.configSortCosting; rEntity.Profit = rEntity.TotalReceiverFee - rEntity.TotalPayFee; rEntity.Remark = entity.Remark; if (isContainDeliverPlan) { List <OrderDeliverPlanEntity> planList = OrderDeliverPlanService.GetOrderDeliverPlanAll(entity.OrderID + ","); if (planList != null && planList.Count > 0) { OrderDeliverPlanEntity planEntity = planList[0]; rEntity.CarNo = planEntity.CarNo; rEntity.CarModel = planEntity.CarModel; rEntity.DriverName = planEntity.DriverName; rEntity.Remark2 = planEntity.Remark; rEntity.DeliveryNo = planEntity.DeliveryNo; } } reportList.Add(rEntity); } reEntity.reportList = reportList; } return(reEntity); }
public object reportDataBind(ReportEntity reportEntity) { var query = (from s in db.Reports where s.UserId == reportEntity.UserId && s.IsDeleted == false select new { ReportId = s.ReportId, Amount = s.Amount }).ToList(); return(query); }
public static ReportEntity Map(this ReportModel model) { var entity = new ReportEntity { Id = model.Id }; model.Map(entity); return(entity); }
public async Task <ReportEntity> SearchOrCreate(long idCompany, long idUser, long idWeek, long idCreator) { if (dbPermissionEntities.Count(p => p.CompanyId == idCompany && p.RoleId == 601 && p.UserId == idUser) > 0) { var report = await db.Include(r => r.Seen).Include(r => r.User).Include(r => r.Files).Where(r => r.WeekId == idWeek && r.UserId == idUser && r.CompanyId == idCompany) .FirstOrDefaultAsync(); if (report == null) { report = new ReportEntity() { CompanyId = idCompany, UserId = idUser, WeekId = idWeek }; db.Add(report); context.SaveChanges(); report.Seen = new List <SeenReportsEntity>(); report.Files = new List <FileEntity>(); } if (report != null) { if (report.Id > 0 && !report.Seen.Exists(s => s.UserId == idCreator) && (!string.IsNullOrEmpty(report.Financial) || !string.IsNullOrEmpty(report.Operative))) { dbSeenReportsEntities.Add(new SeenReportsEntity() { Report = report, UserId = idCreator }); context.SaveChanges(); var aux = db.Include(r => r.Seen).Include(r => r.User).Include(r => r.Files) .FirstOrDefault(r => r.Id == report.Id); report = aux; return(report); } else { var seen = report.Seen.FirstOrDefault(s => s.UserId == idCreator); if (seen != null) { context.Entry(seen).CurrentValues.SetValues(new SeenReportsEntity() { Id = seen.Id, UserId = seen.UserId, ReportId = seen.ReportId, SeenAt = DateTime.Now }); context.SaveChanges(); return(report); } } } return(report); } return(null); }
/// <summary> /// Конструктор /// </summary> /// <param name="entityIds"></param> /// <param name="entity"></param> /// <param name="report"></param> public ReportPage(int[] entityIds, ReportEntity entity, ReportView report) { InitializeComponent(); _viewModel = new ReportViewModel(entityIds, entity, report); this.BindingContext = _viewModel; Title = Droid.Resources.Messages.Text_Report; }
// public IActionResult EditReport(int id) { TempData["active"] = TempDataInfo.TaskOrder; ReportEntity entity = new ReportEntity(); entity = _reportService.GetReportWithTaskProperty(id); var model = _mapper.Map <ReportEditDto>(entity); return(View(model)); }
public async Task <IActionResult> Create([Bind("Id,Date,Source,SourceLatitude,SourceLongitude,Name,LastName,Phone,Email,Description,PicturePath")] ReportEntity reportEntity) { if (ModelState.IsValid) { _context.Add(reportEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(reportEntity)); }
public static void Map(this ReportModel model, ReportEntity entity) { entity.Name = model.Name; entity.TemplateId = model.TemplateId; entity.GroupId = model.TemplateId; if (entity.Id != Guid.Empty) { entity.Id = model.Id; } }
protected void Page_Load(object sender, EventArgs e) { ReportEntity re = (ReportEntity)BusinessManager.Load(ReportEntity.GetAssignedMetaClassName(), PrimaryKeyId.Parse(Request["ReportId"])); string sql = BindFilterControl(re); if (!Page.IsPostBack) { BindReport(re, sql); BindToolbar(); } }
private static void Main(string[] args) { // create service collection var serviceCollection = new ServiceCollection(); var configuration = ConfigureServices(serviceCollection, args); // create service provider var serviceProvider = serviceCollection.BuildServiceProvider(); var reportEntity = new ReportEntity { FilePath = configuration[Arguments.Report]?.Trim(), }; var file = new FileInfo(reportEntity.FilePath); var fileName = file.Name; fileName = fileName.Substring(0, fileName.LastIndexOf('.')); var coverageEntity = new RepositoryCoverageEntity { CoverageFileName = $"{fileName}.csv", OutputPath = file.DirectoryName, Repository = configuration[Arguments.Repository]?.Trim(), Project = configuration[Arguments.Project]?.Trim(), }; var coverageProcessor = serviceProvider.GetService <ICoverageProcessor>(); var mode = string.IsNullOrWhiteSpace(configuration[Arguments.Mode]) == false ? configuration[Arguments.Mode].ToEnum <ModeType>() : ModeType.Full; System.Console.WriteLine($"Mode: {mode}"); switch (mode) { case ModeType.Parse: System.Console.WriteLine("Parser And Collect"); coverageProcessor.ProcessParserAndCollect(reportEntity, coverageEntity); break; case ModeType.Update: System.Console.WriteLine("Load From Collect. Update And Nofity"); coverageProcessor.ProcessUpdateAndNotify(coverageEntity); break; case ModeType.Full: default: System.Console.WriteLine("Parser, Update And Notify"); coverageProcessor.Process(reportEntity, coverageEntity); break; } serviceProvider.Dispose(); }
public static Report ToService(this ReportEntity entity) { return(entity != null ? new Report { Id = entity.Id, Title = entity.Title, Summary = entity.Summary, Author = entity.Author, PublicationDate = entity.PublicationDate, DownloadCount = entity.DownloadCount } : null); }
/// <summary> /// Method to Save Report Data /// </summary> /// <param name="report">Report</param> /// <returns><c>true</c> if Report data is successfully saved else returns <c>false</c></returns> public bool SaveReportData(Report report) { bool isReportDataSaved = false; try { if (report != null && report.ReportDataList != null && report.ReportDataList.Count > 0) { ReportEntity rptEntity = new ReportEntity() { Name = report.Name, ImportDate = DateTime.Now }; db.Report.Add(rptEntity); db.SaveChanges(); foreach (var reportData in report.ReportDataList) { ReportDataEntity rptDataEntity = new ReportDataEntity() { ReportId = rptEntity.ReportId, Node = reportData.Node, Panel = reportData.Panel, Event = reportData.Event, EventDateTime = reportData.EventDateTime, CardNumber = reportData.CardNumber, CardName = reportData.CardName, Location = reportData.Location, ReaderId = reportData.ReaderId, In = reportData.In, Out = reportData.Out, Affiliation = reportData.Affiliation, AlarmText = reportData.AlarmText, EmployeeName = ExtractEmployeeFirstName(reportData.CardName) + " " + ExtractEmployeeLastName(reportData.CardName), EmployeeCode = ExtractEmployeeCode(reportData.CardName) }; db.ReportData.Add(rptDataEntity); } db.SaveChanges(); isReportDataSaved = true; } } catch (Exception ex) { throw ex; } return(isReportDataSaved); }
public async Task <IActionResult> Edit(string id) { var vm = new ReportViewModel(); ReportEntity entity = null; try { entity = await _reportRepository.GetByIdAsync(id); } catch (Exception ex) { } vm = _mapper.Map <ReportViewModel>(entity); return(View(vm)); }
/// <summary> /// 评论举报 /// </summary> /// <param name="entity">举报实体</param> /// <returns></returns> public OperationResult <bool> Report_Insert(ReportEntity entity) { try { using (SqlConnection con = new SqlConnection(SQlHelper.MyConnectStr)) { SqlTransaction trans = null; con.Open(); trans = con.BeginTransaction(); SqlParameter[] prms = { new SqlParameter("@FromUserID", entity.FromUserID), new SqlParameter("@ReportTypeID", entity.ReportTypeID), new SqlParameter("@ReportContent", entity.ReportContent), new SqlParameter("@ReportInfoTypeID", entity.ReportInfoTypeID), new SqlParameter("@ReportInfoID", entity.ReportInfoID), new SqlParameter("@CreateTime", entity.CreateTime == null ? DateTime.Now :entity.CreateTime) }; string insert_sql = string.Empty; string select_sql = string.Empty; select_sql = " SELECT COUNT(1) FROM M_Report WHERE FromUserID={0} AND ReportInfoTypeID={1} AND ReportInfoID={2} "; select_sql = string.Format(select_sql, entity.FromUserID, entity.ReportInfoTypeID, entity.ReportInfoID); int count = int.Parse(SQlHelper.ExecuteScalar(SQlHelper.MyConnectStr, CommandType.Text, select_sql).ToString()); if (count > 0) { return(new OperationResult <bool>(OperationResultType.NoChanged, "您已举报过了!", false)); } insert_sql = " INSERT INTO M_Report(FromUserID,ReportTypeID,ReportContent,ReportInfoTypeID,ReportInfoID,CreateTime) "; insert_sql += " VALUES(@FromUserID,@ReportTypeID,@ReportContent,@ReportInfoTypeID,@ReportInfoID,@CreateTime) "; bool state = SQlHelper.ExecuteNonQuery(trans, CommandType.Text, insert_sql, prms) > 0; trans.Commit(); if (state) { return(new OperationResult <bool>(OperationResultType.Success, "举报成功!", state)); } else { return(new OperationResult <bool>(OperationResultType.Error, "举报失败!", state)); } } } catch (Exception ex) { LogUtil.WriteLog(ex); return(new OperationResult <bool>(OperationResultType.NoConnection, Description.EnumDescription(OperationResultType.NoConnection))); } }
/// <summary> /// 讀取涵蓋率 /// </summary> /// <param name="reportEntity">The report entity.</param> /// <param name="coverageEntity">The coverage entity.</param> /// <exception cref="NotImplementedException"></exception> public void ProcessParserAndCollect(ReportEntity reportEntity, RepositoryCoverageEntity coverageEntity) { if (this._fileHelper.Exists(reportEntity.FilePath) == false) { Console.WriteLine($"File Not Found: {reportEntity.FilePath}"); throw new FileNotFoundException("File Not Found!", reportEntity.FilePath); } //// Parser Console.WriteLine("* Parser"); var methodList = this._reportParser.Parser(coverageEntity, reportEntity); //// Log Console.WriteLine("* Collect"); this._coverageCollect.Collect(coverageEntity, methodList); }
public async Task <IActionResult> Delete(string id) { var vm = new ReportViewModel(); ReportEntity entity = null; try { entity = await _reportRepository.GetByIdAsync(id); await _reportRepository.DeleteAsync(entity); } catch (Exception ex) { } return(RedirectToAction("Index")); }
public void AddReport(CreateReportDto report) { var dog = _dogService.Add(report.Dog); var reportEntity = new ReportEntity { ContactEmail = report.ContactEmail, ContactNumber = report.ContactNumber, DateReported = DateTime.UtcNow, DogId = dog.Id }; _reportRepository.SaveAll(); _reportRepository.AddReport(reportEntity); _reportRepository.SaveAll(); }
public ReportEntity Submit(ReportEntity data, string userid) { var db = new RepositoryFactory().BaseRepository(); var users = default(List <UserEntity>); if (!string.IsNullOrEmpty(data.ToUserId)) { var userids = data.ToUserId.Split(','); users = (from q in db.IQueryable <UserEntity>() where userids.Contains(q.UserId) select q).ToList(); } using (var ctx = new DataContext()) { var entity = ctx.Reports.Include("Notices").FirstOrDefault(x => x.ReportId == data.ReportId); entity.Plan = data.Plan; entity.ReportContent = data.ReportContent; entity.Tasks = data.Tasks; entity.Undo = data.Undo; entity.Cantdo = data.Cantdo; entity.IsSubmit = true; if (users != null) { users.RemoveAll(x => entity.Notices.Any(y => y.UserId == x.UserId)); foreach (var item in users) { entity.Notices.Add(new ReportNotice() { NoticeId = Guid.NewGuid(), IsRead = false, UserId = item.UserId, UserName = item.RealName, NoticeType = 1 }); } } ctx.SaveChanges(); return(new ReportEntity() { ReportId = entity.ReportId, ReportType = this.ToTypeString(entity.ReportType) }); } }
public static ReportModel Map(this ReportEntity entity) { if (entity == null) { return(null); } return(new ReportModel { Id = entity.Id, Name = entity.Name, GroupId = entity.GroupId, TemplateId = entity.TemplateId, Group = entity.Group?.Map(), Template = entity.Template?.Map(), }); }
private List <long> UserFromReport(BiContext context, ReportEntity report) { var _dbCompany = context.Set <CompanyEntity>(); var _dbUser = context.Set <PermissionEntity>(); var userList = new List <long>(); var company = _dbCompany.Find(report.CompanyId); userList.Add(report.UserId); while (company.ParentId != null) { company = _dbCompany.Find(company.ParentId); } var ceo = _dbUser.Where(p => p.CompanyId == company.Id && (p.RoleId == 602 || p.RoleId == 603)) .Select(p => p.UserId).ToList(); return(userList.Concat(ceo).ToList()); }
private void BindReport(ReportEntity reportEntity, string filter) { MemoryStream memStream = new MemoryStream(); StreamWriter writer = new StreamWriter(memStream); writer.Write(reportEntity.RdlText); writer.Flush(); memStream.Seek(0, SeekOrigin.Begin); rvMain.LocalReport.LoadReportDefinition(memStream); ReportDataResponse rdr = BusinessManager.Execute <ReportDataRequest, ReportDataResponse>(new ReportDataRequest(reportEntity, filter)); foreach (DataTable dt in rdr.Data) { rvMain.LocalReport.DataSources.Add(new ReportDataSource(dt.TableName, dt)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var ReportId = Request.QueryString["reportId"]; if (ReportId != null && ReportId != String.Empty) { lblReportId.Text = ReportId; reportEntity = accountManagerBusiness.reportData(Convert.ToInt32(ReportId)); lblAmt.Text = Convert.ToString(reportEntity.Amount); lblDate.Text = Convert.ToString(reportEntity.ReportDate); lblName.Text = reportEntity.Owner; lblApprover.Text = "Account Manager"; GridView1.DataSource = accountManagerBusiness.viewReport(Convert.ToInt32(ReportId)); GridView1.DataBind(); } } }
/// <summary> /// Adds new response for report /// </summary> /// <param name="responseToCreate">Data of new response</param> /// <param name="userId">Identifier of currently authorized user</param> /// <returns>Service result with operation status and object to return (Updated details of the report)</returns> public async Task <IServiceResult <ReportDetailsToReturnDto> > SendResponse(ReportResponseToCreateDto responseToCreate, int userId) { try { UserEntity user = await _userManager.Users.Where(x => x.Id == userId).Include(ur => ur.UserRoles).ThenInclude(r => r.Role).FirstOrDefaultAsync(); string userRole = user.UserRoles.Select(x => x.Role).FirstOrDefault().Name; ReportEntity reportToUpdate = await _repository.GetReportById(responseToCreate.ReportId, userRole, userId); if (reportToUpdate != null) { ResponseEntity response = new ResponseEntity { Date = DateTime.Now, Message = responseToCreate.Message, UserId = userId }; reportToUpdate.Responses.Add(response); reportToUpdate.ModificationEntries.Add(HistoryEntriesGenerator.GetNewResponseEntry(user.UserName, reportToUpdate.Heading)); _repository.SaveChanges(); await SendEmployeeRespondedEmail(reportToUpdate.UserId, reportToUpdate.Heading); ReportDetailsToReturnDto reportToReturn = _reportMapper.Map(reportToUpdate); return(new ServiceResult <ReportDetailsToReturnDto>(ResultType.Correct, reportToReturn)); } return(new ServiceResult <ReportDetailsToReturnDto>(ResultType.Failed, new List <string> { "Błąd podczas aktualizacji zgłoszenia" })); } catch (Exception) { return(new ServiceResult <ReportDetailsToReturnDto>(ResultType.Error, new List <string> { "Błąd podczas aktualizacji zgłoszenia" })); } }
public static byte[] GenerateExcel(ReportEntity entity) { string tmpFile = $"{Path.GetDirectoryName(entity.TemplatePath)}\\{Guid.NewGuid()}_report.xlsx"; try { File.Copy(entity.TemplatePath, tmpFile, true); var destFileInfo = new FileInfo(tmpFile); using (MemoryStream ms = new MemoryStream()) { using (FileStream fs = File.OpenRead(tmpFile)) { using (ExcelPackage excelPackage = new ExcelPackage(fs)) { ExcelWorkbook excelWorkBook = excelPackage.Workbook; ExcelWorksheet excelWorksheet = excelWorkBook.Worksheets.FirstOrDefault(x => x.Name.Equals(entity.SheetName)); var tuple = CreateHeaderRow(excelWorksheet, entity.ExcelEntities); excelPackage.SaveAs(ms); // This is the important part. } ms.Position = 0; var result = ms.ToArray(); ms.Flush(); if (File.Exists(tmpFile)) { File.Delete(tmpFile); } return(result); } } } catch (Exception ex) { if (File.Exists(tmpFile)) { File.Delete(tmpFile); } throw ex; } }
protected void cBackReport_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) { ReportEntity dataReport = new ReportEntity(); DataTable dTabel = dataReport.GetDataReportOAT(datePeriodeStart.Date, datePeriodeEnd.Date, Convert.ToInt32(cmbTBBM.SelectedItem.Value), cmbForce.SelectedItem.Value.ToString(), cmbUnity.SelectedItem.Value.ToString()); string region = dataReport.GetRegion(cmbTBBM.SelectedItem.Value.ToString()); Report.xReportOAT report = new FrancoHandling_App.Report.xReportOAT(); report.xrLabel_Title1.Text = "REKAP PENYALURAN FRANCO BBM " + cmbForce.SelectedItem.Value.ToString().ToUpper() + " DI " + cmbTBBM.SelectedItem.Text.ToUpper() + " " + region; report.xrLabel_Title2.Text = "PERIODE " + datePeriodeStart.Date.ToString("dd MMM yyyy") + " SAMPAI DENGAN " + datePeriodeEnd.Date.ToString("dd MMM yyyy"); report.xrLabel_TBBM.Text = ": " + cmbTBBM.SelectedItem.Text; report.xrLabel_Force.Text = ": " + cmbForce.SelectedItem.Text; report.xrLabel_Unity.Text = ": " + cmbUnity.SelectedItem.Text; report.DataSource = dTabel; report.DataMember = dTabel.TableName; docViewer.OpenReport(report); //docViewer.DataBind(); }
public void UpdateReport(ReportEntity report, string currentReportId) { if (report == null) { throw new ArgumentException("ReportEntity cannot be null."); } if (string.IsNullOrEmpty(currentReportId)) { throw new ArgumentException("CurrentReportId cannot be Null or empty."); } //DB using (var unitOfWork = _dependencyResolver.Resolve <IUnitOfWork>()) { unitOfWork.ReportRepository.UpdateReport(report); unitOfWork.SaveChanges(); } }
/// <summary> /// Updates status of report /// </summary> /// <param name="statusToUpdate">New status and report identifier</param> /// <param name="userId">Identifier of currently authorized user</param> /// <returns>Service result with operation status and object to return (Updated modifiation entries and status)</returns> public async Task <IServiceResult <ReportStatusUpdateToReturnDto> > UpdateStatus(ReportStatusUpdateToCreateDto statusToUpdate, int userId) { try { UserEntity user = await _userManager.Users.Where(x => x.Id == userId).Include(ur => ur.UserRoles).ThenInclude(r => r.Role).FirstOrDefaultAsync(); string userRole = user.UserRoles.Select(x => x.Role).FirstOrDefault().Name; ReportEntity reportToUpdate = await _repository.GetReportById(statusToUpdate.ReportId, userRole, userId); if (reportToUpdate != null) { reportToUpdate.Status = (StatusEnum)Enum.Parse(typeof(StatusEnum), statusToUpdate.NewStatus.ToString()); string statusName = ConvertToStatusName(reportToUpdate.Status); reportToUpdate.ModificationEntries.Add(HistoryEntriesGenerator.GetStatusUpdatedEntry(user.UserName, statusName)); _repository.SaveChanges(); await SendStatusChangedEmail(reportToUpdate.UserId, reportToUpdate.Heading, reportToUpdate.Status); ReportStatusUpdateToReturnDto statusUpdated = new ReportStatusUpdateToReturnDto { ModificationEntries = _reportMapper.Map(reportToUpdate.ModificationEntries).ToList(), Status = statusToUpdate.NewStatus }; return(new ServiceResult <ReportStatusUpdateToReturnDto>(ResultType.Correct, statusUpdated)); } return(new ServiceResult <ReportStatusUpdateToReturnDto>(ResultType.Error, new List <string> { "Błąd podczas aktualizacji zgłoszenia" })); } catch (Exception) { return(new ServiceResult <ReportStatusUpdateToReturnDto>(ResultType.Error, new List <string> { "Błąd podczas aktualizacji zgłoszenia" })); } }
public ReportEntity GetReport(string id, string userid) { var reportid = Guid.Parse(id); var result = default(ReportEntity); using (var ctx = new DataContext()) { var entity = ctx.Reports.Include("Notices").Include("Comments").FirstOrDefault(x => x.ReportId == reportid); var notice = entity.Notices.Find(x => x.UserId == userid); if (notice.IsRead == false) { notice.IsRead = true; ctx.SaveChanges(); } result = new ReportEntity() { ReportId = entity.ReportId, ReportContent = entity.ReportContent, StartTime = entity.StartTime, EndTime = entity.EndTime, Plan = entity.Plan, ReportTime = entity.ReportTime, ReportType = this.ToTypeString(entity.ReportType), ReportUserId = entity.ReportUserId, ReportUser = entity.ReportUser, Tasks = entity.Tasks, Undo = entity.Undo, Cantdo = entity.Cantdo, IsSubmit = entity.IsSubmit, Comments = entity.Comments.OrderByDescending(x => x.CommentTime).Select(y => new CommentEntity() { CommentId = y.CommentId, Content = y.Content, CommentUserId = y.CommentUserId, CommentUser = y.CommentUser }).ToList(), Notices = entity.Notices.Select(x => new NoticeEntity() { NoticeId = x.NoticeId, ReportId = x.ReportId, UserId = x.UserId, UserName = x.UserName, IsRead = x.IsRead }).ToList() }; } if (result != null) { IRepository db = new RepositoryFactory().BaseRepository(); var file = (from q in db.IQueryable <FileInfoEntity>() where q.RecId == id select q).FirstOrDefault(); if (file != null) { result.FilePath = file.FilePath; } } return(result); }
public ViewResult DefineScope(int id) { ReportEntity report = new ReportEntity(id); DefineScopeViewModel model = new DefineScopeViewModel() { Recommendations = Service.RecsByReport(report), RecommendationTypes = Service.RecommendationType() }; return View("DefineScope", model); }
private ReportEntity PopulateReportEntityDomain(DataRow dr, UserEntity user) { ReportEntity re = new ReportEntity(); re.Id = (int)dr["ReportId"]; re.Title = dr["Title"].ToString(); if (dr["LastUpdated"].ToString() != "") re.LastUpdated = dr["LastUpdated"].ToString(); re.ReportStatus = dr["ReportStatus"].ToString(); if (user == null) return re; //Public doesn't need stuff below if (user.IsSFWStaff) //global setting, not report specific { re.Permissions.Add(ReportEntity.Permission.ExportReport); re.Permissions.Add(ReportEntity.Permission.Comment); re.Permissions.Add(ReportEntity.Permission.Answer); re.Permissions.Add(ReportEntity.Permission.UpdateStatus); } else if (dr["IsReviewer"].ToString() == "1") //report specific setting { re.Permissions.Add(ReportEntity.Permission.ExportReport); re.Permissions.Add(ReportEntity.Permission.CompleteReview); } else if (dr["IsAnalyst"].ToString() == "1") //report specific setting { re.Permissions.Add(ReportEntity.Permission.Comment); re.Permissions.Add(ReportEntity.Permission.Answer); re.Permissions.Add(ReportEntity.Permission.ExportReport); //TODO: remove after tab is back, but let them download report for now } else { } return re; }
//Guid _reportLinkId; #endregion Class Level Members #region How To Sample Code /// <summary> /// Create and configure the organization service proxy. /// Retrieve the history limit of a report. /// </summary> /// <param name="serverConfig">Contains server connection information.</param> /// <param name="promptforDelete">When True, the user will be prompted to delete all /// created entities.</param> public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete) { try { // Connect to the Organization service. // The using statement assures that the service proxy will be properly disposed. using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials)) { // This statement is required to enable early-bound type support. _serviceProxy.EnableProxyTypes(); // Call the method to create any data that this sample requires. CreateRequiredRecords(); //<snippetPublishReport1> // Define an anonymous type to define the possible values for // report type. var ReportTypeCode = new { ReportingServicesReport = 1, OtherReport = 2, LinkedReport = 3 }; // Define an anonymous type to define the possible values for // report category. var ReportCategoryCode = new { SalesReports = 1, ServiceReports = 2, MarketingReports = 3, AdministrativeReports = 4 }; // Define an anonymous type to define the possible values for // report visibility var ReportVisibilityCode = new { ReportsGrid = 1, Form = 2, Grid = 3, }; // Instantiate a report object. // See the Entity Metadata topic in the SDK documentation to determine // which attributes must be set for each entity. Report sampleReport = new Report { Name = "Sample Report", BodyText = File.ReadAllText("SampleReport.rdl"), FileName = "SampleReport.rdl", LanguageCode = 1033, // US English ReportTypeCode = new OptionSetValue(ReportTypeCode.ReportingServicesReport) }; // Create a report record named Sample Report. _reportId = _serviceProxy.Create(sampleReport); // Set the report category. ReportCategory sampleReportCategory = new ReportCategory { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), CategoryCode = new OptionSetValue(ReportCategoryCode.AdministrativeReports) }; _reportCategoryId = _serviceProxy.Create(sampleReportCategory); // Define which entity this report uses. ReportEntity reportEntity = new ReportEntity { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), ObjectTypeCode = Account.EntityLogicalName }; _reportEntityId = _serviceProxy.Create(reportEntity); // Set the report visibility. ReportVisibility rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Form) }; _reportVisibilityId1 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.Grid) }; _reportVisibilityId2 = _serviceProxy.Create(rv); rv = new ReportVisibility { ReportId = new EntityReference(Report.EntityLogicalName, _reportId), VisibilityCode = new OptionSetValue(ReportVisibilityCode.ReportsGrid) }; _reportVisibilityId3 = _serviceProxy.Create(rv); Console.WriteLine("{0} published in Microsoft Dynamics CRM.", sampleReport.Name); //</snippetPublishReport1> DeleteRequiredRecords(promptForDelete); } } // Catch any service fault exceptions that Microsoft Dynamics CRM throws. catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>) { // You can handle an exception here or pass it back to the calling method. throw; } }
public IList<RecEntity> RecsByReport(ReportEntity report) { DataTable dt = DB.GetDataTable(new SQLBuilder(@"select rec.Id as RecommendationId, s.CommonName, s.Genus + ' ' + s.Species as ScientificName, l.Description as Location, bow.Description as BodyOfWater, m.Method, rt.Description as RecommendationType, rt.Id as RecommendationTypeId, rec.SpeciesId, rec.LocationId, rec.BodyOfWaterId, rec.MethodId from Recommendation rec inner join Species s on s.Id = rec.SpeciesId and rec.ReportId = @0 left join Location l on l.Id = rec.Locationid left join BodyOfWater bow on bow.Id = rec.BodyOfwaterId left join Method m on m.Id = rec.MethodId inner join RecommendationType rt on rt.Id = rec.RecommendationTypeId ORDER BY s.CommonName, l.Description, bow.Description, m.Method", report.Id.ToString())); List<RecEntity> recs = new List<RecEntity>(); foreach (DataRow dr in dt.Rows) { RecEntity rec = new RecEntity(); //TODO: Talk to Bryan about how this method isn't working //Framework.EntityPopulate(rec, dr); rec.BodyOfWater = dr["BodyOfWater"].ToString(); rec.CommonName = dr["CommonName"].ToString(); rec.Location = dr["Location"].ToString(); rec.Method = dr["Method"].ToString(); rec.RecommendationId = Convert.ToInt32(dr["RecommendationId"]); rec.RecommendationType = dr["RecommendationType"].ToString(); rec.ScientificName = dr["ScientificName"].ToString(); //TODO: Have Bryan review my addition of the Ids fields - it would be better to have objects (RowsourceEntity?) instead of separate ID and Name properties rec.RecommendationTypeId = Convert.ToInt32(dr["RecommendationTypeId"]); rec.SpeciesId = Convert.ToInt32(dr["SpeciesId"]); rec.LocationId = Convert.ToInt32(dr["LocationId"]); rec.BodyOfWaterId = Convert.ToInt32(dr["BodyOfWaterId"]); rec.MethodId = Convert.ToInt32(dr["MethodId"]); recs.Add(rec); } return recs; }