Ejemplo n.º 1
0
        public void UpdatePortMappings()
        {
            // All public API methods are wrapped in a single thread lock.
            // This frees users to invoke the public API from multiple threads, but provides us a bit of sanity.
            lock (singleThreadLock)
            {
                if (Monitor.TryEnter(multiThreadLock))
                {
                    updatePortMappingsThreadFlags = ThreadFlags.None;

                    threadID = ThreadID.UpdatePortMappings;

                    Thread bgThread = new Thread(new ThreadStart(UpdatePortMappingsThread));
                    bgThread.Start();

                    Monitor.Exit(multiThreadLock);
                }
                else
                {
                    if (threadID == ThreadID.UpdatePortMappings)
                    {
                        updatePortMappingsThreadFlags = ThreadFlags.ShouldQuit | ThreadFlags.ShouldRestart;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override ActionResult Delete(string[] id)
        {
            try
            {
                ThreadID tid;
                foreach (string pid in id)
                {
                    IList <ProductRecordItem> items = this.service.ProductRecordItemService.Query().Where(m => m.ProductRecordID == pid).ToList();
                    foreach (ProductRecordItem iitem in items)
                    {
                        this.service.ProductRecordItemService.Delete(iitem);

                        tid             = new ThreadID();
                        tid.currentDate = DateTime.Now;
                        tid.typeID      = iitem.StuffID; //主材id
                        tid.typename    = "0";           //主材
                        this.service.ThreadID.Add(tid);
                    }
                }
                return(base.Delete(id));
            }
            catch (Exception e)
            {
                return(OperateResult(false, Lang.Msg_Operate_Failed + e.Message, ""));
            }
        }
Ejemplo n.º 3
0
        public override ActionResult Add(StuffInfoPrice entity)
        {
            //找原材料名称
            StuffInfo stuffinfo = this.service.StuffInfo.Get(entity.StuffID);

            if (stuffinfo == null)
            {
                return(OperateResult(false, Lang.Msg_Operate_Failed + ":找不到ID为" + entity.StuffID + "的原材料", null));
            }

            entity.StuffName = stuffinfo.StuffName;

            StuffInfoPrice p = this.service.StuffInfoPrice.Query().Where(m => m.year1 == entity.year1 && m.month1 == entity.month1 && m.StuffID == entity.StuffID).FirstOrDefault();

            if (p != null)
            {
                return(OperateResult(false, Lang.Msg_Operate_Failed + string.Format(":{0}年{1}月的材料{2}价格已经存在,请点击修改.", entity.year1, entity.month1, entity.StuffName), null));
            }

            ActionResult r = base.Add(entity);

            ThreadID tid;

            tid             = new ThreadID();
            tid.currentDate = Convert.ToDateTime(entity.year1.ToString() + "-" + entity.month1 + "-01").AddMonths(-1);
            tid.typeID      = entity.StuffID; //主材id
            tid.typename    = "0";            //主材
            this.service.ThreadID.Add(tid);

            return(r);
        }
Ejemplo n.º 4
0
        public override void Delete(object[] ids)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    ThreadID      tid;
                    PublicService ps = new PublicService();

                    foreach (string id in ids)
                    {
                        IList <ProductRecordItem> items = this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Query().Where(m => m.ProductRecordID == id).ToList();
                        foreach (ProductRecordItem iitem in items)
                        {
                            this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Delete(iitem);

                            tid             = new ThreadID();
                            tid.currentDate = DateTime.Now;
                            tid.typeID      = iitem.StuffID; //主材id
                            tid.typename    = "0";           //主材
                            ps.ThreadID.Add(tid);
                        }
                    }

                    base.Delete(ids);
                    //tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
        //private List<SimpleUser> votedUsers = new List<SimpleUser>();
        //public List<SimpleUser> VotedUsers
        //{
        //    get
        //    {
        //        return votedUsers;
        //    }
        //    set { votedUsers = value; }
        //}

        public override string ToString()
        {
            StringTable table = new StringTable();

            table.Add("threadID", ThreadID.ToString());
            table.Add("itemID", ItemID.ToString());
            table.Add("itemName", m_ItemName.ToString());
            table.Add("pollItemCount", PollItemCount.ToString());

            return(table.ToString());
        }
Ejemplo n.º 6
0
        public override ProductRecordItem Add(ProductRecordItem entity)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    var ProductRecord = this.m_UnitOfWork.GetRepositoryBase <ProductRecord>().Get(entity.ProductRecordID);
                    var consMixpropID = this.m_UnitOfWork.GetRepositoryBase <ShippingDocument>().Get(ProductRecord.ShipDocID).ConsMixpropID;
                    var amount        = this.m_UnitOfWork.GetRepositoryBase <ConsMixpropItem>().Query().
                                        Where(a => a.ConsMixpropID == consMixpropID && a.SiloID == entity.SiloID).Select(a => a.Amount).FirstOrDefault();

                    entity.TheoreticalAmount = amount * ProductRecord.ProduceCube;
                    decimal tempActualAmount = entity.ActualAmount != null?Convert.ToDecimal(entity.ActualAmount) : 0;

                    decimal tempTheoreticalAmount = entity.TheoreticalAmount != null?Convert.ToDecimal(entity.TheoreticalAmount) : 0;

                    if (tempTheoreticalAmount != 0)
                    {
                        entity.ErrorValue = Math.Round(((tempActualAmount - tempTheoreticalAmount) / tempTheoreticalAmount * 100), 2);
                    }
                    else
                    {
                        entity.ErrorValue = 0;
                    }
                    IRepositoryBase <StuffInfo> stuffinfoRepository = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>();
                    Silo      silo      = this.m_UnitOfWork.GetRepositoryBase <Silo>().Get(entity.SiloID);
                    StuffInfo stuffinfo = stuffinfoRepository.Get(entity.StuffID);
                    silo.Content        -= tempActualAmount;
                    stuffinfo.Inventory -= tempActualAmount;
                    this.m_UnitOfWork.GetRepositoryBase <Silo>().Update(silo, null);
                    stuffinfoRepository.Update(stuffinfo, null);
                    //this.m_UnitOfWork.Flush();
                    ProductRecordItem obj = base.Add(entity);

                    ThreadID      tid;
                    PublicService ps = new PublicService();
                    tid             = new ThreadID();
                    tid.currentDate = DateTime.Now;
                    tid.typeID      = entity.StuffID; //主材id
                    tid.typename    = "0";            //主材
                    ps.ThreadID.Add(tid);

                    tx.Commit();

                    return(obj);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
Ejemplo n.º 7
0
        public void receive()
        {
            //线程临时文件
            string fileName = Form.fileNames[ThreadID];

            //接收缓冲区
            byte[] buffer = new byte[_bufferSize];
            //接收字节数
            int    readSize = 0;
            Stream stream   = null;

            this.WriteLog("   线程[" + ThreadID.ToString() + "] 开始接收......");
            while (true)
            {
                if (!Form.isPause)
                {
                    using (FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate))
                    {
                        try
                        {
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
                            request.AddRange(Form.restartPos[ThreadID], Form.startPos[ThreadID] + Form.fileSize[ThreadID]);
                            stream   = request.GetResponse().GetResponseStream();
                            readSize = stream.Read(buffer, 0, _bufferSize);
                            while (!Form.isPause && readSize > 0)
                            {
                                fileStream.Write(buffer, 0, readSize);
                                Form.hasReceived[ThreadID] += readSize;
                                this.WriteLog("   线程[" + ThreadID.ToString() + "] 已接收" + Form.hasReceived[ThreadID] + "字节");
                                readSize = stream.Read(buffer, 0, _bufferSize);
                                Thread.Sleep(100);
                            }
                            Form.restartPos[ThreadID] = Form.startPos[ThreadID] + Form.hasReceived[ThreadID];
                            if (Form.hasReceived[ThreadID] < Form.fileSize[ThreadID])
                            {
                                this.WriteLog("   线程[" + ThreadID.ToString() + "] 暂停接收, 已接收" + Form.hasReceived[ThreadID] + "字节");
                            }
                            stream.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                if (Form.hasReceived[ThreadID] >= Form.fileSize[ThreadID] + 1)
                {
                    break;
                }
            }
            Form.threadIsEnd[ThreadID] = true;
            this.WriteLog("   线程[" + ThreadID.ToString() + "] 结束");
        }
Ejemplo n.º 8
0
        public override int GetHashCode()
        {
            int hash = -1;

            if (string.IsNullOrEmpty(ThreadID))
            {
                hash = base.GetHashCode();
            }
            else
            {
                hash = ThreadID.GetHashCode();
            }

            return(hash);
        }
Ejemplo n.º 9
0
        public override ActionResult Add(GoodsOut entity)
        {
            //entity.OutTime = DateTime.Now;
            ActionResult r = base.Add(entity);


            ThreadID tid = new ThreadID();

            tid.currentDate = entity.OutTime;
            tid.typeID      = entity.GoodsID; //辅材id
            tid.typename    = "1";            //辅材
            this.service.ThreadID.Add(tid);


            return(r);
        }
Ejemplo n.º 10
0
        public override ActionResult Update(GoodsOut entity)
        {
            ActionResult r = base.Update(entity);

            //更新同步信息
            //汽修
            CarRepair cr = this.service.CarRepair.Query().Where(m => m.GoodsOutID == entity.ID).FirstOrDefault();

            if (cr != null)
            {
                cr.CarMan       = entity.OutMan;
                cr.RepairMan    = entity.OutMan;
                cr.RepairReason = entity.OutReason;
                cr.RepairDes    = entity.OutReason;
                this.service.CarRepair.Update(cr);
            }
            //设备维修
            EquipMtLy em = this.service.EquipMtLyService.Query().Where(m => m.GoodsOutID == entity.ID).FirstOrDefault();

            if (em != null)
            {
                em.Finder     = entity.OutMan;
                em.FindTime   = entity.OutTime;
                em.ApplyMan   = entity.OutMan;
                em.ApplyTime  = entity.OutTime;
                em.TroubleDes = entity.OutReason;
                this.service.EquipMtLyService.Update(em);
                //子项
                EquipMtLyItem item = this.service.EquipMtLyItem.Query().Where(m => m.EquipMtLyID == em.ID).FirstOrDefault();
                item.DepartmentID = entity.DepartmentID;
                item.Remark       = entity.Remark;
                item.Amount       = Convert.ToInt32(entity.OutNum);
                this.service.EquipMtLyItem.Update(item);
            }


            ThreadID tid = new ThreadID();

            tid.currentDate = entity.OutTime;
            tid.typeID      = entity.GoodsID; //辅材id
            tid.typename    = "1";            //辅材
            this.service.ThreadID.Add(tid);


            return(r);
        }
Ejemplo n.º 11
0
        public bool Import(string id)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    bool result = true;

                    ProductRecord          obj     = this.Get(id);
                    ShippingDocument       shipdoc = this.m_UnitOfWork.ShippingDocumentRepository.Get(obj.ShipDocID);
                    ConsMixprop            cm      = this.m_UnitOfWork.ConsMixpropRepository.Get(shipdoc.ConsMixpropID);
                    List <ConsMixpropItem> list    = this.m_UnitOfWork.ConsMixpropItemRepository.Query().Where(m => m.ConsMixpropID == cm.ID && m.Amount > 0).ToList();

                    ThreadID      tid;
                    PublicService ps = new PublicService();
                    foreach (ConsMixpropItem c in list)
                    {
                        ProductRecordItem tmp = new ProductRecordItem();
                        tmp.ActualAmount      = obj.ProduceCube * c.Amount;
                        tmp.TheoreticalAmount = obj.ProduceCube * c.Amount;
                        tmp.SiloID            = c.SiloID;
                        tmp.StuffID           = c.Silo.StuffInfo.ID;
                        tmp.ProductRecordID   = id;
                        tmp.ErrorValue        = 0;
                        tmp.ProductLineID     = obj.ProductLineID;
                        this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Add(tmp);

                        tid             = new ThreadID();
                        tid.currentDate = DateTime.Now;
                        tid.typeID      = tmp.StuffID; //主材id
                        tid.typename    = "0";         //主材
                        ps.ThreadID.Add(tid);
                    }
                    tx.Commit();
                    return(result);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }
Ejemplo n.º 12
0
        public override ActionResult Delete(int[] id)
        {
            ProductRecordItem item;
            ThreadID          tid;

            for (int i = 0; i < id.Length; i++)
            {
                item = this.m_ServiceBase.Get(id[i]);
                if (item != null)
                {
                    tid             = new ThreadID();
                    tid.currentDate = DateTime.Now;
                    tid.typeID      = item.StuffID; //主材id
                    tid.typename    = "0";          //主材
                    this.service.ThreadID.Add(tid);
                }
            }

            return(base.Delete(id));
        }
Ejemplo n.º 13
0
        public override ActionResult Update(StuffInfoPrice entity)
        {
            StuffInfoPrice obj = this.m_ServiceBase.Get(entity.ID);

            obj.Remark = entity.Remark;
            obj.price  = entity.price;

            this.service.StuffInfoPrice.Update(obj);


            ThreadID tid;

            tid             = new ThreadID();
            tid.currentDate = Convert.ToDateTime(obj.year1.ToString() + "-" + obj.month1 + "-01").AddMonths(-1);
            tid.typeID      = obj.StuffID; //主材id
            tid.typename    = "0";         //主材
            this.service.ThreadID.Add(tid);


            return(OperateResult(true, Lang.Msg_Operate_Success, null));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 物资入库-删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override ActionResult Delete(string[] id)
        {
            ThreadID tid;

            for (int i = 0; i < id.Length; i++)
            {
                GoodsIn g = this.m_ServiceBase.Get(id[i]);
                if (g != null)
                {
                    tid             = new ThreadID();
                    tid.currentDate = g.InTime;
                    tid.typeID      = g.GoodsID; //辅材id
                    tid.typename    = "1";       //辅材
                    this.service.ThreadID.Add(tid);
                }
            }

            ActionResult r = base.Delete(id);

            return(r);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 物资入库-修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override ActionResult Update(GoodsIn entity)
        {
            //添加新的历史记录
            if (s == null)
            {
                s = new PublicService();
            }
            GoodsInHistory history = new GoodsInHistory();

            history.Builder          = entity.Builder;
            history.BuildTime        = entity.BuildTime;
            history.GoodsID          = entity.GoodsID;
            history.GoodsInIDHistory = entity.ID;
            history.InNum            = entity.InNum;
            history.InPrice          = entity.InPrice;
            history.InTime           = entity.InTime;
            history.Lifecycle        = entity.Lifecycle;
            history.Modifier         = entity.Modifier;
            history.ModifyTime       = entity.ModifyTime;
            history.Operator         = entity.Operator;
            history.Remark           = entity.Remark;
            history.SupplyName       = entity.SupplyName;
            history.TransportName    = entity.TransportName;
            history.action_u         = "更新";
            history.GoodsName        = s.GoodsIn.GetName(entity.GoodsID);
            s.GoodsInHistory.Add(history);

            ActionResult r = base.Update(entity);
            //this.service.GoodsInfo.SetM(entity.GoodsID);

            ThreadID tid = new ThreadID();

            tid.currentDate = entity.InTime;
            tid.typeID      = entity.GoodsID; //辅材id
            tid.typename    = "1";            //辅材
            this.service.ThreadID.Add(tid);


            return(r);
        }
Ejemplo n.º 16
0
 public void Await()
 {
     node[ThreadID.Get()].Await();
 }
        public void UpdatePortMappings()
        {
            // All public API methods are wrapped in a single thread lock.
            // This frees users to invoke the public API from multiple threads, but provides us a bit of sanity.
            lock (singleThreadLock)
            {
                if (Monitor.TryEnter(multiThreadLock))
                {
                    updatePortMappingsThreadFlags = ThreadFlags.None;

                    threadID = ThreadID.UpdatePortMappings;

                    Thread bgThread = new Thread(new ThreadStart(UpdatePortMappingsThread));
                    bgThread.Start();

                    Monitor.Exit(multiThreadLock);
                }
                else
                {
                    if (threadID == ThreadID.UpdatePortMappings)
                    {
                        updatePortMappingsThreadFlags = ThreadFlags.ShouldQuit | ThreadFlags.ShouldRestart;
                    }
                }
            }
        }