public void TestMethod1()
        {
            List<KeyValuePair<string, string>> mongoEnv = new List<KeyValuePair<string, string>>();

            mongoEnv.Add(new KeyValuePair<string, string>("MongoServer", "localhost"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoPort", "27017"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoRepositorySvcConfig", "ServiceConfig"));

            ServiceComponentProvider scp = new ServiceComponentProvider(mongoEnv);
            ServiceComponent sc = new ServiceComponent()
            {
                Assembly = "theAssembly",
                Class = "theClass",
                CommandMessageQueue = "theQueue",
                Config = "theConfig",
                CreateDate = DateTime.UtcNow,
                Creator = string.Format(@"{0}\{1}", Environment.UserDomainName, Environment.UserName),
                IsActive = false,
                IsPaused = false,
                Machine = Environment.MachineName,
                ParamsAssembly = "paramsAssembly",
                ParamsClass = "paramsClass"
            };

            Guid origId = sc.Id;

            scp.Insert(sc);

            ServiceComponent sc2 = scp.Queryable().Single(x => x.Id == origId);

            Assert.AreEqual<Guid>(origId, sc2.Id);

            scp.Delete(sc2);
        }
 public RunningServiceComponent(string environment, string configURL, ServiceComponent serviceComponent, IEnumerable<KeyValuePair<string, string>> envConfig)
 {
     this.Environment = environment;
     this.ConfigURL = configURL;
     this.ServiceComponentData = serviceComponent;
     this.EnvironmentConfig = envConfig;
     this.Process = Path.GetFileName(System.Reflection.Assembly.GetCallingAssembly().CodeBase);
 }
示例#3
0
        static void Main(string[] args)
        {
            var mongoEnv = new List<KeyValuePair<string, string>>();

            mongoEnv.Add(new KeyValuePair<string, string>("MongoServer", "localhost"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoPort", "27017"));
            mongoEnv.Add(new KeyValuePair<string, string>("MongoRepositorySvcConfig", "ServiceConfig"));

            //ServiceComponentProvider scp = new ServiceComponentProvider(mongoEnv);
            //ServiceComponent sc = new ServiceComponent()
            //{
            //	Assembly = "SampleServiceComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
            //	Class = "DKK.SampleServiceComponent.SampleComponent",
            //	CommandMessageQueue = string.Empty,
            //	Config = string.Empty,
            //	CreateDate = DateTime.UtcNow,
            //	Creator = $@"{Environment.UserDomainName}\\{Environment.UserName}",
            //	FriendlyName = "Sample Component I",
            //	IsActive = true,
            //	IsPaused = false,
            //	Machine = Environment.MachineName,
            //	ParamsAssembly = "SampleServiceComponent, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
            //	ParamsClass = "DKK.SampleServiceComponent.SampleComponentParams",
            //};

            //Guid origId = sc.Id;

            //scp.Insert(sc);

            //ServiceComponent sc2 = scp.Queryable().Single(x => x.Id == origId);

            //if (origId != sc2.Id)
            //	throw new Exception("Ids do not match");

            //ServiceComponent sc = scp.Queryable().FirstOrDefault();
            //SampleComponentParams theParams = new SampleComponentParams() { IdleMessageRate = 1 };

            //sc.Config = JsonConvert.SerializeObject(theParams, Formatting.None, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
            //sc.ParamsAssembly = theParams.GetType().Assembly.FullName;
            //sc.ParamsClass = theParams.GetType().FullName;

            //scp.Update(sc);

            var theComponent = new SampleComponent();
            var theParams = new SampleComponentParams() { IdleMessageRate = 1, WorkQueue = "SampleWorkQueue" };

            var sc1 = new ServiceComponent()
            {
                Id = Guid.NewGuid(),
                Assembly = theComponent.GetType().Assembly.FullName,
                Class = theComponent.GetType().FullName,
                Config = JsonConvert.SerializeObject(theParams, Formatting.None, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }),
                FriendlyName = "Sample Component I",
                IsActive = true,
                IsPaused = false,
                ParamsAssembly = theParams.GetType().Assembly.FullName,
                ParamsClass = theParams.GetType().FullName,
            };

            //ServiceComponent sc2 = new ServiceComponent()
            //{
            //	Id = Guid.NewGuid(),
            //	Assembly = theComponent.GetType().Assembly.FullName,
            //	Class = theComponent.GetType().FullName,
            //	Config = JsonConvert.SerializeObject(theParams, Formatting.None, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }),
            //	FriendlyName = "Sample Component II",
            //	IsActive = true,
            //	IsPaused = false,
            //	ParamsAssembly = theParams.GetType().Assembly.FullName,
            //	ParamsClass = theParams.GetType().FullName,
            //};

            var sh = new ServiceHost()
            {
                Machine = Environment.MachineName,
            };
            sh.Components.AddRange(new ServiceComponent[] { sc1, /*sc2*/ });

            var shp = new ServiceHostProvider(mongoEnv);
            shp.Insert(sh);
        }
 public void Update(IEventProducer eventProducer, ServiceComponent serviceComponent)
 {
     this.Stop(eventProducer);
     this.ServiceComponentData = serviceComponent;
     this.Start(eventProducer);
 }