コード例 #1
0
        /// <summary>
        /// Returns the value of one of the text attributes from the expected result of the given name.
        /// </summary>
        public string GetExpectedResultText(EntityEnum entity, ExpectedResult expectedResult)
        {
            if (expectedResult == null)
            {
                return(string.Empty);
            }

            switch (entity)
            {
            case EntityEnum.Given:
                return((expectedResult.Given == null) ? string.Empty : expectedResult.Given);

            case EntityEnum.Name:
                return((expectedResult.Name == null) ? string.Empty : expectedResult.Name);

            case EntityEnum.Value:
                return((expectedResult.Text == null) ? string.Empty : expectedResult.Text);

            case EntityEnum.Condition:
                return((expectedResult.Condition == null) ? string.Empty : expectedResult.Condition);

            default:
                return(string.Empty);
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns the value of one of the text attributes from the input parameter of the given name.
        /// </summary>
        public string GetInputParameterText(EntityEnum entity, InputParameter inputParameter)
        {
            if (inputParameter == null)
            {
                return(string.Empty);
            }

            switch (entity)
            {
            case EntityEnum.Given:
                return((inputParameter.Given == null) ? string.Empty : inputParameter.Given);

            case EntityEnum.Name:
                return((inputParameter.Name == null) ? string.Empty : inputParameter.Name);

            case EntityEnum.Value:
                return((inputParameter.Text == null) ? string.Empty : inputParameter.Text);

            case EntityEnum.Condition:
                return((inputParameter.Condition == null) ? string.Empty : inputParameter.Condition);

            default:
                return(string.Empty);
            }
        }
コード例 #3
0
        public static EntityTypeCollection GetCollection(EntityEnum entityName)
        {
            EntityTypeCollection tempList = null;
           
            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetEntityType", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollectionByName);
                    myCommand.Parameters.AddWithValue("@EntityName", entityName.ToString());
                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new EntityTypeCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }

                        }
                        myReader.Close();
                    }
                }
            }

            return tempList;
        }
コード例 #4
0
        /// <summary>
        /// Sets the value of one of the text attributes in the expected result of the given name.
        /// </summary>
        public void SetExpectedResultText(EntityEnum entity, string expectedResultName, string text)
        {
            ExpectedResult expectedResult = GetExpectedResult(expectedResultName);

            if (expectedResult == null)
            {
                return;
            }

            switch (entity)
            {
            case EntityEnum.Given:
                expectedResult.Given = text;
                break;

            case EntityEnum.Name:
                expectedResult.Name = text;
                break;

            case EntityEnum.Value:
                expectedResult.Text = text;
                break;

            case EntityEnum.Condition:
                expectedResult.Condition = text;
                expectedResult.ParseConditions();
                break;

            default:
                break;
            }
        }
コード例 #5
0
        /// <summary>
        /// Sets the value of one of the text attributes in the parameter's equivalence class of the given name.
        /// </summary>
        public void SetEquivalenceClassText(EntityEnum entity, string parameterName, string equivalenceClassName, string text)
        {
            EquivalenceClass equivalenceClass = GetEquivalenceClass(parameterName, equivalenceClassName);

            if (equivalenceClass == null)
            {
                return;
            }

            switch (entity)
            {
            case EntityEnum.Given:
                equivalenceClass.Given = text;
                break;

            case EntityEnum.Name:
                equivalenceClass.Name = text;
                break;

            case EntityEnum.Value:
                equivalenceClass.Text = text;
                break;

            case EntityEnum.Condition:
                equivalenceClass.Condition = text;
                equivalenceClass.ParseConditions();
                break;

            default:
                break;
            }
        }
コード例 #6
0
        /// <summary>
        /// Sets the value of one of the text attributes in the input parameter of the given name.
        /// </summary>
        public void SetInputParameterText(EntityEnum entity, string parameterName, string text)
        {
            InputParameter inputParameter = GetInputParameter(parameterName);

            if (inputParameter == null)
            {
                return;
            }

            switch (entity)
            {
            case EntityEnum.Given:
                inputParameter.Given = text;
                break;

            case EntityEnum.Name:
                inputParameter.Name = text;
                break;

            case EntityEnum.Value:
                inputParameter.Text = text;
                break;

            case EntityEnum.Condition:
                inputParameter.Condition = text;
                inputParameter.ParseConditions();
                break;

            default:
                break;
            }
        }
コード例 #7
0
ファイル: Despawner.cs プロジェクト: csg1233/zombie
        private async Task OnTick()
        {
            await Delay(SpawnerHost.SPAWN_TICK_RATE);

            foreach (Prop prop in EntityEnum.GetProps())
            {
                if (prop.HasDecor(SpawnerHost.SPAWN_DESPAWN_DECOR))
                {
                    prop.MarkAsNoLongerNeeded();
                }
            }

            foreach (Ped ped in EntityEnum.GetPeds())
            {
                if (ped.HasDecor(SpawnerHost.SPAWN_DESPAWN_DECOR))
                {
                    ped.MarkAsNoLongerNeeded();
                }
            }

            foreach (Vehicle veh in EntityEnum.GetVehicles())
            {
                if (veh.HasDecor(SpawnerHost.SPAWN_DESPAWN_DECOR))
                {
                    veh.MarkAsNoLongerNeeded();
                }
            }
        }
コード例 #8
0
        public static EntityTypeCollection GetCollection(EntityEnum entityName)
        {
            EntityTypeCollection tempList = null;

            using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString))
            {
                using (SqlCommand myCommand = new SqlCommand("usp_GetEntityType", myConnection))
                {
                    myCommand.CommandType = CommandType.StoredProcedure;

                    myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollectionByName);
                    myCommand.Parameters.AddWithValue("@EntityName", entityName.ToString());

                    myConnection.Open();
                    using (SqlDataReader myReader = myCommand.ExecuteReader())
                    {
                        if (myReader.HasRows)
                        {
                            tempList = new EntityTypeCollection();
                            while (myReader.Read())
                            {
                                tempList.Add(FillDataRecord(myReader));
                            }
                        }
                        myReader.Close();
                    }
                }
            }
            return(tempList);
        }
コード例 #9
0
        /// <summary>
        /// Returns the value of one of the text attributes from the parameter's equivalence class of the given name.
        /// </summary>
        public string GetEquivalenceClassText(EntityEnum entity, EquivalenceClass equivalenceClass)
        {
            if (equivalenceClass == null)
            {
                return(string.Empty);
            }

            switch (entity)
            {
            case EntityEnum.Given:
                return((equivalenceClass.Given == null) ? string.Empty : equivalenceClass.Given);

            case EntityEnum.Name:
                return((equivalenceClass.Name == null) ? string.Empty : equivalenceClass.Name);

            case EntityEnum.Value:
                return((equivalenceClass.Text == null) ? string.Empty : equivalenceClass.Text);

            case EntityEnum.Condition:
                return((equivalenceClass.Condition == null) ? string.Empty : equivalenceClass.Condition);

            default:
                return(string.Empty);
            }
        }
コード例 #10
0
        public static EntityTypeCollection GetCollection(EntityEnum entityName)
        {
            //Call DAL to retrieve collection, the parameter passes the entire EntityEnum
            EntityTypeCollection entityTypeCollection = EntityTypeDAL.GetCollection(entityName);

            //Return collection object
            return entityTypeCollection;
        }
コード例 #11
0
        static void MarkAs(EntityEnum pType, Point pPosition)
        {
            var mapIndex = CalculateMapPosition(pPosition);

            if (mapIndex >= 0 && mapIndex < map.Length)
            {
                map[mapIndex] = entitiesByEnum[pType].Id;
            }
        }
コード例 #12
0
ファイル: RebelSquadSpawner.cs プロジェクト: csg1233/zombie
 private void HandleRebelSquads()
 {
     foreach (Ped ped in EntityEnum.GetPeds())
     {
         if (ped.HasDecor(REBELSQUAD_DECOR))
         {
             ped.RelationshipGroup.SetRelationshipBetweenGroups(Game.PlayerPed.RelationshipGroup, Relationship.Hate, true);
         }
     }
 }
コード例 #13
0
 private void HandleArmyHeliSquads()
 {
     foreach (Ped ped in EntityEnum.GetPeds())
     {
         if (ped.HasDecor(ARMYHELI_DECOR))
         {
             ped.RelationshipGroup.SetRelationshipBetweenGroups(Game.PlayerPed.RelationshipGroup, Relationship.Like, true);
         }
     }
 }
コード例 #14
0
        public void ReplacePermissions(EntityEnum fromEntity, long fromId, EntityEnum toEntity, long toId)
        {
            var permissionsToRemove = GetPermissionList(toId).Select(p => p).ToList();

            this.Context.Permissions.RemoveRange(permissionsToRemove);

            var permissionsToAdd = GetPermissionList(fromId)
                                   .Select(p => new { permissionId = p.PermissionId, type = p.PermissionTypeId, referenceId = p.ReferenceId, referenceEntityId = p.ReferenceEntityId }).ToList();

            permissionsToAdd.ForEach(p => AddPermission(p.permissionId, toEntity, toId, p.referenceEntityId, (int)p.referenceId, p.type));
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewImport" /> class.
 /// </summary>
 /// <param name="entity">The name of the entity that was imported. (required).</param>
 public NewImport(EntityEnum entity = default(EntityEnum))
 {
     // to ensure "entity" is required (not null)
     if (entity == null)
     {
         throw new InvalidDataException("entity is a required property for NewImport and cannot be null");
     }
     else
     {
         this.Entity = entity;
     }
 }
コード例 #16
0
        public void CopyPermissions(EntityEnum fromEntity, long fromId, EntityEnum toEntity, long toId)
        {
            var permissionsToAdd = GetPermissionList(fromId)
                                   .Select(p => new
            {
                permissionId      = p.PermissionId,
                type              = p.PermissionTypeId,
                referenceEntityId = p.ReferenceEntityId,
                referenceId       = p.ReferenceId
            }).ToList();

            permissionsToAdd
            .ForEach(p => AddPermission(p.permissionId, toEntity, toId, p.referenceEntityId, (int)p.referenceId, p.type));
        }
コード例 #17
0
        private async Task OnTick()
        {
            await Delay(100);

            foreach (Ped ped in EntityEnum.GetPeds())
            {
                if (ped != Game.PlayerPed)
                {
                    ped.AlwaysKeepTask = true;
                    ped.Task.ChatTo(Game.PlayerPed);
                    ped.PlayAmbientSpeech("goodbye_across_street", SpeechModifier.ForceShouted);
                }
            }
        }
コード例 #18
0
ファイル: Entity.cs プロジェクト: vebin/base
        /// <summary>
        ///
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <returns></returns>
        protected long CreateId(EntityEnum datacenterId)
        {
            if (_idWorker == null)
            {
                _idWorker = new IdWorker(GetWorkerId(), (int)datacenterId);
                _sdt      = DateTime.Today;
            }
            else if (_sdt < DateTime.Now.AddDays(-1))
            {
                _idWorker = new IdWorker(GetWorkerId(), (int)datacenterId);
                _sdt      = DateTime.Today;
            }

            return(_idWorker.NextId());
        }
コード例 #19
0
        private void HandleZombies()
        {
            foreach (Ped ped in EntityEnum.GetPeds())
            {
                if (ped.HasDecor(ZOMBIE_DECOR))
                {
                    ped.Voice = "ALIENS";
                    ped.IsPainAudioEnabled = false;
                    ped.RelationshipGroup.SetRelationshipBetweenGroups(Game.PlayerPed.RelationshipGroup, Relationship.Hate, true);

                    API.RequestAnimSet("move_m@drunk@verydrunk");
                    API.SetPedMovementClipset(ped.Handle, "move_m@drunk@verydrunk", 1f);
                }
            }
        }
コード例 #20
0
        public long AddPermission(long?parentPermissionId, EntityEnum objectEntityType, long objectId, EntityEnum?entityReferenceType, int referenceId, PermissionTypeEnum type)
        {
            var newPermissionId = this.Context.GenerateNextLongId();

            this.Context.Permissions.Add(new Permission
            {
                PermissionId       = newPermissionId,
                ParentPermissionId = parentPermissionId,
                ObjectEntityId     = objectEntityType,
                ObjectId           = objectId,
                PermissionTypeId   = type,
                ReferenceEntityId  = entityReferenceType,
                ReferenceId        = referenceId
            });

            return(newPermissionId);
        }
コード例 #21
0
        public List <long> PermissionsUpdate(EntityEnum parentObjectEntity, long?parentObjectId, EntityEnum objectEntity, long?objectId, List <PermissionListModel> permissionList, PermissionTypeEnum type)
        {
            if (objectId == null || default(long) == objectId || permissionList == null)
            {
                return(null);
            }

            var dbSelection = this.Context.Permissions.Where(p => p.ObjectId == objectId && p.PermissionTypeId == type).Select(r => r).ToList();

            var dbSelectionIds = dbSelection.Select(p =>
                                                    new
            {
                p.ReferenceId,
                p.ReferenceEntityId
            }).ToList();

            var newSelection = permissionList.Where(s => s.IsSelected).Select(i => new
            {
                i.ReferenceId,
                i.ReferenceEntityId
            }).ToList();

            // Remove any permissions not selected and in permissions table.
            dbSelection.ForEach(p =>
            {
                if (newSelection.Any(w => w.ReferenceId == p.ReferenceId) == false)
                {
                    var list = this.Context.FnGetPermissionsUnderPermissionId(p.PermissionId).ToList();
                    list.ForEach(p1 => this.Context.Permissions.Remove(p1));
                }
            });

            List <long> newPermissionId = new List <long>();

            // Add any permissions selected but not in permissions table
            newSelection.ForEach(p =>
            {
                if (dbSelectionIds.Any(w => w.ReferenceId == p.ReferenceId) == false)
                {
                    newPermissionId.Add(this.AddPermission(parentObjectId, objectEntity, objectId.Value, p.ReferenceEntityId, p.ReferenceId, type));
                }
            });


            return(newPermissionId);
        }
コード例 #22
0
        public IEnumerable <IMessage> GetMessages(
            EntityEnum entity,
            ConcurrentDictionary <EntityEnum, DataTable> data,
            int skip,
            int take
            )
        {
            IList <IMessage> output = null;

            if (data != null)
            {
                var records = data[entity]
                              .AsEnumerable()
                              .Skip(skip)
                              .Take(take);

                switch (entity)
                {
                case EntityEnum.Menu:
                    output = CreateMessage(EntityType.Menu, records);
                    break;

                case EntityEnum.Group:
                    output = CreateMessage(EntityType.Group, records);
                    break;

                case EntityEnum.Recipe:
                    output = CreateMessage(EntityType.Dish, records);
                    break;

                case EntityEnum.User:
                    output = CreateMessage(EntityType.User, records, MessageActionType.UserUpdated);
                    break;

                case EntityEnum.MealPeriod:
                    output = CreateMessage(EntityType.MealPeriodManagement, records);
                    break;
                }
            }

            return(output);
        }
コード例 #23
0
        /// <summary>
        /// Sets the value of one of the text attributes in the working specification.
        /// </summary>
        public void SetSpecificationText(EntityEnum entity, string text)
        {
            switch (entity)
            {
            case EntityEnum.Given:
                workingTestSpecification.Given = text;
                break;

            case EntityEnum.Name:
                workingTestSpecification.Name = text;
                break;

            case EntityEnum.Description:
                workingTestSpecification.Text = text;
                break;

            default:
                break;
            }
        }
コード例 #24
0
        /// <summary>
        /// Returns the value of one of the text attributes from the working specification.
        /// </summary>
        public string GetSpecificationText(EntityEnum entity, TestSpecification specification)
        {
            if (specification == null)
            {
                return(string.Empty);
            }

            switch (entity)
            {
            case EntityEnum.Given:
                return(workingTestSpecification.Given);

            case EntityEnum.Name:
                return(workingTestSpecification.Name);

            case EntityEnum.Description:
                return(workingTestSpecification.Text);

            default:
                return(string.Empty);
            }
        }
コード例 #25
0
        private async Task OnTick()
        {
            await Delay(100);

            foreach (Ped ped in EntityEnum.GetPeds())
            {
                bool isPlayerPed = false;
                foreach (Player player in Players)
                {
                    if (ped == player.Character)
                    {
                        isPlayerPed = true;
                    }
                }

                if (!isPlayerPed)
                {
                    ped.AlwaysKeepTask = true;
                    ped.Task.ChatTo(Game.PlayerPed);
                    ped.PlayAmbientSpeech("goodbye_across_street", SpeechModifier.ForceShouted);
                }
            }
        }
コード例 #26
0
ファイル: HomeController.cs プロジェクト: sidby/sklad
        // TODO: create ajax method which creates datacontextModel
        private string GetReportFile(SkladDataContext datacontextModel, 
            Document document, 
            EntityEnum.ReportType type)
        {
            if (document == null)
            {
                logger.ErrorFormat("GetReportFile. Document is null");
                throw new ArgumentException("GetReportFile. Document is null");
            }

            bool saveChanges = false;
            // check for folder names
            if (String.IsNullOrEmpty(document.SecureFolderName))
            {
                document.SecureFolderName = GenerateFolderName(document.CommonFolderName);
                saveChanges = true;
            }

            if (String.IsNullOrEmpty(document.CommonFolderName))
            {
                document.CommonFolderName = GenerateFolderName(document.SecureFolderName);
                saveChanges = true;
            }

            if (saveChanges)
                datacontextModel.SaveChanges();

            string relativePath = "../" + Constants.DocumentReportPath;
            string rootPath = Server.MapPath(relativePath);
            string reportFile = String.Empty;

            if (type == EntityEnum.ReportType.SaleReport)
            {
                // Check if file already exists.
                // Than check Modified date of the file in file name
                string docPath = Path.Combine(rootPath, document.DocumentId.ToString(), document.SecureFolderName);

                if(!Directory.Exists(docPath))
                    Directory.CreateDirectory(docPath);

                string dateSeparator = "-";
                string extension = ".xls";
                string mask = String.Format("{0}*{1}", Constants.DocumentReportPrefix, extension);

                var directory = new DirectoryInfo(docPath);
                // get last created file in directory
                var existingFile = directory.GetFiles(mask).OrderByDescending(f => f.LastWriteTime).FirstOrDefault();

                if (existingFile != null && !document.IsReportOutdated)
                {
                    // check if file is actual upon document modified date
                    reportFile = String.Format("{0}/{1}/{2}/{3}", relativePath,
                        document.DocumentId.ToString(), document.SecureFolderName, existingFile.Name);
                }
                else
                {
                    string fileName = String.Format("{0}{1}{4}{2}{4}{3}{5}", Constants.DocumentReportPrefix,
                        DateTimeOffset.Now.Year, DateTimeOffset.Now.ToString("MM"), DateTimeOffset.Now.ToString("dd"),
                        dateSeparator, extension);

                    // create report
                    ExcelReportInfo reportInfo = new ExcelReportInfo
                    {
                        CreatedOf = document.CreatedOf,
                        FileName = fileName,
                        FilePath = docPath,
                        DocumentSubject = "Отчёт №" + document.Number + " от " + document.CreatedOf,
                        SheetName = "Report-" + document.CreatedOf.ToString("dd.MM.yyyy"),
                        TitleLeft = (document.Contractor != null) ? document.Contractor.Code : String.Empty,
                        TitleCenter = document.CreatedOf.ToString("dd.MM.yyyy"),
                        TitleRight = "Док. №" + document.Number + " от " + document.CreatedOf.ToString("dd.MM.yyyy")
                    };

                    ReportHelper.GenerateProductLinesReport(document.Products, reportInfo);

                    document.IsReportOutdated = false;
                    datacontextModel.SaveChanges();
                    reportFile = String.Format("{0}/{1}/{2}/{3}", relativePath,
                        document.DocumentId.ToString(), document.SecureFolderName, fileName);
                }
            }

            return reportFile;
        }
コード例 #27
0
        public static EntityTypeCollection GetCollection(EntityEnum entityName)
        {
            EntityTypeCollection collection = EntityTypeDAL.GetCollection(entityName);

            return(collection);
        }
コード例 #28
0
ファイル: SaleController.cs プロジェクト: sidby/sklad
        private JsonResult GetDocumentList(SkladJqGridModel gridModel, 
            SkladDataContext datacontextModel, EntityEnum.DocumentTypeEnum docType)
        {
            string contractorIdStr = Request.QueryString["ContractorId"];
            if (!String.IsNullOrEmpty(contractorIdStr))
            {
                var contractor = datacontextModel.Contractors.Where(x =>
                    x.Code.ToLower() == contractorIdStr.ToLower()).FirstOrDefault();
                if (contractor != null)
                {
                    // ContractorName
                    return gridModel.DocumentGrid.DataBind(datacontextModel
                        .Documents.Include("Contractor").Where(x => x.ContractorId == contractor.ContractorId &&
                           x.DocumentTypeId == (int)docType));
                }
            }

            return gridModel.DocumentGrid.DataBind(datacontextModel.Documents.Include("Contractor").Where(x =>
                x.DocumentTypeId == (int)docType));
        }
コード例 #29
0
        public static Point FindClosest(EntityEnum e, Point from, NanoBotType botType)
        {
            // initial boundary
            int boundary = 50;

            // initial region
            ArrayList list = new ArrayList(20);

            EntityCollection c =
                e == EntityEnum.HoshimiPoint ?
                MYAI.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint) :
                MYAI.Tissue.GetEntitiesByType(EntityEnum.AZN);

            /*
             * // check whether already on nearest entity
             * foreach (Entity ee in c)
             * {
             *  if (from.X == ee.X && from.Y == ee.Y)
             *      return new Point(ee.X, ee.Y);
             * }*/

            while ((list.Count <= 0) || (boundary > 200))
            {
                foreach (Entity ee in c)
                {
                    if ((e == EntityEnum.HoshimiPoint) && (Global.NeedleGrid[ee.X][ee.Y] != null))
                    {
                        if (Global.NeedleGrid[ee.X][ee.Y].Skipped)
                        {
                            continue;   // skip this HP cos already built by other player
                        }
                        if (Global.NeedleGrid[ee.X][ee.Y].NeedleBuilt)
                        {
                            continue;   // AI ignores needle already built
                        }
                        else if (botType == NanoBotType.NanoContainer && Global.NeedleGrid[ee.X][ee.Y].NeedleTargetted)
                        {
                            continue;   // Container ignores needle already targetted (may not be built yet)
                        }
                    }
                    else if ((e == EntityEnum.AZN) && (!Global.isPierreAIDead))
                    { // check if we should avoid this AZN
                        if (Global.CanShoot(new Point(ee.X, ee.Y), Global.MYAI.PierreTeamInjectionPoint, 10))
                        {
                            continue;
                        }
                    }

                    if (ee.X >= (from.X - boundary) && ee.X <= (from.X + boundary) &&
                        ee.Y >= (from.Y - boundary) && ee.Y <= (from.Y + boundary)
                        )
                    {
                        list.Add(new Point(ee.X, ee.Y));
                    }
                }

                if (list.Count > 0)
                {
                    break;
                }

                // else increment boundary
                boundary += 50;
            }
            if (list.Count <= 0)
            {
                return(Point.Empty);
            }

            // Now calculate each HP/AZN to find the closest one
            Point p = Point.Empty;
            int   curDistance;
            int   minDistance = int.MaxValue;
            Point closestPt   = from;

            for (int i = 0; i < list.Count; i++)
            {
                p           = (Point)list[i];
                curDistance = Global.GetPathLength(from, p);
                if (curDistance < minDistance)
                {
                    minDistance = curDistance;
                    closestPt   = p;
                }
            }

            // return closest HP/AZN;
            return(closestPt);
        }
コード例 #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Import" /> class.
        /// </summary>
        /// <param name="id">Unique ID for this entity. (required).</param>
        /// <param name="created">The exact moment this entity was created. (required).</param>
        /// <param name="accountId">The ID of the account that owns this entity. (required).</param>
        /// <param name="userId">The ID of the account that owns this entity. (required).</param>
        /// <param name="entity">The name of the entity that was imported. (required).</param>
        /// <param name="amount">The number of members that imported. (required).</param>
        public Import(int id = default(int), DateTime created = default(DateTime), int accountId = default(int), int userId = default(int), EntityEnum entity = default(EntityEnum), int amount = default(int))
        {
            // to ensure "id" is required (not null)
            if (id == null)
            {
                throw new InvalidDataException("id is a required property for Import and cannot be null");
            }
            else
            {
                this.Id = id;
            }

            // to ensure "created" is required (not null)
            if (created == null)
            {
                throw new InvalidDataException("created is a required property for Import and cannot be null");
            }
            else
            {
                this.Created = created;
            }

            // to ensure "accountId" is required (not null)
            if (accountId == null)
            {
                throw new InvalidDataException("accountId is a required property for Import and cannot be null");
            }
            else
            {
                this.AccountId = accountId;
            }

            // to ensure "userId" is required (not null)
            if (userId == null)
            {
                throw new InvalidDataException("userId is a required property for Import and cannot be null");
            }
            else
            {
                this.UserId = userId;
            }

            // to ensure "entity" is required (not null)
            if (entity == null)
            {
                throw new InvalidDataException("entity is a required property for Import and cannot be null");
            }
            else
            {
                this.Entity = entity;
            }

            // to ensure "amount" is required (not null)
            if (amount == null)
            {
                throw new InvalidDataException("amount is a required property for Import and cannot be null");
            }
            else
            {
                this.Amount = amount;
            }
        }
コード例 #31
0
        public void UpdatePermissionAudit(EntityEnum UserType,
                                          User entity,
                                          List <Permission> permissionList,
                                          PermissionTypeEnum type,
                                          UserSessionModel admin,
                                          List <Permission> dbSelection
                                          )
        {
            var removeList = dbSelection.Where(dbs => !permissionList.Any(ns => ns.ReferenceId == dbs.ReferenceId)).ToList();
            var addList    = permissionList.Where(ns => !dbSelection.Any(dbs => dbs.ReferenceId == ns.ReferenceId)).ToList();

            foreach (var item in removeList)
            {
                PermissionAudit permissionAuditModel = new PermissionAudit();
                permissionAuditModel.EffectedUserId     = entity.UserId;
                permissionAuditModel.EffectedUserTypeId = (int)entity.UserTypeId;
                permissionAuditModel.ModifyByUserId     = admin.UserId;
                permissionAuditModel.ModifyByUserTypeId = (int)admin.UserTypeId;
                permissionAuditModel.ModifyDate         = DateTime.Now;
                permissionAuditModel.ObjectEntityId     = (int)UserType;
                permissionAuditModel.ObjectId           = entity.UserId;
                permissionAuditModel.ReferenceId        = item.ReferenceId;
                permissionAuditModel.ReferenceEntityId  = (int)item.ReferenceEntityId.Value;
                permissionAuditModel.PermissionTypeId   = (byte)item.PermissionTypeId;
                permissionAuditModel.PermissionId       = item.PermissionId;
                permissionAuditModel.ParentPermissionId = item.ParentPermissionId;
                permissionAuditModel.TypeOfAction       = "Removed";
                permissionAuditModel.BusinessId         = entity.BusinessId.Value;

                this.Context.PermissionAudits.Add(permissionAuditModel);
            }

            foreach (var item in addList)
            {
                var Id = this.Context.Permissions
                         .Where(p => p.ObjectId == entity.UserId &&
                                p.PermissionTypeId == PermissionTypeEnum.SystemAccess &&
                                p.ReferenceId == item.ReferenceId
                                ).Select(P => P.PermissionId).FirstOrDefault();

                PermissionAudit permissionAuditModel = new PermissionAudit();
                permissionAuditModel.EffectedUserId     = entity.UserId;
                permissionAuditModel.EffectedUserTypeId = (int)entity.UserTypeId;
                permissionAuditModel.ModifyByUserId     = admin.UserId;
                permissionAuditModel.ModifyByUserTypeId = (int)admin.UserTypeId;
                permissionAuditModel.ModifyDate         = DateTime.Now;
                permissionAuditModel.ObjectEntityId     = (int)entity.UserTypeId;
                permissionAuditModel.ObjectId           = entity.UserId;
                permissionAuditModel.ReferenceId        = item.ReferenceId;
                permissionAuditModel.ReferenceEntityId  = (int)item.ReferenceEntityId;
                permissionAuditModel.PermissionTypeId   = (byte)type;
                permissionAuditModel.BusinessId         = entity.BusinessId.Value;

                var parentPermissionId = this.Context.Permissions
                                         .Where(p => p.PermissionId == Id)
                                         .Select(p => p.ParentPermissionId).FirstOrDefault();

                permissionAuditModel.PermissionId = Id;

                if (parentPermissionId == null)
                {
                    parentPermissionId = this.Context.Permissions
                                         .Where(p => p.ObjectId == entity.UserId &&
                                                p.ParentPermissionId != null
                                                ).OrderByDescending(p => p.PermissionId)
                                         .Select(p => p.ParentPermissionId).FirstOrDefault();
                }

                permissionAuditModel.ParentPermissionId = parentPermissionId;

                permissionAuditModel.TypeOfAction = "Added";

                this.Context.PermissionAudits.Add(permissionAuditModel);
            }

            this.Context.SaveChanges();
        }
コード例 #32
0
 public BaseRepository(EntityEnum collection, IMongoDatabase db) : base(new DirectoryInfo("C:\\temp"))
 {
     _entityName = collection;
     _collection = db.GetCollection <T>(collection);
 }
コード例 #33
0
 public BaseRepository(EntityEnum collection, IMongoDatabase db, DirectoryInfo imageDir) : base(imageDir)
 {
     _entityName = collection;
     _collection = db.GetCollection <T>(collection);
 }
コード例 #34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Attribute" /> class.
        /// </summary>
        /// <param name="id">Unique ID for this entity. (required).</param>
        /// <param name="created">The exact moment this entity was created. (required).</param>
        /// <param name="accountId">The ID of the account that owns this entity. (required).</param>
        /// <param name="entity">The name of the entity that can have this attribute. When creating or updating the entities of a given type, you can include an &#x60;attributes&#x60; object with keys corresponding to the &#x60;name&#x60; of the custom attributes for that type. (required).</param>
        /// <param name="eventType">eventType.</param>
        /// <param name="name">The attribute name that will be used in API requests and Talang. E.g. if &#x60;name &#x3D;&#x3D; \&quot;region\&quot;&#x60; then you would set the region attribute by including an &#x60;attributes.region&#x60; property in your request payload. (required).</param>
        /// <param name="title">The human-readable name for the attribute that will be shown in the Campaign Manager. Like &#x60;name&#x60;, the combination of entity and title must also be unique. (required).</param>
        /// <param name="type">The data type of the attribute, a &#x60;time&#x60; attribute must be sent as a string that conforms to the [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) timestamp format. (required).</param>
        /// <param name="description">A description of this attribute. (required).</param>
        /// <param name="suggestions">A list of suggestions for the attribute. (required).</param>
        /// <param name="editable">Whether or not this attribute can be edited. (required).</param>
        /// <param name="subscribedApplicationsIds">A list of the IDs of the applications that are subscribed to this attribute.</param>
        public Attribute(int id = default(int), DateTime created = default(DateTime), int accountId = default(int), EntityEnum entity = default(EntityEnum), string eventType = default(string), string name = default(string), string title = default(string), TypeEnum type = default(TypeEnum), string description = default(string), List <string> suggestions = default(List <string>), bool editable = default(bool), List <int> subscribedApplicationsIds = default(List <int>))
        {
            // to ensure "id" is required (not null)
            if (id == null)
            {
                throw new InvalidDataException("id is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Id = id;
            }

            // to ensure "created" is required (not null)
            if (created == null)
            {
                throw new InvalidDataException("created is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Created = created;
            }

            // to ensure "accountId" is required (not null)
            if (accountId == null)
            {
                throw new InvalidDataException("accountId is a required property for Attribute and cannot be null");
            }
            else
            {
                this.AccountId = accountId;
            }

            // to ensure "entity" is required (not null)
            if (entity == null)
            {
                throw new InvalidDataException("entity is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Entity = entity;
            }

            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new InvalidDataException("name is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Name = name;
            }

            // to ensure "title" is required (not null)
            if (title == null)
            {
                throw new InvalidDataException("title is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Title = title;
            }

            // to ensure "type" is required (not null)
            if (type == null)
            {
                throw new InvalidDataException("type is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Type = type;
            }

            // to ensure "description" is required (not null)
            if (description == null)
            {
                throw new InvalidDataException("description is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Description = description;
            }

            // to ensure "suggestions" is required (not null)
            if (suggestions == null)
            {
                throw new InvalidDataException("suggestions is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Suggestions = suggestions;
            }

            // to ensure "editable" is required (not null)
            if (editable == null)
            {
                throw new InvalidDataException("editable is a required property for Attribute and cannot be null");
            }
            else
            {
                this.Editable = editable;
            }

            this.EventType = eventType;
            this.SubscribedApplicationsIds = subscribedApplicationsIds;
        }
コード例 #35
0
ファイル: Global.cs プロジェクト: amudi/MephistoBot
        public static Point FindClosest(EntityEnum e, Point from, NanoBotType botType)
        {
            // initial boundary
            int boundary = 50;

            // initial region
            ArrayList list = new ArrayList(20);

            EntityCollection c =
                e == EntityEnum.HoshimiPoint ?
                MYAI.Tissue.GetEntitiesByType(EntityEnum.HoshimiPoint) :
                MYAI.Tissue.GetEntitiesByType(EntityEnum.AZN);

            /*
            // check whether already on nearest entity
            foreach (Entity ee in c)
            {
                if (from.X == ee.X && from.Y == ee.Y)
                    return new Point(ee.X, ee.Y);
            }*/

            while ((list.Count <= 0) || (boundary > 200))
            {
                foreach (Entity ee in c)
                {
                    if ((e == EntityEnum.HoshimiPoint) && (Global.NeedleGrid[ee.X][ee.Y] != null))
                    {
                        if (Global.NeedleGrid[ee.X][ee.Y].Skipped)
                            continue;	// skip this HP cos already built by other player

                        if (Global.NeedleGrid[ee.X][ee.Y].NeedleBuilt)
                            continue;   // AI ignores needle already built

                        else if (botType == NanoBotType.NanoContainer && Global.NeedleGrid[ee.X][ee.Y].NeedleTargetted)
                            continue;	// Container ignores needle already targetted (may not be built yet)

                    }
                    else if ((e == EntityEnum.AZN) && (!Global.isPierreAIDead))
                    { // check if we should avoid this AZN
                        if (Global.CanShoot(new Point(ee.X, ee.Y), Global.MYAI.PierreTeamInjectionPoint, 10))
                            continue;
                    }

                    if (ee.X >= (from.X - boundary) && ee.X <= (from.X + boundary) &&
                        ee.Y >= (from.Y - boundary) && ee.Y <= (from.Y + boundary)
                        )
                    {
                        list.Add(new Point(ee.X, ee.Y));
                    }
                }

                if (list.Count > 0)
                    break;

                // else increment boundary
                boundary += 50;
            }
            if (list.Count <= 0)
                return Point.Empty;

            // Now calculate each HP/AZN to find the closest one
            Point p = Point.Empty;
            int curDistance;
            int minDistance = int.MaxValue;
            Point closestPt = from;
            for (int i = 0; i < list.Count; i++)
            {
                p = (Point)list[i];
                curDistance = Global.GetPathLength(from, p);
                if (curDistance < minDistance)
                {
                    minDistance = curDistance;
                    closestPt = p;
                }
            }

            // return closest HP/AZN;
            return closestPt;
        }
コード例 #36
0
        public static EntityCollection GetCollection(EntityEnum entityName)
        {
            EntityCollection entityCollection = EntityDAL.GetCollection();

            return entityCollection;
        }
コード例 #37
0
        public static EntityTypeCollection GetCollection(EntityEnum entityName)
        {
            EntityTypeCollection entityTypeCollection = EntityTypeDAL.GetCollection(entityName);

            return entityTypeCollection;
        }