Click here to Skip to main content
15,917,328 members

Comments by Member 7983150 (Top 8 by date)

Member 7983150 3-May-12 14:56pm View    
And this is the code of the Timer in the Class AS400duplicate:
//Timer
private System.Diagnostics.EventLog _AppEventLog;
private System.Timers.Timer _Timer;
private int _Interval = 1000;
public int Interval
{
get { return this._Interval;}
set { this._Interval = value; }
}
private string _Name = "";
public string Name
{
get { return this._Name; }
set { this._Name = value; }
}
///
/// /// Constructor
/// ///

public void TimedItem(System.Diagnostics.EventLog AppEventLog)
{
this._Timer = new System.Timers.Timer();
this._Timer.Elapsed += new
System.Timers.ElapsedEventHandler(_Timer_Elapsed);
this._Timer.Enabled = false;
this._Timer.Interval = this.Interval;
this._AppEventLog = AppEventLog;
}
///
/// /// Start the timer.
/// ///

public void StartTimer()
{
this._Timer.Enabled = true;
}
///
/// Stop the timer.
/// ///

public void StopTimer()
{
this._Timer.Enabled = false;
}

/* * Respond to the _Timer elapsed event. */
private void _Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
DateTime Zeit = DateTime.Now;
if (Zeit.ToString("mm") == "25") //(Zeit.ToString("HH") == "22")
{
if (Funktion_ausfuehren == true)
{
Offline();
}
}

if (Zeit.ToString("mm") == "30") //(Zeit.ToString("HH") == "02")
{
if (Funktion2_ausfuehren == true)
{
Online();
}
}
}

It´s only function is to activate the functions: Offline and Online at a particular time.
The problem appears when I try to start the timer at the OnStart function.
When I try to start the Service, the errormessage I already posted appears.
Member 7983150 3-May-12 14:50pm View    
This is the code of the Service:

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;

using System.Collections;
using System.Globalization;
using System.Reflection;

namespace Project1
{
class WindowsService : ServiceBase
{
AS400duplicate ASdb = new AS400duplicate();

public WindowsService()
{
this.ServiceName = "AS400 duplizieren";
//this.EventLog.Log = "Application";

// These Flags set whether or not to handle that specific
// type of event. Set to true if you need it, false otherwise.
this.CanHandlePowerEvent = true;
this.CanHandleSessionChangeEvent = true;
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanStop = true;
}

///
/// The Main Thread: This is where your Service is Run.
///

static void Main()
{
ServiceBase.Run(new WindowsService());
}

///
/// Dispose of objects that need it here.
///

/// <param name="disposing">Whether
/// or not disposing is going on.</param>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}

///
/// OnStart(): Put startup code here
/// - Start threads, get inital data, etc.
///

/// <param name="args"></param>
protected override void OnStart(string[] args)
{
base.OnStart(args);
ASdb.StartTimer();
}

///
/// OnStop(): Put your stop code here
/// - Stop threads, set final data, etc.
///

protected override void OnStop()
{
base.OnStop();
}

///
/// OnPause: Put your pause code here
/// - Pause working threads, etc.
///

protected override void OnPause()
{
base.OnPause();
}

///
/// OnContinue(): Put your continue code here
/// - Un-pause working threads, etc.
///

protected override void OnContinue()
{
base.OnContinue();
}

///
/// OnShutdown(): Called when the System is shutting down
/// - Put code here when you need special handling
/// of code that deals with a system shutdown, such
/// as saving special data before shutdown.
///

protected override void OnShutdown()
{
base.OnShutdown();
}

///
/// OnCustomCommand(): If you need to send a command to your
/// service without the need for Remoting or Sockets, use
/// this method to do custom methods.
///

/// <param name="command">Arbitrary Integer between 128 & 256</param>
protected override void OnCustomCommand(int command)
{
// A custom command can be sent to a service by using this method:
//# int command = 128; //Some Arbitrary number between 128 & 256
//# ServiceController sc = new ServiceController("NameOfService");
//# sc.ExecuteCommand(command);

base.OnCustomCommand(command);
}

///
/// OnPowerEvent(): Useful for detecting power status changes,
/// such as going into Suspend mode or Low Battery for laptops.
///

/// <param name="powerStatus">The Power Broadcast Status
/// (BatteryLow, Suspend, etc.)</param>
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
{
return base.OnPowerEvent(powerStatus);
Member 7983150 3-May-12 13:16pm View    
Hi Dave,

I declared it Global but it still doesn´t work.
Same error.
By the way, it´s really an IBM AS400 in my company and I have to duplicate data from it and put it on the SQL-Server...
Member 7983150 12-Mar-12 2:21am View    
Hi Björn,
sorry for answering only now.
It works but you have to modify the youtube link to your format.
You get a string like that:
http://www.youtube.com/watch?v=ykwAirfRulg&feature=g-logo&context=G20b913cFOAAAAAAAXAA
Now I need to filter the 'ykwAirfRulg' and put it into:
http://www.youtube.com/embed/ykwAirfRulg?autoplay=1

Now it works thank you very much!!!
Tom
Member 7983150 6-Mar-12 1:09am View    
Hi,
it doesn´t work either.
I´ve created 2 buttons, both of them have different URLs and your &autoplay=1.
If I click on the first button it works but if I click now the second button it doesn´t work anymore. Do I have to close or clear the webelement???

Best regards
Tom