Exemplo n.º 1
0
        private bool SendRequestUpdate(Authentication value, string content, BaseRoot baseRoot, Func <string, object, bool> getResponse)
        {
            string url       = value.UrlService;
            string urlFormat = string.Format("{0}xml/{1}/{2}?authtoken={3}&scope={4}&newFormat=1&id={5}&xmlData={6}", url, GetEntityName(), "updateRecords", value.Token, value.User, baseRoot.GetId(), content);

            return(HttpMessageSender.SendRequestPost(urlFormat, content, baseRoot, getResponse));
        }
Exemplo n.º 2
0
        protected override void SetId(string id, BaseRoot value)
        {
            if (!value.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("CONTACTID")))
            {
                value.MappingFields.Add(new MappingFields {
                    Entity = "Event", Field = "CONTACTID", Value = id
                });
            }

            if (!value.MappingFields.Exists(e => ZohoAccount.Filter(e.Entity) && e.Field.Equals("CONTACTID")))
            {
                value.MappingFields.Add(new MappingFields {
                    Entity = "Account", Field = "CONTACTID", Value = id
                });
            }

            if (!value.MappingFields.Exists(e => ZohoPotential.Filter(e.Entity) && e.Field.Equals("CONTACTID")))
            {
                value.MappingFields.Add(new MappingFields {
                    Entity = "Potential", Field = "CONTACTID", Value = id
                });
            }

            if (!value.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("Participants")))
            {
                value.MappingFields.Add(new MappingFields {
                    Entity = "Event", Field = "Participants", Value = "<Participant><FL val=\"CONTACTID\">{0}</FL></Participant>"
                });
            }

            SetParticipants(id, value);
        }
        void ISeaTruckArmHandler.SetRotation(SeaTruckArm arm, bool isDocked)
        {
            if (isDocked)
            {
                BaseRoot baseRoot = TruckHelper.MainCab.GetComponentInParent <BaseRoot>();

                if (baseRoot.isBase)
                {
                    if (arm == SeaTruckArm.Right)
                    {
                        transform.localRotation = Quaternion.Euler(20, 6, 0);
                    }
                    else
                    {
                        transform.localRotation = Quaternion.Euler(20, 354, 0);
                    }
                }
            }
            else
            {
                if (arm == SeaTruckArm.Right)
                {
                    transform.localRotation = Quaternion.Euler(0, 0, 0);
                }
                else
                {
                    transform.localRotation = Quaternion.Euler(0, 0, 0);
                }
            }
        }
Exemplo n.º 4
0
        protected bool SendRequestGetRecord(BaseRoot value, string entityName, string id, Func <string, object, bool> loadResponse)
        {
            string url       = value.Authentication.UrlService;
            string urlFormat = string.Format("{0}json/{1}/{2}?authtoken={3}&scope={4}&id={5}",
                                             url, entityName, "getRecordById", value.Authentication.Token, value.Authentication.User, id);

            return(HttpMessageSender.SendRequestGet(urlFormat, value, loadResponse));
        }
Exemplo n.º 5
0
        private bool Execute(BaseRoot value, Func <IHubIntegration, BaseRoot, bool> function)
        {
            string msg = string.Format("Execute CRM:{0} ", value.Authentication.Crm);

            _logger.LogDebug(msg);
            AddUrl(value.Authentication);
            return(function(_crmIntegration, value));
        }
Exemplo n.º 6
0
        protected bool SendRequestSearch(BaseRoot value, string entityName, string selectColumn, string searchColumn, string searchValue, Func <string, object, bool> getResponse)
        {
            string url       = value.Authentication.UrlService;
            string urlFormat = string.Format("{0}json/{1}/{2}?authtoken={3}&scope={4}&selectColumns={5}({6})&searchColumn={7}&searchValue={8}",
                                             url, entityName, "getSearchRecordsByPDC", value.Authentication.Token, value.Authentication.User, entityName, selectColumn, searchColumn.ToLower(), searchValue);

            return(HttpMessageSender.SendRequestGet(urlFormat, value, getResponse));
        }
Exemplo n.º 7
0
 private void SetParticipants(string id, BaseRoot value)
 {
     if (value.MappingFields.Where(w => w.Entity.Equals("Event") && w.Field.Equals("Participants")).First().Value.IndexOf(id) <= 0)
     {
         value.MappingFields.Where(w => w.Entity.Equals("Event") && w.Field.Equals("Participants")).First().Value =
             value.MappingFields.Where(w => w.Entity.Equals("Event") && w.Field.Equals("Participants")).First().Value.Replace("{0}", id + ",{0}");
     }
 }
Exemplo n.º 8
0
        protected bool SendRequestGetUser(BaseRoot value, Func <string, object, bool> loadResponse)
        {
            string url       = value.Authentication.UrlService;
            string urlFormat = string.Format("{0}json/{1}/{2}?authtoken={3}&scope={4}&type={5}",
                                             url, "Users", "getUsers", value.Authentication.Token, value.Authentication.User, "ActiveUsers");

            return(HttpMessageSender.SendRequestGet(urlFormat, value, loadResponse));
        }
Exemplo n.º 9
0
        public bool LeadGetFields(Autenticacao value)
        {
            var _value = new BaseRoot()
            {
                Authentication = Mapper.Map <Authentication>(value)
            };

            return(Execute(_value, (c, v) => c.LeadGetFields(_value)));
        }
Exemplo n.º 10
0
        protected bool SendRequestSave(BaseRoot value, List <MappingFields> mapping, Func <string, object, bool> getReponse)
        {
            string content = LoadXml(GetEntityName(), mapping);

            if (string.IsNullOrEmpty(value.GetId()))
            {
                return(SendRequestInsert(value.Authentication, content, value, getReponse));
            }
            return(SendRequestUpdate(value.Authentication, content, value, getReponse));
        }
Exemplo n.º 11
0
 private string LoadId(string value, BaseRoot baseRoot, Action <string, BaseRoot> setId)
 {
     if (value.IndexOf("<FL val=\"Id\">") > 0)
     {
         string id = value.Substring(value.IndexOf("<FL val=\"Id\">") + 13, 19);
         setId(id, baseRoot);
         return(id);
     }
     return(string.Empty);
 }
Exemplo n.º 12
0
        protected string GetFieldValue(BaseRoot value, string field, Func <string, bool> filter)
        {
            var mapping = value.MappingFields.Where(v => filter(v.Entity)).ToList();

            if (mapping.Exists(x => x.Field == field))
            {
                var fieldValue = mapping.Where(x => x.Field == field).FirstOrDefault();
                return(fieldValue.Value);
            }
            return(string.Empty);
        }
Exemplo n.º 13
0
 protected override void SetId(string id, BaseRoot value)
 {
     if (!value.MappingFields.Exists(e => e.Entity.Equals("Event") && e.Field.Equals("SEMODULE")))
     {
         value.MappingFields.Add(new MappingFields {
             Entity = "Event", Field = "SEID", Value = id
         });
         value.MappingFields.Add(new MappingFields {
             Entity = "Event", Field = "SEMODULE", Value = "Potentials"
         });
     }
 }
Exemplo n.º 14
0
        private bool IsSwimming(Vector3 playerPosition, Optional <NitroxId> subId)
        {
            if (subId.HasValue)
            {
                Optional <GameObject> sub = NitroxEntity.GetObjectFrom(subId.Value);
                SubRoot subroot           = null;
                sub.Value.TryGetComponent <SubRoot>(out subroot);
                // Set the animation for the remote player to standing instead of swimming if player is not in a flooded subroot
                // or in a waterpark
                if (subroot)
                {
                    if (subroot.IsUnderwater(playerPosition))
                    {
                        return(true);
                    }
                    if (subroot.isCyclops)
                    {
                        return(false);
                    }
                    // We know that we are in a subroot. But we can also be in a waterpark in a subroot, where we would swim
                    BaseRoot baseRoot = subroot.GetComponentInParent <BaseRoot>();
                    if (baseRoot)
                    {
                        WaterPark[] waterParks = baseRoot.GetComponentsInChildren <WaterPark>();
                        foreach (WaterPark waterPark in waterParks)
                        {
                            if (waterPark.IsPointInside(playerPosition))
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }
                }

                Log.Debug($"Trying to find escape pod for {subId}.");
                EscapePod escapePod = null;
                sub.Value.TryGetComponent <EscapePod>(out escapePod);
                if (escapePod)
                {
                    Log.Debug("Found escape pod for player. Will add him and update animation.");
                    return(false);
                }
            }
            // Player can be above ocean level.
            float oceanLevel = Ocean.main.GetOceanLevel();

            return(playerPosition.y < oceanLevel);
        }
Exemplo n.º 15
0
 public virtual bool Execute(BaseRoot value)
 {
     if (!value.MappingFields.Exists(e => e.Entity.Equals(GetEntityName()) && e.Field.Equals("SMOWNERID")))
     {
         if (SendRequestGetUser(value, LoadResponseUser))
         {
             return(true);
         }
     }
     else
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 16
0
 protected override void SetId(string id, BaseRoot value)
 {
     if (!value.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("ACCOUNTID")))
     {
         value.MappingFields.Add(new MappingFields {
             Entity = ZohoEvent.ENTITY, Field = "ACCOUNTID", Value = id
         });
     }
     if (!value.MappingFields.Exists(e => ZohoPotential.Filter(e.Entity) && e.Field.Equals("ACCOUNTID")))
     {
         value.MappingFields.Add(new MappingFields {
             Entity = ZohoPotential.ENTITY, Field = "ACCOUNTID", Value = id
         });
     }
 }
Exemplo n.º 17
0
        protected virtual bool OnLoadReponseUser(User user, object value)
        {
            BaseRoot baseRoot = (BaseRoot)value;

            try
            {
                Predicate <MappingFields> filter = v => v.Entity.Equals(GetEntity()) && v.Field.Equals("SMOWNERID");
                if (!baseRoot.MappingFields.Exists(e => filter(e)))
                {
                    baseRoot.MappingFields.Add(new MappingFields {
                        Entity = GetEntity(), Field = "SMOWNERID", Value = user.id
                    });
                }
                return(true);
            }
            catch { return(false); }
        }
Exemplo n.º 18
0
        public static float GetDistanceToPlayer(this BaseRoot baseRoot)
        {
            Int3 u    = baseRoot.baseComp.WorldToGrid(Player.main.transform.position);
            int  num  = int.MaxValue;
            Int3 @int = new Int3(int.MaxValue);

            foreach (Int3 int2 in baseRoot.baseComp.AllCells)
            {
                int num2 = (u - int2).SquareMagnitude();
                if (num2 < num)
                {
                    @int = int2;
                    num  = num2;
                }
            }

            baseRoot.baseComp.GridToWorld(@int, UWE.Utils.half3, out var vector);
            return((Player.main.transform.position - vector).magnitude);
        }
Exemplo n.º 19
0
        protected override bool OnLoadReponseUser(User user, object value)
        {
            BaseRoot baseRoot = (BaseRoot)value;

            if (base.OnLoadReponseUser(user, value))
            {
                Func <string, int, MappingFields> mapping = (e, id) => new MappingFields {
                    Entity = e, Field = "SMOWNERID", Value = user.id, Id = id
                };
                baseRoot.MappingFields.Add(mapping(ZohoPotential.ENTITY, 0));
                baseRoot.MappingFields.Add(mapping(ZohoEvent.ENTITY, 0));
                int index = 0;
                if (value.GetType() == typeof(ScheduleRoot))
                {
                    ((ScheduleRoot)baseRoot).Contacts.ForEach(f => { baseRoot.MappingFields.Add(mapping(ZohoContact.ENTITY, index++)); });
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 20
0
        private bool LoadResponseUser(string response, object value)
        {
            if (response.Contains("{\"error\""))
            {
                return(ErrorResponse(response, "Error Load Response Fields"));
            }

            BaseRoot valueRoot = (BaseRoot)value;

            try
            {
                RootUser rootUser = JsonConvert.DeserializeObject <RootUser>(response);
                if (rootUser.users != null)
                {
                    Predicate <User> filter = s => s.email.Equals(valueRoot.Authentication.Email);
                    if (rootUser.users.user.Exists(e => filter(e)))
                    {
                        User user = rootUser.users.user.Where(w => filter(w)).First();
                        return(OnLoadReponseUser(user, value));
                    }
                }
            }
            catch (JsonSerializationException) { }

            try
            {
                RootUserSimple userSimple = JsonConvert.DeserializeObject <RootUserSimple>(response);
                if (userSimple.users != null)
                {
                    User user = userSimple.users.user;
                    if (user.email.Equals(valueRoot.Authentication.Email))
                    {
                        return(OnLoadReponseUser(userSimple.users.user, value));
                    }
                }
            }
            catch (JsonSerializationException) { }

            return(false);
        }
Exemplo n.º 21
0
 protected bool SendRequestGetRecord(BaseRoot value, string id, Func <string, object, bool> loadResponse)
 {
     return(SendRequestGetRecord(value, GetEntityName(), id, loadResponse));
 }
Exemplo n.º 22
0
 private bool Execute(BaseRoot value, Func <BaseIntegration, BaseRoot, bool> function)
 {
     return(Exec(value.Authentication.Crm, (c) => function(c, value)));
 }
Exemplo n.º 23
0
 public bool AccountGetFields(BaseRoot value) => Execute(value, (c, v) => c.AccountGetFields(v));
Exemplo n.º 24
0
 public bool EventGetFields(BaseRoot value) => Execute(value, (c, v) => c.EventGetFields(v));
Exemplo n.º 25
0
 public bool ContactGetFields(BaseRoot value) => Execute(value, (c, v) => c.ContactGetFields(v));
Exemplo n.º 26
0
 public bool LeadGetFields(BaseRoot value) => Execute(value, (c, v) => c.LeadGetFields(v));
Exemplo n.º 27
0
 protected override void SetId(string id, BaseRoot value)
 {
 }
Exemplo n.º 28
0
 protected bool SendRequestSearch(BaseRoot value, string selectColumn, string searchColumn, string searchValue, Func <string, object, bool> getResponse)
 {
     return(SendRequestSearch(value, GetEntityName(), selectColumn, searchColumn, searchValue, getResponse));
 }
Exemplo n.º 29
0
 protected abstract void SetId(string id, BaseRoot value);
Exemplo n.º 30
0
 public bool AccountGetFields(BaseRoot value) => OnGetFieldsAccount(value.Authentication);