using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.IO;
namespace PatientFirst_SureScript.csproj
{
    [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    {
        // we're moving the file from the dmz to fsnt. the drives are mapped as w: and x:, respectivelly.
        // first we'll replace drive letter then we'll extract the path for next step that creates the destination folders
        public void Main()
        {
            string dest;

            dest = Dts.Variables["SourceFullFileSpec"].Value.ToString().Replace("w:", "x:");
            Dts.Variables["DestFullFileSpec1"].Value = dest;
        
            string destPath;
            destPath = dest.Substring(0, dest.LastIndexOf("\\"));
            Dts.Variables["DestPathOnly"].Value = destPath;

            /* can't debug 64-bit SSIS script so I had to go old school.
             */
            TextWriter tw = new StreamWriter("c:\\scott.txt");
            tw.WriteLine("->" + dest + "<-");
            tw.WriteLine("->" + destPath + "<-");
            tw.Close();
            /*
            */
            Dts.TaskResult = (int)ScriptResults.Success;
        }
    }
}