示例#1
0
 public JsonResult CreateEntity(string createEntityName, PortalEntity portalEntity)
 {
     try
     {
         log.Info("Entered CreateEntity");
         if (ValidateDuplicateContact(portalEntity) == false)
         {
             Entity createEntity = GetCrmEntity(portalEntity, createEntityName);
             Guid   Id           = ServiceProxy.Create(createEntity);
             log.Info("Exiting CreateEntity ");
             return(new JsonResult()
             {
                 Data = Id
             });
         }
         else
         {
             log.Error("Duplicate contact with email address found!");
             throw new Exception("Duplicate Record");
         }
     }
     catch (Exception ex)
     {
         log.Error(ex);
         throw new Exception(ex.Message);
     }
 }
示例#2
0
            public static void Create(PortalInfo info, PortalPoint p)
            {
                p.GameObject = new GameObject();

                PortalEntity portal = p.GameObject.AddComponent <PortalEntity>();

#if DEBUG
                Interface.Oxide.LogWarning($"Creating portal object!");
#endif
                p.GameObject.transform.position = p.Location.Vector3;

                portal.info  = info;
                portal.point = p;
#if DEBUG
                Interface.Oxide.LogWarning($"Creating portal sphere!");
#endif
                p.Sphere = GameManager.server.CreateEntity("assets/prefabs/visualization/sphere.prefab", p.Location.Vector3, new Quaternion(), true).GetComponent <SphereEntity>();
                p.Sphere.currentRadius = 2;
                p.Sphere.lerpSpeed     = 0f;
                p.Sphere.Spawn();

                if (info.DeploySpinner)
                {
#if DEBUG
                    Interface.Oxide.LogWarning($"Creating portal wheel!");
#endif
                    p.Wheel = GameManager.server.CreateEntity("assets/prefabs/deployable/spinner_wheel/spinner.wheel.deployed.prefab", p.Location.Vector3 + new Vector3(0, 0.02f, 0), new Quaternion(), true) as SpinnerWheel;
                    p.Wheel.Spawn();

                    if (Instance.configData.nameOnWheel)
                    {
                        Instance.NextTick(() =>
                        {
                            Interface.Oxide.LogDebug($"Texture size: {p.Wheel.paintableSources.FirstOrDefault().texWidth.ToString()}");
                            info.ID      = info.ID.Trim();
                            int fontsize = Convert.ToInt32(Math.Floor(100f / info.ID.Length / 2));
#if DEBUG
                            Interface.Oxide.LogWarning($"Writing name, {info.ID}, on portal wheel with fontsize {fontsize.ToString()} and color {Instance.configData.spinnerTextColor.ToString()}!");
#endif
                            // Try to paint the sign using one of two versions of SignArtist
                            try
                            {
                                // The version with this call needs to have the function modified to private to work.
                                Instance.SignArtist?.Call("API_SignText", new BasePlayer(), p.Wheel as Signage, info.ID, fontsize, Instance.configData.spinnerTextColor, Instance.configData.spinnerBGColor);
                            }
                            catch
                            {
                                // The versions with this call should work...
                                Instance.SignArtist?.Call("signText", null, p.Wheel as Signage, info.ID, fontsize, Instance.configData.spinnerTextColor, Instance.configData.spinnerBGColor);
                            }
#if DEBUG
                            Interface.Oxide.LogWarning($"Writing done, setting flags.");
#endif
                            p.Wheel.SetFlag(BaseEntity.Flags.Busy, true);
                            p.Wheel.SetFlag(BaseEntity.Flags.Reserved3, true);
                        });
                    }
                }
            }
示例#3
0
            public void Create()
            {
                Update();

                PortalEntity.Create(this, Entrance);
                PortalEntity.Create(this, Exit);

                _created = true;
            }
示例#4
0
            public void Teleport(PortalEntity portal)
            {
                if (portal.info.CanUse(player))
                {
                    PortalPoint otherPoint = portal.point.PointType == PortalPointType.Entrance ? portal.info.Exit : portal.info.Entrance;

                    Instance.Teleport(player, otherPoint.Location.Vector3);
                    Interface.CallHook("OnPortalUsed", player, JObject.FromObject(portal.info), JObject.FromObject(portal.point));
                }
            }
示例#5
0
        public void UpdateEntity(string id, string entityName, PortalEntity updateEntity)
        {
            log.Info("Entered UpdateEntity ");

            Entity entity     = GetCrmEntity(updateEntity, entityName);
            Guid   primaryKey = Guid.Parse(id);

            entity.Id = primaryKey;
            ServiceProxy.Update(entity);
            log.Info("Exiting UpdateEntity ");
        }
示例#6
0
            public void Teleport(PortalEntity portal)
            {
                PortalPoint otherPoint = portal.point.PointType == PortalPointType.Entrance ? portal.info.Exit : portal.info.Entrance;

                Effect.server.Run("assets/bundled/prefabs/fx/explosions/explosion_03.prefab",
                                  player.transform.position);
                Instance.Teleport(player, otherPoint.Location.Vector3);
                Instance.timer.Once(2f, () => Effect.server.Run("assets/bundled/prefabs/fx/explosions/explosion_01.prefab",
                                                                otherPoint.Location.Vector3));
                Interface.CallHook("OnPortalUsed", player, JObject.FromObject(portal.info), JObject.FromObject(portal.point));
            }
示例#7
0
            public void Create()
            {
                Update();
#if DEBUG
                Interface.Oxide.LogWarning($"Creating portal Primary");
#endif
                PortalEntity.Create(this, Primary);
#if DEBUG
                Interface.Oxide.LogWarning($"Creating portal Secondary");
#endif
                PortalEntity.Create(this, Secondary);
                _created = true;
            }
示例#8
0
            public static void Create(PortalInfo info, PortalPoint p)
            {
                p.GameObject = new GameObject();

                PortalEntity portal = p.GameObject.AddComponent <PortalEntity>();

                p.Sphere = GameManager.server.CreateEntity("assets/prefabs/visualization/sphere.prefab", p.Location.Vector3, new Quaternion(), true).GetComponent <SphereEntity>();
                p.Sphere.currentRadius = 2;
                p.Sphere.lerpSpeed     = 0f;
                p.Sphere.Spawn();

                p.GameObject.transform.position = p.Location.Vector3;

                portal.info  = info;
                portal.point = p;
            }
示例#9
0
            public void Teleport(PortalEntity portal)
            {
                if (portal.info.CanUse(player))
                {
                    PortalPoint otherPoint = portal.point.PointType == PortalPointType.Primary ? portal.info.Secondary : portal.info.Primary;
                    Instance.Teleport(player, otherPoint.Location.Vector3);

                    if (portal.point.Wheel && Instance.configData.spinEntrance)
                    {
                        (portal.point.Wheel as SpinnerWheel).velocity += Core.Random.Range(2f, 4f);
                    }
                    if (otherPoint.Wheel && Instance.configData.spinExit)
                    {
                        (otherPoint.Wheel as SpinnerWheel).velocity += Core.Random.Range(2f, 4f);
                    }

                    Interface.CallHook("OnPortalUsed", player, JObject.FromObject(portal.info), JObject.FromObject(portal.point));
                }
            }
示例#10
0
        private bool ValidateDuplicateContact(PortalEntity portalEntity)
        {
            bool duplicate = false;

            if (portalEntity.entityName.ToLower() == "contact")
            {
                string emailFieldName = "emailaddress1";
                string emailAddress   = string.Empty;
                if (portalEntity.PortalAttributes.ContainsKey(emailFieldName) && portalEntity.PortalAttributes[emailFieldName] != null)
                {
                    emailAddress = portalEntity.PortalAttributes[emailFieldName].ToString();
                }

                if (!string.IsNullOrEmpty(emailAddress))
                {
                    log.Info("New Contact Email " + emailAddress);
                    string           fetchXml      = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                      <entity name='contact'>
                                        <attribute name='fullname' />
                                        <order attribute='fullname' descending='false' />
                                        <filter type='and'>
                                          <condition attribute='" + emailFieldName + @"' operator='eq' value='" + emailAddress + @"' />
                                          <condition attribute='statecode' operator='eq' value='0' />
                                          <filter type='or'>
                                            <condition attribute='concap_appuser' operator='eq' value='1' />
                                            <condition attribute='concap_createdfromapp' operator='eq' value='1' />
                                          </filter>                                          
                                        </filter>
                                      </entity>
                                    </fetch>";
                    EntityCollection dupCotactColl = ServiceProxy.RetrieveMultiple(new FetchExpression(fetchXml));
                    if (dupCotactColl.Entities.Count > 0)
                    {
                        duplicate = true;
                    }
                }
            }

            return(duplicate);
        }
示例#11
0
            private static Entity JSONToEntity(Level level, JToken entity, List <Action> delayedParseActions)
            {
                var entityType = entity["Type"]?.ToObject <EntityTypes>();

                if (entityType == null)
                {
                    throw new InvalidSerializedContentException($"Invalid entity type specified [{entityType}]");
                }

                var entityX = entity.Value <int>("X");

                if (entityX < 0 || entityX >= level.LevelWidth)
                {
                    throw new InvalidSerializedContentException($"Invalid entity X specified [{entityX}]");
                }

                var entityY = entity.Value <int>("Y");

                if (entityY < 0 || entityY >= level.LevelHeight)
                {
                    throw new InvalidSerializedContentException($"Invalid entity Y specified [{entityY}]");
                }

                switch (entityType.Value)
                {
                case EntityTypes.Pit:
                case EntityTypes.HaltTile:
                case EntityTypes.FinishFlag:
                case EntityTypes.JumpTile:
                    var genericEntity = new StaticEntity(entityType.Value, level.GetNextEntityID(), entityX, entityY);
                    return(genericEntity);

                case EntityTypes.Wall:
                    var adjacentWalls = entity.Value <byte>("AdjacentWalls");
                    var wallEntity    = new WallEntity(level.GetNextEntityID(), entityX, entityY, adjacentWalls);
                    return(wallEntity);

                case EntityTypes.RedirectTile:
                    var redirectDir = entity.Value <int>("RedirectDir");
                    if (redirectDir < 0 || redirectDir > 3)
                    {
                        throw new InvalidSerializedContentException($"Invalid redirect direction [{redirectDir}]");
                    }
                    var redirectEntity = new RedirectTile(level.GetNextEntityID(), entityX, entityY, redirectDir);
                    return(redirectEntity);

                case EntityTypes.Portal:
                    var portalTargetX = entity["PortalTarget"]?.Value <int>("X");
                    var portalTargetY = entity["PortalTarget"]?.Value <int>("Y");

                    if (!portalTargetX.HasValue || portalTargetX < 0 || portalTargetX >= level.LevelWidth)
                    {
                        throw new InvalidSerializedContentException($"Invalid portal target X specified [{portalTargetX}]");
                    }
                    if (!portalTargetY.HasValue || portalTargetY < 0 || portalTargetY >= level.LevelHeight)
                    {
                        throw new InvalidSerializedContentException($"Invalid portal target Y specified [{portalTargetY}]");
                    }

                    var portalEntity = new PortalEntity(level.GetNextEntityID(), entityX, entityY, new IntVector2(portalTargetX.Value, portalTargetY.Value));
                    return(portalEntity);

                case EntityTypes.Player:
                    var playerEntity = new PlayerEntity(-(level.PlayerEntities.Count + 1), entityX, entityY);
                    return(playerEntity);

                case EntityTypes.SlidingCrate:
                    var slidingCrateEntity = new SlidingCrate(level.GetNextEntityID(), entityX, entityY);
                    return(slidingCrateEntity);

                case EntityTypes.WireButton:
                    var buttonMode = entity["Mode"]?.ToObject <WireButtonEntity.ButtonModes>();
                    if (buttonMode == null)
                    {
                        throw new InvalidSerializedContentException($"Invalid button mode specified [{buttonMode}]");
                    }

                    var wireButtonEntity = new WireButtonEntity(level.GetNextEntityID(), entityX, entityY, buttonMode.Value);
                    delayedParseActions.Add(() =>
                    {
                        var wireInteractionsJSON = (JArray)entity["Wire"];
                        if (wireInteractionsJSON == null || wireInteractionsJSON.Count < 1)
                        {
                            throw new InvalidSerializedContentException($"Invalid wire interactions specified for [{wireButtonEntity.EntityType}] at [{wireButtonEntity.Position}]");
                        }
                        foreach (var wireInteractionJSON in wireInteractionsJSON)
                        {
                            var wireX = wireInteractionJSON.Value <int>("X");
                            if (wireX < 0 || wireX >= level.LevelWidth)
                            {
                                throw new InvalidSerializedContentException($"Invalid wire X specified [{wireX}]");
                            }

                            var wireY = wireInteractionJSON.Value <int>("Y");
                            if (wireY < 0 || wireY >= level.LevelHeight)
                            {
                                throw new InvalidSerializedContentException($"Invalid entity Y specified [{wireY}]");
                            }

                            var invert = wireInteractionJSON.Value <bool>("Invert");

                            var interactables = level
                                                .GetEntitiesAtPosition(wireX, wireY)
                                                .Where(i => i is IWireInteractable);
                            foreach (var interactable in interactables)
                            {
                                wireButtonEntity.WireInteractions.Add(new WireInteraction()
                                {
                                    Interactable = (IWireInteractable)interactable,
                                    Invert       = invert
                                });
                            }
                        }
                    });
                    return(wireButtonEntity);

                case EntityTypes.WireDoor:
                    var wireDoorEntity = new WireDoorEntity(level.GetNextEntityID(), entityX, entityY, false);
                    return(wireDoorEntity);

                case EntityTypes.Sushi:
                    var sushiEntity = new SushiEntity(level.GetNextEntityID(), entityX, entityY, true);
                    return(sushiEntity);

                case EntityTypes.None:
                    return(null);

                default:
                    throw new NotSupportedException($"Entity type [{entityType}] is not parsable. Please implement JSON to entity.");
                }
            }
示例#12
0
        private static Entity GetCrmEntity(PortalEntity entityInstance, string entityName)
        {
            Entity crmEntityInstance = new Entity(entityName);

            foreach (var portalAttribute in entityInstance.PortalAttributes)
            {
                if (!portalAttribute.Key.ToLower().Contains("isopen"))
                {
                    string columnType = GetColumnType(portalAttribute.Key, entityInstance.Columns);
                    if (!String.IsNullOrEmpty(columnType))
                    {
                        if (columnType == "picklist")
                        {
                            var obj = (JObject)portalAttribute.Value;
                            if (obj != null)
                            {
                                //var value = obj.Properties().Select(p => p.Value).FirstOrDefault();
                                var value = ((dynamic)portalAttribute.Value).Value.Value;
                                if (value != null && value.ToString() != null && !value.ToString().Equals(""))
                                {
                                    int picklistValue = Int32.Parse(value.ToString());
                                    crmEntityInstance.Attributes.Add(portalAttribute.Key, new OptionSetValue(picklistValue));
                                }
                                else
                                {
                                    crmEntityInstance.Attributes.Add(portalAttribute.Key, null);
                                }
                            }
                            else
                            {
                                crmEntityInstance.Attributes.Add(portalAttribute.Key, null);
                            }
                        }
                        else if (columnType == "boolean")
                        {
                            bool booleanValue;
                            if (bool.TryParse(portalAttribute.Value.ToString(), out booleanValue))
                            {
                                booleanValue = Convert.ToBoolean(portalAttribute.Value.ToString());
                            }
                            else
                            {
                                var str = ((JObject)portalAttribute.Value).Properties().Where(p => p.Value.Path.Equals("Value")).FirstOrDefault().Value.Value <String>();
                                booleanValue = bool.Parse(str);
                            }
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, booleanValue);
                        }
                        else if (columnType == "wholenumber")
                        {
                            int wholeNumberValue = Int32.Parse(portalAttribute.Value.ToString());
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, wholeNumberValue);
                        }
                        else if (columnType == "datetime")
                        {
                            DateTime dateTimeValue = DateTime.Parse(portalAttribute.Value.ToString());
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, dateTimeValue);
                        }
                        else if (columnType == "money")
                        {
                            var str = ((JObject)portalAttribute.Value).Properties().Where(p => p.Value.Path.Equals("Value")).FirstOrDefault().Value.Value <String>();
                            //    Dictionary<string, object> portalAttributeValue = (Dictionary<string, object>)portalAttribute.Value;
                            decimal moneyDecimal = Decimal.Parse(str);
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, new Money(moneyDecimal));
                        }
                        else if (columnType == "lookup" || columnType == "lookup-hidden")
                        {
                            var jobj = (JObject)portalAttribute.Value;
                            IEnumerable <JProperty> props = jobj.Properties();
                            var    id          = new Guid();
                            string logicalName = null;
                            foreach (var prop in props)
                            {
                                if (prop.Name == "Id")
                                {
                                    id = new Guid(prop.Value.Value <String>());
                                }
                                else if (prop.Name == "LogicalName")
                                {
                                    logicalName = prop.Value.Value <String>();
                                }
                            }
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, new EntityReference(logicalName, id));
                        }
                        else if (columnType == "label")
                        {
                            //Skip
                        }
                        else
                        {
                            crmEntityInstance.Attributes.Add(portalAttribute.Key, portalAttribute.Value);
                        }
                    }
                }
            }
            //if (entityInstance.Id != Guid.Empty)
            //{
            //    crmEntityInstance.Id = entityInstance.Id;
            //}
            return(crmEntityInstance);
        }
示例#13
0
 public GameMessage WithPortal(PortalEntity value)
 {
     targetPortal = value;
     return(this);
 }