/// <summary>
		///     Iterates through all values in the matrix or jagged array and finds maximum length required
		///     to show any of the values contained.
		/// </summary>
		/// <param name="array">Matrix or jagged array through which this method will iterate.</param>
		/// <returns>Number of characters sufficient to receive any formatted value contained in <paramref name="array" />.</returns>
		private int GetMaxValueLength(Array array)
		{
			var maxLength = 0;

			if (IsMultiLinedFormat)
			{
				var sfi = new ScalarFormatInfo(this);
				sfi.ShowDataType = false;
				sfi.ShowInstanceName = false;

				if (array.Rank == 2)
				{
					maxLength = sfi.GetMaxValueLength(array.GetEnumerator());
				}
				else
				{
					// In jagged array we have to iterate through rows manually

					var rowsEnumerator = array.GetEnumerator();
					while (rowsEnumerator.MoveNext())
					{
						var row = (Array) rowsEnumerator.Current;
						var curMaxLength = sfi.GetMaxValueLength(row.GetEnumerator());
						maxLength = Math.Max(maxLength, curMaxLength);
					}
				}
			}

			return maxLength;
		}
        /// <summary>
        /// Slices arrays of 2 and more dimensions.
        /// </summary>
        /// <param name="arr">Array to slice</param>
        /// <param name="sliceDimensionIndex">Dimension to slice</param>
        /// <param name="indexToSet">Index to set for the sliced dimension</param>
        /// <returns>Sliced array</returns>
        public static Array Slice(Array arr, int sliceDimensionIndex, int indexToSet)
        {
            var enumerator = arr.GetEnumerator();
            enumerator.MoveNext();
            Type elementType = enumerator.Current.GetType();

            int[] lengthsSliced =
                Enumerable.Range(0, arr.Rank)
                    .Where(i => i != sliceDimensionIndex)
                    .Select(arr.GetLength)
                    .ToArray();

            int[] lowerBoundsSliced =
                Enumerable.Range(0, arr.Rank)
                    .Where(i => i != sliceDimensionIndex)
                    .Select(arr.GetLowerBound)
                    .ToArray();

            var arraySliced = Array.CreateInstance(elementType, lengthsSliced, lowerBoundsSliced);
            var multiIndex1 = _firstIndex(arraySliced);
            var multiIndex2 = _firstIndexBounded(arr, sliceDimensionIndex, indexToSet);
            for (; multiIndex2 != null; multiIndex1 = _nextIndex(arraySliced, multiIndex1), multiIndex2 = _nextIndexBounded(arr, multiIndex2, sliceDimensionIndex))
            {
                arraySliced.SetValue(arr.GetValue(multiIndex2), multiIndex1);
            }
            return arraySliced;
        }
        private void Select_ListaWiadomosciOczekujacych_ExecuteCode(object sender, EventArgs e)
        {
            results = BLL.tabWiadomosci.Select_Batch(workflowProperties.Web);
            myEnum = results.GetEnumerator();

            logSelected_HistoryOutcome = results.Length.ToString();
        }
        private Dictionary <String, List <string> > GetDataFromExcel(Excel.Workbook theWorkbook)
        {
            Dictionary <String, List <string> > rows = new Dictionary <string, List <string> >();

            Excel.Worksheet worksheet = (Excel.Worksheet)theWorkbook.Worksheets["IAN"];
            Excel.Range     rowRange  = worksheet.UsedRange;

            for (int row = 6; row <= rowRange.Rows.Count; row++)
            {
                List <string> rowValues = new List <string>();

                Excel.Range  range      = worksheet.Range["A" + row, "M" + row];
                System.Array values     = (System.Array)range.Cells.Value;
                var          enumerator = values.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    string key = enumerator.Current.ToString();
                    while (enumerator.MoveNext())
                    {
                        var currentvalue = enumerator.Current;
                        if (currentvalue == null || currentvalue.ToString().Equals(""))
                        {
                            break;
                        }

                        rowValues.Add(currentvalue.ToString());
                    }
                    rows.Add(key.ToLower(), rowValues);
                }
            }

            return(rows);
        }
 public static IEnumerator ForEachInArr(Array ary)
 {
     IEnumerator enumerator = ary.GetEnumerator();
     if (enumerator == null)
     {
         throw ExceptionUtils.VbMakeException(0x5c);
     }
     return enumerator;
 }
        private void cmdGet_KartyKontrolne_ExecuteCode(object sender, EventArgs e)
        {
            logSelected_HistoryDescription = "Karty kontrolne do obsługi";

            results = BLL.tabKartyKontrolne.Get_ZwolnioneDoWysylki(workflowProperties.Web);
            myEnum = results.GetEnumerator();

            if (results != null) logSelected_HistoryOutcome = results.Length.ToString();
            else logSelected_HistoryOutcome = "0";
        }
Example #7
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     if (this.IsArray)
     {
         return(_array.GetEnumerator());
     }
     else
     {
         return(this._dic.Keys.GetEnumerator());
     }
 }
Example #8
0
        /// <summary>
        /// Compare the two arrays
        /// </summary>
        /// <param name="a">Array A</param>
        /// <param name="b">Array B</param>
        /// <returns>True if the two array are equals, otherwise False.</returns>
        /// <example>
        /// <code>
        ///   int[] a = new int[] { 1, 2, 3, 4 };
        ///   int[] b = new int[] { 1, 2, 3, 4 };
        ///   Assert.IsTrue(Arrays.DeepEquals(a, b));
        /// </code>
        /// </example>
        public static bool DeepEquals(Array a, Array b)
        {
            if (a == null && b == null)
            {
                return true;
            }
            if (ReferenceEquals(a, b))
            {
                return true;
            }
            if (a.Length != b.Length)
            {
                return false;
            }

            bool result = true;

            IEnumerator enA = a.GetEnumerator();
            IEnumerator enB = b.GetEnumerator();

            while (enA.MoveNext() && enB.MoveNext())
            {
                if (enA.Current == null && enB.Current == null)
                {
                }
                else if (enA.Current == null || enB.Current == null)
                {
                    result = false;
                    break;
                }
                else if ((enA is Array) && (enB is Array))
                {
                    result = DeepEquals((Array)enA, (Array)enB);
                    if (!result)
                    {
                        break;
                    }
                }
                else if (enA.Current == enB.Current)
                {
                }
                else if (enA.Current.Equals(enB.Current))
                {
                }
                else
                {
                    result = false;
                    break;
                }
            }

            return result;
        }
Example #9
0
 static public int GetEnumerator(IntPtr l)
 {
     try {
         System.Array self = (System.Array)checkSelf(l);
         var          ret  = self.GetEnumerator();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        private static bool ItemsEquals(Array x, Array y, Func<object, object, bool> compare)
        {
            var xe = x.GetEnumerator();
            var ye = y.GetEnumerator();
            while (xe.MoveNext() && ye.MoveNext())
            {
                if (!compare(xe.Current, ye.Current))
                {
                    return false;
                }
            }

            return true;
        }
Example #11
0
        static StackObject *GetEnumerator_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Array instance_of_this_method = (System.Array) typeof(System.Array).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.GetEnumerator();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        private Dictionary <String, List <string> > GetDataFromExcel(Excel.Workbook theWorkbook, string luna)
        {
            Dictionary <String, List <string> > rows = new Dictionary <string, List <string> >();

            Excel.Worksheet worksheet   = (Excel.Worksheet)theWorkbook.Worksheets[luna];
            Excel.Range     rowRange    = worksheet.UsedRange;
            bool            shouldBreak = false;

            for (int row = 7; row <= rowRange.Rows.Count; row++)
            {
                List <string> rowValues = new List <string>();

                Excel.Range  range      = worksheet.Range["A" + row, "P" + row];
                System.Array values     = (System.Array)range.Cells.Value;
                var          enumerator = values.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    string key = enumerator.Current.ToString();
                    int    i   = 0;
                    while (enumerator.MoveNext())
                    {
                        var currentvalue = enumerator.Current;
                        if (currentvalue == null || currentvalue.ToString().Equals(""))
                        //                            break;
                        {
                            if (i == 3)
                            {
                                shouldBreak = true;
                                break;
                            }
                            rowValues.Add("");
                        }
                        else
                        {
                            rowValues.Add(currentvalue.ToString());
                        }
                        i++;
                    }
                    rows.Add(key.ToLower(), rowValues);
                }
                if (shouldBreak)
                {
                    break;
                }
            }
            Log.Error("LUNA:" + luna);
            DatabaseHandler.Instance.SavePatients(rows.ExcelToPatient());

            return(rows);
        }
Example #13
0
 static int GetEnumerator(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Array obj = (System.Array)ToLua.CheckObject(L, 1, typeof(System.Array));
         System.Collections.IEnumerator o = obj.GetEnumerator();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        ////////////////////////////////////////////////////////////////////////
        // METHOD: CreateExtendedPropertyRecord
        private bool CreateExtendedPropertyRecord(IJTXJob job, ExtendedPropertyIdentifier child)
        {
            IJTXAuxProperties pAuxProps = (IJTXAuxProperties)job;

            IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(child.LongTableName);

            if (!string.IsNullOrEmpty(m_paramExtendedProperties) && pAuxContainer == null)
            {
                string msg = string.Format(
                    "Unable to set extended property for child job {0}. Unable to find child job's extended property table: {1}",
                    job.ID, child.LongTableName);
                m_ipDatabase.LogMessage(3, 2000, msg);
            }

            System.Array contNames = pAuxProps.ContainerNames;
            System.Collections.IEnumerator contNamesEnum = contNames.GetEnumerator();
            contNamesEnum.Reset();
            while (contNamesEnum.MoveNext())
            {
                try
                {
                    string strContainerName = (string)contNamesEnum.Current;
                    if (!string.IsNullOrEmpty(m_paramExtendedProperties) && (strContainerName.ToUpper()).Equals(child.LongTableName.ToUpper()))
                    {
                        pAuxContainer = pAuxProps.GetRecordContainer(strContainerName);

                        if (pAuxContainer.RelationshipType != esriRelCardinality.esriRelCardinalityOneToOne)
                        {
                            throw new Exception("The table relationship is not one-to-one.");
                        }
                        IJTXAuxRecord childRecord = pAuxContainer.GetRecords().get_Item(0);//pAuxContainer.CreateRecord();


                        SetExtendedPropertyValues(childRecord, child);
                        JobUtilities.LogJobAction(m_ipDatabase, job, Constants.ACTTYPE_UPDATE_EXT_PROPS, "", null);
                    }
                }
                catch (Exception ex)
                {
                    string msg = string.Format(
                        "Unable to create extended property {0} in record for jobid {1}. ERROR: {2}",
                        child.FieldName, job.ID, ex.Message);
                    m_ipDatabase.LogMessage(3, 2000, msg);
                }
            }

            return(true);
        }
        private void PrintArrayValues(System.Array array, bool original)
        {
            IEnumerator i = array.GetEnumerator();

            if (original)
            {
                Console.WriteLine("Original field values:");
            }
            else
            {
                Console.WriteLine("New field values:");
            }

            while (i.MoveNext())
            {
                Console.WriteLine(i.Current.ToString());
            }
        }
Example #16
0
 private static void PrintValues(Array myArr, char mySeparator)
 {
     System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();
     int i = 0;
     int cols = myArr.GetLength(myArr.Rank - 1);
     while (myEnumerator.MoveNext())
     {
         if (i < cols)
         {
             i++;
         }
         else
         {
             Console.WriteLine();
             i = 1;
         }
         Console.Write("{0}{1}", mySeparator, myEnumerator.Current);
     }
     Console.WriteLine();
 }
Example #17
0
 public static void PrintAllValues(Array myArr)
 {
     System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator();
     int i = 0;
     int cols = myArr.GetLength(myArr.Rank - 1);
     while (myEnumerator.MoveNext())
     {
         if (i < cols)
         {
             i++;
         }
         else
         {
             Console.WriteLine();
             i = 1;
         }
         Console.Write("\t{0}", myEnumerator.Current);
     }
     Console.WriteLine();
 }
Example #18
0
        public static bool Equals(Array arr1, Array arr2)
        {
            if(object.ReferenceEquals(arr1, arr2))
            {
                return true;
            }

            if((arr1 == null && arr2 != null) || (arr1 != null && arr2 == null))
            {
                return false;
            }

            if(arr1.Length == arr2.Length)
            {
                IEnumerator e1 = arr1.GetEnumerator();
                IEnumerator e2 = arr2.GetEnumerator();
                while(e1.MoveNext())
                {
                    e2.MoveNext();
                    if(e1.Current == null)
                    {
                        if(e2.Current != null)
                        {
                            return false;
                        }
                    }
                    else if(!e1.Current.Equals(e2.Current))
                    {
                        return false;
                    }
                }

                return true;
            }

            return false;           
        }
Example #19
0
        public static void AreEqual(Array obj1, Array obj2, string failMessage)
        {
            if (obj1 == obj2)
            {
                return;
            }
            if (null == obj1)
            {
                if (null != obj2)
                {
                    throw new AssertionException(failMessage);
                }
                return;
            }
            if (null == obj2)
            {
                throw new AssertionException(failMessage);
            }
            if (!obj1.GetType().Equals(obj2.GetType()))
            {
                throw new AssertionException(failMessage + ". Expected object type: " + obj1.GetType().ToString() + ", but actual object type is: " + obj2.GetType().ToString());
            }
            if (!obj1.Length.Equals(obj2.Length))
            {
                throw new AssertionException(failMessage);
            }

            System.Collections.IEnumerator first = obj1.GetEnumerator();
            System.Collections.IEnumerator second = obj2.GetEnumerator();

            while (first.MoveNext() && second.MoveNext())
            {
                if (((null != first.Current) && !first.Current.Equals(second.Current)) || ((null == first.Current) && (null != second.Current)))
                {
                    throw new AssertionException(failMessage);
                }
            }
        }
Example #20
0
        static public void CompareArrays(Array a1, Array a2, string value)
        {
            if (a1 == null &&
                a2 == null)
                return;
            Assert.IsFalse((a1 == null && a2 != null) || (a1 != null && a2 == null), value + " do not match - one array is null");
            Assert.IsTrue(a1.Length == a2.Length, value + " do not match - array lengths do not match");


            IEnumerator enum1 = a1.GetEnumerator();
            IEnumerator enum2 = a2.GetEnumerator();
            while (enum1.MoveNext() && enum2.MoveNext())
                Assert.IsTrue(enum1.Current.Equals(enum2.Current), value + " do not match");                
        }
Example #21
0
        public static bool IsEqualArray(Array a, Array b)
        {
            if (a == null && b == null)
                return true;
            if (a == null)
                return false;
            if (b == null)
                return false;

            Type aType = a.GetType();
            Type bType = b.GetType();

            if (aType != bType)
                return false;

            if (!aType.IsArray)
                return false;

            var aEnumerator = a.GetEnumerator();
            var bEnumerator = b.GetEnumerator();

            while (true)
            {
                bool aHasElement = aEnumerator.MoveNext();
                bool bHasElement = bEnumerator.MoveNext();

                if (aHasElement != bHasElement)
                    return false;

                if (!aHasElement)
                    return true;

                if (!IsEqualObject(aEnumerator.Current, bEnumerator.Current))
                    return false;
            }
        }
		private byte[] EncodeSliceArray(Array sourceArray)
		{
			IEnumerator i		= sourceArray.GetEnumerator();
			DbDataType	dbType	= DbDataType.Array;
			Charset		charset = this.db.Charset;
			XdrStream	xdr		= new XdrStream(this.db.Charset);
			int			type	= 0;
			int			subtype = (this.Descriptor.Scale < 0) ? 2 : 0;

			type = TypeHelper.GetFbType(this.Descriptor.DataType);
			dbType = TypeHelper.GetDbDataType(this.Descriptor.DataType, subtype, this.Descriptor.Scale);

			while (i.MoveNext())
			{
				switch (dbType)
				{
					case DbDataType.Char:
						byte[] buffer = charset.GetBytes(i.Current.ToString());
						xdr.WriteOpaque(buffer, this.Descriptor.Length);
						break;

					case DbDataType.VarChar:
						xdr.Write((string)i.Current);
						break;

					case DbDataType.SmallInt:
						xdr.Write((short)i.Current);
						break;

					case DbDataType.Integer:
						xdr.Write((int)i.Current);
						break;

					case DbDataType.BigInt:
						xdr.Write((long)i.Current);
						break;

					case DbDataType.Decimal:
					case DbDataType.Numeric:
						xdr.Write((decimal)i.Current, type, this.Descriptor.Scale);
						break;

					case DbDataType.Float:
						xdr.Write((float)i.Current);
						break;

					case DbDataType.Double:
						xdr.Write((double)i.Current);
						break;

					case DbDataType.Date:
						xdr.WriteDate(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat));
						break;

					case DbDataType.Time:
						xdr.WriteTime(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat));
						break;

					case DbDataType.TimeStamp:
						xdr.Write(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat));
						break;

					default:
						throw new NotSupportedException("Unknown data type");
				}
			}

			return xdr.ToArray();
		}
	// Get the enumerator for an array.
	public static IEnumerator ForEachInArr(Array ary)
			{
				return ary.GetEnumerator();
			}
Example #24
0
        /// <summary>Curl an input array up into a multi-dimensional array.</summary>
        /// <param name="input">The one dimensional array to be curled.</param>
        /// <param name="dimens">The desired dimensions</param>
        /// <returns>The curled array.</returns>
        public static Array Curl(Array input, int[] dimens)
        {
            if (CountDimensions(input) != 1)
            {
                throw new SystemException("Attempt to curl non-1D array");
            }

            int test = 1;
            for (int i = 0; i < dimens.Length; i += 1)
            {
                test *= dimens[i];
            }

            if (test != input.Length)
            {
                throw new SystemException("Curled array does not fit desired dimensions");
            }

            Array newArray = NewInstance(GetBaseClass(input), dimens);

            int[] index = new int[dimens.Length];
            index[index.Length - 1] = -1;
            for (int i = 0; i < index.Length - 1; ++i)
            {
                index[i] = 0;
            }

            for (IEnumerator i = input.GetEnumerator(); i.MoveNext() && NextIndex(index, dimens); )
            {
                //NewInstance call creates a jagged array. So we cannot set the value using Array.SetValue
                //as it works for multi-dimensional arrays and not for jagged
                //newArray.SetValue(i.Current, index);

                Array tarr = newArray;
                for (int i2 = 0; i2 < index.Length - 1; i2++)
                {
                    tarr = (Array)tarr.GetValue(index[i2]);
                }
                tarr.SetValue(i.Current, index[index.Length - 1]);
            }
            //int offset = 0;
            //DoCurl(input, newArray, dimens, offset);
            return newArray;
        }
Example #25
0
 private void Select_ListaZadan_ExecuteCode(object sender, EventArgs e)
 {
     bool withAttachements = true;
     zadania = BLL.tabZadania.Get_ZakonczoneDoArchiwizacji(workflowProperties.Web, withAttachements);
     myEnum = zadania.GetEnumerator();
 }
Example #26
0
 private void Select_ListaWiadomosci_ExecuteCode(object sender, EventArgs e)
 {
     wiadomosci = BLL.tabWiadomosci.Get_GotoweDoArchiwizacji(workflowProperties.Web);
     myEnum = wiadomosci.GetEnumerator();
 }
Example #27
0
        private void Create_TargetList_ExecuteCode(object sender, EventArgs e)
        {
            Debug.WriteLine("Create_TargetList");

            klienci = BLL.tabKlienci.Get_AktywniKlienci(workflowProperties.Web);
            Debug.WriteLine("#klienci: " + klienci.Length.ToString());

            myEnum = klienci.GetEnumerator();
        }
Example #28
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(_Parts.GetEnumerator());
 }
		private	byte[] EncodeSlice(ArrayDesc desc, Array sourceArray, int length)
		{
			BinaryWriter	writer	= new BinaryWriter(new MemoryStream());
			IEnumerator		i		= sourceArray.GetEnumerator();
			Charset			charset = this.db.Charset;
			DbDataType		dbType	= DbDataType.Array;
			int				type	= 0;
			int				subtype = (this.Descriptor.Scale < 0) ? 2 : 0;

			// Infer data types
			type = TypeHelper.GetFbType(this.Descriptor.DataType);
			dbType = TypeHelper.GetDbDataType(this.Descriptor.DataType, subtype,	this.Descriptor.Scale);

			while (i.MoveNext())
			{
				switch (dbType)
				{
					case DbDataType.Char:
					{
						string value  = i.Current != null ?	(string)i.Current :	String.Empty;
						byte[] buffer = charset.GetBytes(value);

						writer.Write(buffer);

						if (desc.Length	> buffer.Length)
						{
							for	(int j = buffer.Length;	j <	desc.Length; j++)
							{
								writer.Write((byte)32);
							}
						}
					}
					break;

					case DbDataType.VarChar:
					{
						string value = i.Current !=	null ? (string)i.Current : String.Empty;

						value = value.TrimEnd();

						byte[] buffer = charset.GetBytes(value);
						writer.Write(buffer);

						if (desc.Length	> buffer.Length)
						{
							for	(int j = buffer.Length;	j <	desc.Length; j++)
							{
								writer.Write((byte)0);
							}
						}
						writer.Write((short)0);
					}
					break;
	
					case DbDataType.SmallInt:
						writer.Write((short)i.Current);
						break;
	
					case DbDataType.Integer:
						writer.Write((int)i.Current);
						break;

					case DbDataType.BigInt:
						writer.Write((long)i.Current);
						break;
					
					case DbDataType.Float:
						writer.Write((float)i.Current);
						break;
										
					case DbDataType.Double:
						writer.Write((double)i.Current);
						break;
					
					case DbDataType.Numeric:
					case DbDataType.Decimal:
					{
						object numeric = TypeEncoder.EncodeDecimal((decimal)i.Current, desc.Scale, type);

						switch (type)
						{
							case IscCodes.SQL_SHORT:
								writer.Write((short)numeric);
								break;

							case IscCodes.SQL_LONG:
								writer.Write((int)numeric);
								break;

							case IscCodes.SQL_QUAD:
							case IscCodes.SQL_INT64:
								writer.Write((long)numeric);
								break;
						}
					}
					break;

					case DbDataType.Date:
						writer.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat)));
						break;
					
					case DbDataType.Time:
						writer.Write(TypeEncoder.EncodeTime(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat)));
						break;

					case DbDataType.TimeStamp:
						writer.Write(TypeEncoder.EncodeDate(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat)));
						writer.Write(TypeEncoder.EncodeTime(Convert.ToDateTime(i.Current, CultureInfo.CurrentCulture.DateTimeFormat)));
						break;
					
					default:
						throw new NotSupportedException("Unknown data type");
				}
			}

			return ((MemoryStream)writer.BaseStream).ToArray();
		}
Example #30
0
        static void EnumAsArray(Array arr)
        {
            TestLogger.Log("Testing foreach enumeration over Array...");
            foreach (var a in arr)
            {
                if (a != null)
                    TestLogger.Log(a.ToString());
            }

            TestLogger.Log("Testing untyped direct enumeration over Array...");
            var en1 = arr.GetEnumerator();
            while (en1.MoveNext())
            {
                if (en1.Current != null)
                    TestLogger.Log(en1.Current.ToString());
            }

            TestLogger.Log("Testing typed direct enumeration over Array...");
            var en2 = ((IEnumerable<B>)arr).GetEnumerator();
            while (en2.MoveNext())
            {
                if (en2.Current != null)
                    TestLogger.Log(en2.Current.ToString());
            }
        }
        /// <summary>
        /// Called when a step of this type is executed in the workflow.
        /// </summary>
        /// <param name="JobID">ID of the job being executed</param>
        /// <param name="StepID">ID of the step being executed</param>
        /// <param name="argv">Array of arguments passed into the step's execution</param>
        /// <param name="ipFeedback">Feedback object to return status messages and files</param>
        /// <returns>Return code of execution for workflow path traversal</returns>
        public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            System.Diagnostics.Debug.Assert(m_ipDatabase != null);

            string strValue  = "";
            int    jobTypeID = 0;

            if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strValue))
            {
                throw new ArgumentNullException(m_expectedArgs[0], string.Format("\nMissing the {0} parameter!", m_expectedArgs[0]));
            }

            if (!Int32.TryParse(strValue, out jobTypeID))
            {
                throw new ArgumentNullException(m_expectedArgs[0], "Argument must be an integrer!");
            }

            IJTXJobType    pJobType = m_ipDatabase.ConfigurationManager.GetJobTypeByID(jobTypeID);
            IJTXJobManager pJobMan  = m_ipDatabase.JobManager;
            IJTXJob        pNewJob  = pJobMan.CreateJob(pJobType, 0, true);

            IJTXActivityType pActType = m_ipDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_CREATE_JOB);

            if (pActType != null)
            {
                pNewJob.LogJobAction(pActType, null, "");
            }

            JTXUtilities.SendNotification(Constants.NOTIF_JOB_CREATED, m_ipDatabase, pNewJob, null);

            // Assign a status to the job if the Auto Assign Job Status setting is enabled
            IJTXConfigurationProperties pConfigProps = (IJTXConfigurationProperties)m_ipDatabase.ConfigurationManager;

            if (pConfigProps.PropertyExists(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN))
            {
                string strAutoAssign = pConfigProps.GetProperty(Constants.JTX_PROPERTY_AUTO_STATUS_ASSIGN);
                if (strAutoAssign == "TRUE")
                {
                    pNewJob.Status = m_ipDatabase.ConfigurationManager.GetStatus("Created");
                }
            }

            // Associate the current job with the new job with a parent-child relationship
            pNewJob.ParentJob = JobID;

            // Assign the job as specified in the arguments
            string strAssignTo = "";

            if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], true, out strAssignTo))
            {
                pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeGroup;
                pNewJob.AssignedTo   = strAssignTo;
            }
            else if (StepUtilities.GetArgument(ref argv, m_expectedArgs[2], true, out strAssignTo))
            {
                pNewJob.AssignedType = jtxAssignmentType.jtxAssignmentTypeUser;
                pNewJob.AssignedTo   = strAssignTo;
            }
            pNewJob.Store();

            // Copy the workflow to the new job
            WorkflowUtilities.CopyWorkflowXML(m_ipDatabase, pNewJob);

            // Create 1-1 extended property entries
            IJTXAuxProperties pAuxProps = (IJTXAuxProperties)pNewJob;

            System.Array contNames     = pAuxProps.ContainerNames;
            IEnumerator  contNamesEnum = contNames.GetEnumerator();

            contNamesEnum.Reset();

            while (contNamesEnum.MoveNext())
            {
                string strContainerName = (string)contNamesEnum.Current;
                IJTXAuxRecordContainer pAuxContainer = pAuxProps.GetRecordContainer(strContainerName);
                if (pAuxContainer.RelationshipType == esriRelCardinality.esriRelCardinalityOneToOne)
                {
                    pAuxContainer.CreateRecord();
                }
            }

            m_ipDatabase.LogMessage(5, 1000, System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle);

            // Update Application message about the new job
            if (System.Diagnostics.Process.GetCurrentProcess().MainWindowTitle.Length > 0) //if its not running in server
            {
                MessageBox.Show("Created " + pJobType.Name + " Job " + pNewJob.ID, "Job Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(0);
        }