Console.WriteLine

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

Tags: , ,

CSharp

List<>

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;
      }

Tags:

CSharp

List Scheduler Tasks

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 { getinternal set; }
        public DateTime LastRunTime { getinternal set; }
        public object LastTaskResult { getinternal set; }
        public string Name { getinternal set; }
        public DateTime NextRunTime { getinternal set; }
    }
}

Tags: , ,

CSharp

SQL: Find object from INFORMATION_SCHEMA

by ssi 17. December 2015 11:29

select table_name, column_name from INFORMATION_SCHEMA.columns where column_name like '%control%'

Tags:

SQL

CreateFolder

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 { }
 
       }
 
   }

Tags: ,

CSharp

Limit String

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);
   }

Tags: ,

CSharp

TesT For SQL Connection

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;
     }

Tags: , ,

CSharp | SQL

SQl Restore

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

 

Tags: ,

SQL

Split

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;

 

Tags: ,

CSharp

Test Code

by ssi 15. October 2015 15:53

Tags: , ,

Notes

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"Procrastination is, hands down, our favorite form of self-sabotage"
Alyce P. Cornyn-Selby