Trying to read MIRC logs in ASP.net - asp.net

I am trying to make a page that lets my admins read the MIRC Log files from our bot...I am having the hardest time trying to get this to work for some reason...i have taken bits and pieces of code to get what i have working...but it still either doesn't display at all OR after about 200 lines, it stops reading each line but instead make it one big mess of text...here is what i have for code
Protected Sub bView_Click(sender As Object, e As EventArgs) Handles bView.Click
Response.Write(Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text))
lFileOut.Text = ""
Try
Dim FILENAME As String = Server.MapPath("~/mirc/logs/" & lbfiles.SelectedItem.Text)
Dim objStreamReader As StreamReader = New StreamReader(FILENAME, Encoding.UTF8)
Dim cont As String
Do
cont = objStreamReader.ReadLine()
lFileOut.Text = lFileOut.Text & cont & "<br>"
'Response.Write(cont)
Loop Until cont Is Nothing
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Here is a test file i have been testing everything on...it just doesn't do anything nor does it throw any error...i am completely stumped on this one.
test file

Do this: go into your server, in your root folder make a new folder called whatever you want then go into your mIRC script goto tools/options/logging change directory to the new folder you made click save.. that way you or anyone you want to view all logs from your mIRC script can view by going to www.yoursite.net/foldername and it will show you the list of all logged things, status and room window conversations...
If you want to know how to code it so your opers can just have a clickable link in their remotes I can do that for you as well.... hope this helps

Related

BackgroundWorker task blocks UI thread in my web application

Okay, I've been banging on this problem for close to 10 work hours now with no real progress to speak of. After going through multiple "solutions" offered on the web, I find myself still unable to accomplish what should be a really simple task -- pop up a modal dialog from my web application while I complete a long process I'm forcing the user to wait upon.
I've ripped out all the non-multi-threading-control aspects and am left with this bare bones structure and it still doesn't cut it:
In my ASPX file, I have two "please wait" displays, one is a DIV set up for use with bPopup, the other a DIV runat=server following the examples on BackgroundWorker. The bPopup dialog works great when used independently of any background work. But, when the background worker fires, the UI freezes until it completes, then both opens & closes the bPopup dialog as fast as it can, basically flashing the screen.
This is my code behind: I've cut it to the bare minimum to see a dialog pop up and go away again after the background task completes.
Protected Sub EditBtn_Click(sender As Object, e As EventArgs)
ScriptManager.RegisterStartupScript(Page, Page.GetType, Guid.NewGuid().ToString(), "javascript: bPopup = $('#element_to_pop_up').bPopup({ modal: true, modalClose: false});", True)
MenusBeingGenerated.Visible = True
bw = New BackgroundWorker()
bw.WorkerReportsProgress = True
bw.WorkerSupportsCancellation = True
bw.RunWorkerAsync()
End Sub
The javascript fires the bPopup, while MenusBeingGenerated is the name of the server-side DIV. The background task itself has been ripped down to just a do-nothing time-consumer.
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bw.DoWork
For i = 1 To 40
Threading.Thread.Sleep(250)
bw.ReportProgress(i, "Running...")
If bw.CancellationPending Then
bw.ReportProgress(i, "Cancelling...")
Exit For
End If
Next
' Cleanup
If bw.CancellationPending Then
e.Cancel = True
bw.ReportProgress(100, "Cancelled.")
End If
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles bw.ProgressChanged
StatusLabel.Text = e.ProgressPercentage.ToString & "% complete."
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bw.RunWorkerCompleted
StatusLabel.Text = "Completed successfully"
ScriptManager.RegisterStartupScript(Page, Page.GetType, Guid.NewGuid().ToString(), "javascript: if (bPopup) { bPopup.close() };", True)
End Sub
When I run this code, and click the button that triggers it all there is a long pause then the screen blinks grey (the same behavior can be seen by opening and closing the bPopup from within the same button handler).
Adding breakpoints to walk through the code, I see the background task get launched via the button handler, it cycles through and the BackgroundWorker1_ProgressChanged handler gets called every quarter second, finally the BackgroundWorker1_RunWorkerCompleted method runs, and when that finishes the only page refresh finally happens (with the blink as bPopup fires & clears).
The DIV id=MenusBeingGenerated never displays, despite having been set as visible, nor does the label id=StatusLabel that resides within it ever get rendered.
Any clues what I've missed???
[ BTW, there are several questions along these lines on this and other web sites, none of the current answers apply. I've cookbooked this off several sites, thrown out multiple versions, and this is the closest I've gotten to something that works -- and it's no different than where I started: the user clicks the go button, a lot of nothing visible happens while the server churns out a new file, then the page refreshes when it's all done. ]

Need change compression of images stored in SQLite database with XOJO but getting error during process

I have a table that stores instruction book pages.
while working on the app and finished adding an instuction book, I found that that the table was over 200MB, however the PDF containing the pages was only 70MB 438 Pages.
The problem is that it saves the images as max quality. now i want to make a script that goes over every record opens the images and saves it again as medium compression.
I've made a record set and a loop to go through each record to change the compression, but but the app crashes half way the process.
No matter how i Change the code, it always crashes.
So i took an other approach and make a for loop of 200 records.
This wend well, but it didn't change the file size of the database???
The runtime error is an UnsupportedOperationException, as shown here:
This is the code:
dim rs as RecordSet
rs=lego.LegoData.SQLSelect("SELECT * FROM Books")
dim resize as Picture
while not rs.EOF
resize = picture.FromData(rs.Field("intructions").StringValue)
rs.Edit
rs.Field("intructions").StringValue = resize.GetData(Picture.FormatJPEG, Picture.QualityMedium)
rs.Update
rs.MoveNext
wend
Somehow it reads NIL after 200 records, but it's not NIL.
The error is not happening every time at the same record, it has its own will?
Any suggestions? I want to build-in a book image compression function as well so people can make the exported manual smaller.
The database file does not automatically get smaller if you remove or compact data inside it. You have to issue the VACCUM command (e.g. with SQLExecute("VACUUM")). You can issue that command only after committing, so first do a SQLExecute("COMMIT"). Or use a SQLite tool such as SQLVue to do that by hand.
If resize.GetData returns nil, it means that it can't read the data as JPEG. Maybe it's not in JPEG data but a GIF or something else. Try loading the data into a string first and look at it in the debugger, using the Binary (hex bytes) view to see what's up with it.
If you get an exception, wrap the code in an try block to keep the app from stopping, like this:
try
resize = picture.FromData(rs.Field("intructions").StringValue)
catch exc as RuntimeException
// The image could not be loaded - let's skip it
rs.MoveNext
continue
end try
I've found a solution to make the code faster, still having the crash
OutofMemorry exception
dim rs as RecordSet
dim pic as RecordSet
rs=lego.LegoData.SQLSelect("SELECT ID, SETID, Page FROM Books")
dim resize as Picture
dim count as Integer = 0
while not rs.EOF
pic = LegoData.SQLSelect("Select ID, Intructions FROM Books WHERE ID = " + Str(rs.Field("ID").IntegerValue))
if pic <> nil then
if len(pic.Field("intructions").StringValue) > 0 then
resize = picture.FromData(pic.Field("intructions").StringValue)
pic.Edit
pic.Field("intructions").StringValue = resize.GetData(Picture.FormatJPEG, Picture.QualityMedium)
pic.Update
if count = 100 then
LegoData.SQLExecute("COMMIT")
LegoData.SQLExecute("VACUUM")
count = 0
else
count = count + 1
end if
end if
end if
rs.MoveNext
wend
LegoData.SQLExecute("COMMIT")
LegoData.SQLExecute("VACUUM")
Before the crash its start updating my images with Nil
like 15 images before it crash

log in to a webpage and capture screenshot in vb6

I have a visual basic 6 application that needs to get pictures from a particular website but the problem is that the users have to open the webpage on the browser and log in to the webpage then download the picture and upload it in the vb6 app. Is it possible to have the vb6 go to that webpage and log in and capture the screenshot and save it in a particular folder without opening the browser?
The url opens the login page by default and you have to log in first, to access the picture page, which we just have to take a screen shot and crop it.
Is this possible in pure VB6?
Here is some VERY generic code that will log you into a website. It is basically a matter of finding the controls in the browser document and filling in the correct values. Since you have provided no code to build on it's up to you to fill in all the correct values. This is using Microsoft Internet Controls to add a browser control to a form.
Private Sub Form_Load()
Dim i As Integer
WebBrowser1.Navigate ("http://URL of the page you want to go to")
Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
If InStr(WebBrowser1.LocationURL, "http://targetwebsite/login.aspx") Then
On Error Resume Next
For i = 0 To WebBrowser1.Document.Forms(0).length - 1
' Uncommenting the MsgBox method will display the control names and help find the controls you are looking for
'MsgBox WebBrowser1.Document.Forms(0)(i).Type & ", " & WebBrowser1.Document.Forms(0)(i).Name
If WebBrowser1.Document.Forms(0)(i).Type = "text" Then
WebBrowser1.Document.Forms(0)(i).Value = "user name"
End If
If WebBrowser1.Document.Forms(0)(i).Type = "password" Then
WebBrowser1.Document.Forms(0)(i).Value = "user password"
End If
Next i
' now find and click the submit button
For i = 0 To WebBrowser1.Document.Forms(0).length - 1
If WebBrowser1.Document.Forms(0)(i).Type = "submit" Then
WebBrowser1.Document.Forms(0)(i).Click
End If
Next i
End If
' You should now be logged in and loading the page you want
End Sub

VB.NET/ASP.NET - Getting duration of MP3 file on upload

I'm trying to upload an MP3 file to a site and finding the duration of the audio at the same time. I'm quite new to ASP and VB.NET, but I've managed to get the file to upload to the server using a file upload tool.
However I can't seem to figure out how to read the duration of the audio file?
I'm not particularly looking for a complete solution (although that would be nice), but if anyone could point me in the right direction I'd be very appreciative.
If you require any more information let me know and I'll add it to the question.
I've done this in a recent project using naudio (download using package manager). I've converted the code from c# quickly without testing so double check for errors.
private shared function GetMp3Duration(filename as string) as double
Dim duration as double = 0.0
using (fs as FileStream = File.OpenRead(filename))
Dim frame as Mp3Frame = Mp3Frame.LoadFromStream(fs)
while (frame isnot nothing)
if (frame.ChannelMode = ChannelMode.Mono) then
duration += frame.SampleCount / frame.SampleRate
else
duration += frame.SampleCount * 2.0 / frame.SampleRate
end if
frame = Mp3Frame.LoadFromStream(fs)
End While
End Using
return duration
End Function
I'm not convinced the "* 2.0" in the previous answer is appropriate. I tried this, and resulting duration was two times the actual, for a stereo mp3 sound sample. I suggest the following code, successfully tested in MSVS Community 2013:
Imports NAudio.Wave
'...
Private Shared Function GetMp3Duration(filename As String) As Double
Dim reader As New Mp3FileReader(filename)
Dim duration As Double = reader.TotalTime.TotalSeconds
reader.Dispose()
Return duration
End Function
hii add this code to trackbar timer dont forgot to add laber to player
Label4.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString

Running a series of VBScripts within an ASP.net (vb.net) page?

I have a requirement when a user clicks a specific arrangement of radio buttons to run a series of vbscripts (and soon Perl scripts).
I have all of the vbscripts stored server side, they do not need to be on the remote system to run. Oh yes, the scripts are gathering information on remote system in our intranet.
What would be the best way. Currently I have this to run just one script, not multiple...should I keep this or dispose of this idea.
Protected Sub windowsScript(ByVal COMPUTERNAME As String)
' Create an array to store VBScript results
Dim winVariables(1) As String
Dim filePath As String = COMPUTERNAME & "\C$\Windows\somefile.txt"
'Execute PsExec on script
runPsExec(COMPUTERNAME, "systemInfo.vbs", 1)
'Import data from text file into variables
textRead(filePath, winVariables)
System.Threading.Thread.Sleep(1000)
'Delete the file on server - we don't need it anymore
runPsExec(COMPUTERNAME, "systemInfo.vbs", 2)
MsgBox("Windows OS: " & winVariables(0).ToString())
MsgBox("Service Pack: " & winVariables(1).ToString())
End Sub
Also, it is hard to see here because I do have another function "textRead" but what is going on is this particular script is stored client side and the vbscript it outputting to a text file. textRead will read the variable and send a text file back to the server to read it.
This is definitely not what I want to do.
I want to be a little more dynamic, plus with my new scripts...they don't need to be on the client at all.
Any help would be appreciated :)
I'm thinking of making some type of While loop, not sure if that would work.
It's kind of strange to do this through the browser. In my company we collect systeminfo at logontime with a vbscript logonscript and add the result to a logfile which we can access through a webapp to do research. Occasionally when the need rises we run a specific script to gather more data or change some system setting through windows SCCM.
If the goal is to provide the user with info about his system there are some good utilities around which can be run locally (but from a location on a server share).
EDIT
a simple way to start multiple processes
dim scripts_to_run, script
const COMPUTERNAME = 0, SCRIPTNAME = 1, EXTRA_PARAMS = 2
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each script in scripts_to_run
runPsExec script(COMPUTERNAME), script(SCRIPTNAME), script(EXTRA_PARAMS)
runPsExec join(script,",")
next
sub runPsExec(p1, p2, p3)
'here coms your code shat runs the script
wscript.echo p1 & p2 & p3
end sub
or a shorter version
dim scripts_to_run, aArgs
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each aArgs in scripts_to_run
runPsExec aArgs
next
sub runPsExec(aArgs)
'here coms your code shat runs the script
wscript.echo aArgs(0) & aArgs(1) & aArgs(2)
end sub

Resources