public bool EditSubscription(ReportSchedule reportSchedule)
        {
            service.Resource = "api/Report/";
            service.PutData(reportSchedule);

            return true;
        }
        /// <summary>
        /// Returns corresponding reporty subscription schedule data 
        /// </summary>
        /// <param name="reportSchedule"></param>
        /// <returns>Schedule xml</returns>
        public string GetMatchData(ReportSchedule reportSchedule)
        {
            ScheduleDefinition schedule = new ScheduleDefinition();

            //Make start date time as the begining of the current day
            schedule.StartDateTime = DateTime.Today.Add(reportSchedule.ScheduleTime);

            //if (reportSchedule.Expiration_Date_for_the_Schedule != null)
            //{
            //    if (schedule.StartDateTime < schedule.EndDate)
            //    {
            //        schedule.EndDateSpecified = true;
            //        schedule.EndDate = schedule.EndDate;
            //    }
            //    else
            //    {
            //        schedule.EndDate = schedule.StartDateTime.AddMinutes(20);
            //        schedule.EndDateSpecified = true;
            //    }
            //}
            //else
            //{
            //    schedule.EndDateSpecified = false;
            //}
            schedule.EndDateSpecified = false;
            schedule.Item = GetPattern(reportSchedule.SchedulePeriod, reportSchedule.ScheduleDay);

            XmlDocument xmlDoc = GetScheduleAsXml(schedule);
            return xmlDoc.OuterXml;
        }
Exemple #3
0
 public void Post(ReportSchedule reportSchedule)
 {
     //var result = reportManager.CreateSubscription(reportSchedule, @"\\CMLASHFERNANDO\Shared");
     if (reportSchedule.DeliveryTypeId == (int)DeliveryTypes.File)
     {
         var result = reportManager.CreateFileSubscription(reportSchedule);
     }
     else if (reportSchedule.DeliveryTypeId == (int)DeliveryTypes.Email)
     {
         var result = reportManager.CreateEmailSubscription(reportSchedule);
     }
 }
Exemple #4
0
        public ActionResult Create(ReportSchedule reportschedule)
        {
            reportschedule.Report = db.Reports.Where(r => r.ReportId == reportschedule.ReportId).FirstOrDefault();
            var result = reportBusinessManager.CreateSubscription(reportschedule);

            //if (ModelState.IsValid)
            //{
                //db.ReportSchedules.Add(reportschedule);
                //db.SaveChanges();
                //return RedirectToAction("Index");
            //}

            ViewBag.ReportId = new SelectList(db.Reports, "ReportId", "ReportName", reportschedule.ReportId);

            return RedirectToAction("Index");
        }
Exemple #5
0
 void setContext(ITypeDescriptorContext context)
 {
     _metaConnection   = context.Instance as MetaConnection;
     _metaEnum         = context.Instance as MetaEnum;
     _metaTable        = context.Instance as MetaTable;
     _metaColumn       = context.Instance as MetaColumn;
     _metaJoin         = context.Instance as MetaJoin;
     _reportView       = context.Instance as ReportView;
     _reportOutput     = context.Instance as ReportOutput;
     _reportSchedule   = context.Instance as ReportSchedule;
     _parameter        = context.Instance as Parameter;
     _security         = context.Instance as SealSecurity;
     _emailDevice      = context.Instance as OutputEmailDevice;
     _fileServerDevice = context.Instance as OutputFileServerDevice;
     _model            = context.Instance as ReportModel;
     _configuration    = context.Instance as SealServerConfiguration;
     _widget           = context.Instance as DashboardWidget;
 }
Exemple #6
0
        public async Task <ReportSchedule> LoadReportSchedule(long id)
        {
            string url       = $"https://{apiUrl}/api/Report/{id}";
            var    apiHelper = new ApiHelper(_accessor).InitializeClient();

            using (HttpResponseMessage response = await apiHelper.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    ReportSchedule report = await response.Content.ReadAsAsync <ReportSchedule>();

                    return(report);
                }
                else
                {
                    return(null);
                }
            }
        }
Exemple #7
0
        public async Task <IActionResult> PutReportSchedule(ReportSchedule reportSchedule)
        {
            _context.Entry(reportSchedule).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ReportScheduleExists(reportSchedule.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #8
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ReportSchedule reportSchedule)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ReportBuilderServer v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            reportSchedule.Start();
        }
Exemple #9
0
        // PUT api/report/5

        public void Put(ReportSchedule value)
        {
            reportManager.UpdateSubscription(value);
        }
Exemple #10
0
        public ActionResult Edit(ReportSchedule reportschedule)
        {
            //if (ModelState.IsValid)
            //{
            //    db.Entry(reportschedule).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            //ViewBag.ReportId = new SelectList(db.Reports, "ReportId", "ReportName", reportschedule.ReportId);

               // reportschedule.ReportSubscriptionId = db.ReportSchedules.Where(r => r.ReportId == reportschedule.ReportId).Select(r => r.ReportSubscriptionId).FirstOrDefault();

            reportBusinessManager.EditSubscription(reportschedule);
            ViewBag.ReportId = new SelectList(db.Reports, "ReportId", "ReportName");
            return RedirectToAction("Index");
        }
Exemple #11
0
        /// <summary>
        /// Pouplate parmeter values needed for the report subscription
        /// </summary>
        /// <param name="reportSchedule">report schedule parmate</param>
        /// <returns></returns>
        public ParameterValue[] PopulateParamters(ReportSchedule reportSchedule)
        {
            List <ParameterValue> parameterValueList = new List <ParameterValue>();

            ReportingService2010 rs = new ReportingService2010();

            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //string report = "/Report_Sample_Subscription/Release_Details_Report_RUM";
            string report       = reportSchedule.Report.ReportPath;
            bool   forRendering = false;
            string historyID    = null;

            ParameterValue[]        values      = null;
            DataSourceCredentials[] credentials = null;
            ItemParameter[]         parameters  = null;

            try
            {
                parameters = rs.GetItemParameters(report, historyID, forRendering, values, credentials);

                if (parameters != null)
                {
                    foreach (var parameter in parameters)
                    {
                        ParameterValue param = new ParameterValue();
                        param.Name = parameter.Name;

                        if (parameter.Name == "BranchID")
                        {
                            param.Value = "1";
                        }
                        else if (parameter.Name == "Releases")
                        {
                            //param.Value = reportSchedule.Release_ID.ToString();
                            //param.Value = "3013";
                        }
                        //else if (parameter.Name == "StoreStatus")
                        //{
                        //    //param.Value = reportSchedule.Release_ID.ToString();
                        //    param.Value = "Temp_Closed";
                        //}
                        //else if (parameter.Name == "RegionDivision")
                        //{
                        //    //param.Value = reportSchedule.Release_ID.ToString();
                        //    param.Value = "0";
                        //}
                        //else if (parameter.Name == "DeploymentDates")
                        //{
                        //    //param.Value = reportSchedule.Release_ID.ToString();
                        //    param.Value = "0";
                        //}
                        //else if (parameter.ParameterTypeName == "Boolean")
                        //{
                        //    param.Value = "False";
                        //}
                        //else if (parameter.MultiValue)
                        //{
                        //    param.Value = "1";
                        //}
                        //else if (parameter.ParameterTypeName == "String")
                        //{
                        //    param.Value = parameter.DefaultValues.ToString();
                        //}
                        //else if (parameter.ParameterTypeName == "Int")
                        //{
                        //    param.Value = "1";
                        //    param.Value = parameter.DefaultValues.ToString();

                        //}
                        else
                        {
                            //Console.WriteLine("Name: {0}", parameter.Name);
                            param.Value = parameter.DefaultValues[0].ToString();
                        }

                        parameterValueList.Add(param);
                    }
                }
            }

            catch (SoapException e)
            {
                Console.WriteLine(e.Detail.InnerXml.ToString());
            }

            return(parameterValueList.ToArray());
        }
Exemple #12
0
        public bool CreateEmailSubscription(ReportSchedule reportSchedule)
        {
            string report       = reportSchedule.Report.ReportPath;
            string desc         = reportSchedule.Report.ReportDescription;
            string eventType    = TimedSubscription;
            bool   isSuccessful = false;

            //Getting the schedule data
            string scheduleXml = new ReportScheduleFormatter().GetMatchData(reportSchedule);

            //string scheduleXml = @"<ScheduleDefinition>";
            //scheduleXml += @"<StartDateTime>2003-02-24T09:00:00-08:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval>";
            //scheduleXml += @"<DaysOfWeek><Monday>True</Monday></DaysOfWeek>";
            //scheduleXml += @"</WeeklyRecurrence></ScheduleDefinition>";

            ParameterValue[] extensionParams = new ParameterValue[8];

            extensionParams[0]       = new ParameterValue();
            extensionParams[0].Name  = "TO";
            extensionParams[0].Value = reportSchedule.EmailTo;//"*****@*****.**";

            extensionParams[1]       = new ParameterValue();
            extensionParams[1].Name  = "ReplyTo";
            extensionParams[1].Value = "*****@*****.**";

            extensionParams[2]       = new ParameterValue();
            extensionParams[2].Name  = "IncludeReport";
            extensionParams[2].Value = "True";

            extensionParams[3]       = new ParameterValue();
            extensionParams[3].Name  = "RenderFormat";
            extensionParams[3].Value = "MHTML";

            extensionParams[4]       = new ParameterValue();
            extensionParams[4].Name  = "Subject";
            extensionParams[4].Value = "@ReportName was executed at @ExecutionTime";

            extensionParams[5]       = new ParameterValue();
            extensionParams[5].Name  = "Comment";
            extensionParams[5].Value = reportSchedule.EmailComment;//"Here is your daily sales report for Michael.";

            extensionParams[6]       = new ParameterValue();
            extensionParams[6].Name  = "IncludeLink";
            extensionParams[6].Value = "True";

            extensionParams[7]       = new ParameterValue();
            extensionParams[7].Name  = "Priority";
            extensionParams[7].Value = "NORMAL";

            ParameterValue parameter = new ParameterValue();

            parameter.Name  = "BranchID";
            parameter.Value = "1";

            ParameterValue[] parameters = new ParameterValue[1];
            parameters[0] = parameter;

            string            matchData   = scheduleXml;
            ExtensionSettings extSettings = new ExtensionSettings();

            extSettings.ParameterValues = extensionParams;
            extSettings.Extension       = "Report Server Email";

            try
            {
                var subscriptionId = rs.CreateSubscription(report, extSettings, desc, eventType, matchData, parameters);

                isSuccessful = true;

                reportSchedule.ReportSubscriptionId = subscriptionId;
                reportSchedule.Report = null;

                db.ReportSchedules.Add(reportSchedule);
                db.SaveChanges();
            }

            catch (SoapException e)
            {
                Console.WriteLine(e.Detail.InnerXml.ToString());
            }
            return(isSuccessful);
        }
Exemple #13
0
 public void Init()
 {
     instance = new ReportSchedule();
 }
Exemple #14
0
 // PUT api/report/5
 public void Put(ReportSchedule value)
 {
     reportManager.UpdateSubscription(value);
 }
 public void EditSchedule(ReportSchedule schedule)
 {
 }
Exemple #16
0
        /// <summary>
        /// This method will create required subscription if not exist
        /// </summary>
        /// <param name="reportSchedule">Name of the Report</param>
        /// <param name="parametersDictionary">Report Parameters</param>
        /// <returns></returns>
        public bool CreateFileSubscription(ReportSchedule reportSchedule)
        {
            //Getting the shared folder path from the config file
            string shareFolderPath = ConfigurationManager.AppSettings[ReportSubscirptionSharedPath];
            //string shareFolderPath = sharedSubscriptionFolderPath;

            bool isSuccessful = false;

            //ReportingService2010 rs = new ReportingService2010();
            //rs.Url = ConfigurationManager.AppSettings[ReportServerURL];

            //rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

            //rs.UseDefaultCredentials = true;

            //Check whether the subscription already exist
            //bool isExist = IsSubscriptionExist(rs, reportSchedule);
            bool isExist = false;

            if (!isExist)
            {
                string report    = reportSchedule.Report.ReportPath;
                string desc      = reportSchedule.Report.ReportDescription;
                string eventType = TimedSubscription;

                //Getting the schedule data
                string scheduleXml = new ReportScheduleFormatter().GetMatchData(reportSchedule);

                //Populating the the extension parameters
                ParameterValue[] extensionParams = new ParameterValue[7]
                {
                    new ParameterValue {
                        Name = Path, Value = shareFolderPath
                    },
                    new ParameterValue {
                        Name = FileName, Value = String.Concat(/*reportSchedule.Schedule_ID,*/ FileNameSplitter, reportSchedule.Report.ReportName, FileNameSplitter, TimestampParameter)
                    },
                    new ParameterValue {
                        Name = FileExtention, Value = "TRUE"
                    },
                    new ParameterValue {
                        Name = UserName, Value = ConfigurationManager.AppSettings[ReportUsername]
                    },
                    new ParameterValue {
                        Name = Password, Value = ConfigurationManager.AppSettings[ReportPassword]
                    },
                    new ParameterValue {
                        Name = Render_Format, Value = RenderFormat.EXCEL.ToString()
                    },
                    new ParameterValue {
                        Name = FileWriteMode, Value = WriteMode.Overwrite.ToString()
                    }
                };

                ExtensionSettings extSettings = new ExtensionSettings();
                extSettings.ParameterValues = extensionParams;
                extSettings.Extension       = SubscriptionMode;

                ParameterValue[] parameters = PopulateParamters(reportSchedule);

                var subscriptionId = rs.CreateSubscription(report, extSettings, desc,
                                                           eventType, scheduleXml, parameters);

                isSuccessful = true;

                reportSchedule.ReportSubscriptionId = subscriptionId;
                reportSchedule.Report = null;

                db.ReportSchedules.Add(reportSchedule);
                db.SaveChanges();

                //Add the subscription to the Schedule table


                //Console.WriteLine("Report subscription successFully created");
            }

            else
            {
                //Console.WriteLine("Report subscription already exist");
            }

            return(isSuccessful);
        }
Exemple #17
0
        public void SynchronizeSchedules(ExecutionLogInterface log, bool useCurrentUser)
        {
            int           count = 0, errorCount = 0, taskDeleted = 0;
            StringBuilder errorSummary = new StringBuilder("");

            Repository repository = Repository.Instance.CreateFast();

            try
            {
                log.Log("Starting Report Schedules Synchronization\r\n");

                if (!Helper.IsMachineAdministrator() && !useCurrentUser)
                {
                    log.Log("WARNING: For this tool, we recommend to execute the 'Server Manager' application with the option 'Run as administrator'\r\n");
                }

                SynchronizeSchedules(log, repository.ReportsFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);
                log.Log("Checking personal folders\r\n");
                SynchronizeSchedules(log, repository.PersonalFolder, repository, ref count, ref errorCount, errorSummary, useCurrentUser);

                log.Log("Checking for Orphan schedules\r\n");

                if (repository.UseWebScheduler)
                {
                    SealReportScheduler.Instance.GetSchedules();
                }
                else
                {
                    TaskService taskService = new TaskService();
                    TaskFolder  taskFolder  = taskService.RootFolder.SubFolders.FirstOrDefault(i => i.Name == repository.Configuration.TaskFolderName);
                    if (taskFolder != null)
                    {
                        foreach (Task task in taskFolder.GetTasks())
                        {
                            log.Log("Checking task '{0}'", task.Name);
                            try
                            {
                                string reportPath   = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 0);
                                string reportGUID   = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 1);
                                string scheduleGUID = ReportSchedule.GetTaskSourceDetail(task.Definition.RegistrationInfo.Source, 3);
                                Report report       = ReportExecution.GetScheduledReport(taskFolder, reportPath, reportGUID, scheduleGUID, repository);
                                if (report != null)
                                {
                                    ReportSchedule schedule = ReportExecution.GetReportSchedule(taskFolder, report, scheduleGUID);
                                    if (schedule == null)
                                    {
                                        taskDeleted++;
                                        log.Log("WARNING: Unable to find schedule '{0}' in report '{1}'. Task has been deleted.", scheduleGUID, report.FilePath);
                                    }
                                }
                                else
                                {
                                    taskDeleted++;
                                    log.Log("WARNING: Unable to find report '{0}' for schedule '{1}'. Report tasks have been deleted.", reportGUID, scheduleGUID);
                                }
                            }
                            catch (Exception ex)
                            {
                                errorCount++;
                                log.LogRaw("ERROR\r\n");
                                log.Log(ex.Message);
                                errorSummary.AppendFormat("\r\nTask '{0}': {1}\r\n", task.Name, ex.Message);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Log("\r\n[UNEXPECTED ERROR RECEIVED]\r\n{0}\r\n", ex.Message);
            }
            log.Log("Report Schedules Synchronization terminated\r\n");

            log.Log("SUMMARY: {0} Report(s) checked, {1} Task(s) deleted, {2} Error(s) detected.\r\n{3}", count, taskDeleted, errorCount, errorSummary);
            if (errorCount == 0)
            {
                log.Log("Youpi, pas d'erreur !");
            }
        }
        /// <summary>
        /// The execute.
        /// </summary>
        /// <returns>
        /// The execute.
        /// </returns>
        /// <exception cref="Exception">
        /// </exception>
        /// <exception cref="FormatException">
        /// </exception>
        public override bool Execute()
        {
            R2DeploymentManger r2DeploymentManger = new R2DeploymentManger(this.ReportServerURL);

            r2DeploymentManger.DeploymentMangerMessages += this.deploymentMangerMessages;
            ReportSchedule[] reportSchedules = new ReportSchedule[this.ReportSchedules.Length];
            string           invaildReportScheduleMessage;
            DateTime         reportScheduleDateTime;

            try
            {
                for (int index = 0; index < this.ReportSchedules.Length; index++)
                {
                    if (!this.isVaildReportSchedule(this.ReportSchedules[index], out invaildReportScheduleMessage))
                    {
                        throw new Exception(invaildReportScheduleMessage);
                    }

                    reportSchedules[index]      = new ReportSchedule();
                    reportSchedules[index].Name = this.ReportSchedules[index].ItemSpec;

                    if (
                        !DateTime.TryParse(
                            this.ReportSchedules[index].GetMetadata("StartDateTime"), out reportScheduleDateTime))
                    {
                        throw new FormatException(
                                  string.Format(
                                      "Report Schedule {0} StartDateTime is not vaild ", this.ReportSchedules[index].ItemSpec));
                    }

                    reportSchedules[index].StartDateTime = reportScheduleDateTime;

                    if (!string.IsNullOrEmpty(this.ReportSchedules[index].GetMetadata("EndDateTime")))
                    {
                        if (
                            !DateTime.TryParse(
                                this.ReportSchedules[index].GetMetadata("EndDateTime"), out reportScheduleDateTime))
                        {
                            throw new FormatException(
                                      string.Format(
                                          "Report Schedule {0} EndDateTime is not vaild ",
                                          this.ReportSchedules[index].ItemSpec));
                        }

                        reportSchedules[index].EndDateTime = reportScheduleDateTime;
                    }

                    reportSchedules[index].ScheduleRecurrence =
                        (ScheduleRecurrenceOptions)
                        Enum.Parse(
                            typeof(ScheduleRecurrenceOptions),
                            this.ReportSchedules[index].GetMetadata("ScheduleRecurrence"),
                            true);

                    switch (reportSchedules[index].ScheduleRecurrence)
                    {
                    case ScheduleRecurrenceOptions.Min:
                    case ScheduleRecurrenceOptions.Daily:
                        reportSchedules[index].Interval = this.ReportSchedules[index].GetMetadata("Interval");
                        break;

                    case ScheduleRecurrenceOptions.Weekly:
                        this.GetDaysOfWeek(
                            reportSchedules[index].Days, this.ReportSchedules[index].GetMetadata("DaysOfWeek"));
                        if (!string.IsNullOrEmpty(this.ReportSchedules[index].GetMetadata("Interval")))
                        {
                            reportSchedules[index].Interval = this.ReportSchedules[index].GetMetadata("Interval");
                        }

                        break;

                    case ScheduleRecurrenceOptions.Monthly:
                        this.GetMonthsOfYear(
                            reportSchedules[index].Months, this.ReportSchedules[index].GetMetadata("MonthsOfYear"));
                        if (!string.IsNullOrEmpty(this.ReportSchedules[index].GetMetadata("Interval")))
                        {
                            reportSchedules[index].Interval = this.ReportSchedules[index].GetMetadata("Interval");
                        }

                        break;

                    case ScheduleRecurrenceOptions.MonthlyDOW:
                        this.GetDaysOfWeek(
                            reportSchedules[index].Days, this.ReportSchedules[index].GetMetadata("DaysOfWeek"));
                        this.GetMonthsOfYear(
                            reportSchedules[index].Months, this.ReportSchedules[index].GetMetadata("MonthsOfYear"));
                        if (!string.IsNullOrEmpty(this.ReportSchedules[index].GetMetadata("Interval")))
                        {
                            reportSchedules[index].Interval = this.ReportSchedules[index].GetMetadata("Interval");
                        }

                        break;
                    }
                }

                return(r2DeploymentManger.CreateSchedules(reportSchedules, this.ReportingSite));
            }
            catch (Exception ex)
            {
                this.BuildEngine.LogErrorEvent(
                    new BuildErrorEventArgs(
                        "Reporting",
                        "CreateReportSchedule",
                        this.BuildEngine.ProjectFileOfTaskNode,
                        this.BuildEngine.LineNumberOfTaskNode,
                        this.BuildEngine.ColumnNumberOfTaskNode,
                        0,
                        0,
                        ex.Message,
                        string.Empty,
                        this.ToString()));
                return(false);
            }
        }