Esempio n. 1
0
        public ServiceRequestController()
        {
            var storageAccountName = ConfigurationManager.AppSettings["Microsoft.Storage.AccountName"];
            var storageAccountKey  = ConfigurationManager.AppSettings["Microsoft.Storage.AccountKey"];

            _serviceRequestTableProvider = new TableProvider <ServiceRequestEntity>(storageAccountName, storageAccountKey, "ServiceRequest");
            var statusTableProvider = new TableProvider <StatusTableEntity>(storageAccountName, storageAccountKey, "Status");

            var connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            var topicName        = ConfigurationManager.AppSettings["Microsoft.ServiceBus.TopicName"];

            _sender = new Sender(connectionString, topicName, statusTableProvider);

            _statusChecker = new StatusChecker(statusTableProvider);
        }
Esempio n. 2
0
 public OrderController(
     LookUpProvider lookUpProvider,
     OrderProvider orderProvider,
     TableProvider tableProvider,
     ConfigurationProvider configurationProvider,
     ProductProvider productProvider,
     IMapper mapper)
 {
     this.productProvider       = productProvider;
     this.lookUpProvider        = lookUpProvider;
     this.orderProvider         = orderProvider;
     this.tableProvider         = tableProvider;
     this.configurationProvider = configurationProvider;
     this.mapper = mapper;
 }
Esempio n. 3
0
 public PokerHub(
     DatabaseService databaseService,
     TableProvider tableProvider,
     PokerUserProvider pokerUserProvider,
     IEventProxy eventProxy,
     TableManager tableManager,
     IHubEventEmitter hubEventEmitter)
 {
     _databaseService   = databaseService;
     _tableProvider     = tableProvider;
     _pokerUserProvider = pokerUserProvider;
     _eventProxy        = eventProxy;
     _tableManager      = tableManager;
     _hubEventEmitter   = hubEventEmitter;
 }
        public UnleashedTableProvider(UnleashedModelProvider model, TableProvider original)
            : base(model)
        {
            this.original = original;

            IEnumerable <PropertyDescriptor> customProperties = TypeDescriptor
                                                                .GetProperties(original.EntityType).Cast <PropertyDescriptor>()
                                                                .Where(p => p.PropertyType.IsSubclassOf(typeof(EntityReference)) == false) // filter out properties of EntityReference type, they are duplicates of regular navigation properties, i.e. SupplierReference is a duplicate of Supplier
                                                                .Where(p => this.RootEntityType.IsAssignableFrom(p.ComponentType))         // filter out properties defined in the EntityObject
                                                                .Where(p => original.Columns.All(c => c.Name != p.Name));                  // filter out properties already recognized by the original provider

            this.columns = original.Columns
                           .Concat(customProperties.Select(p => new UnleashedColumnProvider(this, p)))
                           .ToList().AsReadOnly();
        }
Esempio n. 5
0
 private static void RegisterMetadataTypeDescriptionProvider(TableProvider entity, Func <Type, TypeDescriptionProvider> providerFactory)
 {
     if (providerFactory != null)
     {
         Type entityType = entity.EntityType;
         // Support for type-less MetaTable
         if (entityType != null)
         {
             TypeDescriptionProvider provider = providerFactory(entityType);
             if (provider != null)
             {
                 TypeDescriptor.AddProviderTransparent(provider, entityType);
             }
         }
     }
 }
Esempio n. 6
0
        public Sender(string connectionString, string topicName, TableProvider <StatusTableEntity> statusTableProvider)
        {
            _statusTableProvider = statusTableProvider;
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (namespaceManager.TopicExists(topicName))
            {
                _topicClient = TopicClient.CreateFromConnectionString(connectionString, topicName);
            }
            else
            {
                var topicDescription = new TopicDescription(topicName);
                namespaceManager.CreateTopic(topicDescription);
                _topicClient = TopicClient.CreateFromConnectionString(connectionString, topicName);
            }
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="AdvancedMetaTable"/> class.
    /// </summary>
    /// <param name="metaModel">The meta model.</param>
    /// <param name="tableProvider">The table provider.</param>
    public AdvancedMetaTable(MetaModel metaModel, TableProvider tableProvider) :
        base(metaModel, tableProvider)
    {
        // set the Get Method Name
        var context       = base.CreateContext();
        var getMethodName = DefaultGetMethodName;

        if (context != null && context.HasMethod(DefaultGetMethodName))
        {
            GetMethodName          = getMethodName;
            this.CreateQueryMethod = this.DataContextType.GetMethod(GetMethodName);
        }
        else
        {
            GetMethodName = String.Empty;
        }
    }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var connectionString   = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];
            var topicName          = ConfigurationManager.AppSettings["Microsoft.ServiceBus.TopicName"];
            var costRateReceiver   = new MessageReceiver(connectionString, topicName, "costrate-sub", "CostRate", 2);
            var partNumberReceiver = new MessageReceiver(connectionString, topicName, "pnr-sub", "PartNumber", 2);

            var storageAccountName          = ConfigurationManager.AppSettings["Microsoft.Storage.AccountName"];
            var storageAccountKey           = ConfigurationManager.AppSettings["Microsoft.Storage.AccountKey"];
            var serviceRequestTableProvider = new TableProvider <ServiceRequestEntity>(storageAccountName, storageAccountKey, "ServiceRequest");
            var statusTableProvider         = new TableProvider <StatusTableEntity>(storageAccountName, storageAccountKey, "Status");

            var costRateProcessor   = new CostRateProcessor(costRateReceiver, serviceRequestTableProvider, statusTableProvider);
            var partNumberProcessor = new PartNumberProcessor(partNumberReceiver, serviceRequestTableProvider, statusTableProvider);

            costRateProcessor.Start();
            partNumberProcessor.Start();

            Console.ReadLine();
        }
        /// <summary>
        ///     Set configuration For Initialize Game Service.
        /// </summary>
        /// <param name="configuration">(NOTNULL)configuration For Initialize Game Service</param>
        public static void ConfigurationInstance(GameServiceClientConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new GameServiceException("Configuration Cant Be Null").LogException(typeof(GameService),
                                                                                          DebugLocation.Internal, "ConfigurationInstance");
            }

            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }

            SynchronizationContext = SynchronizationContext.Current;

            if (IsAuthenticated())
            {
                throw new GameServiceException("Must Logout First To ReConfiguration").LogException(typeof(GameService),
                                                                                                    DebugLocation.Internal, "ConfigurationInstance");
            }

            Configuration   = configuration;
            HandlerType     = EventHandlerType.UnityContext;
            DownloadManager = new DownloadManager(Configuration);

            Achievement   = new AchievementProvider();
            Assets        = new AssetsProvider();
            Data          = new DataProvider();
            Table         = new TableProvider();
            CloudFunction = new CloudFunctionProvider();
            Leaderboard   = new LeaderboardProvider();
            LoginOrSignUp = new LoginOrSignUpProvider();
            Player        = new PlayerProvider();
            Save          = new SaveProvider();

            GSLive = new GsLive();
            Social = new Social.Social();
        }
Esempio n. 10
0
        public ActionResult PrintTable(Type type = null)
        {
            if (type is null)
            {
                type = context
                       .GetType()
                       .GetProperties()
                       .Where(n => n.PropertyType.IsGenericType)
                       .First()
                       .PropertyType
                       .GetGenericArguments()[0];
            }

            var entities = (IEnumerable <object>)context
                           .GetType()
                           .GetProperties()
                           .Where(n => n.PropertyType.IsGenericType)
                           .First(n => n.PropertyType.GetGenericArguments()[0] == type)
                           .GetGetMethod().Invoke(context, null);

            var fields = type.GetProperties()
                         .Where(n => (n.PropertyType.IsValueType || n.PropertyType == typeof(string)));

            var model = new TableProvider {
                EntityType      = type,
                FieldNames      = fields.Select(n => n.Name),
                Values          = entities.Select(n => fields.ToDictionary(m => m.Name, m => m.GetValue(n))),
                AvailableTables = context.GetType()
                                  .GetProperties()
                                  .Where(n => n.PropertyType.IsGenericType)
                                  .Select(n => n.PropertyType.GetGenericArguments()[0])
                                  .Distinct(),
            };

            return(View("Index", model));
        }
Esempio n. 11
0
        internal void Initialize()
        {
            // If we don't have a PropertyInfo, we're likely dealing with an association column
            // we created in TryCreateAssociationColumn, and we should skip it here
            if (EntityTypeProperty == null)
            {
                return;
            }

            // Check if there is an Entity that has the same type as this column. If so, we treat this column as an entity ref
            TableProvider parentTable = Table.DataModel.Tables.SingleOrDefault(t => t.EntityType == ColumnType);

            if (parentTable == null)
            {
                return;
            }

            DataServiceColumnProvider toColumn = null;

            ColumnProvider parentPK = null;

            // Look for the matching Entity Set column in the parent table
            foreach (DataServiceColumnProvider parentColumn in parentTable.Columns)
            {
                // Pick up the parent table's PK column on the way
                if (parentColumn.IsPrimaryKey)
                {
                    parentPK = parentColumn;
                }

                // The Entity Set column is expected to be of a type like IList<AcmeProduct>

                if (!parentColumn.ColumnType.IsGenericType)
                {
                    continue;
                }

                Type childrenType = parentColumn.ColumnType.GetGenericArguments()[0];
                if (childrenType == Table.EntityType)
                {
                    toColumn = parentColumn;
                    break;
                }
            }

            var foreignKeyNames = new List <string>();

            foreignKeyNames.Add(Name + "." + parentPK.Name);

            if (toColumn == null)
            {
                Association = new DataServiceAssociationProvider(AssociationDirection.ManyToOne, this, parentTable, foreignKeyNames);
            }
            else
            {
                Association = new DataServiceAssociationProvider(AssociationDirection.ManyToOne, this, toColumn, foreignKeyNames);

                // Create the reverse association
                var reverseAssociation = new DataServiceAssociationProvider(AssociationDirection.OneToMany, toColumn, this, foreignKeyNames);
                toColumn.Association = reverseAssociation;
            }
        }
Esempio n. 12
0
 private DataServiceColumnProvider(TableProvider table)
     : base(table)
 {
 }
Esempio n. 13
0
 public CostRateProcessor(MessageReceiver receiver, TableProvider <ServiceRequestEntity> serviceRequestTableProvider, TableProvider <StatusTableEntity> statusTableProvider) : base(receiver)
 {
     _serviceRequestTableProvider = serviceRequestTableProvider;
     _statusTableProvider         = statusTableProvider;
 }
Esempio n. 14
0
 public TableController(TableProvider tableProvider, IMapper mapper)
 {
     this.tableProvider = tableProvider;
     this.mapper        = mapper;
 }
 /// <summary>Gets all database tables. This will always be an empty collection.</summary>
 /// <param name="cancellationToken">A cancellation token.</param>
 /// <returns>An empty collection of database tables.</returns>
 public IAsyncEnumerable <IRelationalDatabaseTable> GetAllTables(CancellationToken cancellationToken = default)
 {
     return(TableProvider.GetAllTables(cancellationToken));
 }
Esempio n. 16
0
 public StatusChecker(TableProvider <StatusTableEntity> statusTableProvider)
 {
     _statusTableProvider = statusTableProvider;
 }
Esempio n. 17
0
 protected override MetaTable CreateTable(TableProvider provider)
 {
     return(new CustomMetaTable(this, provider));
 }
 public MetaTable(MetaModel metaModel, TableProvider tableProvider)
 {
     _tableProvider = tableProvider;
     Model          = metaModel;
 }
Esempio n. 19
0
 public CodedDataValue(string tableId, IDataTableProvider tables = null)
 {
     this.tableProvider = tables;
     this.tableId       = tableId;
     this.table         = TableProvider.GetCodeTable(tableId);
 }
Esempio n. 20
0
 public MetaTable(MetaModel metaModel, TableProvider tableProvider)
 {
     this._tableProvider = tableProvider;
     this.Model          = metaModel;
 }
Esempio n. 21
0
 /// <summary>
 /// Instantiate a MetaTable object. Can be overridden to instantiate a derived type
 /// </summary>
 /// <returns></returns>
 protected virtual MetaTable CreateTable(TableProvider provider)
 {
     return(new MetaTable(this, provider));
 }
Esempio n. 22
0
 public virtual I GetCell(int row, int column)
 {
     return(TableProvider.GetCell(row: row, column: column));
 }
Esempio n. 23
0
 public CustomMetaTable(MetaModel metaModel, TableProvider tableProvider) :
     base(metaModel, tableProvider)
 {
 }
        public void ResolveAssociations()
        {
            if (associationResolved)
            {
                return;
            }

            associationResolved = true;
            string associated = column.AssociatedTo;

            if (String.IsNullOrEmpty(associated))
            {
                return;
            }

            string[] names = associated.Split(new char[] { '.' });
            if (names.Length != 2)
            {
                throw new ApplicationException("Only associations of type Table.Column are supported");
            }
            string tableName  = names[0];
            string columnName = names[1];

            TableProvider tableProvider = null;

            try {
                tableProvider = Table.DataModel.Tables.First <TableProvider> ((TableProvider tp) => {
                    if (tp.Name == tableName)
                    {
                        return(true);
                    }
                    return(false);
                });
            } catch {
                return;
            }

            if (tableProvider == null)
            {
                return;
            }

            ColumnProvider toColumn = null;

            try {
                toColumn = tableProvider.Columns.First <ColumnProvider> ((ColumnProvider cp) => {
                    if (cp.Name == columnName)
                    {
                        return(true);
                    }
                    return(false);
                });
            } catch {
                return;
            }

            if (toColumn == null)
            {
                return;
            }

            IsForeignKeyComponent = true;
            Association           = new DynamicDataAssociationProvider(column.AssociationDirection, this, toColumn);
        }
 /// <summary>
 /// Creates the table.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <returns></returns>
 protected override MetaTable CreateTable(TableProvider provider)
 {
     return(new AdvancedMetaTable(this, provider));
 }
Esempio n. 26
0
        internal MetaTable(MetaModel model, TableProvider provider, ContextConfiguration configuration)
        {
            bool scaffoldAllTables;

            this.model = model;
            Provider   = provider;
            if (configuration != null)
            {
                ScaffoldAllTables = scaffoldAllTables = configuration.ScaffoldAllTables;
                Func <Type, TypeDescriptionProvider> factory = configuration.MetadataProviderFactory;
                if (factory != null)
                {
                    Type t = EntityType;
                    TypeDescriptionProvider p = factory(t);
                    if (p != null)
                    {
                        TypeDescriptor.AddProvider(p, t);
                    }
                }
            }
            else
            {
                scaffoldAllTables = false;
            }

            ScaffoldTableAttribute attr = null;

            MetaModel.GetDataFieldAttribute <ScaffoldTableAttribute> (Attributes, ref attr);
            Scaffold        = attr != null ? attr.Scaffold : scaffoldAllTables;
            DataContextType = provider.DataModel.ContextType;

            var        columns               = new List <MetaColumn> ();
            var        primaryKeyColumns     = new List <MetaColumn> ();
            var        foreignKeyColumnNames = new List <string> ();
            MetaColumn mc;

            foreach (var c in provider.Columns)
            {
                // this seems to be the determining factor on whether we create
                // MetaColumn or MetaForeignKeyColumn/MetaChildrenColumn. As the
                // determination depends upon the relationship direction, we must
                // check that using the ColumnProvider's association, if any.
                //
                //  http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metaforeignkeycolumn.aspx
                //  http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.metachildrencolumn.aspx
                //  http://forums.asp.net/t/1426992.aspx
                var association = c.Association;
                if (association == null)
                {
                    mc = new MetaColumn(this, c);
                }
                else
                {
                    var dir = association.Direction;
                    if (dir == AssociationDirection.OneToOne || dir == AssociationDirection.ManyToOne)
                    {
                        mc = new MetaForeignKeyColumn(this, c);
                    }
                    else
                    {
                        mc = new MetaChildrenColumn(this, c);
                    }
                }

                columns.Add(mc);
                if (c.IsPrimaryKey)
                {
                    primaryKeyColumns.Add(mc);
                }

                if (mc is MetaForeignKeyColumn)
                {
                    foreignKeyColumnNames.Add(c.Name);
                }
            }

            Columns           = new ReadOnlyCollection <MetaColumn> (columns);
            PrimaryKeyColumns = new ReadOnlyCollection <MetaColumn> (primaryKeyColumns);
            if (foreignKeyColumnNames.Count == 0)
            {
                ForeignKeyColumnsNames = String.Empty;
            }
            else
            {
                ForeignKeyColumnsNames = String.Join(",", foreignKeyColumnNames.ToArray());
            }

            HasPrimaryKey = primaryKeyColumns.Count > 0;

            // See http://forums.asp.net/t/1388561.aspx
            //
            // Also, http://forums.asp.net/t/1307243.aspx - that seems to be out of
            // scope for us, though (at least for now)
            IsReadOnly = primaryKeyColumns.Count == 0;

            // FIXME: fill more properties.
        }