/
ivan
/
ModMas
Обзор
Документация
Войти
/
ivan
/
ModMas
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ModuleMaster/slideshow/slideshowurl.aspx.vb
192 строки
11 KB
i.krivokon
Initial commit
13 мар 2026, 13:49
13 мар 2026, 13:49
00d9fb6
Код
Авторство
О чём код?
Imports System.Data Imports sharedClasses.dbFunctions Partial Class Slideshow_slideshowurl Inherits System.Web.UI.Page Private sqlf As New SqlFunctions Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim slideShowId As String = Request.QueryString("id") Dim showInfo As String = Request.QueryString("showInfo") If Not IsNothing(showInfo) Then If showInfo.ToLower = "false" Then info.Visible = False End If End If If Not IsNothing(slideShowId) Then If IsNumeric(slideShowId) Then lblSlideShowId.Text = slideShowId Dim currentItem As String = status.Attributes("currentitem") Dim totalitems As String = status.Attributes("totalitems") Dim dt As DataTable = Nothing If IsNothing(currentItem) Then 'Starting new slideshow dt = sqlf.GetData("SELECT * FROM UserModules.[user].slide_show_url WHERE enable='Y' and slide_show_id = " & slideShowId & " ORDER by cast(isnull(position, 999) as integer)") If Not IsNothing(dt) Then totalitems = dt.Rows.Count.ToString End If Else 'Resuming existing If IsNumeric(currentItem) Then dt = sqlf.GetData("SELECT * FROM UserModules.[user].slide_show_url WHERE enable='Y' and slide_show_id = " & slideShowId & " AND cast(isnull(position, 999) as integer) > " & currentItem & " ORDER by cast(isnull(position, 999) as integer)") If Not IsNothing(dt) Then If dt.Rows.Count > 0 Then 'Continue slideshow Else 'Start from the biginning dt = sqlf.GetData("SELECT * FROM UserModules.[user].slide_show_url WHERE enable='Y' and slide_show_id = " & slideShowId & " ORDER by cast(isnull(position, 999) as integer)") totalitems = dt.Rows.Count.ToString End If End If End If End If If Not IsNothing(dt) Then If dt.Rows.Count > 0 Then '-- ------- Check for image attached status.Attributes.Add("currentitem", IIf(IsDBNull(dt.Rows(0)("position")), 999, dt.Rows(0)("position"))) status.Attributes.Add("totalitems", totalitems) status.Text = IIf(IsDBNull(dt.Rows(0)("position")), 999, dt.Rows(0)("position")) & " of " & totalitems Dim imgId As String = sqlf.GetScalar("SELECT max(id) FROM UserModulesAttachments.[user].SLIDE_SHOW_URL WHERE deleted='N' and type='IMG' and parentid=" & dt.Rows(0)("id")) If imgId <> "" Then Image1.ImageUrl = "~/handlers/getfile.ashx?id=" & imgId & "&storage=UserModulesAttachments.[user].[SLIDE_SHOW_URL]" Image1.Visible = True showFrame.Visible = False lastRenderTime.Text = dt.Rows(0)("last_render_time") Else '-- ----------------------------------- Dim url As String = dt.Rows(0)("url") For Each item In Request.QueryString.Keys If item <> "id" Then If Not url.Contains("?") Then url &= "?" Else url &= "&" End If url &= item & "=" & Request.QueryString(item) End If Next showFrame.Attributes.Add("src", url) Image1.Visible = False showFrame.Visible = True End If '-- ------------------------------------------------------- Dim iplist As String = "" Try If IsDBNull(dt.Rows(0)("ip_list")) Then dt.Rows(0)("ip_list") = "" End If iplist = dt.Rows(0)("ip_list") If iplist = "" Then iplist = Request.UserHostAddress.ToString ElseIf Not iplist.Contains(Request.UserHostAddress.ToString) Then iplist &= vbNewLine & Request.UserHostAddress End If Catch ex As Exception End Try '-- ------------------------------------------------------- Dim lastCallList() As String = {} Dim lastCall As String = "" Dim maxtime As String = "1900-01-01 00:00:00" Dim thisIPInList As Boolean = False Dim emptyList As Boolean = True Dim ip As String = "" Dim time As String = "" Dim numberOfInstance As Integer = 1 Try If IsDBNull(dt.Rows(0)("last_call")) Then dt.Rows(0)("last_call") = "" End If lastCallList = dt.Rows(0)("last_call").split(vbNewLine) If lastCallList.Count > 0 Then numberOfInstance = lastCallList.Count emptyList = False For Each l As String In lastCallList l = l.Trim(Chr(10)).Trim(Chr(13)) If l.Split("|").Count > 1 Then If maxtime < l.Split("|")(1).Trim("X") Then maxtime = l.Split("|")(1).Trim("X") End If If l.Split("|")(0) = Request.UserHostAddress.ToString Then ip = l.Split("|")(0) time = l.Split("|")(1) thisIPInList = True End If End If Next End If Catch ex As Exception End Try Dim delayedStart As String = "" Try '--- Add delay to separate dashboard calls ---- If numberOfInstance > 1 Then Dim lastCallTime As DateTime = DateTime.ParseExact(maxtime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) Dim timePast As TimeSpan = DateTime.Now.Subtract(lastCallTime) If timePast.Seconds < Math.Truncate(dt.Rows(0)("refresh_rate") / numberOfInstance) Then 'Threading.Thread.Sleep(5000) 'If IsDBNull(dt.Rows(0)("NOW_RUNNING")) Then ' dt.Rows(0)("NOW_RUNNING") = "" 'End If 'If dt.Rows(0)("NOW_RUNNING") = "R" Then ' Threading.Thread.Sleep(3000) 'Else ' sqlf.NonQuery("UPDATE UserModules.[user].slide_show_url set NOW_RUNNING = 'R' where id = " & dt.Rows(0)("id")) Threading.Thread.Sleep(1000) delayedStart = "X" 'End If End If End If Catch ex As Exception End Try '-- ------------------------------------------------------- Try Dim com As New System.Data.SqlClient.SqlCommand If emptyList Then com.CommandText = "UPDATE UserModules.[user].slide_show_url set " & "LAST_CALL = @LAST_CALL, " & "IP_LIST = @IP_LIST, NOW_RUNNING = '' " & "WHERE id = @ID" With com.Parameters .AddWithValue("LAST_CALL", Request.UserHostAddress.ToString & "|" & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") & delayedStart) .AddWithValue("IP_LIST", Request.UserHostAddress.ToString) .AddWithValue("ID", dt.Rows(0)("id")) End With Else If Not thisIPInList Then com.CommandText = "UPDATE UserModules.[user].slide_show_url set " & "LAST_CALL = '" & Request.UserHostAddress.ToString & "|" & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") & delayedStart & vbNewLine & "' + LAST_CALL, " & "IP_LIST = '" & Request.UserHostAddress.ToString & vbNewLine & "' + IP_LIST, NOW_RUNNING = '' " & "WHERE id = @ID" com.Parameters.AddWithValue("ID", dt.Rows(0)("id")) Else com.CommandText = "UPDATE UserModules.[user].slide_show_url set " & "LAST_CALL = '" & Request.UserHostAddress.ToString & "|" & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") & delayedStart & vbNewLine & "' + REPLACE(REPLACE(LAST_CALL,'" & ip & "|" & time & vbNewLine & "',''),'" & ip & "|" & time & "',''), " & "IP_LIST = '" & Request.UserHostAddress.ToString & vbNewLine & "' + REPLACE(REPLACE(IP_LIST,'" & ip & vbNewLine & "',''),'" & ip & "',''), " & "NOW_RUNNING = '' " & "WHERE id = @ID" com.Parameters.AddWithValue("ID", dt.Rows(0)("id")) End If End If sqlf.NonQuery(com) Catch ex As Exception End Try Page.Title = dt.Rows(0)("page_name") Try Timer1.Interval = (dt.Rows(0)("refresh_rate") * 1000) Catch End Try Timer1.Enabled = True End If End If End If End If End Sub End Class