Example #1
0
        private void CopyForm_Load(object sender, EventArgs e)
        {
            string filename = Properties.Settings.Default.FileName;

            if (!string.IsNullOrEmpty(filename) && File.Exists(filename))
            {
                this.FileName = filename;
                this.Settings = CopyObject.Read(this.FileName);

                // get latest template values
                this.RefreshSource();
                this.RefreshDestination();
            }
        }
Example #2
0
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            this.FileName = this.openFileDialog1.FileName;

            this.Settings = CopyObject.Read(this.FileName);

            // get latest template values
            this.RefreshSource();
            this.RefreshDestination();

            Properties.Settings.Default.FileName = this.FileName;
            Properties.Settings.Default.Save();

            //SerializationHelper.Serialize<List<CopyObject>>(this.list, @"config\list.xml");
        }
Example #3
0
        //// Consume them
        //static void Main(string[] args) {
        //  var options = new Options();
        //  if (CommandLine.Parser.Default.ParseArguments(args, options)) {
        //	// Values are available here
        //	if (options.Verbose) Console.WriteLine("Filename: {0}", options.InputFile);
        //  }
        //}

        //https://commandline.codeplex.com/

        static void Main(string[] args)
        {
            int exitCode = 0;

            // pare the command line arguments
            var result = CommandLine.Parser.Default.ParseArguments <Options>(args);

            // if there are no errors
            if (!result.Errors.Any())
            {
                // Values are available here
                string filename = result.Value.FileName;

                if (!string.IsNullOrEmpty(filename))
                {
                    if (File.Exists(filename))
                    {
                        CopyObject obj = CopyObject.Read(filename);

                        if (obj != null)
                        {
                            CopyManager manager = new CopyManager(obj);
                            {
                                try
                                {
                                    manager.PreCopy();
                                }
                                catch (Exception er)
                                {
                                    obj.PreCopyStatus = er.Message;
                                    return;
                                }

                                foreach (TableObject table in obj.Tables)
                                {
                                    try
                                    {
                                        if (table.Selected)
                                        {
                                            manager.Copy(table);
                                            //table.Status = "Success";
                                            table.CopyStatus = CopyStatusEnum.Success;
                                            System.Console.WriteLine("Success " + table.Name);
                                        }
                                    }
                                    catch (Exception er)
                                    {
                                        //table.Status = er.Message;
                                        table.Message    = er.Message;
                                        table.CopyStatus = CopyStatusEnum.Error;
                                        System.Console.WriteLine("Error " + table.Name);
                                        exitCode = -1;
                                    }
                                }

                                try
                                {
                                    manager.PostCopy();
                                }
                                catch (Exception er)
                                {
                                    obj.PostCopyStatus = er.Message;
                                    exitCode           = -1;
                                }
                            }
                        }
                    }
                    else
                    {
                        exitCode = -5;
                    }
                }
                else
                {
                    exitCode = -4;
                }
            }
            else
            {
                exitCode = -3;
            }

            Environment.Exit(exitCode);
        }