Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var jobName          = "";
            var syncJobExtension = "";
            var collection       = "";
            var create           = false;
            var delete           = false;
            var minutesInterval  = 2;

            if (args.GetLength(0) == 0)
            {
                Console.WriteLine(Resources.Usage);
                return;
            }

            foreach (var arg in args)
            {
                var nomeArgumento = arg.ToLower();

                if (nomeArgumento.Contains("="))
                {
                    nomeArgumento = nomeArgumento.Split('=')[0];
                }

                if (nomeArgumento == "-jobname")
                {
                    jobName = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-syncjobextension")
                {
                    syncJobExtension = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-collection")
                {
                    collection = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-c")
                {
                    create = true;
                }
                else if (nomeArgumento == "-d")
                {
                    delete = true;
                }
                else if (nomeArgumento == "-t")
                {
                    minutesInterval = int.Parse(arg.Split('=')[1]);
                }
                else
                {
                    Console.WriteLine(Resources.Usage);
                    return;
                }
            }

            var jobManager = new WarehouseJobManager(new Uri(collection));

            if (create)
            {
                if (jobManager.CreateJob(jobName, syncJobExtension, minutesInterval))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    Resources.CreatedJob,
                                                    jobName, syncJobExtension));
                }
                else
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    Resources.JobAlreadyExists, jobName));
                }
            }
            else if (delete)
            {
                if (jobManager.DeleteJob(jobName))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    Resources.JobDeleted, jobName));
                }
                else
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    Resources.JobNotFound, jobName));
                }
            }
            else
            {
                Console.WriteLine(Resources.Usage);
                return;
            }
        }
        static void Main(string[] args)
        {
            var jobName = "";
            var syncJobExtension = "";
            var collection = "";
            var create = false;
            var delete = false;
            var minutesInterval = 2;

            if (args.GetLength(0) == 0)
            {
                Console.WriteLine(Resources.Usage);
                return;
            }

            foreach (var arg in args)
            {
                var nomeArgumento = arg.ToLower();

                if (nomeArgumento.Contains("="))
                    nomeArgumento = nomeArgumento.Split('=')[0];

                if (nomeArgumento == "-jobname")
                {
                    jobName = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-syncjobextension")
                {
                    syncJobExtension = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-collection")
                {
                    collection = arg.Split('=')[1];
                }
                else if (nomeArgumento == "-c")
                {
                    create = true;
                }
                else if (nomeArgumento == "-d")
                {
                    delete = true;
                }
                else if (nomeArgumento == "-t")
                {
                    minutesInterval = int.Parse(arg.Split('=')[1]);
                }
                else
                {
                    Console.WriteLine(Resources.Usage);
                    return;
                }
            }

            var jobManager = new WarehouseJobManager(new Uri(collection));

            if (create)
            {
                if (jobManager.CreateJob(jobName, syncJobExtension, minutesInterval))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                        Resources.CreatedJob,
                        jobName, syncJobExtension));
                }
                else
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                        Resources.JobAlreadyExists, jobName));
                }
            }
            else if (delete)
            {
                if (jobManager.DeleteJob(jobName))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                        Resources.JobDeleted, jobName));
                }
                else
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                        Resources.JobNotFound, jobName));
                }
            }
            else
            {
                Console.WriteLine(Resources.Usage);
                return;
            }
        }