예제 #1
0
 // Single Thread parser thread part
 private void Parse_SigleThread(string FileName, IProgress <int> Progress)
 {
     Initialise(FileName);
     while (!Reader.EndOfStream())
     {
         if (_Cancel.IsCancellationRequested)
         {
             _Cancel.Token.ThrowIfCancellationRequested();
         }
         var line = Reader.ReadLine();
         try
         {
             var converter = Facade.Converter;
             _AnketaFile.Rows.Add(converter.ConvertIt <Anketa>(line));
         }
         catch (Exception ex)
         {
             Logger.Log("\n   " + ex.Message + "\r\n   At line:" + line);
         }
         Task.Delay(5).Wait();
         RowNum++;
         Progress.Report(RowNum);
     }
     Reader.Close();
     if (_AnketaFile.Rows.Count == 0)
     {
         throw new Exception("The file does not contain any good records!");
     }
 }
 public void Close()
 {
     if (m_FileReader != null)
     {
         m_FileReader.Close();
     }
 }
예제 #3
0
 private void CloseReader()
 {
     if (_reader != null)
     {
         _reader.Close();
         _reader = null;
     }
 }
예제 #4
0
 public void Start()
 {
     ParseNumberOfCases();
     ParseCases();
     DisplayCases();
     _reader.Close();
     _writer.Close();
 }
예제 #5
0
        public void Start(string pathIn, string pathOut)
        {
            if (string.IsNullOrEmpty(pathIn))
            {
                throw new ArgumentNullException("Путь входного файла пустой или  не указывает на экземпляр объекта. Функция ParallelProcessing.Start");
            }
            if (string.IsNullOrEmpty(pathOut))
            {
                throw new ArgumentNullException("Путь выходного файла пустой или  не указывает на экземпляр объекта. Функция ParallelProcessing.Start");
            }

            _reader.Open(pathIn, _readerEvent);
            _writer.Open(pathOut, _writerEvent);
            _task.Reader = _reader;
            _task.Writer = _writer;
            _pool        = new Pool(_task);
            _pool.Start();
            _reader.Close();
            _readerEvent.WaitOne();
            _writer.Close();
            _writerEvent.WaitOne();
        }
예제 #6
0
        public void Stop()
        {
            _logger.Info("Остановка процессора сообщений");

            lock (_locker)
            {
                _timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);

                foreach (var queue in _logQueues)
                {
                    queue.Value.Clear();
                }

                try { _reader.Close(); } catch (Exception) { }
                try { _publisher.Close(); } catch (Exception) { }
            }
        }
예제 #7
0
            /// <summary>
            /// Adds records from the specified reader into this selection
            /// </summary>
            /// <param name="reader">The reader</param>
            /// <param name="limit">The maximum number of records to add. Specify -1 for all</param>
            /// <returns>Number of records added</returns>
            public int AddFeatures(IReader reader, int limit)
            {
                int added = 0;

                if (limit < 0)
                {
                    while (reader.ReadNext())
                    {
                        AddFeature(reader);
                        added++;
                    }
                }
                else
                {
                    while (reader.ReadNext() && added < limit)
                    {
                        AddFeature(reader);
                        added++;
                    }
                }
                reader.Close();
                return(added);
            }
예제 #8
0
        private void CreateDistrictsLayer(IServerConnection conn, string resId, string layerId)
        {
            //We use the Utility class to create our layer. You can also use ObjectFactory, but
            //that requires explicitly specifying the resource version. Using Utility will pick
            //the latest supported version
            ILayerDefinition       ldf  = Utility.CreateDefaultLayer(conn, LayerType.Vector);
            IVectorLayerDefinition vldf = (IVectorLayerDefinition)ldf.SubLayer;

            //Set feature source
            vldf.ResourceId = resId;

            //Set the feature class
            //
            //Note: In versions of the Sheboygan Dataset before 2.6, this used to be
            //
            // - Feature Class: SDF_2_Schema:VotingDistricts
            // - Identity Property: Autogenerated_SDF_ID
            // - Geometry Property: Data
            string featureClass = "Default:VotingDistricts";
            string idProp       = "FeatId";
            string geometryProp = "Geometry";

            vldf.FeatureName = featureClass;

            //Set the designated geometry
            vldf.Geometry = geometryProp;

            //Get the first vector scale range. This will have been created for us and is 0 to infinity
            IVectorScaleRange vsr = vldf.GetScaleRangeAt(0);

            //What are we doing here? We're checking if this vector scale range is a
            //IVectorScaleRange2 instance. If it is, it means this layer definition
            //has a composite style attached, which takes precedence over point/area/line
            //styles. We don't want this, so this removes the composite styles if they
            //exist.
            IVectorScaleRange2 vsr2 = vsr as IVectorScaleRange2;

            if (vsr2 != null)
            {
                vsr2.CompositeStyle = null;
            }

            //Get the area style
            IAreaVectorStyle astyle = vsr.AreaStyle;

            //Remove the default rule
            astyle.RemoveAllRules();

            IFeatureService featSvc = conn.FeatureService;
            //Generate a random color for each distinct feature id
            //Perform a distinct value query
            IReader valueReader = featSvc.AggregateQueryFeatureSource(resId, featureClass, null, new NameValueCollection()
            {
                { "Value", "UNIQUE(" + idProp + ")" } //UNIQUE() is the aggregate function that collects all distinct values of FeatId
            });

            while (valueReader.ReadNext())
            {
                //The parent Layer Definition provides all the methods needed to create the necessary child elements
                IAreaRule rule = ldf.CreateDefaultAreaRule();
                //Set the filter for this rule
                rule.Filter = idProp + " = " + valueReader["Value"].ToString();
                //IReader allows object access by name in case you don't care to determine the data type
                rule.LegendLabel = valueReader["Value"].ToString();
                //Assign a random color fill
                rule.AreaSymbolization2D.Fill.ForegroundColor = Utility.SerializeHTMLColor(RandomColor(), true);
                //Add this rule
                astyle.AddRule(rule);
            }
            valueReader.Close();

            //Now save it
            conn.ResourceService.SaveResourceAs(ldf, layerId);
        }
예제 #9
0
        private void ValidateFilm(IReader reader)
        {
            // Validate Header Magic
            reader.SeekTo(0x00);
            var test = reader.ReadAscii();
            if (test != "_blf")
            {
                reader.Close();
                throw new NotSupportedException("Unsupported file.");
            }

            // Validate Header Type
            reader.SeekTo(0x0E);
            test = reader.ReadAscii();
            if (test != "reach saved film")
            {
                reader.Close();
                throw new NotSupportedException("Unsupported file.");
            }

            // Validate BLF Film Chunk Header
            reader.SeekTo(0x340);
            test = reader.ReadAscii();
            if (test != "flmh")
            {
                reader.Close();
                throw new NotSupportedException("Unsupported file.");
            }
        }
예제 #10
0
 public void Close()
 {
     _csvWriter?.Close();
     _csvReader?.Close();
 }
예제 #11
0
        public static void SDFInsert(string SDFFile, string propertyName, string value, string tableName)
        {
            try
            {
                IConnection con = SDFHelper.SDFConnection(SDFFile);
                con.Open();
                //ITransaction fdotrans = null;
                //if (concap.SupportsTransactions()) fdotrans = con.BeginTransaction();
                //ed.WriteMessage("\nFDO Transaction");

                //implement changes
                //IApplySchema applyschema = (IApplySchema)con.CreateCommand(osgeo_command.CommandType.CommandType_ApplySchema);
                //applyschema.Execute();
                //applyschema.Dispose();

                //creating insert
                using (con)
                {
                    using (osgeo_command.Feature.IInsert insert_comm = con.CreateCommand(osgeo_command.CommandType.CommandType_Insert) as osgeo_command.Feature.IInsert)
                    {
                        //set feature calss
                        insert_comm.SetFeatureClassName("Civil_schema:" + tableName);
                        //string test = insert_comm.FeatureClassName.Name;

                        //ed.WriteMessage("Set class name: " + test);

                        //inserting value
                        PropertyValueCollection valcoll = insert_comm.PropertyValues;

                        PropertyValue pvalue1 = new PropertyValue();



                        insert_comm.PropertyValues.Add(new PropertyValue(propertyName, new StringValue(value)));

                        IReader reader = insert_comm.Execute();
                        if (reader.ReadNext())
                        {
                        }
                        reader.Close();
                    }
                }
                //con.Dispose();
                //con.Close();

                /*ed.WriteMessage("\nInser command created: " + insert_comm.ParameterValues.Count);
                 *
                 * OSGeo.FDO.Commands.PropertyValue pvalue = null;
                 * pvalue = new osgeo_command.PropertyValue();
                 *
                 * pvalue.SetName("PipeStyle");
                 * pvalue.Value = new OSGeo.FDO.Expression.StringValue("test string value");
                 *
                 * insert_comm.PropertyValues.Add(pvalue);
                 *
                 * try
                 * {
                 *  using(osgeo_command.Feature.IFeatureReader reader = insert_comm.Execute());
                 *
                 * }
                 * catch(Autodesk.AutoCAD.Runtime.Exception ex)
                 * {
                 *  ed.WriteMessage("\nException: " + ex.Message);
                 *
                 * }
                 * }
                 */
                //if (concap.SupportsTransactions())fdotrans.Commit();
            }
            catch (OSGeo.FDO.Common.Exception ge)
            {
                bool ok = ge.Message.Contains("read-only");
                Debug.Write(ge.ToString());
            }
            catch (SystemException ex)
            {
                bool ok = ex.Message.Contains("read-only");
                Debug.Write(ex.ToString());
            }
        }