Esempio n. 1
0
 public void Del()
 {
     DateTime dateTime = new DateTime(DateTime.UtcNow.Ticks);
     const string name = "Some.Stupid.Request With Spaces";
     ConsoleAppTasks task = new ConsoleAppTasks(new[] {"delrequest", name})
                            {
                                TaskConfiguration = new TaskConfiguration
                                                    {
                                                        RequestTasks = new[]
                                                                       {
                                                                           new RequestTask
                                                                           {
                                                                               Username = "******",
                                                                               DateAdded = dateTime,
                                                                               Name = name,
                                                                           },
                                                                           new RequestTask
                                                                           {
                                                                               Username = "******",
                                                                               DateAdded = dateTime,
                                                                               Name = "Some.Stupid.Request 2",
                                                                           },
                                                                       },
                                                    }
                            };
     TaskConfiguration taskConfiguration = task.TaskConfiguration;
     Assert.AreEqual(2, taskConfiguration.RequestTasks.Length);
     task.Execute(TaskType.Request);
     Assert.AreEqual(1, taskConfiguration.RequestTasks.Length);
 }
Esempio n. 2
0
 public void Add()
 {
     const string requestName = "some stupid request";
     string request = Misc.PathCombine(Config.RequestFolder, Config.RequestPrefix + requestName);
     request.RemoveFolder();
     DateTime dateTime = new DateTime(DateTime.UtcNow.Ticks);
     ConsoleAppTasks task = new ConsoleAppTasks(new[] {"request", requestName})
                            {
                                TaskConfiguration = new TaskConfiguration
                                                    {
                                                        RequestTasks = new[]
                                                                       {
                                                                           new RequestTask
                                                                           {
                                                                               Username = "******",
                                                                               DateAdded = dateTime,
                                                                               Name = "Some.Stupid.Request With Spaces",
                                                                           },
                                                                           new RequestTask
                                                                           {
                                                                               Username = "******",
                                                                               DateAdded = dateTime,
                                                                               Name = "Some.Stupid.Request 2",
                                                                           },
                                                                       },
                                                    }
                            };
     TaskConfiguration taskConfiguration = task.TaskConfiguration;
     Assert.AreEqual(2, taskConfiguration.RequestTasks.Length);
     task.Execute(TaskType.Request);
     Assert.AreEqual(3, taskConfiguration.RequestTasks.Length);
 }
Esempio n. 3
0
 public void AddNewDupe()
 {
     const string releasename = "TestFiles";
     string commandText = String.Format(@"INSERT INTO Folders (UserName, GroupName, ReleaseName, PathReal, PathVirtual) VALUES('jeza', 'group', '{0}', 'c:\temp\{0}', '/temp/{0}')", releasename);
     int numberOfRows = DataBase.Insert(commandText);
     Assert.AreEqual(1, numberOfRows);
     ConsoleAppTasks task = new ConsoleAppTasks(new[] { "newdir", @"..\..\" + releasename, "/test/" + releasename });
     Assert.AreEqual(Constants.CodeFail, task.Execute(TaskType.DupeNewDir));
 }
Esempio n. 4
0
 private static void Main()
 {
     Log.Debug("--------------------------------------------------------------");
     Log.Debug("Archive...");
     try
     {
         ConsoleAppTasks consoleAppTasks = new ConsoleAppTasks();
         consoleAppTasks.ParseConfig();
         consoleAppTasks.Execute(TaskType.Archive);
     }
     catch (Exception exception)
     {
         Log.Debug(exception.ToString());
     }
 }
Esempio n. 5
0
 public void AddNew()
 {
     DateTime dateTime = new DateTime(DateTime.UtcNow.Ticks);
     ConsoleAppTasks task = new ConsoleAppTasks(new[] {"weekly", "add", "newuser", "1024000000"})
                            {
                                TaskConfiguration = new TaskConfiguration
                                                    {
                                                        WeeklyTasks = new[]
                                                                      {
                                                                          new WeeklyTask
                                                                          {
                                                                              WeeklyTaskStatus = WeeklyTaskStatus.Enabled,
                                                                              Uid = 1,
                                                                              Username = "******",
                                                                              Creator = "test",
                                                                              Credits = 1024,
                                                                              Notes = "Just for fun!",
                                                                              DateTimeStart = dateTime,
                                                                              DateTimeStop = dateTime.AddYears(1),
                                                                          },
                                                                          new WeeklyTask
                                                                          {
                                                                              WeeklyTaskStatus = WeeklyTaskStatus.Enabled,
                                                                              Username = "******",
                                                                              Uid = 2,
                                                                              Creator = "test 2",
                                                                              Credits = 1024 * 1024 * 1024,
                                                                              Notes = "Just for fun 2 !",
                                                                              DateTimeStart = dateTime,
                                                                              DateTimeStop = dateTime.AddYears(1),
                                                                          },
                                                                      },
                                                    }
                            };
     TaskConfiguration taskConfiguration = task.TaskConfiguration;
     Assert.AreEqual(2, taskConfiguration.WeeklyTasks.Length);
     task.Execute(TaskType.Weekly);
     Assert.AreEqual(3, taskConfiguration.WeeklyTasks.Length);
 }
Esempio n. 6
0
 public void AddNew()
 {
     ConsoleAppTasks task = new ConsoleAppTasks(new[] {"newdir", @"..\..\TestFiles", "/test/TestFiles"});
     task.Execute(TaskType.DupeNewDir);
 }
Esempio n. 7
0
 public void ListEmpty()
 {
     //DateTime dateTime = new DateTime(DateTime.UtcNow.Ticks);
     ConsoleAppTasks task = new ConsoleAppTasks(new[] {"listrequest"})
                            {
                                TaskConfiguration = new TaskConfiguration {WeeklyTasks = new WeeklyTask[] {}},
                            };
     TaskConfiguration taskConfiguration = task.TaskConfiguration;
     Assert.IsNull(taskConfiguration.RequestTasks);
     task.Execute(TaskType.Request);
     Assert.IsNull(taskConfiguration.RequestTasks);
 }
Esempio n. 8
0
        public static int Main(string[] args)
        {
            Log.Debug("--------------------------------------------------------------");
            Log.Debug("Manager...");
            Log.Debug("args: '{0}'", Misc.ArgsToString(args));
            int codeReturn = Constants.CodeOk;
            try
            {
                int numberOfArguments = args.Length;
                if (numberOfArguments > 0)
                {
                    ConsoleAppTasks consoleAppTasks = new ConsoleAppTasks(args);
                    consoleAppTasks.ParseConfig();

                    string firstArgument = args[0].ToLowerInvariant();
                    //args: 'args[0]='schedulerNewDay' '
                    if (firstArgument.EndsWith("newday"))
                    {
                        consoleAppTasks.Execute(TaskType.NewDay);
                    }
                    //args: 'args[0]='schedulerWeekly' '
                    if (firstArgument.EndsWith("weekly"))
                    {
                        consoleAppTasks.Execute(TaskType.Weekly);
                    }
                    //args: 'args[0]='listRequest' '
                    if (firstArgument.EndsWith("request"))
                    {
                        consoleAppTasks.Execute(TaskType.Request);
                    }
                    //args: 'args[0]='newdir', args[1]='D:\temp\testasd', args[2]='/temp/testasd''
                    if (firstArgument.Equals("newdir"))
                    {
                        codeReturn = consoleAppTasks.Execute(TaskType.DupeNewDir);
                    }
                    //args: 'args[0]='deldir', args[1]='D:\temp\testasd', args[2]='/temp/testasd''
                    if (firstArgument.Equals("deldir"))
                    {
                        codeReturn = consoleAppTasks.Execute(TaskType.DupeDelDir);
                    }
                    //args: 'args[0]='dupelist', args[1]='testasd''
                    if (firstArgument.Equals("dupelist"))
                    {
                        if (args.Length == 2)
                        {
                            consoleAppTasks.Execute(TaskType.DupeList);
                        }
                    }
                    //args: 'args[0]='duperemove', args[1]='testasd''
                    if (firstArgument.Equals("duperemove"))
                    {
                        if (args.Length == 2)
                        {
                            consoleAppTasks.Execute(TaskType.DupeRemove);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Log.Debug(exception.ToString());
                codeReturn = Constants.CodeFail;
            }
            return codeReturn;
        }