Exemplo n.º 1
0
        /// <summary>
        ///     Set the ItemID
        /// </summary>
        private void cmSetItemID_Click(object sender, EventArgs e)
        {
            Pandora.SendToUO(string.Format("Set ItemID {0}", SelectedItem.ItemID), true);

            Pandora.Prop.DisplayedProp  = "ItemID";
            Pandora.Prop.DisplayedValue = SelectedItem.ItemID.ToString();
        }
        public void Initialize(HttpConfiguration configuration, Pandora pandora)
        {
            var container = new Container();
            container.RegisterSingleton<Pandora>(() => pandora);
            Func<IPipelineTransport> transport = () => container.Resolve<IPipelineTransport>();
            Func<ISerializer> serializer = () => container.Resolve<ISerializer>();
            container.RegisterSingleton<IPublisher<ICommand>>(() => new PipelinePublisher<ICommand>(transport(), serializer()));

            var serviceLocator = new ServiceLocator(container);
            ControllerFactory = new ServiceLocatorFactory(serviceLocator);

            var cfg = new CronusSettings(container)
                  .UseCluster(cluster =>
                       cluster.UseAggregateRootAtomicAction(atomic =>
                       {
                           if (pandora.Get<bool>("enable_redis_atomic_action"))
                               atomic.UseRedis(redis => redis.SetLockEndPoints(pandora.Get("redis_endpoints").ParseIPEndPoints(";")));
                           else
                               atomic.WithInMemory();
                       }))
                  .UseContractsFromAssemblies(new[] { Assembly.GetAssembly(typeof(PushNotificationWasSent)) })
                  .UseRabbitMqTransport(x =>
                  {
                      x.Server = pandora.Get("rabbitmq_server");
                      x.Username = pandora.Get("rabbitmq_username");
                      x.Password = pandora.Get("rabbitmq_password");
                      x.VirtualHost = pandora.Get("rabbitmq_virtualhost");
                  });

            (cfg as ICronusSettings).Build();
        }
Exemplo n.º 3
0
        private List <MachineDTO> GetAllMachines(string clusterName)
        {
            var cluster = SecurityAccess.Projects
                          .SingleOrDefault(x => x.Name == ProjectName).Applications
                          .SingleOrDefault(x => x.Name == ApplicationName).Clusters
                          .SingleOrDefault(x => x.Name == clusterName);

            if (clusterName == null)
            {
                return(new List <MachineDTO>());
            }

            if (!this.HasAccess(clusterName))
            {
                return(new List <MachineDTO>());
            }

            var pandora = new Pandora(box);

            var machines = new List <MachineDTO>();

            foreach (var machine in box.Machines)
            {
                machines.Add(new MachineDTO(machine.Name, cluster, pandora.Open(new PandoraOptions(clusterName, machine.Name, true)).AsDictionary()));
            }

            return(machines);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Sends the PrivSound command
        /// </summary>
        /// <param name="sound">The sound index to play</param>
        /// <param name="modifier">The command modifier</param>
        public void DoPrivSound(int sound, string modifier)
        {
            var cmd = m_PrivSound.Replace("{sound}", sound.ToString());

            cmd = ApplyModifier(cmd, modifier);
            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Performs the open browser command
        /// </summary>
        /// <param name="url">The url to open</param>
        /// <param name="modifier">The command modifier</param>
        public void DoOpenBrowser(string url, string modifier)
        {
            var cmd = m_OpenBrowser.Replace("{url}", url);

            cmd = ApplyModifier(cmd, modifier);
            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Performs the Tell command
        /// </summary>
        /// <param name="text">The message to send</param>
        /// <param name="modifier">The modifier for the command</param>
        public void DoTell(string text, string modifier)
        {
            var cmd = m_Tell.Replace("{text}", text);

            cmd = ApplyModifier(cmd, modifier);
            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Tiles a scripted item
        /// </summary>
        /// <param name="z">The tiling height</param>
        /// <param name="item">The item constructor</param>
        public void DoTileItem(int z, string item)
        {
            var cmd = m_Tile.Replace("{z}", z.ToString());

            cmd = cmd.Replace("{item}", item);

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Sets a single skill on a targeted mobile
        /// </summary>
        /// <param name="skill">The name of the skill</param>
        /// <param name="value">The value of the skill</param>
        public void DoSetSkill(string skill, decimal value)
        {
            var cmd = m_SetSkill.Replace("{skill}", skill);

            cmd = cmd.Replace("{value}", value.ToString());

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Performs the dupe in bag command
        /// </summary>
        /// <param name="useamount">States wheter an amount should be specified</param>
        /// <param name="amount">The amount of items to be duped</param>
        public void DoDupeInBag(bool useamount, int amount)
        {
            string cmd = useamount ?
                         m_AmountDupeInBag.Replace("{amount}", amount.ToString()) :
                         m_DupeInBag;

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 10
0
 public void ShowPopNews()
 {
     if (this.m_bInit && !this.m_bShowPopNew)
     {
         this.m_bShowPopNew = true;
         string strJson = "{\"type\":\"open\",\"content\":\"LuckyPop\"}";
         Pandora.Do(strJson);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        ///     Send command
        /// </summary>
        private void m_Def_SendCommand(object sender, SendCommandEventArgs e)
        {
            OnSendCommand(e);

            if (m_IsActive && !e.Sent)
            {
                Pandora.SendToUO(e.Command, e.UsePrefix);
            }
        }
Exemplo n.º 12
0
        public void UninitSys()
        {
            this.m_bInit         = false;
            this.m_bShowPopNew   = false;
            this.m_bShowBoxBtn   = false;
            this.m_bShowRedPoint = false;
            Singleton <CUIEventManager> .GetInstance().RemoveUIEventListener(enUIEventID.Pandroa_ShowActBox, new CUIEventManager.OnUIEventHandler(this.OnShowActBox));

            Pandora.LogOutAccount();
        }
Exemplo n.º 13
0
        public void DoSet(string prop, string value, string modifier)
        {
            var cmd = m_Set.Replace("{prop}", prop);

            cmd = cmd.Replace("{value}", value);

            cmd = ApplyModifier(cmd, modifier);

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 14
0
 public void ShowActBox()
 {
     Debug.Log("Pandora ShowActBox1");
     if (this.m_bInit)
     {
         Debug.Log("Pandora ShowActBox2");
         string strJson = "{\"type\":\"open\",\"content\":\"Lucky\"}";
         Pandora.Do(strJson);
     }
 }
Exemplo n.º 15
0
        public void Configuration(IAppBuilder app)
        {
            log4net.Config.XmlConfigurator.Configure();

            var appContext = new ApplicationContext("PushNotifications");
            var cfgRepo = new ConsulForPandora(new Uri("http://consul.local.com:8500"));
            var pandora = new Pandora(appContext, cfgRepo);

            app.UseHttpWebApi(pandora);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Sends the Send command to UO
        /// </summary>
        /// <param name="x">The target X coordinate</param>
        /// <param name="y">The target Y coordinate</param>
        /// <param name="z">The target Z coordinate</param>
        /// <param name="map">The target map</param>
        public void DoSend(int x, int y, int z, int map)
        {
            var cmd = m_SendFormat;

            cmd = cmd.Replace("{x}", x.ToString());
            cmd = cmd.Replace("{y}", y.ToString());
            cmd = cmd.Replace("{z}", z.ToString());
            cmd = cmd.Replace("{map}", map.ToString());

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Performs the nudge down command
        /// </summary>
        /// <param name="z">The amount to nudge</param>
        /// <param name="modifier">The command modifier</param>
        public void DoNudgeDown(int z, string modifier)
        {
            var nudge = m_NudgeDown.Replace("{z}", z.ToString());

            if (modifier != null)
            {
                nudge = string.Format("{0} {1}", modifier, nudge);
            }

            Pandora.SendToUO(nudge, true);
        }
Exemplo n.º 18
0
        public void DoAddMobile(string mobile, params string[] additional)
        {
            var cmd = string.Format("{0} {1}", m_AddMobile, mobile);

            foreach (var s in additional)
            {
                cmd += " " + s;
            }

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 19
0
 public void InitSys()
 {
     this.InitEvent();
     Debug.Log("Pandora InitSys");
     this.m_bInit         = true;
     this.m_bShowPopNew   = false;
     this.m_bShowBoxBtn   = false;
     this.m_bShowRedPoint = false;
     this.InitPara();
     Pandora.Init();
 }
Exemplo n.º 20
0
        /// <summary>
        /// Gets the language corresponding to the currently selected language
        /// </summary>
        /// <returns></returns>
        public TextProvider GetLanguage(string language)
        {
            string file     = Path.Combine(Pandora.Folder, "Lang");
            string resource = null;

            file = Path.Combine(file, string.Format("{0}.dll", language));

            if (!File.Exists(file))
            {
                // Selected language doesn't exist. Revert to English
                System.Windows.Forms.MessageBox.Show(String.Format("The langague selected for the current profile could not be located. {0} will be used instead.\n\nMissing language: {0}.", Pandora.Profile.Language, DEFAULT_LANGUAGE));

                Pandora.Profile.Language = DEFAULT_LANGUAGE;

                file = Path.Combine(Pandora.Folder, "Lang");
                file = Path.Combine(file, string.Format(DEFAULT_LANGUAGE + ".dll"));

                if (!File.Exists(file))
                {
                    // English doesn't exist either. This is wrong.
                    System.Windows.Forms.MessageBox.Show(String.Format("Pandora's Box couldn't locate a required component ({0}.dll). Please reinstall the program to address this issue.", DEFAULT_LANGUAGE));
                    Pandora.Log.WriteError(null, DEFAULT_LANGUAGE + ".dll not found. Closing.");
                    Pandora.ClosePandora();
                    // Is this executed?
                    throw new Exception("Default language file not found");
                }
            }


            try
            {
                // Read the TextProvider object
                resource = string.Format("{0}.language.xml", language);

                // Load the assembly
                Assembly asm    = Assembly.LoadFile(file);
                Stream   stream = asm.GetManifestResourceStream(resource);

                XmlDocument dom = new XmlDocument();
                dom.Load(stream);

                stream.Close();

                TextProvider tp = TextProvider.Deserialize(dom);

                return(tp);
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("An unexpected error occurred when loading language files. Details about the error have been recorded in the log file. Pandora's Box will now close.");
                Pandora.Log.WriteError(err, "Loading resource {0} from assembly in file {1}", resource, file);
                throw new Exception("Language file corrupted");
            }
        }
Exemplo n.º 21
0
 public ThrotleSettings(Pandora pandora)
 {
     Server = pandora.Get("pushnot_rabbitmq_server");
     Port = pandora.Get<int>("pushnot_rabbitmq_port");
     Username = pandora.Get("pushnot_rabbitmq_username");
     Password = pandora.Get("pushnot_rabbitmq_password");
     VirtualHost = pandora.Get("pushnot_rabbitmq_virtual_host");
     PushNotificationsBatchSize = pandora.Get<int>("pushnot_batch_size");
     PushNotificationsSendoutDelay = pandora.Get<int>("pushnot_sendout_delay");
     PushNotificationsMaxCPUUtilization = pandora.Get<int>("pushnot_max_cpu_utilization");
     EndpointNameConvention = new ThrottledBrokerEndpointNameConvention(typeof(APNSNotificationMessage), typeof(GCMNotificationMessage));
     PipelineNameConvention = new ThrottledBrokerPipelineNameConvention();
 }
Exemplo n.º 22
0
 public void PausePandoraSys(bool bPause)
 {
     if (bPause)
     {
         string strJson = "{\"type\":\"inMainSence\",\"content\":\"0\"}";
         Pandora.Do(strJson);
     }
     else
     {
         string str2 = "{\"type\":\"inMainSence\",\"content\":\"1\"}";
         Pandora.Do(str2);
     }
 }
Exemplo n.º 23
0
        /// <summary>
        ///     Spawns an item
        /// </summary>
        /// <param name="item">The item name</param>
        public void DoSpawnItem(string item)
        {
            var cmd = m_SpawnFormat;

            cmd = cmd.Replace("{creature}", item);
            cmd = cmd.Replace("{amount}", Pandora.Profile.Items.Amount.ToString());
            cmd = cmd.Replace("{min}", Pandora.Profile.Items.MinDelay.ToString());
            cmd = cmd.Replace("{max}", Pandora.Profile.Items.MaxDelay.ToString());
            cmd = cmd.Replace("{team}", Pandora.Profile.Items.Team.ToString());
            cmd = cmd.Replace("{range}", Pandora.Profile.Items.Range.ToString());
            cmd = cmd.Replace("{extra}", Pandora.Profile.Items.Extra.ToString());

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 24
0
        public void Pandora()
        {
            customUrl           = "https://pandora.com.tr/kitap/shuri-the-search-for-black-panther/692816";
            customExpectedName  = "Shuri: The Search for Black Panther";
            customExpectedPrice = 109.77; //normal price

            var pandora = new Pandora();

            pandora = pandora.Product(customUrl);

            Assert.Equal(customExpectedName, pandora.Name);
            Assert.Equal(customExpectedPrice, pandora.Price);
            Assert.Null(pandora.Error);
        }
Exemplo n.º 25
0
        public void DoSet(string prop, string value, string filter, string modifier)
        {
            var cmd = m_Set.Replace("{prop}", prop);

            cmd = cmd.Replace("{value}", value);

            if (filter != null && filter.Length > 0)
            {
                cmd += " " + filter;
            }

            cmd = ApplyModifier(cmd, modifier);

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 26
0
        private static void Main(string[] args)
        {
            var p = new Pandora();

            try
            {
                //p.Sync();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }


            Console.WriteLine("testing");
        }
Exemplo n.º 27
0
        public void DoAddToPack(string item, string modifier, params string[] additional)
        {
            var cmd = string.Format("{0} {1}", m_AddToPack, item);

            if (modifier != null)
            {
                cmd = string.Format("{0} {1}", modifier, cmd);
            }

            foreach (var s in additional)
            {
                cmd += " " + s;
            }

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 28
0
        /// <summary>
        ///     Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);

            if (Pandora.Profile == null)
            {
                Pandora.ClosePandora();
            }
        }
Exemplo n.º 29
0
        /// <summary>
        ///     Sends the Go command to UO
        /// </summary>
        /// <param name="x">The target X coordinate</param>
        /// <param name="y">The target Y coordinate</param>
        /// <param name="z">The target Z coordinate</param>
        /// <param name="map">The target map</param>
        public void DoGo(int x, int y, int z, int map)
        {
            var cmd = m_GoFormat;

            cmd = cmd.Replace("{x}", x.ToString());
            cmd = cmd.Replace("{y}", y.ToString());
            cmd = cmd.Replace("{z}", z.ToString());
            cmd = cmd.Replace("{map}", map.ToString());

            if (m_SetMapOnGo)
            {
                DoSet("map", map.ToString(), "Self");
            }

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 30
0
        public ConfigurationDTO(ClaimsPrincipal user, Jar jar, string projectName)
        {
            this.user       = user;
            box             = Box.Box.Mistranslate(jar);
            pandora         = new Pandora(box);
            SecurityAccess  = GetSecurityAccess();
            ApplicationName = jar.Name;
            ProjectName     = projectName;
            Defaults        = GetDefaults();
            Clusters        = GetAllClusters();

            Machines = new List <MachineDTO>();
            foreach (var cluster in Clusters)
            {
                var machines = GetAllMachines(cluster.Cluster.Name);

                Machines.AddRange(machines);
            }
        }
Exemplo n.º 31
0
        public ConfigurationDTO(ClaimsPrincipal user, Jar jar, string projectName)
        {
            this.user = user;
            box = Box.Box.Mistranslate(jar);
            pandora = new Pandora(box);
            SecurityAccess = GetSecurityAccess();
            ApplicationName = jar.Name;
            ProjectName = projectName;
            Defaults = GetDefaults();
            Clusters = GetAllClusters();

            Machines = new List<MachineDTO>();
            foreach (var cluster in Clusters)
            {
                var machines = GetAllMachines(cluster.Cluster.Name);

                Machines.AddRange(machines);
            }
        }
Exemplo n.º 32
0
        /// <summary>
        ///     Sends the tile command
        /// </summary>
        /// <param name="z">Height at which tiling occurs</param>
        /// <param name="id">ID of the item being added</param>
        /// <param name="movable">States whether the item can be moved or not</param>
        /// <param name="hue">The hue value</param>
        /// <param name="rnd">The randomization amount. Use 0 to disable</param>
        public void DoTile(int z, int id, bool movable, int hue, int rnd)
        {
            var    item = m_Deco;
            string tile = null;

            if (rnd == 0)
            {
                item = item.Replace("{id}", id.ToString());
            }
            else
            {
                item = item.Replace("{id}", string.Format("{0} {1}", id, rnd));
            }
            item = item.Replace("{movable}", movable.ToString());
            item = item.Replace("{hue}", hue.ToString());

            tile = m_Tile.Replace("{item}", item);
            tile = tile.Replace("{z}", z.ToString());

            Pandora.SendToUO(tile, true);
        }
Exemplo n.º 33
0
        /// <summary>
        ///     Sends the IncXYZ command to UO
        /// </summary>
        /// <param name="modifier">The modifier for the command</param>
        /// <param name="x">The X Offset</param>
        /// <param name="y">The Y Offset</param>
        public void DoMove(string modifier, int x, int y)
        {
            var cmd = "Inc";

            if (modifier != null)
            {
                cmd = modifier + " " + cmd;
            }

            if (x != 0)
            {
                cmd += string.Format(" X {0}", x);
            }

            if (y != 0)
            {
                cmd += string.Format(" Y {0}", y);
            }

            Pandora.SendToUO(cmd, true);
        }
Exemplo n.º 34
0
        public bool Initialize(string bassRegEmail = "", string bassRegKey = "")
        {
            _cqman                     = new ControlQueryManager();
            _cqman.NextRequest        += _cqman_NextRequest;
            _cqman.PauseRequest       += _cqman_PauseRequest;
            _cqman.PlayRequest        += _cqman_PlayRequest;
            _cqman.StopRequest        += _cqman_StopRequest;
            _cqman.PlayStateRequest   += _cqman_PlayStateRequest;
            _cqman.SetSongMetaRequest += _cqman_SetSongMetaRequest;

            _sessionWatcher = new SessionWatcher();
            RegisterPlayerControlQuery(_sessionWatcher);

            _pandora = new Pandora();
            _pandora.ConnectionEvent       += _pandora_ConnectionEvent;
            _pandora.StationUpdateEvent    += _pandora_StationUpdateEvent;
            _pandora.FeedbackUpdateEvent   += _pandora_FeedbackUpdateEvent;
            _pandora.LoginStatusEvent      += _pandora_LoginStatusEvent;
            _pandora.StationsUpdatingEvent += _pandora_StationsUpdatingEvent;
            _pandora.QuickMixSavedEvent    += _pandora_QuickMixSavedEvent;

            _bass = new BassAudioEngine(bassRegEmail, bassRegKey);
            _bass.PlaybackProgress     += bass_PlaybackProgress;
            _bass.PlaybackStateChanged += bass_PlaybackStateChanged;
            _bass.PlaybackStart        += bass_PlaybackStart;
            _bass.PlaybackStop         += bass_PlaybackStop;
            _bass.InitBass();

            _playlist                     = new Playlist();
            _playlist.MaxPlayed           = 8;
            _playlist.PlaylistLow        += _playlist_PlaylistLow;
            _playlist.PlayedSongQueued   += _playlist_PlayedSongQueued;
            _playlist.PlayedSongDequeued += _playlist_PlayedSongDequeued;

            DailySkipLimitReached = false;
            DailySkipLimitTime    = DateTime.MinValue;

            LoggedIn = false;
            return(true);
        }
Exemplo n.º 35
0
        private List<MachineDTO> GetAllMachines(string clusterName)
        {
            var cluster = SecurityAccess.Projects
                .SingleOrDefault(x => x.Name == ProjectName).Applications
                .SingleOrDefault(x => x.Name == ApplicationName).Clusters
                .SingleOrDefault(x => x.Name == clusterName);

            if (clusterName == null)
                return new List<MachineDTO>();

            if (!this.HasAccess(clusterName))
                return new List<MachineDTO>();

            var pandora = new Pandora(box);

            var machines = new List<MachineDTO>();

            foreach (var machine in box.Machines)
            {
                machines.Add(new MachineDTO(machine.Name, cluster, pandora.Open(new PandoraOptions(clusterName, machine.Name, true)).AsDictionary()));
            }

            return machines;
        }
Exemplo n.º 36
0
        public static void Start()
        {
            try
            {
                log.Info("Starting Cronus Push Notifications");

                var appContext = new ApplicationContext("PushNotifications");
                var cfgRepo = new ConsulForPandora(new Uri("http://consul.local.com:8500"));
                var pandora = new Pandora(appContext, cfgRepo);

                container = new Container();

                new CronusSettings(container)
                     .UseCluster(cluster =>
                        cluster.UseAggregateRootAtomicAction(atomic =>
                        {
                            if (pandora.Get<bool>("enable_redis_atomic_action"))
                                atomic.UseRedis(redis => redis.SetLockEndPoints(pandora.Get("redis_endpoints").ParseIPEndPoints(";")));
                            else
                                atomic.WithInMemory();
                        }))
                     .UseAppServices(pandora)
                     .UseProjections(pandora)
                     .UsePorts(pandora)
                     .Build();

                host = container.Resolve<CronusHost>();
                host.Start();
                log.Info("STARTED Cronus Push Notifications");
            }
            catch (Exception ex)
            {
                log.ErrorException("Unable to boot PushNotifications.WS", ex);
                throw;
            }
        }
Exemplo n.º 37
0
        public static int Main(string[] args)
        {
            string invokedVerb = string.Empty;
            object invokedVerbInstance = null;

            var options = new Options();

            if (args == null || args.Length == 0)
            {
                Console.WriteLine(options.GetUsage());
                return 0;
            }

            if (!CommandLine.Parser.Default.ParseArguments(
                args,
                options,
                (verb, subOptions) => { invokedVerb = verb; invokedVerbInstance = subOptions; }))
            {
                Console.WriteLine(options.GetUsage());
                return 0;
            }

            if (invokedVerb == "open")
            {
                var openOptions = (OpenOptions)invokedVerbInstance;

                string applicationName = openOptions.Application;
                string cluster = openOptions.Cluster;
                string machine = openOptions.Machine;
                string jarFile = openOptions.Jar ?? openOptions.Application + ".json";
                if (!File.Exists(jarFile)) throw new FileNotFoundException("Jar file is required.", jarFile);

                var jar = JsonConvert.DeserializeObject<Jar>(File.ReadAllText(jarFile));
                var box = Box.Box.Mistranslate(jar);
                if (box.Name != applicationName) throw new InvalidProgramException("Invalid grant");

                var cfg = box.Open(new PandoraOptions(cluster, machine));

                if (openOptions.Output == OpenOptions.EnvVarOutput)
                {
                    foreach (var setting in cfg.AsDictionary())
                    {
                        Environment.SetEnvironmentVariable(setting.Key, setting.Value, EnvironmentVariableTarget.Machine);
                    }
                }
                else if (openOptions.Output == OpenOptions.ConsulOutput)
                {
                    Uri consulAddress = null;
                    if (string.IsNullOrEmpty(openOptions.ConsulHost) == false)
                        consulAddress = new Uri(openOptions.ConsulHost);
                    var consul = new ConsulForPandora(consulAddress);
                    var currentContext = ApplicationConfiguration.CreateContext(applicationName,cluster,machine);

                    var pandora = new Pandora(currentContext, consul);

                    foreach (var setting in pandora.GetAll(currentContext))
                    {
                        consul.Delete(setting.Raw);
                    }

                    foreach (var setting in cfg.AsDictionary())
                    {
                        consul.Set(setting.Key, setting.Value);
                    }
                }
                else
                {
                    var computedCfg = JsonConvert.SerializeObject(cfg.AsDictionary());
                    File.WriteAllText(openOptions.Output, computedCfg);
                }
            }

            return 0;
        }
Exemplo n.º 38
0
        private static PushBroker ConfigurePushBroker(Pandora pandora)
        {
            var broker = new PushBroker();
            broker.OnNotificationSent += PushNotificationLogger.NotificationSent;
            broker.OnChannelException += PushNotificationLogger.ChannelException;
            broker.OnServiceException += PushNotificationLogger.ServiceException;
            broker.OnNotificationFailed += PushNotificationLogger.NotificationFailed;
            broker.OnDeviceSubscriptionExpired += PushNotificationLogger.DeviceSubscriptionExpired;
            broker.OnDeviceSubscriptionChanged += PushNotificationLogger.DeviceSubscriptionChanged;
            broker.OnChannelCreated += PushNotificationLogger.ChannelCreated;
            broker.OnChannelDestroyed += PushNotificationLogger.ChannelDestroyed;

            var iosCert = pandora.Get("pushnot_ios_cert");
            var iosCertPass = pandora.Get("pushnot_ios_cert_pass");

            var androidToken = pandora.Get("pushnot_android_token");

            var parseAppId = pandora.Get("pushnot_parse_app_id");
            var parseRestApiKey = pandora.Get("pushnot_parse_rest_api_key");

            string iosCertPath = Environment.ExpandEnvironmentVariables(iosCert);

            var appleCert = File.ReadAllBytes(iosCertPath);

            bool iSprod = Boolean.Parse(pandora.Get("pushnot_ios_production"));
            broker.RegisterAppleService(new ApplePushChannelSettings(iSprod, appleCert, iosCertPass, disableCertificateCheck: true));
            broker.RegisterGcmService(new GcmPushChannelSettings(androidToken));

            return broker;
        }
Exemplo n.º 39
0
        private static ICronusSettings UseAppServices(this ICronusSettings cronusSettings, Pandora pandora)
        {
            var appServiceFactory = new ServiceLocator(cronusSettings.Container);

            cronusSettings.UseContractsFromAssemblies(new[] {
                    Assembly.GetAssembly(typeof(PushNotificationWasSent)),
                    Assembly.GetAssembly(typeof(APNSSubscriptionsProjection)),
                    Assembly.GetAssembly(typeof(APNSNotificationMessage))
                })
            .UseCommandConsumer(consumer => consumer
                .UseRabbitMqTransport(x =>
                {
                    x.Server = pandora.Get("rabbitmq_server");
                    x.Username = pandora.Get("rabbitmq_username");
                    x.Password = pandora.Get("rabbitmq_password");
                    x.VirtualHost = pandora.Get("rabbitmq_virtualhost");
                })
                .WithDefaultPublishers()
                .UseCassandraEventStore(eventStore => eventStore
                    .SetConnectionString(pandora.Get("pushnot_conn_str_es"))
                    .SetAggregateStatesAssembly(typeof(PushNotificationState))
                    .WithNewStorageIfNotExists())
                .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(PushNotificationAppService).Assembly }, appServiceFactory.Resolve)));

            return cronusSettings;
        }
Exemplo n.º 40
0
        private static ICronusSettings UsePorts(this ICronusSettings cronusSettings, Pandora pandora)
        {
            var portFactory = new ServiceLocator(cronusSettings.Container);

            var broker = ConfigurePushBroker(pandora);
            var throttleSettings = new ThrotleSettings(pandora);
            Func<ISerializer> serializer = () => container.Resolve<ISerializer>();
            var throttler = new ThrottledBrokerAdapter(new ThrottledBroker(cronusSettings.Container, broker, throttleSettings));
            container.RegisterSingleton<IPushBroker>(() => throttler);

            cronusSettings.UsePortConsumer(consumable => consumable
                .WithDefaultPublishers()
                .UseRabbitMqTransport(x =>
                {
                    x.Server = pandora.Get("rabbitmq_server");
                    x.Port = pandora.Get<int>("rabbitmq_port");
                    x.Username = pandora.Get("rabbitmq_username");
                    x.Password = pandora.Get("rabbitmq_password");
                    x.VirtualHost = pandora.Get("rabbitmq_virtualhost");
                })
                .UsePorts(handler => handler.RegisterHandlersInAssembly(new[] { Assembly.GetAssembly(typeof(APNSPort)) }, portFactory.Resolve)));

            return cronusSettings;
        }
Exemplo n.º 41
0
        public static void UseHttpWebApi(this IAppBuilder app, Pandora pandora)
        {
            try
            {
                log.Info("Starting Cronus Push Notifications Api");

                JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();

                var apiConfig = new HttpConfiguration();
                apiConfig.MapHttpAttributeRoutes();
                GlobalConfigureApi(apiConfig);

                var configurations = typeof(Cronus).Assembly.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IApiConfiguration)))
                     .Select(x => Activator.CreateInstance(x) as IApiConfiguration).ToList();
                foreach (var item in configurations)
                {
                    try
                    {
                        item.Initialize(apiConfig, pandora);
                    }
                    catch (Exception ex)
                    {
                        log.FatalException($"Failed to initialize:{item.GetType().Name}", ex);
                        throw;
                    }
                }

                apiConfig.Services.Replace(typeof(IAssembliesResolver), new ControllerAssembliesResolver(configurations.Select(x => x.Assembly).ToList()));
                apiConfig.Services.Replace(typeof(IHttpControllerActivator), new CompositeLocatorFactory(configurations.ToList()));

                app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
                {
                    Authority = pandora.Get("idsrv_authority")
                });

                app.UseWebApi(apiConfig);

                log.Info("Started Cronus Push Notifications Api");
            }
            catch (Exception ex)
            {
                log.ErrorException("Unable to boot PushNotifications.Api", ex);
                throw;
            }
        }
Exemplo n.º 42
0
            /// <summary>
            /// Provides our own implementation of the services.
            /// </summary>
            /// <param name="pandora">The IoC instance.</param>
            /// <param name="configuration">The dotless configuration.</param>
            protected override void OverrideServices(Pandora.Fluent.FluentRegistration pandora, DotlessConfiguration configuration)
            {
                base.OverrideServices(pandora, configuration);

                if (configuration.Logger == null)
                {
                    // IF no logger defined
                    // THEN we're going to use the Compiler as the logger to stream output out

                    pandora.Service<dotless.Core.Loggers.ILogger>().Instance(Compiler);
                }
            }
Exemplo n.º 43
0
        private static ICronusSettings UseProjections(this ICronusSettings cronusSettings, Pandora pandora)
        {
            var projectionFactory = new ServiceLocator(cronusSettings.Container);

            var projectionSession = SessionFactory.Create(pandora.Get("pushnot_conn_str_projections"));
            projectionSession.InitializeProjectionDatabase(Assembly.GetAssembly(typeof(APNSSubscriptionsProjection)));
            var persister = new CassandraPersister(projectionSession);
            Func<ISerializer> serializer = () => container.Resolve<ISerializer>();
            Func<Repository> repo = () => new Repository(persister, obj => serializer().SerializeToBytes(obj), data => serializer().DeserializeFromBytes(data));
            container.RegisterTransient<IProjectionRepository>(() => new CassandraProjectionRepository(new ProjectionBuilder(), repo));
            container.RegisterTransient<IRepository>(() => new Repository(
                new CassandraPersister(container.Resolve<Cassandra.ISession>()),
                container.Resolve<ISerializer>().SerializeToBytes,
                container.Resolve<ISerializer>().DeserializeFromBytes));

            cronusSettings.UseProjectionConsumer(consumable => consumable
                .WithDefaultPublishers()
                .UseRabbitMqTransport(x =>
                {
                    x.Server = pandora.Get("rabbitmq_server");
                    x.Port = pandora.Get<int>("rabbitmq_port");
                    x.Username = pandora.Get("rabbitmq_username");
                    x.Password = pandora.Get("rabbitmq_password");
                    x.VirtualHost = pandora.Get("rabbitmq_virtualhost");
                })
                .UseProjections(h => h.RegisterHandlersInAssembly(new[] { Assembly.GetAssembly(typeof(APNSSubscriptionsProjection)) }, projectionFactory.Resolve)));

            return cronusSettings;
        }