Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

How to correctly deal with "base does not contain a 0 arg constructor"

I am getting the following compile time error:

'MetaSource.SPF.SPFProject' does not contain a constructor that takes '0' arguments      C:\Source\internal\MetaSource\ExportUpload\trunk\Source\ExportUpload\ExportUpload.cs      


How do I deal with this?  I am not authorized to modify SPFProject (the parent class I am inheriting from).

I am trying to inherit from SPFProject:

public class NewSPFProject : SPFProject
{
}

Here is SPFProject:

namespace MetaSource.SPF
{
	public class SPFProject : SPFBusinessBase<SPFProject>, IDisposable
	{
        protected internal SPFProjectDataSet projectDataSet;
	    protected internal System.Data.DataSet jobTypeSettingDataSet;

        internal delegate void StateUpdatedRequestHandler();
        internal event StateUpdatedRequestHandler StateUpdated;

	    private readonly SPFCore parentCore;
	    private readonly SPFCoreDataSet.ProjectRow dataRow;
	    private readonly SPFClient parentClient;

	    private bool selectedProjectInformation;
	    private bool selectedJobTypeInformation;
        private string temporaryPath;

        private SPFDocumentCollection documents;
        private SPFBatchCollection batches;
        private SPFBatchQueueCollection batchQueues;
        private SPFJobCollection jobs;
	    private SPFImageFormatCollection imageFormats;
	    private SPFTypeCollection types;
	    private SPFExportGroupCollection exportGroups;
        private SPFCustomSettingCollection customSettings;
        private SPFProcedureCollection procedures;

	    public event EventHandler<ImageUploadEventArgs> ImageUploaded;
	    
        protected internal string TemporaryPath
        {
            get
            {
                if (temporaryPath == null)
                {
                    temporaryPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                    temporaryPath = Path.Combine(temporaryPath, "MetaSource");
                    temporaryPath = Path.Combine(temporaryPath, "SPF");
                    temporaryPath = Path.Combine(temporaryPath, Guid.NewGuid().ToString());

                    if (!Directory.Exists(temporaryPath))
                    {
                        Directory.CreateDirectory(temporaryPath);
                    }
                }

                return temporaryPath;
            }
        }

	    protected internal SPFCoreDataSet.ProjectRow DataRow
	    {
	        get
	        {
	            return dataRow;
	        }
	    }        
        
        #region Constructor

        protected internal SPFProject(SPFCoreDataSet.ProjectRow ProjectRow, SPFCore spfCore)
        {
            dataRow = ProjectRow;
            projectDataSet = new SPFProjectDataSet();
            parentCore = spfCore;
            parentClient = parentCore.GetClient(ProjectRow.client_id);

            selectedProjectInformation = false;
            selectedJobTypeInformation = false;
        }

        protected internal SPFProject(SPFProject Project)
        {
            Project.SelectProjectInformation();

            parentCore = Project.parentCore.Clone();

            dataRow = parentCore.GetProjectRow(Project.ID);
            projectDataSet = (SPFProjectDataSet) Project.projectDataSet.Copy();
            jobTypeSettingDataSet = Project.jobTypeSettingDataSet.Copy();
            parentClient = parentCore.GetClient(dataRow.client_id);
            
            ConstructObjects();

            // The ProjectDataSet that is passed in should have this data
            selectedProjectInformation = true;
            selectedJobTypeInformation = true;
        }

	    #endregion

        public SPFProject Clone()
        {
            return new SPFProject(this);            
        }

        #region Properties

        #region Public

        public int ID
        {
            get { return dataRow.project_id; }
        }

        public string Code
        {
            get { return dataRow.project_code; }
            set { dataRow.project_code = value; }
        }

        public string Name
        {
            get { return dataRow.project_name; }
            set { dataRow.project_name = value; }
        }

        public Version Version
        {
            get { return new Version(dataRow.project_version); }
            set { dataRow.project_version = value.ToString(); }
        }

        public string ServerName
        {
            get { return dataRow.project_server; }
            set { dataRow.project_server = value; }
        }

        public string DatabaseName
        {
            get { return dataRow.project_database; }
            set { dataRow.project_database = value; }
        }

        public bool Enabled
        {
            get { return dataRow.project_active; }
            set { dataRow.project_active = value; }
        }

        [Browsable(false)]
        public bool HasChanges
        {
            get { return projectDataSet.HasChanges(); }
        }

        #endregion

        #region Public Objects

        [Browsable(false)]
        public SqlConnection SqlConnection
        {
            get
            {
                return new SqlConnection("Server=" + dataRow.project_server + ";Database=" + dataRow.project_database + ";User=spf;Password=Sd3nt0n;");
            }
        }

        [Browsable(false)]
        public SPFClient Client
        {
            get { return parentClient; }
        }

        [Browsable(false)]
        public SPFFileStorage DefaultFileStorage
        {
            get
            {
                return parentCore.FileStorage[dataRow.FileStorageRow];
            }
        }

        [Browsable(false)]
        public SPFCustomSettingCollection CustomSettings
        {
            get
            {
                if (customSettings == null)
                {
                    customSettings = new SPFCustomSettingCollection(this);
                }

                return customSettings;
            }
        }

        #endregion

        #region Public Collections

        [Browsable(false)]
        public SPFDocumentCollection Documents
        {
            get
            {
                if (documents == null)
                {
                    documents = new SPFDocumentCollection(parentCore, this);
                }
                return documents;
            }
        }

        [Browsable(false)]
        public SPFBatchCollection Batches
        {
            get
            {
                if (batches == null)
                {
                    batches = new SPFBatchCollection(parentCore, this);
                }
                return batches;
            }
        }

        [Browsable(false)]
        public SPFBatchQueueCollection BatchQueues
        {
            get
            {
                if (batchQueues == null)
                {
                    batchQueues = new SPFBatchQueueCollection(parentCore, this);
                }
                return batchQueues;
            }
        }

        [Browsable(false)]
        public SPFImageFormatCollection ImageFormats
        {
            get
            {
                SelectProjectInformation();
                return imageFormats;
            }
        }

        [Browsable(false)]
        public SPFJobCollection Jobs
        {
            get
            {
                if (!selectedJobTypeInformation)
                {
                    SelectJobTypeInformation();
                }
                return jobs;
            }
        }

        [Browsable(false)]
        public SPFTypeCollection Types
        {
            get
            {
                if (!selectedJobTypeInformation)
                {
                    SelectJobTypeInformation();
                }
                return types;
            }
        }

        [Browsable(false)]
        public SPFExportGroupCollection ExportGroups
        {
            get
            {
                SelectProjectInformation();
                return exportGroups;
            }
        }

        [Browsable(false)]
        public SPFProcedureCollection Procedures
        {
            get
            {
                SelectProjectInformation();
                return procedures;
            }
        }

        #endregion

        #region Internal

        internal int ApplicationID
	    {
            get { return parentCore.ApplicationID; }
	    }

        public string WebServiceUrl
        {
            get { return parentCore.WebServiceUrl; }
        }

        #endregion

        #endregion

        #region Internal Tables

        protected internal SPFProjectDataSet.JobDataTable JobTable
        {
            get
            {
                SelectProjectInformation();
                return projectDataSet.Job;
            }
        }

	    protected internal SPFProjectDataSet.JobTypeDataTable JobTypeTable
	    {
	        get
	        {
                SelectProjectInformation();
	            return projectDataSet.JobType;
	        }
	    }

        protected internal SPFProjectDataSet.BatchParameterDataTable BatchParameterTable
	    {
            get
            {
                if (!selectedProjectInformation)
                {
                    SelectProjectInformation();
                }
                return projectDataSet.BatchParameter;
            }
	    }

	    protected internal SPFProjectDataSet.BatchParameterValueDataTable BatchParameterValueTable
	    {
            get
            {
                SelectProjectInformation();
                return projectDataSet.BatchParameterValue;
            }
	    }

        protected internal SPFProjectDataSet.BatchDataTable BatchTable
        {
            get { return projectDataSet.Batch; }
        }

        protected internal SPFProjectDataSet.BatchQueueDataTable BatchQueueTable
        {
            get { return projectDataSet.BatchQueue; }
        }

        protected internal SPFProjectDataSet.BatchDocumentDataTable BatchDocumentTable
        {
            get { return projectDataSet.BatchDocument; }
        }

        protected internal SPFProjectDataSet.BatchInfoDataTable BatchInfoTable
        {
            get { return projectDataSet.BatchInfo; }
        }

        protected internal SPFProjectDataSet.ImageFormatDataTable ImageFormatTable
        {
            get
            {
                SelectProjectInformation();
                return projectDataSet.ImageFormat;
            }
        }

	    protected internal SPFProjectDataSet.DocumentDataTable DocumentTable
	    {
            get { return projectDataSet.Document; }
	    }

	    protected internal SPFProjectDataSet.DocumentInfoDataTable DocumentInfoTable
	    {
	        get { return projectDataSet.DocumentInfo; }
	    }

        protected internal SPFProjectDataSet.FileDataTable FileTable
	    {
            get { return projectDataSet.File; }
	    }

        protected internal SPFProjectDataSet.FileImageDataTable FileImageTable
	    {
            get { return projectDataSet.FileImage; }
        }

	    protected internal SPFProjectDataSet.TypeDataTable TypeTable
	    {
            get
            {
                SelectProjectInformation();
                return projectDataSet.Type;
            }
	    }

	    protected internal SPFProjectDataSet.ExportGroupDataTable ExportGroupTable
	    {
            get
            {
                SelectProjectInformation();
                return projectDataSet.ExportGroup;
            }
	    }

	    protected internal SPFProjectDataSet.ExportFileDataTable ExportFileTable
	    {
            get
            {
                SelectProjectInformation();
                return projectDataSet.ExportFile;
            }
	    }

	    protected internal SPFProjectDataSet.BatchPropertiesDataTable BatchPropertiesTable
	    {
	        get
	        {
                SelectProjectInformation();
	            return projectDataSet.BatchProperties;
	        }
	    }

        protected internal SPFProjectDataSet.SettingDataTable SettingsTable
        {
            get
            {
                SelectProjectInformation();
                return projectDataSet.Setting;
            }
        }

        protected internal SPFProjectDataSet.ProcedureDataTable ProcedureTable
        {
            get
            {
                SelectProjectInformation();
                return projectDataSet.Procedure;
            }
        }

        protected internal System.Data.DataSet JobTypeSettingTable
        {
            get
            {
                SelectProjectInformation();
                return jobTypeSettingDataSet;
            }
        }

	    protected internal System.Data.DataSet GetCustomSettings(string SettingName)
	    {
            return parentCore.CoreWebService.ProjectSettingGet(ID, parentCore.UserID, parentCore.ApplicationID, SettingName).Decompress().BinaryDeserialize<System.Data.DataSet>();
	    }

        #endregion

        protected internal byte[] SaveCustomSettings(byte[] compressedBytes)
        {
            return parentCore.CoreWebService.ProjectSettingSave(ID, parentCore.UserID, parentCore.ApplicationID, compressedBytes);
        }

        #region Public Methods

        public void Save()
        {
            Save(false);
        }

	    public void Save(bool useOriginalImageName)
        {
	        projectDataSet.EnforceConstraints = false;
	        //var fullyXmly = projectDataSet.GetXml();
            try
            {

                using (System.Data.DataSet dsChanges = projectDataSet.GetChanges())
                {
                    if (dsChanges != null)
                    {
                        bool modified = false;
                        byte[] compressedBytes = dsChanges.BinarySerialize().Compress();
                        using (System.Data.DataSet dsChangesUpdated = parentCore.CoreWebService.ProjectSave(ID, parentCore.UserID, parentCore.ApplicationID, compressedBytes).Decompress().BinaryDeserialize<SPFProjectDataSet>())
                        {
                            try
                            {
                                projectDataSet.EnforceConstraints = false;
                                projectDataSet.Merge(dsChangesUpdated);
                                projectDataSet.EnforceConstraints = true;
                                projectDataSet.AcceptChanges();

                                var files = new SPFFileCollection(parentCore, this, false);
                                foreach (var file in files)
                                {
                                    if (file.Put(useOriginalImageName))
                                    {
                                        var imageUploaded = ImageUploaded;
                                        if (imageUploaded != null)
                                        {
                                            imageUploaded(this, new ImageUploadEventArgs(file.Name));
                                        }

                                        modified = true;
                                        file.Added = true;
                                        file.Exists = true;
                                    }
                                    else
                                    {
                                        throw new Exception("Warning a file " + file.Name.ToString() + " could not be uploaded.");
                                    }
                                    
                                }
                            }
                            catch (ConstraintException)
                            {
                                CheckDataSetConstraint(projectDataSet);
                                throw;
                            }
                        }

                        if (modified)
                        {
                            using (SPFProjectDataSet dsModifiedChanges = projectDataSet.GetProjectDataSetChanges(DataRowState.Modified))
                            {
                                compressedBytes = dsModifiedChanges.BinarySerialize().Compress();
                                using (SPFProjectDataSet dsModifiedChangesUpdated = parentCore.CoreWebService.ProjectSave(ID, parentCore.UserID, parentCore.ApplicationID, compressedBytes).Decompress().BinaryDeserialize<SPFProjectDataSet>())
                                {
                                    try
                                    {
                                        projectDataSet.Merge(dsModifiedChangesUpdated);
                                        projectDataSet.AcceptChanges();
                                    }
                                    catch (ConstraintException)
                                    {
                                        CheckDataSetConstraint(projectDataSet);
                                        throw;
                                    }
                                }
                            }
                        }

                        StateUpdatedRequestHandler stateUpdatedRequestHandler = StateUpdated;
                        if (stateUpdatedRequestHandler != null)
                        {
                            stateUpdatedRequestHandler();
                        }
                    }
                }
            }
            finally
            {
                projectDataSet.EnforceConstraints = true;
            }
        }

        public void Clear()
        {
            projectDataSet.EnforceConstraints = false;
            projectDataSet.BatchInfo.Clear();
            projectDataSet.Batch.Clear();
            projectDataSet.FileImage.Clear();
            projectDataSet.File.Clear();
            projectDataSet.DocumentInfo.Clear();
            projectDataSet.Document.Clear();
            projectDataSet.BatchDocument.Clear();
            projectDataSet.EnforceConstraints = true;
        }

        #region Xml Methods

        // Insert XML
        public bool DataUpload(FileInfo file)
        {
            file.Refresh();
            if (!file.Exists)
            {
                throw new Exception(string.Format("File {0} does not exist", file.Name));
            }

            Func<FileInfo, byte[]> getBytes = (f =>
            {
                using (FileStream fs = file.Open(FileMode.Open))
                {
                    byte[] data = new byte[file.Length];
                    fs.Read(data, 0, Convert.ToInt32(file.Length));
                    fs.Close();
                    return data;
                }
            });

            byte[] bytes = getBytes(file);

            return DataUpload(bytes, file.Name);
        }

        public bool DataUpload(string Xml, string FileName)
        {
            if (String.IsNullOrEmpty(Xml))
            {
                throw new ArgumentException("Cannot pass a an empty string for upload.");
            }

            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            byte[] bytes = encoding.GetBytes(Xml);

            return DataUpload(bytes, FileName);
        }

        private bool DataUpload(byte[] bytes, string FileName)
        {
            if (bytes.Length <= 0)
            {
                throw new Exception(string.Format("No bytes after reading for {0}", FileName));
            }

            byte[] compressedBytes = bytes.Compress(CompressionMethod.Deflated64, CompressionLevel.Highest);

            int tries = 0;
            bool ReturnStatus = false;
            while (tries < 2)
            {
                try
                {
                    // TODO: Change to xmlupload project
                    ReturnStatus = parentCore.CoreWebService.ProjectDataUpload(this.ID, parentCore.UserID, parentCore.ApplicationID, compressedBytes, FileName);
                    break;
                }
                catch
                {
                    // wait 20 seconds
                    Thread.Sleep(new TimeSpan(0, 0, 20));
                    tries++;
                    if (tries == 2)
                    {
                        throw;
                    }
                }
            }

            if (ReturnStatus)
            {
                return true;
            }

            throw new Exception(string.Format("Could not upload {0} file", FileName));
        }

        // Update xml Status
        public bool DataUpdateStatus(iBaseData Data, XmlStatus Status, string ErrorText, decimal? TotalExecutionTime)
        {
            int tries = 0;
            bool ReturnStatus = false;
            while (tries < 2)
            {
                try
                {
                    // TODO : change to project xml
                    ReturnStatus = parentCore.CoreWebService.ProjectDataUpdateStatus(this.ID, parentCore.UserID, parentCore.ApplicationID, Data.ID, (SPFWebService.Core.XmlStatus)Status, ErrorText, TotalExecutionTime);
                    break;
                }
                catch
                {
                    // wait 20 seconds
                    Thread.Sleep(new TimeSpan(0, 0, 20));
                    tries++;
                    if (tries == 2)
                    {
                        throw;
                    }
                }
            }

            return ReturnStatus;
        }

        // Select XML
        public SPFDataCollection DataProcessGetRecords()
        {
            return DataProcessGetRecords(50);
        }

        public SPFDataCollection DataProcessGetRecords(int MaxRecordsSelected)
        {
            return DataGetRecords(true, MaxRecordsSelected, true, true, null, null, null);
        }

        public SPFDataCollection DataProcessGetRecords(int? MaxRecordsSelected, bool FilterOutProcessed, bool FilterOutStats, string FilterByProcedureName, string FilterByBatchName, XmlStatus? FilterByXmlStatus)
        {
            return DataGetRecords(true, MaxRecordsSelected, FilterOutProcessed, FilterOutStats, FilterByProcedureName, FilterByBatchName, FilterByXmlStatus);
        }

        public SPFDataCollection DataGetRecords(int? MaxRecordsSelected, bool FilterOutProcessed, bool FilterOutStats, string FilterByProcedureName, string FilterByBatchName, XmlStatus? FilterByXmlStatus)
        {
            return DataGetRecords(false, MaxRecordsSelected, FilterOutProcessed, FilterOutStats, FilterByProcedureName, FilterByBatchName, FilterByXmlStatus);
        }

        private SPFDataCollection DataGetRecords(bool ForProcessing, int? MaxRecordsSelected, bool FilterOutProcessed, bool FilterOutStats, string FilterByProcedureName, string FilterByBatchName, XmlStatus? FilterByXmlStatus)
        {
            int tries = 0;
            byte[] returnedBytes = null;
            while (tries < 2)
            {
                try
                {
                    // TODO: change to project xml 
                    returnedBytes = parentCore.CoreWebService.ProjectDataGetRecords(this.ID, parentCore.UserID, parentCore.ApplicationID, ForProcessing, MaxRecordsSelected, FilterOutProcessed, FilterOutStats, FilterByProcedureName, FilterByBatchName, (SPFWebService.Core.XmlStatus?)FilterByXmlStatus);
                    break;
                }
                catch
                {
                    // wait 20 seconds
                    Thread.Sleep(new TimeSpan(0, 0, 20));
                    tries++;
                    if (tries == 2)
                    {
                        throw;
                    }
                }
            }

            return new SPFDataCollection(this, returnedBytes.Decompress().BinaryDeserialize<SPFProjectDataSet.DataDataTable>());
        }

        public XmlStatus DataExecute(SPFData Data)
        {
            return Execute(Data, new Func<iBaseData, XmlStatus, string, decimal?, bool>(DataUpdateStatus));
        }

        public XmlStatus XmlExecute(SPFXmlData XmlData)
        {
            return Execute(XmlData, new Func<iBaseData, XmlStatus, string, decimal?, bool>(this.parentCore.LegacyXmlUpdateStatus));
        }

        private XmlStatus Execute(iBaseData Data, Func<iBaseData, XmlStatus, string, decimal?, bool> UpdateStatus)
        {
            DateTime StartTime = DateTime.Now;
            XmlStatus returnStatus = XmlStatus.ProcessedComplete;
            if (Data == null)
            {
                throw new ArgumentNullException("The Xml Class cannot be null");
            }
            
            // Try to get the xml file information
            Xml XmlFile = null;
            try
            {
                XmlFile = Data.XmlFile;
                // Check to ensure stored procedures exist.
                if (XmlFile.StoredProcedure.Length == 0)
                {
                    throw new ArgumentOutOfRangeException("No Stored Procedure classes exist on the Xml Class");
                }
            }
            catch(Exception ex)
            {
                // If the xml is invalid. Update status to invalid xml
                if(UpdateStatus(Data, XmlStatus.ErrorInvalidXml, "The Xml is not valid. Error: " + ex.Message, 0))
                {
                    return XmlStatus.ErrorInvalidXml;
                }
                throw new Exception("The Xml is not valid and cannot be parsed. " + ex.ToString());
            }

            // Ensure that the procedure is valid
            var procedureResults = (from p in Procedures
                                   join sp in XmlFile.StoredProcedure on
                                    p.Name.ToLower().Trim() equals sp.Name.ToLower().Trim()
                                   select p);

            if (procedureResults.Count() == 0)
            {
                if (UpdateStatus(Data, XmlStatus.ErrorNotAuthorized, "The procedure didn't exists or wasn't enabled.", 0))
                {
                    return XmlStatus.ErrorNotAuthorized;
                }
                throw new Exception("Unable to update the xml status as 'Error Not Authorized'.");
            }

            SqlConnection sqlConnection = null;
            string transactionName = Guid.NewGuid().ToString().Replace("-", "");
            SqlTransaction transaction = null;
            string ExecuteError = null;
            try
            {
                int procedureNumber = 0;
                foreach (StoredProcedure procedure in XmlFile.StoredProcedure)
                {
                    sqlConnection = GetSqlConnection(XmlFile, procedureNumber);
                    sqlConnection.Open();
                    transaction = sqlConnection.BeginTransaction(transactionName);

                    SqlCommand sqlCommand = new SqlCommand(procedure.Name, sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.CommandTimeout = 600;
                    sqlCommand.Transaction = transaction;

                    if (procedure.Parameters != null)
                    {
                        foreach (StoredProcedureParameter parameter in procedure.Parameters)
                        {
                            if (parameter.Parameter == XmlStoredProcedureParameterType.Guid)
                            {
                                sqlCommand.Parameters.Add(parameter.Name, SqlDbType.UniqueIdentifier);
                                sqlCommand.Parameters[parameter.Name].Value = new Guid(parameter.Value);
                            }
                            else
                            {
                                sqlCommand.Parameters.Add(
                                            new SqlParameter(
                                                parameter.Name,
                                                parameter.Value
                                                )
                                                {
                                                    IsNullable = true
                                                });

                                // Hack before we get bulk insert. to extend time out if a large document count is found
                                int documentcount = 0;
                                if (parameter.Name.Equals("documentcount", StringComparison.OrdinalIgnoreCase)
                                && int.TryParse(parameter.Value, out documentcount)
                                && documentcount > 1000)
                                {
                                    sqlCommand.CommandTimeout = 1800;
                                }
                            }
                        }
                    }

                    sqlCommand.Parameters.Add(new SqlParameter("@ReturnValue", SqlDbType.Int));
                    sqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue;

                    sqlCommand.ExecuteNonQuery();
                    int returnValue = (int)sqlCommand.Parameters["@ReturnValue"].Value;

                    if (returnValue == 0)
                    {
                        transaction.Rollback(transactionName);
                        returnStatus = XmlStatus.ErrorRetry;
                        break;
                    }

                    transaction.Commit();
                    switch (returnValue)
                    {
                        case 3:
                            returnStatus = XmlStatus.ProcessedPartial;
                            break;
                        case 2:
                            returnStatus = XmlStatus.ProcessedDuplicate;
                            break;
                        default:
                            returnStatus = XmlStatus.ProcessedComplete;
                            break;
                    }

                    sqlConnection.Close();
                    sqlConnection.Dispose();
                    sqlConnection = null;
                    procedureNumber++;
                }
            }
            catch (Exception ex)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                ExecuteError = ex.Message;
                returnStatus = XmlStatus.ErrorRetry; 
            }
            finally
            {
                if(sqlConnection != null)
                {
                    sqlConnection.Dispose();
                }
            }

            DateTime StopTime = DateTime.Now;
            TimeSpan ExecutionTime = StopTime.Subtract(StartTime);
            lock (parentCore.LockObject)
            {
                if (UpdateStatus(Data, returnStatus, ExecuteError, Decimal.Parse(ExecutionTime.Minutes + "." + ExecutionTime.Seconds)))
                {
                    return returnStatus;
                }
            }            
            throw new Exception("Unable to update the xml status as '" + returnStatus + "'.");
        }

        #endregion

        private SqlConnection GetSqlConnection(Xml XmlFile, int ProcedureNumber)
        {
            if (XmlFile.StoredProcedure.Length == 1)
            {
                return this.SqlConnection;
            }

            StoredProcedure storedProcedure = XmlFile.StoredProcedure[ProcedureNumber];

            if (String.IsNullOrEmpty(storedProcedure.Server) || String.IsNullOrEmpty(storedProcedure.Database))
            {
                return this.SqlConnection;
            }

            if (storedProcedure.Server.Equals("DCS-SLC-SQL", StringComparison.CurrentCultureIgnoreCase) &&
                storedProcedure.Database.Equals("ProjectTracking", StringComparison.CurrentCultureIgnoreCase))
            {
                //HACK: This is here so we can quickly change the master server over to DRPR-SQL1 without having to change the
                //      other processes

                return new SqlConnection("Server=DRPR-SQL1.AD.METASOURCE.COM\\AWS;Database=ProjectTracking;User=spf;Password=Sd3nt0n;");
            }

            return new SqlConnection("Server=" + storedProcedure.Server + ";Database=" + storedProcedure.Database + ";User=spf;Password=Sd3nt0n;");
        }
        #endregion

        private void SelectJobTypeInformation()
        {
            SPFProjectDataSet ds = null;
            try
            {                
                ds = parentCore.CoreWebService.ProjectJobTypeGetByID(ID, parentCore.UserID, parentCore.ApplicationID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
                projectDataSet.Merge(ds);

                jobs = new SPFJobCollection(this);
                types = new SPFTypeCollection(this);

                selectedJobTypeInformation = true;
            }
            catch (ConstraintException)
            {
                //string xmlDump = projectDataSet.XmlSerialize<System.Data.DataSet>();
                if (ds != null) CheckDataSetConstraint(ds);
                CheckDataSetConstraint(projectDataSet);
                throw;
            }
        }

        protected void ConstructObjects()
        {
            jobs = new SPFJobCollection(this);
            procedures = new SPFProcedureCollection(this);
            if (Version >= new Version("2.5"))
            {
                types = new SPFTypeCollection(this);
                //jobTypeSettingDataSet = parentCore.CoreWebService.ProjectGetJobTypeSettings(ID, parentCore.UserID, parentCore.ApplicationID).Decompress().BinaryDeserialize<System.Data.DataSet>();
            }
            if (Version >= new Version("2.7"))
            {
                exportGroups = new SPFExportGroupCollection(this);
                imageFormats = new SPFImageFormatCollection(this);
            }
        }


        protected internal void SelectProjectInformation()
        {
            try
            {
                if (selectedProjectInformation)
                {
                    return;
                }

                if (!selectedJobTypeInformation)
                {
                    SelectJobTypeInformation();
                }

                SPFProjectDataSet ds = parentCore.CoreWebService.ProjectGetByID(ID, parentCore.UserID, parentCore.ApplicationID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
                projectDataSet.Merge(ds);

                //jobs = new SPFJobCollection(this);
                //procedures = new SPFProcedureCollection(this);
                if (Version >= new Version("2.5"))
                {
                    //types = new SPFTypeCollection(this);
                    jobTypeSettingDataSet = parentCore.CoreWebService.ProjectGetJobTypeSettings(ID, parentCore.UserID, parentCore.ApplicationID).Decompress().BinaryDeserialize<System.Data.DataSet>();
                }
                //if (Version >= new Version("2.7"))
                //{
                //    exportGroups = new SPFExportGroupCollection(this);
                //    imageFormats = new SPFImageFormatCollection(this);
                //}
                ConstructObjects();

                selectedProjectInformation = true;
            }
            catch (ConstraintException)
            {
                CheckDataSetConstraint(projectDataSet);
                throw;
            }           
        }

        protected internal bool SelectBatchByID(int BatchID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchGetByID(ID, parentCore.UserID, parentCore.ApplicationID, BatchID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return true;
        }

        protected internal SPFProjectDataSet GetBatchByID(int BatchID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchGetByID(ID, parentCore.UserID, parentCore.ApplicationID, BatchID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            return ds;
        }

        protected internal bool SelectBatchByName(string BatchName)
        {
            try
            {
                int rowCount = projectDataSet.Batch.Rows.Count;
                var ds = parentCore.CoreWebService.ProjectBatchGetByName(ID, parentCore.UserID, parentCore.ApplicationID, BatchName).Decompress().BinaryDeserialize<SPFProjectDataSet>();
                projectDataSet.Merge(ds);
                return ds.Batch.Rows.Count == rowCount+1;
            }
            catch (ConstraintException)
            {
                CheckDataSetConstraint(projectDataSet);
                throw;
            }
        }

        private void CheckDataSetConstraint(System.Data.DataSet dataSet)
        {
//#if DEBUG
//            string xmlDump = projectDataSet.XmlSerialize<System.Data.DataSet>();
//            StreamWriter sw = new StreamWriter(@"C:\XmlDump.xml");
//            sw.Write(xmlDump);
//            sw.Close();
//            sw.Dispose();
//#endif
            if (dataSet.HasErrors)
            {
                foreach (DataTable currentTable in dataSet.Tables)
                {
                    if (currentTable.HasErrors)
                    {
                        foreach (DataRow errorRow in currentTable.GetErrors())
                        {
                            foreach (DataColumn column in currentTable.Columns)
                            {
                                if (errorRow.GetColumnError(column).Length > 0)
                                {
                                    System.Diagnostics.Debug.WriteLine(string.Format("For Table {0} and Column {1}: {2}", currentTable.TableName, column.ColumnName, errorRow.GetColumnError(column)));
                                }
                            }
                        }
                    }
                }
            }
        }

        protected internal bool SelectBatchByAssigned(int StatusID, int LocationID, int ProcessID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchGetByAssigned(ID, parentCore.UserID, parentCore.ApplicationID, StatusID, LocationID, ProcessID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return true;
        }

        protected internal bool SelectBatchByDetail(string Type, string Job, short? Year, short? Julian, int[] Batch, short? LocationID, int? StatusID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchGetByDetail(ID, parentCore.UserID, parentCore.ApplicationID, Type, Job, Year, Julian, Batch, LocationID, StatusID, null).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return true;
        }
        
        protected internal bool SelectBatchAssign(int TypeID, string Job, short? Year, short? Julian, short? LocationID, int Amount)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchAssign(ID, parentCore.UserID, parentCore.ApplicationID, TypeID.ToString(), Job, Year, Julian, LocationID, Amount).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return ds.Batch.Rows.Count > 0;
        }

        protected internal bool SelectBatchAssign(int TypeID, int JobID, short? Year, short? Julian, short? LocationID, int Amount, string GroupValue)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchAssignGroup(ID, parentCore.UserID, parentCore.ApplicationID, TypeID.ToString(), JobID.ToString(), Year, Julian, LocationID, Amount, GroupValue).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            
            projectDataSet.Merge(ds);

            return ds.Batch.Rows.Count > 0;
        }

        protected internal bool SelectBatchByDetail(int TypeID, int JobID, short? Year, short? Julian, int[] Batch, short? LocationID, int? SingleOrMaxStatusID, int? MinStatusId)
        {
            var ds = parentCore.CoreWebService.ProjectBatchGetByDetail(ID, parentCore.UserID, parentCore.ApplicationID, TypeID.ToString(), JobID.ToString(), Year, Julian, Batch, LocationID, SingleOrMaxStatusID, MinStatusId).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return ds.Batch.Rows.Count > 0;
        }

        protected internal bool SelectBatchByScanUpdate(int TypeID, int JobID, int SingleOrMaxStatusID, int? MinStatusId)
        {
            var ds = parentCore.CoreWebService.ProjectBatchGetByScanUpdate(ID, parentCore.UserID, parentCore.ApplicationID, TypeID, JobID, SingleOrMaxStatusID, MinStatusId).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return ds.Batch.Rows.Count > 0;
        }

	    protected internal bool SelectBatchInfoByBatchID(int BatchID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchInfoGetByBatchID(ID, parentCore.UserID, parentCore.ApplicationID, BatchID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);

            return true;
        }

        protected internal bool SelectDocumentByBatchID(int BatchID)
        {
            try
            {
                if (!selectedJobTypeInformation)
                {
                    SelectJobTypeInformation();
                }

                SPFProjectDataSet ds = parentCore.CoreWebService.ProjectDocumentGetByBatchID(ID, parentCore.UserID, parentCore.ApplicationID, BatchID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
                projectDataSet.Merge(ds);

                return true;
            }
            catch (ConstraintException cex)
            {
                CheckDataSetConstraint(projectDataSet);
                throw;
            }
        }

        protected internal SPFProjectDataSet GetDocumentByBatchID(int BatchID)
        {
            try
            {
                if (!selectedJobTypeInformation)
                {
                    SelectJobTypeInformation();
                }

                SPFProjectDataSet ds = parentCore.CoreWebService.ProjectDocumentGetByBatchID(ID, parentCore.UserID, parentCore.ApplicationID, BatchID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
                return ds;
            }
            catch (ConstraintException)
            {
                CheckDataSetConstraint(projectDataSet);
                throw;
            }
        }


        #region Export Upload

	    public bool ProjectExportComplete(byte[] table)
        {
            return parentCore.CoreWebService.ProjectExportGroupComplete(ID, parentCore.UserID, parentCore.ApplicationID, table);
        }

	    public byte[] ProjectExportMark(int GroupID, out Guid GroupGuid)
        {
            return parentCore.CoreWebService.ProjectExportGroupMark(ID, parentCore.UserID, parentCore.ApplicationID, GroupID, out GroupGuid);
        }

        public ActiveSource.Formats.Batch ProjectBatchGenerateActiveCaptureFormat(int ExportFileID, Guid ExportGuid)
        {
            byte[] compressedData = parentCore.CoreWebService.ProjectBatchExportActiveCatpureFormat(ID, parentCore.UserID, parentCore.ApplicationID, ExportFileID, ExportGuid);
	        return compressedData.Decompress().BinaryDeserialize<string>().XmlDeserialize<ActiveSource.Formats.Batch>();
        }

        #endregion

        #region Legacy Scan Station

        public bool LegacyValidBatch(string BatchName, out int DocumentCount, out int BatchStatus)
        {
            return parentCore.CoreWebService.LegacyScanValidBatch(ID, parentCore.UserID, parentCore.ApplicationID, BatchName, out DocumentCount, out BatchStatus);
        }

        public bool LegacyUploadImage(string BatchName, string ImageName, long ImageSize, byte[] Buffer)
        {
            return parentCore.CoreWebService.LegacyScanUploadImage(ID, parentCore.UserID, parentCore.ApplicationID, BatchName, ImageName, ImageSize, Buffer);
        }

        public bool LegacyCloseBatch(SPFWebService.Core.LegacyBatchInfo Batch)
        {
            return parentCore.CoreWebService.LegacyScanCloseBatch(ID, parentCore.UserID, parentCore.ApplicationID, Batch);
        }

        #endregion

        #region Legacy Batch Manager

        public bool LegacyBatchGetUserInformation(string Username, out System.Data.DataSet data)
        {
            return parentCore.CoreWebService.LegacyBatchGetUserInformation(ID, parentCore.UserID, parentCore.ApplicationID, Username, out data);
        }

        public bool LegacyBatchGetJobYear(string Job, out System.Data.DataSet Data)
        {
            return parentCore.CoreWebService.LegacyBatchGetJobYear(ID, parentCore.UserID, ApplicationID, Job, out Data);
        }

        public bool LegacyBatchGetJobYearJulian(string Job, string Year, out System.Data.DataSet Data)
        {
            return parentCore.CoreWebService.LegacyBatchGetJobYearJulian(ID, parentCore.UserID, parentCore.ApplicationID, Job, Year, out Data);
        }

        public bool LegacyBatchGetJobYearJulianBundle(string Job, string Year, string Julian, out System.Data.DataSet Data)
        {
            return parentCore.CoreWebService.LegacyBatchGetJobYearJulianBundle(ID, parentCore.UserID, parentCore.ApplicationID, Job, Year, Julian, out Data);
        }

        public bool LegacyBatchGetBatchFilter(string Job, string Year, string Julian, string Batches, out System.Data.DataSet Data)
        {
            return parentCore.CoreWebService.LegacyBatchGetBatchFilter(ID, parentCore.UserID, parentCore.ApplicationID, Job, Year, Julian, Batches, out Data);
        }

        public bool LegacyBatchGetBatchExtraFieldInfo(string Job, out SPFWebService.Core.ExtraField[] Data)
        {
            return parentCore.CoreWebService.LegacyBatchGetBatchExtraFieldInfo(ID, parentCore.UserID, parentCore.ApplicationID, Job, out Data);
        }

        public bool LegacyBatchInsertBatches(string Job, SPFWebService.Core.LegacyBatches Batches, ref System.Data.DataSet BatchesAdded)
        {
            return parentCore.CoreWebService.LegacyBatchInsertBatches(ID, parentCore.UserID, parentCore.ApplicationID, Job, Batches, ref BatchesAdded);
        }

        public bool LegacyBatchDeleteBatches(string Job, SPFWebService.Core.LegacyBatches Batches)
        {
            return parentCore.CoreWebService.LegacyBatchDeleteBatches(ID, parentCore.UserID, parentCore.ApplicationID, Job, Batches);
        }

        public bool LegacyBatchUpdateBatchDocumentCount(string BatchName, int DocumentCount)
        {
            return parentCore.CoreWebService.LegacyBatchUpdateBatchDocumentCount(ID, parentCore.UserID, parentCore.ApplicationID, BatchName, DocumentCount);
        }

        public bool LegacyBatchGetBatchSearchParameters(out string[][] Parameters)
        {
            return parentCore.CoreWebService.LegacyBatchGetBatchSearchParameters(ID, parentCore.UserID, parentCore.ApplicationID, out Parameters);
        }

        #endregion

        #region Legacy Key Assigner

        public int LegacyKeyAssignKeyBatchNameByJulianDayJobCodeLocation(string Year, string JulianDay, string JobCode, short Location)
        {            
            return parentCore.CoreWebService.LegacyKeyAssignKeyBatchNameByJulianDayJobCodeLocation(ID, parentCore.UserID, parentCore.ApplicationID, Year, JulianDay, JobCode, Location);
        }        

        public System.Data.DataSet LegacyKeyGetEmptyAssignTable()
        {
            return parentCore.CoreWebService.LegacyKeyGetEmptyAssignTable(ID, parentCore.UserID, parentCore.ApplicationID);
        }        

        public System.Data.DataSet LegacyKeyGetJulianDaysWithUnassignedOutstandingDocuments()
        {            
            return parentCore.CoreWebService.LegacyKeyGetJulianDaysWithUnassignedOutstandingDocuments(ID, parentCore.UserID, parentCore.ApplicationID);
        }

        public System.Data.DataSet LegacyKeyGetUnassignedKeyBatchesByJulianDay(string JulianDay, int Year)
        {
            return parentCore.CoreWebService.LegacyKeyGetUnassignedKeyBatchesByJulianDay(ID, parentCore.UserID, parentCore.ApplicationID, JulianDay, Year);
        }

        public System.Data.DataSet LegacyKeyGetLocations()
        {
            return parentCore.CoreWebService.LegacyKeyGetLocations(ID, parentCore.UserID, parentCore.ApplicationID);
        }

        public System.Data.DataSet LegacyKeyGetAssignerStatusInfo(string JulianDay)
        {
            return parentCore.CoreWebService.LegacyKeyGetAssignerStatusInfo(ID, parentCore.UserID, parentCore.ApplicationID, JulianDay);
        }

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            if (temporaryPath != null)
            {
                if (Directory.Exists(temporaryPath))
                {
                    Directory.Delete(temporaryPath, true);
                }
            }
        }

        #endregion

	    public override void Delete()
	    {
	        dataRow.Delete();
	    }

        public override bool IsDeleted
        {
            get
            {
                if (dataRow.RowState == System.Data.DataRowState.Detached || dataRow.RowState == System.Data.DataRowState.Deleted)
                {
                    return true;
                }
                return false;
            }
        }

        internal bool SelectBatchQueueByID(int BatchQueueID)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchQueueGetByID(ID, parentCore.UserID, parentCore.ApplicationID, BatchQueueID).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);
            return true;
        }

        internal bool SelectBatchQueueByName(string BatchQueueName)
        {
            SPFProjectDataSet ds = parentCore.CoreWebService.ProjectBatchQueueGetByName(ID, parentCore.UserID, parentCore.ApplicationID, BatchQueueName).Decompress().BinaryDeserialize<SPFProjectDataSet>();
            projectDataSet.Merge(ds);
            return true;
        }
    }
}

Open in new window



NOTE:  both constructors in the class appear to be "protected internal"
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
1 Solution
 
wdosanjosCommented:
Since SPFProject does not have a default constructor (no parameters), you need to provide a constructor to your class similar to the one below:
public class NewSPFProject : SPFProject
{
    public NewSPFProject() : base(this) /* SPFProject Project */
    {
    }
}

Open in new window


I hope this helps.
0
 
Tom KnowltonWeb developerAuthor Commented:
When I make that change it says:

'MetaSource.SPF.SPFProject' is a 'type' but is used like a 'variable'      


Current inherited class code:

  public class NewSPFProject : SPFProject
    {
        public NewSPFProject()
            : base(this) /* SPFProject Project */
        {
        }
    }

Open in new window

0
 
Tom KnowltonWeb developerAuthor Commented:
I made the following change and now the code compiles:

 public class NewSPFProject : SPFProject
    {
        public NewSPFProject()
            : base(new NewSPFProject()) 
        {
        }
    }

Open in new window



BUT...

What is this DOING and is it correct?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now