예제 #1
0
파일: Hooks.cs 프로젝트: balu92/Fougerite
        public static float EntityDecay(object entity, float dmg)
        {
            Contract.Assume(entity != null);

            try
            {
                DecayEvent de = new DecayEvent(new Entity(entity), ref dmg);
                if (OnEntityDecay != null)
                {
                    OnEntityDecay(de);
                }

                if (decayList.Contains(entity))
                {
                    decayList.Remove(entity);
                }

                decayList.Add(entity);
                return(de.DamageAmount);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(0f);
        }
예제 #2
0
    private void BindTags()
    {
        System.Collections.Generic.List <string> col = new System.Collections.Generic.List <string>();
        foreach (Curricula cls in Curricula.Curriculas)
        {
            foreach (string tag in cls.Tags)
            {
                if (!col.Contains(tag))
                {
                    col.Add(tag);
                }
            }
        }
        foreach (Training cls in Training.Trainings)
        {
            foreach (string tag in cls.Tags)
            {
                if (!col.Contains(tag))
                {
                    col.Add(tag);
                }
            }
        }
        col.Sort(delegate(string s1, string s2) { return(String.Compare(s1, s2)); });

        foreach (string tag in col)
        {
            HtmlAnchor a = new HtmlAnchor();
            a.HRef = "javascript:void(0)";
            a.Attributes.Add("onclick", "AddTag(this)");
            a.InnerText = tag;
            phTags.Controls.Add(a);
        }
    }
예제 #3
0
        public static float EntityDecay(object entity, float dmg)
        {
            if (entity == null)
            {
                return(0f);
            }

            try
            {
                DecayEvent de = new DecayEvent(new Entity(entity), ref dmg);
                if (OnEntityDecay != null)
                {
                    OnEntityDecay(de);
                }

                if (decayList.Contains(entity))
                {
                    decayList.Remove(entity);
                }

                decayList.Add(entity);
                return(de.DamageAmount);
            }
            catch { }
            return(0f);
        }
예제 #4
0
 private void CameraPreCullWrapper(Camera camera)
 {
     if (IgnoreCameras.Contains(camera))
     {
         return;
     }
     CameraPreCull(camera);
 }
예제 #5
0
        public static void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("TankStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                if (!FlatRedBall.FlatRedBallServices.IsLoaded <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/entities/tank/animationchainlistfile.achx", ContentManagerName))
                {
                    registerUnload = true;
                }
                AnimationChainListFile = FlatRedBall.FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/entities/tank/animationchainlistfile.achx", ContentManagerName);
            }
            GreasyPlatypusSlapper.Entities.Turret.LoadStaticContent(contentManagerName);
            GreasyPlatypusSlapper.Entities.Effects.Smoke.LoadStaticContent(contentManagerName);
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("TankStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
예제 #6
0
 public static void LoadStaticContent(string contentManagerName)
 {
     if (string.IsNullOrEmpty(contentManagerName))
     {
         throw new System.ArgumentException("contentManagerName cannot be empty or null");
     }
     ContentManagerName = contentManagerName;
     #if DEBUG
     if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
     {
         HasBeenLoadedWithGlobalContentManager = true;
     }
     else if (HasBeenLoadedWithGlobalContentManager)
     {
         throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
     }
     #endif
     bool registerUnload = false;
     if (LoadedContentManagers.Contains(contentManagerName) == false)
     {
         LoadedContentManagers.Add(contentManagerName);
         lock (mLockObject)
         {
             if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
             {
                 FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PlayerStaticUnload", UnloadStaticContent);
                 mRegisteredUnloads.Add(ContentManagerName);
             }
         }
         if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/player/tiny_ship.png", ContentManagerName))
         {
             registerUnload = true;
         }
         tiny_ship = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/player/tiny_ship.png", ContentManagerName);
         if (!FlatRedBall.FlatRedBallServices.IsLoaded <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/entities/player/playeranimation.achx", ContentManagerName))
         {
             registerUnload = true;
         }
         PlayerAnimation = FlatRedBall.FlatRedBallServices.Load <FlatRedBall.Graphics.Animation.AnimationChainList>(@"content/entities/player/playeranimation.achx", ContentManagerName);
         if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/player/flame.png", ContentManagerName))
         {
             registerUnload = true;
         }
         Flame = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/player/flame.png", ContentManagerName);
     }
     if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
     {
         lock (mLockObject)
         {
             if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
             {
                 FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PlayerStaticUnload", UnloadStaticContent);
                 mRegisteredUnloads.Add(ContentManagerName);
             }
         }
     }
     CustomLoadStaticContent(contentManagerName);
 }
 public static System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics> ItemDeliveryPercentageWithCriteria(System.Collections.Generic.List <int?> supplierIds, System.Collections.Generic.List <int?> warehouseIds, System.Collections.Generic.List <int?> businessUnitIds, System.Collections.Generic.List <int?> categoryIds, System.Collections.Generic.List <int?> subCategoryIds, System.Collections.Generic.List <int?> baseUnitIds, System.Collections.Generic.List <string> SKUs, DateTime?fromDate, DateTime?toDate)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("SLADelivery", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "ItemDeliveryPercentageWithCriteria")) {
         System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics> stats = new System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics>();
         System.Collections.Generic.List <int?>   emptyIDs  = new System.Collections.Generic.List <int?>();
         System.Collections.Generic.List <string> emptySKUs = new System.Collections.Generic.List <string>();
         if ((warehouseIds == null))
         {
             warehouseIds = emptyIDs.ToList();
         }
         if ((SKUs == null))
         {
             SKUs = emptySKUs.ToList();
         }
         if ((businessUnitIds == null))
         {
             businessUnitIds = emptyIDs.ToList();
         }
         if ((categoryIds == null))
         {
             categoryIds = emptyIDs.ToList();
         }
         if ((subCategoryIds == null))
         {
             subCategoryIds = emptyIDs.ToList();
         }
         if ((baseUnitIds == null))
         {
             baseUnitIds = emptyIDs.ToList();
         }
         if ((supplierIds == null))
         {
             supplierIds = emptyIDs.ToList();
         }
         var _var0 = (fromDate?.Month ?? 0); var _var1 = (toDate?.Month ?? 0); System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLADelivery> filteredDeliveries = new DSS1_RetailerDriverStockOptimisation.DAL.Repository().Get <DSS1_RetailerDriverStockOptimisation.BO.SLADelivery>((a) => (SKUs.Count() == 0 || SKUs.Contains(a.Item.SKU)) && (businessUnitIds.Count() == 0 || businessUnitIds.Contains((a.Item.BusinessUnit.Id).GetValueOrDefault(0))) && (categoryIds.Count() == 0 || categoryIds.Contains((a.Item.Category.Id).GetValueOrDefault(0))) && (subCategoryIds.Count() == 0 || subCategoryIds.Contains((a.Item.SubCategory.Id).GetValueOrDefault(0))) && (baseUnitIds.Count() == 0 || baseUnitIds.Contains((a.Item.BaseUnit.Id).GetValueOrDefault(0))) && (supplierIds.Count() == 0 || supplierIds.Contains((a.Item.Supplier.Id).GetValueOrDefault(0))) && (warehouseIds.Count() == 0 || warehouseIds.Contains((a.Warehouse.Id).GetValueOrDefault(0))) && (fromDate == null || a.Month >= _var0) && (toDate == null || a.Month <= _var1));
         System.Collections.Generic.List <int?> uniqueMonths = filteredDeliveries?.Select((a) => a.Month).ToList().Distinct().ToList().OrderBy((a) => a).ToList();
         if (SKUs.Contains("4047706") && SKUs.Count() == 1)
         {
             zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "SLADelivery", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "Months: " + uniqueMonths.Count());
         }
         foreach (var i in uniqueMonths ?? Enumerable.Empty <int?>())
         {
             System.Collections.Generic.List <DSS1_RetailerDriverStockOptimisation.BO.SLADelivery> thisMonthsDeliveries = filteredDeliveries?.Where((a) => a.Month == i).ToList();
             if ((thisMonthsDeliveries?.Count() == 0))
             {
                 continue;
             }
             if (SKUs.Contains("4047706") && SKUs.Count() == 1)
             {
                 zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "SLADelivery", DSS1_RetailerDriverStockOptimisation.Hubs.EventsHub.RaiseDebugMessage, "thisMonthsDeliveries: " + (thisMonthsDeliveries?.Count() ?? 0));
             }
             DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics stat = new DSS1_RetailerDriverStockOptimisation.BO.SLAStatistics();
             stat.Percentage = (thisMonthsDeliveries?.Sum((a) => a.Percentage) ?? 0) / (thisMonthsDeliveries?.Count() ?? 0); stat.Percentage = Math.Round((stat?.Percentage ?? 0), 2); stat.Month = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName((i).GetValueOrDefault(0)); stat.Threshold = 80; stats?.Add(stat);
         }
         return(stats);
     }
 }
예제 #8
0
        public void RemoveRecord(System.Collections.Generic.List <int> DelList, DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (DelList == null || DelList.Count == 0)
            {
                return;
            }
            if (Default_sql != null)
            {
                object busisData = null;
                YueMES.Base.Dal.DTO.TryGetCache(Default_sql, DBNo, out busisData);
                Sys_Role_Users busis = (Sys_Role_Users)busisData;

                base.addThreadInfo(DBNo);
                List <DataRow> lst = null;
                if (DAO.Default.dataBaseType == DataBaseType.Oracle)
                {
                    lst = (from a in busis.AsEnumerable()
                           join c in Sys_Roles.Default.AsEnumerable()
                           on a.Field <Int64>("MID") equals c.Field <Int64>("ID")
                           where DelList.Contains(Convert.ToInt32(a.Field <Int64>("ID")))
                           select c).ToList();
                }
                else
                {
                    lst = (from a in busis.AsEnumerable()
                           join c in Sys_Roles.Default.AsEnumerable()
                           on a.Field <int>("MID") equals c.Field <int>("ID")
                           where DelList.Contains(a.Field <int>("ID"))
                           select c).ToList();
                }
                if (lst != null && lst.Count > 0)
                {
                    foreach (DataRow row in lst)
                    {
                        Sys_Role role = Sys_Roles.GetItem(Convert.ToInt32(row["ID"]));
                        if (role != null)
                        {
                            role.ResetRoleUsers();
                        }
                    }
                }
                lock (_lock)
                {
                    foreach (var id in DelList)
                    {
                        DataRow[] drs = busis.Select(string.Format("ID={0}", id));
                        if (drs.Length == 0)
                        {
                            continue;
                        }
                        busis.Rows.Remove(drs[0]);
                    }
                    busis.AcceptChanges();
                }
            }
        }
예제 #9
0
        public static void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.CoreUIs;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BulletStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/spaceinvaders/bullet/shells.png", ContentManagerName))
                {
                    registerUnload = true;
                }
                shells = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/spaceinvaders/bullet/shells.png", ContentManagerName);
            }
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BulletStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
예제 #10
0
        public List <Mode> GetAllOptions(string[] args)
        {
            System.Collections.Generic.List <Mode> lstmode = new System.Collections.Generic.List <Mode>();
            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i];

                if (arg == "-m" || arg == "-mode")
                {
                    string mode = args[i + 1];
                    if (mode != null)
                    {
                        string[] modes = mode.Split(',');
                        foreach (string m in modes)
                        {
                            switch (m.Trim().ToLower())
                            {
                            case "blockedlists":
                                if (!lstmode.Contains(Mode.BlockedLists))
                                {
                                    lstmode.Add(Mode.BlockedLists);
                                }
                                break;

                            case "blockedpages":
                                if (!lstmode.Contains(Mode.BlockedPages))
                                {
                                    lstmode.Add(Mode.BlockedPages);
                                }
                                break;

                            case "ignoredcustomizations":
                                if (!lstmode.Contains(Mode.IgnoredCustomizations))
                                {
                                    lstmode.Add(Mode.IgnoredCustomizations);
                                }
                                break;

                            default:
                                if (!lstmode.Contains(Mode.Scan))
                                {
                                    lstmode.Add(Mode.Scan);
                                }
                                break;
                            }
                        }

                        return(lstmode);
                    }
                }
            }

            lstmode.Add(Mode.Scan);

            return(lstmode);
        }
예제 #11
0
 public static decimal?CalculatePathCost(this BO.Shipment @this, System.Collections.Generic.List <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder> Orders)
 {
     using (new zAppDev.DotNet.Framework.Profiling.Profiler("Shipment", zAppDev.DotNet.Framework.Profiling.AppDevSymbolType.ClassOperation, "CalculatePathCost")) {
         System.Collections.Generic.List <string> coordinates = new System.Collections.Generic.List <string>();
         coordinates.Add((@this?.DeparturePoint?.Coordinates?.CoordinateY ?? 0) + "," + (@this?.DeparturePoint?.Coordinates?.CoordinateX ?? 0));
         zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Error, "Shipment", DSS3_LogisticsPoolingForUrbanDistribution.Hubs.EventsHub.RaiseDebugMessage, coordinates.FirstOrDefault());
         foreach (var i in Orders ?? Enumerable.Empty <DSS3_LogisticsPoolingForUrbanDistribution.BO.ShippingOrder>())
         {
             string departure = (i?.DeparturePoint?.Coordinates?.CoordinateY ?? 0) + "," + (i?.DeparturePoint?.Coordinates?.CoordinateX ?? 0);
             string arrival   = (i?.ArrivalPoint?.Coordinates?.CoordinateY ?? 0) + "," + (i?.ArrivalPoint?.Coordinates?.CoordinateX ?? 0);
             if ((((coordinates.Contains(departure)) == false) && i?.DeparturePoint != @this?.FinalDestination))
             {
                 coordinates.Add(departure);
             }
             if ((((coordinates.Contains(arrival)) == false) && i?.ArrivalPoint != @this?.FinalDestination))
             {
                 coordinates.Add(arrival);
             }
         }
         string FinalCoordinate = (@this?.FinalDestination?.Coordinates?.CoordinateY ?? 0) + "," + (@this?.FinalDestination?.Coordinates?.CoordinateX ?? 0);
         coordinates.Add(FinalCoordinate);
         while ((coordinates.Contains("0,0")))
         {
             coordinates.Remove("0,0");
         }
         string coord = "";
         foreach (var i in coordinates ?? Enumerable.Empty <string>())
         {
             if (coord == "")
             {
                 coord = coord + i;
             }
             else
             {
                 coord = coord + "," + i;
             }
         }
         DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot response = DSS3_LogisticsPoolingForUrbanDistribution.BLL.ExternalRestServices.Router_MapotempoRestService.route("time", "true", "true", "true", "200", "EUR", "en", coord, "inlecom-1-pe3io4Ui5aimobich1oot0eilothongo");
         zAppDev.DotNet.Framework.Utilities.Serializer <DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot> serializer = new zAppDev.DotNet.Framework.Utilities.Serializer <DSS3_LogisticsPoolingForUrbanDistribution.ExternalStructs.Router_Mapotempo.Router_MapotempoRoot>();
         zAppDev.DotNet.Framework.Utilities.DebugHelper.Log(zAppDev.DotNet.Framework.Utilities.DebugMessageType.Info, "Shipment", DSS3_LogisticsPoolingForUrbanDistribution.Hubs.EventsHub.RaiseDebugMessage, serializer.ToJson(response));
         decimal?time         = (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(response.features, 0)).properties.router.total_time / 3600;
         decimal?distance     = (zAppDev.DotNet.Framework.Utilities.Common.GetItemFromArray(response.features, 0)).properties.router.total_distance / 1000;
         decimal?DistanceCost = distance.GetValueOrDefault(0) * (@this?.VehiculeType?.CalculatedDistanceCost ?? 0);
         decimal?TimeCost     = time.GetValueOrDefault(0) * (@this?.VehiculeType?.CalculatedTimeCost ?? 0);
         decimal?TotalCost    = new decimal?();
         if (@this?.VehiculeType?.AmortizationType1?.Label == "technical")
         {
             TotalCost = TimeCost.GetValueOrDefault(0) + DistanceCost.GetValueOrDefault(0) + (@this?.VehiculeType?.CalculatedOwnershipCost ?? 0) * distance.GetValueOrDefault(0);
         }
         else
         {
             TotalCost = TimeCost.GetValueOrDefault(0) + DistanceCost.GetValueOrDefault(0) + (@this?.VehiculeType?.CalculatedOwnershipCost ?? 0) * time.GetValueOrDefault(0);
         }
         TotalCost = TotalCost.GetValueOrDefault(0) * (1 + (@this?.VehiculeType?.OverHeadCost ?? 0) / 100); return(TotalCost);
     }
 }
예제 #12
0
 private System.Data.DataTable ConvertListToDataTable <T>(System.Collections.Generic.IList <T> list, params string[] propertyName)
 {
     System.Collections.Generic.List <string> list2 = new System.Collections.Generic.List <string>();
     if (propertyName != null)
     {
         list2.AddRange(propertyName);
     }
     System.Data.DataTable dataTable = new System.Data.DataTable();
     if (list.Count > 0)
     {
         T t = list[0];
         System.Reflection.PropertyInfo[] properties = t.GetType().GetProperties();
         System.Reflection.PropertyInfo[] array      = properties;
         for (int i = 0; i < array.Length; i++)
         {
             System.Reflection.PropertyInfo propertyInfo = array[i];
             if (list2.Count == 0)
             {
                 dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
             }
             else
             {
                 if (list2.Contains(propertyInfo.Name))
                 {
                     dataTable.Columns.Add(propertyInfo.Name, propertyInfo.PropertyType);
                 }
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             System.Collections.ArrayList     arrayList = new System.Collections.ArrayList();
             System.Reflection.PropertyInfo[] array2    = properties;
             for (int k = 0; k < array2.Length; k++)
             {
                 System.Reflection.PropertyInfo propertyInfo2 = array2[k];
                 if (list2.Count == 0)
                 {
                     object value = propertyInfo2.GetValue(list[j], null);
                     arrayList.Add(value);
                 }
                 else
                 {
                     if (list2.Contains(propertyInfo2.Name))
                     {
                         object value2 = propertyInfo2.GetValue(list[j], null);
                         arrayList.Add(value2);
                     }
                 }
             }
             object[] values = arrayList.ToArray();
             dataTable.LoadDataRow(values, true);
         }
     }
     return(dataTable);
 }
        public static new void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            AbbatoirIntergrade.Entities.BaseEntities.BaseStructure.LoadStaticContent(contentManagerName);
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PiercingTowerStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
                PiercingShot1 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot1", ContentManagerName);
                PiercingShot2 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot2", ContentManagerName);
                PiercingShot3 = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Audio.SoundEffect>(@"content/entities/structures/piercingtower/piercingshot3", ContentManagerName);
            }
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("PiercingTowerStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
예제 #14
0
 public static void AddZone(NoPlacementZone zone)
 {
     if (_zones == null)
     {
         _zones = new System.Collections.Generic.List <NoPlacementZone>();
     }
     if (!_zones.Contains(zone))
     {
         _zones.Add(zone);
     }
 }
예제 #15
0
    private string GetContractLimitsByContractTypeAndPrj(string contractTypeID, string prjId)
    {
        System.Collections.Generic.List <string> UserCodes = new System.Collections.Generic.List <string>();
        System.Collections.Generic.List <string> ztbUsers  = (System.Collections.Generic.List <string>) new PTPrjInfoZTBUserService().GetUser(prjId);
        System.Collections.Generic.List <string> userCodesByIDThroughPrjProperty = new PTPrjInfoZTBDetailService().getUserCodesByIDThroughPrjProperty(prjId);
        System.Collections.Generic.List <string> userCode2 = new PrivBusiDataRoleService().GetUserCode(prjId);
        ConContractType byID = new ConContractTypeService().GetByID(contractTypeID);

        System.Collections.Generic.List <string> ContractTypeUsers = JsonHelper.GetListFromJson(byID.UserCodes);
        userCodesByIDThroughPrjProperty.ForEach(delegate(string userCode)
        {
            if (!ztbUsers.Contains(userCode))
            {
                ztbUsers.Add(userCode);
            }
        });
        userCode2.ForEach(delegate(string userCode)
        {
            if (!ztbUsers.Contains(userCode))
            {
                ztbUsers.Add(userCode);
            }
        });
        if (ztbUsers.Count >= ContractTypeUsers.Count)
        {
            ContractTypeUsers.ForEach(delegate(string userCode)
            {
                if (ztbUsers.Contains(userCode))
                {
                    UserCodes.Add(userCode);
                }
            });
        }
        else
        {
            ztbUsers.ForEach(delegate(string userCode)
            {
                if (ContractTypeUsers.Contains(userCode))
                {
                    UserCodes.Add(userCode);
                }
            });
        }
        if (!UserCodes.Contains("00000000"))
        {
            UserCodes.Add("00000000");
        }
        if (!UserCodes.Contains(base.UserCode))
        {
            UserCodes.Add(base.UserCode);
        }
        return(JsonHelper.Serialize(UserCodes.ToArray()));
    }
        public static void LoadStaticContent(string contentManagerName)
        {
            if (string.IsNullOrEmpty(contentManagerName))
            {
                throw new System.ArgumentException("contentManagerName cannot be empty or null");
            }
            ContentManagerName = contentManagerName;
            // Set the content manager for Gum
            var contentManagerWrapper = new FlatRedBall.Gum.ContentManagerWrapper();

            contentManagerWrapper.ContentManagerName = contentManagerName;
            RenderingLibrary.Content.LoaderManager.Self.ContentLoader = contentManagerWrapper;
            // Access the GumProject just in case it's async loaded
            var throwaway = GlobalContent.GumProject;

            #if DEBUG
            if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                HasBeenLoadedWithGlobalContentManager = true;
            }
            else if (HasBeenLoadedWithGlobalContentManager)
            {
                throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
            }
            #endif
            bool registerUnload = false;
            if (LoadedContentManagers.Contains(contentManagerName) == false)
            {
                LoadedContentManagers.Add(contentManagerName);
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("TileCollisionRectangleStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
            {
                lock (mLockObject)
                {
                    if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
                    {
                        FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("TileCollisionRectangleStaticUnload", UnloadStaticContent);
                        mRegisteredUnloads.Add(ContentManagerName);
                    }
                }
            }
            CustomLoadStaticContent(contentManagerName);
        }
예제 #17
0
    private string GetContractLimits(string ContractTypeId)
    {
        System.Collections.Generic.List <string> userCodes = new System.Collections.Generic.List <string>();
        userCodes.Add(base.UserCode);
        if (base.UserCode != "00000000")
        {
            userCodes.Add("00000000");
        }
        ContractType      contractType = new ContractType();
        ContractTypeModel model        = contractType.GetModel(ContractTypeId);

        if (model != null)
        {
            System.Collections.Generic.List <string> listFromJson = JsonHelper.GetListFromJson(model.UserCodes);
            listFromJson.ForEach(delegate(string userCode)
            {
                if (!userCodes.Contains(userCode))
                {
                    userCodes.Add(userCode);
                }
            });
        }
        string text = this.hdnProjectCode.Value.Trim();

        System.Collections.Generic.List <string> list = (System.Collections.Generic.List <string>) new PTPrjInfoZTBUserService().GetUser(text);
        list.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        System.Collections.Generic.List <string> userCodesByIDThroughPrjProperty = new PTPrjInfoZTBDetailService().getUserCodesByIDThroughPrjProperty(text);
        System.Collections.Generic.List <string> userCode2 = new PrivBusiDataRoleService().GetUserCode(text);
        userCodesByIDThroughPrjProperty.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        userCode2.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        return(JsonHelper.Serialize(userCodes.ToArray()));
    }
예제 #18
0
        /// <summary>
        /// Processes the modes passed via commandline into a list of modes
        /// </summary>
        /// <param name="args">Commandline arguments</param>
        /// <returns>List of passed scan modes</returns>
        public List <Mode> GetAllOptions(string[] args)
        {
            System.Collections.Generic.List <Mode> lstmode = new System.Collections.Generic.List <Mode>();
            for (int i = 0; i < args.Length; i++)
            {
                string arg = args[i].ToLower();

                if (arg == "-m" || arg == "--mode")
                {
                    string mode = args[i + 1];
                    if (mode != null)
                    {
                        string[] modes = mode.Split(',');
                        foreach (string m in modes)
                        {
                            switch (m.Trim().ToLower())
                            {
                            case "mode2":
                                if (!lstmode.Contains(Mode.Mode2))
                                {
                                    lstmode.Add(Mode.Mode2);
                                }
                                break;

                            case "mode3":
                                if (!lstmode.Contains(Mode.Mode3))
                                {
                                    lstmode.Add(Mode.Mode3);
                                }
                                break;

                            default:
                                if (!lstmode.Contains(Mode.DefaultMode))
                                {
                                    lstmode.Add(Mode.DefaultMode);
                                }
                                break;
                            }
                        }

                        return(lstmode);
                    }
                }
            }

            lstmode.Add(Mode.DefaultMode);

            return(lstmode);
        }
예제 #19
0
 public static void Add(string ipAddress)
 {
     if (!list_0.Contains(ipAddress))
     {
         list_0.Add(ipAddress);
     }
     if (Core.DatabaseType.Equals("MYSQL"))
     {
         MySQL.Update(string.Format("REPLACE INTO `db_blocked_ip` (`ip_address`) VALUES ('{0}');", ipAddress));
     }
     if (Core.DatabaseType.Equals("FILE"))
     {
         SaveAsTextFile();
     }
 }
예제 #20
0
 /// <summary>
 /// Event: Occurs when a directory is found while searching for the given wildcard.
 /// The directory is polled to be searched if necessary.
 /// </summary>
 /// <param name="o"></param>
 /// <param name="e"></param>
 private void DirectoryFound(object o, HashEventArgs e)
 {
     lock (Poll)
     {
         //System.Console.WriteLine("{0}, was found and appended to queue", e.Task);
         if (!CompletedDirs.Contains(e.Task.ToLower()) && !Poll.Contains(e.Task.ToLower()) && !Exclude(e.Task))
         {
             ManualResetEvent mre = new ManualResetEvent(false);
             tmpEvents.Add(mre);
             Task task = new Task((TaskItem)o, wildcards, SearchBrain.List.MaxPerFolder, mre);
             task.IsSubDir = true;
             Poll.Add(task);
         }
     }
 }
        public System.Collections.Generic.List <int> arDictDupSecondary = new System.Collections.Generic.List <int>(); // only needed for 2 AR bands
        private void Data3_AfterData(object sender, EventArgs e)
        {
            int currentARTransactionId = (int)Report.GetColumnValue("ARTransactions.ARTransactionId");

            if (arDict.Contains(currentARTransactionId))
            {
                arDictDup.Add(currentARTransactionId);
                arDictDupSecondary.Add(currentARTransactionId);
            }
            else
            {
                arDict.Add(currentARTransactionId);
                arDictSecondary.Add(currentARTransactionId);
            }
        }
예제 #22
0
 public static void LoadStaticContent(string contentManagerName)
 {
     if (string.IsNullOrEmpty(contentManagerName))
     {
         throw new System.ArgumentException("contentManagerName cannot be empty or null");
     }
     ContentManagerName = contentManagerName;
     #if DEBUG
     if (contentManagerName == FlatRedBall.FlatRedBallServices.GlobalContentManager)
     {
         HasBeenLoadedWithGlobalContentManager = true;
     }
     else if (HasBeenLoadedWithGlobalContentManager)
     {
         throw new System.Exception("This type has been loaded with a Global content manager, then loaded with a non-global.  This can lead to a lot of bugs");
     }
     #endif
     bool registerUnload = false;
     if (LoadedContentManagers.Contains(contentManagerName) == false)
     {
         LoadedContentManagers.Add(contentManagerName);
         lock (mLockObject)
         {
             if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
             {
                 FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("MenuButtonExitStaticUnload", UnloadStaticContent);
                 mRegisteredUnloads.Add(ContentManagerName);
             }
         }
         if (!FlatRedBall.FlatRedBallServices.IsLoaded <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/menubuttonexit/gamebuttonsforguifree.png", ContentManagerName))
         {
             registerUnload = true;
         }
         GameButtonsForGUIFREE = FlatRedBall.FlatRedBallServices.Load <Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/menubuttonexit/gamebuttonsforguifree.png", ContentManagerName);
     }
     if (registerUnload && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
     {
         lock (mLockObject)
         {
             if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBall.FlatRedBallServices.GlobalContentManager)
             {
                 FlatRedBall.FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("MenuButtonExitStaticUnload", UnloadStaticContent);
                 mRegisteredUnloads.Add(ContentManagerName);
             }
         }
     }
     CustomLoadStaticContent(contentManagerName);
 }
예제 #23
0
 /// <summary>
 /// 监控文件是否完成下载的方法
 /// </summary>
 public void hebinfile()
 {
     //在新线程中执行
     System.Threading.Thread th2 = new System.Threading.Thread(
         //使用匿名方法
         delegate()
     {
         //每隔一秒,检测是否所有线程都完成了下载任务
         while (true)
         {
             //如果所有线程都完成了下载任务
             if (!lbo.Contains(false))
             {
                 //开始合并文件
                 GetFile();
                 //停上检测线程
                 break;
             }
             else
             {
                 if (this.stop2)
                 {
                     DeleteFile();
                 }
             }
             //线程挂起1秒
             Thread.Sleep(1000);
         }
     });
     //此线程是后台线程
     th2.IsBackground = true;
     //线程开始
     th2.Start();
 }
예제 #24
0
 public void AddListener(EntityGameEventListener param0)
 {
     if (!_listeners.Contains(param0))
     {
         _listeners.Add(param0);
     }
 }
예제 #25
0
        internal bool TryValidateObject(ValidationContext validationContext, List <ValidationResult> validationResults, System.Collections.Generic.List <string> PropertiesToValidate)
        {
            var properties = TypeDescriptor.GetProperties(this);

            bool isValid = true;

            foreach (PropertyDescriptor prop in properties)
            {
                if (PropertiesToValidate != null && !PropertiesToValidate.Contains(prop.Name))
                {
                    continue;
                }

                object value = this.GetValue(prop);
                var    attrs = prop.Attributes.OfType <ValidationAttribute>();

                validationContext.MemberName  = prop.Name;
                validationContext.DisplayName = prop.DisplayName;

                bool _valid = Validator.TryValidateValue(value, validationContext, validationResults, attrs);
                isValid &= _valid;

                //Console.WriteLine($"Validate: {prop.Name} value: {value} attrs:{attrs?.Count()} valid={_valid}");
            }

            //var custom = this._parent as IValidatableObject;
            //if (custom != null)
            //    custom.Validate(validationContext);

            return(isValid);
        }
예제 #26
0
        private void cargar_combobox_horarios()
        {
            ConexionSQL conn  = new ConexionSQL();
            string      query = string.Format("SELECT CAST(hora_inicio AS TIME(0)), CAST(hora_fin AS TIME(0))");

            query += string.Format(" FROM PROYECTO_W.RangoHorario JOIN PROYECTO_W.AgendaProfesional ON hora_agen_cod = agen_cod");
            query += string.Format(" WHERE CAST(hora_fecha AS DATE) = '{0}' AND agen_prof_cod = {1}", fecha, prof_cod);
            query += string.Format(" ORDER BY hora_inicio");
            DataRowCollection filas_rango_horario = conn.ejecutarQuery(query).Rows;

            foreach (DataRow fila in filas_rango_horario)
            {
                string time_ini       = fila[0].ToString();
                string time_fin       = fila[1].ToString();
                string min_ini_string = Convert.ToString(time_ini[3]);
                min_ini_string += Convert.ToString(time_ini[4]);
                int    minutos         = Convert.ToInt32(min_ini_string);
                string hora_ini_string = Convert.ToString(time_ini[0]);
                hora_ini_string += Convert.ToString(time_ini[1]);
                int hora = Convert.ToInt32(hora_ini_string);

                TimeSpan count_time = new TimeSpan(hora, minutos, 00);
                while (CompareStringAscii(count_time.ToString(), time_fin))
                {
                    if (!col_horarios_turnos.Contains(count_time.ToString()))
                    {
                        cbTurnos.Items.Add(count_time.ToString());
                    }
                    minutos   += 30;
                    count_time = new TimeSpan(hora, minutos, 00);
                }
            }
        }
예제 #27
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            System.Collections.Specialized.StringDictionary dic = new System.Collections.Specialized.StringDictionary();
            System.Collections.Generic.List <string>        col = new System.Collections.Generic.List <string>();

            foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
            {
                RegionInfo ri = new RegionInfo(ci.LCID);
                if (!dic.ContainsKey(ri.EnglishName))
                {
                    dic.Add(ri.EnglishName, ri.TwoLetterISORegionName.ToLowerInvariant());
                }

                if (!col.Contains(ri.EnglishName))
                {
                    col.Add(ri.EnglishName);
                }
            }

            col.Sort();

            this.Items.Add(new ListItem("[Not specified]", ""));
            foreach (string key in col)
            {
                this.Items.Add(new ListItem(key, dic[key]));
            }
        }
예제 #28
0
 /// <summary>
 /// If it isn't already present, add a sequence id to the list
 /// </summary>
 private static void AddSequenceIdToList(ulong id)
 {
     if (!sequenceIds.Contains(id))
     {
         sequenceIds.Add(id);
     }
 }
예제 #29
0
        /// <summary>
        /// Property helper for Files &amp; WordFiles, ensures the data retrieved
        /// from those two properties is 'in sync'
        /// </summary>
        private void PrepareForSerialization()
        {
            if (_SerializePreparationDone)
            {
                return;
            }

            _FileList      = new List <File>();
            _WordfileArray = new CatalogWordFile[_Index.Count];
            Word[] wordArray = new Word[_Index.Count];
            _Index.Values.CopyTo(wordArray, 0);

            // go through all the words
            for (int i = 0; i < wordArray.Length; i++)
            {
                // first, add all files to the 'flist' collection
                foreach (File f in wordArray[i].Files)
                {
                    if (!_FileList.Contains(f))
                    {
                        _FileList.Add(f);
                    }
                }
                // now go through again and use the indexes
                CatalogWordFile wf = new CatalogWordFile();
                wf.Text = wordArray[i].Text;
                foreach (File f in wordArray[i].Files)
                {
                    wf.FileIds.Add(_FileList.IndexOf(f));
                }
                _WordfileArray[i] = wf;
            }
            _SerializePreparationDone = true;
        }
예제 #30
0
        static int _m_Contains(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Collections.Generic.List <string> gen_to_be_invoked = (System.Collections.Generic.List <string>)translator.FastGetCSObj(L, 1);



                {
                    string _item = LuaAPI.lua_tostring(L, 2);

                    bool gen_ret = gen_to_be_invoked.Contains(
                        _item);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
예제 #31
0
    public List<int> GetReworkedMatches()
    {
        List<int> answer = new List<int>();

        var currCopy = CurrentPositions.GetRange(0, CurrentPositions.Count);
        var startMatchesCopy = new System.Collections.Generic.List<int>();
        foreach (var item in StartMatches)
        {
            startMatchesCopy.Add(item);
        };
        foreach (var item in currCopy)
        {
            if (!startMatchesCopy.Contains(item))
                answer.Add(item);
        }
        return answer;
    }
예제 #32
0
 private string VerifyParentLinks()
 {
     System.Collections.Generic.List<long> list = new System.Collections.Generic.List<long> {
         base.Id
     };
     Organization parent = this.Parent;
     while (parent != null)
     {
         if (list.Contains(parent.Id))
         {
             return ("Циклическая ссылка в иерархии организаций. Проверьте правильность указания старшей организации." + System.Environment.get_NewLine());
         }
         list.Add(parent.Id);
         parent = parent.Parent;
         if (parent == Organization.Null)
         {
             break;
         }
     }
     return string.Empty;
 }
예제 #33
0
    // CALL THIS EVERY TIME A UNIT GETS A NEW TURN
    public static void GenerateMovementTree(UnitActions mover)
    {
        System.Collections.Generic.List<Tile> all = new System.Collections.Generic.List<Tile>();
        //optimization
        int mx = (int)mover.gridPosition.x;
        int my = (int)mover.gridPosition.y;
        int mxmin = mx - mover.MovementTiles;
        int mxmax = mx + mover.MovementTiles;
        int mymin = my - mover.MovementTiles;
        int mymax = my + mover.MovementTiles;
        if (mxmin < 0)
            mxmin = 0;
        if (mxmax >= GameManager.MapWidth)
            mxmax = GameManager.MapWidth - 1;
        if (mymin < 0)
            mymin = 0;
        if (mymax >= GameManager.MapHeight)
            mymax = GameManager.MapHeight - 1;
        Tile temp = GetTileFromPlayer(mover);
        for (int i = mxmin; i <= mxmax; ++i)
        {
            for (int j = mymin; j <= mymax; ++j)
            {
                if (GetDistance(temp, GameManager.map[i][j]) < mover.MovementTiles + 1)
                    if (true) //TODO replace this with a check to see if the mover can walk on map[i][j]
                        all.Add(GameManager.map[i][j]);
            }
        }
        //TODO This will need to be tweaked if we allow movement through allied units
        //if allied movement is desired, this foreach can be removed to allow it, but you'll need to manually remove player location tiles
        // from the output of getmovement or they'll be able to walk into each other
        //uncomment this to make it so that allied units block player movement
        /*foreach (Player p in GameManager.currentTeam.myRoster)
        {
            temp = GetTileFromPlayer(p);
            if (all.Contains(temp))
                all.Remove(temp);
        }*/
        foreach (UnitActions p in GameManager.enemyTeam.myRoster)
        {
            temp = GetTileFromPlayer(p);
            if (all.Contains(temp))
                all.Remove(temp);
        }

        //Dijkstra's Algorithm
        Dictionary<Tile, int> weights = new Dictionary<Tile, int>();
        List<Tile> unvisited = new List<Tile>();
        Dictionary<Tile, Tile> nextParent = new Dictionary<Tile, Tile>();
        foreach (Tile t in all)
        {
            weights.Add(t, Infinity);
            unvisited.Add(t);
        }
        temp = GetTileFromPlayer(mover);
        weights[temp] = 0;
        unvisited.Remove(temp);
        CurrentMovementTree.Clear();
        CurrentMovementTree.Value = temp;
        while (unvisited.Count > 0)
        {
            List<Tile> uvn = GetUnvisitedNeighbors(unvisited, temp);
            int dist;
            foreach (Tile t in uvn)
            {
                float jdist = t.elevation - temp.elevation;
                if (jdist < 0)
                    jdist *= -1;
                if (t.isAccessible && jdist <= mover.MovementJump)
                    dist = t.MoveCost + weights[temp];
                else
                    dist = Infinity;
                if (dist < weights[t])
                {
                    weights[t] = dist;
                    if (nextParent.ContainsKey(t))
                        nextParent[t] = temp;
                    else
                        nextParent.Add(t, temp);
                }
            }
            if (unvisited.Count > 0)
            {
                temp = unvisited[0];
                foreach (Tile t in weights.Keys)
                {
                    if (unvisited.Contains(t) && weights[t] < weights[temp])
                        temp = t;
                }
            }
            unvisited.Remove(temp);
        }
        Queue<Tile> distancecheck = new Queue<Tile>();
        foreach (Tile t in nextParent.Keys)
        {
            distancecheck.Enqueue(t);
        }
        Queue<Tile> Remove = new Queue<Tile>();
        while (distancecheck.Count > 0)
        {
            if (weights[distancecheck.Peek()] > mover.MovementTiles)
                Remove.Enqueue(distancecheck.Dequeue());
            else
                distancecheck.Dequeue();
        }
        while (Remove.Count > 0)
            nextParent.Remove(Remove.Dequeue());
        RecursiveBuildTileTree(nextParent, CurrentMovementTree);
    }
		public GXScheduleEditorDlg(GXSchedule scheduleItem, GXDeviceList deviceList)
		{
			InitializeComponent();
			try
			{
				if (scheduleItem == null)
				{
					scheduleItem = new GXSchedule();
					scheduleItem.ScheduleStartTime = DateTime.Now;
					scheduleItem.ScheduleEndTime = DateTime.MaxValue;
					scheduleItem.TransactionStartTime = DateTime.MinValue;
                    scheduleItem.TransactionEndTime = DateTime.MaxValue;
				}
				m_DeviceList = deviceList;
				m_ScheduleItem = scheduleItem;
				if (System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek == DayOfWeek.Sunday)
				{
					Point TmpLoc = new Point(DaySunCb.Location.X, DaySunCb.Location.Y);
					DaySunCb.Location = DayMonCb.Location;
					DayMonCb.Location = DayTueCb.Location;
					DayTueCb.Location = DayWedCb.Location;
					DayWedCb.Location = DayThuCb.Location;
					DayThuCb.Location = DayFriCb.Location;
					DayFriCb.Location = DaySatCb.Location;
					DaySatCb.Location = TmpLoc;
				}
				FillEnums();                
				UpdateResouces();				

				NameTb.Text = m_ScheduleItem.Name;
                if (m_ScheduleItem.TransactionStartTime != DateTime.MinValue)
                {
                    TransactionStartTimeTp.Value = m_ScheduleItem.TransactionStartTime;
                }
                else
                {
                    TransactionStartTimeTp.Checked = false;
                }
                if (m_ScheduleItem.TransactionEndTime != DateTime.MaxValue)
                {
                    TransactionEndTimeTp.Value = m_ScheduleItem.TransactionEndTime;
                }
                //Has to be done to uncheck, known issue in .NET
				TransactionEndTimeTp.Checked = true; //Has to be done to uncheck, known issue in .NET
				TransactionEndTimeTp.Checked = m_ScheduleItem.TransactionEndTime != DateTime.MaxValue;

                if (m_ScheduleItem.TransactionEndTime != DateTime.MaxValue)
                {
                    TransactionEndTimeTp.Value = m_ScheduleItem.TransactionEndTime;
                }
                if (m_ScheduleItem.TransactionCount == 0)
				{
					TransactionCountCb.Checked = false;
					TransactionCountTb.Text = "";
				}
				else
				{
					TransactionCountCb.Checked = true;
					TransactionCountTb.Text = m_ScheduleItem.TransactionCount.ToString();
				}
				UpdateFrequencyTp.Value = new DateTime(((long)m_ScheduleItem.UpdateInterval) * 10000000 + UpdateFrequencyTp.MinDate.Ticks);
				RepeatModeCb.SelectedItem = ScheduleRepeatToString(m_ScheduleItem.RepeatMode);
				DayOfMonthTb.Text = m_ScheduleItem.DayOfMonth.ToString();
				IntervalTb.Text = m_ScheduleItem.Interval.ToString();
				ActionCb.SelectedItem = ScheduleActionToString(m_ScheduleItem.Action);
                if (m_ScheduleItem.ScheduleStartTime != DateTime.MinValue)
                {
                    ScheduleStartDateTp.Value = m_ScheduleItem.ScheduleStartTime;
                }
                if (m_ScheduleItem.ScheduleEndTime != DateTime.MaxValue)
                {
                    ScheduleEndDateTp.Value = m_ScheduleItem.ScheduleEndTime;
                }
                ScheduleEndDateTp.Checked = true; //Has to be done to uncheck, known issue in .NET
                ScheduleEndDateTp.Checked = m_ScheduleItem.ScheduleEndTime != DateTime.MaxValue;
				UpdateTargetCheckTree();

				ErrorWaitTimeTp.Value = new DateTime(ErrorWaitTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.FailWaitTime) * 10000);
				//ErrorWaitTimeTp.Value. = m_ScheduleItem.FailWaitTime/1000.0;
				ErrorTryCountTb.Text = m_ScheduleItem.FailTryCount.ToString();
				ConnectionDelayTimeTp.Value = new DateTime(ConnectionDelayTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.ConnectionDelayTime) * 10000);
				MaxThreadCountTb.Text = m_ScheduleItem.MaxThreadCount.ToString();
				//ConnectionFailWaitTimeTb.Text = Convert.ToString(m_ScheduleItem.ConnectionFailWaitTime/1000.0);
				ConnectionFailWaitTimeTp.Value = new DateTime(ConnectionFailWaitTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.ConnectionFailWaitTime) * 10000);
				ConnectionFailTryCountTb.Text = m_ScheduleItem.ConnectionFailTryCount.ToString();

                if (m_ScheduleItem.DayOfWeeks == null)
                {
                    DayMonCb.Checked = DayTueCb.Checked = DayWedCb.Checked = DayThuCb.Checked = DayFriCb.Checked = DaySatCb.Checked = DaySunCb.Checked = false;
                }
                else
                {
                    System.Collections.Generic.List<DayOfWeek> list = new System.Collections.Generic.List<DayOfWeek>();
                    list.AddRange(m_ScheduleItem.DayOfWeeks);
                    DayMonCb.Checked = list.Contains(DayOfWeek.Monday);
                    DayTueCb.Checked = list.Contains(DayOfWeek.Tuesday);
                    DayWedCb.Checked = list.Contains(DayOfWeek.Wednesday);
                    DayThuCb.Checked = list.Contains(DayOfWeek.Thursday);
                    DayFriCb.Checked = list.Contains(DayOfWeek.Friday);
                    DaySatCb.Checked = list.Contains(DayOfWeek.Saturday);
                    DaySunCb.Checked = list.Contains(DayOfWeek.Sunday);
                }
                OKBtn.Enabled = (m_ScheduleItem.Status & ScheduleState.Run) == 0;
			}
			catch (Exception Ex)
			{
				GXCommon.ShowError(this, Ex);
			}
		}
예제 #35
0
    private int getNearestNode( Vector3 pos, params int[] excludeNodes )
    {
        var excludeNodesList = new System.Collections.Generic.List<int>( excludeNodes );
        var bestDistance = float.MaxValue;
        var index = -1;

        var distance = float.MaxValue;
        for( var i = _target.nodes.Count - 1; i >= 0; i-- )
        {
            if( excludeNodesList.Contains( i ) )
                continue;

            distance = Vector3.Distance( pos, _target.nodes[i] );
            if( distance < bestDistance )
            {
                bestDistance = distance;
                index = i;
            }
        }
        return index;
    }
예제 #36
0
 private static bool IsRejected(AIS.SN.Model.DomainObjects.Views.ExchangeRequestAddress snAddress)
 {
     if (snAddress.Residents.get_Count() != 0)
     {
         string reason = snAddress.Residents.get_Item(0).Reason;
         string valueByName = Setting.GetValueByName("Глобальные установки", "Критерии получения изменений из ПС");
         if (valueByName == Setting.Null.Value)
         {
             return false;
         }
         string[] strArray = valueByName.Split((char[]) new char[] { ';' });
         string[] strArray2 = reason.Split((char[]) new char[] { ',' });
         System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
         string[] strArray3 = strArray;
         for (int i = 0; i < strArray3.Length; i = (int) (i + 1))
         {
             string str3 = strArray3[i];
             list.Add(str3);
         }
         string[] strArray4 = strArray2;
         for (int j = 0; j < strArray4.Length; j = (int) (j + 1))
         {
             string str4 = strArray4[j];
             if (!list.Contains(str4.Trim()))
             {
                 return true;
             }
         }
     }
     return false;
 }
예제 #37
0
 private void LoadServiceTypeGroupByGroupTypeId(int groupTypeId)
 {
     this.combGroupName.Items.Clear();
     ObjectList<ServiceTypeGroupPermit> list = ServiceTypeGroupPermit.FindByGroupTypeId(groupTypeId);
     if ((list == null) || (list.get_Count() == 0))
     {
         System.Collections.Generic.List<int> list2 = new System.Collections.Generic.List<int>();
         foreach (ServiceTypeGroup group in ObjectWithId.FindAll<ServiceTypeGroup>())
         {
             if (((group.GroupTypeId == this.m_GroupTypeId) && !group.GroupName.Equals("")) && !list2.Contains(group.Code))
             {
                 this.combGroupName.Items.Add(((int) group.Code) + "." + group.GroupName);
                 list2.Add(group.Code);
             }
         }
         this.radioNewGroup.set_Enabled(true);
         this.btnChangeNameGroup.set_Enabled(true);
     }
     else
     {
         foreach (ServiceTypeGroupPermit permit in list.ApplySort("Name"))
         {
             this.combGroupName.Items.Add(((int) permit.Code) + "." + permit.Name);
         }
         this.radioNewGroup.set_Enabled(false);
         this.btnChangeNameGroup.set_Enabled(false);
     }
     if (this.combGroupName.Items.get_Count() > 0)
     {
         this.combGroupName.set_SelectedIndex(0);
         this.btnChangeNameGroup.set_Enabled(true);
     }
     else
     {
         this.btnChangeNameGroup.set_Enabled(false);
     }
 }
private void CreatePropertyAccessorsForShapeInternal(PresentationElementClass domainElement, bool hasBaseClass)
{

        
        #line default
        #line hidden
        
        #line 318 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("#region Shape Properties\r\n");

        
        #line default
        #line hidden
        
        #line 320 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	AttributedDomainElement temp = domainElement;
	System.Collections.Generic.List<string> handledProperty = new System.Collections.Generic.List<string>();
	while(temp != null )
	{
		foreach(DomainProperty property in temp.Properties)
		{
			if( handledProperty.Contains(property.Name) )
				continue;
			
			handledProperty.Add(property.Name);
			
			AccessModifier setterAccessModifier = property.SetterAccessModifier;
			AccessModifier getterAccessModifier = property.GetterAccessModifier;
			AccessModifier overallAccessModifier;
			
			if(setterAccessModifier==AccessModifier.Public || getterAccessModifier==AccessModifier.Public)
			{
				overallAccessModifier = AccessModifier.Public;
			}
			else if(setterAccessModifier==AccessModifier.FamilyOrAssembly || getterAccessModifier==AccessModifier.FamilyOrAssembly)
			{
				overallAccessModifier = AccessModifier.FamilyOrAssembly;	
			}
			else if(setterAccessModifier==AccessModifier.Family || getterAccessModifier==AccessModifier.Family)
			{
				overallAccessModifier = AccessModifier.Family;
			}
			else if(setterAccessModifier==AccessModifier.Assembly || getterAccessModifier==AccessModifier.Assembly)
			{
				overallAccessModifier = AccessModifier.Assembly;
			}
			else 
			{
				overallAccessModifier = AccessModifier.Private;
			}			
			
			string modifier = "";
			//if( hasBaseClass )
			//	modifier = " new";
			
			//if( p.IsElementName )

        
        #line default
        #line hidden
        
        #line 362 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("/// <summary>\r\n/// Gets or sets the value of ");

        
        #line default
        #line hidden
        
        #line 364 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 364 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" domain property.\r\n/// </summary>\r\n");

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(overallAccessModifier)));

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(modifier));

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" ");

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetDomainTypeFullName(property)));

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" Shape_");

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\r\n{\r\n");

        
        #line default
        #line hidden
        
        #line 368 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	if(getterAccessModifier!=overallAccessModifier)
	{

        
        #line default
        #line hidden
        
        #line 371 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t");

        
        #line default
        #line hidden
        
        #line 372 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(getterAccessModifier)));

        
        #line default
        #line hidden
        
        #line 372 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" get\r\n");

        
        #line default
        #line hidden
        
        #line 373 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}
	else
	{

        
        #line default
        #line hidden
        
        #line 377 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\tget\r\n");

        
        #line default
        #line hidden
        
        #line 379 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}

        
        #line default
        #line hidden
        
        #line 381 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t{\r\n");

        
        #line default
        #line hidden
        
        #line 383 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	if( property.IsElementName )
	{

        
        #line default
        #line hidden
        
        #line 386 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t\treturn this.DomainElementName;\r\n");

        
        #line default
        #line hidden
        
        #line 388 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}
	else
	{

        
        #line default
        #line hidden
        
        #line 392 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t\treturn (this.ShapeElement as ");

        
        #line default
        #line hidden
        
        #line 393 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(domainElement.GetFullName(true)));

        
        #line default
        #line hidden
        
        #line 393 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(").");

        
        #line default
        #line hidden
        
        #line 393 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 393 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(";\r\n");

        
        #line default
        #line hidden
        
        #line 394 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}

        
        #line default
        #line hidden
        
        #line 396 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t}\r\n");

        
        #line default
        #line hidden
        
        #line 398 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

		if(setterAccessModifier != overallAccessModifier)
		{

        
        #line default
        #line hidden
        
        #line 401 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t");

        
        #line default
        #line hidden
        
        #line 402 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(setterAccessModifier)));

        
        #line default
        #line hidden
        
        #line 402 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" set\r\n");

        
        #line default
        #line hidden
        
        #line 403 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

		}
		else
		{

        
        #line default
        #line hidden
        
        #line 407 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\tset\r\n");

        
        #line default
        #line hidden
        
        #line 409 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

		}

        
        #line default
        #line hidden
        
        #line 411 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t{\r\n");

        
        #line default
        #line hidden
        
        #line 413 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"


	if( property.IsElementName )
	{

        
        #line default
        #line hidden
        
        #line 417 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t\tif( this.DomainElementName != value )\r\n\t\t\tthis.DomainElementName = value;\r\n");

        
        #line default
        #line hidden
        
        #line 420 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}
	else
	{

        
        #line default
        #line hidden
        
        #line 424 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t\tif( (this.Element as ");

        
        #line default
        #line hidden
        
        #line 425 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(domainElement.GetFullName(true)));

        
        #line default
        #line hidden
        
        #line 425 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(").");

        
        #line default
        #line hidden
        
        #line 425 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 425 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" != value )\r\n\t\t{\r\n\t\t\tusing( DslModeling::Transaction transaction = this.Store.Tra" +
        "nsactionManager.BeginTransaction(\"Update value of ");

        
        #line default
        #line hidden
        
        #line 427 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 427 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\") )\r\n\t\t\t{\r\n\t\t\t\t(this.Element as ");

        
        #line default
        #line hidden
        
        #line 429 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(domainElement.GetFullName(true)));

        
        #line default
        #line hidden
        
        #line 429 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(").");

        
        #line default
        #line hidden
        
        #line 429 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));

        
        #line default
        #line hidden
        
        #line 429 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" = value;\r\n\t\t\t\t\r\n\t\t\t\ttransaction.Commit();\r\n\t\t\t}\r\n\t\t}\r\n");

        
        #line default
        #line hidden
        
        #line 434 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

	}

        
        #line default
        #line hidden
        
        #line 436 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("\t}\r\n}\r\n\r\n");

        
        #line default
        #line hidden
        
        #line 440 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"

		}
		
		temp = temp.BaseElement;
	}

        
        #line default
        #line hidden
        
        #line 445 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("#endregion\r\n");

        
        #line default
        #line hidden
        
        #line 447 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
		
}
예제 #39
0
        public void Unicode_AddDirectoryByName_wi8984()
        {
            string format = "弹出应用程序{0:D3}.dir"; // Chinese characters
            System.Text.Encoding UTF8 = System.Text.Encoding.GetEncoding("UTF-8");

            TestContext.WriteLine("== WorkItem 8984");
            // three trials: one for old-style
            // ProvisionalAlternateEncoding, one for "AsNecessary"
            // and one for "Always"
            for (int j=0; j < 3; j++)
            {
                TestContext.WriteLine("Trial {0}", j);
                for (int n = 1; n <= 10; n++)
                {
                TestContext.WriteLine("nEntries {0}", n);
                    var dirsAdded = new System.Collections.Generic.List<String>();
                    var zipFileToCreate = String.Format("wi8984-{0}-{1:N2}.zip", j, n);
                    using (ZipFile zip1 = new ZipFile(zipFileToCreate))
                    {
                        switch (j)
                        {
                            case 0:
#pragma warning disable 618
                                zip1.UseUnicodeAsNecessary = true;
#pragma warning restore 618
                                break;
                            case 1:
                                zip1.AlternateEncoding = UTF8;
                                zip1.AlternateEncodingUsage = ZipOption.AsNecessary;
                                break;
                            case 2:
                                zip1.AlternateEncoding = UTF8;
                                zip1.AlternateEncodingUsage = ZipOption.Always;
                                break;
                        }
                        for (int i = 0; i < n; i++)
                        {
                            // create an arbitrary directory name, add it to the zip archive
                            string dirName = String.Format(format, i);
                            zip1.AddDirectoryByName(dirName);
                            dirsAdded.Add(dirName + "/");
                        }
                        zip1.Save();
                    }


                    string extractDir = String.Format("extract-{0}-{1:D3}", j, n);
                    int dirCount = 0;
                    using (ZipFile zip2 = ZipFile.Read(zipFileToCreate))
                    {
                        foreach (var e in zip2)
                        {
                            TestContext.WriteLine("dir: {0}", e.FileName);
                            Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected entry ({0})", e.FileName);
                            Assert.IsTrue(e.IsDirectory);
                            e.Extract(extractDir);
                            dirCount++;
                        }
                    }
                    Assert.AreEqual<int>(n, dirCount);
                    TestContext.WriteLine("");
                }
                TestContext.WriteLine("");
            }
        }
예제 #40
0
        List<mTuple<bool, SubCalendarEvent>> stitchUnRestrictedSubCalendarEvent(TimeLine FreeBoundary, List<mTuple<bool, SubCalendarEvent>> restrictedSnugFitAvailable, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> PossibleEntries, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> CompatibleWithList,double Occupancy)
        {
            TimeLine[] AllFreeSpots = FreeBoundary.getAllFreeSlots();
            int TotalEventsForThisTImeLine = 0;

            foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in CompatibleWithList)
            {
                TotalEventsForThisTImeLine += eachKeyValuePair.Value.Item1;
            }

            CompatibleWithList.Clear();


            DateTime EarliestReferenceTIme = FreeBoundary.Start;
            List<mTuple<bool, SubCalendarEvent>> FrontPartials = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();
            List<mTuple<bool, SubCalendarEvent>> EndPartials = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();
            Dictionary<DateTime, List<mTuple<bool, SubCalendarEvent>>> FrontPartials_Dict = new System.Collections.Generic.Dictionary<DateTime, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>();
            Dictionary<DateTime, List<mTuple<bool, SubCalendarEvent>>> EndPartials_Dict = new System.Collections.Generic.Dictionary<DateTime, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>();
            Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> PossibleEntries_Cpy = new Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>();
            Dictionary<string, Dictionary<string, SubCalendarEvent>> CalendarIDAndNonPartialSubCalEvents = new Dictionary<string, Dictionary<string, SubCalendarEvent>>();//List of non partials for current Reference StartTime To End of FreeBoundary. Its gets updated with Partials once the earliest reference time passes the partial event start time

            foreach (KeyValuePair<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> eachKeyValuePair in PossibleEntries)//populates PossibleEntries_Cpy. I need a copy to maintain all references to PossibleEntries
            {
                Dictionary<string, mTuple<bool, SubCalendarEvent>> NewDictEntry = new Dictionary<string, mTuple<bool, SubCalendarEvent>>();
                
                foreach (KeyValuePair<string, mTuple<bool, SubCalendarEvent>> KeyValuePair0 in eachKeyValuePair.Value)
                {
                    mTuple<bool, SubCalendarEvent> MyEvent = KeyValuePair0.Value;

                    if (MyEvent.Item2.ID == "469_471")
                    {
                        ;
                    }

                    bool isInrestrictedSnugFitAvailable = false;
                    if (CompatibleWithList.ContainsKey(eachKeyValuePair.Key))
                    {
                        ++CompatibleWithList[eachKeyValuePair.Key].Item1;
                    }
                    else
                    {
                        CompatibleWithList.Add(eachKeyValuePair.Key, new mTuple<int, TimeSpanWithStringID>(1, new TimeSpanWithStringID(KeyValuePair0.Value.Item2.ActiveDuration, KeyValuePair0.Value.Item2.ActiveDuration.Ticks.ToString())));
                    }

                    foreach (mTuple<bool, SubCalendarEvent> eachMtuple in restrictedSnugFitAvailable)//checks if event is in restricted list
                    {
                        if (eachMtuple.Item2.ID == MyEvent.Item2.ID)
                        {
                            isInrestrictedSnugFitAvailable = true;
                            break;
                        }

                    }


                    if (!isInrestrictedSnugFitAvailable)
                    {
                        NewDictEntry.Add(KeyValuePair0.Value.Item2.ID, KeyValuePair0.Value);
                        if (FreeBoundary.IsDateTimeWithin(KeyValuePair0.Value.Item2.getCalendarEventRange.Start))
                        {
                            FrontPartials.Add(KeyValuePair0.Value);
                        }
                        else
                        {
                            if (FreeBoundary.IsDateTimeWithin(KeyValuePair0.Value.Item2.getCalendarEventRange.End))
                            {
                                EndPartials.Add(KeyValuePair0.Value);
                            }
                            else 
                            {
                                string CalLevel0ID=KeyValuePair0.Value.Item2.SubEvent_ID.getLevelID(0);
                                if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(CalLevel0ID))
                                {
                                    CalendarIDAndNonPartialSubCalEvents[CalLevel0ID].Add(KeyValuePair0.Value.Item2.ID, KeyValuePair0.Value.Item2);
                                }
                                else 
                                {
                                    //CalendarIDAndNonPartialSubCalEvents.Add(CalLevel0ID, new List<SubCalendarEvent>() { KeyValuePair0.Value.Item2 });
                                    CalendarIDAndNonPartialSubCalEvents.Add(CalLevel0ID, new Dictionary<string, SubCalendarEvent>());
                                    CalendarIDAndNonPartialSubCalEvents[CalLevel0ID].Add(KeyValuePair0.Value.Item2.ID, KeyValuePair0.Value.Item2);
                                }
                            
                            }
                        }
                    }
                }
                if (NewDictEntry.Count > 0)
                { PossibleEntries_Cpy.Add(eachKeyValuePair.Key, NewDictEntry); }

            }

            FrontPartials = FrontPartials.OrderBy(obj => obj.Item2.getCalendarEventRange.Start).ToList();
            EndPartials = EndPartials.OrderBy(obj => obj.Item2.getCalendarEventRange.End).ToList();

            foreach (mTuple<bool, SubCalendarEvent> eachmTuple in FrontPartials)//populates FrontPartials_Dict in ordered manner since FrontPartials is ordered
            {
                if (FrontPartials_Dict.ContainsKey(eachmTuple.Item2.getCalendarEventRange.Start))
                {
                    FrontPartials_Dict[eachmTuple.Item2.getCalendarEventRange.Start].Add(eachmTuple);
                }
                else
                {
                    FrontPartials_Dict.Add(eachmTuple.Item2.getCalendarEventRange.Start, new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>() { eachmTuple });
                }

            }

            foreach (mTuple<bool, SubCalendarEvent> eachmTuple in EndPartials)//populates EndPartials_Dict in ordered manner since EndPartials is ordered
            {
                if (EndPartials_Dict.ContainsKey(eachmTuple.Item2.getCalendarEventRange.Start))
                {
                    EndPartials_Dict[eachmTuple.Item2.getCalendarEventRange.Start].Add(eachmTuple);
                }
                else
                {
                    EndPartials_Dict.Add(eachmTuple.Item2.getCalendarEventRange.Start, new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>() { eachmTuple });
                }
            }


            List<SubCalendarEvent> CompleteArranegement = new System.Collections.Generic.List<SubCalendarEvent>();
            int StartingReferneceIndex = 0;


            /*foreach (mTuple<bool, SubCalendarEvent> eachmTuple in restrictedSnugFitAvailable)//removes the restricted from CompatibleWithList
            {
                --CompatibleWithList[eachmTuple.Item2.ActiveDuration.Ticks.ToString()].Item1;
                //PossibleEntries_Cpy[eachmTuple.Item2.ActiveDuration.Ticks.ToString()].Remove(eachmTuple.Item2.ID);
            }*/

            List<DateTime> ListOfFrontPartialsStartTime = FrontPartials_Dict.Keys.ToList();

            int i = 0;
            int j = 0;
            int FrontPartialCounter = 0;

            if (restrictedSnugFitAvailable.Count < 1)
            {
                ;
            }

            Tuple<DateTime, List<SubCalendarEvent>> TimeLineUpdated = null;
            SubCalendarEvent BorderElementBeginning = null;
            SubCalendarEvent BorderElementEnd = null;
            SubCalendarEvent LastSubCalElementForEarlierReferenceTime = null;
            for (; i < restrictedSnugFitAvailable.Count; i++)
            {
                //bool isFreeSpotBeforeRigid = AllFreeSpots[i].End <= restrictedSnugFitAvailable[i].Item2.Start;
                TimeLineUpdated = null;

                if (CompleteArranegement.Count == 46)
                {
                    ;
                }

                if (i ==2)
                {
                    ;
                }

                restrictedSnugFitAvailable[i].Item2.PinSubEventsToStart(new TimeLine(EarliestReferenceTIme, restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End));
                List<BusyTimeLine> RestrictedBusySlots = new System.Collections.Generic.List<BusyTimeLine>();
                FreeBoundary = new TimeLine(FreeBoundary.Start, FreeBoundary.End);
                foreach (mTuple<bool, SubCalendarEvent> eachmTuple in restrictedSnugFitAvailable)
                {
                    eachmTuple.Item1 = true;
                    RestrictedBusySlots.Add(eachmTuple.Item2.ActiveSlot);
                    string timeSpanString = eachmTuple.Item2.ActiveDuration.Ticks.ToString();
                    string SubEventID = eachmTuple.Item2.ID;

                }
                FreeBoundary.AddBusySlots(RestrictedBusySlots.ToArray());

                List<SubCalendarEvent> LowestCostArrangement = new System.Collections.Generic.List<SubCalendarEvent>();
                TimeLine PertinentFreeSpot = null;
                TimeLine FreeSpotUpdated = null;
                j = i + 1;
                if (ListOfFrontPartialsStartTime.Count > 0)//fits any sub calEvent in preceeding restricting free spot
                {
                    DateTime RestrictedStopper = restrictedSnugFitAvailable[i].Item2.Start;


                    bool breakForLoop = false;
                    bool PreserveRestrictedIndex = false;
                    for (; FrontPartialCounter < ListOfFrontPartialsStartTime.Count; FrontPartialCounter++)
                    {
                        TimeLineUpdated = null;
                        DateTime PertinentFreeSpotStart = EarliestReferenceTIme;
                        DateTime PertinentFreeSpotEnd;
                        if (CompleteArranegement.Count == 46)
                        {
                            ;
                        }
                        if ((ListOfFrontPartialsStartTime[FrontPartialCounter] < RestrictedStopper))
                        {
                            PertinentFreeSpotEnd = ListOfFrontPartialsStartTime[FrontPartialCounter];
                            //FrontPartials_Dict.Remove(ListOfFrontPartialsStartTime[FrontPartialCounter]);
                            ListOfFrontPartialsStartTime.RemoveAt(FrontPartialCounter);
                            --FrontPartialCounter;
                            PreserveRestrictedIndex = true;
                        }
                        else
                        {
                            PertinentFreeSpotEnd = RestrictedStopper;

                            if (breakForLoop)
                            {//populates with final boundary for each restricted
                                PertinentFreeSpot = new TimeLine(PertinentFreeSpotStart, PertinentFreeSpotEnd);

                                BorderElementBeginning = CompleteArranegement.Count>0?CompleteArranegement[CompleteArranegement.Count-1]:null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                                BorderElementEnd = restrictedSnugFitAvailable[i].Item2;//uses restricted value as boundary element
                                LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy,Occupancy);
                                DateTime EarliestTimeForBetterEarlierReferenceTime = PertinentFreeSpot.Start;
                                LastSubCalElementForEarlierReferenceTime = ((CompleteArranegement.Count < 1) || (CompleteArranegement == null) ? null : CompleteArranegement[CompleteArranegement.Count - 1]);
                                    FreeSpotUpdated = PertinentFreeSpot.CreateCopy();
                                if (LowestCostArrangement.Count > 0)
                                {
                                    if (!(LowestCostArrangement[0].getCalendarEventRange.Start == PertinentFreeSpot.Start))//Pin SubEvents To Start
                                    {//if the first element is not a partial Sub Cal Event element
                                        FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                                    }
                                    else
                                    {
                                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();// new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                                        Utility.PinSubEventsToStart(LowestCostArrangement, PertinentFreeSpot);
                                    }
                                    EarliestReferenceTIme = PertinentFreeSpot.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;

                                    SubCalendarEvent LastSubCalEvent = LowestCostArrangement[LowestCostArrangement.Count - 1];
                                    EarliestTimeForBetterEarlierReferenceTime = LastSubCalEvent.End;
                                    LastSubCalElementForEarlierReferenceTime = LastSubCalEvent;
                                    
                                }
                                TimeLineUpdated = null;
                                TimeLineUpdated = ObtainBetterEarlierReferenceTime(LowestCostArrangement, CalendarIDAndNonPartialSubCalEvents, RestrictedStopper - EarliestTimeForBetterEarlierReferenceTime, EarliestReferenceTIme, new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End), LastSubCalElementForEarlierReferenceTime);
                                if (TimeLineUpdated != null)
                                {
                                    LowestCostArrangement = TimeLineUpdated.Item2;
                                    EarliestReferenceTIme = TimeLineUpdated.Item1;
                                }
                                

                                foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                                {
                                    --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                                    PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                                    string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                                    if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                                    {
                                        CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                                        if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                                        {
                                            CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                                        }
                                    }
                                    if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                                    {
                                        PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                                    }
                                }


                                LowestCostArrangement = CompleteArranegement.Concat(LowestCostArrangement).ToList();
                                LowestCostArrangement = PlaceSubCalEventInLowestCostPosition(FreeBoundary, restrictedSnugFitAvailable[i].Item2, LowestCostArrangement);
                                Utility.PinSubEventsToStart(LowestCostArrangement, FreeBoundary);

                                CompleteArranegement = LowestCostArrangement;
                                EarliestReferenceTIme = LowestCostArrangement[LowestCostArrangement.Count - 1].End;

                                PreserveRestrictedIndex = false;
                                break;
                            }

                            --FrontPartialCounter;
                            if (j < restrictedSnugFitAvailable.Count)
                            {
                                RestrictedStopper = restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End > restrictedSnugFitAvailable[j].Item2.Start ? restrictedSnugFitAvailable[j].Item2.Start : restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End;
                            }
                            else
                            {
                                RestrictedStopper = restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End > FreeBoundary.End ? FreeBoundary.End : restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End;
                            }
                            RestrictedStopper -= restrictedSnugFitAvailable[i].Item2.ActiveDuration;
                            breakForLoop = true;
                        }
                        PertinentFreeSpot = new TimeLine(PertinentFreeSpotStart, PertinentFreeSpotEnd);

                        BorderElementBeginning = CompleteArranegement.Count > 0 ? CompleteArranegement[CompleteArranegement.Count - 1] : null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                        BorderElementEnd = restrictedSnugFitAvailable[i].Item2;//uses restricted value as boundary element

                        LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy, Occupancy);
                        DateTime LatestDaterforEarlierReferenceTime = PertinentFreeSpot.Start;
                        LastSubCalElementForEarlierReferenceTime = ((CompleteArranegement.Count < 1) || (CompleteArranegement == null) ? null : CompleteArranegement[CompleteArranegement.Count - 1]);//updates the last element as either null or the last element in the current Complete arrangement
                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();
                        if (LowestCostArrangement.Count > 0)
                        {
                            if (!(LowestCostArrangement[0].getCalendarEventRange.Start == PertinentFreeSpot.Start))//Pin SubEvents To Start
                            {//if the first element is not a partial Sub Cal Event element
                                FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                                Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);

                            }
                            else
                            {
                                //FreeSpotUpdated = new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                                FreeSpotUpdated = PertinentFreeSpot.CreateCopy();
                                Utility.PinSubEventsToStart(LowestCostArrangement, PertinentFreeSpot);
                            }
                            EarliestReferenceTIme = PertinentFreeSpot.End;
                            
                            ///Comeback to this
                            ///
                            SubCalendarEvent LastSubCalEvent = LowestCostArrangement[LowestCostArrangement.Count - 1];
                            LatestDaterforEarlierReferenceTime = LastSubCalEvent.End;
                            LastSubCalElementForEarlierReferenceTime = LastSubCalEvent;
                        }

                        TimeLineUpdated = ObtainBetterEarlierReferenceTime(LowestCostArrangement, CalendarIDAndNonPartialSubCalEvents, RestrictedStopper - LatestDaterforEarlierReferenceTime, EarliestReferenceTIme, new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End), LastSubCalElementForEarlierReferenceTime);
                        //errorline
                        
                        if (TimeLineUpdated != null)
                        {
                            LowestCostArrangement = TimeLineUpdated.Item2;
                            EarliestReferenceTIme = TimeLineUpdated.Item1;
                        }
                        

                        foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                        {
                            --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                            PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                            string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                            if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                            {
                                CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                                if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                                {
                                    CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                                }
                            }
                            if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                            {
                                PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                            }
                        }
                        CompleteArranegement.AddRange(LowestCostArrangement);


                        int DateTimeCounter = 0;
                        for (; DateTimeCounter < FrontPartials_Dict.Keys.Count; DateTimeCounter++)//updates CalendarIDAndNonPartialSubCalEvents if frontpartial Startime has been passed. Alls updates FrontPartials_Dict
                        {
                            DateTime eachDateTIme = FrontPartials_Dict.Keys.ToList()[DateTimeCounter];
                            if (EarliestReferenceTIme >= eachDateTIme)
                            {
                                List<mTuple<bool, SubCalendarEvent>> mTUpleSubCalEvents = FrontPartials_Dict[eachDateTIme];
                                foreach (mTuple<bool, SubCalendarEvent> eachmTUple in mTUpleSubCalEvents)
                                {

                                    string CalLevel0ID = eachmTUple.Item2.SubEvent_ID.getLevelID(0);
                                    if (!CompleteArranegement.Contains(eachmTUple.Item2))
                                    {
                                        if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(CalLevel0ID))
                                        {
                                            CalendarIDAndNonPartialSubCalEvents[CalLevel0ID].Add(eachmTUple.Item2.ID, eachmTUple.Item2);
                                        }
                                        else
                                        {
                                            //CalendarIDAndNonPartialSubCalEvents.Add(CalLevel0ID, new List<SubCalendarEvent>() { KeyValuePair0.Value.Item2 });
                                            CalendarIDAndNonPartialSubCalEvents.Add(CalLevel0ID, new Dictionary<string, SubCalendarEvent>());
                                            CalendarIDAndNonPartialSubCalEvents[CalLevel0ID].Add(eachmTUple.Item2.ID, eachmTUple.Item2);
                                        }
                                    }
                                }
                                FrontPartials_Dict.Remove(eachDateTIme);
                            }
                        }


                    }
                    if (PreserveRestrictedIndex)//verifies if we took the path of restricted or front partial element. The latter needs a preservation of the current restricted Subcalevent index index 
                    {
                        --i;
                    }
                }
                else
                {//No FrontPartials
                    DateTime ReferenceEndTime = restrictedSnugFitAvailable[i].Item2.Start;
                    PertinentFreeSpot = new TimeLine(EarliestReferenceTIme, ReferenceEndTime);

                    BorderElementBeginning = CompleteArranegement.Count > 0 ? CompleteArranegement[CompleteArranegement.Count - 1] : null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                    BorderElementEnd = restrictedSnugFitAvailable[i].Item2;//uses restricted value as boundary element

                    LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy,Occupancy);

                    if (LowestCostArrangement.Count > 0)
                    {
                        if (!(LowestCostArrangement[0].getCalendarEventRange.Start == PertinentFreeSpot.Start))//Pin SubEvents To Start
                        {//if the first element is not a partial Sub Cal Event element
                            FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                            Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                        }
                        else
                        {
                            FreeSpotUpdated = new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                            Utility.PinSubEventsToStart(LowestCostArrangement, PertinentFreeSpot);
                        }
                        EarliestReferenceTIme = FreeSpotUpdated.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;
                    }

                    foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                    {
                        --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                        PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                        string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                        if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                        {
                            CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                            if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                            {
                                CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                            }
                        }
                        if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                        {
                            PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                        }
                    }


                    List<SubCalendarEvent> AdditionalCOstArrangement = new System.Collections.Generic.List<SubCalendarEvent>();
                    if (j < restrictedSnugFitAvailable.Count)
                    {
                        DateTime StartDateTimeAfterFitting = PertinentFreeSpot.End;//this is the barring end time of the preceding boundary search

                        DateTime RelativeEndTime = restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End > restrictedSnugFitAvailable[j].Item2.Start ? restrictedSnugFitAvailable[j].Item2.Start : restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End;

                        RelativeEndTime -= restrictedSnugFitAvailable[i].Item2.ActiveDuration;
                        TimeLine CurrentlyFittedTimeLine = new TimeLine(StartDateTimeAfterFitting, RelativeEndTime);

                        BorderElementBeginning = CompleteArranegement.Count > 0 ? CompleteArranegement[CompleteArranegement.Count - 1] : null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                        BorderElementEnd = restrictedSnugFitAvailable[i].Item2;//uses restricted value as boundary element

                        AdditionalCOstArrangement = OptimizeArrangeOfSubCalEvent(CurrentlyFittedTimeLine, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy, Occupancy);
                        if (AdditionalCOstArrangement.Count > 0)
                        {//Additional get populated
                            if (!(AdditionalCOstArrangement[0].getCalendarEventRange.Start == CurrentlyFittedTimeLine.Start))//Pin SubEvents To Start
                            {//if the first element is not a partial Sub Cal Event element
                                FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, CurrentlyFittedTimeLine.End);
                                Utility.PinSubEventsToStart(AdditionalCOstArrangement, FreeSpotUpdated);
                            }
                            else
                            {
                                FreeSpotUpdated = new TimeLine(AdditionalCOstArrangement[0].getCalendarEventRange.Start, CurrentlyFittedTimeLine.End);
                                Utility.PinSubEventsToStart(AdditionalCOstArrangement, FreeSpotUpdated);
                            }

                            foreach (SubCalendarEvent eachSubCalendarEvent in AdditionalCOstArrangement)
                            {
                                --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                                PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                                string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                                if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                                {
                                    CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                                    if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                                    {
                                        CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                                    }
                                }
                                if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                                {
                                    PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                                }
                            }


                            RelativeEndTime = AdditionalCOstArrangement[AdditionalCOstArrangement.Count - 1].End;
                            RelativeEndTime += restrictedSnugFitAvailable[i].Item2.ActiveDuration; ;
                            FreeSpotUpdated = new TimeLine(FreeSpotUpdated.Start, RelativeEndTime);
                            AdditionalCOstArrangement = PlaceSubCalEventInLowestCostPosition(FreeSpotUpdated, restrictedSnugFitAvailable[i].Item2, AdditionalCOstArrangement);
                        }
                        else
                        {//if there is no other Restricted in list
                            RelativeEndTime += restrictedSnugFitAvailable[i].Item2.ActiveDuration;

                            CurrentlyFittedTimeLine = new TimeLine(CurrentlyFittedTimeLine.Start, RelativeEndTime);

                            AdditionalCOstArrangement = PlaceSubCalEventInLowestCostPosition(CurrentlyFittedTimeLine, restrictedSnugFitAvailable[i].Item2, AdditionalCOstArrangement);
                        }
                    }
                    else
                    {
                        DateTime RelativeEndTime = restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End > FreeBoundary.End ? FreeBoundary.End : restrictedSnugFitAvailable[i].Item2.getCalendarEventRange.End;
                        TimeLine CurrentlyFittedTimeLine = new TimeLine(EarliestReferenceTIme, RelativeEndTime);
                        AdditionalCOstArrangement = PlaceSubCalEventInLowestCostPosition(CurrentlyFittedTimeLine, restrictedSnugFitAvailable[i].Item2, AdditionalCOstArrangement);
                    }

                    List<SubCalendarEvent> var2 = new System.Collections.Generic.List<SubCalendarEvent>();//List is a addition of LowestCostArrangement and AdditionalCOstArrangement
                    var2 = LowestCostArrangement.Concat(AdditionalCOstArrangement).ToList();

                    CompleteArranegement.AddRange(LowestCostArrangement);
                    CompleteArranegement.AddRange(AdditionalCOstArrangement);
                    if (CompleteArranegement.Count > 0)
                    {
                        EarliestReferenceTIme = CompleteArranegement[CompleteArranegement.Count - 1].End;
                    }
                }
            }


            { //Handles THe Last Free Space outside of rigids
                TimeLine FreeSpotOutSideRigids = new TimeLine(EarliestReferenceTIme, FreeBoundary.End);
                TimeLine PertinentFreeSpot = new TimeLine(EarliestReferenceTIme, FreeBoundary.End); ;
                TimeLine FreeSpotUpdated;
                List<SubCalendarEvent> LowestCostArrangement;
                if (ListOfFrontPartialsStartTime.Count > 0)
                {
                    for (FrontPartialCounter = 0; FrontPartialCounter < ListOfFrontPartialsStartTime.Count; FrontPartialCounter++)
                    {
                        DateTime PertinentFreeSpotStart = EarliestReferenceTIme;
                        DateTime PertinentFreeSpotEnd;
                        PertinentFreeSpotEnd = ListOfFrontPartialsStartTime[FrontPartialCounter];
                        //FrontPartials_Dict.Remove(ListOfFrontPartialsStartTime[FrontPartialCounter]);
                        ListOfFrontPartialsStartTime.RemoveAt(FrontPartialCounter);
                        --FrontPartialCounter;
                        PertinentFreeSpot = new TimeLine(PertinentFreeSpotStart, PertinentFreeSpotEnd);
                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();

                        BorderElementBeginning = CompleteArranegement.Count > 0 ? CompleteArranegement[CompleteArranegement.Count - 1] : null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                        BorderElementEnd = null;

                        LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy, Occupancy);
                        DateTime LatestTimeForBetterEarlierReferenceTime = PertinentFreeSpot.Start;
                        LastSubCalElementForEarlierReferenceTime = ((CompleteArranegement.Count < 1) || (CompleteArranegement == null) ? null : CompleteArranegement[CompleteArranegement.Count - 1]);
                        if (LowestCostArrangement.Count > 0)
                        {
                            if ((LowestCostArrangement[0].getCalendarEventRange.Start != PertinentFreeSpot.Start))//Pin SubEvents To Start
                            {//if the first element is not a partial Sub Cal Event element
                                FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                                Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);

                            }
                            else
                            {
                                FreeSpotUpdated = PertinentFreeSpot.CreateCopy();// new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                                Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                            }
                            EarliestReferenceTIme = PertinentFreeSpot.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;
                            SubCalendarEvent LastSubCalEvent = LowestCostArrangement[LowestCostArrangement.Count - 1];
                            LatestTimeForBetterEarlierReferenceTime = LastSubCalEvent.End;
                            LastSubCalElementForEarlierReferenceTime = LastSubCalEvent;
                            /*
                            Dictionary<string, double> AllValidNodes = CalendarEvent.DistanceToAllNodes(LastSubCalEvent.SubEvent_ID.getLevelID(0));
                            SubCalendarEvent AppendableEVent;
                            foreach (string eachstring in AllValidNodes.Keys)
                            {
                                if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(eachstring))
                                {
                                    AppendableEVent = CalendarIDAndNonPartialSubCalEvents[eachstring].ToList()[0].Value;//Assumes Theres Always an element
                                    

                                    if ((AppendableEVent.ActiveDuration <= (FreeBoundary.End - LastSubCalEvent.End)) && (!LowestCostArrangement.Contains(AppendableEVent)))
                                    {
                                        LowestCostArrangement.Add(AppendableEVent);
                                        CalendarIDAndNonPartialSubCalEvents[eachstring].Remove(AppendableEVent.ID);
                                        if (CalendarIDAndNonPartialSubCalEvents[eachstring].Count < 1)//checks if List is empty. Deletes keyValuepair if list is empty
                                        {
                                            CalendarIDAndNonPartialSubCalEvents.Remove(eachstring);
                                        }
                                        FreeSpotUpdated = new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End);
                                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                                        EarliestReferenceTIme = AppendableEVent.End;
                                        break;
                                    }
                                }
                            }*/
                        }


                        TimeLineUpdated = null;
                        TimeLineUpdated = ObtainBetterEarlierReferenceTime(LowestCostArrangement, CalendarIDAndNonPartialSubCalEvents, FreeBoundary.End - LatestTimeForBetterEarlierReferenceTime, EarliestReferenceTIme, new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End), LastSubCalElementForEarlierReferenceTime);
                        if (TimeLineUpdated != null)
                        {
                            LowestCostArrangement = TimeLineUpdated.Item2;
                            EarliestReferenceTIme = TimeLineUpdated.Item1;
                        }
                        
                        foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                        {
                            --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                            PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                            string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                            if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                            {
                                CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                                if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                                {
                                    CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                                }
                            }
                            if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                            {
                                PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                            }
                        }
                        CompleteArranegement.AddRange(LowestCostArrangement);
                    }
                }


                DateTime ReferenceEndTime = FreeBoundary.End;
                PertinentFreeSpot = new TimeLine(EarliestReferenceTIme, ReferenceEndTime);
                /*LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(null, null), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy);

                if (LowestCostArrangement.Count > 0)
                {
                    if (!(LowestCostArrangement[0].getCalendarEventRange.Start == PertinentFreeSpot.Start))//Pin SubEvents To Start
                    {//if the first element is not a partial Sub Cal Event element
                        FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                    }
                    else
                    {
                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();// new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                    }
                    EarliestReferenceTIme = FreeSpotUpdated.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;
                }*/
                BorderElementBeginning = CompleteArranegement.Count > 0 ? CompleteArranegement[CompleteArranegement.Count - 1] : null;//Checks if Complete arrangement has partially being filled. Sets Last elements as boundary Element
                BorderElementEnd = null;

                LowestCostArrangement = OptimizeArrangeOfSubCalEvent(PertinentFreeSpot, new Tuple<SubCalendarEvent, SubCalendarEvent>(BorderElementBeginning, BorderElementEnd), CompatibleWithList.Values.ToList(), PossibleEntries_Cpy, Occupancy);
                LastSubCalElementForEarlierReferenceTime = ((CompleteArranegement.Count < 1) || (CompleteArranegement == null) ? null : CompleteArranegement[CompleteArranegement.Count - 1]);
                DateTime LimitForBetterEarlierReferencTime = EarliestReferenceTIme;
                FreeSpotUpdated = PertinentFreeSpot.CreateCopy();
                if (LowestCostArrangement.Count > 0)
                {
                    if ((LowestCostArrangement[0].getCalendarEventRange.Start != PertinentFreeSpot.Start))//Pin SubEvents To Start
                    {//if the first element is not a partial Sub Cal Event element
                        FreeSpotUpdated = new TimeLine(EarliestReferenceTIme, PertinentFreeSpot.End);
                        Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);

                    }
                    else
                    {
                        FreeSpotUpdated = PertinentFreeSpot.CreateCopy();// new TimeLine(LowestCostArrangement[0].getCalendarEventRange.Start, PertinentFreeSpot.End);
                        Utility.PinSubEventsToStart(LowestCostArrangement, PertinentFreeSpot);
                    }
                    EarliestReferenceTIme = PertinentFreeSpot.End;// LowestCostArrangement[LowestCostArrangement.Count - 1].End;
                    SubCalendarEvent LastSubCalEvent = LowestCostArrangement[LowestCostArrangement.Count - 1];
                    LimitForBetterEarlierReferencTime=LastSubCalEvent.End;
                    LastSubCalElementForEarlierReferenceTime = LastSubCalEvent;
                    
                    
                    
                    /*
                    
                    
                    Dictionary<string, double> AllValidNodes = CalendarEvent.DistanceToAllNodes(LastSubCalEvent.SubEvent_ID.getLevelID(0));
                    SubCalendarEvent AppendableEVent;
                    foreach (string eachstring in AllValidNodes.Keys)
                    {
                        if (CalendarIDAndNonPartialSubCalEvents.ContainsKey(eachstring))
                        {
                            AppendableEVent = CalendarIDAndNonPartialSubCalEvents[eachstring].ToList()[0].Value;//Assumes Theres Always an element

                            if ((AppendableEVent.ActiveDuration <= (FreeBoundary.End - LastSubCalEvent.End)) && (!LowestCostArrangement.Contains(AppendableEVent)))
                            {
                                LowestCostArrangement.Add(AppendableEVent);
                                CalendarIDAndNonPartialSubCalEvents[eachstring].Remove(AppendableEVent.ID);
                                if (CalendarIDAndNonPartialSubCalEvents[eachstring].Count < 1)//checks if List is empty. Deletes keyValuepair if list is empty
                                {
                                    CalendarIDAndNonPartialSubCalEvents.Remove(eachstring);
                                }
                                FreeSpotUpdated = new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End);
                                Utility.PinSubEventsToStart(LowestCostArrangement, FreeSpotUpdated);
                                EarliestReferenceTIme = AppendableEVent.End;
                                break;
                            }
                        }
                    }*/

                }
                TimeLineUpdated = null;
                TimeLineUpdated = ObtainBetterEarlierReferenceTime(LowestCostArrangement, CalendarIDAndNonPartialSubCalEvents, FreeBoundary.End - LimitForBetterEarlierReferencTime, EarliestReferenceTIme, new TimeLine(FreeSpotUpdated.Start, FreeBoundary.End), LastSubCalElementForEarlierReferenceTime);
                if (TimeLineUpdated != null)
                {
                    LowestCostArrangement = TimeLineUpdated.Item2;
                    EarliestReferenceTIme = TimeLineUpdated.Item1;
                }


                foreach (SubCalendarEvent eachSubCalendarEvent in LowestCostArrangement)
                {
                    --CompatibleWithList[eachSubCalendarEvent.ActiveDuration].Item1;
                    PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Remove(eachSubCalendarEvent.ID);
                    string SubCalString = eachSubCalendarEvent.SubEvent_ID.getLevelID(0);
                    if(CalendarIDAndNonPartialSubCalEvents.ContainsKey(SubCalString))
                    {
                        CalendarIDAndNonPartialSubCalEvents[SubCalString].Remove(eachSubCalendarEvent.ID);
                        if (CalendarIDAndNonPartialSubCalEvents[SubCalString].Count < 1)
                        {
                            CalendarIDAndNonPartialSubCalEvents.Remove(SubCalString);
                        }
                    }

                    if (PossibleEntries_Cpy[eachSubCalendarEvent.ActiveDuration].Count < 1)
                    {
                        PossibleEntries_Cpy.Remove(eachSubCalendarEvent.ActiveDuration);
                    }
                }
                CompleteArranegement.AddRange(LowestCostArrangement);

            }






            List<mTuple<bool, SubCalendarEvent>> retValue = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();

            foreach (SubCalendarEvent eachSubCalendarEvent in CompleteArranegement)
            {
                PossibleEntries[eachSubCalendarEvent.ActiveDuration][eachSubCalendarEvent.ID].Item1 = true;
                retValue.Add(PossibleEntries[eachSubCalendarEvent.ActiveDuration][eachSubCalendarEvent.ID]);
            }

            //List<List<SubCalendarEvent>> unrestrictedValidCombinations = generateCombinationForDifferentEntries(CompatibleWithList, PossibleEntries);

            retValue = reAlignSubCalEvents(FreeBoundary, retValue);
            if (TotalEventsForThisTImeLine != retValue.Count)
            {
                ;
            }
            return retValue;

        }
예제 #41
0
    private void BindTags()
    {
        System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();
        foreach (Training cls in Training.Trainings)
        {
            foreach (string tag in cls.Tags)
            {
                if (!col.Contains(tag))
                    col.Add(tag);
            }

        }
        foreach (Curricula cls in Curricula.Curriculas)
        {
            foreach (string tag in cls.Tags)
            {
                if (!col.Contains(tag))
                    col.Add(tag);
            }

        }

        col.Sort(delegate(string s1, string s2) { return String.Compare(s1, s2); });

        foreach (string tag in col)
        {
            HtmlAnchor a = new HtmlAnchor();
            a.HRef = "javascript:void(0)";
            a.Attributes.Add("onclick", "AddTag(this)");
            a.InnerText = tag;
            phTags.Controls.Add(a);
        }
    }
예제 #42
0
        /// <summary>
        /// Imports (create) a document from a xmlrepresentation of a document, used by the packager
        /// </summary>
        /// <param name="ParentId">The id to import to</param>
        /// <param name="Creator">Creator of the new document</param>
        /// <param name="Source">Xmlsource</param>
        public static int Import(int ParentId, User Creator, XmlElement Source)
        {
            // check what schema is used for the xml
            bool sourceIsLegacySchema = Source.Name.ToLower() == "node" ? true : false;

            // check whether or not to create a new document
            int id = int.Parse(Source.GetAttribute("id"));
            Document d = null;
            if (Document.IsDocument(id))
            {
                try
                {
                    // if the parent is the same, we'll update the existing document. Else we'll create a new document below
                    d = new Document(id);
                    if (d.ParentId != ParentId)
                        d = null;
                }
                catch { }
            }

            // document either didn't exist or had another parent so we'll create a new one
            if (d == null)
            {
                string nodeTypeAlias = sourceIsLegacySchema ? Source.GetAttribute("nodeTypeAlias") : Source.Name;
                d = MakeNew(
                    Source.GetAttribute("nodeName"),
                    DocumentType.GetByAlias(nodeTypeAlias),
                    Creator,
                    ParentId);
            }
            else
            {
                // update name of the document
                d.Text = Source.GetAttribute("nodeName");
            }

            d.CreateDateTime = DateTime.Parse(Source.GetAttribute("createDate"));

            // Properties
            string propertyXPath = sourceIsLegacySchema ? "data" : "* [not(@isDoc)]";
            foreach (XmlElement n in Source.SelectNodes(propertyXPath))
            {
                string propertyAlias = sourceIsLegacySchema ? n.GetAttribute("alias") : n.Name;
                Property prop = d.getProperty(propertyAlias);
                string propValue = xmlHelper.GetNodeValue(n);

                if (prop != null)
                {
                    // only update real values
                    if (!String.IsNullOrEmpty(propValue))
                    {
                        //test if the property has prevalues, of so, try to convert the imported values so they match the new ones
                        SortedList prevals = cms.businesslogic.datatype.PreValues.GetPreValues(prop.PropertyType.DataTypeDefinition.Id);

                        //Okey we found some prevalue, let's replace the vals with some ids
                        if (prevals.Count > 0)
                        {
                            System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(propValue.Split(','));

                            foreach (DictionaryEntry item in prevals)
                            {
                                string pval = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Value;
                                string pid = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Id.ToString();

                                if (list.Contains(pval))
                                    list[list.IndexOf(pval)] = pid;

                            }

                            //join the list of new values and return it as the new property value
                            System.Text.StringBuilder builder = new System.Text.StringBuilder();
                            bool isFirst = true;

                            foreach (string str in list)
                            {
                                if (!isFirst)
                                    builder.Append(",");

                                builder.Append(str);
                                isFirst = false;
                            }
                            prop.Value = builder.ToString();

                        }
                        else
                            prop.Value = propValue;
                    }
                }
                else
                {
					LogHelper.Warn<Document>(String.Format("Couldn't import property '{0}' as the property type doesn't exist on this document type", propertyAlias));
                }
            }

            d.Save();

            // Subpages
            string subXPath = sourceIsLegacySchema ? "node" : "* [@isDoc]";
            foreach (XmlElement n in Source.SelectNodes(subXPath))
                Import(d.Id, Creator, n);

            return d.Id;
        }
예제 #43
0
        private void buttonExchange_Click(object sender, EventArgs e)
        {
            //string test = "ABC:PNK";
            //string ext = test.Substring(test.IndexOf(":") + 1);

            string sourceDirectory = @"ScreenerUSOnly";
            //Dictionary<string, string> dictionary = new System.Collections.Generic.Dictionary<string,string>;
            List<string> dictionary = new System.Collections.Generic.List<string>();

            try
            {
                var txtFiles = Directory.EnumerateFiles(sourceDirectory);

                foreach (string currentFile in txtFiles)
                {
                    //string fileName = currentFile.Substring(sourceDirectory.Length + 1);
                    string content = System.IO.File.ReadAllText(currentFile);
                    //Match m = Regex.Match(content, @"value=""(.+?)""", RegexOptions.IgnoreCase | RegexOptions.Singleline);

                    MatchCollection mm = Regex.Matches(content, @"value=""(.+?)""", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    //if (mm.Count == 0)
                    //    continue;
                    foreach (Match match in mm) {
                        string ext = match.Groups[1].Value;
                        string exchange = ext.Substring(ext.IndexOf(":") + 1);
                        if (!dictionary.Contains(exchange))
                            dictionary.Add(exchange);
                    }
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.Message);
            }

            foreach (string item in dictionary)
            {
                Console.WriteLine(item);
            }
        }
예제 #44
0
        public void controller(string[] args)
        {
            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-FTDNA"))
            {
                FamilyTreeDNA.FamilyTreeDNA ftd = new FamilyTreeDNA.FamilyTreeDNA();
                if (args.Length >= 3)
                    ftd.Login(args[1], args[2]);
                else
                    ftd.Login("169551", "D3742");
            }
            if (args.Length >= 2 && args[0].ToUpper().Equals("-23"))
            {
                MeAnd23.MeAnd23 m23 = new MeAnd23.MeAnd23();
                if (args.Length >= 3)
                    m23.Login(args[1], args[2]);
                else
                    m23.Login("*****@*****.**", "nurse1");
            }
            if (args.Length >= 2 && args[0].ToUpper().Equals("-CSV"))
            {

            }
             
            if (args.Length >= 2 && args[0].Equals("-compare"))
            {
                GedcomDatabase gd1 = new GedcomDatabase();
                GedcomIndividualRecord record = new GedcomIndividualRecord(gd1, "Robert Warthen");
                record.Sex = GedcomSex.Male;
                //record.Birth = new GedcomIndividualEvent().Date.;

                GedcomParser.GedcomRecordWriter grw = new GedcomParser.GedcomRecordWriter();
                grw.WriteGedcom(gd1, "C:\\Temp\\Rob.ged");

            }
            if (args.Length >= 2 && args[0].Equals("-surlist"))
            {
                swsn = new StreamWriter(args[1] + "\\surname.csv", false);

                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                string[] files2 = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);

                if (args.Length >= 3 && args[2].Equals("-file"))
                {
                    files = new string[1];
                    files[0] = args[3];
                }

                if (args.Length >= 3 && args[2].Equals("-dir"))
                {
                    files2 = Directory.GetFiles(args[3], "*.*", SearchOption.TopDirectoryOnly);
                }

                foreach (string gdf1 in files)
                {
                    string gedcomFile1 = gdf1.ToUpper();
                    if (!gedcomFile1.EndsWith(".GED"))
                        continue;

                    swFile1 = Path.GetFileName(gedcomFile1);
                    //Console.WriteLine("Loading " + );
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    try { grr1.ReadGedcom(); }
                    catch { Console.WriteLine("Couldn't read file " + gedcomFile1);  continue; }
                    GedcomDatabase gd1 = grr1.Database;
                    System.Collections.Generic.List<string> sv = new System.Collections.Generic.List<string>();
                    sv.Clear();
                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            foreach (GedcomName sname in rec.Names)
                            {
                                string sn = sname.Surname.ToUpper();
                                if (sn.Length == 0)
                                    continue;
                                if (!sv.Contains(sname.Surname.ToUpper()))
                                {
                                    sv.Add(sname.Surname.ToUpper());
                                    swsn.WriteLine(gedcomFile1 + ",\"" + sname.Surname.ToUpper().Replace("\"", "_") + "\"");
                                }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't read");
                        }
                    }
                }
                swsn.Close();
            }
            if (args.Length >= 2 && args[0].Equals("-compdir"))
            {
                sw = new StreamWriter(args[1] + "\\match.csv");
                sw.WriteLine("File1,File2,Exact Match,Given1,Surname1,Birth Date1,Birth Place1,Death Date1,Death Place1,Given2,Surname2,Birth Date2,Birth Place2,Death Date2,Death Place2");
                
                swsn = new StreamWriter(args[1] + "\\surname.csv",false);
                
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                string[] files2 = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);

                if (args.Length >= 3 && args[2].Equals("-file"))
                {
                    files = new string[1];
                    files[0] = args[3];
                }

                if (args.Length >= 3 && args[2].Equals("-dir"))
                {
                    files2 = Directory.GetFiles(args[3], "*.*", SearchOption.TopDirectoryOnly);
                }

                foreach (string gdf1 in files)
                {
                    string gedcomFile1 = gdf1.ToUpper();
                    if (!gedcomFile1.EndsWith(".GED"))
                        continue;

                    swFile1 = Path.GetFileName(gedcomFile1);
                    //Console.WriteLine("Loading " + );
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    try { grr1.ReadGedcom(); }
                    catch { continue; }
                    GedcomDatabase gd1 = grr1.Database;
                    System.Collections.Generic.List<string> sv = new System.Collections.Generic.List<string>();
                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            foreach (GedcomName sname in rec.Names)
                            {
                                if (!sv.Contains(sname.Surname.ToUpper()))
                                {
                                    sv.Add(sname.Surname.ToUpper());
                                    swsn.WriteLine(gedcomFile1 + ",\"" + sname.Surname.ToUpper().Replace("\"","_") + "\"");
                                }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't read");
                        }
                    }
                    foreach (string gdf2 in files2)
                    {
                        string gedcomFile2 = gdf2.ToUpper();
                        if (!gedcomFile2.EndsWith(".GED"))
                            continue;
                        if (gedcomFile2.Equals(gedcomFile1))
                            continue;
                        swFile2 = Path.GetFileName(gedcomFile2);
                        //Console.WriteLine("Comparing " + gedcomFile1 + " and " + gedcomFile2);
                        GedcomParser.GedcomRecordReader grr2 = new GedcomParser.GedcomRecordReader();
                        grr2.GedcomFile = gedcomFile2;
                        try { grr2.ReadGedcom(); }
                        catch { continue; }
                        GedcomDatabase gd2 = grr2.Database;

                        GedcomDuplicate.DuplicateFoundFunc found = new GedcomDuplicate.DuplicateFoundFunc(FoundDuplicate);
                        float matchThreshold = 95;

                        GedcomDuplicate.FindDuplicates(gd1, gd2, matchThreshold, found);
                    }
                    sw.Flush();
                    swsn.Flush();
                }
                sw.Close();
                swsn.Close();
            }
            if (args.Length >= 2 && args[0].Equals("-surname"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    try
                    {
                        grr1.GedcomFile = gedcomFile1;
                        grr1.ReadGedcom();
                        GedcomDatabase gd1 = grr1.Database;
                        bool foundfile = false;

                        foreach (GedcomIndividualRecord rec in gd1.Individuals)
                        {
                            try
                            {
                                if (rec.Names.Count > 0 && rec.Names[0].Surname.ToUpper().Equals(surname))
                                {
                                    if (!foundfile)
                                    {
                                        Console.WriteLine("File " + gedcomFile1);
                                        foundfile = true;
                                    }
                                    Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                                    try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                                    catch { }
                                    try { Console.Write(" in " + rec.Birth.Place.Name); }
                                    catch { }
                                    try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                                    catch { }
                                    try { Console.Write(" at " + rec.Death.Place.Name); }
                                    catch { }
                                    Console.WriteLine();
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Can't read");
                            }
                        }
                    }
                    catch { }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-surfile"))
            {
                List<string> lstSurname = new List<string>();
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.TopDirectoryOnly);
                //string surname = args[2].ToUpper();
                
                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    try
                    {
                        grr1.GedcomFile = gedcomFile1;
                        grr1.ReadGedcom();
                        GedcomDatabase gd1 = grr1.Database;
                        bool foundfile = false;

                        if (!Directory.Exists(args[1] + "\\Surname"))
                            Directory.CreateDirectory(args[1] + "\\Surname");

                        foreach (GedcomIndividualRecord rec in gd1.Individuals)
                        {
                            try
                            {
                                StreamWriter sw;
                                if (rec.Names.Count > 0)
                                {
                                    string surname = rec.Names[0].Surname.Replace("(", "").Replace(")", "").Replace("_", "").Replace("?", "").Replace("[", "").Replace("]", "").Replace("\'", "").Replace("\\", "").Replace("/", "");
                                    if (!lstSurname.Contains(surname))
                                    {
                                        sw = new StreamWriter(args[1] + "\\Surname\\Surname_" + surname + ".csv", false);
                                        sw.WriteLine("File,Given,Surname,Birth Date,Birth Place,Death Date,Death Place");
                                        lstSurname.Add(surname);
                                    }
                                    else
                                        sw = new StreamWriter(args[1] + "\\Surname\\Surname_" + surname + ".csv", true);

                                    sw.Write("\"" + gedcomFile1 + "\"," + "\"" + rec.Names[0].Given + "\"," + "\"" + rec.Names[0].Surname + "\",");
                                    try { sw.Write("\"" + rec.Birth.Date.DateString + "\"," + "\"" + rec.Birth.Place.Name + "\","); }
                                    catch { sw.Write(",,"); }
                                    try { sw.WriteLine( "\"" + rec.Death.Date.DateString + "\"," + "\"" + rec.Death.Place.Name + "\"");}
                                    catch { sw.WriteLine(","); }
                                    sw.Close();
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Can't read: " + ex.Message + "-" + ex.StackTrace);
                            }
                            finally
                            {
                                if (sw != null)
                                    sw.Close();
                            }
                        }
                    }
                    catch { }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-birth"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        try
                        {
                            if (rec.Birth != null && rec.Birth.Place != null && rec.Birth.Place.Name != null && rec.Birth.Place.Name.ToUpper().Contains(surname))
                            {
                                if (!foundfile)
                                {
                                    Console.WriteLine("File " + gedcomFile1);
                                    foundfile = true;
                                }
                                Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                                try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                                catch { }
                                try { Console.Write(" in " + rec.Birth.Place.Name); }
                                catch { }
                                try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                                catch { }
                                try { Console.Write(" at " + rec.Death.Place.Name); }
                                catch { }
                                Console.WriteLine();
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Can't read:" + ex.Message + " : " + ex.StackTrace);
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-soundex"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);
                string surname = args[2].ToUpper();
                string sunameSoundex = Util.GenerateSoundex(surname);

                foreach (string gedcomFile1 in files)
                {
                    if (!gedcomFile1.ToUpper().EndsWith(".GED"))
                        continue;

                    //Console.WriteLine("Comparing " + gedcomFile1 + " for surname " + surname);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;
                    bool foundfile = false;

                    foreach (GedcomIndividualRecord rec in gd1.Individuals)
                    {
                        if (rec.Names[0].SurnameSoundex.Equals(sunameSoundex))
                        {
                            if (!foundfile)
                            {
                                Console.WriteLine("File " + gedcomFile1);
                                foundfile = true;
                            }
                            Console.Write("  Found " + rec.Names[0].Given + " " + rec.Names[0].Surname);
                            try { Console.Write(" Born: " + rec.Birth.Date.DateString); }
                            catch { }
                            try { Console.Write(" in " + rec.Birth.Place.Name); }
                            catch { }
                            try { Console.Write(" Died: " + rec.Death.Date.DateString); }
                            catch { }
                            try { Console.Write(" at " + rec.Death.Place.Name); }
                            catch { }
                            Console.WriteLine();
                        }
                    }

                }
            }

            if (args.Length >= 2 && args[0].Equals("-loaddir"))
            {
                string[] files = Directory.GetFiles(args[1], "*.*", SearchOption.AllDirectories);

                foreach (string gedcomFile1 in files)
                {
                    Console.WriteLine("Loading " + gedcomFile1);
                    GedcomParser.GedcomRecordReader grr1 = new GedcomParser.GedcomRecordReader();
                    grr1.GedcomFile = gedcomFile1;
                    grr1.ReadGedcom();
                    GedcomDatabase gd1 = grr1.Database;

                    foreach (GedcomIndividualRecord matchIndi in gd1.Individuals)
                    {
                        SaveDatabase(matchIndi);
                    }
                }
            }

            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-GEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoMatch = true;
                gm.DoGed = true;

                gm.loadGedMatch(args[2],true);
            }
            
            if (args.Length >= 2 && args[0].ToUpper().Equals("-GETGEDMATCH"))
            {
                GedMatch.GedMatch gm = new GedMatch.GedMatch();
                gm.WorkDir = args[1];
                gm.DoGed = true;

                gm.loadGedMatch(args[2], true);
            }
             
        }
예제 #45
0
        /// <summary>
        /// Property helper for Files &amp; WordFiles, ensures the data retrieved
        /// from those two properties is 'in sync'
        /// </summary>
        private void PrepareForSerialization()
        {
            if (_SerializePreparationDone) return;

            _FileList = new List<File>();
            _WordfileArray = new CatalogWordFile[_Index.Count];
            Word[] wordArray = new Word[_Index.Count];
            _Index.Values.CopyTo(wordArray, 0);

            // go through all the words
            for (int i = 0; i < wordArray.Length; i++)
            {
                // first, add all files to the 'flist' collection
                foreach (File f in wordArray[i].Files)
                {
                    if (!_FileList.Contains(f))
                    {
                        _FileList.Add(f);
                    }
                }
                // now go through again and use the indexes
                CatalogWordFile wf = new CatalogWordFile();
                wf.Text = wordArray[i].Text;
                foreach (File f in wordArray[i].Files)
                {
                    wf.FileIds.Add(_FileList.IndexOf(f));
                }
                _WordfileArray[i] = wf;
            }
            _SerializePreparationDone = true;
        }
예제 #46
0
 private void FillTreeViewColoringShowStatusTypeCombobox()
 {
     //System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>();
     // Shows
     foreach (string status in Enum.GetNames(typeof(ShowItem.ShowAirStatus)))
     {
         ShowStatusColoringType t = new ShowStatusColoringType(true, true, status);
         //System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Show Seasons Status: " + status, new ShowStatusColoringType(true, true, status));
         this.cboShowStatus.Items.Add(t);
         //this.cboShowStatus.Items.Add("Show Seasons Status: " + status);
     }
     System.Collections.Generic.List<string> showStatusList = new System.Collections.Generic.List<string>();
     List<ShowItem> shows = this.mDoc.GetShowItems(false);
     foreach (var show in shows)
     {
         if(!showStatusList.Contains(show.ShowStatus))
             showStatusList.Add(show.ShowStatus);
     }
     foreach (string status in showStatusList)
     {
         ShowStatusColoringType t = new ShowStatusColoringType(false, true, status);
         //System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Show  Status: " + status, new ShowStatusColoringType(false, true, status));
         this.cboShowStatus.Items.Add(t);
     }
     //this.cboShowStatus.Items.Add(new System.Collections.Generic.KeyValuePair<string, object>("Show Seasons Status: Custom", null));
     // Seasons
     foreach (string status in Enum.GetNames(typeof(Season.SeasonStatus)))
     {
         ShowStatusColoringType t = new ShowStatusColoringType(true, false, status);
         //System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Seasons Status: " + status, new ShowStatusColoringType(true, false, status));
         this.cboShowStatus.Items.Add(t);
         //this.cboShowStatus.Items.Add("Seasons Status: " + status);
     }
     this.cboShowStatus.DisplayMember = "Text";
     //this.cboShowStatus.ValueMember = ";
 }
예제 #47
0
		/// <summary>
		/// Make sure the list of ASP.NET roles is synchronized with the Gallery Server roles. If any are missing from 
		/// either, add it.
		/// </summary>
		private static void ValidateRoles()
		{
			System.Collections.Generic.List<IGalleryServerRole> validatedRoles = new System.Collections.Generic.List<IGalleryServerRole>();
			IGalleryServerRoleCollection galleryRoles = GalleryServerPro.Business.Factory.LoadGalleryServerRoles();
			bool needToPurgeCache = false;

			foreach (string roleName in Roles.GetAllRoles())
			{
				IGalleryServerRole galleryRole = galleryRoles.GetRoleByRoleName(roleName);
				if (galleryRole == null)
				{
					// This is an ASP.NET role that doesn't exist in our list of gallery server roles. Add it with minimum permissions
					// applied to zero albums.
					IGalleryServerRole newRole = GalleryServerPro.Business.Factory.CreateGalleryServerRoleInstance(roleName, false, false, false, false, false, false, false, false, false, false, false, false);
					newRole.Save();
					needToPurgeCache = true;
				}
				validatedRoles.Add(galleryRole);
			}

			// Now check to see if there are gallery roles that are not ASP.NET roles. Add if necessary.
			foreach (IGalleryServerRole galleryRole in galleryRoles)
			{
				if (!validatedRoles.Contains(galleryRole))
				{
					// Need to create an ASP.NET role for this gallery role.
					System.Web.Security.Roles.CreateRole(galleryRole.RoleName);
					needToPurgeCache = true;
				}
			}

			if (needToPurgeCache)
			{
				Gsp.HelperFunctions.PurgeCache();
			}
		}
예제 #48
0
        private void RefreshTreeviewNodeFormatting(TreeNode treeNode)
        {
            Cursor origCursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            //if (isFolder(treeNode))
            if (treeNode.Nodes.Count > 0)
            {
                // First rename (title) the node items...
                //value = "{get_accession.accession_number_part1} + \" \" + {get_accession.accession_number_part2} + \" \" + {get_accession.accession_number_part3}; ";
                System.Collections.Generic.Dictionary<string, string> idTypeFormattingFormula = new System.Collections.Generic.Dictionary<string, string>();
                System.Collections.Generic.List<string> idTypes = new System.Collections.Generic.List<string>();
                System.Collections.Generic.Dictionary<string, string> idNumbers = new System.Collections.Generic.Dictionary<string, string>();
                DataSet ds = new DataSet();

                // First find all of the distinct ID_TYPES,
                // their corresponding formatting formulas,
                // and gather all of the ID_NUMBERS for each ID_TYPE in the userItemList collection...
                foreach (TreeNode tn in treeNode.Nodes)
                {
                    if (!isFolder(tn))
                    {
            //string pKey = tn.Tag.ToString().Split(';')[1].Trim();
            //string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
            //string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
            string[] pKey = tn.Name.Split('=');
            string nodePKeyType = pKey[0];
            string nodePKeyValue = pKey[1];

                        // Get the ID_TYPE...
                        if (!idTypes.Contains(nodePKeyType)) idTypes.Add(nodePKeyType);
                        // Now get the formatting formula for each ID_TYPE in the collection...
                        if (!idTypeFormattingFormula.ContainsKey(nodePKeyType))
                        {
                            //string formula = GetTreeviewNodeProperty(nodePKeyType + "_NAME_FORMULA", tn);
                            string formula = GetTreeviewNodeProperty(tn.Tag.ToString().Split(';')[0].Trim().ToUpper() + "_NAME_FORMULA", tn, true, "");
                            if (string.IsNullOrEmpty(formula))
                            {
                                // Could not find a formula for this type of treenode object type...
                            }
                            idTypeFormattingFormula.Add(nodePKeyType, formula);
                        }
                        // Next collect all of the ID_NUMBERS for each of the ID_TYPES for the userItemList collection...
                        if (!idNumbers.ContainsKey(nodePKeyType))
                        {
                            idNumbers.Add(nodePKeyType, nodePKeyValue + ",");
                        }
                        else
                        {
                            idNumbers[nodePKeyType] = idNumbers[nodePKeyType] + nodePKeyValue + ",";
                        }
                    }
                    else
                    {
                        if (ux_checkboxIncludeSubFolders.Checked)
                        {
                            RefreshTreeviewNodeFormatting(tn);
                        }
                    }
                }

                Dictionary<string, Dictionary<int, string>> friendlyNames = new Dictionary<string,Dictionary<int,string>>();

                // Make all the trips to the server now to get all data needed for new userItemList titles...
                foreach (string idType in idTypes)
                {
                    // Create the new dictionary LU for the friendly name and add it to the collection...
                    friendlyNames.Add(idType, new Dictionary<int, string>());

                    // Break down the name formula into tokens and process the tokens one by one...
                    string[] formatTokens = idTypeFormattingFormula[idType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
                    string staticTextSeparator = "";
                    foreach (string formatToken in formatTokens)
                    {
                        if (formatToken.Contains("{") &&
                            formatToken.Contains("}"))
                        {
                            // This is a DB field used in the title - so if we don't already have it go get it now...
                            string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
                            if (!ds.Tables.Contains(dataviewAndField[0]))
                            {
                                DataSet newDS = _sharedUtils.GetWebServiceData(dataviewAndField[0], idType.Trim().ToLower() + "=" + idNumbers[idType].Trim().TrimEnd(','), 0, 0);
                                if (newDS != null &&
                                    newDS.Tables.Contains(dataviewAndField[0]))
                                {
                                    ds.Tables.Add(newDS.Tables[dataviewAndField[0]].Copy());
                                }
            else if (newDS.Tables.Contains("ExceptionTable") &&
            newDS.Tables["ExceptionTable"].Rows.Count > 0)
            {
            GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data from {0} to use in building a node friendly name.\n\nFull error message:\n{1}", "Get Name Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
            ggMessageBox.Name = "RefreshTreeviewNodeFormatting1";
            _sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
            //if (ggMessageBox.MessageText.Contains("{0}") &&
            //    ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0], newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            //}
            //else if (ggMessageBox.MessageText.Contains("{0}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0]);
            //}
            //else if (ggMessageBox.MessageText.Contains("{1}"))
            //{
            //    ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
            //}
            string[] argsArray = new string[100];
            argsArray[0] = dataviewAndField[0];
            argsArray[1] = newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString();
            ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
            ggMessageBox.ShowDialog();
            }
                            }
                            // Process all of the rows in the table to add the dbToken to the friendly name...
                            // But first check to make sure the field exists in the datatable (if it doesn't exist just skip it)...
                            if (ds != null &&
                                ds.Tables.Count > 0 &&
                                ds.Tables[dataviewAndField[0]].Columns.Contains(dataviewAndField[1]))
                            {
                                foreach (DataRow dr in ds.Tables[dataviewAndField[0]].Rows)
                                {
                                    int pkey;
                                    string dbTokenText = dr[dataviewAndField[1]].ToString();
                                    DataColumn dc = ds.Tables[dataviewAndField[0]].Columns[dataviewAndField[1]];

                                    if (int.TryParse(dr[ds.Tables[dataviewAndField[0]].PrimaryKey[0]].ToString(), out pkey) &&
                                        !string.IsNullOrEmpty(dbTokenText))
                                    {
                                        // Resolve fkeys and code_values to the display_member if necessary...
                                        if (_sharedUtils.LookupTablesIsValidFKField(dc))
                                        {
                                            dbTokenText = _sharedUtils.GetLookupDisplayMember(dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim(), dbTokenText, "", dbTokenText);
                                        }
                                        else if (_sharedUtils.LookupTablesIsValidCodeValueField(dc))
                                        {
                                            dbTokenText = _sharedUtils.GetLookupDisplayMember("code_value_lookup", dbTokenText, dc.ExtendedProperties["group_name"].ToString(), dbTokenText);
                                        }
                                        // If the pkey is already in the dictionary append to it (otherwise add it)...
                                        if (friendlyNames[idType].ContainsKey(pkey))
                                        {
                                            friendlyNames[idType][pkey] += staticTextSeparator + dbTokenText;
                                        }
                                        else
                                        {
                                            friendlyNames[idType][pkey] = staticTextSeparator + dbTokenText;
                                        }
                                    }
                                }
                            }
                            staticTextSeparator = "";
                        }
                        else
                        {
                            staticTextSeparator += formatToken.Trim().Replace("\"", "");
                        }
                    }
                    if (!string.IsNullOrEmpty(staticTextSeparator))
                    {
                        for (int i = 0; i < friendlyNames[idType].Keys.Count; i++)
                        {
                            friendlyNames[idType][friendlyNames[idType].ElementAt(i).Key] += staticTextSeparator;
                        }
                    }
                }

                // Now refresh the titles for each item in the collection...
                // This next line REALLY speeds things up (it tells the control to stop painting during a major update)...
                treeNode.TreeView.BeginUpdate();
                foreach (TreeNode tn in treeNode.Nodes)
                {
                    if (!isFolder(tn))
                    {
                        string[] pKey = tn.Name.Split('=');
                        string nodePKeyType = pKey[0];
                        string nodePKeyValue = pKey[1];
                        int pkey;
                        //
                        if (int.TryParse(nodePKeyValue, out pkey) &&
                            friendlyNames[nodePKeyType].ContainsKey(pkey))
                        {
                            string title = friendlyNames[nodePKeyType][pkey];
                            tn.Text = title;
                            title = EnsureUniqueNodeText(treeNode, tn);
                            tn.Text = title.Trim();
                        }
                    }
                }
                // We are all done updating names so now we can let the treeview resume painting its display...
                treeNode.TreeView.EndUpdate();

            //                foreach (TreeNode tn in treeNode.Nodes)
            //                {
            //                    if (!isFolder(tn))
            //                    {
            ////string pKey = tn.Tag.ToString().Split(';')[1].Trim();
            ////string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
            ////string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
            //string[] pKey = tn.Name.Split('=');
            //string nodePKeyType = pKey[0];
            //string nodePKeyValue = pKey[1];

            //                        string title = "";
            //                        string[] formatTokens = idTypeFormattingFormula[nodePKeyType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
            //                        foreach (string formatToken in formatTokens)
            //                        {
            //                            if (formatToken.Contains("{") &&
            //                                formatToken.Contains("}"))
            //                            {
            //                                // This is a DB field used in the title - so go get it...
            //                                string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
            //                                if (dataviewAndField.Length == 2)
            //                                {
            //                                    if (ds.Tables.Contains(dataviewAndField[0]) &&
            //                                        ds.Tables[dataviewAndField[0]].Rows.Count > 0 &&
            //                                        ds.Tables[dataviewAndField[0]].Columns.Contains(dataviewAndField[1]))
            //                                    {
            //                                        // The list of dataviews that can be used for building node titles must have a pkey that is one of the ID_TYPES
            //                                        // otherwise this next line won't work...
            //                                        DataRow tokenRawDataRow = ds.Tables[dataviewAndField[0]].Rows.Find(nodePKeyValue);
            //                                        if (tokenRawDataRow != null)
            //                                        {
            //                                            DataColumn dc = tokenRawDataRow.Table.Columns[dataviewAndField[1]];
            //                                            string valueMember = tokenRawDataRow[dataviewAndField[1]].ToString();
            //                                            if (_sharedUtils.LookupTablesIsValidFKField(dc) &&
            //                                                !string.IsNullOrEmpty(valueMember))
            //                                            {
            //                                                title += _sharedUtils.GetLookupDisplayMember(dc.ExtendedProperties["foreign_key_dataview_name"].ToString().Trim(), valueMember, "", valueMember);
            //                                            }
            //                                            else if (_sharedUtils.LookupTablesIsValidCodeValueField(dc) &&
            //                                                    !string.IsNullOrEmpty(valueMember))
            //                                            {
            ////title += _sharedUtils.GetLookupDisplayMember("code_value_lookup", valueMember, "", valueMember);
            //                                                title += _sharedUtils.GetLookupDisplayMember("code_value_lookup", valueMember, dc.ExtendedProperties["group_name"].ToString(), valueMember);
            //                                            }
            //                                            else
            //                                            {
            //                                                title += valueMember;
            //                                            }
            //                                        }
            //                                    }
            //                                }
            //                            }
            //                            else
            //                            {
            //                                title += formatToken.Trim().Replace("\"", "");
            //                            }
            //                        }
            //                        // If there was success in building a new node title and it is a different name than the old title, make sure it is unique and then replace the old title...
            //                        if (!string.IsNullOrEmpty(title))
            //                        {
            //                            tn.Text = title;
            //title = EnsureUniqueNodeText(treeNode, tn);
            //tn.Text = title.Trim();
            //                        }
            //                    }

            //                }

                // Now resort the items...
                string sortMode = GetTreeviewNodeProperty("SORT_MODE", treeNode, true, "MANUAL");
                string folderGroupingMode = GetTreeviewNodeProperty("FOLDER_GROUPING_MODE", treeNode, true, "TOP");
                if (isFolder(treeNode) && sortMode.ToUpper().Trim() != "MANUAL") sortFolder(treeNode, sortMode);
            }

            /*
            // Find the user_item_list row corresponding to this node...
            if (isFolder(treeNode))
            {
                // First rename (title) the node items...
                RefreshUserItemListTitles(drcItems);
                // Now resort the items...
                // Get the sort settings from the folder (actually it will come from the parent of the collection items)...
                if (drcItems.Length > 0)
                {
                    string sortMode = GetUserItemListProperty("SORT_MODE", drcItems[0]);
                    string folderGroupingMode = GetUserItemListProperty("FOLDER_GROUPING_MODE", drcItems[0]);
                    SortUserItemList(tabText, treeNode, sortMode, folderGroupingMode == "TOP");
                }
            }
            */
            // Restore cursor to default cursor...
            Cursor.Current = origCursor;
        }
 private void FillTerminalFilterList()
 {
     this.cbTerminals.Items.Clear();
     System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
     foreach (System.Data.DataRow row in this.m_DtRequests.Rows)
     {
         if (!list.Contains(row.get_Item("terminal").ToString()))
         {
             list.Add(row.get_Item("terminal").ToString());
         }
     }
     this.cbTerminals.Items.AddRange(list.ToArray());
 }
예제 #50
0
        public void Test_AddDirectoryByName_Nested()
        {
            Directory.SetCurrentDirectory(TopLevelDir);
            var dirsAdded = new System.Collections.Generic.List<String>();
            string zipFileToCreate = Path.Combine(TopLevelDir, "Test_AddDirectoryByName_Nested.zip");
            using (ZipFile zip1 = new ZipFile())
            {
                for (int n = 1; n <= 14; n++)
                {
                    string DirName = n.ToString();
                    for (int i = 0; i < n; i++)
                    {
                        // create an arbitrary directory name, add it to the zip archive
                        DirName = Path.Combine(DirName, TestUtilities.GenerateRandomAsciiString(11));
                    }
                    zip1.AddDirectoryByName(DirName);
                    dirsAdded.Add(DirName.Replace("\\", "/") + "/");
                }
                zip1.Save(zipFileToCreate);
            }

            int dirCount = 0;
            using (ZipFile zip2 = FileSystemZip.Read(zipFileToCreate))
            {
                foreach (var e in zip2)
                {
                    TestContext.WriteLine("dir: {0}", e.FileName);
                    Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected directory.");
                    Assert.IsTrue(e.IsDirectory);
                    dirCount++;
                }
            }
            Assert.AreEqual<int>(dirsAdded.Count, dirCount);
        }
예제 #51
0
    public static string[] GetInstalledPlugInFolders()
    {
      System.Collections.Generic.List<string> dirs = new System.Collections.Generic.List<string>(32);
      for( int i=0; i<m_plugins.Count; i++ )
      {
        var dir = System.IO.Path.GetDirectoryName(m_plugins[i].Assembly.Location);
        if( !dirs.Contains(dir) )
          dirs.Add(dir);
      }

      int count = InstalledPlugInCount;
      for (int i = 0; i < count; i++)
      {
        IntPtr pFile = UnsafeNativeMethods.CRhinoPlugInManager_GetFileName(i);
        if (pFile != IntPtr.Zero)
        {
          string path = Marshal.PtrToStringUni(pFile);
          if (System.IO.File.Exists(path))
          {
            path = System.IO.Path.GetDirectoryName(path);
            if (dirs.Contains(path))
              continue;
            dirs.Add(path);
          }
        }
      }
      return dirs.ToArray();
    }
예제 #52
0
 public void ShowSelectedOrganization(string childrenYK, ObjectList<Organization> orgs, Organization m_provider)
 {
     this.provider = m_provider;
     System.Collections.Generic.List<Organization> list = new System.Collections.Generic.List<Organization>();
     foreach (Organization organization in orgs)
     {
         if ((organization.ToString() == childrenYK) && !list.Contains(organization))
         {
             list.Add(organization);
             break;
         }
     }
     foreach (Organization organization2 in list)
     {
         base.Nodes.Add(new OrganizationNode(organization2, m_provider));
     }
 }
예제 #53
0
        public void Test_AddDirectoryByName()
        {
            for (int n = 1; n <= 10; n++)
            {
                var dirsAdded = new System.Collections.Generic.List<String>();
                string zipFileToCreate = Path.Combine(TopLevelDir, String.Format("Test_AddDirectoryByName{0:N2}.zip", n));
                using (ZipFile zip1 = new ZipFile())
                {
                    for (int i = 0; i < n; i++)
                    {
                        // create an arbitrary directory name, add it to the zip archive
                        string dirName = TestUtilities.GenerateRandomName(24);
                        zip1.AddDirectoryByName(dirName);
                        dirsAdded.Add(dirName + "/");
                    }
                    zip1.Save(zipFileToCreate);
                }


                int dirCount = 0;
                using (ZipFile zip2 = FileSystemZip.Read(zipFileToCreate))
                {
                    foreach (var e in zip2)
                    {
                        TestContext.WriteLine("dir: {0}", e.FileName);
                        Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected entry");
                        Assert.IsTrue(e.IsDirectory);
                        dirCount++;
                    }
                }
                Assert.AreEqual<int>(n, dirCount);
            }
        }
예제 #54
0
        private void FixList()
        {
            StoreDBEntities storeDBEntities = new StoreDBEntities();

            System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
            System.Collections.Generic.List<long> list2 = new System.Collections.Generic.List<long>();
            System.Collections.Generic.List<long> list3 = new System.Collections.Generic.List<long>();
            System.Collections.Generic.List<DailyTransaction> list4 = (
                from x in storeDBEntities.DailyTransactions
                orderby x.Date
                select x).ToList<DailyTransaction>();
            for (int i = 0; i < list4.Count; i++)
            {
                if (!list.Contains(list4[i].Date))
                {
                    list.Add(list4[i].Date);
                    list2.Add(0L);
                    list3.Add(0L);
                }
                if (list4[i].Payment)
                {
                    System.Collections.Generic.List<long> list5;
                    int index;
                    (list5 = list2)[index = list.IndexOf(list4[i].Date)] = list5[index] + list4[i].Price;
                }
                else
                {
                    System.Collections.Generic.List<long> list6;
                    int index2;
                    (list6 = list3)[index2 = list.IndexOf(list4[i].Date)] = list6[index2] + list4[i].Price;
                }
            }
            ListViewItem[] array = new ListViewItem[list.Count];
            for (int j = 0; j < list.Count; j++)
            {
                long num = list2[j] - list3[j];
                array[j] = new ListViewItem(new string[]
				{
					list[j],
					list2[j].ToString("0,0"),
					list3[j].ToString("0,0"),
					((num > 0L) ? "+" : "") + num.ToString("0,0")
				});
                if (num != 0L)
                {
                    array[j].SubItems[3].ForeColor = System.Drawing.Color.OrangeRed;
                }
            }
            this.lstAllTrans.Items.Clear();
            this.lstAllTrans.Items.AddRange(array);
            lstAllTrans.EnsureVisible(lstAllTrans.Items.Count - 1);
            Utilities.ListViewFixColumns(lstAllTrans);
        }
예제 #55
0
        public void Test_AddDirectoryByName_WithFiles()
        {
            Directory.SetCurrentDirectory(TopLevelDir);

            var dirsAdded = new System.Collections.Generic.List<String>();
            string password = TestUtilities.GenerateRandomPassword();
            string zipFileToCreate = Path.Combine(TopLevelDir, "Test_AddDirectoryByName_WithFiles.zip");
            using (ZipFile zip1 = new ZipFile())
            {
                string dirName = null;
                int T = 3 + _rnd.Next(4);
                for (int n = 0; n < T; n++)
                {
                    // nested directories
                    dirName = (n == 0) ? "root" :
                        Path.Combine(dirName, TestUtilities.GenerateRandomAsciiString(8));

                    zip1.AddDirectoryByName(dirName);
                    dirsAdded.Add(dirName.Replace("\\", "/") + "/");
                    if (n % 2 == 0) zip1.Password = password;
                    zip1.AddEntry(Path.Combine(dirName, new System.String((char)(n + 48), 3) + ".txt"), "Hello, Dolly!");
                    if (n % 2 == 0) zip1.Password = null;
                }
                zip1.Save(zipFileToCreate);
            }

            int entryCount = 0;
            using (ZipFile zip2 = FileSystemZip.Read(zipFileToCreate))
            {
                foreach (var e in zip2)
                {
                    TestContext.WriteLine("e: {0}", e.FileName);
                    if (e.IsDirectory)
                        Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected directory.");
                    else
                    {
                        if ((entryCount - 1) % 4 == 0) e.Password = password;
                        string output = StreamToStringUTF8(e.OpenReader());
                        Assert.AreEqual<string>("Hello, Dolly!", output);
                    }
                    entryCount++;
                }
            }
            Assert.AreEqual<int>(dirsAdded.Count * 2, entryCount);
        }
예제 #56
0
        private void buttonExchNoCountries_Click(object sender, EventArgs e)
        {
            string[] split = textBoxNoCountries.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            List<string> dictionary = new System.Collections.Generic.List<string>();

            foreach (string s in split)
            {
                string ext = s.Substring(s.IndexOf(":") + 1);
                if (!dictionary.Contains(ext))
                {
                    dictionary.Add(ext);
                    Console.WriteLine(ext);
                }
            }
        }
예제 #57
0
        public void ShowOrganizations(ObjectList<Organization> orgs)
        {
            this.m_LastSetOrgs = orgs;
            base.Nodes.Clear();
            System.Collections.Generic.List<Organization> list = new System.Collections.Generic.List<Organization>();
            foreach (Organization organization in orgs)
            {
                if (organization.Parent == Organization.Null)
                {
                    if (!list.Contains(organization))
                    {
                        list.Add(organization);
                    }
                }
                else
                {
                    Organization parent = organization.Parent;
                    while (parent.Parent != Organization.Null)
                    {
                        parent = parent.Parent;
                    }
                    if (!list.Contains(parent))
                    {
                        list.Add(parent);
                    }
                }
            }
            switch (Manager.SortOrder)
            {
                case ChiefSortOrders.ByName:
                    list.Sort(new ShortNameComparer<Organization>());
                    break;

                case ChiefSortOrders.ByCode:
                    list.Sort(new CodeNameComparer<Organization>());
                    break;
            }
            foreach (Organization organization3 in list)
            {
                base.Nodes.Add(new OrganizationNode(organization3));
            }
        }
예제 #58
0
 /// <summary>
 /// 数组打乱顺序(返回arraylist)
 /// </summary>
 ///   
 public List<User> RandomSort(List<User> array)
 {
     int len = array.Count;
     System.Collections.Generic.List<int> list = new System.Collections.Generic.List<int>();
     List<User> newlist = new List<User>();
     Random rand = new Random();
     int i = 0;
     while (list.Count < len)
     {
         int iter = rand.Next(0, len);
         if (!list.Contains(iter))
         {
             list.Add(iter);
             newlist.Add(array[iter]);
             i++;
         }
     }
     return newlist;
 }