Exemplo n.º 1
0
 private void OnEnable()
 {
     if (autoLoad)
     {
         psdPath = EditorPrefs.GetString(Prefs_pdfPath);
         ruleObj = RuleHelper.GetRuleObj();
     }
 }
Exemplo n.º 2
0
        public void ShouldGetNoProblemWithNoRuleViolationOnServiceContract()
        {
            ReviewProtectionLevel rule = new ReviewProtectionLevel();
            TypeNode typeNode          = RuleHelper.GetTypeNodeFromType(typeof(IHelloWorld2));

            rule.VisitAttributes(typeNode.Attributes);
            Assert.AreEqual(0, rule.Problems.Count);
        }
Exemplo n.º 3
0
        public void ShouldGetNoProblemWithNoRuleViolationOnOperationContract()
        {
            ReviewProtectionLevel rule = new ReviewProtectionLevel();
            TypeNode typeNode          = RuleHelper.GetTypeNodeFromType(typeof(IHelloWorld2));

            rule.VisitAttributes(typeNode.GetMembersNamed(Identifier.For("HelloWorld"))[0].Attributes);
            Assert.AreEqual(0, rule.Problems.Count);
        }
Exemplo n.º 4
0
        public ComplexCondition(object model)
        {
            var complexModel = JsonSerializer.Deserialize <ComplexConditionModel>(model.ToString());

            LeftCondition  = RuleHelper.GetCondition(complexModel.LeftCondition);
            RightCondition = RuleHelper.GetCondition(complexModel.RightCondition);
            Operator       = complexModel.Operator.ToLower();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the last trading day.
        /// </summary>
        /// <param name="month">The month.</param>
        /// <param name="year">The year.</param>
        /// <returns></returns>
        public override DateTime GetLastTradingDay(int month, int year)
        {
            //Rather than the last weekday, this use the last day for IB contracts
            //since the RBA dates are very close to the beginning of the month.
            DateTime significantDate = RuleHelper.LastDayInMonth(month, year);//LastWeekdayDayInMonth

            return(significantDate);
        }
Exemplo n.º 6
0
        public void ShouldGetOneProblemWithBadOperationBehaviorUsage()
        {
            ReturnVoidWithOneWayOperation rule = new ReturnVoidWithOneWayOperation();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(IReturnVoidWithOneWay));

            rule.Check(typeNode.GetMembersNamed(Identifier.For("Operation"))[0]);

            Assert.AreEqual(1, rule.Problems.Count);
        }
        public void ShouldGetOneProblemWhenIssueInFirstParam()
        {
            MixingMessageContractAttributes rule = new MixingMessageContractAttributes();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(IMixingMessageContractAttributes));

            rule.Check(typeNode.GetMembersNamed(Identifier.For("Operation3"))[0]);

            Assert.AreEqual(1, rule.Problems.Count);
        }
        public void ShouldGetNoProblemWithVoidReturn()
        {
            MixingMessageContractAttributes rule = new MixingMessageContractAttributes();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(IMixingMessageContractAttributes));

            rule.Check(typeNode.GetMembersNamed(Identifier.For("Operation4"))[0]);

            Assert.AreEqual(0, rule.Problems.Count);
        }
        public void ShouldGetOneProblemWithFaultOnOneWayOperation()
        {
            NoFaultsWithOneWayOperation rule = new NoFaultsWithOneWayOperation();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(IFaultsWithOneWayOperation));

            rule.Check(typeNode.GetMembersNamed(Identifier.For("Operation"))[0]);

            Assert.AreEqual(1, rule.Problems.Count);
        }
Exemplo n.º 10
0
        public void ShouldBeEquals()
        {
            SyntaxicRule rule1;
            SyntaxicRule rule2;

            rule1 = RuleHelper.BuildRule("A*=<C,a>;");
            rule2 = RuleHelper.BuildRule("A*=<C,a>;");
            Assert.IsTrue(rule1.Equals(rule2));
        }
Exemplo n.º 11
0
        public void ShouldBeEquals()
        {
            LexicalRule rule1;
            LexicalRule rule2;

            rule1 = RuleHelper.BuildRule("A*=a;");
            rule2 = RuleHelper.BuildRule("A*=a;");
            Assert.IsTrue(rule1.Equals(rule2));
        }
Exemplo n.º 12
0
        private static void SearchRules()
        {
            SearchCriteria SC = GetSearchCriteria();

            Rule[] Rules = RuleHelper.GetRules7(SC);
            //Window.Alert ( Rules.Length+"ఫలితాలు దొరికాయి.\nResults found: " + Rules.Length );
            Document.GetElementById("result").InnerHTML = BuildList(Rules);
            Util.ScrollTo("main");
        }
        public void ShouldGetOneProblemWithReplyActionWithOneWayOperation()
        {
            NoReplyActionWithOneWayOperation rule = new NoReplyActionWithOneWayOperation();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(IReplyActionWithOneWay));

            rule.Check(RuleHelper.GetMemberForOperation(typeNode, "Operation"));

            Assert.AreEqual(1, rule.Problems.Count);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the date rules.
        /// </summary>
        /// <param name="month">The month.</param>
        /// <param name="year">The year.</param>
        /// <returns></returns>
        protected override DateTime?DateRules(int month, int year)
        {
            if (!IsValidMonth(month))
            {
                return(null);
            }
            var date = RuleHelper.GetNthDayInMonth(month, 1, 3, year, 0, 0);

            return(date);
        }
Exemplo n.º 15
0
 private void CheckInt(String table, String id, String value, String name)
 {
     if (RuleHelper.IsNotEmpty(value))
     {
         if (!RuleHelper.IsInteger(value))
         {
             ErrorMsg.Add(table + "表中," + id + "的" + name + "格式错误,应是整数");
         }
     }
 }
 public override ValidationResult Validate(object value, CultureInfo cultureInfo)
 {
     if (string.IsNullOrWhiteSpace(value?.ToString()))
     {
         return(ValidationResult.ValidResult);
     }
     return(RuleHelper.IsNumberic(value)
         ? ValidationResult.ValidResult
         : new ValidationResult(false, "请输入数字"));
 }
Exemplo n.º 17
0
 /// <summary>
 /// 检查是否是数字
 /// </summary>
 /// <param name="table"></param>
 /// <param name="id"></param>
 /// <param name="value"></param>
 /// <param name="name"></param>
 private void CheckNumic(String table, String id, String value, String name)
 {
     if (RuleHelper.IsNotEmpty(value))
     {
         if (!RuleHelper.IsNumberic(value))
         {
             ErrorMsg.Add(table + "表中," + id + "的" + name + "格式错误,应是数字");
         }
     }
 }
Exemplo n.º 18
0
        public static void SetList()
        {
            //perf to  be improved...
            Element E = Window.Document.GetElementById("MachineEnabled");

            E.InnerHTML = "";

            Element Jati         = Util.AddOptionItem("జాతులు", "జాతులు", true);
            Element SamaVruttam  = Util.AddOptionItem("సమ వృత్తములు", "సమ వృత్తములు", true);
            Element ASamaVruttam = Util.AddOptionItem("అసమ వృత్తములు", "అసమ వృత్తములు", true);


            foreach (Rule R in SortHelper.SortByName(RuleHelper.GetRules2(PadyamSubType.Jati)))
            {
                if (R.Identifier == "kandam")
                {
                    Element O = Util.AddOptionItem(R.Name, R.Identifier, false);
                    Jati.AppendChild(O);
                }
            }

            List <Element> OrderedVruttams = new List <Element>();

            for (int i = 1; i <= 27; i++)
            {
                string  cName  = Helper.ChandamName(i) + (i <= 26 ? " (" + i + ")" : " (>26)");
                Element Local  = Util.AddOptionItem(cName, cName, true);
                Rule[]  VRules = i <= 26 ? RuleHelper.GetRules3(i) : RuleHelper.GetRules4(i);
                foreach (Rule R in SortHelper.SortByName(VRules))
                {
                    if (!R.InfiniteLength)
                    {
                        Element O = Util.AddOptionItem(R.Name, R.Identifier, false);
                        Local.AppendChild(O);
                        OrderedVruttams.Add(Local);
                    }
                }
            }

            Rule[] asamaRules = RuleHelper.GetRules2(PadyamSubType.VishamaVruttam);
            foreach (Rule R in SortHelper.SortByName(asamaRules))
            {
                Element O = Util.AddOptionItem(R.Name, R.Identifier, false);
                ASamaVruttam.AppendChild(O);
            }


            E.AppendChild(Jati);
            E.AppendChild(SamaVruttam);
            foreach (Element _E in OrderedVruttams)
            {
                E.AppendChild(_E);
            }
            E.AppendChild(ASamaVruttam);
        }
Exemplo n.º 19
0
        public static void FindMatraVruttams(int n)
        {
            Rule[] Rules = RuleHelper.GetMatraVruttams(n);
            if (Rules.Length == 0)
            {
                Document.GetElementById("result").InnerHTML = "<span class='gName'>ఫలితాలు ఏమీ లేవు</span>";
                return;
            }

            Rules = SortHelper.SortByCharLength(Rules);
            StringBuilder sb = new StringBuilder();

            sb.Append("<span class='gName'>");
            sb.Append(n);
            sb.Append("</span>");
            sb.Append(" మాత్రలు గల వృత్తములు క్రిందన ఇవ్వబడ్డాయి.");

            sb.Append(" మొత్తం ");
            sb.Append("<span class='gName'> ");
            sb.Append(Rules.Length);
            sb.Append("</span>");
            sb.Append(" వృత్తములు దొరికాయి. ");


            sb.Append("<ol>");
            int last = 0;

            foreach (Rule R in Rules)
            {
                if (R.CharLength != last)
                {
                    if (0 != last)
                    {
                        sb.Append("</ol>");
                        sb.Append("</li>");
                    }
                    sb.Append("<li>");

                    sb.Append("<b>");
                    sb.Append(R.ChandamName + " (" + R.CharLength + ") ");
                    sb.Append("</b>");
                    sb.Append("</li>");
                    sb.Append("<ol>");
                }

                sb.Append("<li>");
                sb.Append(R.Name);
                sb.Append("</li>");

                last = R.CharLength;
            }
            sb.Append("</li>");
            sb.Append("</ol>");
            Document.GetElementById("result").InnerHTML = (string)Script.Literal("sb.toString2()", null);
        }
Exemplo n.º 20
0
        public void ShouldGetOneProblemWithNoOperationContractValuesDeclared()
        {
            InconsistentServiceContract rule = new InconsistentServiceContract();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(INoOperationContractValuesDeclared));

            rule.Check(typeNode);
            Assert.AreEqual(0, rule.Problems.Count);

            rule.Check(RuleHelper.GetMemberForOperation(typeNode, "Operation"));
            Assert.AreEqual(1, rule.Problems.Count);
        }
Exemplo n.º 21
0
    /// <summary>
    /// Stores Macro condition to main Edit form.
    /// </summary>
    private void StoreMacroData()
    {
        // For macro rule don't store validity
        ClearStoredValidityData();

        // Store null value as rule parameter
        editForm.Data["RuleParameter"] = null;

        // Store xml with macro condition
        editForm.Data["RuleCondition"] = RuleHelper.GetMacroCondition(macroEditor.Text);
    }
Exemplo n.º 22
0
        public void GetRulesForCustomer_EmptyRule_ReturnsBasicRule()
        {
            // Arrange
            var customerRule = new List <CustomerRule> {
            };
            // Act
            var result = RuleHelper.GetRulesForCustomer("", customerRule);

            // Assert
            Assert.AreEqual(1, result.Count);
        }
Exemplo n.º 23
0
 private static void CheckoutDefault(List <CustomerRule> fileRules)
 {
     Console.WriteLine("Total of Cart is : " + AdsCheckout.PerformCheckout(
                           new List <Product>
     {
         new ClassicAd(),
         new StandoutAd(),
         new PremiumAd()
     },
                           RuleHelper.GetRulesForCustomer("default", fileRules)
                           ));
 }
Exemplo n.º 24
0
    /// <summary>
    /// Stores Attribute form data to main Edit form.
    /// </summary>
    private void StoreAttributeData()
    {
        // For attribute rule don't store validity
        ClearStoredValidityData();

        // Store contact column for attribute rule
        editForm.Data["RuleParameter"] = mSelectedAttribute.Name;

        // Store xml with where condition
        attributeFormCondition.SaveData(null);
        editForm.Data["RuleCondition"] = RuleHelper.GetAttributeCondition(attributeFormCondition.Data, attributeFormCondition.GetWhereCondition());
    }
Exemplo n.º 25
0
        public string SortByName2(string head, PadyamSubType padyamSubType)
        {
            string s2 = "";

            s2 = s2 + "<h2 style='text-align:center;'>" + head + "</h2>";
            s2 = s2 + "<ol>";
            foreach (Rule R in SortHelper.SortByName(RuleHelper.GetRules2(padyamSubType)))
            {
                s2 = s2 + "<li id='h_" + R.Identifier + "'><a class='identifier'  title='" + R.Name + "'  href='?chandassu=" + R.Identifier + "'>" + R.ShortName + "</a></li>";
            }
            s2 = s2 + "</ol>";
            return(s2);
        }
Exemplo n.º 26
0
 private static void CheckoutNike(List <CustomerRule> fileRules)
 {
     Console.WriteLine("Total of cart is : " + AdsCheckout.PerformCheckout(
                           new List <Product>
     {
         new PremiumAd(),
         new PremiumAd(),
         new PremiumAd(),
         new PremiumAd()
     },
                           RuleHelper.GetRulesForCustomer("nike", fileRules)
                           ));
 }
Exemplo n.º 27
0
        public void ShouldGetOneProblemWithNotAllowedSessionDeclared()
        {
            InconsistentServiceContract rule = new InconsistentServiceContract();
            TypeNode typeNode = RuleHelper.GetTypeNodeFromType(typeof(INotAllowedSessionDeclared));

            rule.Check(typeNode);

            Assert.AreEqual(0, rule.Problems.Count);

            rule.Check(RuleHelper.GetMemberForOperation(typeNode, "Operation"));
            Assert.AreEqual(1, rule.Problems.Count);
            Assert.AreEqual("remove", rule.Problems[0].Resolution.Items[0]);
        }
        /// <summary>
        /// This method will check for all available business rules in system.
        /// </summary>
        /// <param name="order"></param>
        private void EvaluateforAllBusinessRules(Order.Domain.Model.Order order)
        {
            if (order.Category == "Book" || order.Category == "PhysicalProduct" || order.Category == "Membership" || order.Category == "MembershipUpgrade" || order.Category == "VideoProduct")
            {
                var rule =
                    RuleHelper.And(
                        new IRule[5] {
                    new BookProductRule(), new PhysicalProductRule(), new VideoProductRule(), new MembershipProductRule(), new UpgradeMembershipRule()
                });

                _ruleService.Evaluate(rule, order);
            }
        }
Exemplo n.º 29
0
    /// <summary>
    /// Loads basicform with filter controls.
    /// </summary>
    /// <param name="bf">BasicForm control</param>
    /// <param name="fi">Form definition</param>
    /// <param name="activityType">Activity type in case the rule type is activity</param>
    private void LoadForm(BasicForm bf, FormInfo fi, string activityType = null)
    {
        bf.FormInformation      = fi;
        bf.Data                 = RuleHelper.GetDataFromCondition(Rule, fi.GetDataRow().Table, ref activityType);
        bf.SubmitButton.Visible = false;
        bf.SiteName             = SiteContext.CurrentSiteName;

        if (Rule != null)
        {
            bf.Mode = FormModeEnum.Update;
        }

        bf.ReloadData();
    }
Exemplo n.º 30
0
 private void CheckNUllAndNumic(String table, String id, String value, String name)
 {
     if (!RuleHelper.IsNotEmpty(value))
     {
         //ErrorMsg.Add(table + "表中,第" + rownum + "行的" + name + "为空");
         ErrorMsg.Add(table + "表中," + id + "的" + name + "为空");
         return;
     }
     if (!RuleHelper.IsNumberic(value))
     {
         ErrorMsg.Add(table + "表中," + id + "的" + name + "格式错误,应是数字");
         //ErrorMsg.Add(table + "表中,第" + rownum + "行的" + name + "格式错误,应是数字");
     }
 }
Exemplo n.º 31
0
        public void bindData(BusinessRule businessRule)
        {
            int clientID = SessionHelper.getClientId();

            IQueryable<AdjusterMaster> adjusters = null;

            adjusters = AdjusterManager.GetAll(clientID);

            ddlAdjuster.DataSource = adjusters.ToList();
            ddlAdjuster.DataValueField = "AdjusterId";
            ddlAdjuster.DataTextField = "adjusterName";
            ddlAdjuster.DataBind();
            ddlAdjuster.Items.Insert(0, new ListItem("--- Select ---", "0"));

            //CollectionManager.FillCollection(ddlAdjuster, "AdjusterId", "adjusterName", adjusters);

            ViewState["businessRuleID"] = businessRule.BusinessRuleID.ToString();

            clearFields();

            if (businessRule.BusinessRuleID == 0) {
                // for new rules only.
                cbxActive.Checked = true;
            }
            else {
                // edit
                XElement ruleXML = XElement.Parse(businessRule.RuleXML);
                cbxActive.Checked = businessRule.IsActive;
                cbxEmailAdjuster.Checked = businessRule.EmailAdjuster;
                cbxEmailSupervisor.Checked = businessRule.EmailSupervisor;
                txtDescription.Text = businessRule.Description;

                using (RuleHelper ruleHelper = new RuleHelper()) {
                    XElement invoiceCondition = ruleHelper.GetElement(ruleXML, "Claim");
                    txtNumberOfClaims.Text = invoiceCondition.Element("value").Value;

                    XElement adjusterCondition = ruleHelper.GetElement(ruleXML, "AdjusterID");
                    ddlAdjuster.SelectedValue = adjusterCondition.Element("value").Value;
                }

                //.Where(x => x.Element("property").Value == "Invoice").FirstOrDefault();
            }
        }
Exemplo n.º 32
0
        public void bindData(BusinessRule businessRule)
        {
            int clientID = SessionHelper.getClientId();

            ViewState["businessRuleID"] = businessRule.BusinessRuleID.ToString();

            clearFields();

            if (businessRule.BusinessRuleID == 0)
            {
                // for new rules only.
                cbxActive.Checked = true;
                carriers = CarrierManager.GetCarriers(clientID).ToList();
                CollectionManager.FillCollection(ddlCarrier, "CarrierID", "CarrierName", carriers);
            }
            else
            {
                // edit
                XElement ruleXML = XElement.Parse(businessRule.RuleXML);
                cbxActive.Checked = businessRule.IsActive;
                cbxEmailAdjuster.Checked = businessRule.EmailAdjuster;
                cbxEmailSupervisor.Checked = businessRule.EmailSupervisor;

                txtDescription.Text = businessRule.Description;

                carriers = CarrierManager.GetCarriers(clientID).ToList();
                CollectionManager.FillCollection(ddlCarrier, "CarrierID", "CarrierName", carriers);

                string str_query = @"SELECT * FROM BusinessRule WHERE BusinessRuleID = @BusinessRuleId
                                       ";
                using (SqlConnection conn = new SqlConnection(connectionString))
                using (SqlCommand cmd = new SqlCommand(str_query, conn))
                {
                    cmd.Parameters.AddWithValue("@BusinessRuleId", businessRule.BusinessRuleID);

                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        BusinessRule businessRuleObj = new BusinessRule();

                        businessRuleObj.BusinessRuleID = Convert.ToInt32(reader["BusinessRuleID"]);
                        if (reader["CarrierId"] == DBNull.Value)
                        {
                            ddlCarrierId = 0;
                        }
                        else {
                            ddlCarrierId = Convert.ToInt32(reader["CarrierId"]);
                        }

                    }

                    conn.Close();
                }
                ddlCarrier.SelectedValue = Convert.ToString(ddlCarrierId);

                using (RuleHelper ruleHelper = new RuleHelper())
                {
                    XElement conditionLapseTime = ruleHelper.GetElement(ruleXML, "LapseTime");
                    txtDayHours.Value = conditionLapseTime.Element("value").Value;

                    XElement conditionLapseTimeType = ruleHelper.GetElement(ruleXML, "LapseTimeType");
                    setValue(this.ddlhourday, conditionLapseTimeType.Element("value").Value);
                }
            }
        }
Exemplo n.º 33
0
        public List<BusinessRule> getBusinessRuleId(int clientID, int ruleId)
        {
            List<BusinessRule> businessRuleArr = new List<BusinessRule>();
            BusinessRuleManager businessRuleManager = new BusinessRuleManager();

            businessRuleArr = businessRuleManager.GetBusinessRuleThread(clientID, ruleId);
            for (var i = 0; i < businessRuleArr.Count; i++)
            {
                XElement ruleXML = XElement.Parse(businessRuleArr[i].RuleXML.ToString());
                using (RuleHelper ruleHelper = new RuleHelper())
                {
                    XElement conditionLapseTime = ruleHelper.GetElement(ruleXML, "LapseTime");
                    businessRuleArr[i].Description = conditionLapseTime.Element("value").Value;

                    XElement conditionLapseTimeType = ruleHelper.GetElement(ruleXML, "LapseTimeType");
                    businessRuleArr[i].RuleXML = conditionLapseTimeType.Element("value").Value;
                }

            }

            return businessRuleArr;
        }
Exemplo n.º 34
0
        public XDocument buildRule()
        {
            XDocument ruleXml = base.buildRootNode();

            XAttribute xaType = new XAttribute("type", "equal");
            XElement definitionNode = new XElement("definition", xaType);

            using (RuleHelper ruleHelper = new RuleHelper())
            {

                // hours/days unit
                XElement conditionLapseTime = ruleHelper.CreateCondition("LapseTime", txtDayHours.Text);

                // hour/day selection
                XElement conditionLapseTimeType = ruleHelper.CreateCondition("LapseTimeType", this.ddlhourday.SelectedValue);

                // add conditions to rule definition
                definitionNode.Add(conditionLapseTime);
                definitionNode.Add(conditionLapseTimeType);

                //ruleXml.Add(ruleNode);
                ruleXml.Element("rule").Add(definitionNode);
            }

            return ruleXml;
        }