protected void TakeSnapshot() { try { DNNSnapshotSettings settingsData = new DNNSnapshotSettings(this.TabModuleId); if (settingsData.UrlToCheck.Length > 1) { StartDuration(); Bitmap bmp = ClassWSThumb.GetWebSiteThumbnail(txtURL.Text.ToString(), Int32.Parse(settingsData.BrowserWidth), Int32.Parse(settingsData.BrowserHeight), Int32.Parse(settingsData.ThumbWidth), Int32.Parse(settingsData.ThumbHeight)); string MyFileName = txtURL.Text.ToString().Replace("https://", "").Replace("http://", ""); MyFileName = MyFileName.Replace("/", "\\"); // lblDebug.Text = PortalSettings.HomeDirectoryMapPath.ToString() + settingsData.ImageFolder.ToString().Replace("/", "\\").ToString() + MyFileName.ToString() + ".jpg"; bmp.Save(PortalSettings.HomeDirectoryMapPath.ToString() + settingsData.ImageFolder + MyFileName + ".jpg", ImageFormat.Jpeg); ImageBox.ImageUrl = "~" + PortalSettings.HomeDirectory.ToString() + settingsData.ImageFolder.ToString().Replace("/", "\\").ToString() + MyFileName + ".jpg?timestamp=1"; ImageBox.Visible = true; StopDuration(); string SnapURL = PortalSettings.HomeDirectory.ToString() + settingsData.ImageFolder + MyFileName + ".jpg"; SendNotifications(SnapURL); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// handles the loading of the module setting for this /// control /// </summary> public override void LoadSettings() { try { if (!IsPostBack) { BindFolders(); DNNSnapshotSettings settingsData = new DNNSnapshotSettings(this.TabModuleId); if (settingsData.UrlToCheck != null) { txtUrlToCheck.Text = settingsData.UrlToCheck; } if (settingsData.EmailAddress != null) { txtEmailAddress.Text = settingsData.EmailAddress; } if (settingsData.EmailFrom != null) { txtEmailFrom.Text = settingsData.EmailFrom; } if (settingsData.EmailSubject != null) { txtEmailSubject.Text = settingsData.EmailSubject; } if (settingsData.BrowserHeight != null) { txtBrowserHeight.Text = settingsData.BrowserHeight; } if (settingsData.BrowserWidth != null) { txtBrowserWidth.Text = settingsData.BrowserWidth; } if (settingsData.ThumbHeight != null) { txtThumbHeight.Text = settingsData.ThumbHeight; } if (settingsData.ThumbWidth != null) { txtThumbWidth.Text = settingsData.ThumbWidth; } if (settingsData.AutoLoad != null) { rblAutoLoad.SelectedValue = settingsData.AutoLoad; } if (settingsData.ImageFolder != null) { drpDefaultImageFolder.SelectedValue = settingsData.ImageFolder; } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { DNNSnapshotSettings settingsData = new DNNSnapshotSettings(this.TabModuleId); if (settingsData.AutoLoad == "true" || Request.QueryString["ScheduledTask"] == "true") { if (settingsData.UrlToCheck != null) { if (settingsData.UrlToCheck.Length > 1) { txtURL.Text = settingsData.UrlToCheck.ToString(); TakeSnapshot(); } } } else { if (settingsData.UrlToCheck != null) { if (settingsData.UrlToCheck.Length > 1) { txtURL.Text = settingsData.UrlToCheck.ToString(); } } else { lblDebug.Text = "Click Settings to Configure Module"; } } } else { } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// handles updating the module settings for this control /// </summary> public override void UpdateSettings() { try { DNNSnapshotSettings settingsData = new DNNSnapshotSettings(this.TabModuleId); settingsData.BrowserHeight = txtBrowserHeight.Text; settingsData.BrowserWidth = txtBrowserWidth.Text; settingsData.ThumbHeight = txtThumbHeight.Text; settingsData.ThumbWidth = txtThumbWidth.Text; settingsData.EmailSubject = txtEmailSubject.Text; settingsData.EmailAddress = txtEmailAddress.Text; settingsData.UrlToCheck = txtUrlToCheck.Text; settingsData.AutoLoad = rblAutoLoad.SelectedValue; settingsData.ImageFolder = drpDefaultImageFolder.SelectedValue; settingsData.EmailFrom = txtEmailFrom.Text; } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void SendNotifications(string SnapshotURL) { try { DNNSnapshotSettings settingsData = new DNNSnapshotSettings(this.TabModuleId); if (settingsData.EmailAddress.Length > 1) { string MailFrom = PortalSettings.Email.ToString(); string mySubject = settingsData.EmailSubject.ToString(); string SMTPUserName = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("SMTPUsername"); string myBaseURL = this.PortalSettings.DefaultPortalAlias.ToString(); string EmailContent = "<p>URL: " + txtURL.Text.ToString() + "<br>Time Taken: " + DateTime.Now + "<br>Snapshot Request Time: " + lblTime.Text + "</p>"; EmailContent += "<p align='center'><img src='http://" + myBaseURL.ToString() + SnapshotURL + "' alt='" + txtURL.Text.ToString() + "'></p>"; EmailContent += "<p>" + PortalSettings.PortalName + " - http://" + myBaseURL.ToString() + Request.RawUrl + "<p>"; string emailAddress = settingsData.EmailAddress; var emailListToSend = emailAddress.Split(';').ToList(); string[] emailAttachemnts1 = new string[] { }; string sendToEmailAddress = ""; for (int i = 0; i < emailListToSend.Count; i++) { sendToEmailAddress = emailListToSend[i].ToString().Trim(); DotNetNuke.Services.Mail.Mail.SendMail(SMTPUserName.ToString(), sendToEmailAddress.ToString(), "", "", sendToEmailAddress.ToString(), DotNetNuke.Services.Mail.MailPriority.Normal, mySubject.ToString(), DotNetNuke.Services.Mail.MailFormat.Html, System.Text.ASCIIEncoding.ASCII, EmailContent.ToString(), emailAttachemnts1, string.Empty, string.Empty, string.Empty, string.Empty, true); //MailFrom, MailTo, Cc, Bcc, ReplyTo, Priority, Subject, BodyFormat, BodyEncoding, Body, Attachments, SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword, SMTPEnableSSL } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }