Esempio n. 1
0
        public int GetEventIndex(WorkbenchFile wb2)
        {
            int eventIdx = 0;

            if (ZoneID < 3071)
            {
                FEMA fema = (FEMA)(wb2.Files[CompanionFileType.FEMA][ZoneID]);
                FGRP fgrp = (FGRP)(wb2.Files[CompanionFileType.FGRP][fema.FeatureGroupID]);
                eventIdx = fgrp.Levels[EventLevel].EventIndex;
            }

            return eventIdx;
        }
Esempio n. 2
0
        private static void BackupFiles()
        {
            // Use "localhost" when debugging.
            //const string redisUri = "localhost";

            const string redisUri = "cache.silversphere.com";

            var clientManager = new PooledRedisClientManager(1000, 3, redisUri)
            {
                ConnectTimeout = 300,
                IdleTimeOutSecs = 30,
                PoolTimeout = 500
            };

            try
            {
                using (IRedisClient redis = clientManager.GetClient())
                {
                    List<string> data = redis.SearchKeys("Configuration:Workbench:Master:*");

                    if (data.Any())
                    {
                        foreach (string file in data)
                        {
                            // split the string to get the correct property id.
                            char[] delimiter = {':'};
                            string[] elements = file.Split(delimiter);
                            string propertyID = elements[3];

                            try
                            {
                                Console.WriteLine("Getting: " + propertyID);
                                var wbKey = String.Format("Configuration:Workbench:Master:{0}",propertyID);
                                var wbRaw = redis.Get<String>(wbKey);
                                var workbench = new WorkbenchFile(wbRaw);
                                SendOneToS3(elements[3], workbench.CreateWB2File());

                            }
                            catch (Exception e)
                            {
                                MissedProperties.Add(propertyID);
                                LogWriter.LogWrite(" Could not find workbench file for property: " + propertyID);
                            }
                        }
                    }
                }

                try
                {
                    Classes.SiteMailer.BackupError(MissedProperties);

                }
                catch(Exception e)
                {
                    LogWriter.LogWrite(" Could not mail missed properties.");
                }
            }
            catch (Exception e)
            {
                try
                {
                    Classes.SiteMailer.GeneralError(
                        "Could not get configuration!" +
                        Environment.NewLine +
                        "Exception: " +
                        e.ToString() +
                        Environment.NewLine +
                        "Inner Exception:" +
                        e.InnerException.ToString()
                        );
                }
                catch (Exception exc)
                {
                    LogWriter.LogWrite(" Could not mail invalid configuration.");
                }

                string now = DateTime.Now.ToString(CultureInfo.InvariantCulture);
                LogWriter.LogWrite(" Could not get configuration.");
            }
        }
        public static string SerializeToJson(WorkbenchFile file)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.Converters.Add(new WorkbenchFileConverter());
            settings.Converters.Add(new JOBXConverter());

            settings.Formatting = Formatting.Indented;

            return JsonConvert.SerializeObject(file, settings);
        }