/// <summary>
        /// Updates the report generation queue output.
        /// </summary>
        /// <param name="newReportQueueGenerationOutput">The new report queue generation output.</param>
        public void UpdateReportGenerationQueueOutput(ReportGenerationQueueOutputDto newReportQueueGenerationOutput)
        {
            using (GenerationDao generationDao = DataAccessFactory.Create<GenerationDao>())
            {
                generationDao.Insert<ReportGenerationQueueOutput>(new ReportGenerationQueueOutput()
                {
                    ErrorMessage = newReportQueueGenerationOutput.ErrorMessage,
                    InsertedDate = DateTime.Now,
                    IsSuccessfulDeleted = newReportQueueGenerationOutput.IsSuccessfulDeleted,
                    IsSuccessfullyUploaded = newReportQueueGenerationOutput.IsSuccessfullyUploaded,
                    IsUserFolderMissing = newReportQueueGenerationOutput.IsUserFolderMissing,
                    ReportGenerationQueueId = newReportQueueGenerationOutput.ReportGenerationQueueId,
                    ReportReceiverStaffId = newReportQueueGenerationOutput.ReportReceiverStaffId,
                    UpdatedByStaffId = newReportQueueGenerationOutput.UpdatedByStaffId,
                    SharePointTargetUrl = newReportQueueGenerationOutput.SharePointTargetUrl
                });

                if (generationDao.CanSubmitChanges())
                {
                    generationDao.SubmitChanges();
                }
                else
                {
                    string errors = string.Empty;

                    foreach (EntityBase entity in generationDao.InvalidEntities)
                    {
                        foreach (string error in entity.Errors)
                        {
                            errors = errors += error + "\r\n";
                        }
                    }

                    throw new Exception("Could not write report generation queue output to database : " + errors);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the report generation queue output.
 /// </summary>
 /// <param name="newReportQueueGenerationOutput">The new report queue generation output.</param>
 public void UpdateReportGenerationQueueOutput(ReportGenerationQueueOutputDto newReportQueueGenerationOutput)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Uploads to sharepoint.
        /// </summary>
        /// <param name="fileMemoryStream">The file memory stream.</param>
        /// <param name="periodString">The period string.</param>
        /// <param name="reportReceiver">The report receiver.</param>
        private void UploadToSharepoint(MemoryStream fileMemoryStream, string periodString, ParameterReportReceiver reportReceiver)
        {
            SharePointWrapper sharePointWrapper = new SharePointWrapper(this.SharePointUserName, this.SharePointPassword, this.SharePointDomain, this.SharePointURL);

            using (GenerationDao generationDao = DataAccessFactory.Create<GenerationDao>())
            {
                var newReportQueueGenerationOutput = new ReportGenerationQueueOutputDto();

                try
                {
                    string destinationFolder = this.SharePointURL + this.SharePointURLExtended + reportReceiver.StaffName + "/";

                    newReportQueueGenerationOutput.SharePointTargetUrl = destinationFolder + periodString + "/" + this.GetFileName();

                    bool doesUserFolderExist = sharePointWrapper.CheckIfFolderExists(destinationFolder);

                    if (doesUserFolderExist)
                    {
                        sharePointWrapper.AddFile(destinationFolder + periodString + "/", this.ReportParameter.ReportName, fileMemoryStream.GetBuffer());

                        newReportQueueGenerationOutput.IsUserFolderMissing = false;
                        newReportQueueGenerationOutput.IsSuccessfullyUploaded = true;
                    }
                    else
                    {
                        newReportQueueGenerationOutput.IsUserFolderMissing = true;
                        newReportQueueGenerationOutput.IsSuccessfullyUploaded = false;
                    }
                }
                catch (ApplicationException ex)
                {
                    newReportQueueGenerationOutput.ErrorMessage = "Message:\n" + ex.Message + "\nDetail:\n" + ex.ToString() + "\nStackTrace:\n" + ex.StackTrace;
                    newReportQueueGenerationOutput.IsSuccessfullyUploaded = false;
                }
                finally
                {
                    newReportQueueGenerationOutput.ReportGenerationQueueId = this.ReportParameter.ReportGenerationQueueId;
                    newReportQueueGenerationOutput.ReportReceiverStaffId = reportReceiver.StaffID;

                    this._ReportQueueStatusService.UpdateReportGenerationQueueOutput(newReportQueueGenerationOutput);
                }
            }
        }