Esempio n. 1
0
        public EntityCreator Set(string name, EntityTypeEnum entityType)
        {
            entity.Name         = name;
            entity.EntityTypeID = (int)entityType;

            return(this);
        }
Esempio n. 2
0
        public override CustomFieldType MapToEntity(CustomFieldDTO model)
        {
            var res = new CustomFieldType(new CustomFieldTypeId(model.Id), model.Name, model.DictionaryName,
                                          model.MinValue, model.MaxValue, (EntityTypeEnum.FromValue <EntityTypeEnum>(model.EntityId.ToString())), model.TypeId);

            return(res);
        }
Esempio n. 3
0
 public TNODE(EntityTypeEnum entityTypeEnum)
 {
     Attr           = new ATTR();
     PrevLinks      = new List <LINK>();
     Links          = new List <LINK>();
     EntityTypeEnum = entityTypeEnum;
 }
Esempio n. 4
0
 public TNODE(TNODE node)
 {
     this.Links          = node.Links;
     this.PrevLinks      = node.PrevLinks;
     this.EntityTypeEnum = node.EntityTypeEnum;
     this.Attr           = node.Attr;
 }
Esempio n. 5
0
 // conversion: type -> string
 protected static string EntityTypeToString(EntityTypeEnum entityType)
 {
     if (entityType == EntityTypeEnum.Patient)
     {
         return("patient");
     }
     else if (entityType == EntityTypeEnum.Staff)
     {
         return("staff");
     }
     else if (entityType == EntityTypeEnum.Referrer)
     {
         return("referrer");
     }
     else if (entityType == EntityTypeEnum.Organisation)
     {
         return("organisation");
     }
     else if (entityType == EntityTypeEnum.Site)
     {
         return("site");
     }
     else
     {
         return("");
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Request entity synchronization
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        public void RequestSynchronization(EntityTypeEnum entityType, int nopEntityId)
        {
            if (!QBIsEnabled)
            {
                throw new NopException("QuickBooks is not enabled.");
            }

            QBEntity qbEntity = GetQBEntityByNopId(entityType, nopEntityId);

            if (qbEntity == null)
            {
                qbEntity = new QBEntity()
                {
                    QBEntityId   = String.Empty,
                    EntityTypeId = (int)entityType,
                    NopEntityId  = nopEntityId,
                    SynStateId   = (int)SynStateEnum.Requested,
                    SeqNum       = String.Empty,
                    CreatedOn    = DateTime.UtcNow,
                    UpdatedOn    = DateTime.UtcNow
                };
                CreateQBEntity(qbEntity);
            }
            else if (qbEntity.SynState != SynStateEnum.Requested)
            {
                qbEntity.SynStateId = (int)SynStateEnum.Requested;
                qbEntity.UpdatedOn  = DateTime.UtcNow;
                UpdateQBEntity(qbEntity);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Updates QBEntity
        /// </summary>
        /// <param name="entityId">Entity ID</param>
        /// <param name="qbEntityId">QuickBooks entity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity UpdateQBEntity(int entityId, string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            QBEntity entity = GetQBEntityById(entityId);

            if (entity == null)
            {
                return(null);
            }

            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;

            if (!context.IsAttached(entity))
            {
                context.QBEntities.Attach(entity);
            }

            entity.QBEntityId  = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType  = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState    = synState;
            entity.SeqNum      = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn   = entity.CreatedOn;
            entity.UpdatedOn   = DateTime.UtcNow;

            context.SaveChanges();

            return(entity);
        }
Esempio n. 8
0
        public static List <int> GetArgIndexes(string var, EntityTypeEnum type)
        {
            if (var == "_")
            {
                return(GetAllArgIndexes(type));
            }

            if (var[0] == '\"' & var[var.Length - 1] == '\"')
            {
                string name = var.Substring(1, var.Length - 2);
                if (type == EntityTypeEnum.Procedure)
                {
                    return(new List <int>(new int[] { ProcTable.ProcTable.Instance.GetProcIndex(name) }));
                }

                else if (type == EntityTypeEnum.Variable)
                {
                    return(new List <int>(new int[] { VarTable.VarTable.Instance.GetVarIndex(name) }));
                }
            }

            if (int.TryParse(var, out _))
            {
                return(new List <int>(new int[] { Int32.Parse(var) }));
            }
            return(variableIndexes[var]);
        }
Esempio n. 9
0
        public static string ToHumanReadable(this EntityTypeEnum entityType)
        {
            switch (entityType)
            {
            case EntityTypeEnum.Citizen:
                return("citizen");

            case EntityTypeEnum.Company:
                return("company");

            case EntityTypeEnum.Country:
                return("country");

            case EntityTypeEnum.Newspaper:
                return("newspaper");

            case EntityTypeEnum.Organisation:
                return("organisation");

            case EntityTypeEnum.Party:
                return("party");
            }
#if DEBUG
            throw new NotImplementedException(string.Format("ToHumanReadable not found for {0}", entityType.ToString()));
#else
            return(entityType.ToString());
#endif
        }
Esempio n. 10
0
        public static List <int> GetAllArgIndexes(EntityTypeEnum type)
        {
            List <int> result = new List <int>();

            if (type == EntityTypeEnum.Variable)
            {
                foreach (Variable v in VarTable.VarTable.Instance.Variables)
                {
                    result.Add(v.Index);
                }
            }

            else if (type == EntityTypeEnum.Procedure)
            {
                foreach (Procedure p in ProcTable.ProcTable.Instance.Procedures)
                {
                    result.Add(p.Index);
                }
            }
            else
            {
                foreach (Statement s in StmtTable.StmtTable.Instance.Statements)
                {
                    result.Add(s.CodeLine);
                }
            }

            return(result);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="entityData"></param>
        /// <returns></returns>
        public GameObject CreateFromNetwork(EntityTypeEnum type, int subType, byte[] entityData)
        {
            var        reader = new BinaryReader(new MemoryStream(entityData));
            GameObject obj    = null;

            switch (type)
            {
            case EntityTypeEnum.HERO:
                var heroType = (HeroTypeEnum)subType;
                switch (heroType)
                {
                case HeroTypeEnum.DRAGON_BALL:
                    obj = new DragonBallHero();
                    break;
                }
                break;

            case EntityTypeEnum.GROUND:
                obj = new Ground();
                break;

            case EntityTypeEnum.PROJECTILE:
                obj = new Projectile();
                break;
            }
            if (obj != null)
            {
                obj.FromNetwork(reader);
            }
            return(obj);
        }
Esempio n. 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type"></param>
        /// <param name="id"></param>
        protected AbstractEntity(EntityTypeEnum type, long id)
        {
            Id          = id;
            Type        = type;
            Orientation = 1;

            m_listeners     = new HashSet <Entity.IEntityListener>();
            m_chatByChannel = new Dictionary <ChatChannelEnum, ChatChannelData>
            {
                {
                    ChatChannelEnum.CHANNEL_GENERAL,
                    new ChatChannelData(
                        () => MovementHandler == null ? default(Action <string>) : MovementHandler.Dispatch)
                },
                {
                    ChatChannelEnum.CHANNEL_RECRUITMENT,
                    new ChatChannelData(
                        () => Map == null ? default(Action <string>) : WorldService.Instance.Dispatcher.SafeDispatch)
                },
                {
                    ChatChannelEnum.CHANNEL_DEALING,
                    new ChatChannelData(
                        () => Map == null ? default(Action <string>) : WorldService.Instance.Dispatcher.SafeDispatch)
                },
                { ChatChannelEnum.CHANNEL_ADMIN, new ChatChannelData(() => null) },
                { ChatChannelEnum.CHANNEL_ALIGNMENT, new ChatChannelData(() => null) },
                { ChatChannelEnum.CHANNEL_GROUP, new ChatChannelData(() => null) },
                { ChatChannelEnum.CHANNEL_GUILD, new ChatChannelData(() => null) },
                { ChatChannelEnum.CHANNEL_TEAM, new ChatChannelData(() => null) },
                { ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE, new ChatChannelData(() => Dispatch) },
                { ChatChannelEnum.CHANNEL_PRIVATE_SEND, new ChatChannelData(() => Dispatch) }
            };
        }
Esempio n. 13
0
        protected void createEntity(EntityTypeEnum entityType)
        {
            entity = new Entity();
            entity.EntityTypeID = (int)entityType;
            entity.EntityID     = idGenerator.UniqueID;

            SetRandomName();
        }
Esempio n. 14
0
 /// <summary>
 /// Instructs the media mapper to link the media item to the given reference field on the entity
 /// </summary>
 /// <param name="type"></param>
 /// <param name="entityIds"></param>
 /// <param name="fieldId"></param>
 /// <returns></returns>
 public MediaProfileBuilder MapTo(EntityTypeEnum type, IEnumerable <string> entityIds, string fieldId)
 {
     foreach (var id in entityIds)
     {
         _mappings.Add(new MediaEntityMapping(type, id, fieldId));
     }
     return(this);
 }
Esempio n. 15
0
        protected Entity(string[] inputs)
        {
            EntityId = int.Parse(inputs[0]);
            string entityType = inputs[1];

            Col        = int.Parse(inputs[2]);
            Row        = int.Parse(inputs[3]);
            EntityType = (EntityTypeEnum)Enum.Parse(typeof(EntityTypeEnum), entityType);
        }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FavoriteContact" /> class.
 /// </summary>
 /// <param name="entityId">List or Contact ID. (required).</param>
 /// <param name="entityType">Entity type which should be marked as **favourite**. (required).</param>
 /// <param name="primaryLabel">Contact first name/last name if entityType is **contact**, List name if entity type is **list**. (required).</param>
 /// <param name="secondaryLabel">Phone number if entityType is **contact**, List contacts number if entity type is **list**. (required).</param>
 /// <param name="tertiaryLabel">Contact country if entityType is **contact** else null. (required).</param>
 /// <param name="avatar">avatar (required).</param>
 public FavoriteContact(int?entityId = default(int?), EntityTypeEnum entityType = default(EntityTypeEnum), string primaryLabel = default(string), string secondaryLabel = default(string), string tertiaryLabel = default(string), string avatar = default(string))
 {
     // to ensure "entityId" is required (not null)
     if (entityId == null)
     {
         throw new InvalidDataException("entityId is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.EntityId = entityId;
     }
     // to ensure "entityType" is required (not null)
     if (entityType == null)
     {
         throw new InvalidDataException("entityType is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.EntityType = entityType;
     }
     // to ensure "primaryLabel" is required (not null)
     if (primaryLabel == null)
     {
         throw new InvalidDataException("primaryLabel is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.PrimaryLabel = primaryLabel;
     }
     // to ensure "secondaryLabel" is required (not null)
     if (secondaryLabel == null)
     {
         throw new InvalidDataException("secondaryLabel is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.SecondaryLabel = secondaryLabel;
     }
     // to ensure "tertiaryLabel" is required (not null)
     if (tertiaryLabel == null)
     {
         throw new InvalidDataException("tertiaryLabel is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.TertiaryLabel = tertiaryLabel;
     }
     // to ensure "avatar" is required (not null)
     if (avatar == null)
     {
         throw new InvalidDataException("avatar is a required property for FavoriteContact and cannot be null");
     }
     else
     {
         this.Avatar = avatar;
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Gets QBEntity by nopCommerce entity ID
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <returns>QBEntity</returns>
        public QBEntity GetQBEntityByNopId(EntityTypeEnum entityType, int nopEntityId)
        {
            var query = from qbe in _context.QBEntities
                        where qbe.EntityTypeId == (int)entityType && qbe.NopEntityId == nopEntityId
                        select qbe;

            QBEntity entity = query.SingleOrDefault();

            return(entity);
        }
Esempio n. 18
0
 public void GetAll(EntityTypeEnum entityType, ListFetchStrategy <CustomFieldType> fs)
 {
     if (entityType == null)
     {
         rep.GetAll(fs);
     }
     else
     {
         rep.Find(c => c.EntityId == entityType, fs);
     }
 }
Esempio n. 19
0
 public void FindBy(EntityTypeEnum entityId, ListFetchStrategy <CustomFieldType> fs)
 {
     if (entityId == null)
     {
         rep.GetAll(fs);
     }
     else
     {
         rep.Find(c => Equals(c.EntityId, entityId), fs);
     }
 }
Esempio n. 20
0
 public Statement(EntityTypeEnum entityTypeEnum, int codeLine)
 {
     if (!(entityTypeEnum == EntityTypeEnum.Assign || entityTypeEnum == EntityTypeEnum.If || entityTypeEnum == EntityTypeEnum.While || entityTypeEnum == EntityTypeEnum.Call))
     {
         throw new InvalidOperationException();
     }
     CodeLine     = codeLine;
     Type         = entityTypeEnum;
     ModifiesList = new Dictionary <int, bool>();
     UsesList     = new Dictionary <int, bool>();
 }
Esempio n. 21
0
        /// <summary>
        /// Gets QBEntity by nopCommerce entity ID
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <returns>QBEntity</returns>
        public static QBEntity GetQBEntityByNopId(EntityTypeEnum entityType, int nopEntityId)
        {
            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;

            var query = from qbe in context.QBEntities
                        where qbe.EntityTypeId == (int)entityType && qbe.NopEntityId == nopEntityId
                        select qbe;

            QBEntity entity = query.SingleOrDefault();

            return(entity);
        }
Esempio n. 22
0
 public int InsertStmt(EntityTypeEnum entityTypeEnum, int codeLine)
 {
     if (Statements.Where(i => i.CodeLine == codeLine).Any())
     {
         return(-1);
     }
     else
     {
         Statement variable = new Statement(entityTypeEnum, codeLine);
         Statements.Add(variable);
         return(0);
     }
 }
Esempio n. 23
0
        public bool WillGiftUseFuel(Entity source, Entity destination)
        {
            var entityTypesUsingFuel = new EntityTypeEnum[]
            {
                EntityTypeEnum.Newspaper,
                EntityTypeEnum.Company
            };

            if (source.Is(EntityTypeEnum.Company) && entityTypesUsingFuel.Contains(destination.GetEntityType()))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 24
0
            public void Synchronize()
            {
                EntityTypeEnum entityType = EntityTypeEnum.Hierarchy;

                var type = $@"teste.Sync{entityType.ToString()}";

                var coco = System.Reflection.Assembly.GetExecutingAssembly().FullName;
                var tata = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

                Entity = (ISyncEntity)System.Reflection.Assembly.GetExecutingAssembly().CreateInstance(type);
                var teste = GetInstance(type);


                Entity.SynchronizeAll();
            }
Esempio n. 25
0
        private static TNODE GetNodeByType(EntityTypeEnum et, int ind)
        {
            TNODE node;

            if (et == EntityTypeEnum.Procedure)
            {
                node = ProcTable.ProcTable.Instance.GetAstRoot(ind);
            }
            else
            {
                node = StmtTable.StmtTable.Instance.GetAstRoot(ind);
            }

            return(node);
        }
Esempio n. 26
0
 // conversion: type -> string
 protected static string EntityTypeToString(EntityTypeEnum entityType)
 {
     if (entityType == EntityTypeEnum.Patient)
         return "patient";
     else if (entityType == EntityTypeEnum.Staff)
         return "staff";
     else if (entityType == EntityTypeEnum.Referrer)
         return "referrer";
     else if (entityType == EntityTypeEnum.Organisation)
         return "organisation";
     else if (entityType == EntityTypeEnum.Site)
         return "site";
     else
         return "";
 }
Esempio n. 27
0
        public List <ProductTypeEnum> GetAllowedProductsForEntity(EntityTypeEnum entityType)
        {
            switch (entityType)
            {
            case EntityTypeEnum.Citizen:
                return(ProductGroups.Consumables
                       .AddRet(ProductTypeEnum.House)
                       .ToList());

            case EntityTypeEnum.Newspaper:
                return(new List <ProductTypeEnum>()
                {
                    ProductTypeEnum.Paper,
                    ProductTypeEnum.Oil
                });

            case EntityTypeEnum.Company:
            {
                return(ProductGroups.All);
            }

            case EntityTypeEnum.Organisation:
            {
                return(ProductGroups.All);
            }

            case EntityTypeEnum.Country:
            {
                return(new List <ProductTypeEnum>());
            }

            case EntityTypeEnum.Party:
            {
                return(new List <ProductTypeEnum>());
            }

            case EntityTypeEnum.Hotel:
            {
                return(new List <ProductTypeEnum>()
                    {
                        ProductTypeEnum.ConstructionMaterials,
                        ProductTypeEnum.Fuel
                    });
            }
            }

            throw new NotImplementedException();
        }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Mapping" /> class.
 /// </summary>
 /// <param name="created">The datetime the mapping was created in the Smarkets exchange (required).</param>
 /// <param name="entityType">The entity type of the event. Provider ID is unique for each entity type (required) (default to EntityTypeEnum.Match).</param>
 /// <param name="providerId">This ID uniquely identifies the event for the provider (required).</param>
 /// <param name="providerName">The name of the provider for which mappings are requested (required).</param>
 /// <param name="smarketsId">This ID uniquely identifies an event (required).</param>
 public Mapping(string created = default(string), EntityTypeEnum entityType = EntityTypeEnum.Match, string providerId = default(string), ProviderNameEnum providerName = default(ProviderNameEnum), string smarketsId = default(string))
 {
     // to ensure "created" is required (not null)
     if (created == null)
     {
         throw new InvalidDataException("created is a required property for Mapping and cannot be null");
     }
     else
     {
         this.Created = created;
     }
     // to ensure "entityType" is required (not null)
     if (entityType == null)
     {
         throw new InvalidDataException("entityType is a required property for Mapping and cannot be null");
     }
     else
     {
         this.EntityType = entityType;
     }
     // to ensure "providerId" is required (not null)
     if (providerId == null)
     {
         throw new InvalidDataException("providerId is a required property for Mapping and cannot be null");
     }
     else
     {
         this.ProviderId = providerId;
     }
     // to ensure "providerName" is required (not null)
     if (providerName == null)
     {
         throw new InvalidDataException("providerName is a required property for Mapping and cannot be null");
     }
     else
     {
         this.ProviderName = providerName;
     }
     // to ensure "smarketsId" is required (not null)
     if (smarketsId == null)
     {
         throw new InvalidDataException("smarketsId is a required property for Mapping and cannot be null");
     }
     else
     {
         this.SmarketsId = smarketsId;
     }
 }
 /// <summary>
 /// Constructs a BattleEntityModel based on the monster input
 /// </summary>
 /// <param name="data"></param>
 public BattleEntityModel(MonsterModel data)
 {
     EntityType       = EntityTypeEnum.Monster;
     Id               = data.Id;
     Alive            = data.Alive;
     ExperiencePoints = data.ExperienceGiven;
     Level            = data.Level;
     Name             = data.Name;
     Description      = data.Description;
     Speed            = data.Speed;
     ImageURI         = data.ImageURI;
     CurrentHealth    = data.CurrentHealth;
     MaxHealth        = data.MaxHealth;
     Attack           = data.Attack;
     Defense          = data.Defense;
     Range            = data.Range;
 }
Esempio n. 30
0
        /// <summary>
        /// Creates a new QBEntity
        /// </summary>
        /// <param name="qbEntityId">QBEntity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity CreateQBEntity(string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;
            QBEntity         entity  = context.QBEntities.CreateObject();

            entity.QBEntityId  = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType  = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState    = synState;
            entity.SeqNum      = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn   = DateTime.UtcNow;
            entity.UpdatedOn   = DateTime.UtcNow;

            context.QBEntities.AddObject(entity);
            context.SaveChanges();

            return(entity);
        }
Esempio n. 31
0
        /// <summary>
        /// Request entity synchronization
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        public static void RequestSynchronization(EntityTypeEnum entityType, int nopEntityId)
        {
            if (!QBIsEnabled)
            {
                throw new NopException("QuickBooks is not enabled.");
            }

            QBEntity qbEntity = GetQBEntityByNopId(entityType, nopEntityId);

            if (qbEntity == null)
            {
                qbEntity = CreateQBEntity(String.Empty, entityType, nopEntityId, SynStateEnum.Requested, String.Empty);
            }
            else if (qbEntity.SynState != SynStateEnum.Requested)
            {
                qbEntity = UpdateQBEntity(qbEntity.EntityId, qbEntity.QBEntityId, qbEntity.EntityType, qbEntity.NopEntityId, SynStateEnum.Requested, qbEntity.SeqNum);
            }
        }
Esempio n. 32
0
 // creation methods
 public static EntityType GetByType(EntityTypeEnum entityType)
 {
     return new EntityType(entityType);
 }
Esempio n. 33
0
 // constructor (hidden to force using creation methods
 protected EntityType(EntityTypeEnum _type)
 {
     this._type = _type;
 }
Esempio n. 34
0
 /// <summary>
 /// 生成数据库连接
 /// </summary>
 /// <param name="database">数据库枚举</param>
 /// <returns>对应数据库连接</returns>
 protected SqlConnection CreateSqlConnection(EntityTypeEnum database = EntityTypeEnum.EBS_READ)
 {
     string databaseName = ((EntityTypeEnum)database).ToString();
     string connectionStr = ConfigurationManager.ConnectionStrings[databaseName].ConnectionString;
     return new SqlConnection(connectionStr);
 }
Esempio n. 35
0
        /// <summary>
        /// Request entity synchronization
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        public void RequestSynchronization(EntityTypeEnum entityType, int nopEntityId)
        {
            if(!QBIsEnabled)
            {
                throw new NopException("QuickBooks is not enabled.");
            }

            QBEntity qbEntity = GetQBEntityByNopId(entityType, nopEntityId);
            if (qbEntity == null)
            {
                qbEntity = new QBEntity()
                {
                    QBEntityId = String.Empty,
                    EntityTypeId = (int)entityType,
                    NopEntityId = nopEntityId,
                    SynStateId = (int)SynStateEnum.Requested,
                    SeqNum = String.Empty,
                    CreatedOn = DateTime.UtcNow,
                    UpdatedOn = DateTime.UtcNow
                };
                CreateQBEntity(qbEntity);
            }
            else if (qbEntity.SynState != SynStateEnum.Requested)
            {
                qbEntity.SynStateId = (int)SynStateEnum.Requested;
                qbEntity.UpdatedOn = DateTime.UtcNow;
                UpdateQBEntity(qbEntity);
            }
        }
Esempio n. 36
0
        /// <summary>
        /// Gets QBEntity by nopCommerce entity ID
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <returns>QBEntity</returns>
        public static QBEntity GetQBEntityByNopId(EntityTypeEnum entityType, int nopEntityId)
        {
            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;

            var query = from qbe in context.QBEntities
                        where qbe.EntityTypeId == (int)entityType && qbe.NopEntityId == nopEntityId
                        select qbe;

            QBEntity entity = query.SingleOrDefault();

            return entity;
        }
Esempio n. 37
0
        /// <summary>
        /// Gets all QBEntities
        /// </summary>
        /// <param name="entityType">Entity type or null</param>
        /// <param name="synState">Synchronization state or null</param>
        /// <param name="count">Number of records to return</param>
        /// <returns>QBEntity collection</returns>
        public List<QBEntity> GetAllQBEntities(EntityTypeEnum? entityType, SynStateEnum? synState, int count)
        {
            if (count <= 0)
            {
                return new List<QBEntity>();
            }

            var query = (IQueryable<QBEntity>)_context.QBEntities;

            if (entityType.HasValue)
            {
                int entityTypeId = (int)entityType.Value;
                query = query.Where(qbe => qbe.EntityTypeId == entityTypeId);
            }

            if (synState.HasValue)
            {
                int synStateId = (int)synState.Value;
                query = query.Where(qbe => qbe.SynStateId == synStateId);
            }

            query = query.OrderBy(qbe => qbe.UpdatedOn);

            return query.Take(count).ToList();
        }
 /// <summary>
 /// 
 /// </summary>
 protected AbstractFighter(EntityTypeEnum type, long id, bool staticInvocation = false)
     : base(type, id)
 {
     StaticInvocation = staticInvocation;
 }
Esempio n. 39
0
        /// <summary>
        /// Updates QBEntity
        /// </summary>
        /// <param name="entityId">Entity ID</param>
        /// <param name="qbEntityId">QuickBooks entity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity UpdateQBEntity(int entityId, string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            QBEntity entity = GetQBEntityById(entityId);
            if (entity == null)
            {
                return null;
            }

            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;
            if (!context.IsAttached(entity))
            {
                context.QBEntities.Attach(entity);
            }

            entity.QBEntityId = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState = synState;
            entity.SeqNum = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn = entity.CreatedOn;
            entity.UpdatedOn = DateTime.UtcNow;

            context.SaveChanges();

            return entity;
        }
Esempio n. 40
0
        /// <summary>
        /// Request entity synchronization
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        public static void RequestSynchronization(EntityTypeEnum entityType, int nopEntityId)
        {
            if(!QBIsEnabled)
            {
                throw new NopException("QuickBooks is not enabled.");
            }

            QBEntity qbEntity = GetQBEntityByNopId(entityType, nopEntityId);
            if (qbEntity == null)
            {
                qbEntity = CreateQBEntity(String.Empty, entityType, nopEntityId, SynStateEnum.Requested, String.Empty);
            }
            else if(qbEntity.SynState != SynStateEnum.Requested)
            {
                qbEntity = UpdateQBEntity(qbEntity.EntityId, qbEntity.QBEntityId, qbEntity.EntityType, qbEntity.NopEntityId, SynStateEnum.Requested, qbEntity.SeqNum);
            }
        }
Esempio n. 41
0
        /// <summary>
        /// Gets QBEntity by nopCommerce entity ID
        /// </summary>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <returns>QBEntity</returns>
        public QBEntity GetQBEntityByNopId(EntityTypeEnum entityType, int nopEntityId)
        {
            var query = from qbe in _context.QBEntities
                        where qbe.EntityTypeId == (int)entityType && qbe.NopEntityId == nopEntityId
                        select qbe;

            QBEntity entity = query.SingleOrDefault();

            return entity;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        /// <param name="id"></param>
        protected AbstractEntity(EntityTypeEnum type, long id)
        {
            Id = id;
            Type = type;
            Orientation = 1;

            m_listeners = new HashSet<Entity.IEntityListener>();
            m_chatByChannel = new Dictionary<ChatChannelEnum, ChatChannelData>
               {
               {
                   ChatChannelEnum.CHANNEL_GENERAL,
                   new ChatChannelData(
                       () => MovementHandler == null ? default(Action<string>) : MovementHandler.Dispatch)
               },
               {
                   ChatChannelEnum.CHANNEL_RECRUITMENT,
                   new ChatChannelData(
                       () => Map == null ? default(Action<string>) : WorldService.Instance.Dispatcher.SafeDispatch)
               },
               {
                   ChatChannelEnum.CHANNEL_DEALING,
                   new ChatChannelData(
                       () => Map == null ? default(Action<string>) : WorldService.Instance.Dispatcher.SafeDispatch)
               },
               {ChatChannelEnum.CHANNEL_ADMIN, new ChatChannelData(() => null)},
               {ChatChannelEnum.CHANNEL_ALIGNMENT, new ChatChannelData(() => null)},
               {ChatChannelEnum.CHANNEL_GROUP, new ChatChannelData(() => null)},
               {ChatChannelEnum.CHANNEL_GUILD, new ChatChannelData(() => null)},
               {ChatChannelEnum.CHANNEL_TEAM, new ChatChannelData(() => null)},
               {ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE, new ChatChannelData(() => Dispatch)},
               {ChatChannelEnum.CHANNEL_PRIVATE_SEND, new ChatChannelData(() => Dispatch)}
               };
        }
Esempio n. 43
0
        /// <summary>
        /// Creates a new QBEntity
        /// </summary>
        /// <param name="qbEntityId">QBEntity ID</param>
        /// <param name="entityType">Entity type</param>
        /// <param name="nopEntityId">nopCommerce entity ID</param>
        /// <param name="synState">Synchronization state</param>
        /// <param name="seqNum">Edit sequence number</param>
        /// <returns>QBEntity</returns>
        public static QBEntity CreateQBEntity(string qbEntityId, EntityTypeEnum entityType, int nopEntityId, SynStateEnum synState, string seqNum)
        {
            NopObjectContext context = ObjectContextHelper.CurrentObjectContext;
            QBEntity entity = context.QBEntities.CreateObject();

            entity.QBEntityId = CommonHelper.EnsureMaximumLength(qbEntityId, 50);
            entity.EntityType = entityType;
            entity.NopEntityId = nopEntityId;
            entity.SynState = synState;
            entity.SeqNum = CommonHelper.EnsureMaximumLength(seqNum, 20);
            entity.CreatedOn = DateTime.UtcNow;
            entity.UpdatedOn = DateTime.UtcNow;

            context.QBEntities.AddObject(entity);
            context.SaveChanges();

            return entity;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="account"></param>
        /// <param name="characterDAO"></param>
        /// <param name="type"></param>
        public CharacterEntity(AccountTicket account, CharacterDAO characterDAO, EntityTypeEnum type = EntityTypeEnum.TYPE_CHARACTER)
            : base(type, characterDAO.Id)
        {
            m_lastRegenTime = -1;
            m_lastEmoteId = -1;

            Away = false;
            DatabaseRecord = characterDAO;
            Alignment = characterDAO.Alignment;

            Account = account;
            PartyId = -1;
            PartyInvitedPlayerId = -1;
            PartyInviterPlayerId = -1;
            GuildInvitedPlayerId = -1;
            GuildInviterPlayerId = -1;
            NotifyOnFriendConnection = true;

            Quests = new List<CharacterQuest>(characterDAO.Quests.Select(record => new CharacterQuest(this, record)));

            CharacterJobs = new JobBook(this);
            Statistics = new GenericStats(characterDAO);
            SpellBook = SpellBookFactory.Instance.Create(this);
            Waypoints = CharacterWaypointRepository.Instance.GetByCharacterId(Id);
            FrameManager = new FrameManager<CharacterEntity, string>(this);
            Inventory = new CharacterInventory(this);
            Bank = BankManager.Instance.GetBankByAccountId(AccountId);
            PersonalShop = new PersistentInventory((int)EntityTypeEnum.TYPE_MERCHANT, Id);
            Relations = SocialRelationRepository.Instance.GetByAccountId(AccountId);

            var guildMember = GuildManager.Instance.GetMember(characterDAO.Guild.GuildId, Id);
            if (guildMember != null)
                if (type == EntityTypeEnum.TYPE_CHARACTER)
                    guildMember.CharacterConnected(this);
                else
                    SetCharacterGuild(guildMember); // Merchant

            SetChatChannel(ChatChannelEnum.CHANNEL_GUILD, () => DispatchGuildMessage);
            SetChatChannel(ChatChannelEnum.CHANNEL_GROUP, () => DispatchPartyMessage);

            RefreshPersonalShopTaxe();
            CheckRestrictions();
            LoadEquippedMount();
        }
Esempio n. 45
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="type"></param>
 /// <param name="id"></param>
 /// <param name="staticInvocation"></param>
 protected AIFighter(EntityTypeEnum type, long id, bool staticInvocation = false)
     : base(type, id, staticInvocation)
 {
     CurrentBrain = new DefaultAIBrain(this);
 }