DECLARE @f FLOAT = 13.5;
SELECT CONVERT(TIME(0), DATEADD(MINUTE, 60*@f, 0));
Thursday, June 11, 2015
SQL Convert decimal time to hours and minutes
Tuesday, June 9, 2015
SQL EXISTS CONDITION
select *
from trn_log tl
where Exists( select 1
from trn_queue aq
where aq.track_num=tl.track_num and aq.code=tl.code
)
from trn_log tl
where Exists( select 1
from trn_queue aq
where aq.track_num=tl.track_num and aq.code=tl.code
)
SQL cursor example
-- [insert] 'ex'
create procedure[insert]
@LoginId varchar(50)
as
begin
-- DECLARE @iErrorDetailId INT
-- BEGIN TRANSACTION
-- BEGIN TRY
declare @FileId int = null
declare @Sender varchar(200) = null
declare @Recepient varchar(200) = null
declare @RecStatus char(1)
declare @IsProcessed char(1)
declare @ProcessedOn datetime = null
declare @EstProcessedOn datetime = null
declare @ProcessType char(1) = null
declare @TemplateId int = null
declare @StartDate datetime = null
declare @EndDate datetime = null
declare @TrackingNum int = null
declare @StageCode int
--print 'Cursor start'
declare @TrackLogCursor CURSOR
SET @TrackLogCursor = CURSOR
FOR
select 1 as [file_id],'Shekhar' as Sender,'Satish' as Recepient,'P' as rec_status,'N' as is_processed,tl.tr_end_dt as processed_on,
tl.tr_end_dt as est_processed_on,'S' as process_type,1 as template_id,tl.tr_start_dt as tr_start_dt,tl.tr_end_dt as tr_end_dt,
tl.tracking_num as tracking_num,tl.stage_code as stage_code
from tralog tl left outer join
aleque aq on aq.tracking_num <> tl.tracking_num and aq.stage_code <> tl.stage_code
where tl.tr_date is null and tl.tr_end_dt = CAST(CURRENT_TIMESTAMP AS DATE)
order by tl.tr_end_dt
--print 'Open Cursor'
OPEN @TrackLogCursor
FETCH NEXT FROM @TrackLogCursor INTO @FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,
@StartDate,@EndDate,@TrackingNum,@StageCode
WHILE @@FETCH_STATUS = 0
BEGIN
begin
insert into aleque ([file_id],Sender,Recepient,rec_status,is_processed,processed_on,est_processed_on,process_type,template_id,
tr_start_dt,tr_end_dt,tracking_num,stage_code,updated_by,updated_on)
values(@FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,@StartDate,@EndDate,
@TrackingNum,@StageCode,@LoginId,GETDATE())
end
FETCH NEXT FROM @TrackLogCursor INTO @FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,
@StartDate,@EndDate,@TrackingNum,@StageCode
END
CLOSE @TrackLogCursor
DEALLOCATE @TrackLogCursor
--start cursor for insert update record in table
--COMMIT TRANSACTION
--END TRY
--BEGIN CATCH
--ROLLBACK TRANSACTION
--EXEC [uspLog] @psSchemaName = NULL, @piErrorDetailId=@iErrorDetailId OUTPUT;
--RAISERROR('Error: [CRM].[syncuserinfo]',-1,-1)
--END CATCH
end
create procedure[insert]
@LoginId varchar(50)
as
begin
-- DECLARE @iErrorDetailId INT
-- BEGIN TRANSACTION
-- BEGIN TRY
declare @FileId int = null
declare @Sender varchar(200) = null
declare @Recepient varchar(200) = null
declare @RecStatus char(1)
declare @IsProcessed char(1)
declare @ProcessedOn datetime = null
declare @EstProcessedOn datetime = null
declare @ProcessType char(1) = null
declare @TemplateId int = null
declare @StartDate datetime = null
declare @EndDate datetime = null
declare @TrackingNum int = null
declare @StageCode int
--print 'Cursor start'
declare @TrackLogCursor CURSOR
SET @TrackLogCursor = CURSOR
FOR
select 1 as [file_id],'Shekhar' as Sender,'Satish' as Recepient,'P' as rec_status,'N' as is_processed,tl.tr_end_dt as processed_on,
tl.tr_end_dt as est_processed_on,'S' as process_type,1 as template_id,tl.tr_start_dt as tr_start_dt,tl.tr_end_dt as tr_end_dt,
tl.tracking_num as tracking_num,tl.stage_code as stage_code
from tralog tl left outer join
aleque aq on aq.tracking_num <> tl.tracking_num and aq.stage_code <> tl.stage_code
where tl.tr_date is null and tl.tr_end_dt = CAST(CURRENT_TIMESTAMP AS DATE)
order by tl.tr_end_dt
--print 'Open Cursor'
OPEN @TrackLogCursor
FETCH NEXT FROM @TrackLogCursor INTO @FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,
@StartDate,@EndDate,@TrackingNum,@StageCode
WHILE @@FETCH_STATUS = 0
BEGIN
begin
insert into aleque ([file_id],Sender,Recepient,rec_status,is_processed,processed_on,est_processed_on,process_type,template_id,
tr_start_dt,tr_end_dt,tracking_num,stage_code,updated_by,updated_on)
values(@FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,@StartDate,@EndDate,
@TrackingNum,@StageCode,@LoginId,GETDATE())
end
FETCH NEXT FROM @TrackLogCursor INTO @FileId,@Sender,@Recepient,@RecStatus,@IsProcessed,@ProcessedOn,@EstProcessedOn,@ProcessType,@TemplateId,
@StartDate,@EndDate,@TrackingNum,@StageCode
END
CLOSE @TrackLogCursor
DEALLOCATE @TrackLogCursor
--start cursor for insert update record in table
--COMMIT TRANSACTION
--END TRY
--BEGIN CATCH
--ROLLBACK TRANSACTION
--EXEC [uspLog] @psSchemaName = NULL, @piErrorDetailId=@iErrorDetailId OUTPUT;
--RAISERROR('Error: [CRM].[syncuserinfo]',-1,-1)
--END CATCH
end
Thursday, June 4, 2015
asp.net call exe from web application
Process p1 = new Process();
try
{
//p1.StartInfo.WorkingDirectory = "C:\\Inetpub\\wwwroot"; //sets the working directory in which the exe file resides
p1.StartInfo.WorkingDirectory = "C:\\Users\\shekhar\\Desktop\\ScanUtility"; //sets the working directory in which the exe file resides
p1.StartInfo.FileName = "ScanUtility.exe"; // actual file name
p1.StartInfo.Arguments = "D:\\Temp\\Pic_{0}";//arguments here i had taken hello as first argument and Murali as second argument and splited them in exe file
p1.Start();
p1.WaitForExit();
if (p1.HasExited) p1.Dispose();
else
{
p1.Kill();
}
}
catch (Exception e1) { e1.Message.ToString(); }
try
{
//p1.StartInfo.WorkingDirectory = "C:\\Inetpub\\wwwroot"; //sets the working directory in which the exe file resides
p1.StartInfo.WorkingDirectory = "C:\\Users\\shekhar\\Desktop\\ScanUtility"; //sets the working directory in which the exe file resides
p1.StartInfo.FileName = "ScanUtility.exe"; // actual file name
p1.StartInfo.Arguments = "D:\\Temp\\Pic_{0}";//arguments here i had taken hello as first argument and Murali as second argument and splited them in exe file
p1.Start();
p1.WaitForExit();
if (p1.HasExited) p1.Dispose();
else
{
p1.Kill();
}
}
catch (Exception e1) { e1.Message.ToString(); }
Tuesday, June 2, 2015
asp.net Scanner in Both TWAIN and WIA
1) Download Source code from - https://sites.google.com/site/eduardfilefepositore/
2) Open ScannerAdapterFactory.cs
3) Check Below Method and update according to your situation
public static ScannerAdapterBase GetScannerAdapter(nessScanning control, IMessageFilter messageFilter, IntPtr handle)
{
lock (locker)
{
bool isWiaDeviceSelected = false;
bool isTwainDeviceSelected = false;
if (m_ScannerAdapterBase != null)
{
return m_ScannerAdapterBase;
}
try
{
//commented by shekhar 6/2/2015 - If you want to use WIA then uncomment this
//Checks WIA Devices
//m_ScannerAdapterBase = new WiaScannerAdapter();
//m_ScannerAdapterBase.InitAdapter(control, messageFilter, handle);
//isWiaDeviceSelected = m_ScannerAdapterBase.SelectDevice();
//if (isWiaDeviceSelected)
//{
// return m_ScannerAdapterBase;
//}
//end of commented by shekhar 6/2/2015 - If you want to use WIA then uncomment this
//Checks TWAIN Devices
m_ScannerAdapterBase = new TwainScannerAdapter();
m_ScannerAdapterBase.InitAdapter(control, messageFilter, handle);
isTwainDeviceSelected = m_ScannerAdapterBase.SelectDevice();
if (isTwainDeviceSelected)
{
return m_ScannerAdapterBase;
}
}
catch (ScannerException ex)
{
throw ex;
}
return null;
}
}
2) Open ScannerAdapterFactory.cs
3) Check Below Method and update according to your situation
public static ScannerAdapterBase GetScannerAdapter(nessScanning control, IMessageFilter messageFilter, IntPtr handle)
{
lock (locker)
{
bool isWiaDeviceSelected = false;
bool isTwainDeviceSelected = false;
if (m_ScannerAdapterBase != null)
{
return m_ScannerAdapterBase;
}
try
{
//commented by shekhar 6/2/2015 - If you want to use WIA then uncomment this
//Checks WIA Devices
//m_ScannerAdapterBase = new WiaScannerAdapter();
//m_ScannerAdapterBase.InitAdapter(control, messageFilter, handle);
//isWiaDeviceSelected = m_ScannerAdapterBase.SelectDevice();
//if (isWiaDeviceSelected)
//{
// return m_ScannerAdapterBase;
//}
//end of commented by shekhar 6/2/2015 - If you want to use WIA then uncomment this
//Checks TWAIN Devices
m_ScannerAdapterBase = new TwainScannerAdapter();
m_ScannerAdapterBase.InitAdapter(control, messageFilter, handle);
isTwainDeviceSelected = m_ScannerAdapterBase.SelectDevice();
if (isTwainDeviceSelected)
{
return m_ScannerAdapterBase;
}
}
catch (ScannerException ex)
{
throw ex;
}
return null;
}
}
Subscribe to:
Posts (Atom)