Ejemplo n.º 1
0
 public State(State oState)
 {
     JobName = oState.JobName;
     CurrentDependency = oState.CurrentDependency;
     CurrentExecutingMode = oState.CurrentExecutingMode;
     ExecutionState = oState.ExecutionState;
     CurrentJobCode = oState.CurrentJobCode;
     CurrentJobHash = oState.CurrentJobHash;
     CurrentParameters = oState.CurrentParameters;
     CurrentStatusCollection = oState.CurrentStatusCollection;
     SourceFileName = oState.SourceFileName;
 }
Ejemplo n.º 2
0
        private void WriteToFile(State state,  Hashtable inputData, string sourceFileName, DataTable dt, out string finalPath)
        {
            string fullfilename = String.Empty;
            int jobKeyCode = state.CurrentJobHash;
            finalPath = String.Empty;

            //DateTime rundate = GetRunDate(inputData);
            DateTime rundate = state.CurrentParameters.ProcessInputDates.InDate;
            if (state.CurrentParameters.GetModuleInDatesOverride(this.Name) != null)
                rundate = state.CurrentParameters.GetModuleInDatesOverride(this.Name).InDate;


            //Meta Tag replacement on mudule properties happens at job's launch
            //fullfilename = path.TrimEnd('\\') + "\\" + ((fileName == String.Empty) ? sourceFileName : ConfigUtils.MetaTagReplacer(fileName.Replace("00010101","*RUNDATE*"), rundate));
            fullfilename = path.TrimEnd('\\') + "\\" + ((fileName == String.Empty) ? sourceFileName :
                                                                                fileName.Replace("00010101", 
                                                                                    MetaTagReplacer.GetMetaTagValue("*RUNDATE*", rundate)));

            newPath = newPath.CompareTo(String.Empty) == 0 ? path : newPath;
            if (!newExtension.Equals(String.Empty))
                fullfilename = fullfilename.Substring(0, fullfilename.LastIndexOf('.') + 1) + newExtension;

            if (!Convert.ToBoolean(ifSupressFile))
            {
                //Meta Tag replacement on mudule properties happens at job's launch
                //finalPath = ConfigUtils.MetaTagReplacer(fullfilename.Replace(path.TrimEnd('\\'), newPath.TrimEnd('\\')));
                finalPath = fullfilename.Replace(path.TrimEnd('\\'), newPath.TrimEnd('\\'));
                log.InfoFormat(jobKeyCode, "Beginning write to file {0}.", finalPath);

                numDeleteTries = 0;
                if (DeleteFile(jobKeyCode, finalPath))
                {
                    using (StreamWriter sr = new StreamWriter(File.OpenWrite(finalPath)))
                    {
                        if (dt != null)
                        {
                            recCountTotal = dt.Rows.Count;
                            recCountSuccess = dt.Rows.Count;
                            string[] outputs = new string[dt.Columns.Count];
                            string[] colNames = new string[0];
                            if (ifIncludeHeaders)
                            {
                                if (Columns.Trim() != "")
                                {
                                    colNames = ReduceColumns(jobKeyCode,Columns, separator);
                                }
                                for (int i = 0; i < dt.Columns.Count; i++)
                                {
                                    outputs[i] = dt.Columns[i].ColumnName.ToString().TrimEnd('1');
                                    if (colNames.Length > 0 && colNames[i] != null)
                                        outputs[i] = colNames[i];
                                }
                                
                                if (outputs.Length > 0)
                                    WriteLine(jobKeyCode, sr, outputs);
                            }

                            foreach (DataRow dr in dt.Rows)
                            {
                                outputs = new string[dt.Columns.Count];

                                for (int i = 0; i < dt.Columns.Count; i++)
                                {
                                    string s = dr[i].ToString();

                                    if (!CollapseField.Equals(String.Empty))
                                    {
                                        string[] keys = collapseField.Split(':');
                                        if (keys.Length == 3 && dt.Columns[i].ColumnName.Equals(keys[0]))
                                        {
                                            string filter = keys[2];
                                            string[] filterKeys = filter.Split('=');
                                            if (filterKeys.Length == 2 && dr[dt.Columns[filterKeys[0]]].Equals(filterKeys[1]))
                                            {
                                                char[] cs = keys[1].ToCharArray();
                                                foreach (char c in cs)
                                                    s = s.Replace(c.ToString(),"");
                                            }
                                        }
                                    }

                                    outputs[i] = s;
                                }

                                if (outputs.Length > 0)
                                    WriteLine(jobKeyCode, sr, outputs);
                            }
                        }
                        else
                        {
                            WriteLine(jobKeyCode, sr, new string[] { "" });
                            log.ErrorFormat(jobKeyCode, "ExportToFile did not execute (DataTable is null).");
                            recCountFailed = recCountTotal;
                            recCountSuccess = 0;
                        }
                        sr.Flush();
                        sr.Close();
                    }
                }
            }
            else
            {
                log.ErrorFormat(jobKeyCode, "ExportToFile failed to execute.");
                recCountFailed = recCountTotal;
                recCountSuccess = 0;
            }
        }
Ejemplo n.º 3
0
        //public Job(Job oJob, bool isNew)
        //{
        //    key = isNew ? DateTime.Now : oJob.key;
        //    jobName = oJob.jobName;
        //    dependencyTraversalMode = oJob.dependencyTraversalMode;
        //    config = oJob.config;
        //    arrModules = oJob.arrModules;
        //    modules = oJob.modules;
        //    dependencies = oJob.dependencies;
        //    limiter = oJob.limiter;

        //    jobStats = new JobStats(this);
        //    jobDetails = oJob.jobDetails;

        //    jobState = new State(oJob.JobState);
        //    jobState.CurrentJobCode = key;
        //    jobState.CurrentJobHash = KeyHash;
        //    jobState.JobName = jobName;
        //}

        public Job(string _jobName, string _dependencyTraversalMode, JobDetails _jobDetails, GlobalConfigDetails _config)
        {
            config = _config;

            jobName = _jobName;
            jobStats = new JobStats(this);
            jobState = new State(_jobName);
            jobDetails = _jobDetails;
            dependencyTraversalMode = _dependencyTraversalMode;
        }
Ejemplo n.º 4
0
        private string OmgeoLogic(State state, Hashtable inputData, string finalPath, string sourceFileName)
        {
            List<string> brokers = new List<string>();
            foreach (string name in inputData.Keys)
                if (name.IndexOf("_Broker_") > -1)
                    brokers.Add(name);

            foreach (string name in brokers)
            {
                DataTable dt = new DataTable();
                dt = inputData[name] as DataTable;
                newExtension = name.Substring(name.IndexOf("_Broker_") + 8) + ".csv";
                WriteToFile(state, inputData, sourceFileName, dt, out finalPath);
            }
            return finalPath;
        }
Ejemplo n.º 5
0
        public Job(Job oJob)
        {
            key = oJob.key;
            jobName = oJob.jobName;
            dependencyTraversalMode = oJob.dependencyTraversalMode;

            jobStats = new JobStats(this);
            jobDetails = oJob.jobDetails;
            jobState = new State(oJob.JobState);

            config = oJob.config;
            arrModules = oJob.arrModules;
            modules = oJob.modules;
            dependencies = oJob.dependencies;
            limiter = oJob.limiter;
        }