Пример #1
0
        public BaseResult GetNextDH(object entity, Type type = null)
        {
            BaseResult br = new BaseResult();

            br = CodingRule.SetBaseCoding(entity, type);
            return(br);
        }
Пример #2
0
 public static void CheckForFormat(NeosSdiMef neosSdiMef, CodingRule rule, BasePropertyDeclarationSyntax _property, string text, string textFull, int spanStart, int spanEnd)
 {
     switch (rule.RuleCase)
     {
         case CodingRuleCaseEnum.UpperCamelCase:
             string upperText = rule.RuleFirstLetter + text.UpperCamelCase();
             if (text != upperText)
             {
                 neosSdiMef.AddDecorationError(_property, textFull, "Replace " + text + " by " + upperText, () =>
                 {
                     var span = Span.FromBounds(spanStart, spanEnd);
                     neosSdiMef._textView.TextBuffer.Replace(span, upperText);
                 });
             }
             break;
         case CodingRuleCaseEnum.LowerCamelCase:
             string lowerText = rule.RuleFirstLetter + text.LowerCamelCase();
             if (text != lowerText)
             {
                 neosSdiMef.AddDecorationError(_property, textFull, "Replace " + text + " by " + lowerText, () =>
                 {
                     var span = Span.FromBounds(spanStart, spanEnd);
                     neosSdiMef._textView.TextBuffer.Replace(span, lowerText);
                 });
             }
             break;
         default:
             break;
     }
 }
Пример #3
0
        /// <summary>
        /// 将编码规则设定为createOnSave
        /// </summary>
        /// <param name="billType"></param>
        /// <param name="progId"></param>
        /// <param name="createOnSave">可选参数,默认为true</param>
        public void SetCreateOnSave(BillType billType, string progId, bool createOnSave = true)
        {
            CodingRule rule = GetCodingRule(billType, progId);

            if (rule != null)
            {
                rule.CreateOnSave = createOnSave;
            }
            //使用Redis缓存,需要将修改后的值Set回去
            this.Set <CodingRule>(progId, rule, new TimeSpan(0, 180, 0));
        }
Пример #4
0
        public CodingRule GetCodingRule(BillType billType, string progId)
        {
            CodingRule codingRule = this.Get <CodingRule>(progId);

            if (codingRule == null)
            {
                lock (_LockRuleObj)
                {
                    codingRule = this.Get <CodingRule>(progId);
                    if (codingRule == null)
                    {
                        codingRule = new CodingRule();
                        Dictionary <int, int> listIndex  = new Dictionary <int, int>();
                        SqlBuilder            sqlBuilder = new SqlBuilder("com.CodingRule");
                        //string sql = sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.SECTIONTYPE,B.SECTIONLENGTH,B.FIELDNAME,B.SECTIONVALUE", string.Format("A.PROGID = {0} And A.VALIDITYSTARTDATE <= {1} And (A.VALIDITYENDDATE >= {1} or A.VALIDITYENDDATE = 0)", LibStringBuilder.GetQuotString(progId), LibDateUtils.GetCurrentDate()), "B.ROWNO ASC");
                        string        sql        = sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.SECTIONTYPE,B.SECTIONLENGTH,B.FIELDNAME,B.SECTIONVALUE", string.Format("A.PROGID = {0}", LibStringBuilder.GetQuotString(progId), LibDateUtils.GetCurrentDate()), "B.ROWNO ASC");
                        LibDataAccess dataAccess = new LibDataAccess();
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            while (reader.Read())
                            {
                                CodingRuleItem rule = new CodingRuleItem();
                                rule.SectionType = (SectionType)LibSysUtils.ToInt32(reader["SECTIONTYPE"]);
                                rule.Length      = LibSysUtils.ToInt32(reader["SECTIONLENGTH"]);
                                switch (rule.SectionType)
                                {
                                case SectionType.None:
                                    rule.Value = LibSysUtils.ToString(reader["SECTIONVALUE"]);
                                    break;

                                case SectionType.Dynamic:
                                    rule.FieldName = LibSysUtils.ToString(reader["FIELDNAME"]);
                                    rule.Values.Add(rule.FieldName, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    int rowId = LibSysUtils.ToInt32(reader["ROW_ID"]);
                                    if (!listIndex.ContainsKey(rowId))
                                    {
                                        listIndex.Add(rowId, codingRule.Items.Count);
                                    }
                                    if (!codingRule.CreateOnSave)
                                    {
                                        codingRule.CreateOnSave = true;
                                    }
                                    break;
                                }
                                codingRule.Items.Add(rule);
                            }
                        }
                        sql = sqlBuilder.GetQuerySql(2, "C.PARENTROWID,C.FIELDVALUE,C.SECTIONVALUE", string.Format("A.PROGID = {0}", LibStringBuilder.GetQuotString(progId)));
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            while (reader.Read())
                            {
                                int rowId = LibSysUtils.ToInt32(reader["PARENTROWID"]);
                                if (listIndex.ContainsKey(rowId))
                                {
                                    CodingRuleItem rule       = codingRule.Items[listIndex[rowId]];
                                    string         fieldValue = LibSysUtils.ToString(reader["FIELDVALUE"]);
                                    if (!rule.Values.ContainsKey(fieldValue))
                                    {
                                        rule.Values.Add(fieldValue, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    }
                                }
                            }
                        }
                        //如果为单据,默认产生编码规则 日期+6位流水码
                        if (codingRule.Items.Count == 0)
                        {
                            if (billType == BillType.Bill)
                            {
                                codingRule.Items.Add(new CodingRuleItem()
                                {
                                    SectionType = SectionType.DateL
                                });
                                codingRule.Items.Add(new CodingRuleItem()
                                {
                                    SectionType = SectionType.SerialNum, Length = 6
                                });
                            }
                        }
                        else
                        {
                            codingRule.IsSetRule = true;
                        }
                        if (codingRule.Items.Count > 0)
                        {
                            this.Set(progId, codingRule, new TimeSpan(0, 180, 0));
                        }
                    }
                }
            }
            return(codingRule);
        }