CreateWB2File() public method

public CreateWB2File ( ) : string
return string
Esempio n. 1
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.");
            }
        }