private void cmdDisplay_Click(object sender, EventArgs e) { try { string strStartDate = this.txtStartDate.Text; if (!string.IsNullOrEmpty(strStartDate)) { strStartDate = strStartDate + " 00:00"; } string strEndDate = this.txtEndDate.Text; if (!string.IsNullOrEmpty(strEndDate)) { strEndDate = strEndDate + " 23:59"; } var objUrls = new UrlController(); // localize datagrid Localization.LocalizeDataGrid(ref this.grdLog, this.LocalResourceFile); this.grdLog.DataSource = objUrls.GetUrlLog(this.PortalSettings.PortalId, this.lblLogURL.Text, this.ModuleID, Convert.ToDateTime(strStartDate), Convert.ToDateTime(strEndDate)); this.grdLog.DataBind(); } catch (Exception exc) // Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
public override void HandleRequest() { string output = null; DialogParams dialogParams = Content.FromJson <DialogParams>(); // This uses the new JSON Extensions in DotNetNuke.Common.Utilities.JsonExtensionsWeb string link = dialogParams.LinkUrl; dialogParams.LinkClickUrl = link; if (dialogParams != null) { if (!(dialogParams.LinkAction == "GetLinkInfo")) { if (dialogParams.Track) { string tempVar = dialogParams.LinkUrl; dialogParams.LinkClickUrl = GetLinkClickURL(ref dialogParams, ref tempVar); dialogParams.LinkUrl = tempVar; UrlTrackingInfo linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, dialogParams.LinkUrl, dialogParams.ModuleId); if (linkTrackingInfo != null) { dialogParams.Track = linkTrackingInfo.TrackClicks; dialogParams.TrackUser = linkTrackingInfo.LogActivity; dialogParams.DateCreated = linkTrackingInfo.CreatedDate.ToString(); dialogParams.LastClick = linkTrackingInfo.LastClick.ToString(); dialogParams.Clicks = linkTrackingInfo.Clicks.ToString(); } else { dialogParams.Track = false; dialogParams.TrackUser = false; } dialogParams.LinkUrl = link; } } switch (dialogParams.LinkAction) { case "GetLoggingInfo": //also meant for the tracking tab but this is to retrieve the user information DateTime logStartDate = DateTime.MinValue; DateTime logEndDate = DateTime.MinValue; string logText = "<table><tr><th>Date</th><th>User</th></tr><tr><td colspan='2'>The selected date-range did<br /> not return any results.</td></tr>"; if (DateTime.TryParse(dialogParams.LogStartDate, out logStartDate)) { if (!(DateTime.TryParse(dialogParams.LogEndDate, out logEndDate))) { logEndDate = logStartDate.AddDays(1); } UrlController _urlController = new UrlController(); ArrayList urlLog = _urlController.GetUrlLog(dialogParams.PortalId, GetLinkUrl(ref dialogParams, dialogParams.LinkUrl), dialogParams.ModuleId, logStartDate, logEndDate); if (urlLog != null) { logText = GetUrlLoggingInfo(urlLog); } } dialogParams.TrackingLog = logText; break; case "GetLinkInfo": if (dialogParams.Track) { link = link.Replace(@"\", @"/"); //this section is for when the user clicks ok in the dialog box, we actually create a record for the linkclick urls. if (!(dialogParams.LinkUrl.ToLower().Contains("linkclick.aspx"))) { dialogParams.LinkClickUrl = GetLinkClickURL(ref dialogParams, ref link); } _urlController.UpdateUrl(dialogParams.PortalId, link, GetURLType(Globals.GetURLType(link)), dialogParams.TrackUser, true, dialogParams.ModuleId, false); } else { //this section is meant for retrieving/displaying the original links and determining if the links are being tracked(making sure the track checkbox properly checked) UrlTrackingInfo linkTrackingInfo = null; if (dialogParams.LinkUrl.Contains("fileticket")) { var queryString = dialogParams.LinkUrl.Split('='); var encryptedFileId = queryString[1].Split('&')[0]; string fileID = UrlUtils.DecryptParameter(encryptedFileId, dialogParams.PortalGuid); FileInfo savedFile = _fileController.GetFileById(Int32.Parse(fileID), dialogParams.PortalId); linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, string.Format("fileID={0}", fileID), dialogParams.ModuleId); } else if (dialogParams.LinkUrl.ToLowerInvariant().Contains("linkclick.aspx")) { try { if (dialogParams.LinkUrl.Contains("?")) { link = dialogParams.LinkUrl.Split('?')[1].Split('&')[0]; if (link.Contains("=")) { link = link.Split('=')[1]; } } int tabId; if (int.TryParse(link, out tabId)) //if it's a tabid get the tab path { dialogParams.LinkClickUrl = TabController.Instance.GetTab(tabId, dialogParams.PortalId, true).FullUrl; linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, tabId.ToString(), dialogParams.ModuleId); } else { dialogParams.LinkClickUrl = HttpContext.Current.Server.UrlDecode(link); //get the actual link linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, dialogParams.LinkClickUrl, dialogParams.ModuleId); } } catch (Exception ex) { Logger.Error(ex); dialogParams.LinkClickUrl = dialogParams.LinkUrl; } } if (linkTrackingInfo == null) { dialogParams.Track = false; dialogParams.TrackUser = false; } else { dialogParams.Track = linkTrackingInfo.TrackClicks; dialogParams.TrackUser = linkTrackingInfo.LogActivity; } } break; } output = dialogParams.ToJson(); } Response.Write(output); }