예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            string responseText = string.Empty;

            string _containerID = string.Empty;

            if (!string.IsNullOrEmpty(context.Request.QueryString["ContainerID"]))
            {
                _containerID = context.Request.QueryString["ContainerID"];
            }

            try
            {
                ContainerDetail con = ContainerDetail.Cache.Load(_containerID);;

                if (con != null)
                {
                    JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                    responseText = jsonSerializer.Serialize(con);
                }
            }
            catch (Exception ex)
            {
                responseText = string.Format("{{  \"result\": \"error\", \"error_msg\": \"{0}\" }}", ex.Message);
            }

            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(responseText);
            context.Response.End();
        }
        public void can_serialize_container_details()
        {
            var pluginTypeDetails = new[]
            {
                new PluginTypeDetail(typeof (string), typeof (object),
                                     new[] {new InstanceDetail("First", "First Instance", typeof (string)),})
            };
            var wrapper = new ContainerDetail(new[] {"config"}, pluginTypeDetails);
            var binaryFormatter = new BinaryFormatter();
            Stream stream = new MemoryStream();
            binaryFormatter.Serialize(stream, wrapper);

            stream.Position = 0;
            var detailOnOtherSide = (ContainerDetail) binaryFormatter.Deserialize(stream);
            Assert.That(detailOnOtherSide, SyntaxHelper.Not.Null);
            Assert.That(detailOnOtherSide, Is.TypeOf(typeof (ContainerDetail)));
        }
        public void can_serialize_container_details()
        {
            var pluginTypeDetails = new[]
            {
                new PluginTypeDetail(typeof(string), typeof(object),
                                     new[] { new InstanceDetail("First", "First Instance", typeof(string)), })
            };
            var    wrapper         = new ContainerDetail(new[] { "config" }, pluginTypeDetails);
            var    binaryFormatter = new BinaryFormatter();
            Stream stream          = new MemoryStream();

            binaryFormatter.Serialize(stream, wrapper);

            stream.Position = 0;
            var detailOnOtherSide = (ContainerDetail)binaryFormatter.Deserialize(stream);

            Assert.That(detailOnOtherSide, SyntaxHelper.Not.Null);
            Assert.That(detailOnOtherSide, Is.TypeOf(typeof(ContainerDetail)));
        }
예제 #4
0
        private static void Main(string[] args)
        {
            var container = new Container(x =>
            {
                x.Scan(s =>
                {
                    s.TheCallingAssembly();
                    s.WithDefaultConventions();
                });
                x.ForRequestedType <IDoMore <string> >().TheDefaultIsConcreteType <DoForStrings>();
                x.ForRequestedType <IDoThat>().AddInstances(i =>
                {
                    i.OfConcreteType <DoThat>().WithName("Red");
                    i.OfConcreteType <DoThat>().WithName("Blue");
                });
            });

            ObjectFactory.Initialize(i => i.ForRequestedType <IDoThat>().TheDefaultIsConcreteType <DoThat>());
            Debug.WriteLine(container.WhatDoIHave());

            ContainerDetail details = ContainerVisualizerObjectSource.BuildContainerDetails(container);

            Application.Run(new ContainerForm(details));
        }
예제 #5
0
        protected override void ScanBarCode()
        {
            string barCode = this.tbBarCode.Text.Trim();
            this.tbBarCode.Focus();
            this.tbBarCode.Text = string.Empty;
            string op = Utility.GetBarCodeType(this.user.BarCodeTypes, barCode);

            if (barCode.Length < 3)
            {
                throw new BusinessException("条码格式不合法");
            }

            if (this._containerDetail == null && !this.isCancel)
            {
                if (op == CodeMaster.BarCodeType.COT.ToString())
                {
                    this._containerDetail = smartDeviceService.GetContainerDetail(barCode);
                    if (this._containerDetail == null)
                    {
                        throw new BusinessException("扫描的容器不存在");
                    }
                    else
                    {
                        this.lblMessage.Text = "请扫描物料条码";
                        this.lblMessage.ForeColor = Color.Black;
                    }
                }
                else
                {
                    throw new BusinessException("请先扫描容器条码");
                }
            }
            else if (!this.isCancel)
            {
                if (op == CodeMaster.BarCodeType.HU.ToString())
                {
                    Hu hu = this.smartDeviceService.GetHu(barCode);
                    if (hu == null)
                    {
                        throw new BusinessException("此条码不存在");
                    }
                    else if (hu.Status != HuStatus.Location)
                    {
                        throw new BusinessException("条码不在库存中,不能装入容器");
                    }
                    else if(hu.IsFreeze)
                    {
                        throw new BusinessException("条码被冻结,不能装入容器");
                    }
                    else if (hu.OccupyType != OccupyType.None)
                    {
                        throw new BusinessException("条码被{0}占用!", hu.OccupyReferenceNo);
                    }
                    else
                    {
                        var isHuInContainer = smartDeviceService.IsHuInContainer(hu.HuId);
                        if (this._isIn == true)
                        {
                            if (isHuInContainer == true)
                            {
                                throw new BusinessException("条码已在容器中!");
                            }
                            this.smartDeviceService.ContainerBind(this._containerDetail.ContainerId, hu.HuId, this.user.Code);
                        }
                        else
                        { 
                            //如果是拆,检查条码是否是在容器中
                            if (isHuInContainer == false)
                            {
                                throw new BusinessException("条码未在容器中!");
                            }
                            this.smartDeviceService.ContainerUnBind(this._containerDetail.ContainerId, hu.HuId, this.user.Code);
                        }
                        //hus.Add(hu);
                        
                        this.isCancel = false;
                    }
                }
                else
                {
                    throw new BusinessException("条码格式不合法");
                }
            }
            else
            {
                if (op == CodeMaster.BarCodeType.HU.ToString())
                {
                    if (hus.Where(h => h.HuId == barCode).ToList().Count > 0)
                    {
                        this.hus = this.hus.Where(h => h.HuId != barCode).ToList();
                        base.gvHuListDataBind();
                    }
                    else
                    {
                        throw new BusinessException("条码{0}未扫入不需取消", barCode);
                    }
                }
            }
            this.gvHuListDataBind();
        }
예제 #6
0
 protected override void Reset()
 {
     this.hus = new List<Hu>();
     this._containerDetail = null;
     base.lblMessage.Text = "请扫描容器条码";
     base.lblMessage.ForeColor = Color.Black;
     //this.lblMessage.Text = string.Empty;
     this.tbBarCode.Text = string.Empty;
     this.isCancel = false;
     this.isMasterBind = true;
     this.lblBarCode.ForeColor = Color.Black;
     this.gvHuListDataBind();
     this.tbBarCode.Focus();
 }