Ejemplo n.º 1
0
        public HYProduceData GetProduceData(string billNo)
        {
            HYProduceData produceData = null;

            if (!string.IsNullOrEmpty(billNo))
            {
                produceData = this.Get <HYProduceData>(billNo);
            }
            if (produceData == null)
            {
                object lockItem = _lockObjDic.GetOrAdd(billNo, new object());
                lock (lockItem)
                {
                    produceData = this.Get <HYProduceData>(billNo);
                    if (produceData == null)
                    {
                        //CacheItemPolicy policy = new CacheItemPolicy();
                        //policy.SlidingExpiration = new TimeSpan(0, 720, 0); //720分钟内不访问自动剔除
                        LibBcfGrid        ppWorkOrderBcf = (LibBcfGrid)LibBcfSystem.Default.GetBcfInstance("pp.TenWorkRecord");
                        LibQueryCondition lb             = new LibQueryCondition();
                        lb.QueryFields.Add(new LibQueryField()
                        {
                            Name = "WORKORDERNO", QueryChar = LibQueryChar.Equal, Value = new List <object> {
                                billNo
                            }
                        });
                        DataSet ds = ppWorkOrderBcf.BrowseTo(lb);
                        //DataSet ds = ppWorkOrderBcf.BrowseTo(new object[] { billNo });
                        produceData = new HYProduceData(ds);
                        this.Set(billNo, produceData, new TimeSpan(0, 720, 0));
                    }
                }
            }
            return(produceData);
        }
Ejemplo n.º 2
0
        public void AddGatherData(string pPWorkOrderNo, string saleBillNo)
        {
            HYProduceData produceData = LibHYProduceCache.Default.GetProduceData(pPWorkOrderNo);

            if (produceData != null)
            {
                LibBcfGrid        ppWorkOrderBcf = (LibBcfGrid)LibBcfSystem.Default.GetBcfInstance("pp.TenWorkRecord");
                LibQueryCondition lb             = new LibQueryCondition();
                lb.QueryFields.Add(new AxCRL.Core.Comm.LibQueryField()
                {
                    Name      = "WORKORDERNO",
                    QueryChar = LibQueryChar.Equal,
                    Value     = new List <object> {
                        pPWorkOrderNo
                    }
                });
                lb.QueryFields.Add(new AxCRL.Core.Comm.LibQueryField()
                {
                    Name      = "FROMSALEBILLNO",
                    QueryChar = LibQueryChar.Equal,
                    Value     = new List <object> {
                        saleBillNo
                    }
                });
                DataSet ds = ppWorkOrderBcf.BrowseTo(lb);
                if (ds.Tables.Count > 0)
                {
                    produceData.TenWorkRecord.EnforceConstraints = false;
                    try
                    {
                        DataTable dt = produceData.TenWorkRecord.Tables[0];
                        dt.BeginLoadData();
                        try
                        {
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                DataRow row = dt.NewRow();
                                row.BeginEdit();
                                try
                                {
                                    foreach (DataColumn column in ds.Tables[0].Columns)
                                    {
                                        row[column.ColumnName] = dr[column.ColumnName];
                                    }
                                }
                                finally
                                {
                                    row.EndEdit();
                                }
                                dt.Rows.Add(row);
                            }
                        }
                        finally
                        {
                            dt.EndLoadData();
                        }
                    }
                    finally
                    {
                        produceData.TenWorkRecord.EnforceConstraints = true;
                    }
                }
            }
        }