예제 #1
0
 static void Main(string[] args)
 {
     try
     {
         ChaosRename chaosRename = new ChaosRename();
         //In Minutes
         double renameConfigurationTime = 1;
         //<summary>
         //Checks whether there are any files which are renamed.
         //If so, then check whether the file rename configuration time has expired.
         //If so, rollback to the original name.
         //</summary>
         if (RestoreOperationFieldsList.Count() > 0)
         {
             foreach (var blobdata in RestoreOperationFieldsList.RestoreOperationFields)
             {
                 chaosRename.RestoreAsync(blobdata, renameConfigurationTime);
             }
         }
         //<summary>
         //Select a random file and do renaming operation.
         //</summary>
         chaosRename.RandomRenamingAsync();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.Source);
         Console.WriteLine(ex.StackTrace);
     }
 }
예제 #2
0
        //<summary>
        //Does the task of randomly selecting a table record and generates the 'rename' chaos in an asynchronous way.
        //</summary>
        public async void RandomRenamingAsync()
        {
            try
            {
                var result = GetRandomTableResult();
                if (result != null)
                {
                    bool renameOperation = await RenameAsync(result);

                    if (renameOperation)
                    {
                        string scrapeName  = ((TableRecord)result.Result).ScrapeName;
                        string newFileName = "renamed" + scrapeName;
                        RestoreOperationFields restoreOperationField = new RestoreOperationFields
                        {
                            ScrapeName      = scrapeName,
                            RetreiveResult  = result,
                            RenameOperation = renameOperation,
                            NewFileName     = newFileName
                        };
                        RestoreOperationFieldsList.Add(restoreOperationField);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.Source);
                Console.WriteLine(ex.StackTrace);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            ChaosRename chaosRename = new ChaosRename();

            //1
            if (RestoreOperationFieldsList.Count() > 0)
            {
                foreach (var blobdata in RestoreOperationFieldsList.restoreOperationFields)
                {
                    chaosRename.RestoreAsync(blobdata);
                }
            }
            //2
            //create a  list of new class
            chaosRename.RandomRenamingAsync();
        }
예제 #4
0
        public async void RandomRenamingAsync()
        {
            var result = GetRandomTableResult();

            if (result != null)
            {
                bool renameOperation = await RenameAsync(result);

                if (renameOperation)
                {
                    string scrapeName  = ((Json_File)result.Result).ScrapeName;
                    string newFileName = "renamed" + scrapeName;
                    RestoreOperationFields restoreOperationField = new RestoreOperationFields();
                    restoreOperationField.ScrapeName      = scrapeName;
                    restoreOperationField.RetreiveResult  = result;
                    restoreOperationField.RenameOperation = renameOperation;
                    restoreOperationField.NewFileName     = newFileName;
                    RestoreOperationFieldsList.Add(restoreOperationField);
                    //add the fields renameOperation,retreive result,newFileName,scrapeName to the list of new class
                }
            }
        }