Example #1
0
        public void GetRulesFromRuleCategory()
        {
            try
            {
                RuleCategory rc = new RuleCategory();
                rc.Name       = "دسته قانون001";
                rc.CustomCode = "00-00test2";

                decimal[] ids   = new decimal[10];
                int       count = 0;
                foreach (DatabaseGateway.TA_RuleTemplateRow item in ruleTmpTA.GetDataByTopCount(10))
                {
                    ids[count] = (decimal)item["RuleTmp_ID"];
                    count++;
                }
                rc.InsertedTemplateIDs = ids;

                decimal id = businessCategory.SaveChanges(rc, UIActionType.ADD);
                ClearSession();
                Assert.AreEqual(10, businessCategory.GetRulesByRuleCatID(id).Count());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <RuleCategory> GetAvailableCategories()
        {
            List <RuleCategory> ret = new List <RuleCategory>();

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand("RUlesEngine.spa_GetRulesCategories", conn))
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandTimeout = 360;

                    conn.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (reader.Read())
                        {
                            int?parentCategoryId = string.IsNullOrWhiteSpace(reader["ParentCategoryId"].ToString()) ? (int?)null :int.Parse(reader["ParentCategoryId"].ToString());

                            var tempCat = new RuleCategory
                            {
                                ParentCategoryId = parentCategoryId,
                                CategoryName     = reader["CategoryName"].ToString(),
                                RuleCategoryId   = int.Parse(reader["RuleCategoryId"].ToString())
                            };

                            ret.Add(tempCat);
                        }
                    }

                    conn.Close();
                }

            return(ret);
        }
Example #3
0
        public void GetChilds_Test()
        {
            dataAccessRuleTA.Insert(BUser.CurrentUser.ID, AdoRuleCat.ID, false);

            RuleCategory root = businessCategory.GetRoot();

            Assert.AreEqual(1, root.ChildList.Count);
        }
Example #4
0
        protected void Button43_Click(object sender, EventArgs e)
        {
            BRuleCategory bus = new BRuleCategory();
            RuleCategory  cat = new RuleCategory();

            cat.Name = "sadfdsfsd";
            cat.InsertedTemplateIDs = new decimal[] { 1 };
            bus.SaveChanges(cat, UIActionType.ADD);
        }
Example #5
0
        ///// <summary>
        ///// 遍历清除文本框内容
        ///// 2013-01-10
        ///// </summary>
        ///// <param name="gc"></param>
        //private void ClearText(GroupControl gc)
        //{
        //    try
        //    {
        //        foreach (Control ctl in gc.Controls)
        //        {
        //            Type type = ctl.GetType();
        //            if (type == typeof(TextEdit))
        //            {
        //                TextEdit textEdit = ctl as TextEdit;
        //                if (textEdit != null)
        //                {
        //                    textEdit.Text = string.Empty;
        //                }
        //            }
        //            else if (type == typeof(ComboBoxEdit))
        //            {
        //                ComboBoxEdit cmbEdit = ctl as ComboBoxEdit;
        //                if (cmbEdit != null)
        //                {
        //                    cmbEdit.SelectedIndex = -1;
        //                }
        //            }
        //            else if (type == typeof(LookUpEdit))
        //            {
        //                LookUpEdit lookUpEdit = ctl as LookUpEdit;
        //                if (lookUpEdit != null)
        //                {
        //                    lookUpEdit.EditValue = string.Empty;
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        #endregion

        /// <summary>
        /// 保存方法
        /// xlb 2013-01-06
        /// </summary>
        private void SaveCurrentRule()
        {
            try
            {
                string message = "";
                bool   result  = Validate(ref message);
                if (!result)
                {
                    MessageBox.Show(message);
                    return;
                }
                QCRule       qcRule       = new QCRule();
                RuleCategory ruleCategory = new RuleCategory();
                QCCondition  qcCondition  = new QCCondition();
                qcRule.RuleCode    = textBoxRuleId.Text.Trim();
                qcCondition.Code   = lookUpEditConditionName.EditValue.ToString();
                qcRule.TimeLimit   = TimesToSeconds(textBoxRuleTime.Text);
                qcRule.Description = textBoxRuleName.Text.Trim();

                qcRule.DoctorLevel = (DoctorGrade)Enum.Parse(typeof(DoctorGrade), lookUpEditDoctorLevel.EditValue.ToString());
                qcRule.Reminder    = textBoxTipInfo.Text.Trim();
                qcRule.FoulMessage = textBoxWarningInfo.Text.Trim();
                if (comboBoxOpMode.SelectedIndex >= 0)
                {
                    qcRule.MARK = (OperationType)comboBoxOpMode.SelectedIndex;
                }
                else
                {
                    qcRule.MARK = OperationType.OnlyOne;
                }
                qcRule.CycleTimes    = int.Parse(textEditLooptimes.Text == "" ? "0" : textEditLooptimes.Text.Trim());
                qcRule.CycleInterval = TimesToSeconds(textEditLoopinterval.Text == "" ? "0" : textEditLoopinterval.Text.Trim());
                qcRule.DelayTime     = int.Parse(spinEditDelayTime.Value.ToString());
                qcRule.Sorce         = double.Parse(spinEditScore.Text == "" ? "0" : spinEditScore.Text.Trim());
                qcRule.QCCode        = lookUpEditQcCode.EditValue.ToString();
                qcRule.Memo          = textEditRuleMemo.Text.Trim();
                ruleCategory.Code    = lookUpEditRuleGroup.EditValue.ToString();
                qcRule.Valid         = checkEditValid.Checked ? "1" : "0";
                if (editstate == EditSate.Edit)
                {
                    QCRule.UpdateQcRule(qcRule, qcCondition, ruleCategory);
                    MessageBox.Show("修改成功");
                }
                else if (editstate == EditSate.Add)
                {
                    QCRule.InsertQcRule(qcRule, qcCondition, ruleCategory);
                    MessageBox.Show("添加成功");
                }
                InitDataRule();
                SetRuleEditState(false, false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #6
0
 public void DeleteCategory(RuleCategory removeThis)
 {
     while (removeThis.RuleCategories.Count > 0)
     {
         this.DeleteCategory(removeThis.RuleCategories[0]);
     }
     foreach (Rule current in removeThis.Rules)
     {
         this.observableCollection_0.Remove(current);
     }
     this.ruleSet_0.Remove(removeThis);
 }
Example #7
0
 internal void method_12(RuleCategory ruleCategory_0)
 {
     foreach (RuleCategory current in ruleCategory_0.RuleCategories)
     {
         this.method_12(current);
     }
     foreach (Rule current2 in ruleCategory_0.Rules)
     {
         if (current2.Active)
         {
             this.method_14(current2, true);
         }
     }
 }
Example #8
0
 public void Delete_RootTest()
 {
     try
     {
         RuleCategory RC = businessCategory.GetRoot();
         ClearSession();
         businessCategory.SaveChanges(RC, UIActionType.DELETE);
         Assert.Fail();
     }
     catch (UIValidationExceptions ex)
     {
         Assert.AreEqual(ex.ExceptionList[0].ResourceKey, ExceptionResourceKeys.RuleCategoryRootDeleteIllegal);
     }
 }
Example #9
0
 public void Copy_InsertRuleCat_Test()
 {
     try
     {
         decimal newId = businessCategory.CopyRuleCategory(AdoRuleCat.ID).ID;
         ClearSession();
         ruleCat_testObject = businessCategory.GetByID(newId);
         Assert.AreEqual(newId, ruleCat_testObject.ID);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Example #10
0
        public void Update_RuleCategoryWithRulesTest()
        {
            try
            {
                ///////////////////////// اضافه نمودن دسته قانون شامل 10 قانون

                RuleCategory InsertRleCat = new RuleCategory();
                InsertRleCat.Name       = "دسته قانون001";
                InsertRleCat.CustomCode = "00-00test1";

                decimal[] ids   = new decimal[16];
                int       count = 0;
                foreach (DatabaseGateway.TA_RuleTemplateRow item in ruleTmpTA.GetDataByTopCount(10).OrderBy(x => x.RuleTmp_ID))
                {
                    ids[count] = (decimal)item["RuleTmp_ID"];
                    count++;
                }
                InsertRleCat.InsertedTemplateIDs = ids;
                decimal id = businessCategory.SaveChanges(InsertRleCat, UIActionType.ADD);

                //////////////////////////

                ClearSession();
                RuleCategory UpdateRleCat = new RuleCategory();
                UpdateRleCat.ID          = id;
                UpdateRleCat.Name        = "دسته قانون001 اصلاح شده";
                UpdateRleCat.Discription = "";

                //حذف 4 قانون با کم نمودن شمارنده
                count = 0;
                UpdateRleCat.DeletedTemplateIDs  = ids.OrderByDescending(x => x).Take(4).ToArray <decimal>();
                UpdateRleCat.InsertedTemplateIDs = new decimal[10];
                /////////////////////////بروزرسانی دسته قانون به همراه اضافه کردن 10 قانون
                foreach (DatabaseGateway.TA_RuleTemplateRow item in ruleTmpTA.GetDataByTopCount(20).OrderByDescending(x => x.RuleTmp_ID))
                {
                    UpdateRleCat.InsertedTemplateIDs[count] = (decimal)item["RuleTmp_ID"];
                    count++;
                    if (count == 10)
                    {
                        break;
                    }
                }
                id = businessCategory.SaveChanges(UpdateRleCat, UIActionType.EDIT);
                Assert.AreEqual(17, ruleTA.GetCountByCatId(id));
            }
            finally
            {
            }
        }
Example #11
0
        private IList <RuleDetail> GetActiveRule(bool isFutureBooking, RuleCategory category)
        {
            using (var context = _contextFactory.Invoke())
            {
                var rules = context.Query <RuleDetail>().Where(r => (r.Category == (int)category) &&
                                                               ((!isFutureBooking &&
                                                                 r.AppliesToCurrentBooking) ||
                                                                (isFutureBooking &&
                                                                 r.AppliesToFutureBooking)) &&
                                                               r.IsActive)
                            .OrderBy(r => r.Priority).ToList();

                return(rules);
            }
        }
Example #12
0
        public void CreateRule(Guid ruleId, string name, string message, string zoneList, bool zoneRequired, RuleType type,
                               RuleCategory category, bool appliedToCurrentBooking, bool appliesToFutureBooking, bool appliesToPickup, bool appliesToDropoff, int priority,
                               bool isActive, DayOfTheWeek daysOfTheWeek, DateTime?startTime, DateTime?endTime, DateTime?activeFrom,
                               DateTime?activeTo, string market, bool disableFutureBookingOnError)
        {
            if ((type == RuleType.Default) && message.IsNullOrEmpty())
            {
                throw new InvalidOperationException(string.Format("Missing message for default rule - category {0}",
                                                                  category));
            }
            if ((type == RuleType.Recurring) &&
                (Params.Get(message, name).Any(s => s.IsNullOrEmpty()) || (daysOfTheWeek == DayOfTheWeek.None) ||
                 (!startTime.HasValue) || (!endTime.HasValue)))
            {
                throw new InvalidOperationException("Missing message for recurrring rule");
            }
            if ((type == RuleType.Date) &&
                (Params.Get(message, name).Any(s => s.IsNullOrEmpty()) || (!activeFrom.HasValue) ||
                 (!activeFrom.HasValue)))
            {
                throw new InvalidOperationException("Missing message for date rule");
            }


            Update(new RuleCreated
            {
                RuleId                      = ruleId,
                Type                        = type,
                Name                        = name,
                Message                     = message,
                ZoneList                    = zoneList,
                ZoneRequired                = zoneRequired,
                Category                    = category,
                AppliesToCurrentBooking     = appliedToCurrentBooking,
                AppliesToFutureBooking      = appliesToFutureBooking,
                AppliesToPickup             = appliesToPickup,
                AppliesToDropoff            = appliesToDropoff,
                IsActive                    = isActive,
                DaysOfTheWeek               = daysOfTheWeek,
                StartTime                   = startTime,
                EndTime                     = endTime,
                ActiveFrom                  = activeFrom,
                ActiveTo                    = activeTo,
                Priority                    = priority,
                Market                      = market,
                DisableFutureBookingOnError = disableFutureBookingOnError
            });
        }
Example #13
0
 public void Update_ValidationDuplicateNameTest()
 {
     try
     {
         RuleCategory rc = new RuleCategory()
         {
             ID = -1, Name = "دسته قانون000"
         };
         businessCategory.SaveChanges(rc, UIActionType.EDIT);
         Assert.Fail("نام تکراری نباید درج شود");
     }
     catch (UIValidationExceptions ex)
     {
         Assert.AreEqual(ex.ExceptionList[0].ResourceKey, ExceptionResourceKeys.RuleCategoryNameRepeated);
     }
 }
Example #14
0
 public void Update_ValidateEmptyName()
 {
     try
     {
         RuleCategory rc = new RuleCategory()
         {
             ID = AdoRuleCat.ID, Name = "", CustomCode = "00-00test1"
         };
         businessCategory.SaveChanges(rc, UIActionType.ADD);
         Assert.Fail("نام خالی نباید درج شود");
     }
     catch (UIValidationExceptions ex)
     {
         Assert.AreEqual(ex.ExceptionList[0].ResourceKey, ExceptionResourceKeys.RuleCategoryNameRequierd);
     }
 }
Example #15
0
        /// <summary>
        /// 初始化时限规则数据集
        /// by xlb 2013-01-05
        /// </summary>
        private void InitDataRule()
        {
            try
            {
                Dictionary <string, QCCondition>  dictQCCondition  = QCCondition.GetAllQCCondition();
                Dictionary <string, RuleCategory> dictRuleCategory = RuleCategory.GetAllRuleCategory();
                IList <QCRule> listRule = QCRule.GetRuleList(dictQCCondition, dictRuleCategory);

                gridControlRule.DataSource = listRule;
                gridViewRule.ExpandAllGroups();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #16
0
        /// <summary>
        /// شناسه گروه قانون بمنظور استفاده در عملیات دریافت میگردد
        /// </summary>
        /// <param name="ruleCategoryId"></param>
        public BRuleViewer(decimal ruleCategoryId)
        {
            RuleCategoryRepository repository = new RuleCategoryRepository(false);
            IList <RuleCategory>   list       = repository.GetByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new RuleCategory().ID), ruleCategoryId));

            if (list.Count == 1)
            {
                workingRuleCategory = list[0];
            }
            else
            {
                UIValidationExceptions exception = new UIValidationExceptions();
                exception.Add(ExceptionResourceKeys.RuleCategoryIdIsInValid, "پارامتر ارسال شده معرف دسته قانون نمیباشد", ExceptionSrc);
                throw exception;
            }
        }
 /// <summary>
 /// 初始化数据
 /// </summary>
 private void InitData()
 {
     try
     {
         m_DictQCCondition = QCCondition.GetAllQCCondition();
         m_DictQCCategory  = RuleCategory.GetAllRuleCategory();
         //获得所有QCRule,包括有效和无效
         m_DictQCRuleAll = QCRule.GetAllQCRule(m_DictQCCondition, m_DictQCCategory);
         m_ListQCRecord  = QCRecord.GetAllQCRecord(m_DictQCRuleAll, m_DictQCCondition, m_DictQCCategory);
         //获得所有有效的QCRule
         m_DictQCRuleValid = QCRule.GetAllQCRuleValid(m_DictQCCondition, m_DictQCCategory);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #18
0
 public void Insert_ValidationDuplicateNameTest()
 {
     try
     {
         RuleCategory rc = new RuleCategory()
         {
             Name = "دسته قانون000", InsertedTemplateIDs = new decimal[2] {
                 1, 2
             }
         };
         businessCategory.SaveChanges(rc, UIActionType.ADD);
         Assert.Fail("نام تکراری نباید درج شود");
     }
     catch (UIValidationExceptions ex)
     {
         Assert.AreEqual(ex.ExceptionList[0].ResourceKey, ExceptionResourceKeys.RuleCategoryNameRepeated);
     }
 }
Example #19
0
        private bool IsTargetRuleBlock(Block block, RuleCategory ruleCategory)
        {
            var gameConfig = m_logicGameManager.GameManager.gameConfig;

            var entityConfig = gameConfig.GetEntityConfig(block.entityType);

            if (entityConfig.category != EntityCategory.Rule)
            {
                return(false);
            }

            if (entityConfig.ruleCategory != ruleCategory)
            {
                return(false);
            }

            return(true);
        }
Example #20
0
 /// <summary>
 /// 初始化LookUpEdit控件
 /// by xlb 2013-01-06
 /// </summary>
 private void InitRuleCategoryName()
 {
     try
     {
         DataTable dtRuleCategoryName = RuleCategory.GetAllRuleCategorys();
         lookUpEditRuleGroup.Properties.DataSource = dtRuleCategoryName;
         AddLookupColumnInfo(lookUpEditRuleGroup, new KeyValuePair <string, string>[] {
             new KeyValuePair <string, string>("CODE", RuleCategory.cstFieldCaptionId),
             new KeyValuePair <string, string>("DESCRIPTION", RuleCategory.cstFieldCaptionDescript)
         });
         lookUpEditRuleGroup.Properties.DisplayMember = "DESCRIPTION";
         lookUpEditRuleGroup.Properties.ValueMember   = "CODE";
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #21
0
 public void Insert_ValidateEmptyName()
 {
     try
     {
         RuleCategory rc = new RuleCategory()
         {
             Name = "", InsertedTemplateIDs = new decimal[2] {
                 1, 2
             }
         };
         businessCategory.SaveChanges(rc, UIActionType.ADD);
         Assert.Fail("نام خالی نباید درج شود");
     }
     catch (UIValidationExceptions ex)
     {
         Assert.AreEqual(ex.ExceptionList[0].ResourceKey, ExceptionResourceKeys.RuleCategoryNameRequierd);
     }
 }
Example #22
0
        public void TestSetup()
        {
            businessCategory   = new BRuleCategory();
            ruleCat_testObject = new RuleCategory();

            Convert.ToInt32(personTA.InsertQuery("0000", "Ali", true, null));
            int personId = Convert.ToInt32(personTA.GetDataByBarcode("0000").Rows[0]["prs_ID"]);


            ruleCatTA.Insert("دسته قانون000", "0000", false, "00-00test1");
            table           = ruleCatTA.GetDataByName("دسته قانون000");
            AdoRuleCat.ID   = (Decimal)table[0]["RuleCat_ID"];
            AdoRuleCat.Name = (String)table[0]["RuleCat_Name"];

            prsRleCatAsgTA.Insert(personId, AdoRuleCat.ID, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortDateString(), DateTime.Now);

            ruleCAtPartTA.Insert(businessCategory.GetRoot().ID, AdoRuleCat.ID, true);

            ClearSession();
        }
        public TestXmlFile(Stream testFileContent, RuleCategory ruleCategory)
        {
            var xdoc = new XmlDocument();

            using (var xtr = new XmlTextReader(testFileContent))
            {
                xtr.Read();
                xdoc.LoadXml(xtr.ReadOuterXml());
            }

            var xpath = default(string);

            switch (ruleCategory)
            {
            case RuleCategory.All:              xpath = "//example";                 break;

            case RuleCategory.IndirectSpeech:   xpath = "//IndirectSpeech//example"; break;

            case RuleCategory.DirectSpeech:     xpath = "//DirectSpeech//example";   break;

            default: throw (new ArgumentException(ruleCategory.ToString()));
            }

            TestRules = new ReadOnlyCollection <TestRule>
                        (
                (from ruleNode in xdoc.SelectNodes(xpath).Cast <XmlNode>()
                 let text = ruleNode.InnerText
                            where !text.IsEmptyOrNull()
                            let pattern_id = ruleNode.SelectSingleNode("./ancestor::pattern/@id")
                                             where pattern_id.IsNotNull()
                                             let id = pattern_id.Value
                                                      where !id.IsEmptyOrNull()
                                                      select new TestRule(id, text)
                ).ToList()
                        );
        }
Example #24
0
        public void Insert_RuleCategoryWithRulesTest()
        {
            try
            {
                RuleCategory rc = new RuleCategory();
                rc.Name       = "دسته قانون001";
                rc.CustomCode = "00-00test1";

                decimal[] ids   = new decimal[10];
                int       count = 0;
                foreach (DatabaseGateway.TA_RuleTemplateRow item in ruleTmpTA.GetDataByTopCount(10))
                {
                    ids[count] = (decimal)item["RuleTmp_ID"];
                    count++;
                }
                rc.InsertedTemplateIDs = ids;
                decimal id = businessCategory.SaveChanges(rc, UIActionType.ADD);
                Assert.AreNotEqual(id, 0);
                Assert.AreEqual(10, ruleTA.GetCountByCatId(id));
            }
            finally
            {
            }
        }
Example #25
0
 private bool Equals(RuleCategory other)
 {
     return(string.Equals(Name, other.Name));
 }
Example #26
0
 private static DiagnosticDescriptor Rule(string id, string title, RuleCategory category, DiagnosticSeverity defaultSeverity, string messageFormat, string description = null)
 {
     return(new DiagnosticDescriptor(id, title, messageFormat, category.Name, defaultSeverity, true, description, $"https://jokokko.github.io/reviewhelp.analyzers/rules/{id}"));
 }
Example #27
0
    public string[] UpdateRuleGroup_RulesGroupUpdatePage(string state, string SelectedRuleGroupID, string RuleGroupName, string RuleGroupDescriptions, string RulesList)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            AttackDefender.CSRFDefender(this.Page);
            decimal RuleGroupID         = 0;
            decimal selectedRuleGroupID = decimal.Parse(this.StringBuilder.CreateString(SelectedRuleGroupID), CultureInfo.InvariantCulture);
            RuleGroupName         = this.StringBuilder.CreateString(RuleGroupName);
            RuleGroupDescriptions = this.StringBuilder.CreateString(RuleGroupDescriptions);
            Dictionary <string, decimal[]> rulesListDic = this.CreateRulesListArray_RulesGroupUpdate(this.StringBuilder.CreateString(RulesList));
            UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());

            RuleCategory ruleGroup = new RuleCategory();
            ruleGroup.Name        = RuleGroupName;
            ruleGroup.Discription = RuleGroupDescriptions;

            switch (uam)
            {
            case UIActionType.ADD:
                ruleGroup.ID = 0;
                ruleGroup.InsertedTemplateIDs = rulesListDic["AddedRules"];

                ruleGroup.IsGroup  = false;
                ruleGroup.ParentId = selectedRuleGroupID;

                RuleGroupID = this.RulesGroupBusiness.InsertRuleGroup(ruleGroup, uam);
                break;

            case UIActionType.EDIT:
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoRuleGroupSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup.ID = selectedRuleGroupID;
                    ruleGroup.InsertedTemplateIDs = rulesListDic["AddedRules"];
                    ruleGroup.DeletedTemplateIDs  = rulesListDic["DeletedRules"];
                }
                RuleGroupID = this.RulesGroupBusiness.UpdateRuleGroup(ruleGroup, uam);
                break;
            }


            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            string SuccessMessageBody = string.Empty;
            switch (uam)
            {
            case UIActionType.ADD:
                SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                break;

            case UIActionType.EDIT:
                SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                break;

            default:
                break;
            }
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = RuleGroupID.ToString();
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }
        protected void runTestButton_Click(object sender, EventArgs e)
        {
            #region [.set controls state.]
            runTestButton.Visible         = false;
            testFileUpload1.Visible       = false;
            testFileUpload2.Visible       = false;
            showOnlyErrorCheckBox.Visible = false;
            ruleCategoryDropDownList
            .Visible = false;
            againHyperLink1.Visible = true; againHyperLink1.NavigateUrl = NAVIGATE_URL.FormatEx(RuleCategory.ToString(), ShowOnlyError);
            againHyperLink2.Visible = true; againHyperLink2.NavigateUrl = NAVIGATE_URL.FormatEx(RuleCategory.ToString(), ShowOnlyError);
            //repeatLinkButton1    .Visible = true;
            //repeatLinkButton2    .Visible = true;
            backHyperLink2.Visible = true;
            #endregion

            #region [.read text-file.]
            var testXmlFile = new TestXmlFile(TestFileContent, RuleCategory);
            #endregion

            resultDiv.Controls.Add(new Label()
            {
                Text = ruleCategoryDropDownList.SelectedItem.Text.InBrackets()
            });
            resultDiv.Controls.AddHr();

            #region [.test.]
            var errorCount = 0;
            foreach (var rule in testXmlFile.TestRules)
            {
                try
                {
                    var result = GetOpinionMiningOutputResult(rule);

                    #region [.check.]
                    if (result.OperateRulesNames == null)
                    {
                        throw (new TestException(rule.Text.ToHtmlBold().InSingleQuotes() +
                                                 "<br/> - не сработало ни одно правило" +
                                                 ", должно " + rule.Id.ToHtmlBold()));
                    }
                    else if (result.OperateRulesNames.Count != 1)
                    {
                        throw (new TestException(rule.Text.ToHtmlBold().InSingleQuotes() +
                                                 "<br/> - должно &nbsp;&nbsp;&nbsp; " + rule.Id.ToHtmlBold().InSingleQuotes() +
                                                 "<br/>,  сработало " + result.OperateRulesNames.Count + " правил(а): " + result.OperateRulesNames.ToHtml()));
                    }
                    else if (!rule.Id.Equals(result.OperateRulesNames.First(), StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw (new TestException(rule.Text.ToHtmlBold().InSingleQuotes() +
                                                 "<br/> - должно &nbsp;&nbsp;&nbsp; " + rule.Id.ToHtmlBold() +
                                                 "<br/>,  сработало " + result.OperateRulesNames.First().ToString().ToHtmlBold()));
                    }
                    #endregion

                    if (ShowOnlyError)
                    {
                        continue;
                    }

                    resultDiv.Controls.AddDiv4OkMessage(rule);
                }
                catch (Exception ex)
                {
                    #region
                    errorCount++;

                    resultDiv.Controls.AddDiv4ExceptionMessage(ex, rule);

                    if (ex is CommunicationException)
                    {
                        resultDiv.Controls.AddDiv("....выполниение теста прервано....");
                        return;
                    }
                    #endregion
                }
                resultDiv.Controls.AddHr();
            }

            resultDiv.Controls.AddDiv4FinalMessage(testXmlFile, errorCount);
            #endregion
        }
Example #29
0
        public void RootIsNotNullTest()
        {
            RuleCategory root = businessCategory.GetRoot();

            Assert.IsNotNull(root);
        }
Example #30
0
    public string[] UpdatePersonnelMultiDateFeature_PersonnelMultiDateFeaturesPage(string caller, string state, string SelectedPersonnelMultiDateFeatureID, string PersonnelID, string MultiDateFeatureID, string MultiDateFeatureName, string FromDate, string ToDate, string PersonnelState)
    {
        this.InitializeCulture();

        string[] retMessage = new string[6];

        Caller       PersonnelMultiDateFeatureCaller     = (Caller)Enum.Parse(typeof(Caller), this.StringBuilder.CreateString(caller));
        decimal      PersonnelMultiDateFeatureID         = 0;
        decimal      selectedPersonnelMultiDateFeatureID = decimal.Parse(this.StringBuilder.CreateString(SelectedPersonnelMultiDateFeatureID), CultureInfo.InvariantCulture);
        decimal      personnelID        = decimal.Parse(this.StringBuilder.CreateString(PersonnelID), CultureInfo.InvariantCulture);
        decimal      multiDateFeatureID = decimal.Parse(this.StringBuilder.CreateString(MultiDateFeatureID), CultureInfo.InvariantCulture);
        UIActionType personnelState     = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(PersonnelState).ToUpper());

        MultiDateFeatureName = this.StringBuilder.CreateString(MultiDateFeatureName);
        FromDate             = this.StringBuilder.CreateString(FromDate);
        ToDate = this.StringBuilder.CreateString(ToDate);
        string CurrentActiveMultiDateFeatureName = string.Empty;

        string NoItemSelectedforEditMessage   = string.Empty;
        string NoItemSelectedforDeleteMessage = string.Empty;

        switch (PersonnelMultiDateFeatureCaller)
        {
        case Caller.RuleGroups:
            NoItemSelectedforEditMessage   = this.GetLocalResourceObject("NoRuleGroupPersonnelMultiDateFeatureselectedforEdit").ToString();
            NoItemSelectedforDeleteMessage = this.GetLocalResourceObject("NoRuleGroupPersonnelMultiDateFeatureselectedforDelete").ToString();
            break;

        case Caller.Contracts:
            NoItemSelectedforEditMessage   = this.GetLocalResourceObject("NoContractPersonnelMultiDateFeatureselectedforEdit").ToString();
            NoItemSelectedforDeleteMessage = this.GetLocalResourceObject("NoContractPersonnelMultiDateFeatureselectedforDelete").ToString();
            break;
        }

        UIActionType uam = UIActionType.ADD;

        try
        {
            AttackDefender.CSRFDefender(this.Page);
            switch (this.StringBuilder.CreateString(state))
            {
            case "Add":
                uam = UIActionType.ADD;
                break;

            case "Edit":
                uam = UIActionType.EDIT;
                if (selectedPersonnelMultiDateFeatureID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(NoItemSelectedforEditMessage), retMessage);
                    return(retMessage);
                }
                break;

            case "Delete":
                uam = UIActionType.DELETE;
                if (selectedPersonnelMultiDateFeatureID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(NoItemSelectedforDeleteMessage), retMessage);
                    return(retMessage);
                }
                break;

            default:
                break;
            }

            switch (PersonnelMultiDateFeatureCaller)
            {
            case Caller.RuleGroups:
                PersonRuleCatAssignment personnelRuleGroup = new PersonRuleCatAssignment();
                personnelRuleGroup.ID     = selectedPersonnelMultiDateFeatureID;
                personnelRuleGroup.Person = new Person()
                {
                    ID = personnelID
                };
                if (uam != UIActionType.DELETE)
                {
                    Person person = new Person();
                    person.ID = personnelID;
                    personnelRuleGroup.Person = person;
                    RuleCategory ruleGroup = new RuleCategory();
                    ruleGroup.ID   = multiDateFeatureID;
                    ruleGroup.Name = MultiDateFeatureName;
                    personnelRuleGroup.RuleCategory = ruleGroup;
                    personnelRuleGroup.UIFromDate   = FromDate;
                    personnelRuleGroup.UIToDate     = ToDate;
                }
                switch (personnelState)
                {
                case UIActionType.ADD:
                    switch (uam)
                    {
                    case UIActionType.ADD:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.InsertAssignRule_OnPersonnelInsert(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;

                    case UIActionType.EDIT:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.UpdateAssignRule_OnPersonnelInsert(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;

                    case UIActionType.DELETE:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.DeleteAssignRule_OnPersonnelInsert(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;
                    }
                    break;

                case UIActionType.EDIT:
                    switch (uam)
                    {
                    case UIActionType.ADD:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.InsertAssignRule_OnPersonnelUpdate(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;

                    case UIActionType.EDIT:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.UpdateAssignRule_OnPersonnelUpdate(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;

                    case UIActionType.DELETE:
                        PersonnelMultiDateFeatureID       = this.bAssignRule.DeleteAssignRule_OnPersonnelUpdate(personnelRuleGroup, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveRuleGroup(personnelID);
                        break;
                    }
                    break;
                }
                break;

            case Caller.Contracts:
                PersonContractAssignment personContractAssignment = new PersonContractAssignment();
                personContractAssignment.ID     = selectedPersonnelMultiDateFeatureID;
                personContractAssignment.Person = new Person()
                {
                    ID = personnelID
                };
                if (uam != UIActionType.DELETE)
                {
                    Contract contract = new Contract();
                    contract.ID    = multiDateFeatureID;
                    contract.Title = MultiDateFeatureName;
                    personContractAssignment.Contract   = contract;
                    personContractAssignment.UIFromDate = FromDate;
                    personContractAssignment.UIToDate   = ToDate;
                }
                switch (personnelState)
                {
                case UIActionType.ADD:
                    switch (uam)
                    {
                    case UIActionType.ADD:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.InsertContract_OnPersonnelInsert(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;

                    case UIActionType.EDIT:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.UpdateContract_OnPersonnelInsert(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;

                    case UIActionType.DELETE:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.DeleteContract_OnPersonnelInsert(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;
                    }
                    break;

                case UIActionType.EDIT:
                    switch (uam)
                    {
                    case UIActionType.ADD:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.InsertContract_OnPersonnelUpdate(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;

                    case UIActionType.EDIT:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.UpdateContract_OnPersonnelUpdate(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;

                    case UIActionType.DELETE:
                        PersonnelMultiDateFeatureID       = this.bPersonContractAssignment.DeleteContract_OnPersonnelUpdate(personContractAssignment, uam);
                        CurrentActiveMultiDateFeatureName = this.PersonBusiness.GetCurrentActiveContract(personnelID);
                        break;
                    }
                    break;
                }
                break;
            }

            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            string SuccessMessageBody = string.Empty;
            switch (uam)
            {
            case UIActionType.ADD:
                SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                break;

            case UIActionType.EDIT:
                SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                break;

            case UIActionType.DELETE:
                SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                break;

            default:
                break;
            }
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = PersonnelMultiDateFeatureID.ToString();
            retMessage[4] = CurrentActiveMultiDateFeatureName;
            retMessage[5] = FromDate;
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }