Пример #1
0
 public MetricsHolderRepository(IDbContext context,
                                MetricsService metricsService,
                                ILog log, RelationService relRepo)
     : base(context, log, relRepo)
 {
     this.metricsService = metricsService;
 }
Пример #2
0
        public PDatabase OpenExistingDatabase(ref PDatabase pDatabase)
        {
            //reset Concrete
            ConcreteDb.Instance.resetConnection();
            try
            {
                //IList<PSchema> Schemas = new List<PSchema>();
                var Schemas = SchemaService.Instance().getAllScheme();
                pDatabase.Schemas = Schemas;

                //IList<PRelation> relations = new List<PRelation>();
                var relations = RelationService.Instance().getAllRelation();
                pDatabase.Relations = relations;

                //var querys = new List<PQuery>();
                var querys = QueryService.Instance().getAllQuery();
                pDatabase.Queries = querys;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Notification");

                return(null);
            }
            return(pDatabase);
        }
 public SettingsHolderRepository(IDbContext context, ILog log,
                                 SettingsService settingsService, RelationService relRepo)
     : base(context, log, relRepo)
 {
     this.settingsService = settingsService;
     ComponentsLoadLevel  = ComponentsLoadLevel.Single;
 }
Пример #4
0
 public TestRepository(
     IDbContext context,
     ILog log,
     RelationService relRepo,
     TrackingRepository trackRepo) : base(context, log, relRepo, trackRepo)
 {
 }
Пример #5
0
        public PTuple GetTuplebyId(ref PRelation rel, string tupId)
        {
            var    relid = rel.id;
            PTuple reVal = null;

            {
                var relation = RelationService.Instance().getAllRelation().Where(r => r.id.Equals(relid)).First();

                tupId = tupId.Replace("{", "");
                tupId = tupId.Replace("}", "");

                if (!(relation is null))
                {
                    var pri = relation.schema.Attributes.Where(a => a.primaryKey).First();
                    var atr = String.Format("{0}.{1}", relation.relationName, pri.AttributeName);
                    if (!(pri is null))
                    {
                        try
                        {
                            reVal = relation.tupes.Where(t => SelectCondition.EQUAL(t.valueSet[atr].First(), tupId.Trim(), pri.Type.TypeName)).First();
                        }
                        catch //ko tim thay (insert khi id is Empty)
                        {
                            if (String.IsNullOrEmpty(tupId))
                            {
                                reVal = new PTuple(relation);
                            }
                        }
                    }
                    rel = relation;
                }
            }
            return(reVal);
        }
 public static IEnumerable <T> Related <T>(this IPublishedContent content, string relationAlias)
 {
     return(GetRelatedContent <T>(
                relationAlias,
                RelationService.GetByParentOrChildId(content.Id),
                r => content.Id == r.ChildId ? r.ParentId : r.ChildId
                ));
 }
Пример #7
0
        public HttpResponseMessage Get(int id)
        {
            var result = RelationService.GetById(id);

            return(result == null
                ? Request.CreateResponse(HttpStatusCode.NotFound)
                : Request.CreateResponse(HttpStatusCode.OK, CreateRepresentation(result)));
        }
 public SettingsRepository(
     IDbContext context,
     TaxonomyTree taxonomyTree,
     RelationService relationService,
     ILog log)
     : base(context, log, relationService)
 {
     settingsRelation     = taxonomyTree.GetOrCreatePath(SETTINGS_PATH, "SettingsRepository relations");
     this.relationService = relationService;
 }
Пример #9
0
 public static RelationService Instance()
 {
     lock (synclock)
     {
         if (instance == null)
         {
             instance = new RelationService();
         }
     }
     return(instance);
 }
Пример #10
0
        public StateRepository(
            IDbContext context,
            TaxonomyTree taxonomyTree,
            RelationService relationService,
            ILog log)
            : base(context, log, relationService)
        {
            triggerRelation = taxonomyTree.GetOrCreatePath(TRIGGER_PATH, "StateRepository trigger relations");

            this.taxonomyTree    = taxonomyTree;
            this.relationService = relationService;
        }
Пример #11
0
        public virtual HttpResponseMessage Delete(int id)
        {
            var found = RelationService.GetById(id);

            if (found == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            RelationService.Delete(found);
            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Пример #12
0
 public HttpResponseMessage Post(RelationRepresentation representation)
 {
     try
     {
         var relation = Mapper.Map <IRelation>(representation);
         RelationService.Save(relation);
         return(Request.CreateResponse(HttpStatusCode.OK, CreateRepresentation(relation)));
     }
     catch (ModelValidationException exception)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, exception.Errors));
     }
 }
Пример #13
0
        public MetricsService(
            MetricsRepository metricsRepo,
            MetricsEntryRepository metricsEntryRepo,
            RelationService relationService,
            TaxonomyTree taxonomyTree,
            ILog log)
        {
            this.metricsRepo = metricsRepo;
            this.metricsEntryRepo = metricsEntryRepo;
            this.relationService = relationService;
            this.log = log;

            relationNode = taxonomyTree.GetOrCreatePath(RELATIONS_PATH, "MetricsRepository relations");
        }
Пример #14
0
        public HttpResponseMessage GetByParent(int id, string relationType = null)
        {
            var parent = EntityService.Get(id);

            if (parent == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            var relations    = (string.IsNullOrEmpty(relationType)) ? RelationService.GetByParent(parent) : RelationService.GetByParent(parent, relationType);
            var relationsRep = new RelationListRepresentation(relations.Select(CreateRepresentation).ToList(), new RelationLinkTemplate(CurrentVersionRequest));

            return(Request.CreateResponse(HttpStatusCode.OK, relationsRep));
        }
        public void CodeGenerator_GeneratesEqualitySelectionDeclarations_Correctly(string codeInput, string[] declarations)
        {
            var extractor = new DataStructureExtractor();

            extractor.Visit(codeInput);
            var typeService       = new TypeService(extractor.DataStructure);
            var generationService = new RelationService(extractor.DataStructure, typeService);
            var codeGenerator     = new CodeGenerator(extractor.DataStructure, generationService);

            codeGenerator.Visit(codeInput);

            Console.WriteLine(codeInput);
            Console.WriteLine("====================");
            Console.WriteLine(codeGenerator.CodeOutput);

            foreach (var declaration in declarations)
            {
                Assert.True(codeGenerator.CodeOutput.Contains(declaration));
            }
        }
Пример #16
0
        public HttpResponseMessage Put(int id, RelationRepresentation rel)
        {
            try
            {
                var found = RelationService.GetById(id);
                if (found == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                Mapper.Map(rel, found);
                RelationService.Save(found);

                return(Request.CreateResponse(HttpStatusCode.OK, CreateRepresentation(found)));
            }
            catch (ModelValidationException exception)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, exception.Errors));
            }
        }
Пример #17
0
        public PRelation Insert(PRelation pRelation)
        {
            if (pRelation.id == -1)
            {
                pRelation.id = RelationService.Instance().getNextIdRel();
            }
            using (var conn = ConcreteDb.Instance.BeginTransaction())
            {
                try
                {
                    string SQL = "";
                    SQL  = "";
                    SQL += "INSERT INTO SystemRelation VALUES ( ";
                    SQL += pRelation.id + ",";
                    SQL += "'" + pRelation.relationName + "'" + ",";
                    SQL += pRelation.schema.id;
                    SQL += " );";
                    if (ConcreteDb.Instance.Update(SQL, false) < 0)
                    {
                        throw new Exception(ConcreteDb.Instance.errorMessage);
                    }
                    //insert Relation Data Table

                    if (!RelationService.Instance().InsertTupleDataTable(pRelation))
                    {
                        throw new Exception("The schema have no Attribute!");
                    }
                    conn.Commit();
                }
                catch (Exception ex)
                {
                    conn.Rollback();
                    throw new Exception(ex.Message);
                }
                ConcreteDb.Instance.closeConnection();
            }

            return(pRelation);
        }
 public ClassifiableRepository(IDbContext context, ILog log,
                               RelationService relationService) : base(context, log)
 {
     _relationService = relationService;
 }
Пример #19
0
        private static void RunServer()
        {
            Data.Data.DataPath = "data/";

            Stopwatch sw = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            Console.WriteLine("----===== Tera-Project C# GameServer Emulator =====----\n\n");
            Console.WriteLine("Starting Game Server!\n"
                              + "-------------------------------------------");

            TcpServer = new TcpServer("*", Config.GetServerPort(), Config.GetServerMaxCon());
            Connection.SendAllThread.Start();

            OpCodes.Init();
            Console.WriteLine("OpCodes - Revision 1725 initialized!\n"
                              + "-------------------------------------------\n");

            #region global_components

            //services
            FeedbackService    = new FeedbackService();
            AccountService     = new AccountService();
            PlayerService      = new PlayerService();
            MapService         = new MapService();
            ChatService        = new ChatService();
            VisibleService     = new VisibleService();
            ControllerService  = new ControllerService();
            CraftService       = new CraftService();
            ItemService        = new ItemService();
            AiService          = new AiService();
            GeoService         = new GeoService();
            StatsService       = new StatsService();
            ObserverService    = new ObserverService();
            AreaService        = new AreaService();
            InformerService    = new InformerService();
            TeleportService    = new TeleportService();
            PartyService       = new PartyService();
            SkillsLearnService = new SkillsLearnService();
            CraftLearnService  = new CraftLearnService();
            GuildService       = new GuildService();
            EmotionService     = new EmotionService();
            RelationService    = new RelationService();
            DuelService        = new DuelService();
            StorageService     = new StorageService();
            TradeService       = new TradeService();
            MountService       = new MountService();

            //engines
            ActionEngine = new ActionEngine.ActionEngine();
            AdminEngine  = new AdminEngine.AdminEngine();
            SkillEngine  = new SkillEngine.SkillEngine();
            QuestEngine  = new QuestEngine.QuestEngine();

            #endregion

            GlobalLogic.ServerStart("SERVER=" + Config.GetDatabaseHost() + ";DATABASE=" + Config.GetDatabaseName() + ";UID=" + Config.GetDatabaseUser() + ";PASSWORD="******";PORT=" + Config.GetDatabasePort() + ";charset=utf8");

            Console.WriteLine("-------------------------------------------\n"
                              + "Loading Tcp Service.\n"
                              + "-------------------------------------------");
            TcpServer.BeginListening();

            try
            {
                ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232));
                ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService);
                ServiceApplication.Start();
                Log.Info("InformerService started at *:23232.");

                var webservices = new ServiceManager();
                webservices.Run();
            }
            catch (Exception ex)
            {
                Log.ErrorException("InformerService can not be started.", ex);
            }

            sw.Stop();
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine("           Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s"));
            Console.WriteLine("-------------------------------------------");
        }
Пример #20
0
 public TaxonRepository(IDbContext context, ILog log, RelationRepository relRepo,
                        RelationService relSvc)
     : base(context, log, relSvc)
 {
     this.relRepo = relRepo;
 }
Пример #21
0
        private static void RunServer()
        {
            Data.Data.DataPath = "data/";

            Stopwatch sw = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            Console.WriteLine("----===== GameServer =====----\n\n"
                              + "Starting game server\n\n"
                              + "Loading data files.\n"
                              + "-------------------------------------------");

            TcpServer = new TcpServer("*", 11101, 1000);
            Connection.SendAllThread.Start();

            OpCodes.Init();

            #region global_components

            //services
            FeedbackService    = new FeedbackService();
            AccountService     = new AccountService();
            PlayerService      = new PlayerService();
            MapService         = new MapService();
            ChatService        = new ChatService();
            VisibleService     = new VisibleService();
            ControllerService  = new ControllerService();
            CraftService       = new CraftService();
            ItemService        = new ItemService();
            AiService          = new AiService();
            GeoService         = new GeoService();
            StatsService       = new StatsService();
            ObserverService    = new ObserverService();
            AreaService        = new AreaService();
            InformerService    = new InformerService();
            TeleportService    = new TeleportService();
            PartyService       = new PartyService();
            SkillsLearnService = new SkillsLearnService();
            CraftLearnService  = new CraftLearnService();
            GuildService       = new GuildService();
            EmotionService     = new EmotionService();
            RelationService    = new RelationService();
            DuelService        = new DuelService();
            StorageService     = new StorageService();
            TradeService       = new TradeService();
            MountService       = new MountService();

            //engines
            ActionEngine = new ActionEngine.ActionEngine();
            AdminEngine  = new AdminEngine.AdminEngine();
            SkillEngine  = new SkillEngine.SkillEngine();
            QuestEngine  = new QuestEngine.QuestEngine();

            #endregion

            GlobalLogic.ServerStart();

            TcpServer.BeginListening();

            try
            {
                ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232));
                ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService);
                ServiceApplication.Start();
                Log.Info("InformerService started at *:23232.");
            }
            catch (Exception ex)
            {
                Log.ErrorException("InformerService can not be started.", ex);
            }

            sw.Stop();
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine("           Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s"));
            Console.WriteLine("-------------------------------------------");
        }
Пример #22
0
 public int getNextIdRl()
 {
     return(RelationService.Instance().getNextIdRel());
 }
Пример #23
0
 public PRelation Delete(PRelation pRelation)
 {
     return(RelationService.Instance().Delete(pRelation));
 }
Пример #24
0
 public ScheduleRepository(IDbContext context, ILog log,
                           SettingsService settingsService, RelationService relRepo)
     : base(context, log, settingsService, relRepo)
 {
 }
Пример #25
0
 public CodeGenerator(DataStructure dataStructure, RelationService relationService)
 {
     _dataStructure   = dataStructure;
     _relationService = relationService;
     _updateTable     = new CodeUpdateTable();
 }
Пример #26
0
 public MetricsRepository(IDbContext context, ILog log, RelationService relRepo,
                          MetricsEntryRepository mentryRepo) : base(context, log, relRepo)
 {
     this.mentryRepo = mentryRepo;
 }
Пример #27
0
        public IList <PRelation> getRelByIdSch(PSchema pSchema)
        {
            var relation = RelationService.Instance().getAllRelation().Where(p => p.schema.id == pSchema.id).ToList();

            return(relation);
        }
 public TrackableRepository(IDbContext context, ILog log, RelationService relRepo,
                            TrackingRepository trackRepo) : base(context, log, relRepo)
 {
     this.trackRepo = trackRepo;
 }
Пример #29
0
        private static void RunServer()
        {
            //Start ServerStartTime
            Stopwatch serverStartStopwatch = Stopwatch.StartNew();

            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            //CheckServerMode
            CheckServerMode();

            //ConsoleOutput-Infos
            PrintServerLicence();
            PrintServerInfo();

            //Initialize TcpServer
            TcpServer = new TcpServer("*", Configuration.Network.GetServerPort(), Configuration.Network.GetServerMaxCon());
            Connection.SendAllThread.Start();

            //Initialize Server OpCodes
            OpCodes.Init();
            Console.WriteLine("----------------------------------------------------------------------------\n"
                              + "---===== OpCodes - Revision: " + OpCodes.Version + " EU initialized!");

            //Global Services
            #region global_components
            //Services
            FeedbackService    = new FeedbackService();
            AccountService     = new AccountService();
            PlayerService      = new PlayerService();
            MapService         = new MapService();
            ChatService        = new ChatService();
            VisibleService     = new VisibleService();
            ControllerService  = new ControllerService();
            CraftService       = new CraftService();
            ItemService        = new ItemService();
            AiService          = new AiService();
            GeoService         = new GeoService();
            StatsService       = new StatsService();
            ObserverService    = new ObserverService();
            AreaService        = new AreaService();
            TeleportService    = new TeleportService();
            PartyService       = new PartyService();
            SkillsLearnService = new SkillsLearnService();
            CraftLearnService  = new CraftLearnService();
            GuildService       = new GuildService();
            EmotionService     = new EmotionService();
            RelationService    = new RelationService();
            DuelService        = new DuelService();
            StorageService     = new StorageService();
            TradeService       = new TradeService();
            MountService       = new MountService();

            //Engines
            ActionEngine = new ActionEngine.ActionEngine();
            AdminEngine  = new AdminEngine.AdminEngine();
            SkillEngine  = new SkillEngine.SkillEngine();
            QuestEngine  = new QuestEngine.QuestEngine();
            #endregion

            //Set SqlDatabase Connection
            GlobalLogic.ServerStart("SERVER=" + DAOManager.MySql_Host + ";DATABASE=" + DAOManager.MySql_Database + ";UID=" + DAOManager.MySql_User + ";PASSWORD="******";PORT=" + DAOManager.MySql_Port + ";charset=utf8");
            Console.ForegroundColor = ConsoleColor.Gray;

            //Start Tcp-Server Listening
            Console.WriteLine("----------------------------------------------------------------------------\n"
                              + "---===== Loading GameServer Service.\n"
                              + "----------------------------------------------------------------------------");
            TcpServer.BeginListening();

            //Stop ServerStartTime
            serverStartStopwatch.Stop();
            Console.WriteLine("----------------------------------------------------------------------------");
            Console.WriteLine("---===== GameServer start in {0}", (serverStartStopwatch.ElapsedMilliseconds / 1000.0).ToString("0.00s"));
            Console.WriteLine("----------------------------------------------------------------------------");
        }
Пример #30
0
 public bool InsertTupleIntoTableRelation(PRelation pRelation)
 {
     return(RelationService.Instance().InsertTupleIntoTableRelation(pRelation));
 }
 public HttpProxyRepository(IDbContext context, ILog log, RelationService relRepo)
     : base(context, log, relRepo)
 {
 }