Exemplo n.º 1
0
        public static bool CreateCadastralJob(ICadastralFabric Fabric, string JobName, out ICadastralJob NewCadastralJob, bool WriteToFabric, ref bool JobExists)
        {
            try
            {
                JobExists = false; //first assume it does not exist
                //Create a job.
                ICadastralJob pJob = new CadastralJobClass();
                pJob.Name        = JobName;
                pJob.Owner       = System.Windows.Forms.SystemInformation.UserName;
                pJob.Description = "Append Cadastral XML";
                int jobId;
                NewCadastralJob = null;

                if (WriteToFabric)
                {
                    try
                    {
                        jobId           = Fabric.CreateJob(pJob);
                        NewCadastralJob = pJob;
                    }
                    catch (COMException ex)
                    {
                        if (ex.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_ALREADY_EXISTS)
                        {
                            //now set the job variable to existing job
                            NewCadastralJob = Fabric.GetJob(JobName);
                            JobExists       = true;
                        }
                        return(false);
                    }
                }
                else
                {
                    NewCadastralJob = pJob;
                }

                return(true);
            }
            catch (Exception ex)
            {
                //create a dictionary of error codes for cadastral job related activities.
                Dictionary <int, String> errorCodeDict = new Dictionary <int, String>();
                errorCodeDict.Add(-2147212278, "Job has already been committed.");
                errorCodeDict.Add(-2147212277, "Job not found.");
                errorCodeDict.Add(-2147212269, "Parcel feature is part of a job that is currently being edited.");
                errorCodeDict.Add(-2147212268, "Source datum does not match the fabric datum.");
                errorCodeDict.Add(-2147212271, "The version of XML cannot be loaded.");
                errorCodeDict.Add(-2147212274, "The specified cadastral job does not belong to the current fabric.");
                errorCodeDict.Add(-2147212284, "A job with the specified name already exists.");
                errorCodeDict.Add(-2147212283, "The status of the job is invalid for this procedure.");
                errorCodeDict.Add(-2147212282, "Schema error. Required fields are missing.");
                errorCodeDict.Add(-2147212281, "Lock already exists for cadastral feature.");
                COMException c_Ex = (COMException)ex;
                NewCadastralJob = null;
                MessageBox.Show(ex.Message + Environment.NewLine + errorCodeDict[c_Ex.ErrorCode]);
                return(false);
            }
        }