CREATE PROCEDURE [dbo].[procInsertApplication]
	@Type int,
	@Time varchar(30),
	@ComputerId varchar(128),
	@Name varchar(255),
	@Path varchar(255),
	@ProcessId int,
	@AllTime float,
	@ActiveSeconds int
AS
	INSERT INTO tblApplication (Operator, OppTime, ComputerId, Name, Path, procid)
		VALUES(@Type, CONVERT(datetime, @Time), @ComputerId, @Name, @Path, @ProcessId)

	If @Type = 1
		INSERT INTO tblEvent (OppTime, ComputerId, Type, Operator, Description)
			VALUES(CONVERT(datetime, @Time, 120), @ComputerId, 5, 1, @Path)
	Else
		Begin
			INSERT INTO tblAppStat (ComputerId, ProcId, AssocId, StartTime, EndTime, ActiveSecond, Status, ModuleName, ModulePath)
				VALUES(@ComputerId, @ProcessId, 0, CONVERT(DATETIME, @Time, 120) - @AllTime, CONVERT(DATETIME, @Time, 120), @ActiveSeconds, 1, @Name, @Path)
	
			INSERT INTO tblEvent (OppTime, ComputerId, Type, Operator, Description)
				VALUES(CONVERT(datetime, @Time, 120), @ComputerId, 5, 2, @Path)
		End
GO
