public List <FACULTY> GetForUniversity(long uniId)
        {
            List <FACULTY> faculties = null;

            using (ctx = new ReadingRoomsEntities())
            {
                var collection = ctx.FACULTies
                                 .Where(f => f.UNI_ID == uniId)
                                 .Include(f => f.UNIVERSITY);
                if (CheckHelper.IsFilled(collection))
                {
                    faculties = collection.ToList();
                }
            }

            return(faculties);
        }
Пример #2
0
        public List <ReadingRoomDTO> GetReadingRooms(long facId)
        {
            FACULTY faculty = null;
            List <ReadingRoomDTO>  retVal = null;
            ReadingRoomTransformer rroomTransformer;
            List <READING_ROOM>    rrooms;

            rrooms           = rroomRepository.GetRRoomsForFaculty(facId);
            rroomTransformer = new ReadingRoomTransformer();

            if (CheckHelper.IsFilled(rrooms))
            {
                retVal = rroomTransformer.TransformToDTO(rrooms);
            }

            return(retVal);
        }
Пример #3
0
        public async Task DoAsync(Action action)
        {
            CheckHelper.ArgumentNotNull(action, "action");

            var asyncStatusPresenter = Container.Get <IAsyncStatusPresenter>();

            try
            {
                asyncStatusPresenter.SetAsyncStatus(true);

                await Task.Run(action);
            }
            finally
            {
                asyncStatusPresenter.SetAsyncStatus(false);
            }
        }
Пример #4
0
        public void RegisterFactoryMethod_Success()
        {
            ITestCase testCase = new FactoryMethodTestCaseC(new NiquIoCPartialRegistration(),
                                                            new NiquIoCPartialResolving());

            var c = new Container();

            c = (Container)testCase.Register(c, RegistrationKind.FactoryMethod);

            var obj1 = c.Resolve <ITestC>(ResolveKind.PartialEmitFunction);
            var obj2 = c.Resolve <ITestC>(ResolveKind.PartialEmitFunction);


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
Пример #5
0
        public void RegisterTransientSingleton_Success()
        {
            ITestCase testCase =
                new TransientSingletonTestCaseC(new NiquIoCPartialRegistration(), new NiquIoCPartialResolving());

            var c = new Container();

            c = (Container)testCase.Register(c, RegistrationKind.TransientSingleton);

            var obj1 = c.Resolve <ITestC>(ResolveKind.PartialEmitFunction);
            var obj2 = c.Resolve <ITestC>(ResolveKind.PartialEmitFunction);


            CheckHelper.Check(obj1, false, true);
            CheckHelper.Check(obj2, false, true);
            CheckHelper.Check(obj1, obj2, false, true);
        }
        public void RegisterTransient_Success()
        {
            ITestCase testCase = new TransientTestCaseB(new StructureMapRegistration(), new StructureMapResolving());


            var c = new Container();

            c = (Container)testCase.Register(c, RegistrationKind.Transient);

            var obj1 = c.GetInstance <ITestB>();
            var obj2 = c.GetInstance <ITestB>();


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
        public UNIVERSITY TransformFromDTO(long id, UniversityDTO dto)
        {
            UNIVERSITY retVal = new UNIVERSITY();

            if (CheckHelper.IsFilled(dto))
            {
                retVal.UNI_ID   = id;
                retVal.UNI_NAME = dto.Name;
                retVal.UNI_CITY = dto.City;
            }
            else
            {
                retVal = null;
            }

            return(retVal);
        }
Пример #8
0
        public void RegisterTransientSingleton_Success()
        {
            ITestCase testCase =
                new TransientSingletonTestCaseB(new LightInjectRegistration(), new LightInjectResolving());

            var c = new ServiceContainer();

            c = (ServiceContainer)testCase.Register(c, RegistrationKind.TransientSingleton);

            var obj1 = c.GetInstance <ITestB>();
            var obj2 = c.GetInstance <ITestB>();


            CheckHelper.Check(obj1, false, true);
            CheckHelper.Check(obj2, false, true);
            CheckHelper.Check(obj1, obj2, false, true);
        }
Пример #9
0
        public List <FacultyDTO> GetAll()
        {
            List <FacultyDTO> retVal = null;
            List <FACULTY>    entries;

            try
            {
                entries = facultyRepository.GetAll();
                if (CheckHelper.IsFilled(entries))
                {
                    retVal = transformer.TransformToDTO(entries);
                }
            }
            catch (Exception) { }

            return(retVal);
        }
Пример #10
0
        public List <UserDTO> GetStudents(long facId)
        {
            List <UserDTO>  retVal = null;
            UserTransformer userTransformer;
            List <USER>     students;


            students        = userRepository.GetForFaculty(facId);
            userTransformer = new UserTransformer();

            if (CheckHelper.IsFilled(students))
            {
                retVal = userTransformer.TransformToDTO(students);
            }

            return(retVal);
        }
        public void RegisterSingleton_Success()
        {
            ITestCase testCase = new SingletonTestCaseB(new StructureMapRegistration(), new StructureMapResolving());


            var c = new Container();

            c = (Container)testCase.Register(c, RegistrationKind.Singleton);

            var obj1 = c.GetInstance <ITestB>();
            var obj2 = c.GetInstance <ITestB>();


            CheckHelper.Check(obj1, true, true);
            CheckHelper.Check(obj2, true, true);
            CheckHelper.Check(obj1, obj2, true, true);
        }
Пример #12
0
        public List <BlogDTO> GetBlogs(long facId)
        {
            FACULTY         faculty = null;
            List <BlogDTO>  retVal  = null;
            BlogTransformer blogTransformer;

            // TODO : Implementirati metodu za dobavljanje blogova koji pripadaju fakultetu sa prosledjenim ID.
            //faculty = facultyRepository.GetById(facId);
            blogTransformer = new BlogTransformer();

            if (CheckHelper.IsFilled(faculty) && CheckHelper.IsFilled(faculty.BLOGs))
            {
                retVal = blogTransformer.TransformToDTO(faculty.BLOGs.ToList());
            }

            return(retVal);
        }
Пример #13
0
        public FacultyDTO GetById(long id)
        {
            FACULTY    entry;
            FacultyDTO retVal = null;

            try
            {
                entry = facultyRepository.GetById(id);
                if (CheckHelper.IsFilled(entry))
                {
                    retVal = transformer.TransformToDTO(entry);
                }
            }
            catch (Exception) { }

            return(retVal);
        }
        public void RegisterTransient_Success()
        {
            ITestCase testCase = new TransientTestCaseB(new GraceRegistration(), new GraceResolving());

            var c = new DependencyInjectionContainer();

            c = (DependencyInjectionContainer)testCase.Register(c, RegistrationKind.Transient);


            var obj1 = c.Locate <ITestB>();
            var obj2 = c.Locate <ITestB>();


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
Пример #15
0
        public void RegisterSingleton_Success()
        {
            ITestCase testCase = new SingletonTestCaseD(new WindsorRegistration(), new WindsorResolving());


            var c = new WindsorContainer();

            c = (WindsorContainer)testCase.Register(c, RegistrationKind.Singleton);

            var obj1 = c.Resolve <ITestD>();
            var obj2 = c.Resolve <ITestD>();


            CheckHelper.Check(obj1, true, true);
            CheckHelper.Check(obj2, true, true);
            CheckHelper.Check(obj1, obj2, true, true);
        }
Пример #16
0
        public void RegisterTransient_Success()
        {
            ITestCase testCase = new TransientTestCaseD(new WindsorRegistration(), new WindsorResolving());


            var c = new WindsorContainer();

            c = (WindsorContainer)testCase.Register(c, RegistrationKind.Transient);

            var obj1 = c.Resolve <ITestD>();
            var obj2 = c.Resolve <ITestD>();


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
Пример #17
0
        public void RegisterSingleton_Success()
        {
            ITestCase testCase = new SingletonTestCaseD(new GraceRegistration(), new GraceResolving());

            var c = new DependencyInjectionContainer();

            c = (DependencyInjectionContainer)testCase.Register(c, RegistrationKind.Singleton);


            var obj1 = c.Locate <ITestD>();
            var obj2 = c.Locate <ITestD>();


            CheckHelper.Check(obj1, true, true);
            CheckHelper.Check(obj2, true, true);
            CheckHelper.Check(obj1, obj2, true, true);
        }
Пример #18
0
        public void RegisterTransient_Success()
        {
            ITestCase testCase = new TransientTestCaseD(new NinjectRegistration(), new NinjectResolving());


            var c = new StandardKernel();

            c = (StandardKernel)testCase.Register(c, RegistrationKind.Transient);

            var obj1 = c.Get <ITestD>();
            var obj2 = c.Get <ITestD>();


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
Пример #19
0
        public void RegisterSingleton_Success()
        {
            ITestCase testCase = new SingletonTestCaseD(new NinjectRegistration(), new NinjectResolving());


            var c = new StandardKernel();

            c = (StandardKernel)testCase.Register(c, RegistrationKind.Singleton);

            var obj1 = c.Get <ITestD>();
            var obj2 = c.Get <ITestD>();


            CheckHelper.Check(obj1, true, true);
            CheckHelper.Check(obj2, true, true);
            CheckHelper.Check(obj1, obj2, true, true);
        }
        public void RegisterFactoryMethod_Success()
        {
            ITestCase testCase = new FactoryMethodTestCaseD(new SimpleInjectorRegistration(),
                                                            new SimpleInjectorResolving());

            var c = new Container();

            c = (Container)testCase.Register(c, RegistrationKind.FactoryMethod);

            var obj1 = c.GetInstance <ITestD>();
            var obj2 = c.GetInstance <ITestD>();


            CheckHelper.Check(obj1, false, false);
            CheckHelper.Check(obj2, false, false);
            CheckHelper.Check(obj1, obj2, false, false);
        }
Пример #21
0
 private bool ProcessCmdActivateInfo(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot9))
         {
             client.sendCmd <int>(1040, -8, false);
             return(true);
         }
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 5))
         {
             return(false);
         }
         int    roleID       = int.Parse(cmdParams[0]);
         string userID       = cmdParams[1];
         int    activateType = Convert.ToInt32(cmdParams[2]);
         string activateInfo = cmdParams[3].ToLower();
         string error        = cmdParams[4];
         string checkInfo    = this.GetCheckInfo(userID, error, activateType);
         if (checkInfo != activateInfo)
         {
             client.sendCmd <int>(1040, -1, false);
             return(true);
         }
         PlatformTypes platformType = GameCoreInterface.getinstance().GetPlatformType();
         if (platformType != PlatformTypes.APP)
         {
             client.sendCmd <int>(1040, -2, false);
             return(true);
         }
         if (activateType != 0)
         {
             client.sendCmd <int>(1040, -7, false);
             return(true);
         }
         int awardState = this.DBActivateStateGet(client);
         client.sendCmd <int>(1040, awardState, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Пример #22
0
        public void CreateOrder(DTO.Order createdOrder)
        {
            CheckHelper.ArgumentNotNull(createdOrder, "createdOrder");
            CheckHelper.ArgumentWithinCondition(createdOrder.IsNew(), "Order is not new.");
            Container.Get <IValidateService>().CheckIsValid(createdOrder);

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");
            CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can create order.");

            var persistentService = Container.Get <IPersistentService>();

            var order =
                new DataAccess.Order
            {
                OrderDate           = createdOrder.OrderDate,
                CustomerFirstName   = createdOrder.CustomerFirstName,
                CustomerLastName    = createdOrder.CustomerLastName,
                CustomerAddress     = createdOrder.CustomerAddress,
                CustomerCity        = createdOrder.CustomerCity,
                CustomerCountry     = createdOrder.CustomerCountry,
                CustomerPostalCode  = createdOrder.CustomerPostalCode,
                CustomerPhoneNumber = createdOrder.CustomerPhoneNumber,
                CustomerEmail       = createdOrder.CustomerEmail,
                Active          = createdOrder.Active,
                Comments        = createdOrder.Comments,
                RublesPerDollar = createdOrder.RublesPerDollar,
                CustomerPrepaid = createdOrder.CustomerPrepaid,
                CustomerPaid    = createdOrder.CustomerPaid
            };

            order.UpdateTrackFields(Container);

            persistentService.Add(order);
            persistentService.SaveChanges();

            createdOrder.Id         = order.Id;
            createdOrder.CreateDate = order.CreateDate;
            createdOrder.CreateUser = order.CreatedBy.GetFullName();
            createdOrder.ChangeDate = order.ChangeDate;
            createdOrder.ChangeUser = order.ChangedBy.GetFullName();

            createdOrder.Parcel = null;
            createdOrder.DistributorSpentOnDelivery = 0m;
            createdOrder.TrackingNumber             = null;
        }
Пример #23
0
        public void CreateProduct(DTO.Product createdProduct)
        {
            CheckHelper.ArgumentNotNull(createdProduct, "createdProduct");
            CheckHelper.ArgumentWithinCondition(createdProduct.IsNew(), "Product is not new.");
            Container.Get<IValidateService>().CheckIsValid(createdProduct);
            CheckHelper.ArgumentWithinCondition(!createdProduct.SubCategory.IsNew(), "SubCategory of Product is new.");
            CheckHelper.ArgumentWithinCondition(!createdProduct.Brand.IsNew(), "Brand of Product is new.");

            CheckHelper.WithinCondition(SecurityService.IsLoggedIn, "User is not logged in.");
            CheckHelper.WithinCondition(SecurityService.IsCurrentUserSeller, "Only seller can create product.");

            var persistentService = Container.Get<IPersistentService>();

            var subCategory = persistentService.GetEntityById<SubCategory>(createdProduct.SubCategory.Id);
            CheckHelper.NotNull(subCategory, "SubCategory does not exist.");
            var brand = persistentService.GetEntityById<DataAccess.Brand>(createdProduct.Brand.Id);
            CheckHelper.NotNull(brand, "Brand does not exist.");

            var httpService = Container.Get<IHttpService>();

            var product =
                new DataAccess.Product
                {
                    Name = createdProduct.Name,
                    SubCategoryId = subCategory.Id,
                    SubCategory = subCategory,
                    BrandId = brand.Id,
                    Brand = brand,
                    Active = brand.Active,
                    Description = createdProduct.Description,
                    VendorShopURL = createdProduct.VendorShopURL,
                    FullPictureURL = httpService.GetRelativeURLFromAbsoluteURL(createdProduct.FullPictureURL),
                    PreviewPictureURL = httpService.GetRelativeURLFromAbsoluteURL(createdProduct.PreviewPictureURL)
                };
            product.UpdateTrackFields(Container);
            
            persistentService.Add(product);
            persistentService.SaveChanges();

            createdProduct.Id = product.Id;
            createdProduct.CreateDate = product.CreateDate;
            createdProduct.CreateUser = product.CreatedBy.GetFullName();
            createdProduct.ChangeDate = product.ChangeDate;
            createdProduct.ChangeUser = product.ChangedBy.GetFullName();
        }
Пример #24
0
        public void UserReturnAwardList(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            Dictionary <int, int[]> result = new Dictionary <int, int[]>();

            string[] fields = null;
            try
            {
                int length = 3;
                if (!CheckHelper.CheckTCPCmdFields(nID, cmdParams, count, out fields, length))
                {
                    client.sendCmd <Dictionary <int, int[]> >(nID, result);
                    return;
                }
                string activityDay = fields[0];
                int    activityID  = int.Parse(fields[1]);
                string userID      = fields[2];
                using (MyDbConnection3 conn = new MyDbConnection3(false))
                {
                    string          cmdText = string.Format("SELECT type,state FROM t_user_return_award WHERE activityDay = '{0}' AND activityID = '{1}' AND userid='{2}'", activityDay, activityID, userID);
                    MySQLDataReader reader  = conn.ExecuteReader(cmdText, new MySQLParameter[0]);
                    while (reader.Read())
                    {
                        int      type     = Convert.ToInt32(reader["type"].ToString());
                        string[] awardArr = reader["state"].ToString().Split(new char[]
                        {
                            '*'
                        });
                        List <int> list = new List <int>();
                        foreach (string s in awardArr)
                        {
                            list.Add(Convert.ToInt32(s));
                        }
                        if (!result.ContainsKey(type))
                        {
                            result.Add(type, list.ToArray());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            client.sendCmd <Dictionary <int, int[]> >(nID, result);
        }
Пример #25
0
        public void SetControls(EditFormMode mode, ITrackableDto dto)
        {
            CheckHelper.ArgumentWithinCondition(
                mode == EditFormMode.Create
                ||
                dto != null && dto.Id > 0 && mode != EditFormMode.Create,
                "Invalid usage");

            switch (mode)
            {
            case EditFormMode.Create:
            {
                var currentUserFullName = GetCurrentUserFullName();
                var localNow            = GetLocalTime();

                _createUserTextBox.Text = currentUserFullName;
                _createDateTextBox.Text = localNow;
                _changeUserTextBox.Text = currentUserFullName;
                _changeDateTextBox.Text = localNow;
            }
            break;

            case EditFormMode.Edit:
            {
                var currentUserFullName = GetCurrentUserFullName();
                var localNow            = GetLocalTime();

                _createUserTextBox.Text = dto.CreateUser;
                _createDateTextBox.Text = dto.CreateDate.ToLocalTime().ToString("F");
                _changeUserTextBox.Text = currentUserFullName;
                _changeDateTextBox.Text = localNow;
            }
            break;

            case EditFormMode.View:
                _createUserTextBox.Text = dto.CreateUser;
                _createDateTextBox.Text = dto.CreateDate.ToLocalTime().ToString("F");
                _changeUserTextBox.Text = dto.ChangeUser;
                _changeDateTextBox.Text = dto.ChangeDate.ToLocalTime().ToString("F");
                break;

            default:
                throw new NotSupportedException(mode.ToString());
            }
        }
Пример #26
0
        /// <summary>
        /// Gets the coordinates and pixel sizes of image.
        /// </summary>
        /// <param name="inputFileInfo">Input GeoTiff file.</param>
        /// <returns>Array of double coordinates and pixel sizes.</returns>
        private static double[] GetGeoTransform(FileInfo inputFileInfo)
        {
            #region Parameters checking

            CheckHelper.CheckFile(inputFileInfo, true);

            #endregion

            //Initialize Gdal, if needed.
            ConfigureGdal();

            using (Dataset inputDataset = OSGeo.GDAL.Gdal.Open(inputFileInfo.FullName, Access.GA_ReadOnly))
            {
                double[] geoTransform = new double[6];
                inputDataset.GetGeoTransform(geoTransform);
                return(geoTransform);
            }
        }
Пример #27
0
 private bool ProcessCmdTodayData(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 1))
         {
             return(false);
         }
         string result = this.GetTodayData(client);
         client.sendCmd(1030, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Пример #28
0
 private bool ProcessCmdUnionPalaceData(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLengthAndRole(client, nID, cmdParams, 1))
         {
             return(false);
         }
         UnionPalaceData data = UnionPalaceManager.UnionPalaceGetData(client, false);
         client.sendCmd <UnionPalaceData>(1035, data, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Пример #29
0
 private bool ProcessCmdPetSkillAwakeCost(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!CheckHelper.CheckCmdLength(client, nID, cmdParams, 1))
         {
             return(false);
         }
         int result = PetSkillManager.GetSkillAwakeCost(PetSkillManager.GetUpCount(client));
         client.sendCmd <int>(1039, result, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Пример #30
0
        protected static void RefreshDataGridView(object[][] rows, DataGridView dataGridView)
        {
            CheckHelper.ArgumentNotNull(rows, "rows");
            CheckHelper.ArgumentNotNull(dataGridView, "dataGridView");

            dataGridView.Rows.Clear();

            foreach (var values in rows)
            {
                var row = new DataGridViewRow {
                    Height = 17
                };

                row.CreateCells(dataGridView, values);

                dataGridView.Rows.Add(row);
            }
        }
Пример #31
0
        /// <summary>
        /// 验证
        /// </summary>
        /// <returns></returns>
        private bool Verify()
        {
            CheckHelper checkHelper = new CheckHelper(this.m_ResultConnection);
            //Init();
            if (m_NormalRuleList == null)
                return false;

            if (m_TopoRuleList == null)
                return false;

            bool isSucceed = true;

            for (int i = 0; i < m_NormalRuleList.Count; i++)
            {
                try
                {
                    SendVerifyingEvent(m_NormalRuleList[i]);
                    if (!m_NormalRuleList[i].Verify())
                    {
                        SendMessage(enumMessageType.VerifyError, string.Format("规则“{0}”验证失败\r\n", m_NormalRuleList[i].InstanceName));
                        m_NormalRuleList.RemoveAt(i);
                        i--;
                        isSucceed = false;
                    }
                    else
                    {
                        checkHelper.AddVerifiedRule(m_DictRuleAndInfo[m_NormalRuleList[i]],m_NormalRuleList[i].ErrorType, enumRuleState.ExecuteFailed);
                    }
                }
                catch (Exception exp)
                {
                    SendMessage(enumMessageType.Exception, exp.ToString());

                    SendMessage(enumMessageType.VerifyError, string.Format("规则“{0}”验证失败\r\n", m_NormalRuleList[i].InstanceName));
                    m_NormalRuleList.RemoveAt(i);
                    i--;
                    isSucceed = false;
                }
            }
            for (int i = 0; i < m_TopoRuleList.Count; i++)
            {
                try
                {
                    SendVerifyingEvent(m_TopoRuleList[i]);
                    if (!m_TopoRuleList[i].Verify())
                    {
                        SendMessage(enumMessageType.VerifyError, string.Format("规则“{0}”验证失败\r\n", m_TopoRuleList[i].InstanceName));
                        m_TopoRuleList.RemoveAt(i);
                        i--;
                        isSucceed = false;
                    }
                    else
                    {
                        checkHelper.AddVerifiedRule(m_DictRuleAndInfo[m_TopoRuleList[i]],m_TopoRuleList[i].ErrorType, enumRuleState.ExecuteFailed);
                    }
                }
                catch (Exception exp)
                {
                    SendMessage(enumMessageType.Exception, exp.ToString());

                    SendMessage(enumMessageType.VerifyError, string.Format("规则“{0}”验证失败{1}\r\n", m_TopoRuleList[i].InstanceName,exp.Message));
                    m_TopoRuleList.RemoveAt(i);
                    i--;
                    isSucceed = false;
                }
            }

            if (this.VerifyedComplete != null)
                this.VerifyedComplete.Invoke(this,m_NormalRuleList.Count + m_TopoRuleList.Count);

            return isSucceed;
        }
Пример #32
0
        /// <summary>
        /// 执行检查
        /// </summary>
        /// <returns></returns>
        public bool Check()
        {
            //初始化
            Init();

            if (m_NormalRuleList == null && m_TopoRuleList == null)
            {
                SendMessage(enumMessageType.RuleError, "没有可检查的规则,检查结束");
                return false;
            }

            // 验证
            Verify();

            ReOpenTopo();

            // 预处理
            Pretreat();

            if (m_NormalRuleList.Count == 0 && m_TopoRuleList.Count == 0)
            {
                SendMessage(enumMessageType.RuleError, "没有可检查的规则,检查结束");
                return false;
            }

            bool isSucceed = true;
            ErrorHelper errHelper = ErrorHelper.Instance;
            errHelper.ResultConnection = this.m_ResultConnection;
            CheckHelper checkHelper = new CheckHelper(this.m_ResultConnection);

            // 自动检查
            for (int i = 0; i < m_NormalRuleList.Count; i++)
            {
                SendCheckingEvent(m_NormalRuleList[i]);
                SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”开始检查", m_NormalRuleList[i].InstanceName));

                List<Error> errList = new List<Error>();
                int errCount = 0;
                try
                {
                    bool ruleSucceed = m_NormalRuleList[i].Check(ref errList);
                    if (ruleSucceed)
                    {
                        this.m_SucceedCount++;
                        if (errList != null)
                            errCount = errList.Count;

                        this.m_ErrorCount += 0;
                        SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”检查成功,错误数:{1}\r\n", m_NormalRuleList[i].InstanceName, errCount));

                        checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_NormalRuleList[i]].arrayRuleParas[0].strInstID, errCount, enumRuleState.ExecuteSucceed);
                    }
                    else
                    {
                        // 添加时默认了为失败,不用更新
                        //checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_NormalRuleList[i]].arrayRuleParas[0].strInstID, 0, enumRuleState.ExecuteFailed);

                        SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”检查失败\r\n", m_NormalRuleList[i].InstanceName));
                        isSucceed = false;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    // 添加时默认了为失败,不用更新
                    //checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_NormalRuleList[i]].arrayRuleParas[0].strInstID, 0, enumRuleState.ExecuteFailed);

                    SendMessage(enumMessageType.Exception, string.Format("规则“{0}”检查失败,信息:{1}\r\n", m_NormalRuleList[i].InstanceName, ex.Message));
                    continue;
                }
                finally
                {
                    // 无论如何,检查完成了
                    SendRuleCheckedEvent(m_NormalRuleList[i], errCount);
                }

                errHelper.AddErrorList(errList);
            }

            // Topo检查
                // 由本类在Init方法中创建拓扑
                // 在Topo规则的预处理中进行拓扑规则添加
                // 在这里统一进行拓扑验证
                // 规则的Hy.Check方法只负责错误结果的读取
            if (m_TopoRuleList.Count > 0)
            {
                if (this.TopoRuleCheckBegin != null)
                    this.TopoRuleCheckBegin.Invoke(this);

                if (this.m_Topology != null)
                {
                    this.m_Topology.ValidateTopology((this.m_Topology.FeatureDataset as IGeoDataset).Extent);
                }

                for (int i = 0; i < m_TopoRuleList.Count; i++)
                {
                    SendCheckingEvent(m_TopoRuleList[i]);
                    SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”开始获取(拓扑)结果", m_TopoRuleList[i].InstanceName));

                    List<Error> errList = new List<Error>();
                    int errCount = 0;
                    try
                    {
                        bool ruleSucceed = m_TopoRuleList[i].Check(ref errList);
                        if (ruleSucceed)
                        {
                            this.m_SucceedCount++;
                            if (errList != null)
                                errCount = errList.Count;

                            this.m_ErrorCount += errCount;
                            SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”获取(拓扑)结果成功,错误数:{1}\r\n", m_TopoRuleList[i].InstanceName, errCount));

                            checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_TopoRuleList[i]].arrayRuleParas[0].strInstID, errCount, enumRuleState.ExecuteSucceed, m_TopoRuleList[i].InstanceName);
                        }
                        else
                        {

                            // 添加时默认了为失败,不用更新
                            //checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_TopoRuleList[i]].arrayRuleParas[0].strInstID, 0, enumRuleState.ExecuteFailed,m_TopoRuleList[i].InstanceName);

                            SendMessage(enumMessageType.RuleError, string.Format("规则“{0}”获取(拓扑)结果失败\r\n", m_TopoRuleList[i].InstanceName));
                            isSucceed = false;
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {

                        // 添加时默认了为失败,不用更新
                        //checkHelper.UpdateRuleState(m_DictRuleAndInfo[m_TopoRuleList[i]].arrayRuleParas[0].strInstID, 0, enumRuleState.ExecuteFailed,m_TopoRuleList[i].InstanceName);

                        SendMessage(enumMessageType.Exception, string.Format("规则“{0}”获取(拓扑)结果失败,信息:{1}\r\n", m_TopoRuleList[i].InstanceName, ex.Message));
                        continue;
                    }
                    finally
                    {
                        // 无论如何,检查完成了
                        SendRuleCheckedEvent(m_TopoRuleList[i], errCount);
                    }

                    errHelper.AddErrorList(errList);
                }
            }

            errHelper.Flush();
            this.Release();

            if (this.CheckComplete != null)
                this.CheckComplete.Invoke(this);

            return isSucceed;
        }