Exemplo n.º 1
0
        private void Update(DataGridCommandEventArgs e)
        {
            string strName        = dtbConfig.Rows[e.Item.ItemIndex]["Name"].ToString();
            string strDescription = dtbConfig.Rows[e.Item.ItemIndex]["Description"].ToString();

            bool noRichText = ((strName == "Number_Of_Quiz_Questions") || (strName == "css") || (strName == "ShowDetailedHelp") ||
                               (strName == "Student_Summary_Subject") || (strName == "Overdue_Summary_Subject"));

            string strValue = null;

            if (noRichText)
            {
                strValue = ((TextBox)dgrConfig.Items[(int)e.Item.ItemIndex].FindControl("txtValue_Edit2")).Text;
            }
            else
            {
                strValue = ((TextEditor)dgrConfig.Items[(int)e.Item.ItemIndex].FindControl("txtValue_Edit")).Text;
            }

            // Perform business update
            OrganisationConfig objOrgConfig = new OrganisationConfig();

            objOrgConfig.Update(0, strName, strDescription, strValue);

            // Done
            Response.Redirect("EmailDefault.aspx");
        }
 private void GetData()
 {
     if (dtbConfig == null)
     {
         OrganisationConfig objOrgConfig = new OrganisationConfig();
         dtbConfig = objOrgConfig.GetList(UserContext.UserData.OrgID);
     }
 }
Exemplo n.º 3
0
 private void GetData()
 {
     if (dtbConfig == null)
     {
         OrganisationConfig objOrgConfig = new OrganisationConfig();
         dtbConfig = objOrgConfig.GetList(0);
     }
 }
Exemplo n.º 4
0
        public void certemail(int intUserID, int intCourseID, int intProfileID)
        {
            int orgid;

            BusinessServices.User objUser = new BusinessServices.User();
            DataTable             dtUser  = objUser.GetUser(intUserID);

            Int32.TryParse(dtUser.Rows[0]["OrganisationID"].ToString(), out orgid);
            string username = dtUser.Rows[0]["UserName"].ToString();

            BusinessServices.AppConfig objAppConfig = new BusinessServices.AppConfig();
            DataTable dtbAppConfig = objAppConfig.GetList();
            string    strHostname  = HttpContext.Current.Request.Url.Authority.ToString();
            bool      isSSL        = bool.Parse(dtbAppConfig.Select("Name='SSL'")[0]["Value"].ToString());
            string    strUrl       = null;

            if (strHostname.ToLower().Equals("127.0.0.2"))
            {
                strUrl = "https://" + strHostname;
            }
            else
            {
                strUrl = "http://" + strHostname;
            }
            strUrl = "https://" + strHostname;
            //WriteErrorLog(strUrl.ToString());
            OrganisationConfig objOrgConfig = new OrganisationConfig();
            string             strCss       = objOrgConfig.GetOne(orgid, "css");

            string pdfFileName = "cert_" + username + "_" + intCourseID.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
            bool   status      = HtmlToPdf.WKHtmlToPdf(strUrl + @"/Certificate.aspx?courseid=" + intCourseID + "&profileid=" + intProfileID + "&userid=" + intUserID + "&orgid=" + orgid + "&css=" + strCss, pdfFileName);
            string filename    = "";

            if (status)
            {
                filename = HttpContext.Current.Server.MapPath(ConfigurationSettings.AppSettings["WorkingFolder"]) + "\\" + pdfFileName;
            }
            else
            {
                ErrorLog objError = new ErrorLog(new Exception("Course completion certificate"), ErrorLevel.Medium, "DefaultQuiz.cs", "GenerateCourseCompletionCertificate", "Course completion certificate generation failed: " + pdfFileName);
            }


            sendCertEmail(intUserID, intCourseID, orgid, filename);

            try
            {
                FileInfo fileinfo = new FileInfo(filename);
                if (fileinfo.Exists)
                {
                    File.Delete(filename);
                }
            }
            catch (Exception e)
            {
                ErrorLog objError = new ErrorLog(e, ErrorLevel.Medium, "DefaultQuiz.cs", "DeleteCourseCompletionCertificate", "Course completion certificate deletion failed: " + pdfFileName);
            }
        }
        private void Delete(DataGridCommandEventArgs e)
        {
            // Gather Values
            int    intOrganisationID = UserContext.UserData.OrgID;
            string strName           = dtbConfig.Rows[e.Item.ItemIndex]["Name"].ToString();

            // Perform business update
            OrganisationConfig objOrgConfig = new OrganisationConfig();

            objOrgConfig.Delete(intOrganisationID, strName);

            // Done
            Response.Redirect("OrganisationConfiguration.aspx");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Style sheet for printing.
        /// </summary>
        //protected System.Web.UI.HtmlControls.HtmlGenericControl lnkStyleSheetPrint;

        protected void Page_Load(object sender, System.EventArgs e)
        {
            string strCss = "";

            // If the organisation is known
            try
            {
                OrganisationConfig objOrgConfig = new OrganisationConfig();
                strCss = objOrgConfig.GetOne(Utilities.UserContext.UserData.OrgID, "css");

                // If its an empty string then use the application name
                if (strCss.Length == 0)
                {
                    strCss = Utilities.ApplicationSettings.StyleSheet;
                }

                // append '.css' if requied
                if (!strCss.ToLower().EndsWith(".css"))
                {
                    strCss += ".css";
                }

                strCss = "/general/css/" + strCss;

                // Update the stylesheet link
                lnkStyleSheet.Attributes.Add("href", strCss);
            }

            // If the organisation isnt known then default css is used.
            catch
            {
                // Update the stylesheet link
                strCss = Utilities.ApplicationSettings.StyleSheet;

                // append '.css' if requied
                if (!strCss.ToLower().EndsWith(".css"))
                {
                    strCss += ".css";
                }
                strCss = "/general/css/" + strCss;
                lnkStyleSheet.Attributes.Add("href", strCss);
            }

            // Style sheet link for printing
            //lnkStyleSheetPrint.Attributes.Add("href","/General/css/PrintFriendly.css");
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            OrganisationConfig objOrgConfig = new OrganisationConfig();
            string             strShow      = objOrgConfig.GetOne(Utilities.UserContext.UserData.OrgID, "ShowDetailedHelp");

            if (strShow[0].ToString().ToLower() == "y")
            {
                string strKey  = this.Attributes["Key"].ToString();
                string strDesc = this.Attributes["Desc"].ToString();

                this.lnkToHelpFile.Text        = strDesc;
                this.lnkToHelpFile.NavigateUrl = "/Help.aspx#" + strKey;
            }
            else
            {
                this.lnkToHelpFile.Visible = false;
            }
        }
Exemplo n.º 8
0
		private string GetEmailBody(EmailReportType emailReportType)
		{
			OrganisationConfig objOrgConfig = new OrganisationConfig();
			BusinessServices.AppConfig objAppConfig = new BusinessServices.AppConfig();
			string strEmailBody="";

			switch (emailReportType)
			{
				case EmailReportType.Email_Incomplete_CPD_User:
				{
					strEmailBody = objOrgConfig.GetOne(UserContext.UserData.OrgID,"Email_Incomplete_CPD_User");
					break;
				}
				
				case EmailReportType.Email_Incomplete_CPD_Administrator:
				{
					strEmailBody = objOrgConfig.GetOne(UserContext.UserData.OrgID,"Email_Incomplete_CPD_Administrator");
					break;
				}
			} // switch

			
			// Get the application conffiguration details
			DataTable dtbAppConfig = objAppConfig.GetList();

			// Setup the email body
			foreach (DataRow drwAppConfig in dtbAppConfig.Rows)
			{
				if (drwAppConfig.ItemArray[0].ToString().ToUpper()=="APPNAME")
				{
					strEmailBody = strEmailBody.Replace("%APP_NAME%",drwAppConfig.ItemArray[1].ToString());
				}
			}
			strEmailBody = strEmailBody.Replace("<BR>",Environment.NewLine);
			return (strEmailBody);
		}
Exemplo n.º 9
0
        public static void sendCertEmail(int userid, int courseid, int orgid, string certPath)
        {
            Organisation org = new Organisation();
            AppConfig    a   = new AppConfig();

            if (!org.orgMailFlagConfig(orgid, 0, userid) && a.getConfigValue("SEND_AUTO_EMAILS").ToUpper().Equals("YES"))
            {
                User        usr     = new User();
                DataTable   dtUser  = usr.GetUser(userid);
                MailAddress emailTo = new MailAddress(dtUser.Rows[0]["Email"].ToString());

                string strEmailFrom = null;

                using (StoredProcedure sp = new StoredProcedure("prcUser_GetAdministratorsEmailAddress",
                                                                StoredProcedure.CreateInputParam("@UserId", SqlDbType.Int, userid))
                       )
                {
                    strEmailFrom = sp.ExecuteScalar().ToString();
                }
                MailAddress emailFrom = new MailAddress(strEmailFrom);
                MailMessage emailCert = new MailMessage(emailFrom, emailTo);

                OrganisationConfig orgConfig = new OrganisationConfig();

                Course    course       = new Course();
                DataTable dtCourse     = course.GetCourse(courseid, orgid);
                Email     eml          = new Email();
                string    strEmailBody = orgConfig.GetOne(orgid, "Course_Completion_Certificate");
                eml.SetEmailBody(strEmailBody, userid, dtCourse.Rows[0]["Name"].ToString(), "", "", "", "", "", "", "");
                strEmailBody = eml.getEmailBody();

                emailCert.Body    = strEmailBody;
                emailCert.Subject = eml.emailHeaderSub("%APP_NAME% - " + dtCourse.Rows[0]["Name"].ToString());
                Attachment cert = new Attachment(certPath);
                if (!certPath.Equals(""))
                {
                    emailCert.Attachments.Add(cert);
                }

                emailCert.IsBodyHtml = true;

                emailCert.From = new MailAddress(getOnBehalfOfEmail());

                emailCert.Sender = emailFrom;

                //SmtpClient client = new SmtpClient();
                string     MailServer = (string)HttpContext.Current.Application["MailServer"];
                SmtpClient SmtpMail   = new SmtpClient(MailServer);
                SmtpMail.Credentials = new System.Net.NetworkCredential();      //.CredentialCache.DefaultNetworkCredentials;
                emailCert.Headers.Add("Reply-To", emailCert.Sender.ToString()); //for IIS7 and below
                emailCert.ReplyTo = emailCert.Sender;                           //for IIS7.5 and above
                //SmtpClient smtp = new SmtpClient();
                //smtp.Host = "smtp.nsw.exemail.com.au";
                //smtp.Port = 25;
                //smtp.UseDefaultCredentials = false;
                ////smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                //smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                ////smtp.Credentials = new NetworkCredential("custadmin", "decemBer25TH1");
                //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "abcd-1234");
                //smtp.EnableSsl = true;
                ////smtp.EnableSsl = false;
                //smtp.Timeout = 20000;


                try
                {
                    SmtpMail.Send(emailCert);
                    //smtp.Send(emailCert);

                    eml.LogSentEmail(dtUser.Rows[0]["Email"].ToString(),
                                     dtUser.Rows[0]["FirstName"].ToString() + " " + dtUser.Rows[0]["LastName"].ToString(),
                                     emailFrom.Address, emailFrom.Address, "", "", emailCert.Subject, emailCert.Body, orgid, userid);
                }
                catch (Exception e)
                {
                    // General Exception occured, log it
                    ErrorLog objError = new ErrorLog(e, ErrorLevel.Medium, "DefaultQuiz.cs", "SendCourseCompletionCertificateEmail", "Course completion send email failed: " + certPath);
                }

                //SmtpClient client = new SmtpClient();
                //client.Send(emailCert);
                finally
                {
                    cert.ContentStream.Close();
                }
            }
        }