示例#1
0
        public void RegisteringPlugInWithoutGuidThrowsError()
        {
            var manager = new PlugInManager();

            Assert.Throws <ArgumentException>(() => manager.RegisterPlugIn <IExamplePlugIn, ExamplePlugIn.NestedWithoutGuid>());
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatServerListener"/> class.
 /// </summary>
 /// <param name="endpoint">The endpoint.</param>
 /// <param name="plugInManager">The plug in manager.</param>
 public ChatServerListener(ChatServerEndpoint endpoint, PlugInManager plugInManager)
 {
     this.endpoint      = endpoint;
     this.plugInManager = plugInManager;
 }
示例#3
0
        static void Main(string[] args)
        {
            string source_connstr = "", source_fc = "";
            string dest_connstr = "", dest_fc = "";

            string[]         sourceFields = null, destFields = null;
            Guid             source_guid = Guid.Empty, dest_guid = Guid.Empty;
            bool             checkout            = false;
            string           checkoutDescription = String.Empty;
            string           child_rights        = "iud";
            string           parent_rights       = "iud";
            string           conflict_handling   = "normal";
            ISpatialIndexDef treeDef             = null;
            geometryType?    sourceGeometryType  = null;

            for (int i = 0; i < args.Length - 1; i++)
            {
                if (args[i] == "-source_connstr")
                {
                    source_connstr = args[++i];
                }

                else if (args[i] == "-source_guid")
                {
                    source_guid = new Guid(args[++i]);
                }

                else if (args[i] == "-source_fc")
                {
                    source_fc = args[++i];
                }

                else if (args[i] == "-dest_connstr")
                {
                    dest_connstr = args[++i];
                }

                else if (args[i] == "-dest_guid")
                {
                    dest_guid = new Guid(args[++i]);
                }

                else if (args[i] == "-dest_fc")
                {
                    dest_fc = args[++i];
                }

                else if (args[i] == "-sourcefields")
                {
                    sourceFields = args[++i].Split(';');
                }

                else if (args[i] == "-destfields")
                {
                    destFields = args[++i].Split(';');
                }

                else if (args[i] == "-checkout")
                {
                    checkout            = true;
                    checkoutDescription = args[++i];
                }
                else if (args[i] == "-source_geometrytype")
                {
                    geometryType geomType;
                    if (Enum.TryParse <geometryType>(args[++i], out geomType))
                    {
                        sourceGeometryType = geomType;
                        Console.WriteLine("Source geometry type: " + sourceGeometryType);
                    }
                }

                else if (args[i] == "-pr")
                {
                    parent_rights = args[++i];
                }
                else if (args[i] == "-cr")
                {
                    child_rights = args[++i];
                }
                else if (args[i] == "-ch")
                {
                    conflict_handling = args[++i];
                }

                //else if (args[i] == "-si")
                //{
                //    treeDef = BinaryTreeDef.FromString(args[++i]);
                //    if (treeDef == null)
                //    {
                //        Console.WriteLine("Invalid Spatial Index Def. " + args[i]);
                //    }
                //}
            }

            if (source_connstr == "" || source_fc == "" || source_guid == Guid.Empty ||
                dest_connstr == "" || dest_fc == "" || dest_guid == Guid.Empty)
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.CopyFeatureclass -source_connstr <Source Dataset Connection String>");
                Console.WriteLine("                           -source_guid <GUID of Dataset Extension>");
                Console.WriteLine("                           -source_fc <Featureclass name>");
                Console.WriteLine("                           -dest_connstr <Destination Dataset Connection String>");
                Console.WriteLine("                           -dest_guid <GUID of Dataset Extension>");
                Console.WriteLine("                           -dest_fc <Featureclass name>");
                Console.WriteLine("   when check out featureclass:");
                Console.WriteLine("                -checkout <Description> ... Write checkout information");
                Console.WriteLine("                -pr ... parent rights. <iud|iu|ud|...> (i..INSERT, u..UPDATE, d..DELETE)");
                Console.WriteLine("                -cr ... child rights.  <iud|iu|ud|...> (i..INSERT, u..UPDATE, d..DELETE)");
                Console.WriteLine("                -ch <none|normal|parent_wins|child_wins|newer_wins> ... conflict handling");
                Console.WriteLine("   optional:");
                Console.WriteLine("                -source_geometrytype <Point,Polyline,Polygon> ... if source geometrytype is not explizit specified (SQL Geometry)");
                return;
            }

            IFeatureDataset sourceDS, destDS;
            IFeatureClass   sourceFC;

            PlugInManager compMan = new PlugInManager();
            object        comp    = compMan.CreateInstance(source_guid);

            if (!(comp is IFeatureDataset))
            {
                Console.WriteLine("Component with GUID '" + source_guid.ToString() + "' is not a feature dataset...");
                return;
            }
            sourceDS = (IFeatureDataset)comp;
            sourceDS.ConnectionString = source_connstr;
            sourceDS.Open();
            sourceFC = GetFeatureclass(sourceDS, source_fc);
            if (sourceFC == null)
            {
                Console.WriteLine("Can't find featureclass '" + source_fc + "' in source dataset...");
                sourceDS.Dispose();
                return;
            }


            if (String.IsNullOrWhiteSpace(sourceFC.IDFieldName))
            {
                Console.WriteLine("WARNING: Souorce FeatureClass has no IDField -> Bad performance!!");
            }
            Console.WriteLine("Source FeatureClass: " + sourceFC.Name);
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Shape Field: " + sourceFC.ShapeFieldName);
            if (String.IsNullOrWhiteSpace(sourceFC.IDFieldName))
            {
                Console.WriteLine("WARNING: Souorce FeatureClass has no IDField -> Bad performance!!");
            }
            else
            {
                Console.WriteLine("Id Field   : " + sourceFC.IDFieldName);
            }

            Console.WriteLine();
            Console.WriteLine("Import: " + source_fc);
            Console.WriteLine("-----------------------------------------------------");

            FieldTranslation fieldTranslation = new FieldTranslation();

            if (sourceFields != null && destFields != null)
            {
                if (sourceFields.Length != destFields.Length)
                {
                    Console.WriteLine("Error in field definition...");
                    sourceDS.Dispose();
                    return;
                }
                for (int i = 0; i < sourceFields.Length; i++)
                {
                    IField field = sourceFC.FindField(sourceFields[i]);
                    if (field == null)
                    {
                        Console.WriteLine("Error: Can't find field '" + sourceFields[i] + "'...");
                        sourceDS.Dispose();
                        return;
                    }
                    fieldTranslation.Add(field, destFields[i]);
                }
            }
            else
            {
                foreach (IField field in sourceFC.Fields.ToEnumerable())
                {
                    if (field.type == FieldType.ID ||
                        field.type == FieldType.Shape)
                    {
                        continue;
                    }

                    fieldTranslation.Add(field, FieldTranslation.CheckName(field.name));
                }
            }


            comp = compMan.CreateInstance(dest_guid);

            if (comp is IFileFeatureDatabase)
            {
                IFileFeatureDatabase fileDB = (IFileFeatureDatabase)comp;
                if (!fileDB.Open(dest_connstr))
                {
                    Console.WriteLine("Error opening destination database:" + fileDB.lastErrorMsg);
                    return;
                }
                destDS = fileDB[dest_connstr];
            }
            else if (comp is IFeatureDataset)
            {
                destDS = (IFeatureDataset)comp;
                destDS.ConnectionString = dest_connstr;
                if (!destDS.Open())
                {
                    Console.WriteLine("Error opening destination dataset:" + destDS.lastErrorMsg);
                    return;
                }
            }
            else
            {
                Console.WriteLine("Component with GUID '" + dest_guid.ToString() + "' is not a feature dataset...");
                return;
            }

            string replIDField = String.Empty;

            if (checkout)
            {
                if (!(destDS.Database is IFeatureDatabaseReplication) ||
                    !(sourceDS.Database is IFeatureDatabaseReplication))
                {
                    Console.WriteLine("Can't checkout FROM/TO databasetype...");
                    return;
                }
                replIDField = Replication.FeatureClassReplicationIDFieldname(sourceFC);
                if (String.IsNullOrEmpty(replIDField))
                {
                    Console.WriteLine("Can't checkout from source featureclass. No replication ID!");
                    return;
                }
                IDatasetElement element = destDS[dest_fc];
                if (element != null)
                {
                    List <Guid> checkout_guids = Replication.FeatureClassSessions(element.Class as IFeatureClass);
                    if (checkout_guids != null && checkout_guids.Count != 0)
                    {
                        string errMsg = "Can't check out to this featureclass\n";
                        errMsg += "Check in the following Sessions first:\n";
                        foreach (Guid g in checkout_guids)
                        {
                            errMsg += "   CHECKOUT_GUID: " + g.ToString();
                        }
                        Console.WriteLine("ERROR:\n" + errMsg);
                        return;
                    }
                }
            }

            if (destDS.Database is IFeatureDatabase)
            {
                if (destDS.Database is AccessFDB)
                {
                    //Console.WriteLine();
                    //Console.WriteLine("Import: " + source_fc);
                    //Console.WriteLine("-----------------------------------------------------");


                    FDBImport import = new FDBImport(((IFeatureUpdater)destDS.Database).SuggestedInsertFeatureCountPerTransaction);
                    import.ReportAction   += new FDBImport.ReportActionEvent(import_ReportAction);
                    import.ReportProgress += new FDBImport.ReportProgressEvent(import_ReportProgress);

                    if (checkout)
                    {
                        if (sourceDS.Database is AccessFDB)
                        {
                            treeDef = ((AccessFDB)sourceDS.Database).FcSpatialIndexDef(source_fc);
                            if (destDS.Database is AccessFDB)
                            {
                                ISpatialIndexDef dsTreeDef = ((AccessFDB)destDS.Database).SpatialIndexDef(destDS.DatasetName);
                                if (treeDef.GeometryType != dsTreeDef.GeometryType)
                                {
                                    treeDef = dsTreeDef;
                                }
                            }
                        }
                    }

                    if (!import.ImportToNewFeatureclass((IFeatureDatabase)destDS.Database, destDS.DatasetName, dest_fc, sourceFC, fieldTranslation, true, null, treeDef,
                                                        sourceGeometryType: sourceGeometryType))
                    {
                        Console.WriteLine("ERROR: " + import.lastErrorMsg);
                    }
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Create: " + source_fc);
                    Console.WriteLine("-----------------------------------------------------");

                    FeatureImport import = new FeatureImport();

                    import.ReportAction   += new FeatureImport.ReportActionEvent(import_ReportAction2);
                    import.ReportProgress += new FeatureImport.ReportProgressEvent(import_ReportProgress2);

                    if (!import.ImportToNewFeatureclass(destDS, dest_fc, sourceFC, fieldTranslation, true,
                                                        sourceGeometryType: sourceGeometryType))
                    {
                        Console.WriteLine("ERROR: " + import.lastErrorMsg);
                    }
                }

                if (checkout)
                {
                    IDatasetElement element = destDS[dest_fc];
                    if (element == null)
                    {
                        Console.WriteLine("ERROR: Can't write checkout information...");
                        return;
                    }
                    IFeatureClass destFC = element.Class as IFeatureClass;

                    string errMsg;
                    if (!Replication.InsertReplicationIDFieldname(destFC, replIDField, out errMsg))
                    {
                        Console.WriteLine("ERROR: " + errMsg);
                        return;
                    }

                    Replication.VersionRights    cr = Replication.VersionRights.NONE;
                    Replication.VersionRights    pr = Replication.VersionRights.NONE;
                    Replication.ConflictHandling ch = Replication.ConflictHandling.NORMAL;

                    if (child_rights.ToLower().Contains("i"))
                    {
                        cr |= Replication.VersionRights.INSERT;
                    }
                    if (child_rights.ToLower().Contains("u"))
                    {
                        cr |= Replication.VersionRights.UPDATE;
                    }
                    if (child_rights.ToLower().Contains("d"))
                    {
                        cr |= Replication.VersionRights.DELETE;
                    }

                    if (parent_rights.ToLower().Contains("i"))
                    {
                        pr |= Replication.VersionRights.INSERT;
                    }
                    if (parent_rights.ToLower().Contains("u"))
                    {
                        pr |= Replication.VersionRights.UPDATE;
                    }
                    if (parent_rights.ToLower().Contains("d"))
                    {
                        pr |= Replication.VersionRights.DELETE;
                    }

                    switch (conflict_handling.ToLower())
                    {
                    case "none":
                        ch = Replication.ConflictHandling.NONE;
                        break;

                    case "normal":
                        ch = Replication.ConflictHandling.NORMAL;
                        break;

                    case "parent_wins":
                        ch = Replication.ConflictHandling.PARENT_WINS;
                        break;

                    case "child_wins":
                        ch = Replication.ConflictHandling.CHILD_WINS;
                        break;

                    case "newer_wins":
                        ch = Replication.ConflictHandling.NEWER_WINS;
                        break;
                    }

                    if (!Replication.InsertNewCheckoutSession(sourceFC,
                                                              pr,
                                                              destFC,
                                                              cr,
                                                              ch,
                                                              SystemInformation.Replace(checkoutDescription),
                                                              out errMsg))
                    {
                        Console.WriteLine("ERROR: " + errMsg);
                        return;
                    }

                    if (!Replication.InsertCheckoutLocks(sourceFC, destFC, out errMsg))
                    {
                        Console.WriteLine("ERROR: " + errMsg);
                        return;
                    }
                }
            }
            else
            {
                Console.WriteLine("Destination dataset has no feature database...");
                Console.WriteLine("Can't create featureclasses for this kind of dataset...");
            }
            sourceDS.Dispose();
            destDS.Dispose();
        }
示例#4
0
        private void btnScript_Click(object sender, EventArgs e)
        {
            if (_dataset == null || _sourceFC == null || _sourceFC.Dataset == null)
            {
                return;
            }

            Replication.VersionRights rights = Replication.VersionRights.NONE;

            if (chkINSERT.Checked)
            {
                rights |= Replication.VersionRights.INSERT;
            }
            if (chkUPDATE.Checked)
            {
                rights |= Replication.VersionRights.UPDATE;
            }
            if (chkDELETE.Checked)
            {
                rights |= Replication.VersionRights.DELETE;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Explort Script...";
            dlg.Filter = "BATCH File(*.bat)|*.bat";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("echo off\r\n");

                sb.Append("\"%GVIEW4_HOME%\\gView.Cmd.CopyFeatureclass\" -source_connstr \"" + _sourceFC.Dataset.ConnectionString + "\" -source_guid \"" + PlugInManager.PlugInID(_sourceFC.Dataset) + "\" -source_fc \"" + _sourceFC.Name + "\" ");
                sb.Append("-dest_connstr \"" + _dataset.ConnectionString + "\" -dest_guid \"" + PlugInManager.PlugInID(_dataset) + "\" -dest_fc \"" + txtTargetClass.Text + "\" ");
                sb.Append("-checkout \"" + txtCheckoutDescription.Text + "\" ");
                sb.Append("-pr iud -cr ");
                if (rights == Replication.VersionRights.NONE)
                {
                    sb.Append("x");
                }
                else
                {
                    if (Bit.Has(rights, Replication.VersionRights.INSERT))
                    {
                        sb.Append("i");
                    }
                    if (Bit.Has(rights, Replication.VersionRights.UPDATE))
                    {
                        sb.Append("u");
                    }
                    if (Bit.Has(rights, Replication.VersionRights.DELETE))
                    {
                        sb.Append("d");
                    }
                }
                sb.Append(" -ch ");
                if (radioNoConflict.Checked)
                {
                    sb.Append("none");
                }
                else if (radioNormalConflict.Checked)
                {
                    sb.Append("normal");
                }
                else if (radioParentWins.Checked)
                {
                    sb.Append("parent_wins");
                }
                else if (radioChildWins.Checked)
                {
                    sb.Append("child_wins");
                }
                else if (radioNewerWins.Checked)
                {
                    sb.Append("newer_wins");
                }

                sb.Append("\r\n");

                StreamWriter sw = new StreamWriter(dlg.FileName, false);
                if (!String2DOS(sw.BaseStream, sb.ToString()))
                {
                    MessageBox.Show("Warning: Can't find encoding codepage (ibm850)...");
                    sw.WriteLine(sb.ToString());
                }
                sw.Close();
            }
        }
示例#5
0
        public void RegisteringPlugInWithoutGuidThrowsError()
        {
            var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider());

            Assert.Throws <ArgumentException>(() => manager.RegisterPlugIn <IExamplePlugIn, ExamplePlugIn.NestedWithoutGuid>());
        }
示例#6
0
        static void Main(string[] args)
        {
            string gmlSource = String.Empty;
            string cacheSource = String.Empty;
            string cacheTarget = String.Empty;
            int    jpegQuality = -1, maxlevel = -1;

            for (int i = 0; i < args.Length - 1; i++)
            {
                if (args[i] == "-gml")
                {
                    gmlSource = args[++i];
                }
                if (args[i] == "-cache")
                {
                    cacheSource = args[++i];
                }
                else if (args[i] == "-target")
                {
                    cacheTarget = args[++i];
                }
                else if (args[i] == "-jpeg-qual")
                {
                    jpegQuality = int.Parse(args[++i]);
                }
                else if (args[i] == "-maxlevel")
                {
                    maxlevel = int.Parse(args[++i]);
                }
            }

            if (String.IsNullOrWhiteSpace(gmlSource) || String.IsNullOrWhiteSpace(cacheSource) || String.IsNullOrWhiteSpace(cacheTarget))
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.ClipCompactTilecache.exe -gml <Filename> -cache <cachedirectory> -target <cachetarget>");
                Console.WriteLine("                      [-jpeg-qual <quality  0..100>] -maxlevel <level>");
                return;
            }

            PlugInManager   compMan    = new PlugInManager();
            IFeatureDataset gmlDataset = compMan.CreateInstance(new Guid("dbabe7f1-fe46-4731-ab2b-8a324c60554e")) as IFeatureDataset;

            gmlDataset.ConnectionString = gmlSource;
            gmlDataset.Open();

            List <IPolygon> sourcePolygons = new List <IPolygon>();

            foreach (var element in gmlDataset.Elements)
            {
                if (element.Class is IFeatureClass)
                {
                    var fc = (IFeatureClass)element.Class;

                    using (var cursor = fc.GetFeatures(null))
                    {
                        IFeature feature;
                        while ((feature = cursor.NextFeature) != null)
                        {
                            if (feature.Shape is IPolygon)
                            {
                                sourcePolygons.Add((IPolygon)feature.Shape);
                            }
                        }
                    }
                }
            }

            Console.WriteLine(sourcePolygons.Count + " polygons found for clipping...");

            FileInfo configFile = new FileInfo(cacheSource + @"\conf.json");

            if (!configFile.Exists)
            {
                throw new ArgumentException("File " + configFile.FullName + " not exists");
            }

            #region Image Encoding Parameters

            System.Drawing.Imaging.ImageCodecInfo jpgEncoder = GetEncoder(System.Drawing.Imaging.ImageFormat.Jpeg);

            // Create an Encoder object based on the GUID
            // for the Quality parameter category.
            System.Drawing.Imaging.Encoder myEncoder =
                System.Drawing.Imaging.Encoder.Quality;

            // Create an EncoderParameters object.
            // An EncoderParameters object has an array of EncoderParameter
            // objects. In this case, there is only one
            // EncoderParameter object in the array.
            System.Drawing.Imaging.EncoderParameters myEncoderParameters = new System.Drawing.Imaging.EncoderParameters(1);

            #endregion


            CompactTileConfig cacheConfig = JsonConvert.DeserializeObject <CompactTileConfig>(File.ReadAllText(configFile.FullName));
            double            dpm         = cacheConfig.Dpi / 0.0254;

            foreach (var level in cacheConfig.Levels)
            {
                Console.WriteLine("Level: " + level.Level + " Scale=" + level.Scale);

                double resolution      = (level.Scale / dpm);
                double tileWorldWidth  = cacheConfig.TileSize[0] * resolution;
                double tileWorldHeight = cacheConfig.TileSize[1] * resolution;

                var scaleDirectory = new DirectoryInfo(cacheSource + @"\" + ((int)level.Scale).ToString());
                if (!scaleDirectory.Exists)
                {
                    continue;
                }

                foreach (var bundleFile in scaleDirectory.GetFiles("*.tilebundle"))
                {
                    var bundle = new Bundle(bundleFile.FullName);
                    if (!bundle.Index.Exists)
                    {
                        continue;
                    }

                    int    startRow = bundle.StartRow, startCol = bundle.StartCol;
                    double bundleWorldWidth = tileWorldWidth * 128D, bundleWorldHeight = tileWorldHeight * 128D;

                    IPoint bundleLowerLeft = new Point(cacheConfig.Origin[0] + startCol * tileWorldWidth,
                                                       cacheConfig.Origin[1] - startRow * tileWorldHeight - bundleWorldHeight);
                    IEnvelope bundleEnvelope = new Envelope(bundleLowerLeft, new Point(bundleLowerLeft.X + bundleWorldWidth, bundleLowerLeft.Y + bundleWorldHeight));

                    if (!Intersect(bundleEnvelope, sourcePolygons))
                    {
                        continue;
                    }

                    Console.WriteLine("Clip bundle: " + bundleFile.FullName);

                    var clippedBundleFile = new FileInfo(cacheTarget + @"\" + (int)level.Scale + @"\" + bundleFile.Name);
                    if (!clippedBundleFile.Directory.Exists)
                    {
                        clippedBundleFile.Directory.Create();
                    }
                    if (clippedBundleFile.Exists)
                    {
                        clippedBundleFile.Delete();
                    }

                    var indexBuilder   = new CompactTilesIndexBuilder();
                    int clippedTilePos = 0;

                    for (int r = 0; r < 128; r++)
                    {
                        for (int c = 0; c < 128; c++)
                        {
                            int tileLength;
                            int tilePos = bundle.Index.TilePosition(r, c, out tileLength);

                            if (tilePos >= 0 && tileLength >= 0)
                            {
                                IPoint tileLowerLeft = new Point(cacheConfig.Origin[0] + (startCol + c) * tileWorldWidth,
                                                                 cacheConfig.Origin[1] - (startRow + r + 1) * tileWorldHeight);
                                IEnvelope tileEnvelope = new Envelope(tileLowerLeft, new Point(tileLowerLeft.X + tileWorldWidth, tileLowerLeft.Y + tileWorldHeight));

                                if (!Intersect(tileEnvelope, sourcePolygons))
                                {
                                    continue;
                                }

                                Console.WriteLine("Append tile " + level.Level + "/" + (startRow + r) + "/" + (startCol + c));

                                byte[] data = bundle.ImageData(tilePos, tileLength);

                                if (jpegQuality > 0)
                                {
                                    #region New Jpeg Quality

                                    MemoryStream ms = new MemoryStream(data);
                                    using (System.Drawing.Image image = System.Drawing.Image.FromStream(ms))
                                    {
                                        MemoryStream outputMs = new MemoryStream();

                                        System.Drawing.Imaging.EncoderParameter myEncoderParameter = new System.Drawing.Imaging.EncoderParameter(myEncoder, Convert.ToInt64(jpegQuality));
                                        myEncoderParameters.Param[0] = myEncoderParameter;

                                        image.Save(outputMs, jpgEncoder, myEncoderParameters);
                                        data = outputMs.ToArray();
                                    }

                                    #endregion
                                }
                                using (var stream = new FileStream(clippedBundleFile.FullName, FileMode.Append))
                                {
                                    stream.Write(data, 0, data.Length);
                                }

                                indexBuilder.SetValue(r, c, clippedTilePos, data.Length);
                                clippedTilePos += data.Length;
                            }
                        }
                    }

                    if (clippedTilePos > 0)
                    {
                        indexBuilder.Save(clippedBundleFile.Directory.FullName + @"\" + new FileInfo(bundle.Index.Filename).Name);
                    }
                }

                if (maxlevel >= 0 && level.Level >= maxlevel)
                {
                    break;
                }
            }
        }
示例#7
0
        private void btnScript_Click(object sender, EventArgs e)
        {
            if (_childFc == null || _childFc.Dataset == null ||
                _parentFc == null || _parentFc.Dataset == null)
            {
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title  = "Explort Script...";
            dlg.Filter = "BATCH File(*.bat)|*.bat";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("echo off\r\n");

                sb.Append("\"%GVIEW4_HOME%\\checkin\" -source_connstr \"" + _childFc.Dataset.ConnectionString + "\" -source_guid \"" + PlugInManager.PlugInID(_childFc.Dataset) + "\" -source_fc \"" + _childFc.Name + "\" ");
                sb.Append("-dest_connstr \"" + _parentFc.Dataset.ConnectionString + "\" -dest_guid \"" + PlugInManager.PlugInID(_parentFc.Dataset) + "\" -dest_fc \"" + _parentFc.Name + "\"");
                if (radioReconcile.Checked == true)
                {
                    sb.Append(" -reconcile");
                }
                sb.Append("\r\n");

                StreamWriter sw = new StreamWriter(dlg.FileName, false);
                if (!String2DOS(sw.BaseStream, sb.ToString()))
                {
                    MessageBox.Show("Warning: Can't find encoding codepage (ibm850)...");
                    sw.WriteLine(sb.ToString());
                }
                sw.Close();
            }
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomTestPlugInContainer"/> class.
 /// </summary>
 /// <param name="manager">The plugin manager which manages this instance.</param>
 public CustomTestPlugInContainer(PlugInManager manager)
     : base(manager)
 {
     this.Initialize();
 }
示例#9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                // ArcGIS Server
                routes.MapRoute(
                    name: "arcgis_rest_exportmap",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/export",
                    defaults: new { controller = "ArcGis", Action = "ExportMap" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_query",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/{layerId}/query",
                    defaults: new { controller = "ArcGis", Action = "Query" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelayers",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/layers",
                    defaults: new { controller = "ArcGis", Action = "ServiceLayers" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelegend",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/legend",
                    defaults: new { controller = "ArcGis", Action = "Legend" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_servicelayer",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver/{layerId}",
                    defaults: new { controller = "ArcGis", Action = "ServiceLayer" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_service",
                    template: "arcgis/rest/services/{folder}/{id}/mapserver",
                    defaults: new { controller = "ArcGis", Action = "Service" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_folder",
                    template: "arcgis/rest/services/{id}",
                    defaults: new { controller = "ArcGis", Action = "Folder" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_services",
                    template: "arcgis/rest/services",
                    defaults: new { controller = "ArcGis", Action = "Services" }
                    );

                routes.MapRoute(
                    name: "arcgis_rest_featureserver_query",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/query",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerQuery" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_addfeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/addfeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerAddFeatures" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_updatefeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/updatefeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerUpdateFeatures" }
                    );
                routes.MapRoute(
                    name: "arcgis_rest_featureserver_deletefeatures",
                    template: "arcgis/rest/services/{folder}/{id}/featureserver/{layerId}/deletefeatures",
                    defaults: new { controller = "ArcGis", Action = "FeatureServerDeleteFeatures" }
                    );

                // Ogc
                routes.MapRoute(
                    name: "ogc_request",
                    template: "ogc/{id}",
                    defaults: new { controller = "Ogc", Action = "OgcRequest" }
                    );

                // ArcIMS
                routes.MapRoute(
                    name: "ags-servlet",
                    template: "servlet/com.esri.esrimap.Esrimap",
                    defaults: new { controller = "ArcIMS", Action = "Esrimap" }
                    );
                routes.MapRoute(
                    name: "ags-servlet2",
                    template: "arcims/servlet/com.esri.esrimap.Esrimap",
                    defaults: new { controller = "ArcIMS", Action = "Esrimap" }
                    );

                // MapServer
                routes.MapRoute(
                    name: "mapserver-catelog",
                    template: "catalog",
                    defaults: new { controller = "MapServer", Action = "Catalog" }
                    );
                routes.MapRoute(
                    name: "mapserver-maprequest",
                    template: "MapRequest/{guid}/{id}",
                    defaults: new { controller = "MapServer", Action = "MapRequest" }
                    );
                routes.MapRoute(
                    name: "mapserver-addmap",
                    template: "AddMap/{name}",
                    defaults: new { controller = "MapServer", Action = "AddMap" }
                    );
                routes.MapRoute(
                    name: "mapserver-remotemap",
                    template: "RemoveMap/{name}",
                    defaults: new { controller = "MapServer", Action = "RemoveMap" }
                    );
                routes.MapRoute(
                    name: "mapserver-getmetadata",
                    template: "GetMetadata/{name}",
                    defaults: new { controller = "MapServer", Action = "GetMetadata" }
                    );
                routes.MapRoute(
                    name: "mapserver-setmetadata",
                    template: "SetMetadata/{name}",
                    defaults: new { controller = "MapServer", Action = "SetMetadata" }
                    );

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            PlugInManager.Init();

            InternetMapServer.Init(env.ContentRootPath);
            //InternetMapServer.Init(@"C:\Development_OpenSource\GeoDaten\MXL\8050");
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogInOutGroup" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public LogInOutGroup(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(clientVersionProvider, manager, loggerFactory)
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatServer" /> class.
 /// </summary>
 /// <param name="settings">The settings.</param>
 /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <param name="plugInManager">The plug in manager.</param>
 public ChatServer(ChatServerSettings settings, IIpAddressResolver addressResolver, ILoggerFactory loggerFactory, PlugInManager plugInManager)
 {
     this.loggerFactory               = loggerFactory;
     this.logger                      = loggerFactory.CreateLogger <ChatServer>();
     this.settings                    = settings;
     this.addressResolver             = addressResolver;
     this.manager                     = new ChatRoomManager(loggerFactory);
     this.randomNumberGenerator       = RandomNumberGenerator.Create();
     this.clientCleanupTimer          = new Timer(this.settings.ClientCleanUpInterval.TotalMilliseconds);
     this.clientCleanupTimer.Elapsed += this.ClientCleanupInactiveClients;
     this.clientCleanupTimer.Start();
     this.roomCleanupTimer          = new Timer(this.settings.RoomCleanUpInterval.TotalMilliseconds);
     this.roomCleanupTimer.Elapsed += this.ClientCleanupUnusedRooms;
     this.roomCleanupTimer.Start();
     foreach (var endpoint in this.settings.Endpoints)
     {
         var listener = new ChatServerListener(endpoint, plugInManager, loggerFactory);
         listener.ClientAccepted  += this.ChatClientAccepted;
         listener.ClientAccepting += this.ChatClientAccepting;
         this.listeners.Add(listener);
     }
 }
示例#12
0
        static void Main(string[] args)
        {
            #region Parse Parameters
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-add":
                    if (job != jobs.unknown)
                    {
                        Console.WriteLine("Can't do more than one job. Run programm twice...");
                        return;
                    }
                    job = jobs.add;
                    break;

                case "-clean":
                    if (job != jobs.unknown)
                    {
                        Console.WriteLine("Can't do more than one job. Run programm twice...");
                        return;
                    }
                    job = jobs.removeUnexisting;
                    break;

                case "-truncate":
                    if (job != jobs.unknown)
                    {
                        Usage();
                        Console.WriteLine("Can't do more than one job. Run programm twice...");
                        return;
                    }
                    job = jobs.truncate;
                    break;

                case "-s":
                    connectinString = args[++i];
                    break;

                case "-db":
                    dbType = args[++i].ToLower();
                    break;

                case "-provider":
                    provider = args[++i].ToLower();
                    break;

                case "-fn":
                    if (rootPath != String.Empty)
                    {
                        Usage();
                        Console.WriteLine("Filename OR Rootdirectory...");
                        return;
                    }
                    fileName = args[++i];
                    break;

                case "-rd":
                    if (fileName != String.Empty)
                    {
                        Usage();
                        Console.WriteLine("Filename OR Rootdirectory...");
                        return;
                    }
                    rootPath = args[++i];
                    break;

                case "-f":
                    Filters = args[++i];
                    break;
                }
            }
            #endregion

            #region Check Parameters
            if (connectinString == String.Empty)
            {
                Usage();
                Console.WriteLine("No connection string...");
                return;
            }
            switch (job)
            {
            case jobs.removeUnexisting:
            case jobs.truncate:
                break;

            case jobs.add:
                if (fileName == String.Empty &&
                    (rootPath == String.Empty || Filters == String.Empty))
                {
                    Usage();
                    Console.WriteLine("No file or rootdirectory and filter defined...");
                    return;
                }
                break;

            case jobs.unknown:
                Usage();
                Console.WriteLine("No job defined...");
                return;
            }
            #endregion

            DateTime dt = DateTime.Now;

            string mdb     = ConfigTextStream.ExtractValue(connectinString, "mdb");
            string dsname  = ConfigTextStream.ExtractValue(connectinString, "dsname");
            string connStr = ConfigTextStream.RemoveValue(connectinString, "dsname");

            IFeatureDataset ds = null;
            if (mdb != String.Empty)
            {
                AccessFDB fdb = new AccessFDB();
                fdb.Open(connStr);
                IFeatureDataset dataset = fdb[dsname];
                if (dataset == null)
                {
                    Console.WriteLine("Error opening dataset: " + fdb.lastErrorMsg);
                    return;
                }
                //dataset.ConnectionString = connectinString;
                if (!dataset.Open())
                {
                    Console.WriteLine("Error opening dataset: " + dataset.lastErrorMsg);
                    return;
                }
                ds = dataset;
            }
            else if (dbType == "sql")
            {
                SqlFDB fdb = new SqlFDB();
                fdb.Open(connStr);
                IFeatureDataset dataset = fdb[dsname];
                if (dataset == null)
                {
                    Console.WriteLine("Error opening dataset: " + fdb.lastErrorMsg);
                    return;
                }
                //dataset.ConnectionString = connectinString;
                if (!dataset.Open())
                {
                    Console.WriteLine("Error opening dataset: " + dataset.lastErrorMsg);
                    return;
                }
                ds = dataset;
            }
            else if (dbType == "postgres")
            {
                pgFDB fdb = new pgFDB();
                fdb.Open(connStr);
                IFeatureDataset dataset = fdb[dsname];
                if (dataset == null)
                {
                    Console.WriteLine("Error opening dataset: " + fdb.lastErrorMsg);
                    return;
                }
                //dataset.ConnectionString = connectinString;
                if (!dataset.Open())
                {
                    Console.WriteLine("Error opening dataset: " + dataset.lastErrorMsg);
                    return;
                }
                ds = dataset;
            }
            else if (dbType == "sqlite")
            {
                SQLiteFDB fdb = new SQLiteFDB();
                fdb.Open(connStr);
                IFeatureDataset dataset = fdb[dsname];
                if (dataset == null)
                {
                    Console.WriteLine("Error opening dataset: " + fdb.lastErrorMsg);
                    return;
                }
                //dataset.ConnectionString = connectinString;
                if (!dataset.Open())
                {
                    Console.WriteLine("Error opening dataset: " + dataset.lastErrorMsg);
                    return;
                }
                ds = dataset;
            }

            IRasterFileDataset rds = null;
            if (provider == "gdal")
            {
                rds = PlugInManager.Create(new Guid("43DFABF1-3D19-438c-84DA-F8BA0B266592")) as IRasterFileDataset;
            }
            else if (provider == "raster")
            {
                rds = PlugInManager.Create(new Guid("D4812641-3F53-48eb-A66C-FC0203980C79")) as IRasterFileDataset;
            }

            Dictionary <string, Guid> providers = new Dictionary <string, Guid>();
            if (rds != null)
            {
                foreach (string format in rds.SupportedFileFilter.Split('|'))
                {
                    string extension = format;

                    int pos = format.LastIndexOf(".");
                    if (pos > 0)
                    {
                        extension = format.Substring(pos, format.Length - pos);
                    }

                    providers.Add(extension, PlugInManager.PlugInID(rds));
                    Console.WriteLine("Provider " + extension + ": " + rds.ToString() + " {" + PlugInManager.PlugInID(rds).ToString() + "}");
                }
            }
            if (providers.Count == 0)
            {
                providers = null;
            }

            switch (job)
            {
            case jobs.truncate:
                Truncate(ds, dsname + "_IMAGE_POLYGONS");
                break;

            case jobs.removeUnexisting:
                RemoveUnexisting(ds);
                CalculateExtent(ds);
                break;

            case jobs.add:
                if (fileName != String.Empty)
                {
                    if (!ImportFiles(ds, fileName.Split(';'), providers))
                    {
                        if (!continueOnError)
                        {
                            return;
                        }
                    }
                }
                else if (rootPath != String.Empty && Filters != String.Empty)
                {
                    if (!ImportDirectory(ds, new DirectoryInfo(rootPath), Filters.Split(';'), providers))
                    {
                        if (!continueOnError)
                        {
                            return;
                        }
                    }
                }
                CalculateExtent(ds);
                break;
            }
            Console.WriteLine("\n" + ((TimeSpan)(DateTime.Now - dt)).TotalSeconds + "s");
            Console.WriteLine("done...");
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VaultLockGroupPlugIn" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public VaultLockGroupPlugIn(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(clientVersionProvider, manager, loggerFactory)
 {
 }
示例#14
0
        static int Main(string[] args)
        {
            string source_connstr = "", source_fc = "";
            string dest_connstr = "", dest_fc = "";
            Guid   source_guid = Guid.Empty, dest_guid = Guid.Empty;
            bool   reconcile = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-source_connstr")
                {
                    source_connstr = args[++i];
                }

                else if (args[i] == "-source_guid")
                {
                    source_guid = new Guid(args[++i]);
                }

                else if (args[i] == "-source_fc")
                {
                    source_fc = args[++i];
                }

                else if (args[i] == "-dest_connstr")
                {
                    dest_connstr = args[++i];
                }

                else if (args[i] == "-dest_guid")
                {
                    dest_guid = new Guid(args[++i]);
                }

                else if (args[i] == "-dest_fc")
                {
                    dest_fc = args[++i];
                }

                else if (args[i] == "-reconcile")
                {
                    reconcile = true;
                }

                else if (args[i] == "-silent")
                {
                    _silent = true;
                }
            }

            if (source_connstr == "" || source_fc == "" || source_guid == Guid.Empty ||
                dest_connstr == "" || dest_fc == "" || dest_guid == Guid.Empty)
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.Checkin -source_connstr <Source Dataset Connection String>");
                Console.WriteLine("                  -source_guid <GUID of Dataset Extension>");
                Console.WriteLine("                  -source_fc <Featureclass name>");
                Console.WriteLine("                  -dest_connstr <Destination Dataset Connection String>");
                Console.WriteLine("                  -dest_guid <GUID of Dataset Extension>");
                Console.WriteLine("                  -dest_fc <Featureclass name>");
                Console.WriteLine("                  [-reconcile]");
                Console.WriteLine("                  [-silent]");
                return(1);
            }

            Console.WriteLine("\n" + source_fc + ":");

            PlugInManager   compMan  = new PlugInManager();
            IFeatureDataset sourceDS = compMan.CreateInstance(source_guid) as IFeatureDataset;

            if (sourceDS == null)
            {
                Console.WriteLine("ERROR: Component with GUID '" + source_guid.ToString() + "' not found...");
                return(1);
            }
            IFeatureDataset destDS = compMan.CreateInstance(dest_guid) as IFeatureDataset;

            if (destDS == null)
            {
                Console.WriteLine("ERROR: Component with GUID '" + dest_guid.ToString() + "' not found...");
                return(1);
            }

            sourceDS.ConnectionString = source_connstr;
            destDS.ConnectionString   = dest_connstr;
            if (!sourceDS.Open() || !(sourceDS.Database is IFeatureDatabaseReplication))
            {
                Console.WriteLine("ERROR: Component with GUID '" + source_guid.ToString() + "' is not a replicatable feature dataset...");
                return(1);
            }
            if (!destDS.Open() || !(destDS.Database is IFeatureDatabaseReplication))
            {
                Console.WriteLine("ERROR: Component with GUID '" + dest_guid.ToString() + "' is not a replicatable feature dataset...");
                return(1);
            }

            IDatasetElement sourceElement = sourceDS[source_fc];
            IDatasetElement destElement   = destDS[dest_fc];
            IFeatureClass   sourceFC      = ((sourceElement != null) ? sourceElement.Class as IFeatureClass : null);
            IFeatureClass   destFC        = ((destElement != null) ? destElement.Class as IFeatureClass : null);

            if (sourceFC == null)
            {
                Console.WriteLine("ERROR: Featureclass " + source_fc + " is not available...");
                return(1);
            }
            if (destFC == null)
            {
                Console.WriteLine("ERROR: Featureclass " + dest_fc + " is not available...");
                return(1);
            }

            string      errMsg = String.Empty;
            Replication repl   = new Replication();

            repl.CheckIn_ConflictDetected       += new Replication.CheckIn_ConflictDetectedEventHandler(repl_CheckIn_ConflictDetected);
            repl.CheckIn_FeatureDeleted         += new Replication.CheckIn_FeatureDeletedEventHandler(repl_CheckIn_FeatureDeleted);
            repl.CheckIn_FeatureInserted        += new Replication.CheckIn_FeatureInsertedEventHandler(repl_CheckIn_FeatureInserted);
            repl.CheckIn_FeatureUpdated         += new Replication.CheckIn_FeatureUpdatedEventHandler(repl_CheckIn_FeatureUpdated);
            repl.CheckIn_IgnoredSqlStatement    += new Replication.CheckIn_IgnoredSqlStatementEventHandler(repl_CheckIn_IgnoredSqlStatement);
            repl.CheckIn_BeginPost              += new Replication.CheckIn_BeginPostEventHandler(repl_CheckIn_BeginPost);
            repl.CheckIn_BeginCheckIn           += new Replication.CheckIn_BeginCheckInEventHandler(repl_CheckIn_BeginCheckIn);
            repl.CheckIn_ChangeSessionLockState += new Replication.CheckIn_ChangeSessionLockStateEventHandler(repl_CheckIn_ChangeSessionLockState);
            repl.CheckIn_Message += new Replication.CheckIn_MessageEventHandler(repl_CheckIn_Message);

            Replication.ProcessType type = (reconcile) ?
                                           Replication.ProcessType.Reconcile :
                                           Replication.ProcessType.CheckinAndRelease;

            if (!repl.Process(destFC, sourceFC, type, out errMsg))
            {
                Console.WriteLine();
                Console.WriteLine("ERROR :" + errMsg);
                Console.WriteLine();
            }
            else
            {
                if (!String.IsNullOrEmpty(_checkInResults))
                {
                    if (_silent)
                    {
                        Console.WriteLine(_checkInResults);
                    }
                    else
                    {
                        Console.WriteLine("\n" + _checkInResults);
                    }
                }

                if (reconcile)
                {
                    Console.WriteLine("Reconcile:\t" + _inserted + "\t" + _updated + "\t" + _deleted + "\t" + _conflicts);
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("\t\tINSERT\tUPDATE\tDELETE\tCONFLICTS");
                    Console.WriteLine("------------------------------------------------------------");
                    Console.WriteLine("Checkin  :\t" + _inserted + "\t" + _updated + "\t" + _deleted + "\t" + _conflicts);
                }
            }
            Console.WriteLine("------------------------------------------------------------");

            return(0);
        }
示例#15
0
        static int Main(string[] args)
        {
            string  connString = String.Empty, fcName = String.Empty, fields = String.Empty, name = String.Empty;
            Guid    dsGuid  = new Guid();
            Command command = Command.Unknown;

            for (int i = 0; i < args.Length - 1; i++)
            {
                if (args[i] == "-connstr")
                {
                    connString = args[++i];
                }

                else if (args[i] == "-guid")
                {
                    dsGuid = new Guid(args[++i]);
                }

                else if (args[i] == "-fc")
                {
                    fcName = args[++i];
                }

                else if (args[i] == "-fields")
                {
                    fields = args[++i];
                }

                else if (args[i] == "-name")
                {
                    name = args[++i];
                }

                else if (args[i] == "-c")
                {
                    switch (args[++i].ToLower())
                    {
                    case "createindex":
                        command = Command.CreateIndex;
                        break;

                    case "dropindex":
                        command = Command.DropIndex;
                        break;
                    }
                }
            }

            if (String.IsNullOrWhiteSpace(connString) || dsGuid.Equals(new Guid()) ||
                command == Command.Unknown)
            {
                Console.WriteLine("USAGE:");
                Console.WriteLine("gView.Cmd.Fdb -connstr <ConnectionString> -guid <DatasetGuid>");
                Console.WriteLine("              -c <CreateIndex|DropIndex>");
                return(1);
            }

            IFeatureDataset dataset;

            PlugInManager compMan = new PlugInManager();
            object        comp    = compMan.CreateInstance(dsGuid);

            if (!(comp is IFeatureDataset))
            {
                Console.WriteLine("Component with GUID '" + dsGuid.ToString() + "' is not a feature dataset...");
                return(1);
            }

            dataset = (IFeatureDataset)comp;

            if (!(dataset.Database is AccessFDB))
            {
                Console.WriteLine("Component dataset is not a gView Feature-Database...");
                return(1);
            }

            AccessFDB fdb = (AccessFDB)dataset.Database;

            if (!fdb.Open(connString))
            {
                Console.WriteLine("Can't open database");
                return(1);
            }

            if (command == Command.CreateIndex)
            {
                #region Create Index

                if (String.IsNullOrEmpty(fcName) || String.IsNullOrEmpty(fields))
                {
                    Console.WriteLine("USAGE:");
                    Console.WriteLine("gView.Cmd.Fdb -connstr <ConnectionString> -guid <DatasetGuid>");
                    Console.WriteLine("              -c <CreateIndex>");
                    Console.WriteLine("              -fc <FeatureClassName> -fields <Fields>");
                    return(1);
                }

                string indexName = "IDX_FC_" + fcName + "_" + fields.Replace(",", "_").Replace(" ", "");
                try
                {
                    Console.WriteLine("Try drop index...");
                    fdb.DropIndex(indexName);
                }
                catch { }

                Console.WriteLine("Try create index...");
                if (!fdb.CreateIndex(indexName,
                                     "FC_" + fcName, fields, false))
                {
                    Console.WriteLine("ERROR:");
                    Console.WriteLine(fdb.lastErrorMsg);
                    return(1);
                }

                Console.WriteLine("Index created...");
                return(0);

                #endregion
            }
            else if (command == Command.DropIndex)
            {
                #region Drop Index

                if (String.IsNullOrEmpty(name))
                {
                    Console.WriteLine("USAGE:");
                    Console.WriteLine("gView.Cmd.Fdb -connstr <ConnectionString> -guid <DatasetGuid>");
                    Console.WriteLine("              -c <DropIndex>");
                    Console.WriteLine("              -name <IndexName>");
                    return(1);
                }

                Console.WriteLine("Try drop index...");
                if (!fdb.DropIndex(name))
                {
                    Console.WriteLine("ERROR:");
                    Console.WriteLine(fdb.lastErrorMsg);
                    return(1);
                }

                Console.WriteLine("Index dropped...");
                return(0);

                #endregion
            }

            return(0);
        }
示例#16
0
        private void gridFcs_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || lstWeights.SelectedItems.Count != 1)
            {
                return;
            }

            IGraphWeight weight = ((WeightListViewItem)lstWeights.SelectedItems[0]).GraphWeight;
            int          fcId   = Convert.ToInt32(gridFcs.Rows[e.RowIndex].Cells[0].Value);

            string fieldName = (string)((DataGridViewComboBoxCell)gridFcs.Rows[e.RowIndex].Cells[2]).Value;
            IGraphWeightFeatureClass gwfc = weight.FeatureClasses[fcId];

            if (gwfc == null)
            {
                gwfc = new GraphWeightFeatureClass(fcId, fieldName);
                weight.FeatureClasses[fcId] = gwfc;
            }
            if (e.ColumnIndex == 2)
            {
                if (fieldName == null || fieldName == "<none>")
                {
                    ((GraphWeightFeatureClass)gwfc).FieldName = String.Empty;
                }
                else
                {
                    ((GraphWeightFeatureClass)gwfc).FieldName = fieldName;
                }
            }
            if (e.ColumnIndex == 3)
            {
                if (gwfc.SimpleNumberCalculation != null &&
                    gwfc.SimpleNumberCalculation.Name == gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString())
                {
                }
                else
                {
                    if (gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString() == "<none>")
                    {
                        ((GraphWeightFeatureClass)gwfc).SimpleNumberCalculation = null;
                    }
                    foreach (ISimpleNumberCalculation calc in _calculators)
                    {
                        if (calc.Name == gridFcs.Rows[e.RowIndex].Cells[3].Value.ToString())
                        {
                            PlugInManager pMan = new PlugInManager();
                            ((GraphWeightFeatureClass)gwfc).SimpleNumberCalculation = pMan.CreateInstance(PlugInManager.PlugInID(calc)) as ISimpleNumberCalculation;
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterGroupHandlerPlugIn" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public CharacterGroupHandlerPlugIn(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(clientVersionProvider, manager, loggerFactory)
 {
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainPacketHandlerPlugInContainer"/> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version.</param>
 /// <param name="manager">The manager.</param>
 public MainPacketHandlerPlugInContainer(IClientVersionProvider clientVersionProvider, PlugInManager manager)
     : base(clientVersionProvider, manager)
 {
 }
示例#19
0
        async public Task Run(string[] args)
        {
            string inFile  = String.Empty;
            string outFile = String.Empty;
            string targetConnectionString        = String.Empty;
            IEnumerable <string> dontCopyFeatues = null;
            Guid targetGuid = new Guid();

            for (int i = 1; i < args.Length - 1; i++)
            {
                switch (args[i].ToLower())
                {
                case "-mxl":
                    inFile = args[++i];
                    break;

                case "-target-connectionstring":
                    targetConnectionString = args[++i];
                    break;

                case "-target-guid":
                    var guid = args[++i];
                    switch (guid.ToLower())
                    {
                    case "sqlserver":
                        targetGuid = new Guid("3B870AB5-8BE0-4a00-911D-ECC6C83DD6B4");
                        break;

                    case "postgres":
                        targetGuid = new Guid("33254063-133D-4b17-AAE2-46AF7A7DA733");
                        break;

                    case "sqlite":
                        targetGuid = new Guid("36DEB6AC-EA0C-4B37-91F1-B2E397351555");
                        break;

                    default:
                        targetGuid = new Guid(guid);
                        break;
                    }
                    break;

                case "-out-mxl":
                    outFile = args[++i];
                    break;

                case "-dont-copy-features-from":
                    dontCopyFeatues = args[++i].Split(',').Select(n => n.Trim().ToLower());
                    break;
                }
            }

            if (String.IsNullOrEmpty(inFile) ||
                String.IsNullOrEmpty(targetConnectionString) ||
                targetGuid.Equals(new Guid()))
            {
                throw new IncompleteArgumentsException();
            }

            if (String.IsNullOrEmpty(outFile))
            {
                outFile = String.IsNullOrEmpty(inFile) ? String.Empty : inFile.Substring(0, inFile.LastIndexOf(".")) + "_fdb.mxl";
            }

            XmlStream stream = new XmlStream("");

            stream.ReadStream(inFile);

            MxlDocument doc = new MxlDocument();
            await stream.LoadAsync("MapDocument", doc);

            var pluginManager = new PlugInManager();

            #region Destination Dataset

            IFeatureDataset targetFeatureDataset = pluginManager.CreateInstance(targetGuid) as IFeatureDataset;
            if (targetFeatureDataset == null)
            {
                throw new Exception("Plugin with GUID '" + targetGuid.ToString() + "' is not a feature dataset...");
            }
            await targetFeatureDataset.SetConnectionString(targetConnectionString);

            await targetFeatureDataset.Open();

            var targetDatabase = (IFDBDatabase)targetFeatureDataset.Database;

            #endregion Destination Dataset

            var map = doc.Maps.FirstOrDefault() as Map;

            var featureLayers = map.TOC.Layers.Where(l => l is IFeatureLayer)
                                .Select(l => (IFeatureLayer)l);

            if (map.Datasets != null)
            {
                int datasetId = 0;
                foreach (var dataset in map.Datasets.ToArray())
                {
                    Console.WriteLine();
                    Console.WriteLine($"Dataset: { dataset.DatasetName }");
                    Console.WriteLine($"         { dataset.GetType() }");
                    Console.WriteLine("-------------------------------------------------------");

                    foreach (var dsElement in map.MapElements.Where(e => e.DatasetID == datasetId))
                    {
                        if (dsElement?.Class == null)
                        {
                            continue;
                        }

                        var featureLayer = featureLayers.Where(l => l.DatasetID == datasetId && l.Class == dsElement.Class)
                                           .FirstOrDefault();

                        if (featureLayer == null)
                        {
                            continue;
                        }

                        Console.WriteLine();
                        Console.WriteLine($"FeatureLayer: { featureLayer.Title }");
                        Console.WriteLine($"       Class: { dsElement.Class.Name }");
                        Console.WriteLine($"              { dsElement.Class.GetType() }");
                        Console.WriteLine();

                        var sourceFc = dsElement.Class as IFeatureClass;
                        if (sourceFc == null)
                        {
                            Console.WriteLine("Class is not a FeatureClass");
                            continue;
                        }

                        #region Create Target Featureclass (if not exists)

                        string targetFcName = dsElement.Class.Name;
                        if (targetFcName.Contains("."))
                        {
                            targetFcName = targetFcName.Substring(targetFcName.LastIndexOf(".") + 1);
                        }

                        var targetFc = (await targetFeatureDataset.Element(targetFcName))?.Class as IFeatureClass;

                        if (targetFc != null)
                        {
                            var count = await targetFc.CountFeatures();

                            if (count > 0)
                            {
                                Console.Write($"Already exists in target fdb ({ count } features)");
                            }
                            else
                            {
                                if (!await targetDatabase.DeleteFeatureClass(targetFcName))
                                {
                                    throw new Exception($"Can't delete existing (empty) featureclass { targetFcName }");
                                }
                            }
                        }
                        else
                        {
                            var fcId = await targetDatabase.CreateFeatureClass(
                                targetFeatureDataset.DatasetName,
                                targetFcName,
                                new GeometryDef()
                            {
                                GeometryType     = sourceFc.GeometryType,
                                HasM             = sourceFc.HasM,
                                HasZ             = sourceFc.HasZ,
                                SpatialReference = sourceFc.SpatialReference
                            },
                                new Fields(sourceFc.Fields.ToEnumerable().Select(f =>
                            {
                                if (f != null && f.type == FieldType.ID && f.name.ToUpper().Equals("FDB_OID") == false)      // also include original ID Column
                                {
                                    return(new Field(f.name, FieldType.integer));
                                }
                                return(f);
                            })));

                            if (fcId <= 0)
                            {
                                throw new Exception($"Can't create featureclass { targetFcName }: { targetDatabase.LastErrorMessage }");
                            }

                            targetFc = (await targetFeatureDataset.Element(targetFcName)).Class as IFeatureClass;
                            if (targetFc == null)
                            {
                                throw new Exception($"Can't load target FeatureClass { targetFcName }");
                            }

                            var copyFeatures = dontCopyFeatues == null ||
                                               (!dontCopyFeatues.Contains(sourceFc.Name.ToLower()) && !dontCopyFeatues.Contains(targetFc.Name.ToLower()));

                            if (copyFeatures)
                            {
                                var sIndexDef = new gViewSpatialIndexDef(null, 62);

                                var tree2 = await SpatialIndex2(
                                    targetDatabase,
                                    sourceFc,
                                    sIndexDef);

                                tree2.Trim();

                                List <long> nids = new List <long>();
                                foreach (BinaryTree2BuilderNode node in tree2.Nodes)
                                {
                                    nids.Add(node.Number);
                                }
                                await((AccessFDB)targetDatabase).ShrinkSpatialIndex(targetFcName, nids);
                                await((AccessFDB)targetDatabase).SetSpatialIndexBounds(targetFcName, "BinaryTree2", tree2.Bounds, tree2.SplitRatio, tree2.MaxPerNode, tree2.maxLevels);
                                await((AccessFDB)targetDatabase).SetFeatureclassExtent(targetFcName, tree2.Bounds);

                                #endregion Create Target Featureclass (if not exists)

                                var      featureBag = new List <IFeature>();
                                IFeature feature    = null;
                                int      counter    = 0;

                                Console.WriteLine("Copy features:");

                                if (sourceFc is IFeatureClassPerformanceInfo && ((IFeatureClassPerformanceInfo)sourceFc).SupportsHighperformanceOidQueries == false)
                                {
                                    using (var memoryFeatureBag = new FeatureBag())
                                    {
                                        #region Read all Features to FeatureBag (Memory)

                                        //
                                        //  eg. SDE Multiversion Views are very slow, queiried win OID Filter!!
                                        //
                                        Console.WriteLine("Source feature class do not support high performance oid quries!");

                                        QueryFilter filter = new QueryFilter()
                                        {
                                            WhereClause = "1=1"
                                        };
                                        filter.AddField("*");

                                        Console.WriteLine("Read all features to memory feature bag...");

                                        using (var featureCursor = await sourceFc.GetFeatures(filter))
                                        {
                                            if (featureCursor == null)
                                            {
                                                throw new Exception($"Can't query features from soure featureclass: { (sourceFc is IDebugging ? ((IDebugging)sourceFc).LastException?.Message : "") }");
                                            }

                                            while ((feature = await featureCursor.NextFeature()) != null)
                                            {
                                                memoryFeatureBag.AddFeature(feature);
                                                counter++;

                                                if (counter % 10000 == 0)
                                                {
                                                    Console.Write($"...{ counter }");
                                                }
                                            }
                                        }

                                        #endregion Read all Features to FeatureBag (Memory)

                                        #region Write to target featureclass

                                        Console.WriteLine($"...{ counter }");
                                        Console.WriteLine("copy feature to target feature class");
                                        counter = 0;

                                        foreach (BinaryTree2BuilderNode node in tree2.Nodes)
                                        {
                                            foreach (var memoryFeature in memoryFeatureBag.GetFeatures(node.OIDs))
                                            {
                                                memoryFeature.Fields.Add(new FieldValue("$FDB_NID", node.Number));
                                                featureBag.Add(memoryFeature);
                                                counter++;

                                                if (counter % 10000 == 0)
                                                {
                                                    await Store(targetDatabase, targetFc, featureBag, counter);
                                                }
                                            }
                                        }

                                        #endregion Write to target featureclass
                                    }

                                    GC.Collect();
                                }
                                else
                                {
                                    #region Query all per Oid and Node

                                    foreach (BinaryTree2BuilderNode node in tree2.Nodes)
                                    {
                                        RowIDFilter filter = new RowIDFilter(sourceFc.IDFieldName);
                                        filter.IDs       = node.OIDs;
                                        filter.SubFields = "*";

                                        using (var featureCursor = await sourceFc.GetFeatures(filter))
                                        {
                                            if (featureCursor == null)
                                            {
                                                throw new Exception($"Can't query features from soure featureclass: { (sourceFc is IDebugging ? ((IDebugging)sourceFc).LastException?.Message : "") }");
                                            }

                                            while ((feature = await featureCursor.NextFeature()) != null)
                                            {
                                                feature.Fields.Add(new FieldValue("$FDB_NID", node.Number));
                                                featureBag.Add(feature);
                                                counter++;

                                                if (counter % 10000 == 0)
                                                {
                                                    await Store(targetDatabase, targetFc, featureBag, counter);
                                                }
                                            }
                                        }
                                    }

                                    #endregion Query all per Oid and Node
                                }
                                await Store(targetDatabase, targetFc, featureBag, counter);

                                await((AccessFDB)targetDatabase).CalculateExtent(targetFcName);
                            }
                        }

                        dsElement.Title = targetFc.Name;
                        ((DatasetElement)dsElement).Class = targetFc;
                    }

                    ((MapPersist)map).SetDataset(datasetId, targetFeatureDataset);
                    datasetId++;
                }
            }

            map.Compress();

            stream = new XmlStream("");
            stream.Save("MapDocument", doc);

            Console.WriteLine($"Write: { outFile }");
            stream.WriteStream(outFile);
            Console.WriteLine("succeeded...");
        }
示例#20
0
        static int Main(string[] args)
        {
            string cmd = "fill", jsonFile = (args.Length == 1 && args[0] != "fill" ? args[0] : String.Empty), indexUrl = String.Empty, indexName = String.Empty, category = String.Empty;
            bool   replace = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "fill" && i < args.Length - 1)
                {
                    cmd      = "fill";
                    jsonFile = args[i + 1];
                    i++;
                }
                if (args[i] == "remove-category")
                {
                    cmd = "remove-category";
                }
                if (args[i] == "-s" && i < args.Length - 1)
                {
                    indexUrl = args[i + 1];
                }

                if (args[i] == "-i" && i < args.Length - 1)
                {
                    indexName = args[i + 1];
                }

                if (args[i] == "-c" && i < args.Length - 1)
                {
                    category = args[i + 1];
                }

                if (args[i] == "-r")
                {
                    replace = true;
                }
            }

            if (args.Length == 0)
            {
                Console.WriteLine("Usage: gView.Cmd.ElasticSearch fill|remove-catetory [Options]");
                return(1);
            }

            if (cmd == "fill" && String.IsNullOrEmpty(jsonFile))
            {
                Console.WriteLine("Usage: gView.Cmd.ElasticSearch fill {json-file}");
                return(1);
            }
            else if (cmd == "remove-category" && (String.IsNullOrWhiteSpace(indexUrl) || String.IsNullOrWhiteSpace(category)))
            {
                Console.WriteLine("Usage: gView.cmd.ElasticSearch remove-category -s {index-url} -i {index-name} -c {category} [-r]");
                Console.WriteLine("  -r ... raplace german Umlaute:");
                Console.WriteLine("            _ae_, _oe_, _ue_   =>  ä, ö, ü");
                Console.WriteLine("            _Ae_, _Oe_, _Ue_   =>  Ä, Ö, Ü");
                Console.WriteLine("            _sz_               =>  ß");
                return(1);
            }

            try
            {
                //gView.Framework.system.SystemVariables.CustomApplicationDirectory =
                //    System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

                Console.WriteLine("Environment");

                Console.WriteLine("Working Directory: " + gView.Framework.system.SystemVariables.StartupDirectory);
                Console.WriteLine("64Bit=" + gView.Framework.system.Wow.Is64BitProcess);

                if (cmd == "fill")
                {
                    #region Fill Index (with Json File)

                    var importConfig = JsonConvert.DeserializeObject <ImportConfig>(File.ReadAllText(jsonFile));

                    var searchContext = new ElasticSearchContext(importConfig.Connection.Url, importConfig.Connection.DefaultIndex);

                    if (importConfig.Connection.DeleteIndex)
                    {
                        searchContext.DeleteIndex();
                    }

                    searchContext.CreateIndex();
                    searchContext.Map <Item>();
                    searchContext.Map <Meta>();

                    ISpatialReference sRefTarget = SpatialReference.FromID("epsg:4326");

                    Console.WriteLine("Target Spatial Reference: " + sRefTarget.Name + " " + String.Join(" ", sRefTarget.Parameters));

                    foreach (var datasetConfig in importConfig.Datasets)
                    {
                        if (datasetConfig.FeatureClasses == null)
                        {
                            continue;
                        }

                        IDataset dataset = new PlugInManager().CreateInstance(datasetConfig.DatasetGuid) as IDataset;
                        if (dataset == null)
                        {
                            throw new ArgumentException("Can't load dataset with guid " + datasetConfig.DatasetGuid.ToString());
                        }

                        dataset.ConnectionString = datasetConfig.ConnectionString;
                        dataset.Open();

                        foreach (var featureClassConfig in datasetConfig.FeatureClasses)
                        {
                            var itemProto = featureClassConfig.IndexItemProto;
                            if (itemProto == null)
                            {
                                continue;
                            }

                            string metaId = Guid.NewGuid().ToString("N").ToLower();
                            category = featureClassConfig.Category;
                            if (!String.IsNullOrWhiteSpace(category))
                            {
                                var meta = new Meta()
                                {
                                    Id         = metaId,
                                    Category   = category,
                                    Descrption = featureClassConfig.Meta?.Descrption,
                                    Sample     = featureClassConfig?.Meta.Sample,
                                    Service    = featureClassConfig?.Meta.Service,
                                    Query      = featureClassConfig?.Meta.Query
                                };
                                searchContext.Index <Meta>(meta);
                            }

                            bool useGeometry = featureClassConfig.UserGeometry;

                            IDatasetElement dsElement = dataset[featureClassConfig.Name];
                            if (dsElement == null)
                            {
                                throw new ArgumentException("Unknown dataset element " + featureClassConfig.Name);
                            }

                            IFeatureClass fc = dsElement.Class as IFeatureClass;
                            if (fc == null)
                            {
                                throw new ArgumentException("Dataobject is not a featureclass " + featureClassConfig.Name);
                            }

                            Console.WriteLine("Index " + fc.Name);
                            Console.WriteLine("=====================================================================");

                            QueryFilter filter = new QueryFilter();
                            filter.SubFields = "*";
                            if (!String.IsNullOrWhiteSpace(featureClassConfig.Filter))
                            {
                                filter.WhereClause = featureClassConfig.Filter;
                                Console.WriteLine("Filter: " + featureClassConfig.Filter);
                            }

                            List <Item> items = new List <Item>();
                            int         count = 0;

                            ISpatialReference sRef = fc.SpatialReference ?? SpatialReference.FromID("epsg:" + featureClassConfig.SRefId);
                            Console.WriteLine("Source Spatial Reference: " + sRef.Name + " " + String.Join(" ", sRef.Parameters));
                            Console.WriteLine("IDField: " + fc.IDFieldName);

                            using (GeometricTransformer transformer = new GeometricTransformer())
                            {
                                if (useGeometry)
                                {
                                    transformer.SetSpatialReferences(sRef, sRefTarget);
                                }

                                IFeatureCursor cursor = fc.GetFeatures(filter);
                                IFeature       feature;
                                while ((feature = cursor.NextFeature) != null)
                                {
                                    var indexItem = ParseFeature(metaId, category, feature, itemProto, useGeometry, transformer, featureClassConfig);
                                    items.Add(indexItem);
                                    count++;

                                    if (items.Count >= 500)
                                    {
                                        searchContext.IndexMany <Item>(items.ToArray());
                                        items.Clear();

                                        Console.Write(count + "...");
                                    }
                                }

                                if (items.Count > 0)
                                {
                                    searchContext.IndexMany <Item>(items.ToArray());
                                    Console.WriteLine(count + "...finish");
                                }
                            }
                        }
                    }

                    #endregion
                }
                else if (cmd == "remove-category")
                {
                    #region Remove Category

                    RemoveCategory(indexUrl, indexName, replace ? Replace(category) : category);

                    #endregion
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                return(1);
            }
        }
示例#21
0
        public bool Open()
        {
            try
            {
                _state = DatasetState.unknown;
                _elements.Clear();

                FileInfo fi_gml = new FileInfo(_connectionString);
                if (!fi_gml.Exists)
                {
                    return(false);
                }
                FileInfo fi_xsd = new FileInfo(fi_gml.FullName.Substring(0, fi_gml.FullName.Length - fi_gml.Extension.Length) + ".xsd");
                if (!fi_xsd.Exists)
                {
                    return(false);
                }

                _gml_file = fi_gml.FullName;
                _xsd_file = fi_xsd.FullName;

                XmlDocument schema = new XmlDocument();
                schema.Load(System.IO.File.ReadAllText(fi_xsd.FullName));
                XmlSchemaReader schemaReader    = new XmlSchemaReader(schema);
                string          targetNamespace = schemaReader.TargetNamespaceURI;
                if (targetNamespace == String.Empty)
                {
                    return(false);
                }

                PlugInManager compMan = new PlugInManager();
                foreach (string elementName in schemaReader.ElementNames)
                {
                    string       shapeFieldName;
                    geometryType geomType;
                    Fields       fields = schemaReader.ElementFields(elementName, out shapeFieldName, out geomType);
                    FeatureClass fc     = new FeatureClass(this, elementName, fields);
                    fc.ShapeFieldName = shapeFieldName;
                    fc.GeometryType   = geomType;
                    IFeatureLayer layer = LayerFactory.Create(fc) as IFeatureLayer;
                    if (layer == null)
                    {
                        continue;
                    }

                    //layer.FeatureRenderer = compMan.getComponent(KnownObjects.Carto_UniversalGeometryRenderer) as IFeatureRenderer;

                    _elements.Add(layer);
                }

                _doc = new XmlDocument();

                using (XmlTextReader xmlTextReader = new XmlTextReader(fi_gml.FullName))
                {
                    xmlTextReader.ReadToDescendant("boundedBy", "http://www.opengis.net/gml");
                    string boundedBy = xmlTextReader.ReadOuterXml();
                    _doc.LoadXml(boundedBy);
                }

                _ns = new XmlNamespaceManager(_doc.NameTable);
                _ns.AddNamespace("GML", "http://www.opengis.net/gml");
                _ns.AddNamespace("WFS", "http://www.opengis.net/wfs");
                _ns.AddNamespace("OGC", "http://www.opengis.net/ogc");
                _ns.AddNamespace("myns", targetNamespace);
                XmlNode boundedByNode = _doc.ChildNodes[0];

                if (boundedByNode != null)
                {
                    XmlNode geomNode = boundedByNode.SelectSingleNode("GML:*", _ns);
                    if (geomNode != null)
                    {
                        _envelope = GeometryTranslator.GML2Geometry(geomNode.OuterXml, _gmlVersion) as IEnvelope;
                        if (geomNode.Attributes["srsName"] != null)
                        {
                            _sRef = gView.Framework.Geometry.SpatialReference.FromID(geomNode.Attributes["srsName"].Value);
                        }
                    }
                }

                _state = DatasetState.opened;
                return(true);
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                return(false);
            }
        }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketHandlerPlugInContainer{THandler}"/> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 public PacketHandlerPlugInContainer(IClientVersionProvider clientVersionProvider, PlugInManager manager)
     : base(manager)
 {
     this.clientVersionProvider = clientVersionProvider;
     this.clientVersionProvider.ClientVersionChanged += this.OnClientVersionChanged;
 }
示例#23
0
        public void DeactivatingUnknownPlugInDoesNotThrowError()
        {
            var manager = new PlugInManager(null, new NullLoggerFactory(), this.CreateServiceProvider());

            manager.ActivatePlugIn(new Guid("4C38A813-F9BF-428A-8EA1-A6C90A87E583"));
        }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainPacketHandlerPlugInContainer" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public MainPacketHandlerPlugInContainer(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(clientVersionProvider, manager, loggerFactory)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GroupPacketHandlerPlugIn" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 protected GroupPacketHandlerPlugIn(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(clientVersionProvider, manager, loggerFactory)
 {
 }
示例#26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChatServerListener" /> class.
 /// </summary>
 /// <param name="endpoint">The endpoint.</param>
 /// <param name="plugInManager">The plug in manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public ChatServerListener(ChatServerEndpoint endpoint, PlugInManager plugInManager, ILoggerFactory loggerFactory)
 {
     this.endpoint      = endpoint;
     this.plugInManager = plugInManager;
     this.loggerFactory = loggerFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketHandlerPlugInContainer{THandler}" /> class.
 /// </summary>
 /// <param name="clientVersionProvider">The client version provider.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public PacketHandlerPlugInContainer(IClientVersionProvider clientVersionProvider, PlugInManager manager, ILoggerFactory loggerFactory)
     : base(manager, loggerFactory)
 {
     this.clientVersionProvider = clientVersionProvider;
     this.clientVersionProvider.ClientVersionChanged += this.OnClientVersionChanged;
     this.serviceContainer = new ServiceContainer();
     this.serviceContainer.AddService(typeof(IClientVersionProvider), clientVersionProvider);
     this.serviceContainer.AddService(typeof(PlugInManager), manager);
     this.serviceContainer.AddService(typeof(ILoggerFactory), loggerFactory);
 }
示例#28
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: gView.Cmd.FillElasticSearch [json-file]");
                return;
            }

            try
            {
                //gView.Framework.system.SystemVariables.CustomApplicationDirectory =
                //    System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

                Console.WriteLine("Environment");

                Console.WriteLine("Working Directory: " + gView.Framework.system.SystemVariables.StartupDirectory);
                Console.WriteLine("64Bit=" + gView.Framework.system.Wow.Is64BitProcess);

                var importConfig = JsonConvert.DeserializeObject <ImportConfig>(File.ReadAllText(args[0]));

                var searchContext = new ElasticSearchContext(importConfig.Connection.Url, importConfig.Connection.DefaultIndex);

                if (importConfig.Connection.DeleteIndex)
                {
                    searchContext.DeleteIndex();
                }

                searchContext.CreateIndex();
                searchContext.Map <Item>();
                searchContext.Map <Meta>();

                ISpatialReference sRefTarget = SpatialReference.FromID("epsg:4326");

                Console.WriteLine("Target Spatial Reference: " + sRefTarget.Name + " " + String.Join(" ", sRefTarget.Parameters));

                foreach (var datasetConfig in importConfig.Datasets)
                {
                    if (datasetConfig.FeatureClasses == null)
                    {
                        continue;
                    }

                    IDataset dataset = new PlugInManager().CreateInstance(datasetConfig.DatasetGuid) as IDataset;
                    if (dataset == null)
                    {
                        throw new ArgumentException("Can't load dataset with guid " + datasetConfig.DatasetGuid.ToString());
                    }

                    dataset.ConnectionString = datasetConfig.ConnectionString;
                    dataset.Open();

                    foreach (var featureClassConfig in datasetConfig.FeatureClasses)
                    {
                        var itemProto = featureClassConfig.IndexItemProto;
                        if (itemProto == null)
                        {
                            continue;
                        }

                        string metaId   = Guid.NewGuid().ToString("N").ToLower();
                        string category = featureClassConfig.Category;
                        if (!String.IsNullOrWhiteSpace(category))
                        {
                            var meta = new Meta()
                            {
                                Id         = metaId,
                                Category   = category,
                                Descrption = featureClassConfig.Meta?.Descrption,
                                Sample     = featureClassConfig?.Meta.Sample,
                                Service    = featureClassConfig?.Meta.Service,
                                Query      = featureClassConfig?.Meta.Query
                            };
                            searchContext.Index <Meta>(meta);
                        }

                        bool useGeometry = featureClassConfig.UserGeometry;

                        IDatasetElement dsElement = dataset[featureClassConfig.Name];
                        if (dsElement == null)
                        {
                            throw new ArgumentException("Unknown dataset element " + featureClassConfig.Name);
                        }
                        IFeatureClass fc = dsElement.Class as IFeatureClass;
                        if (fc == null)
                        {
                            throw new ArgumentException("Dataobject is not a featureclass " + featureClassConfig.Name);
                        }

                        Console.WriteLine("Index " + fc.Name);
                        Console.WriteLine("=====================================================================");

                        QueryFilter filter = new QueryFilter();
                        filter.SubFields = "*";

                        List <Item> items = new List <Item>();
                        int         count = 0;

                        ISpatialReference sRef = fc.SpatialReference ?? SpatialReference.FromID("epsg:" + featureClassConfig.SRefId);
                        Console.WriteLine("Source Spatial Reference: " + sRef.Name + " " + String.Join(" ", sRef.Parameters));

                        using (GeometricTransformer transformer = new GeometricTransformer())
                        {
                            if (useGeometry)
                            {
                                transformer.SetSpatialReferences(sRef, sRefTarget);
                            }

                            IFeatureCursor cursor = (IFeatureCursor)fc.GetFeatures(filter);
                            IFeature       feature;
                            while ((feature = cursor.NextFeature) != null)
                            {
                                var indexItem = ParseFeature(metaId, category, feature, itemProto, useGeometry, transformer, featureClassConfig);
                                items.Add(indexItem);
                                count++;

                                if (items.Count >= 500)
                                {
                                    searchContext.IndexMany <Item>(items.ToArray());
                                    items.Clear();

                                    Console.Write(count + "...");
                                }
                            }

                            if (items.Count > 0)
                            {
                                searchContext.IndexMany <Item>(items.ToArray());
                                Console.WriteLine(count + "...finish");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
示例#29
0
文件: Monster.cs 项目: xtr3sor/OpenMU
 /// <summary>
 /// Initializes a new instance of the <see cref="Monster" /> class.
 /// </summary>
 /// <param name="spawnInfo">The spawn information.</param>
 /// <param name="stats">The stats.</param>
 /// <param name="map">The map on which this instance will spawn.</param>
 /// <param name="dropGenerator">The drop generator.</param>
 /// <param name="npcIntelligence">The monster intelligence.</param>
 /// <param name="plugInManager">The plug in manager.</param>
 public Monster(MonsterSpawnArea spawnInfo, MonsterDefinition stats, GameMap map, IDropGenerator dropGenerator, INpcIntelligence npcIntelligence, PlugInManager plugInManager)
     : base(spawnInfo, stats, map)
 {
     this.dropGenerator    = dropGenerator;
     this.Attributes       = new MonsterAttributeHolder(this);
     this.MagicEffectList  = new MagicEffectsList(this);
     this.walker           = new Walker(this, () => this.StepDelay);
     this.intelligence     = npcIntelligence;
     this.plugInManager    = plugInManager;
     this.intelligence.Npc = this;
     this.intelligence.Start();
     this.Initialize();
 }
示例#30
0
        public void DeactivatingUnknownPlugInDoesNotThrowError()
        {
            var manager = new PlugInManager();

            manager.ActivatePlugIn(new Guid("4C38A813-F9BF-428A-8EA1-A6C90A87E583"));
        }