Exemplo n.º 1
0
        /// <summary>
        /// Parses job definition name and job run DateTime from provided path string.
        /// Example:
        ///   path = "ScheduledJob1\\Output\\20111219-200921-369\\Results.xml"
        ///      'ScheduledJob1' is the definition name.
        ///      '20111219-200921-369' is the jobRun DateTime.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="definitionName"></param>
        /// <param name="jobRunReturn"></param>
        /// <returns></returns>
        private static bool GetJobRunInfo(
            string path,
            out string definitionName,
            out DateTime jobRunReturn)
        {
            // Parse definition name from path.
            string[] pathItems = path.Split(System.IO.Path.DirectorySeparatorChar);
            if (pathItems.Length == 4)
            {
                definitionName = pathItems[0];
                return(ScheduledJobStore.ConvertJobRunNameToDateTime(pathItems[2], out jobRunReturn));
            }

            definitionName = null;
            jobRunReturn   = DateTime.MinValue;
            return(false);
        }
 private static bool GetJobRunInfo(string path, out string definitionName, out DateTime jobRunReturn)
 {
     char[] directorySeparatorChar = new char[1];
     directorySeparatorChar[0] = Path.DirectorySeparatorChar;
     string[] strArrays = path.Split(directorySeparatorChar);
     if ((int)strArrays.Length != 4)
     {
         definitionName = null;
         jobRunReturn   = DateTime.MinValue;
         return(false);
     }
     else
     {
         definitionName = strArrays[0];
         return(ScheduledJobStore.ConvertJobRunNameToDateTime(strArrays[2], out jobRunReturn));
     }
 }
Exemplo n.º 3
0
        public static Collection <DateTime> GetJobRunsForDefinitionPath(string definitionOutputPath)
        {
            DateTime dateTime;
            string   str;

            if (!string.IsNullOrEmpty(definitionOutputPath))
            {
                Collection <DateTime> dateTimes = new Collection <DateTime>();
                IEnumerable <string>  strs      = Directory.EnumerateDirectories(definitionOutputPath);
                if (strs != null)
                {
                    foreach (string str1 in strs)
                    {
                        int num = str1.LastIndexOf('\\');
                        if (num != -1)
                        {
                            str = str1.Substring(num + 1);
                        }
                        else
                        {
                            str = str1;
                        }
                        string str2 = str;
                        if (!ScheduledJobStore.ConvertJobRunNameToDateTime(str2, out dateTime))
                        {
                            continue;
                        }
                        dateTimes.Add(dateTime);
                    }
                }
                return(dateTimes);
            }
            else
            {
                throw new PSArgumentException("definitionOutputPath");
            }
        }