Ejemplo n.º 1
0
        public PrecedenceConstraint Add_PrecConstr(
            Executable ex1,
            Executable ex2,
            Sequence sqn = null,
            DTSPrecedenceEvalOp EvalOp = DTSPrecedenceEvalOp.Constraint,
            DTSExecResult Result       = DTSExecResult.Success,
            string Expression          = "",
            bool LogicalAnd            = true
            )
        {
            PrecedenceConstraint cstr = null;

            if (sqn == null)
            {
                cstr = p.PrecedenceConstraints.Add(ex1, ex2);
            }
            else
            {
                cstr = sqn.PrecedenceConstraints.Add(ex1, ex2);
            }

            cstr.EvalOp     = EvalOp;
            cstr.Value      = Result;
            cstr.Expression = Expression;
            cstr.LogicalAnd = LogicalAnd;

            return(cstr);
        }
 private void ExpressionMatchConstraint(TreeNode constraintsNode, PrecedenceConstraint constraint)
 {
     foreach (string match in expressionCandidateMatches.Where(matchCandidate => constraint.Expression.Contains(matchCandidate)).ToList())
     {
         VariableFoundEventArgs info = new VariableFoundEventArgs();
         info.Match = match;
         OnRaiseVariableFound(info);
         AddNode(constraintsNode, "Expression", GetImageIndex(IconKeyPrecedenceConstraint), constraint, true);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// A ctor that accepts the parent container, the preceding and succeeding executables.
        /// </summary>
        /// <param name="parentContainer">The parent container in which the precedence constraint is to be added.</param>
        /// <param name="precedingExecutable">The preceding executable.</param>
        /// <param name="succeedingExecutable">The constrained or the succeeding executable.</param>
        public ISPrecedenceConstraint(ISEventsProviderAsIDTSSequence parentContainer, ISExecutable precedingExecutable, ISExecutable succeedingExecutable)
        {
            bool precedenceConstraintExists = false;

            for (int p = 0; p < parentContainer.PrecedenceConstraints_m.Count; p++)
            {
                PrecedenceConstraint pc = parentContainer.PrecedenceConstraints_m[p];
                if (pc.ConstrainedExecutable == succeedingExecutable.Executable && pc.PrecedenceExecutable == precedingExecutable.Executable)
                {
                    precedenceConstraintExists = true;
                    PrecedenceConstraint       = pc;
                }
            }

            if (!(precedenceConstraintExists))
            {
                PrecedenceConstraint = parentContainer.PrecedenceConstraints_m.Add(precedingExecutable.Executable, succeedingExecutable.Executable);
            }
        }
Ejemplo n.º 4
0
        private void AttachPrecedenceToDecryptionSequence3(Executable sequenceExec)
        {
            constrainedExecutablesFollowingDecryptionSequence = new List <Executable>();

            //if no other tasks are there in onPreExecute event handler, just return
            if (onPreExecuteAllExecCount == 0)
            {
                //decrypt sequence is the only task, so do nothing
            }
            else if (onPreExecuteDanglingExecCount == 0)
            {
                foreach (string execName in onPreExecuteTopMostPreceedenceExecutableNames)
                {
                    constrainedExecutablesFollowingDecryptionSequence.Add(onPreExecute.Executables[execName]);
                }
            }
            else if (onPreExecuteDanglingExecCount > 0 && onPreExecutePreConstraintsCount == 0)
            {
                foreach (string execName in onPreExecuteAllExecutablesNames)
                {
                    constrainedExecutablesFollowingDecryptionSequence.Add(onPreExecute.Executables[execName]);
                }
            }
            else if (onPreExecuteDanglingExecCount > 0 && onPreExecutePreConstraintsCount > 0)
            {
                foreach (string execName in onPreExecuteTopMostPreceedenceExecutableNames)
                {
                    constrainedExecutablesFollowingDecryptionSequence.Add(onPreExecute.Executables[execName]);
                }
                foreach (string execName in onPreExecuteDanglingExecutablesNames)
                {
                    constrainedExecutablesFollowingDecryptionSequence.Add(onPreExecute.Executables[execName]);
                }
            }

            foreach (Executable constrainedExecutableFollowingDecryptionSequence in constrainedExecutablesFollowingDecryptionSequence)
            {
                PrecedenceConstraint topMost = onPreExecute.PrecedenceConstraints.Add(sequenceExec, constrainedExecutableFollowingDecryptionSequence);
                topMost.LogicalAnd = true;
                topMost.Value      = DTSExecResult.Completion;
                topMost.EvalOp     = DTSPrecedenceEvalOp.Constraint;
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Building Package...");

            // Create a new SSIS Package
            var      package = new Package();
            TaskHost taskHost;

            // Add a Connection Manager to the Package, of type, OLEDB
            var connMgrOleDb = package.Connections.Add("OLEDB");

            var connectionString = new StringBuilder();

            connectionString.Append("Provider=SQLOLEDB.1;");
            connectionString.Append("Integrated Security=SSPI;Initial Catalog=");
            connectionString.Append("DB");
            connectionString.Append(";Data Source=");
            connectionString.Append(".");
            connectionString.Append(";");

            connMgrOleDb.ConnectionString = connectionString.ToString();
            connMgrOleDb.Name             = "My OLE DB Connection";
            connMgrOleDb.Description      = "OLE DB connection";
            int i = 0;

            package.Variables.Add("ChangeDate", false, "User", "2019-21-01");

            using (SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=DB;Integrated Security=SSPI;"))
            {
                con.Open();

                using (SqlCommand command = new SqlCommand("select * from ##list", con))
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var a = package.Executables.Add("STOCK:SQLTask");
                            taskHost = a as TaskHost;
                            i++;
                            // Set required properties
                            taskHost.Properties["Connection"].SetValue(taskHost, connMgrOleDb.ID);
                            taskHost.Properties["SqlStatementSource"].SetValue(taskHost, reader.GetString(1));

                            // Add variable to hold parameter value


                            Console.WriteLine(taskHost.InnerObject.GetType().ToString());

                            ExecuteSQLTask task = taskHost.InnerObject as ExecuteSQLTask;
                            task.ParameterBindings.Add();
                            IDTSParameterBinding parameterBinding = task.ParameterBindings.GetBinding(0);
                            parameterBinding.DtsVariableName    = "User::ChangeDate";
                            parameterBinding.ParameterDirection = ParameterDirections.Input;
                            parameterBinding.DataType           = 7;
                            parameterBinding.ParameterName      = "0";

                            taskHost.Name = reader.GetString(2);
                        }
                    }

                using (SqlCommand command = new SqlCommand("select * from ##dep2", con))
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            PrecedenceConstraint pcFileTasks = package.PrecedenceConstraints.Add(package.Executables[reader.GetString(1)], package.Executables[reader.GetString(0)]);
                        }
                    }
            }


            var app = new Application();



            Console.WriteLine("Saving Package...");
            app.SaveToXml(@"C:\Users\cognos\Documents\SSIS Exports\test.dtsx", package, null);
        }
        void expressionListWindow_EditExpressionSelected(object sender, EditExpressionSelectedEventArgs e)
        {
            try
            {
                Package      package   = null;
                DtsContainer container = null;

                if (win == null)
                {
                    return;
                }

                try
                {
                    package = GetCurrentPackage();
                    if (package == null)
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Assert(false, ex.ToString());
                    return;
                }

                // Parameters for Expression Editor
                Variables         variables         = null;
                VariableDispenser variableDispenser = null;
                string            propertyName      = string.Empty;
                Type propertyType = null;

                // Target objects
                IDTSPropertiesProvider propertiesProvider = null;
                Variable             variable             = null;
                PrecedenceConstraint constraint           = null;

                // Get the container
                container = SSISHelpers.FindContainer(package, e.ContainerID);

                // Get the property details and variable objects for the editor
                if (e.Type == typeof(Variable))
                {
                    variable = SSISHelpers.FindVariable(container, e.ObjectID);

                    propertyName = "Value";
                    propertyType = System.Type.GetType("System." + variable.DataType.ToString());

                    variables         = container.Variables;
                    variableDispenser = container.VariableDispenser;
                }
                else if (e.Type == typeof(PrecedenceConstraint))
                {
                    constraint = SSISHelpers.FindConstraint(container, e.ObjectID);

                    propertyName = "Expression";
                    propertyType = typeof(bool);

                    variables         = container.Variables;
                    variableDispenser = container.VariableDispenser;
                }
                else
                {
                    if (e.Type == typeof(ConnectionManager))
                    {
                        propertiesProvider = SSISHelpers.FindConnectionManager(package, e.ObjectID) as IDTSPropertiesProvider;
                    }
                    else if (e.Type == typeof(ForEachEnumerator))
                    {
                        ForEachLoop forEachLoop = container as ForEachLoop;
                        propertiesProvider = forEachLoop.ForEachEnumerator as IDTSPropertiesProvider;
                    }
                    else
                    {
                        propertiesProvider = container as IDTSPropertiesProvider;
                    }

                    if (propertiesProvider != null)
                    {
                        DtsProperty property = propertiesProvider.Properties[e.Property];
                        propertyName      = property.Name;
                        propertyType      = PackageHelper.GetTypeFromTypeCode(property.Type);
                        variables         = container.Variables;
                        variableDispenser = container.VariableDispenser;
                    }
                    else
                    {
                        throw new Exception(string.Format(CultureInfo.InvariantCulture, "Expression editing not supported on this object ({0}).", e.ObjectID));
                    }
                }

                // Show the editor
                Konesans.Dts.ExpressionEditor.ExpressionEditorPublic editor = new Konesans.Dts.ExpressionEditor.ExpressionEditorPublic(variables, variableDispenser, propertyType, propertyName, e.Expression);
                editor.Editor.ExpressionFont  = ExpressionFont;
                editor.Editor.ExpressionColor = ExpressionColor;
                editor.Editor.ResultFont      = ResultFont;
                editor.Editor.ResultColor     = ResultColor;
                if (editor.ShowDialog() == DialogResult.OK)
                {
                    // Get expression
                    string expression = editor.Expression;
                    if (expression == null || string.IsNullOrEmpty(expression.Trim()))
                    {
                        expression = null;
                    }

                    // Set the new expression on the target object
                    object objectChanged = null;
                    if (variable != null)
                    {
                        if (expression == null)
                        {
                            variable.EvaluateAsExpression = false;
                        }

                        variable.Expression = expression;
                        objectChanged       = variable;
                    }
                    else if (constraint != null)
                    {
                        if (expression == null)
                        {
                            constraint.EvalOp = DTSPrecedenceEvalOp.Constraint;
                        }

                        constraint.Expression = expression;
                        objectChanged         = constraint;
                    }
                    else if (propertiesProvider != null)
                    {
                        // TaskHost, Sequence, ForLoop, ForEachLoop and ConnectionManager
                        propertiesProvider.SetExpression(e.Property, expression);
                        objectChanged = propertiesProvider;
                    }

                    expressionListWindow_RefreshExpressions(null, null);

                    // Finish displaying expressions list before you mark the package
                    // as dirty (which runs the expression highlighter)
                    System.Windows.Forms.Application.DoEvents();

                    SetPackageAsDirty(package, expression, objectChanged);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// A ctor that accepts a Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraint object.
 /// </summary>
 /// <param name="precedenceConstraint">The Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraint object.</param>
 internal ISPrecedenceConstraint(PrecedenceConstraint precedenceConstraint)
 {
     PrecedenceConstraint = precedenceConstraint;
 }
Ejemplo n.º 8
0
        private void ObtainDecryptionSequence(ref string scriptMainDotCsCode, string referenceAssemblyName)
        {
            Executable stDummyExec   = default(Executable);
            Executable stDecryptExec = default(Executable);

            if (!onPreExecuteAllExecutablesNames.Contains("SSISCipherUtil_seqDecryption"))
            {
                seqDecryptionExec         = onPreExecute.Executables.Add("STOCK:SEQUENCE");
                seqDecryption             = (Sequence)seqDecryptionExec;
                seqDecryption.Name        = "SSISCipherUtil_seqDecryption";
                seqDecryption.Description = "AUTOGENERATED_DO_NOT_MODIFY_SISCipherUtil_seqDecryption_sequence_containing_decrypion_scripttask";


                stDummyExec = seqDecryption.Executables.Add("STOCK:ScriptTask");
                TaskHost stDummyTaskHost = (TaskHost)stDummyExec;
                stDummyTaskHost.Properties["Name"].SetValue(stDummyTaskHost, "SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow");
                stDummyTaskHost.Properties["Description"].SetValue(stDummyTaskHost, "AUTOGENERATED_DO_NOT_MODIFY_SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow_scripttask_to_allow_decryption_only_for_package_level_onpreexecuteevent");

                stDecryptExec = seqDecryption.Executables.Add("STOCK:ScriptTask");
                TaskHost stDecryptTaskHost = (TaskHost)stDecryptExec;
                stDecryptTaskHost.Properties["Name"].SetValue(stDecryptTaskHost, "SSISCipherUtil_stDecryptConfigValues");
                stDecryptTaskHost.Properties["Description"].SetValue(stDecryptTaskHost, "AUTOGENERATED_DO_NOT_MODIFY_SSISCipherUtil_stDecryptConfigValues_scripttask_to_decrypt_configuration_values");

                ScriptTask stDecrypt = (ScriptTask)stDecryptTaskHost.InnerObject;

                EditScriptTaskCode(ref stDecrypt, ref scriptMainDotCsCode, referenceAssemblyName);
            }
            //modify the existing sequence
            else
            {
                seqDecryptionExec = onPreExecute.Executables["SSISCipherUtil_seqDecryption"];
                seqDecryption     = (Sequence)seqDecryptionExec;

                if (seqDecryption.Executables.Contains("SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow"))
                {
                    seqDecryption.Executables.Remove("SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow");
                }
                if (seqDecryption.Executables.Contains("SSISCipherUtil_stDecryptConfigValues"))
                {
                    seqDecryption.Executables.Remove("SSISCipherUtil_stDecryptConfigValues");
                }

                List <string> precedenceConstraintsToRemove = new List <string>();
                foreach (PrecedenceConstraint pc in seqDecryption.PrecedenceConstraints)
                {
                    precedenceConstraintsToRemove.Add(pc.Name);
                }

                foreach (string s in precedenceConstraintsToRemove)
                {
                    seqDecryption.PrecedenceConstraints.Remove(s);
                }

                if (onPreExecuteTopMostPreceedenceExecutableNames.Contains("SSISCipherUtil_seqDecryption"))
                {
                    onPreExecuteTopMostPreceedenceExecutableNames.Remove("SSISCipherUtil_seqDecryption");
                }
                if (onPreExecuteDanglingExecutablesNames.Contains("SSISCipherUtil_seqDecryption"))
                {
                    onPreExecuteDanglingExecutablesNames.Remove("SSISCipherUtil_seqDecryption");
                }
                if (onPreExecuteAllExecutablesNames.Contains("SSISCipherUtil_seqDecryption"))
                {
                    onPreExecuteAllExecutablesNames.Remove("SSISCipherUtil_seqDecryption");
                }



                stDummyExec = seqDecryption.Executables.Add("STOCK:ScriptTask");
                TaskHost stDummyTaskHost = (TaskHost)stDummyExec;
                stDummyTaskHost.Properties["Name"].SetValue(stDummyTaskHost, "SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow");
                stDummyTaskHost.Properties["Description"].SetValue(stDummyTaskHost, "AUTOGENERATED_DO_NOT_MODIFY_SSISCipherUtil_stDummyForPkgOnlyOnPreExecuteAllow_scripttask_to_allow_decryption_only_for_package_level_onpreexecuteevent");

                stDecryptExec = seqDecryption.Executables.Add("STOCK:ScriptTask");
                TaskHost stDecryptTaskHost = (TaskHost)stDecryptExec;
                stDecryptTaskHost.Properties["Name"].SetValue(stDecryptTaskHost, "SSISCipherUtil_stDecryptConfigValues");
                stDecryptTaskHost.Properties["Description"].SetValue(stDecryptTaskHost, "AUTOGENERATED_DO_NOT_MODIFY_SSISCipherUtil_stDecryptConfigValues_scripttask_to_decrypt_configuration_values");

                ScriptTask stDecrypt = (ScriptTask)stDecryptTaskHost.InnerObject;

                EditScriptTaskCode(ref stDecrypt, ref scriptMainDotCsCode, referenceAssemblyName);
            }


            //Add PrecedenceConstraint between Dummy script task and decrypt script task
            PrecedenceConstraint respondOnlyForPackageEvents = seqDecryption.PrecedenceConstraints.Add(stDummyExec, stDecryptExec);

            respondOnlyForPackageEvents.Expression = "@[System::SourceID]== @[System::PackageID]";
            respondOnlyForPackageEvents.EvalOp     = DTSPrecedenceEvalOp.ExpressionAndConstraint;
            respondOnlyForPackageEvents.Value      = DTSExecResult.Completion;
            respondOnlyForPackageEvents.LogicalAnd = true;
        }
        //
        private void AddToSSIS(Dictionary <string, object> collectedData)
        {
            #region ALL Tasks-update
            #region BOTask



            string      pkgPath     = accountWizardSettings.Get("SSIS.TemplateAllBoPackagePath"); //Load Bo Template
            Application application = new Application();

            Package package = application.LoadPackage(pkgPath, null);
            //BackUp the package
            string backupPath = accountWizardSettings.Get("SSIS.AllBoPackageBackupPath");
            if (!Directory.Exists(backupPath))
            {
                Directory.CreateDirectory(backupPath);
            }

            application.SaveToXml(Path.Combine(backupPath, Path.GetFileName(pkgPath).Replace(".dtsx", DateTime.Now.ToString("ddMMyyyy_hhmm") + ".dtsx")), package, null);
            //Get the last executable
            Executable fromTask = GetLastTaskOnSequence(package);
            //Add new task
            Executable newTask  = package.Executables.Add(TaskType);
            TaskHost   tNewTask = (TaskHost)newTask;
            tNewTask.Properties["ConnectionName"].SetValue(tNewTask, accountWizardSettings.Get("SSIS.ConnectionName"));
            string procCmd = string.Format("<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">" +
                                           "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
                                           "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                           "<Object>" +
                                           "<DatabaseID>{0}</DatabaseID>" +
                                           "<CubeID>{1}</CubeID>" +
                                           "</Object>" +
                                           "<Type>ProcessFull</Type>" +
                                           "<WriteBackTableCreation>UseExisting</WriteBackTableCreation>" +
                                           "</Process>" +
                                           "</Batch>", accountWizardSettings.Get("AnalysisServer.Database.ID"), accountWizardSettings.Get("Cube.BO.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString());


            tNewTask.Properties["ProcessingCommands"].SetValue(tNewTask, procCmd);

            tNewTask.Name = accountWizardSettings.Get("Cube.BO.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString();
            PrecedenceConstraint precedenceConstraint = package.PrecedenceConstraints.Add(fromTask, newTask);
            precedenceConstraint.Value = DTSExecResult.Completion;



            application.SaveToXml(pkgPath, package, null);
            //  app.SaveToDtsServer(p, null, @"D:\SSIS_Projects\test10.dtsx", "localhost"); //ToDo: may be this is better check with amit
            #endregion
            #region ContentTask
            //Get params from last step
            if (bool.Parse(collectedData["AccountSettings.AddContentCube"].ToString()) == true)
            {
                pkgPath     = accountWizardSettings.Get("SSIS.TemplateAllContentPackagePath"); //Load ContentTemplate Template
                application = new Application();

                package = application.LoadPackage(pkgPath, null);
                //BackUp the package
                backupPath = accountWizardSettings.Get("SSIS.AllContentPackageBackupPath");
                if (!Directory.Exists(backupPath))
                {
                    Directory.CreateDirectory(backupPath);
                }

                application.SaveToXml(Path.Combine(backupPath, Path.GetFileName(pkgPath).Replace(".dtsx", DateTime.Now.ToString("ddMMyyyy_hhmm") + ".dtsx")), package, null);
                //Get the last executable
                fromTask = GetLastTaskOnSequence(package);
                //Add new task
                newTask  = package.Executables.Add(TaskType);
                tNewTask = (TaskHost)newTask;
                tNewTask.Properties["ConnectionName"].SetValue(tNewTask, accountWizardSettings.Get("SSIS.ConnectionName"));
                procCmd = string.Format("<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">" +
                                        "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
                                        "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                        "<Object>" +
                                        "<DatabaseID>{0}</DatabaseID>" +
                                        "<CubeID>{1}</CubeID>" +
                                        "</Object>" +
                                        "<Type>ProcessFull</Type>" +
                                        "<WriteBackTableCreation>UseExisting</WriteBackTableCreation>" +
                                        "</Process>" +
                                        "</Batch>", accountWizardSettings.Get("AnalysisServer.Database.ID"), accountWizardSettings.Get("Cube.Content.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString());


                tNewTask.Properties["ProcessingCommands"].SetValue(tNewTask, procCmd);

                tNewTask.Name              = accountWizardSettings.Get("Cube.Content.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString();
                precedenceConstraint       = package.PrecedenceConstraints.Add(fromTask, newTask);
                precedenceConstraint.Value = DTSExecResult.Completion;


                application.SaveToXml(pkgPath, package, null);
            }

            #endregion
            #endregion
            #region Specific Cube only BO

            pkgPath     = accountWizardSettings.Get("SSIS.TemplateBoSpecific"); //Load Bo Template
            application = new Application();

            package = application.LoadPackage(pkgPath, null);



            fromTask = GetLastTaskOnSequence(package);

            TaskHost taskToUpdate = (TaskHost)fromTask;
            taskToUpdate.Properties["ConnectionName"].SetValue(tNewTask, accountWizardSettings.Get("SSIS.ConnectionName"));
            procCmd = string.Format("<Batch xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">" +
                                    "<Process xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
                                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                    "<Object>" +
                                    "<DatabaseID>{0}</DatabaseID>" +
                                    "<CubeID>{1}</CubeID>" +
                                    "</Object>" +
                                    "<Type>ProcessFull</Type>" +
                                    "<WriteBackTableCreation>UseExisting</WriteBackTableCreation>" +
                                    "</Process>" +
                                    "</Batch>", accountWizardSettings.Get("AnalysisServer.Database.ID"), accountWizardSettings.Get("Cube.BO.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString());


            taskToUpdate.Properties["ProcessingCommands"].SetValue(taskToUpdate, procCmd);

            taskToUpdate.Name = accountWizardSettings.Get("Cube.BO.Name.Perfix") + collectedData["AccountSettings.CubeName"].ToString();
            string fileName = Path.Combine(Path.GetDirectoryName(accountWizardSettings.Get("SSIS.TemplateBoSpecific")), string.Format(accountWizardSettings.Get("SSIS.NewSpecificPackageName"), collectedData["AccountSettings.CubeName"].ToString()));

            pkgPath = Path.Combine(accountWizardSettings.Get("SSIS.SSISNewTaskPath"), fileName);
            application.SaveToXml(pkgPath, package, null);
            #region AddToSqlServerAgent

            //Connect to the local, default instance of SQL Server.
            Server srv      = new Server();
            Job    template = srv.JobServer.Jobs[accountWizardSettings.Get("AccountSettings.TemplateSqlJob")];


            Job jb = new Job(srv.JobServer, string.Format(@"Load_{0}_Data", collectedData["AccountSettings.CubeName"].ToString()));
            jb.Name = string.Format(@"Load_{0}_Data", collectedData["AccountSettings.CubeName"].ToString());
            //new Job(srv.JobServer, string.Format(@"Load_{0}_Data", collectedData["AccountSettings.CubeName"].ToString()));
            jb.IsEnabled = false;

            jb.Create();

            for (int i = 0; i < template.JobSteps.Count; i++)
            {
                JobStep sourceStep = template.JobSteps[i];
                JobStep target     = new JobStep(jb, sourceStep.Name);
                target.Command         = sourceStep.Command;
                target.SubSystem       = sourceStep.SubSystem;
                target.OnSuccessAction = sourceStep.OnSuccessAction;
                target.OnFailAction    = sourceStep.OnFailAction;


                target.Create();
            }
            string stepName = "temp";
            try
            {
                stepName = string.Format(accountWizardSettings.Get("SSIS.NewSpecificPackageName"), collectedData["AccountSettings.CubeName"].ToString()).Replace(".dtsx", string.Empty);
            }
            catch
            {
            }
            //Define a JobStep object variable by supplying the parent job and name arguments in the constructor.
            JobStep jbstp = new JobStep(jb, stepName);
            jbstp.Command = @"dtexec /FILE " + "\"" + pkgPath + "\"";

            jbstp.SubSystem = AgentSubSystem.CmdExec;

            jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess; //CHANNGE SINCE DASHBOAD STEP IS CANCELED BY AMIT AND SHAY
            jbstp.OnFailAction    = StepCompletionAction.QuitWithFailure; //CHANNGE SINCE DASHBOAD STEP IS CANCELED BY AMIT AND SHAY

            //Create the job step on the instance of SQL Agent.
            jbstp.Create();

            /* CANCELD BY AMIT AND SHAY
             * jbstp = new JobStep(jb, "Load Dashboard Data");
             * jbstp.Command = "exec Seperia_dwh.dbo.DataService_ProcessMeasures";
             * jbstp.DatabaseName = "master"; //TODO PUT THE REAL ONE WITH PARAMETER
             *
             * jbstp.SubSystem = AgentSubSystem.TransactSql;
             *
             * jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
             * jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
             *
             * //Create the job step on the instance of SQL Agent.
             * jbstp.Create();
             * /
             */
            try
            {
                jb.ApplyToTargetServer(accountWizardSettings.Get("SSIS.JobServer"));
            }
            catch (Exception)
            {
                //wil be fixed....
            }

            #endregion


            #endregion
        }
        public static bool TryGetValue(this PrecedenceConstraints constraints, string source, string target, out PrecedenceConstraint constraint)
        {
            foreach (var item in constraints)
            {
                if (((IDTSName)item.PrecedenceExecutable).Name == source &&
                    ((IDTSName)item.ConstrainedExecutable).Name == target)
                {
                    constraint = item;
                    return(true);
                }
            }

            constraint = null;
            return(false);
        }