96
Appendice B: Web Service
ReportGenerator
using System; using System.Collections; using System.ComponentModel; using System.Configuration; using System.Data; using System.Diagnostics; using System.Web; using System.Web.Services; namespace Statini.Admin { /// <summary>/// Generate reports for registered exams. /// </summary>
[WebService(Namespace="http://di.unipi.it/webservices/")]
public class ReportsGenerator : System.Web.Services.WebService { public ReportsGenerator() {
InitializeComponent(); }
#region Component Designer generated code //Required by the Web Services Designer private IContainer components = null;
97 /// <summary>
/// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary>
private void InitializeComponent() { }
/// <summary>
/// Clean up any resources being used. /// </summary>
protected override void Dispose( bool disposing ) { if(disposing && components != null) {
components.Dispose(); }
base.Dispose(disposing); }
#endregion
/// <returns>the number of generated reports</returns>
[WebMethod(Description="Generate and email to teacher report of recent grades")]
public int GenerateForProfessors() {
Report rep = new Report(this.Server.MapPath("")); try {
return rep.GenerateForProfessors(Global.esami); } catch (Exception ex) {
string email =
98 if (email != "")
rep.Send(email, "Error on generation", ex.ToString()); } return 0; } /// <summary> /// /// </summary>
/// <returns>the number of generated reports</returns> [WebMethod(Description="Generate and upload to admin server file with recent grades")]
public int GenerateForSecretary() {
Report rep = new Report(this.Server.MapPath("")); try {
return rep.GenerateForSecretary(Global.esami); } catch (Exception ex) {
string email =
(string)ConfigurationSettings.AppSettings["helpMail"]; if (email != "")
rep.Send(email, "Error on generation", ex.ToString());
}
return 0; }