Ejemplo n.º 1
0
        /// <summary>
        /// 将object格式化成字节数组byte[]
        /// </summary>
        /// <param name="billNo">单据编号</param>
        /// <returns>字节数组</returns>

        public ProduceData GetProduceData(string billNo)
        {
            ProduceData produceData = null;
            string      json        = this.StringGet(billNo);

            if (!string.IsNullOrEmpty((json)))
            {
                produceData = JsonUtiler.Deserialize <ProduceData>(json);
            }
            if (produceData == null)
            {
                object lockItem = lockObjDic.GetOrAdd(billNo, new object());
                lock (lockItem)
                {
                    json = this.StringGet(billNo);
                    if (!string.IsNullOrEmpty((json)))
                    {
                        produceData = JsonUtiler.Deserialize <ProduceData>(json);
                    }
                    //  produceData = this.Get< ProduceData>(billNo)  ;
                    if (produceData == null)
                    {
                        //CacheItemPolicy policy = new CacheItemPolicy();
                        //policy.SlidingExpiration = new TimeSpan(0, 60, 0); //60分钟内不访问自动剔除
                        LibBcfData ppWorkOrderBcf = (LibBcfData)LibBcfSystem.Default.GetBcfInstance("pp.WorkOrder");
                        DataSet    ds             = ppWorkOrderBcf.BrowseTo(new object[] { billNo });
                        produceData = new ProduceData(ds);
                        this.Set(billNo, produceData, new TimeSpan(0, 720, 0));

                        //   byte[] binaryDataResult = GetBinaryFormatData(produceData);
                        //   Default.StringSetBytes(billNo, binaryDataResult, new TimeSpan(0, 30, 0));
                    }
                }
            }
            return(produceData);
        }
Ejemplo n.º 2
0
        private static bool ParseCore(string condition, DataRow masterRow, DataRow bodyRow, Dictionary <string, object> masterDic, Dictionary <string, object> bodyDic)
        {
            bool result = false;

            try
            {
                //先使用QueryFields尝试
                if ((masterDic == null || masterDic.Count == 0) && masterRow != null)
                {
                    masterDic = new Dictionary <string, object>();
                    if (masterRow.Table != null)
                    {
                        foreach (DataColumn column in masterRow.Table.Columns)
                        {
                            masterDic.Add(column.ColumnName, masterRow[column.ColumnName]);
                        }
                    }
                }
                if (masterDic != null && masterDic.Count > 0)
                {
                    LibQueryCondition queryCondition = JsonUtiler.Deserialize <LibQueryCondition>(condition);
                    if (queryCondition != null)
                    {
                        if (queryCondition.AccordOfThis(masterDic))
                        {
                            return(true);
                        }
                    }
                }
            }
            catch (Exception)
            {
                //to do log
            }


            Memory memory = new Memory();
            //匹配类似表达式"[A.QTY]>=10 && ([A.MaterialId]=='13212321' || ([A.RANGEID]=='AAA' && [A.SSID]=='9999')) && (([A.DD]=='xxx' || [A.DD]=='xxx1' || [A.DD]=='xxx2') || [A.ZZ]>=0)";
            string           pattern   = @"[[][A-Z]\.\w+[]]";
            MatchCollection  matchList = Regex.Matches(condition, pattern);
            HashSet <string> temp      = new HashSet <string>();

            foreach (var item in matchList)
            {
                string field = item.ToString();
                if (temp.Contains(field))
                {
                    continue;
                }
                temp.Add(field);
                string copyField = field;
                field = field.Remove(0, 1);
                field = field.Remove(field.Length - 1, 1);
                int    tableIndex = (int)field[0] - (int)'A';
                string fieldName  = field.Substring(2, field.Length - 2);
                object value      = tableIndex == 0 ? (masterRow == null ? masterDic[fieldName] : masterRow[fieldName]) : (bodyRow == null ? bodyDic[fieldName] : bodyRow[fieldName]);
                memory.AddObject(fieldName, value);
                condition = condition.Replace(copyField, fieldName);
            }
            Script.Execute("if(" + condition + "){ret=true;}else{ret=false;}", memory);
            result = LibSysUtils.ToBoolean(memory["ret"].value);
            return(result);
        }