예제 #1
0
    public static IWorldMap Create(string name)
    {
        IServiceProvider serviceProvider = new ServiceCollection()
                                           .AddSingleton(new Mock <ILogger <WorldMap> >().Object)
                                           .AddSingleton <IBlockFactory>(s =>
        {
            IRegistry registry   = s.GetRequiredService <IRegistry>();
            var blockFactoryMock = new Mock <IBlockFactory>();
            blockFactoryMock.Setup(x => x.CreateBlock(It.IsAny <BlockType>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <IChunk>()))
            .Returns <BlockType, int, int, int, IChunk>((type, x, y, z, chunk) =>
            {
                return(new Block(x, y, z, chunk, new BlockData(type.ToString(), (int)type, null, new[]
                {
                    new BlockStateData((int)type, true, new Dictionary <string, string>())
                }), registry));
            });

            return(blockFactoryMock.Object);
        })
                                           .AddSingleton <IRegistry>(s =>
        {
            var registry = new DataRegistry(new Mock <ILogger <DataRegistry> >().Object);
            registry.Load();

            return(registry);
        })
                                           .BuildServiceProvider();
        var map = new WorldMap(name, serviceProvider);

        return(map);
    }
예제 #2
0
        protected override bool OnStart()
        {
            _quartzSchedule = new QuartzSchedule(_configStorage, _queuePublisherSchedule);
            try
            {
                DataRegistry registry = Registry.GetNewRegistry(_localRsdudbConn.DSN, _localRsdudbConn.Login, _localRsdudbConn.Password);
                registry.SetAppName(_localRsdudbConn.AppName);
                _svcSignal.Initialize(registry);
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Возникли ошибки при инициализации сигнальной системы! Отправка сигналов производиться не будет! \n\rОшибка: {0}\n{1}", ex.Message, ex.StackTrace));
            }
            try
            {
                _rcvRetroThread = new ReceiveRetroKadrThreadEx(_localRsdudbConn, _receiveRetroThVars, _queuePublisherAction, _queueConsumerAction, _queuePublisherSchedule, _queueConsumerSchedule, _configStorage, _svcSignal);
                _rcvRetroThread.Start();
                _quartzSchedule.StartThread();

                _svcSignal.LoadAndInitSignal();

                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Возникли ошибки при старте сервиса! \n\rОшибка: {0}\n{1}", ex.Message, ex.StackTrace));
            }
            return(false);
        }
예제 #3
0
        /// <summary>
        /// Registers all default data types... can be overriden later
        /// </summary>
        public static IDataRegistry CreateDefaultDataRegistry()
        {
            var dataRegistry = new DataRegistry();

            dataRegistry.Register(typeof(IProject), new Factory <IData>(() => new Project(0)));
            dataRegistry.Register(typeof(ITodo), new Factory <IData>(() => new Todo(0)));

            return(dataRegistry);
        }
예제 #4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            ModelMetadataProviders.Current = new CERSModelMetadataProvider();
            DataRegistry.Initialize();
            LicenseKeys.Intialize();
        }
예제 #5
0
        public JsonResult ReloadAppCache_Async()
        {
            //reload CDR stuff.
            DataRegistry.ReloadCache();
            Repository.SystemLookupTables.RebuildCache();

            var result = new
            {
                Success = true
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();


            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            DataRegistry.RegisterDependencies(services);
            ServiceRegistry.RegisterDependencies(services);
        }
예제 #7
0
        public ActionResult DataDictionaryLibrary(DataRegistryDataSourceType dictionary, string identifier)
        {
            Server.ScriptTimeout = 600;

            //No role based authentication needed, just make sure they have a valid credential for Library services.
            var authResult = CERSSecurityManager.AuthenticateHttpAuthorizationHeader();

            if (authResult.Result.Status == AuthenticationStatus.Success)
            {
                using (EDTTransactionScope transScope = new EDTTransactionScope(authResult.Account, EDTEndpoint.DataDictionaryQuery, Request.UserHostAddress, authenticationRequestID: authResult.EDTAuthenticationRequestID))
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(identifier))
                        {
                            transScope.WriteActivity("Finding DataElement by Specific Identifier: \"" + identifier + "\".");
                        }
                        else
                        {
                            transScope.WriteActivity("Get All DataElements.");
                        }

                        var elements = DataRegistry.GetDataElements(dictionary, identifier);
                        transScope.WriteActivity("Fetched " + elements.Count + " Data Elements");
                        var xmlResult = elements.ToXml();
                        transScope.WriteActivity("Generated XML Package Successfully");
                        return(XmlElement(xmlResult));
                    }
                    catch (Exception ex)
                    {
                        transScope.WriteActivity("Exception Occurred", ex);
                        transScope.WriteMessage("Exception Occurred. " + ex.Format(), EDTTransactionMessageType.Error);
                        transScope.Complete(EDTTransactionStatus.ErrorProcessing);
                        return(HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
                    }
                }
            }
            else
            {
                return(HttpStatusCodeResult(HttpStatusCode.Unauthorized, authResult));
            }
        }
예제 #8
0
 private static void WriteRegistry(DataRegistry registry)
 {
     Console.WriteLine($"Numero: {registry.Id} Nome: {registry.Name} Idade: {registry.Age} Salario: {registry.Salary}");
 }
예제 #9
0
파일: Program.cs 프로젝트: hdpham77/Test
        private static void Main(string[] args)
        {
            Console.WriteLine("CERS2 Address Washing Utility, v0.01");
            Console.WriteLine("Initializing Data Registry...");
            DataRegistry.Initialize();
            int successCount              = 0;
            int failureCount              = 0;
            int lengthViolationsCount     = 0;
            int skippedDueToMissingStreet = 0;

            bool lengthViolation = false;

            using (ICERSRepositoryManager repo = ServiceLocator.GetRepositoryManager())
            {
                ICERSSystemServiceManager services = ServiceLocator.GetSystemServiceManager(repo);
                Console.WriteLine("Gathering Facilities...");

                //DateTime washDate = DateTime.Now.Date.AddDays( -3 );
                //DateTime washDate = Convert.ToDateTime( "12/31/2013" );
                DateTime washDate = Convert.ToDateTime("6/30/2014");

                //var facilities = repo.Facilities.Search(washDate: washDate).ToList();

                var facilities = (from fac in repo.DataModel.Facilities where !fac.Voided && !fac.IsAddressWashed && fac.WashDate > washDate select fac).ToList();

                //var facilities = ( from facil in repo.DataModel.Facilities where facil.Voided == false select facil ).ToList();

                Console.WriteLine("Found " + facilities.Count() + " Facilities...");
                foreach (var facility in facilities)
                {
                    lengthViolation = false;
                    Console.WriteLine("CERSID: " + facility.CERSID);
                    Console.WriteLine("Facility Name: " + facility.Name);
                    Console.Write("\tSource Address: ");
                    Console.WriteLine(GetSourceAddress(facility));
                    if (!string.IsNullOrWhiteSpace(facility.Street))
                    {
                        Console.Write("\tWashed Address:");
                        AddressInformation result = services.Geo.GetAddressInformation(facility.Street, facility.City, facility.ZipCode, facility.State);
                        if (result != null)
                        {
                            CheckLength("WashedStreet", result.Street, 100, ref lengthViolation);
                            CheckLength("WashedCity", result.City, 100, ref lengthViolation);
                            CheckLength("WashedState", result.State, 2, ref lengthViolation);
                            CheckLength("WashedZipCode", result.ZipCode, 10, ref lengthViolation);

                            if (!lengthViolation)
                            {
                                int washConfidence;
                                if (int.TryParse(result.MelissaAddressWashConfidence, out washConfidence) == false)
                                {
                                    washConfidence = 0;
                                }

                                if (result.MelissaAddressWashSucceeded && Convert.ToInt32(washConfidence) > 0)
                                {
                                    facility.IsAddressWashed           = true;
                                    facility.WashDate                  = DateTime.Now;
                                    facility.WashedStreet              = result.Street;
                                    facility.WashedStreetWithoutSuite  = result.StreetWithoutSuiteNumber;
                                    facility.WashedSuite               = result.Suite;
                                    facility.WashedCity                = result.City;
                                    facility.WashedState               = result.State;
                                    facility.WashedZipCode             = result.ZipCode;
                                    facility.WashedStreetName          = result.StreetName;
                                    facility.WashedStreetPostDirection = result.PostDirection;
                                    facility.WashedStreetPreDirection  = result.PreDirection;
                                    facility.WashedStreetRange         = result.Range;
                                    facility.WashedStreetSuffix        = result.Suffix;
                                    facility.WashConfidence            = washConfidence;
                                    facility.WashSourceID              = (int)WashSource.Melissa;
                                    if (facility.CountyID == null)
                                    {
                                        facility.CountyID = result.CountyID;
                                    }

                                    CERSFacilityGeoPoint geoPoint = facility.CERSFacilityGeoPoint;

                                    if (geoPoint == null)
                                    {
                                        geoPoint = new CERSFacilityGeoPoint();
                                    }

                                    //make sure the result coordinates are in range before saving them
                                    if ((result.Latitude >= 32 && result.Latitude < 43) && (result.Longitude >= -114 && result.Longitude < 125))
                                    {
                                        geoPoint.CERSID                       = facility.CERSID;
                                        geoPoint.LatitudeMeasure              = result.Latitude;
                                        geoPoint.LongitudeMeasure             = result.Longitude;
                                        geoPoint.HorizontalAccuracyMeasure    = result.HorizontalAccuracyMeasure;
                                        geoPoint.HorizontalCollectionMethodID = result.HorizontalCollectionMethodID;
                                        geoPoint.HorizontalReferenceDatumID   = result.HorizontalReferenceDatumID;
                                        geoPoint.GeographicReferencePointID   = result.GeographicReferencePointID;
                                        geoPoint.SetCommonFields();
                                        repo.CERSFacilityGeoPoints.Save(geoPoint);
                                    }
                                }
                                else if (result.MelissaAddressWashSucceeded)
                                {
                                    //Use the parsed street values to get a standardized address

                                    facility.IsAddressWashed           = false;
                                    facility.WashDate                  = DateTime.Now;
                                    facility.WashSourceID              = (int)WashSource.Melissa;
                                    facility.WashedStreet              = result.Street;
                                    facility.WashedStreetWithoutSuite  = result.StreetWithoutSuiteNumber;
                                    facility.WashedSuite               = result.Suite;
                                    facility.WashedCity                = result.City;
                                    facility.WashedState               = result.State;
                                    facility.WashedZipCode             = result.ZipCode;
                                    facility.WashedStreetName          = result.StreetName;
                                    facility.WashedStreetPostDirection = null;
                                    facility.WashedStreetPreDirection  = null;
                                    facility.WashedStreetRange         = result.Range;
                                    facility.WashedStreetSuffix        = result.Suffix;
                                }

                                Console.WriteLine(GetWashedAddress(result));
                                Console.WriteLine("\tUpdating Facility...");
                                repo.Facilities.Save(facility);
                                Console.WriteLine("\tFacility Updated");
                                successCount++;
                            }
                            else
                            {
                                Console.WriteLine("\tFacility NOT Updated");
                                lengthViolationsCount++;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Unable to obtain washed address.");
                            failureCount++;
                        }
                    }
                    else
                    {
                        skippedDueToMissingStreet++;
                        Console.WriteLine("\tSkipped Due to Missing Street!");
                    }
                }

                Console.WriteLine("Process Completed.");
                Console.WriteLine("Successfully Washed: " + successCount);
                Console.WriteLine("Failed To Wash: " + failureCount);
                Console.WriteLine("Length Violations (NOT Washed): " + lengthViolationsCount);
                Console.WriteLine("Skipped Due to Missing Street: " + skippedDueToMissingStreet);
            }
            Console.Write("Press enter to quit.");
            Console.ReadLine();
        }
예제 #10
0
        /// <summary>
        /// Получение кадра по id
        /// </summary>
        /// <param name="kadrId"></param>
        /// <returns></returns>
        private RetroKadr GetKadr(int kadrId, DataRegistry _dataRegistry)
        {
            lock (_dataRegistry.Locker)
            {
                using (_dataRegistry.ConnHolder)
                {
                    _dataRegistry.Map.RemoveFromMap <RetroKadr>(new ObjectIdentity(kadrId));
                    var kadr = _dataRegistry.Map.Find <RetroKadr>(new ObjectIdentity(kadrId));
                    _dataRegistry.Map.FullLoad(kadr);

                    foreach (var parameter in kadr.Parameters)
                    {
                        _dataRegistry.Map.MiddleLoad(parameter.Ginfo);
                        if (parameter.Ginfo != null)
                        {
                            _dataRegistry.Map.MiddleLoad(parameter.Ginfo.GTopt);
                        }

                        if (parameter.Measure == null)
                        {
                            continue;
                        }

                        if (parameter.Measure is AutoMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((AutoMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is ElRegDgMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((ElRegDgMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is ElRegMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((ElRegMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is PhRegMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((PhRegMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is PswtMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((PswtMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is CalcMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((CalcMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is DaMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((DaMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is DgMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((DgMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is EaMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((EaMeasure)parameter.Measure);
                        }
                        if (parameter.Measure is StateMeasure)
                        {
                            _dataRegistry.Map.MiddleLoad((StateMeasure)parameter.Measure);
                        }

                        if (parameter.Measure == null)
                        {
                            continue;
                        }

                        if (parameter.Measure.Node is AstOrganization)
                        {
                            _dataRegistry.Map.MiddleLoad((AstOrganization)parameter.Measure.Node);
                        }
                        if (parameter.Measure.Node is DgPlanGroup)
                        {
                            _dataRegistry.Map.MiddleLoad((DgPlanGroup)parameter.Measure.Node);
                        }
                        if (parameter.Measure.Node is EaGroup)
                        {
                            _dataRegistry.Map.MiddleLoad((EaGroup)parameter.Measure.Node);
                        }
                        if (parameter.Measure.Node is Equipment)
                        {
                            _dataRegistry.Map.MiddleLoad((Equipment)parameter.Measure.Node);
                        }
                        if (parameter.Measure.Node is HgGroup)
                        {
                            _dataRegistry.Map.MiddleLoad((HgGroup)parameter.Measure.Node);
                        }
                        if (parameter.Measure.Node is SborEquipment)
                        {
                            _dataRegistry.Map.MiddleLoad((SborEquipment)parameter.Measure.Node);
                        }
                    }
                    return(kadr);
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Получить архивные данные кадра
        /// </summary>
        /// <param name="dateStart"></param>
        /// <param name="dateFinish"></param>
        /// <param name="kadr"></param>
        /// <param name="dataRegistry"></param>
        /// <returns></returns>
        private List <ParamData> GetDataArc(DateTime dateStart, DateTime dateFinish, RetroKadr kadr, DataRegistry dataRegistry)
        {
            var result = new List <ParamData>();

            lock (dataRegistry.Locker)
            {
                using (dataRegistry.ConnHolder)
                {
                    foreach (IArchive arc in kadr.Parameters)
                    {
                        result.Add(new ParamData(
                                       MeasureHelper.GetByTablePeriod(dataRegistry, arc.Retfname, new RsduTime(dateStart), new RsduTime(dateFinish)),
                                       arc));
                    }
                }
            }

            return(result);
        }