by ssi
17. December 2015 14:18
#if TEST_DATE
Console.WriteLine("Enter <q> to quit:");
string line = Console.ReadLine();
if (line == "q")
{
// break;
}
#endif
by ssi
17. December 2015 12:50
List<DocumentTab> THEDOCS = GetDocumentTab();
private List<DocumentTab> GetDocumentTab()
{
List<DocumentTab> DOCAT = new List<DocumentTab>();
DocumentTab rcd = new DocumentTab();
rcd.Short_Name = "DOC1";
rcd.TAB_NAME = "DOC01";
DOCAT.Add(rcd);
rcd = new DocumentTab();
rcd.Short_Name = "DOC2";
rcd.TAB_NAME = "DCO02";
DOCAT.Add(rcd);
rcd = new DocumentTab();
rcd.Short_Name = "DOC3";
rcd.TAB_NAME = "DOC03";
DOCAT.Add(rcd);
rcd = new DocumentTab();
rcd.Short_Name = "DOC4";
rcd.TAB_NAME = "4thDOC";
DOCAT.Add(rcd);
return DOCAT;
}
2dc95547-6b20-4952-b083-77f4a30dda13|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: List<>
CSharp
by ssi
17. December 2015 12:44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32.TaskScheduler;
using System.Diagnostics.Eventing.Reader;
namespace ListSchedulerTasks
{
class Program
{
static string sFolder = "<MS scheduler folder>";
static List<SchedulerTasks> SCHEDTASK = new List<SchedulerTasks>();
static void Main(string[] args)
{
string sVer = "15.12.15.a";
Console.WriteLine("{0}", sVer);
EnumAllTasks();
Console.WriteLine("{0}", "Its over");
foreach (var ts in SCHEDTASK)
Console.WriteLine("Name: {0} => next{1} en{2} lst{3} res:{4}", ts.Name, ts.NextRunTime, ts.Enabled, ts.LastRunTime, ts.LastTaskResult);
Console.ReadLine();
}
static void EnumAllTasks()
{
using (TaskService ts = new TaskService())
EnumFolderTasks(ts.RootFolder);
}
static void EnumFolderTasks(TaskFolder fld)
{
foreach (Task task in fld.Tasks)
ActOnTask(task);
foreach (TaskFolder sfld in fld.SubFolders)
EnumFolderTasks(sfld);
}
static void ActOnTask(Task t)
{
if (t.Folder.ToString().Contains(sFolder))
{
// Console.WriteLine("Name: {0} => next{1} en{2} lst{3} res:{4}", t.Name, t.NextRunTime, t.Enabled, t.LastRunTime, t.LastTaskResult);
SchedulerTasks rcd = new SchedulerTasks();
rcd.Name = t.Name;
rcd.NextRunTime = t.NextRunTime;
rcd.Enabled = t.Enabled;
rcd.LastRunTime = t.LastRunTime;
rcd.LastTaskResult = t.LastTaskResult;
SCHEDTASK.Add(rcd);
}
}
}
}
using System;
namespace ListSchedulerTasks
{
internal class SchedulerTasks
{
public bool Enabled { get; internal set; }
public DateTime LastRunTime { get; internal set; }
public object LastTaskResult { get; internal set; }
public string Name { get; internal set; }
public DateTime NextRunTime { get; internal set; }
}
}
by ssi
17. December 2015 11:29
select table_name, column_name from INFORMATION_SCHEMA.columns where column_name like '%control%'
adedfa31-2807-43b4-bcd8-82f46d55c73f|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: SQL
SQL
by ssi
17. December 2015 10:54
public class clsFolders
{
public void CreateFolder(string sFolder)
{
try
{
// Determine whether the directory exists.
if (Directory.Exists(sFolder))
{
Console.WriteLine(string.Format("Path: {0} exists already.", sFolder ));
return;
}
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(sFolder);
Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(sFolder));
//// Delete the directory.
//di.Delete();
//Console.WriteLine("The directory was deleted successfully.");
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
finally { }
}
}
c03a7399-ae80-4032-9f8a-3c3f30ec876f|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: Folders, Create
CSharp
by ssi
17. December 2015 10:52
public static string LimitString(string sTextValue, int nMaxLength, string sTextTemplate)
{
/********************************************************************
created: 2014/02/13
created: 13:2:2014 16:32
filename: C:\Users\Public\Documents\appsCadence\appsGl\GlTran\GLTrans\Classes\clsStaticMethods.cs
file path: C:\Users\Public\Documents\appsCadence\appsGl\GlTran\GLTrans\Classes
file base: clsStaticMethods
file ext: cs
author: ssi
note: Usage : LimitString("Ross Mason",25 , "R:{0}$$$")
purpose:
*********************************************************************/
int nLen = Math.Min(string.Format(sTextTemplate, sTextValue).Length, nMaxLength);
return string.Format(sTextTemplate, sTextValue).Substring(0, nLen);
}
8d1adf9c-8908-4374-bc31-1e394c83f679|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: String, Math
CSharp
by ssi
15. December 2015 15:33
private bool GotConnected2SQL(string sConnectionString)
{
bool bRet = false;
SqlConnection mySQLConnection = new SqlConnection(sConnectionString);
string SQLStatement = "SELECT control FROM [tbvl_ssi_control]";
string sSql = string.Format(SQLStatement);
SqlCommand mySQLCommand = mySQLConnection.CreateCommand();
try
{
mySQLCommand.CommandText = sSql;
SqlDataAdapter mySQLDataAdapter = new SqlDataAdapter();
mySQLDataAdapter.SelectCommand = mySQLCommand;
DataSet myDataSet = new DataSet();
mySQLConnection.Open();
Console.WriteLine("Retrieving rows from the Query");
mySQLDataAdapter.Fill(myDataSet, "RECS");
mySQLConnection.Close();
DataTable myDataTable = myDataSet.Tables["RECS"];
bRet = true;
}
catch (Exception ex)
{
MessageBox.Show(string.Format("", "SQL Connection Error: {0}", ex.Message), "SQL Connection Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
bRet = false;
}
return bRet;
}
by ssi
17. November 2015 14:27
RESTORE DATABASE PROD FROM disk = 'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\MyBackup\UnZipped\dbase_FULL_20151215_230000.bak'
WITH REPLACE, FILE = 1, NORECOVERY, STATS=5, MOVE 'dbase_dat' TO 'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbase.mdf', MOVE 'dbase_Log' TO
'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\dbase_Log.ldf'
RESTORE LOG dbaseRecovering FROM DISK = 'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\MyBackup\UnZipped\dbase_backup_2015_06_05_040006_5970059.trn'
WITH NORECOVERY, FILE = 1;
RESTORE LOG dbaseRecovering FROM DISK = 'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\MyBackup\UnZipped\dbase_backup_2015_06_05_043000_6483931.trn'
WITH NORECOVERY, FILE = 1;
RESTORE LOG dbaseRecovering FROM DISK = 'D:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLMyBackup\UnZipped\dbase_backup_2015_06_05_050001_0024105.trn'
WITH NORECOVERY, FILE = 1;
--Put database back into operation
RESTORE DATABASE {0} WITH RECOVERY
by ssi
12. November 2015 16:34
sRet = sRet.Replace("DB_backup_", "").Replace(".trn.7z", "");
char[] delimiter = { '_' };
string[] split = null;
for (int x = 0; x <= 5; x++)
split = sRet.Split(delimiter, x);
string sYr = split[0];
string sMn = split[1];
string sDy = split[2];
string sTm = split[3].Substring(0, 4);
sRet = string.Format("Last TL from : {0}/{1}/{2} @ {3}", sMn, sDy, sYr, sTm);
return sRet;
ede2fbbd-d913-4ed8-9432-8ed51dfeb0d0|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: split, delimiter
CSharp
by ssi
15. October 2015 15:53
93a41a80-bc6d-4854-8d00-1eb7390305d9|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: cartoon, PROD, test
Notes