private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";

            JSONArray layersArray = new JSONArray();

            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject    jo        = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddBoolean("addlayer", false);
                jo.AddString("description", layerInfo.Description);

                layersArray.AddJSONObject(jo);
            }

            JSONObject result = new JSONObject();

            result.AddJSONArray("layers", layersArray);
            return(Encoding.UTF8.GetBytes(result.ToJSONString(null)));
        }
        private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";

            JSONArray layersArray = new JSONArray();
            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject jo = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddBoolean("addlayer", false);
                jo.AddString("description", layerInfo.Description);
              
                layersArray.AddJSONObject(jo);
            }

            JSONObject result = new JSONObject();
            result.AddJSONArray("layers", layersArray);
            return Encoding.UTF8.GetBytes(result.ToJSONString(null));
        }
        private byte[] ProcessEditAreas(IServerObject serverObject, string versionName)
        {
            try
            {
                // Open utility network
                IDataset   unDataset = _soiUtil.GetUNDataset(serverObject, versionName);
                IWorkspace workspace = (IWorkspace)unDataset.Workspace;

                // Get all the dirty areas in the given validation area
                IBaseNetwork baseNetwork    = (IBaseNetwork)unDataset;
                ITable       dirtyAreaTable = baseNetwork.DirtyAreaTable;

                string shapeFieldName    = ((IFeatureClass)dirtyAreaTable).ShapeFieldName;
                int    areaFieldIndex    = dirtyAreaTable.FindField(shapeFieldName);
                int    creatorFieldIndex = dirtyAreaTable.FindField("CREATOR");

                // Get UN schema version
                IDatasetComponent dsComponent   = (IDatasetComponent)unDataset;
                IDEBaseNetwork    deBaseNetwork = (IDEBaseNetwork)dsComponent.DataElement;
                int unVersion = deBaseNetwork.SchemaGeneration;

                // Get inserts made to dirty areas table in the current version
                // For UN > V4, Errors are discarded (ERROCODE>0) to only retain true dirty areas
                // Note that changes made in the last edit session must be saved for this to work
                // as it is not possible to get the modifications until they have been saved.

                IVersionedTable versionedTable = (IVersionedTable)dirtyAreaTable;
                QueryFilter     qryFilter      = null;
                if (unVersion >= 4)
                {
                    qryFilter             = new QueryFilter();
                    qryFilter.WhereClause = _errorCodeFName + "=0";
                }

                IDifferenceCursor diffCursor = versionedTable.Differences(dirtyAreaTable, esriDifferenceType.esriDifferenceTypeInsert, qryFilter);

                // Loop through added rows to construct the modified zone extent
                int       editCount = 0;
                int       OID;
                IRow      diffRow;
                IEnvelope editZone = null;
                string    creator  = "";

                diffCursor.Next(out OID, out diffRow);

                // Return an error if no dirty areas found as it may be because the last edits were not saved
                if (diffRow == null)
                {
                    JSONObject responseJSON = new JSONObject();
                    responseJSON.AddBoolean("success", false);
                    JSONObject errorJSON = new JSONObject();
                    errorJSON.AddLong("extendedCode", (int)fdoError.FDO_E_DIRTY_AREA_BUILD_EXTENT_DO_NOT_INTERSECT);
                    errorJSON.AddString("message", "A dirty area is not present within the validate network topology input extent. A validate network topology process did not occur.");
                    JSONArray detailsJSON = new JSONArray();
                    detailsJSON.AddString("Make sure to save edits before validating.");
                    errorJSON.AddJSONArray("details", detailsJSON);
                    responseJSON.AddJSONObject("error", errorJSON);

                    return(Encoding.UTF8.GetBytes(responseJSON.ToJSONString(null)));
                }

                while (diffRow != null)
                {
                    editCount += 1;
                    creator    = diffRow.Value[creatorFieldIndex].ToString();
                    IGeometry rowShape = (IGeometry)diffRow.Value[areaFieldIndex];
                    IEnvelope rowArea  = rowShape.Envelope;
                    if (editZone != null)
                    {
                        editZone.Union(rowArea);
                    }
                    else
                    {
                        editZone = rowArea.Envelope;
                    }

                    diffCursor.Next(out OID, out diffRow);
                }
                diffCursor     = null;
                versionedTable = null;
                workspace      = null;

                // Add new or modify existing edit zone
                if (editZone != null)
                {
                    AddEditArea(serverObject, creator, versionName, editCount, editZone);
                }
            }
            catch (Exception e)
            {
                _serverLog.LogMessage(ServerLogger.msgType.infoStandard, _soiName + ".AddEditArea()",
                                      200, "Error while adding edit are: " + e.ToString());
            }

            return(null);
        }