Beispiel #1
0
		private void Parse(string[] args) 
		{
			int numargs = args.Length;
			string arg;

			if (numargs == 0) 
			{
				this._showHelp = true;
				return;
			}

			for (int i = 0; i < numargs; i++) 
			{
				arg = args[i];

				switch (arg)
                {
                    case "-internaluse":
                        this._internalUse = true;
                        break;
                    case "-installvs2005":
                        this._installVS2005 = true;
                        break;
                    case "-tc":
                    case "-testconnection":
                        this._mode = ProcessMode.MyMeta;
                        if (numargs > (i + 2))
                        {
                            this._connType = args[++i];
                            this._connString = args[++i];
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-aio":
					case "-addintrinsicobject":
						if (numargs > (i+3)) 
						{
							string assembly = args[++i];
							string classpath = args[++i];
							string varname = args[++i];

							ZeusIntrinsicObject iobj = new ZeusIntrinsicObject(assembly, classpath, varname);
							this._intrinsicObjects.Add(iobj);
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-rio":
					case "-removeintrinsicobject":
                        if (numargs > (i + 1))
                        {
                            string varname = args[++i];
                            foreach (ZeusIntrinsicObject zio in ZeusConfig.Current.IntrinsicObjects)
                            {
                                if (zio.VariableName == varname && !_intrinsicObjectsToRemove.Contains(zio))
                                {
                                    this._intrinsicObjectsToRemove.Add(zio);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-r":
					case "-relative":
						this._makeRelative = true;
						break;
					case "-s":
					case "-silent":
						this._silent = true;
						break;
					case "-?":
					case "-h":
					case "-help":
						this._showHelp = true;
						break;
					case "-l":
					case "-logfile":
						this._enableLog = true;
						if (numargs > (i+1)) 
							this._pathLog = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-o":
					case "-outfile":
						if (numargs > (i+1)) 
							this._pathOutput = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-p":
					case "-project":
						this._mode = ProcessMode.Project;
						if (numargs > (i+1)) 
							this._pathProject = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-mumd":
                    case "-mergeusermetadata":
                        this._mode = ProcessMode.MyMeta;
                        this._metaDataMerge = true;
                        if (numargs > (i + 5))
                        {
                            this._metaDataFile1 = args[++i];
                            this._metaDatabase1 = args[++i];
                            this._metaDataFile2 = args[++i];
                            this._metaDatabase2 = args[++i];
                            this._metaDataFileMerged = args[++i];
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
                    case "-m":
                    case "-pf":
                    case "-module":
                    case "-projectfolder":
						if (numargs > (i+1)) 
						{
							string data = args[++i];
							if (!_moduleNames.Contains(data))
								this._moduleNames.Add(data);
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
                        break;
                    case "-rti":
                    case "-recordtemplateinstance":
                        if (numargs > (i + 1))
                        {
                            this._projectItemToRecord = args[++i];
                            this._mode = ProcessMode.Project;
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
                    case "-ti":
                    case "-templateinstance":
                        if (numargs > (i + 1))
                        {
                            string data = args[++i];
                            if (!_projectItems.Contains(data))
                                this._projectItems.Add(data);
                        }
                        else
                        {
                            this._valid = false;
                            this._errorMessage = "Invalid switch usage: " + arg;
                        }
                        break;
					case "-i":
					case "-inputfile":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathXmlData = args[++i];
						else  
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-t":
					case "-template":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathTemplate = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-c":
					case "-collect":
						this._mode = ProcessMode.Template;
						if (numargs > (i+1)) 
							this._pathCollectXmlData = args[++i];
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					case "-e":
					case "-timeout":
						if (numargs > (i+1)) 
						{
							try 
							{
								this._timeout = Int32.Parse(args[++i]);
							}
							catch 
							{
								this._timeout = -1;
							}
						}
						else 
						{
							this._valid = false;
							this._errorMessage = "Invalid switch usage: " + arg;
						}
						break;
					default:
						_valid = false;
						this._errorMessage = "Invalid argument: " + arg;
						break;
				}
			}

			if (this._makeRelative) 
			{
				if (this._pathCollectXmlData != null)
					this._pathCollectXmlData = Zeus.FileTools.MakeAbsolute(this._pathCollectXmlData, FileTools.ApplicationPath);
				if (this._pathLog != null)
                    this._pathLog = Zeus.FileTools.MakeAbsolute(this._pathLog, FileTools.ApplicationPath);
				if (this._pathOutput != null)
                    this._pathOutput = Zeus.FileTools.MakeAbsolute(this._pathOutput, FileTools.ApplicationPath);
				if (this._pathProject != null)
                    this._pathProject = Zeus.FileTools.MakeAbsolute(this._pathProject, FileTools.ApplicationPath);
				if (this._pathTemplate != null)
                    this._pathTemplate = Zeus.FileTools.MakeAbsolute(this._pathTemplate, FileTools.ApplicationPath);
				if (this._pathXmlData != null)
                    this._pathXmlData = Zeus.FileTools.MakeAbsolute(this._pathXmlData, FileTools.ApplicationPath);
                if (this._metaDataFile1 != null)
                    this._metaDataFile1 = Zeus.FileTools.MakeAbsolute(this._metaDataFile1, FileTools.ApplicationPath);
                if (this._metaDataFile2 != null)
                    this._metaDataFile2 = Zeus.FileTools.MakeAbsolute(this._metaDataFile2, FileTools.ApplicationPath);
                if (this._metaDataFileMerged != null)
                    this._metaDataFileMerged = Zeus.FileTools.MakeAbsolute(this._metaDataFileMerged, FileTools.ApplicationPath);
			}


			// Validate required fields are filled out for the selected mode.
			if (_valid) 
			{
                if (this.Mode == ProcessMode.MyMeta) 
                {
                    if (this._metaDataMerge)
                    {
                        if (!System.IO.File.Exists(_metaDataFile1) || !System.IO.File.Exists(_metaDataFile2))
                        {
                            _valid = false;
                            this._errorMessage = "The two source files must exist for the merge to work!";
                        }
                    }
                }
				else if (this._mode == ProcessMode.Project) 
				{
					if (this._pathProject == null)
					{
						_valid = false;
						this._errorMessage = "Project Path Required";
					}
					else 
					{
						try 
						{
							this._project = new ZeusProject(this._pathProject);
							this._project.Load();
						}
						catch (Exception ex)
						{
							this._project = null;
							this._valid = false;
							this._errorMessage = ex.Message;
						}
					}


                    if (this._pathTemplate != null)
                    {
                        try
                        {
                            this._template = new ZeusTemplate(this._pathTemplate);
                        }
                        catch (Exception ex)
                        {
                            this._template = null;
                            this._valid = false;
                            this._errorMessage = ex.Message;
                        }
                    }
				}
				else if (this._mode == ProcessMode.Template) 
				{
					if ( (this._pathTemplate == null) && (this._pathXmlData == null) )
					{
						_valid = false;
						this._errorMessage = "Template path or XML input path required.";
					}
					else 
					{
						if (this._pathTemplate != null)
						{
							try 
							{
								this._template = new ZeusTemplate(this._pathTemplate);
							}
							catch (Exception ex)
							{
								this._template = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}

						if ( (this._valid) && (this._pathXmlData != null) )
						{
							try 
							{
								this._savedInput = new ZeusSavedInput(this._pathXmlData);
								this._savedInput.Load();

								if (this._template == null) 
								{
									this._template = new ZeusTemplate(this._savedInput.InputData.TemplatePath);
								}
							}
							catch (Exception ex)
							{
								this._savedInput = null;
								this._template = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}

						if ( (this._valid) && (this._pathCollectXmlData != null) )
						{
							try 
							{
								this._inputToSave = new ZeusSavedInput(this._pathCollectXmlData);
								this._inputToSave.InputData.TemplatePath = this._template.FilePath + this._template.FileName;
								this._inputToSave.InputData.TemplateUniqueID = this._template.UniqueID;
							}
							catch (Exception ex)
							{
								this._inputToSave = null;
								this._valid = false;
								this._errorMessage = ex.Message;
							}
						}
					}
				}

			}
		}
Beispiel #2
0
        private void Parse(string[] args)
        {
            int    numargs = args.Length;
            string arg;

            if (numargs == 0)
            {
                this._showHelp = true;
                return;
            }

            for (int i = 0; i < numargs; i++)
            {
                arg = args[i];

                switch (arg)
                {
                case "-internaluse":
                    this._internalUse = true;
                    break;

                case "-installvs2005":
                    this._installVS2005 = true;
                    break;

                case "-tc":
                case "-testconnection":
                    this._mode = ProcessMode.MyMeta;
                    if (numargs > (i + 2))
                    {
                        this._connType   = args[++i];
                        this._connString = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-aio":
                case "-addintrinsicobject":
                    if (numargs > (i + 3))
                    {
                        string assembly  = args[++i];
                        string classpath = args[++i];
                        string varname   = args[++i];

                        ZeusIntrinsicObject iobj = new ZeusIntrinsicObject(assembly, classpath, varname);
                        this._intrinsicObjects.Add(iobj);
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-rio":
                case "-removeintrinsicobject":
                    if (numargs > (i + 1))
                    {
                        string varname = args[++i];
                        foreach (ZeusIntrinsicObject zio in ZeusConfig.Current.IntrinsicObjects)
                        {
                            if (zio.VariableName == varname && !_intrinsicObjectsToRemove.Contains(zio))
                            {
                                this._intrinsicObjectsToRemove.Add(zio);
                                break;
                            }
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-r":
                case "-relative":
                    this._makeRelative = true;
                    break;

                case "-s":
                case "-silent":
                    this._silent = true;
                    break;

                case "-?":
                case "-h":
                case "-help":
                    this._showHelp = true;
                    break;

                case "-l":
                case "-logfile":
                    this._enableLog = true;
                    if (numargs > (i + 1))
                    {
                        this._pathLog = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-o":
                case "-outfile":
                    if (numargs > (i + 1))
                    {
                        this._pathOutput = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-p":
                case "-project":
                    this._mode = ProcessMode.Project;
                    if (numargs > (i + 1))
                    {
                        this._pathProject = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-mumd":
                case "-mergeusermetadata":
                    this._mode          = ProcessMode.MyMeta;
                    this._metaDataMerge = true;
                    if (numargs > (i + 5))
                    {
                        this._metaDataFile1      = args[++i];
                        this._metaDatabase1      = args[++i];
                        this._metaDataFile2      = args[++i];
                        this._metaDatabase2      = args[++i];
                        this._metaDataFileMerged = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-m":
                case "-pf":
                case "-module":
                case "-projectfolder":
                    if (numargs > (i + 1))
                    {
                        string data = args[++i];
                        if (!_moduleNames.Contains(data))
                        {
                            this._moduleNames.Add(data);
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-rti":
                case "-recordtemplateinstance":
                    if (numargs > (i + 1))
                    {
                        this._projectItemToRecord = args[++i];
                        this._mode = ProcessMode.Project;
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-ti":
                case "-templateinstance":
                    if (numargs > (i + 1))
                    {
                        string data = args[++i];
                        if (!_projectItems.Contains(data))
                        {
                            this._projectItems.Add(data);
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-i":
                case "-inputfile":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathXmlData = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-t":
                case "-template":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathTemplate = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-c":
                case "-collect":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathCollectXmlData = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-e":
                case "-timeout":
                    if (numargs > (i + 1))
                    {
                        try
                        {
                            this._timeout = Int32.Parse(args[++i]);
                        }
                        catch
                        {
                            this._timeout = -1;
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                default:
                    _valid             = false;
                    this._errorMessage = "Invalid argument: " + arg;
                    break;
                }
            }

            if (this._makeRelative)
            {
                if (this._pathCollectXmlData != null)
                {
                    this._pathCollectXmlData = Zeus.FileTools.MakeAbsolute(this._pathCollectXmlData, FileTools.ApplicationPath);
                }
                if (this._pathLog != null)
                {
                    this._pathLog = Zeus.FileTools.MakeAbsolute(this._pathLog, FileTools.ApplicationPath);
                }
                if (this._pathOutput != null)
                {
                    this._pathOutput = Zeus.FileTools.MakeAbsolute(this._pathOutput, FileTools.ApplicationPath);
                }
                if (this._pathProject != null)
                {
                    this._pathProject = Zeus.FileTools.MakeAbsolute(this._pathProject, FileTools.ApplicationPath);
                }
                if (this._pathTemplate != null)
                {
                    this._pathTemplate = Zeus.FileTools.MakeAbsolute(this._pathTemplate, FileTools.ApplicationPath);
                }
                if (this._pathXmlData != null)
                {
                    this._pathXmlData = Zeus.FileTools.MakeAbsolute(this._pathXmlData, FileTools.ApplicationPath);
                }
                if (this._metaDataFile1 != null)
                {
                    this._metaDataFile1 = Zeus.FileTools.MakeAbsolute(this._metaDataFile1, FileTools.ApplicationPath);
                }
                if (this._metaDataFile2 != null)
                {
                    this._metaDataFile2 = Zeus.FileTools.MakeAbsolute(this._metaDataFile2, FileTools.ApplicationPath);
                }
                if (this._metaDataFileMerged != null)
                {
                    this._metaDataFileMerged = Zeus.FileTools.MakeAbsolute(this._metaDataFileMerged, FileTools.ApplicationPath);
                }
            }


            // Validate required fields are filled out for the selected mode.
            if (_valid)
            {
                if (this.Mode == ProcessMode.MyMeta)
                {
                    if (this._metaDataMerge)
                    {
                        if (!System.IO.File.Exists(_metaDataFile1) || !System.IO.File.Exists(_metaDataFile2))
                        {
                            _valid             = false;
                            this._errorMessage = "The two source files must exist for the merge to work!";
                        }
                    }
                }
                else if (this._mode == ProcessMode.Project)
                {
                    if (this._pathProject == null)
                    {
                        _valid             = false;
                        this._errorMessage = "Project Path Required";
                    }
                    else
                    {
                        try
                        {
                            this._project = new ZeusProject(this._pathProject);
                            this._project.Load();
                        }
                        catch (Exception ex)
                        {
                            this._project      = null;
                            this._valid        = false;
                            this._errorMessage = ex.Message;
                        }
                    }


                    if (this._pathTemplate != null)
                    {
                        try
                        {
                            this._template = new ZeusTemplate(this._pathTemplate);
                        }
                        catch (Exception ex)
                        {
                            this._template     = null;
                            this._valid        = false;
                            this._errorMessage = ex.Message;
                        }
                    }
                }
                else if (this._mode == ProcessMode.Template)
                {
                    if ((this._pathTemplate == null) && (this._pathXmlData == null))
                    {
                        _valid             = false;
                        this._errorMessage = "Template path or XML input path required.";
                    }
                    else
                    {
                        if (this._pathTemplate != null)
                        {
                            try
                            {
                                this._template = new ZeusTemplate(this._pathTemplate);
                            }
                            catch (Exception ex)
                            {
                                this._template     = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }

                        if ((this._valid) && (this._pathXmlData != null))
                        {
                            try
                            {
                                this._savedInput = new ZeusSavedInput(this._pathXmlData);
                                this._savedInput.Load();

                                if (this._template == null)
                                {
                                    this._template = new ZeusTemplate(this._savedInput.InputData.TemplatePath);
                                }
                            }
                            catch (Exception ex)
                            {
                                this._savedInput   = null;
                                this._template     = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }

                        if ((this._valid) && (this._pathCollectXmlData != null))
                        {
                            try
                            {
                                this._inputToSave = new ZeusSavedInput(this._pathCollectXmlData);
                                this._inputToSave.InputData.TemplatePath     = this._template.FilePath + this._template.FileName;
                                this._inputToSave.InputData.TemplateUniqueID = this._template.UniqueID;
                            }
                            catch (Exception ex)
                            {
                                this._inputToSave  = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }
                    }
                }
            }
        }