Beispiel #1
0
 private void CreateRunner(Collection <Target> target, Collection <Parameter> param)
 {
     try
     {
         ManualResetEvent resetEvent = new ManualResetEvent(false);
         TextConsole      console    = new TextConsole();
         //console.Show();
         //ThreadStart consoleThreadStart = console.Show;
         //Thread consoleThread = new Thread(consoleThreadStart);
         //consoleThread.IsBackground = true;
         //consoleThread.Start();
         doneEvents.Add(resetEvent);
         TargetRunner runner = new TargetRunner(target, param, null, resetEvent);
         targetRunners.AddItem(runner);
         ThreadPool.QueueUserWorkItem(runner.ThreadPoolCallback, targetRunners.Count - 1);
         //ThreadPool.SetMaxThreads(maxRunners, maxRunners);
         //WaitOrTimerCallback waitOrTimerCallback = runner.ThreadPoolCallback;
         //ThreadPool.RegisterWaitForSingleObject(resetEvent, waitOrTimerCallback, targetRunners, TEN_MINUTES, true);
         WaitHandle.WaitAny(doneEvents.ToArray());
         //RemoveItemFromQueue(targetRunners.Count - 1);
         OnRemoveFromQueueEvent(runner, new RemoveFromQueueEventArgs(targetRunners.Count - 1));
     }
     catch
     {
     }
 }
    public int[] Intersect(int[] nums1, int[] nums2)
    {
        if (nums1.Length == 0 || nums2.Length == 0)//corner case
        {
            return(new int[0]);
        }
        Dictionary <int, int> ht = new Dictionary <int, int>();

        foreach (int num in nums1) //traverse array nums1, and add each num in Dictionary
        {
            if (!ht.ContainsKey(num))
            {
                ht.Add(num, 1);
            }
            else
            {
                ht[num]++;
            }
        }
        ICollection <int> collection = new System.Collections.ObjectModel.Collection <int>();

        foreach (int num in nums2)
        {
            if (ht.ContainsKey(num))
            {
                if (--ht[num] == 0) //decrease the value by 1, and if value = 0, then remove the key
                {
                    ht.Remove(num);
                }
                collection.Add(num);
            }
        }
        return(collection.ToArray());
    }
Beispiel #3
0
        /// <summary>
        /// Saves the specified entity.
        /// </summary>
        /// <typeparam name="TEntity">The type of the entity.</typeparam>
        /// <param name="entity">The entity.</param>
        /// <param name="procedureName">Name of the procedure.</param>
        /// <returns>primary Key Value</returns>
        public static int Save <TEntity>(TEntity entity, string procedureName)
        {
            System.Collections.ObjectModel.Collection <SqlParameter> parameters = AddParameters(entity);

            /*Execute Stored Procedure*/
            object primaryKeyValue = ExecuteScalar(procedureName, parameters.ToArray());

            return(Convert.ToInt32(primaryKeyValue));
        }
Beispiel #4
0
        private CascadingDropDownNameValue[] GetValues(System.Data.DataTable table)
        {
            System.Collections.ObjectModel.Collection<CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection<CascadingDropDownNameValue>();

            foreach(System.Data.DataRow dr in table.Rows)
            {
                values.Add(new CascadingDropDownNameValue(dr["party"].ToString(), dr["party_code"].ToString()));
            }

            return values.ToArray();
        }
Beispiel #5
0
        private CascadingDropDownNameValue[] GetValues(System.Data.DataTable table)
        {
            System.Collections.ObjectModel.Collection <CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection <CascadingDropDownNameValue>();

            foreach (System.Data.DataRow dr in table.Rows)
            {
                values.Add(new CascadingDropDownNameValue(dr["party"].ToString(), dr["party_code"].ToString()));
            }

            return(values.ToArray());
        }
Beispiel #6
0
        public CascadingDropDownNameValue[] GetStockItems(string knownCategoryValues, string category)
        {
            System.Collections.ObjectModel.Collection <CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection <CascadingDropDownNameValue>();

            using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Helpers.FormHelper.GetTable("core", "items", "maintain_stock", "true"))
            {
                foreach (System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["item_name"].ToString(), dr["item_code"].ToString()));
                }

                return(values.ToArray());
            }
        }
Beispiel #7
0
        public CascadingDropDownNameValue[] GetStockItems(string knownCategoryValues, string category)
        {
            System.Collections.ObjectModel.Collection<CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection<CascadingDropDownNameValue>();

            using(System.Data.DataTable table = MixERP.Net.BusinessLayer.Helpers.FormHelper.GetTable("core", "items", "maintain_stock", "true"))
            {
                foreach(System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["item_name"].ToString(), dr["item_code"].ToString()));
                }

                return values.ToArray();
            }
        }
Beispiel #8
0
        public CascadingDropDownNameValue[] GetUnits(string knownCategoryValues, string category)
        {
            StringDictionary kv       = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string           itemCode = kv["Item"];

            System.Collections.ObjectModel.Collection <CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection <CascadingDropDownNameValue>();

            using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Core.Units.GetUnitViewByItemCode(itemCode))
            {
                foreach (System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["unit_name"].ToString(), dr["unit_id"].ToString()));
                }

                return(values.ToArray());
            }
        }
Beispiel #9
0
        public CascadingDropDownNameValue[] GetUnits(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string itemCode = kv["Item"];

            System.Collections.ObjectModel.Collection<CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection<CascadingDropDownNameValue>();

            using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Core.Units.GetUnitViewByItemCode(itemCode))
            {
                foreach (System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["unit_name"].ToString(), dr["unit_id"].ToString()));
                }

                return values.ToArray();
            }
        }
Beispiel #10
0
        public CascadingDropDownNameValue[] GetShippingAddresses(string knownCategoryValues, string category)
        {
            System.Collections.ObjectModel.Collection<CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection<CascadingDropDownNameValue>();

            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string partyCode = kv["Party"];

            using(System.Data.DataTable table = MixERP.Net.BusinessLayer.Core.ShippingAddresses.GetShippingAddressView(partyCode))
            {
                table.Columns.Add("shipping_address", typeof(string), MixERP.Net.BusinessLayer.Core.ShippingAddresses.GetDisplayField());

                foreach(System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["shipping_address_code"].ToString(), dr["shipping_address"].ToString()));
                }
            }

            return values.ToArray();
        }
Beispiel #11
0
        public CascadingDropDownNameValue[] GetShippingAddresses(string knownCategoryValues, string category)
        {
            System.Collections.ObjectModel.Collection <CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection <CascadingDropDownNameValue>();

            StringDictionary kv        = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string           partyCode = kv["Party"];

            using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Core.ShippingAddresses.GetShippingAddressView(partyCode))
            {
                table.Columns.Add("shipping_address", typeof(string), MixERP.Net.BusinessLayer.Core.ShippingAddresses.GetDisplayField());

                foreach (System.Data.DataRow dr in table.Rows)
                {
                    values.Add(new CascadingDropDownNameValue(dr["shipping_address_code"].ToString(), dr["shipping_address"].ToString()));
                }
            }

            return(values.ToArray());
        }
    public int[] Intersection(int[] nums1, int[] nums2)
    {
        //tc:O(n); sc:O(n)
        if (nums1.Length == 0 || nums2.Length == 0) //corner case
        {
            return(new int[0]);
        }
        HashSet <int>     hs         = new HashSet <int>(nums1); //initialize hashset with array nums1
        ICollection <int> collection = new System.Collections.ObjectModel.Collection <int>();

        foreach (int num in nums2)
        {
            if (hs.Remove(num)) //HashSet.Remove(T) return true if can find and remove the element, otherwise return false
            {
                collection.Add(num);
            }
        }
        return(collection.ToArray());
    }
        public CascadingDropDownNameValue[] GetCashRepositories(string knownCategoryValues, string category)
        {
            StringDictionary kv          = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string           accountCode = kv["Account"];

            System.Collections.ObjectModel.Collection <CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection <CascadingDropDownNameValue>();

            if (MixERP.Net.BusinessLayer.Core.Accounts.IsCashAccount(accountCode))
            {
                using (System.Data.DataTable table = MixERP.Net.BusinessLayer.Helpers.FormHelper.GetTable("office", "cash_repositories"))
                {
                    foreach (System.Data.DataRow dr in table.Rows)
                    {
                        values.Add(new CascadingDropDownNameValue(dr["cash_repository_name"].ToString(), dr["cash_repository_code"].ToString()));
                    }
                }
            }

            return(values.ToArray());
        }
Beispiel #14
0
        public CascadingDropDownNameValue[] GetCashRepositories(string knownCategoryValues, string category)
        {
            StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string accountCode = kv["Account"];

            System.Collections.ObjectModel.Collection<CascadingDropDownNameValue> values = new System.Collections.ObjectModel.Collection<CascadingDropDownNameValue>();

            if(MixERP.Net.BusinessLayer.Core.Accounts.IsCashAccount(accountCode))
            {
                using(System.Data.DataTable table = MixERP.Net.BusinessLayer.Helpers.FormHelper.GetTable("office", "cash_repositories"))
                {
                    foreach(System.Data.DataRow dr in table.Rows)
                    {
                        values.Add(new CascadingDropDownNameValue(dr["cash_repository_name"].ToString(), dr["cash_repository_code"].ToString()));
                    }
                }
            }

            return values.ToArray();
        }