Esempio n. 1
0
        public override string GenerateTransformer()
        {
            string inputColumn  = InputColumns.Count() == 1 ? InputColumns[0] : throw new Exception($"input columns for the suggested transform: {MethodName} is not exactly one.");
            string outputColumn = OutputColumns.Count() == 1 ? OutputColumns[0] : throw new Exception($"output columns for the suggested transform: {MethodName} it not exactly one.");

            return($"ExtractPixels({outputColumn}, {inputColumn})");
        }
Esempio n. 2
0
        public override string GenerateTransformer()
        {
            StringBuilder sb           = new StringBuilder();
            string        inputColumn  = InputColumns.Count() > 0 ? InputColumns[0] : "\"Features\"";
            string        outputColumn = OutputColumns.Count() > 0 ? OutputColumns[0] : throw new Exception($"output columns for the suggested transform: {MethodName} are null");

            sb.Append(MethodName);
            sb.Append("(");
            sb.Append("new []{");
            for (int i = 0; i < InputColumns.Length; i++)
            {
                sb.Append("new ");
                sb.Append(ArgumentsName);
                sb.Append("(");
                sb.Append(OutputColumns[i]);
                sb.Append(",");
                sb.Append(InputColumns[i]);
                sb.Append(")");
                sb.Append(",");
            }
            sb.Remove(sb.Length - 1, 1); // remove extra ,
            sb.Append("}");
            sb.Append(")");
            return(sb.ToString());
        }
Esempio n. 3
0
        public override int CalculateSearchHashCode()
        {
            var hashCode = base.CalculateSearchHashCode();

            hashCode += UniqueResult.GetHashCode();

            if (Type != null)
            {
                hashCode += Type.GetHashCode();
            }

            if (OutputColumns != null)
            {
                OutputColumns.ForEach(x => hashCode += x.CalculateSearchHint());
            }

            if (SortColumns != null)
            {
                SortColumns.ForEach(x => hashCode += x.CalculateSearchHint());
            }

            if (Criteria != null)
            {
                Criteria.ForEach(x => hashCode += x.CalculateSearchHashCode());
            }

            return(hashCode);
        }
Esempio n. 4
0
        public override string GenerateTransformer()
        {
            string inputColumn  = InputColumns.Count() == 1 ? InputColumns[0] : throw new Exception($"input columns for the suggested transform: {MethodName} is not exactly one.");
            string outputColumn = OutputColumns.Count() == 1 ? OutputColumns[0] : throw new Exception($"output columns for the suggested transform: {MethodName} it not exactly one.");

            // example: Transforms.LoadImages(output, inputfolder, input)
            return($"{MethodName}({outputColumn}, {@"null"}, {inputColumn})");
        }
Esempio n. 5
0
 private void UpgradeToExecuteMultipleIfNecessary()
 {
     // If there are output columns for anything that isn't part of the Create Response, then
     // we have to upgrade to an executemultiplerequest, with an additional Retrieve to get the extra values.
     if (OutputColumns.Any())
     {
         UpgradeRequestToExecuteMultipleWithRetrieve(CurrentRequest.Target.LogicalName, CurrentRequest.Target.Id);
     }
 }
        internal static OutputColumns GetOutputColumns <T>(DbContext context, bool hasInserts, bool hasUpdates,
                                                           RefreshMode refreshMode, Dictionary <string, PropertyInfo> columns, ICollection <string> keys,
                                                           Dictionary <string, bool> computedCols)
        {
            List <string> keyList = null;
            List <string> colList = null;

            switch (refreshMode)
            {
            case RefreshMode.None:
                return(null);

            case RefreshMode.Identity:
                //No need to return identity if there're no inserts
                if (hasInserts)
                {
                    keyList = computedCols.Where(x => x.Value).Select(x => x.Key).ToList();
                }
                break;

            case RefreshMode.All:
                if (hasInserts)
                {
                    keyList = computedCols.Where(x => x.Value).Select(x => x.Key).ToList();
                }
                //Return computed columns if there're an inserts/updates
                if (hasInserts || hasUpdates)
                {
                    var computedColumns = computedCols.Where(x => !x.Value).Select(x => x.Key).ToList();
                    if (computedColumns.Count > 0 && keyList != null && keyList.Count == 0)
                    {
                        //If there're only computed columns and no identities, we need to include the primary key to identify the values.
                        keyList = keys.ToList();
                    }
                    colList = computedColumns;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(refreshMode), refreshMode, null);
            }

            if (keyList == null || keyList.Count == 0)
            {
                return(null);
            }

            var outKeys = keyList.ToDictionary(x => x, y => columns[y]);
            var outCols = colList?.ToDictionary(x => x, y => columns[y]);

            var tableName = GetTempTableName <T>() + "OutValues";
            var tableSql  = context.GetOutTableDdl(tableName, outKeys, outCols);
            var result    = new OutputColumns(outKeys, outCols, tableName, tableSql);

            return(result);
        }
Esempio n. 7
0
        // sets the column as hidden when not present in the list of visible columns
        private void SetColHiddenProperty(DataColumn cl_dt)
        {
            OutputColumn currentCol = OutputColumns.FirstOrDefault(x => x.Name == cl_dt.ColumnName);

            if (currentCol != null)
            {
                cl_dt.ExtendedProperties.Add("hidden", currentCol.Hidden);
            }
            else
            {
                cl_dt.ExtendedProperties.Add("hidden", false);
            }
        }
Esempio n. 8
0
        public override string GenerateTransformer()
        {
            StringBuilder sb           = new StringBuilder();
            string        inputColumn  = InputColumns.Count() > 0 ? InputColumns[0] : "\"Features\"";
            string        outputColumn = OutputColumns.Count() > 0 ? OutputColumns[0] : throw new Exception($"output columns for the suggested transform: {MethodName} are null");

            sb.Append(MethodName);
            sb.Append("(");
            sb.Append(outputColumn);
            sb.Append(",");
            sb.Append(inputColumn);
            sb.Append(")");
            return(sb.ToString());
        }
Esempio n. 9
0
 public override bool Equals(object obj)
 {
     if (obj is SelectStatement statement)
     {
         return(Kind == statement.Kind &&
                Class == statement.Class &&
                OutputColumns.SequenceEqual(statement.OutputColumns) &&
                (MainSource == statement.MainSource || MainSource.Equals(statement.MainSource)) &&
                (FilterConditions == statement.FilterConditions || FilterConditions.Equals(statement.FilterConditions)) &&
                OutputOrder.SequenceEqual(statement.OutputOrder));
     }
     else
     {
         return(false);
     }
 }
Esempio n. 10
0
        public override string GenerateTransformer()
        {
            StringBuilder sb           = new StringBuilder();
            string        inputColumn  = InputColumns.Count() > 0 ? InputColumns[0] : "\"Features\"";
            string        outputColumn = OutputColumns.Count() > 0 ? OutputColumns[0] : throw new Exception($"output columns for the suggested transform: {MethodName} are null");

            sb.Append(MethodName);
            sb.Append("(");
            sb.Append(outputColumn);
            sb.Append(",");
            sb.Append("new []{");
            foreach (var col in InputColumns)
            {
                sb.Append(col);
                sb.Append(",");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("}");
            sb.Append(")");
            return(sb.ToString());
        }
        /// <summary>
        /// Checks  the output columns. if there are output values that that aren't available from the CreateResponse, then
        /// upgrades the Request to an ExecuteMultiple request, that contains the CreateRequest, and a RetrieveRequest to
        /// to get the additional output values.
        /// </summary>
        private void UpgradeToExecuteMultipleIfNecessary()
        {
            // If there are output columns for anything that isn't part of the Create Response, then
            // we have to upgrade to an executemultiplerequest, with an additional Retrieve to get the extra values.
            if (OutputColumns.Any())
            {
                // If only a single output column, and if it's the id, then executemultiple not necessary as
                // this is already returned as the result from the createrequest.
                var targetEntity = CurrentRequest.Target;
                if (OutputColumns.Count() == 1)
                {
                    var col = OutputColumns.First();
                    IsVisitingSingleOutput = true;
                    col.ProjectionItem.Accept(this);
                    if (IsOutputSingleId)
                    {
                        return;
                    }
                }

                IsVisitingSingleOutput = false;

                // To get any other output, the id must be specified as part of the insert, so that we have the info
                // we need to do the additional retrieve request.
                if (targetEntity.Id == Guid.Empty)
                {
                    throw new NotSupportedException("An OUTPUT clause can only be used in an Insert statement, if either the INSERT specifies the ID for the new entity, or if the only Output column is the inserted entities ID.");
                }

                UpgradeRequestToExecuteMultipleWithRetrieve(targetEntity.LogicalName, targetEntity.Id);
            }
            else
            {
                // No output columns however we still automatically output the id.
                this.AddColumnMetadata(CurrentRequest.Target.LogicalName, null, CurrentRequest.Target.LogicalName + "id");
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Reads the database generated identity/computed columns.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="context"></param>
        /// <param name="entities"></param>
        /// <param name="outSettings"></param>
        internal static void RefreshEntities <T>(DbContext context, ICollection <T> entities, OutputColumns outSettings)
        {
            //storing values into a dictionary based on keys hash to facilitate fast lookup.
            var values  = new Dictionary <int, object[]>();
            var command = context.Database.Connection.CreateCommand();

            command.CommandText = outSettings.SelectSql;
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    // ReSharper disable once AccessToDisposedClosure
                    var keys = outSettings.Keys.Select(x => reader[SqlHelper.OldColumnPrefix + x.Key]).ToArray();
                    var vals = new object[outSettings.AllColumns.Count];
                    var i    = 0;
                    foreach (var col in outSettings.AllColumns.Keys)
                    {
                        vals[i] = reader[col];
                        i++;
                    }
                    values.Add(HashHelper.CombineHashCodes(keys), vals);
                }
                reader.Close();
            }

            foreach (var entity in entities)
            {
                var key = HashHelper.CombineHashCodes(outSettings.Keys.Select(x => x.Value.GetValue(entity, null)).ToArray());
                var i   = 0;
                foreach (var prop in outSettings.AllColumns.Values)
                {
                    //Values are stored in the object array in the same order as AllColumns, hence it's safe to use the index.
                    prop.SetValue(entity, values[key][i], null);
                    i++;
                }
            }
        }
Esempio n. 13
0
        private void Prepare()
        {
            lock (eventsTable)
            {
                //
                // Add Collection Time column
                //
                if (!eventsTable.Columns.Contains("collection_time") && (OutputColumns.Count == 0 || OutputColumns.Exists(x => x.Name == "collection_time") || (Filter != null && Filter.Contains("collection_time"))))
                {
                    DataColumn cl_dt = new DataColumn("collection_time", typeof(DateTime))
                    {
                        DefaultValue = DateTime.Now
                    };
                    cl_dt.ExtendedProperties.Add("auto_column", true);
                    SetColHiddenProperty(cl_dt);
                    eventsTable.Columns.Add(cl_dt);
                }


                //
                // Add Name column
                //
                if (!eventsTable.Columns.Contains("name") && (OutputColumns.Count == 0 || OutputColumns.Exists(x => x.Name == "name") || (Filter != null && Filter.Contains("name"))))
                {
                    eventsTable.Columns.Add("name", typeof(String));
                    eventsTable.Columns["name"].ExtendedProperties.Add("auto_column", true);
                }
            }
        }
Esempio n. 14
0
 public void AddOutputColumn(string columnName)
 {
     OutputColumns.Add(new SearchOutputColumn {
         Name = columnName
     });
 }
Esempio n. 15
0
        protected IDTSOutputColumn100 GetOutputColumn(string columnName)
        {
            var column = OutputColumns.Single(oc => oc.Name == columnName);

            return(column);
        }
Esempio n. 16
0
        private void Prepare()
        {
            lock (eventsTable)
            {
                //
                // Add Collection Time column
                //
                if (!eventsTable.Columns.Contains("collection_time") && (OutputColumns.Count == 0 || OutputColumns.Contains("collection_time")))
                {
                    DataColumn cl_dt = new DataColumn("collection_time", typeof(DateTime))
                    {
                        DefaultValue = DateTime.Now
                    };
                    cl_dt.ExtendedProperties.Add("auto_column", true);
                    eventsTable.Columns.Add(cl_dt);
                }


                //
                // Add Name column
                //
                if (!eventsTable.Columns.Contains("Name") && (OutputColumns.Count == 0 || OutputColumns.Contains("Name")))
                {
                    eventsTable.Columns.Add("Name", typeof(String));
                    eventsTable.Columns["Name"].ExtendedProperties.Add("auto_column", true);
                }
            }
        }
Esempio n. 17
0
        public void ReadEvent(PublishedEvent evt)
        {
            Prepare();
            //
            // Read event data
            //
            lock (eventsTable)
            {
                foreach (PublishedEventField fld in evt.Fields)
                {
                    if (!eventsTable.Columns.Contains(fld.Name) && (OutputColumns.Count == 0 || OutputColumns.Contains(fld.Name)))
                    {
                        Type       t;
                        DataColumn dc;
                        bool       disallowed = false;
                        if (DataTableTSQLAdapter.AllowedDataTypes.Contains(fld.Type.ToString()))
                        {
                            t = fld.Type;
                        }
                        else
                        {
                            t = Type.GetType("System.String");
                        }
                        dc = eventsTable.Columns.Add(fld.Name, t);
                        dc.ExtendedProperties.Add("subtype", "field");
                        dc.ExtendedProperties.Add("disallowedtype", disallowed);
                        dc.ExtendedProperties.Add("calculated", false);
                    }
                }

                foreach (PublishedAction act in evt.Actions)
                {
                    if (!eventsTable.Columns.Contains(act.Name) && (OutputColumns.Count == 0 || OutputColumns.Contains(act.Name)))
                    {
                        Type       t;
                        DataColumn dc;
                        bool       disallowed = false;
                        if (DataTableTSQLAdapter.AllowedDataTypes.Contains(act.Type.ToString()))
                        {
                            t = act.Type;
                        }
                        else
                        {
                            t = Type.GetType("System.String");
                        }
                        dc = eventsTable.Columns.Add(act.Name, t);
                        dc.ExtendedProperties.Add("subtype", "action");
                        dc.ExtendedProperties.Add("disallowedtype", disallowed);
                        dc.ExtendedProperties.Add("calculated", false);
                    }
                }


                // add calculated columns
                for (int i = 0; i < OutputColumns.Count; i++)
                {
                    string outCol = OutputColumns[i];
                    if (!eventsTable.Columns.Contains(outCol))
                    {
                        if (Regex.IsMatch(outCol, @"\s+AS\s+", RegexOptions.IgnoreCase))
                        {
                            var    tokens        = Regex.Split(outCol, @"\s+AS\s+", RegexOptions.IgnoreCase);
                            string colName       = tokens[0];
                            string colDefinition = tokens[1];

                            DataColumn dc;
                            dc            = eventsTable.Columns.Add();
                            dc.ColumnName = colName;
                            dc.Expression = colDefinition;
                            dc.ExtendedProperties.Add("subtype", "calculated");
                            dc.ExtendedProperties.Add("disallowedtype", false);
                            dc.ExtendedProperties.Add("calculated", true);

                            //change OutputColumns
                            OutputColumns[i] = colName;
                        }
                    }
                }
            }

            DataTable tmpTab = eventsTable.Clone();
            DataRow   row    = tmpTab.NewRow();

            if (row.Table.Columns.Contains("Name"))
            {
                row.SetField("Name", evt.Name);
            }
            if (row.Table.Columns.Contains("collection_time"))
            {
                row.SetField("collection_time", evt.Timestamp.LocalDateTime);
            }

            foreach (PublishedEventField fld in evt.Fields)
            {
                if (row.Table.Columns.Contains(fld.Name))
                {
                    if ((bool)row.Table.Columns[fld.Name].ExtendedProperties["disallowedtype"])
                    {
                        row.SetField(fld.Name, fld.Value.ToString());
                    }
                    else
                    {
                        row.SetField(fld.Name, fld.Value);
                    }
                }
            }

            foreach (PublishedAction act in evt.Actions)
            {
                if (row.Table.Columns.Contains(act.Name))
                {
                    if ((bool)row.Table.Columns[act.Name].ExtendedProperties["disallowedtype"])
                    {
                        row.SetField(act.Name, act.Value.ToString());
                    }
                    else
                    {
                        row.SetField(act.Name, act.Value);
                    }
                }
            }

            if (!String.IsNullOrEmpty(Filter))
            {
                DataView dv = new DataView(tmpTab);
                dv.RowFilter = Filter;

                tmpTab.Rows.Add(row);

                lock (eventsTable)
                {
                    foreach (DataRow dr in dv.ToTable().Rows)
                    {
                        eventsTable.ImportRow(dr);
                    }
                }
            }
            else
            {
                tmpTab.Rows.Add(row);
                lock (eventsTable)
                {
                    foreach (DataRow dr in tmpTab.Rows)
                    {
                        eventsTable.ImportRow(dr);
                    }
                }
            }
        }
        public BufferToolConfig(string anXMLProfile)
        {
            // Open XML
            myFileFuncs   = new FileFunctions();
            myStringFuncs = new StringFunctions();
            string strXMLFile = anXMLProfile; // The user has specified this and we've checked it exists.

            foundXML  = true;                 // In this version we have already checked that it exists.
            loadedXML = true;

            // Go forth and obtain all information.
            // Firstly, read the file.
            if (foundXML)
            {
                XmlDocument xmlConfig = new XmlDocument();
                try
                {
                    xmlConfig.Load(strXMLFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in XML file; cannot load. System error message: " + ex.Message, "XML Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }
                string  strRawText;
                XmlNode currNode = xmlConfig.DocumentElement.FirstChild; // This gets us the DataBuffer.
                xmlDataBuffer = (XmlElement)currNode;

                // XML loaded successfully; get all of the detail in the Config object.

                try
                {
                    logFilePath = xmlDataBuffer["LogFilePath"].InnerText;
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'LogFilePath' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                try
                {
                    defaultClearLog = false;
                    string strDefaultClearLogFile = xmlDataBuffer["DefaultClearLogFile"].InnerText;
                    if (strDefaultClearLogFile == "Yes")
                    {
                        defaultClearLog = true;
                    }
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'DefaultClearLogFile' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                try
                {
                    defaultPath = xmlDataBuffer["DefaultPath"].InnerText;
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'DefaultPath' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                try
                {
                    layerPath = xmlDataBuffer["LayerPath"].InnerText;
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'LayerPath' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                //try
                //{
                //    tempFilePath = xmlDataBuffer["TempFilePath"].InnerText;
                //}
                //catch
                //{
                //    MessageBox.Show("Could not locate the item 'TempFilePath' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    loadedXML = false;
                //    return;
                //}

                // Locate the GIS Layers.
                XmlElement MapLayerCollection = null;
                try
                {
                    MapLayerCollection = xmlDataBuffer["InLayers"];
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'InLayers' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }
                // Now cycle through them.
                foreach (XmlNode aNode in MapLayerCollection)
                {
                    MapLayer thisLayer = new MapLayer();
                    string   strName   = aNode.Name;
                    strName = strName.Replace("_", " "); // Replace any underscores with spaces for better display.
                    thisLayer.DisplayName = strName;

                    try
                    {
                        thisLayer.LayerName = aNode["LayerName"].InnerText;
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'LayerName' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    // Sort out the columns. This is pretty involved.
                    try
                    {
                        InputColumns theInputColumns = new InputColumns();
                        string       strColumnList   = aNode["Columns"].InnerText;
                        // We have the format (inputColumn1 "outputColumn1", inputColumn2, inputColumn3, "outputColumn3", "inputText" "outputColumn4", ...)
                        // Firstly split the list at the commas.
                        List <string> strColumnDefList = strColumnList.Split(',').ToList();
                        // Go through these and sort out what's what.
                        foreach (string aColumnDef in strColumnDefList)
                        {
                            InputColumn thisInputColumn = new InputColumn();
                            // Check if the first character is a "\"". If so, we deal with it slightly differently.
                            string        strColumnDef = aColumnDef.Trim(); // Remove any spaces.
                            List <string> strColItems  = new List <string>();
                            if (strColumnDef.Substring(0, 1) == "\"")
                            {
                                // find the first entry.
                                int position; // First character is a '"' so we don't want to find that.
                                int start = 0;
                                // Extract the items from the string.
                                position = strColumnDef.IndexOf('\"', start + 1);
                                if (position == 0)
                                {
                                    position = 1;
                                }
                                if (position > 0)
                                {
                                    string strResult = strColumnDef.Substring(start, position - start + 1).Trim();
                                    strColItems.Add(strResult);
                                    //start = position;
                                }
                                // The second item is split by string.
                                List <string> strAllEntries = strColumnDef.Split(' ').ToList();
                                string        theEntry      = strAllEntries[strAllEntries.Count - 1]; // Last entry.
                                strColItems.Add(theEntry.Trim('"'));                                  // Trim quotes if they are there.
                            }
                            else
                            {
                                // Split at space.
                                strColItems = strColumnDef.Split(' ').ToList();
                            }
                            // Test to see how many elements.
                            if (strColItems.Count == 1)
                            {
                                thisInputColumn.InputName  = strColItems[0].Trim();
                                thisInputColumn.OutputName = strColItems[0].Trim(); // They are both the same.
                            }
                            else if (strColItems.Count == 2)
                            {
                                thisInputColumn.InputName  = strColItems[0].Trim();
                                thisInputColumn.OutputName = strColItems[1].Trim('"'); // Trim quotes if they are there
                            }
                            else
                            {
                                // More than two elements; that's not right.
                                MessageBox.Show("The column entry " + strColItems[0] + " for map layer " + thisLayer.DisplayName + " in the XML file contains " + strColItems.Count.ToString() + " items. It should only have two.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                loadedXML = false;
                                return;
                            }

                            theInputColumns.Add(thisInputColumn);
                        }
                        thisLayer.InputColumns = theInputColumns;
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'Columns' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    try
                    {
                        thisLayer.WhereClause = aNode["WhereClause"].InnerText;
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'WhereClause' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    //try
                    //{
                    //    thisLayer.SortOrder = aNode["SortOrder"].InnerText;
                    //}
                    //catch
                    //{
                    //    MessageBox.Show("Could not locate the item 'SortOrder' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //    loadedXML = false;
                    //    return;
                    //}

                    try
                    {
                        int  a;
                        bool blResult = int.TryParse(aNode["BufferSize"].InnerText, out a);
                        if (blResult)
                        {
                            thisLayer.BufferSize = a;
                        }
                        else
                        {
                            MessageBox.Show("Could not locate the item 'BufferSize' for map layer " + thisLayer.DisplayName + " in the XML file, or the item is not an integer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            loadedXML = false;
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'BufferSize' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    try
                    {
                        int  a;
                        bool blResult = int.TryParse(aNode["DissolveSize"].InnerText, out a);
                        if (blResult)
                        {
                            thisLayer.DissolveSize = a;
                        }
                        else
                        {
                            MessageBox.Show("Could not locate the item 'DissolveSize' for map layer " + thisLayer.DisplayName + " in the XML file, or the item is not an integer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            loadedXML = false;
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'BufferSize' for map layer " + thisLayer.DisplayName + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }


                    // if everything is correct, add to the list.
                    if (loadedXML)
                    {
                        inputLayers.Add(thisLayer);
                    }
                }

                // Now get the output layer definition
                XmlElement OutLayerDef = null;
                try
                {
                    OutLayerDef = xmlDataBuffer["OutLayer"];
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'OutLayer' in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                // Get to the columns
                XmlNode ColumnNode = null;
                try
                {
                    ColumnNode = OutLayerDef["Columns"];
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'Columns' for the OutLayer in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }


                // Get all the columns.
                OutputColumns theOutputColumns = new OutputColumns();
                foreach (XmlNode aNode in ColumnNode)
                {
                    OutputColumn thisColumn = new OutputColumn();
                    thisColumn.ColumnName = aNode.Name;

                    try
                    {
                        thisColumn.ColumnName = aNode["ColumnName"].InnerText;
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'ColumnName' for output column " + thisColumn.ColumnTag + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    // List of accepted types.
                    List <string> ColumnTypes = new List <string>()
                    {
                        "key", "cluster", "first", "common", "min", "max", "range"
                    };
                    try
                    {
                        strRawText = aNode["ColumnType"].InnerText.ToLower();
                        if (ColumnTypes.Contains(strRawText))
                        {
                            thisColumn.ColumnType = strRawText; // Always lower case.

                            // Now also add this type to the relevant output column in ALL the input layers.
                            foreach (MapLayer aLayer in inputLayers)
                            {
                                // Find the output column with the same name.
                                bool blFoundIt = false;
                                foreach (InputColumn aColumn in aLayer.InputColumns)
                                {
                                    if (aColumn.OutputName == thisColumn.ColumnName)
                                    {
                                        aColumn.ColumnType = strRawText;
                                        blFoundIt          = true;
                                        break;
                                    }
                                }
                                if (!blFoundIt)
                                {
                                    MessageBox.Show("The output column " + thisColumn.ColumnName + " was not found for map layer " + aLayer.LayerName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    loadedXML = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("The value for 'ColumnType' for output column " + thisColumn.ColumnTag + " in the XML file is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            loadedXML = false;
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'ColumnType' for output column " + thisColumn.ColumnTag + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    List <string> FieldTypes = new List <string>()
                    {
                        "TEXT", "FLOAT", "DOUBLE", "SHORT", "LONG", "DATE"
                    };
                    try
                    {
                        strRawText = aNode["FieldType"].InnerText.ToUpper();
                        if (FieldTypes.Contains(strRawText))
                        {
                            thisColumn.FieldType = strRawText; // Always upper case.

                            // Now also add this type to the relevant output column in ALL the input layers.
                            foreach (MapLayer aLayer in inputLayers)
                            {
                                // Find the output column with the same name.
                                bool blFoundIt = false;
                                foreach (InputColumn aColumn in aLayer.InputColumns)
                                {
                                    if (aColumn.OutputName == thisColumn.ColumnName)
                                    {
                                        aColumn.FieldType = strRawText;
                                        blFoundIt         = true;
                                        break;
                                    }
                                }
                                if (!blFoundIt)
                                {
                                    MessageBox.Show("The output column " + thisColumn.ColumnName + " was not found for map layer " + aLayer.LayerName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    loadedXML = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("The value for 'FieldType' for output column " + thisColumn.ColumnTag + " in the XML file is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            loadedXML = false;
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'ColumnType' for output column " + thisColumn.ColumnTag + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    try
                    {
                        int  a;
                        bool blResult = int.TryParse(aNode["ColumnLength"].InnerText, out a);
                        if (blResult)
                        {
                            thisColumn.ColumnLength = a;

                            // Now also add this length to the relevant output column in ALL the input layers.
                            foreach (MapLayer aLayer in inputLayers)
                            {
                                // Find the output column with the same name.
                                bool blFoundIt = false;
                                foreach (InputColumn aColumn in aLayer.InputColumns)
                                {
                                    if (aColumn.OutputName == thisColumn.ColumnName)
                                    {
                                        aColumn.FieldLength = a;
                                        blFoundIt           = true;
                                        break;
                                    }
                                }
                                if (!blFoundIt)
                                {
                                    MessageBox.Show("The output column " + thisColumn.ColumnName + " was not found for map layer " + aLayer.LayerName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    loadedXML = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Could not locate the item 'ColumnLength' for map layer " + thisColumn.ColumnTag + " in the XML file, or the item is not an integer", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            loadedXML = false;
                            return;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Could not locate the item 'ColumnLength' for map layer " + thisColumn.ColumnTag + " in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                        return;
                    }

                    if (loadedXML)
                    {
                        theOutputColumns.Add(thisColumn);
                    }
                }

                // Add the columns to the output layer definition
                outputLayer.OutputColumns = theOutputColumns;

                // Get the rest of the output layer definition
                try
                {
                    outputLayer.LayerPath = layerPath + @"\";
                    outputLayer.LayerFile = OutLayerDef["LayerFile"].InnerText;
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'LayerFile' for the OutLayer in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }

                try
                {
                    List <string> OutputFormatList = new List <string>()
                    {
                        "shape", "gdb"
                    };
                    strRawText = OutLayerDef["OutputFormat"].InnerText.ToLower();
                    if (OutputFormatList.Contains(strRawText))
                    {
                        outputLayer.Format = strRawText;
                    }
                    else
                    {
                        MessageBox.Show("The entry for the output layer's OutputFormat in the XML file is not valid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        loadedXML = false;
                    }
                }
                catch
                {
                    MessageBox.Show("Could not locate the item 'OutputFormat' for the OutLayer in the XML file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    loadedXML = false;
                    return;
                }
            }
            else
            {
                foundXML = false; // this has to be checked first; all other properties are empty.
            }
        }