Exemplo n.º 1
0
        /// <summary>
        /// this method will set up schema for new user, will return unique id to application
        /// </summary>
        /// <returns></returns>
        public long SetupSchema(ShardStartegyData dto)
        {
            // call ShardStrategy with app name
            // Strategy will return me shardid.
            // call cedar data method which would execute schema def statements in above shard id

            var dataReader = new DataFactory().GetdataReader(FetchMode.Sql);
            dto.App = _app;
            var shardId = ShardStrategy.ShardSelectionStrategy.SelectShardIdForExistingObject(dto);

            var worker = new IdWorker(shardId);
            var uniqueId = worker.GetUniqueId();
            //_currentShard = uniqueId;
            var appSchema = dataReader.GetAppSchema(shardId);

            var cedarSession = new CedarSession(uniqueId) { EnableTrasaction = true };
            cedarSession.SetupSchema(appSchema);
            cedarSession.Close();
            new DataFactory().GetdataReader(FetchMode.Sql).UpdateShard(shardId);
            _app.Shards = new DataFactory().GetdataReader(FetchMode.Sql).GetAllShardByAppname(_app.ApplicationName);
            return uniqueId;
        }
Exemplo n.º 2
0
        public void SetupSchema(long shardId, long uuid)
        {
            var app = new App();
            var shard = GetShardById(shardId);

            var connectionString = shard.connection_string;

            var appSchema = GetAppSchema(shard.application_name);

            app.AppId = uuid;
            app.ApplicationName = shard.application_name;
            app.Shards.Add(shard);

            var cedarSession = new CedarSession(shardId);
            cedarSession.EnableTrasaction = true;
            cedarSession.SetupSchema(appSchema);
            cedarSession.Close();
        }