Exemplo n.º 1
0
    void OnDisable()
    {
        if (Application.isPlaying)
        {
            return;
        }

        if (mRenderer != null)
        {
            mRenderer.sharedMaterials = MaterialReplace.Replace(mRenderer.sharedMaterials);
        }

        mDynamicMat = null;
        mMaterial   = null;
    }
Exemplo n.º 2
0
    void SetMaterials(Material[] mats)
    {
        mMaterial = MaterialReplace.Replace(mats);
        for (int i = 0; i < mMaterial.Length; ++i)
        {
            if (mMaterial[i] == null && mMatGUIDs.Count > i)
            {
                string guid = mMatGUIDs[i];
                mMaterial[i] = (Material)UnityEditor.AssetDatabase.LoadAssetAtPath(UnityEditor.AssetDatabase.GUIDToAssetPath(guid), typeof(Material));
            }
        }

        mMatGUIDs.Clear();
        foreach (Material mat in mMaterial)
        {
            string path = UnityEditor.AssetDatabase.GetAssetPath(mat);
            mMatGUIDs.Add(UnityEditor.AssetDatabase.AssetPathToGUID(path));
        }
    }
Exemplo n.º 3
0
        public async Task <ActionResult> Save(MaterialReplaceViewModel model)
        {
            DateTime           now = DateTime.Now;
            MethodReturnResult rst = new MethodReturnResult();

            #region 界面录入信息合规性检查
            using (MaterialServiceClient client = new MaterialServiceClient())
            {
                MethodReturnResult <Material> result = client.Get(model.ProductCode);
                if (result.Code != 0)
                {
                    rst.Code    = 1001;
                    rst.Message = String.Format("MES中不存在产品编码:{0}", model.ProductCode);
                    return(Json(rst));
                }
                else
                {
                    if (result.Data.IsProduct != true)
                    {
                        rst.Code    = 1001;
                        rst.Message = String.Format("物料编码[{0}]非产品!", model.ProductCode);
                        return(Json(rst));
                    }
                    if (model.OrderNumber != "*")
                    {
                        using (WorkOrderServiceClient clientOfWorkOrder = new WorkOrderServiceClient())
                        {
                            MethodReturnResult <WorkOrder> resultOfOrder = clientOfWorkOrder.Get(model.OrderNumber);
                            if (resultOfOrder.Code != 0)
                            {
                                rst.Code    = 1001;
                                rst.Message = String.Format("MES中不存在工单:{0}", model.OrderNumber);
                                return(Json(rst));
                            }
                            else
                            {
                                if (resultOfOrder.Data.MaterialCode != model.ProductCode)
                                {
                                    rst.Code    = 1001;
                                    rst.Message = String.Format("产品编码{0}与工单{1}不匹配!", model.ProductCode, model.OrderNumber);
                                    return(Json(rst));
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            using (ERPClient erpClient = new ERPClient())
            {
                MethodReturnResult <DataSet> ds_supplier  = erpClient.GetERPSupplier(model.OldMaterialSupplier);
                MethodReturnResult <DataSet> ds_supplier1 = erpClient.GetERPSupplier(model.NewMaterialSupplier);
                if (model.OldMaterialSupplier != "*")
                {
                    if (ds_supplier.Data == null || ds_supplier.Data.Tables[0].Rows.Count == 0)
                    {
                        rst.Code    = 1001;
                        rst.Message = String.Format("ERP中不存在供应商:{0}", model.OldMaterialSupplier);
                        return(Json(rst));
                    }
                    if (ds_supplier.Data != null || ds_supplier.Data.Tables[0].Rows.Count > 0)
                    {
                        //新增替换前供应商
                        using (SupplierServiceClient supplierClient = new SupplierServiceClient())
                        {
                            MethodReturnResult <Supplier> result = await supplierClient.GetAsync(model.OldMaterialSupplier);

                            if (result.Code != 0)
                            {
                                Supplier supplier = new Supplier()
                                {
                                    Key         = ds_supplier.Data.Tables[0].Rows[0]["CUSCODE"].ToString(),
                                    Name        = ds_supplier.Data.Tables[0].Rows[0]["CUSNAME"].ToString(),
                                    NickName    = " ",
                                    CreateTime  = now,
                                    EditTime    = now,
                                    Creator     = User.Identity.Name,
                                    Editor      = User.Identity.Name,
                                    Description = ""
                                };
                                rst = await supplierClient.AddAsync(supplier);

                                if (rst.Code != 0)
                                {
                                    return(Json(rst));
                                }
                            }
                        }
                    }
                }
                if (model.NewMaterialSupplier != "000000")
                {
                    if (ds_supplier1.Data == null || ds_supplier1.Data.Tables[0].Rows.Count == 0)
                    {
                        rst.Code    = 1001;
                        rst.Message = String.Format("ERP中不存在供应商:{0}", model.NewMaterialSupplier);
                        return(Json(rst));
                    }
                    //新增替换后供应商
                    using (SupplierServiceClient supplierClient1 = new SupplierServiceClient())
                    {
                        MethodReturnResult <Supplier> result = await supplierClient1.GetAsync(model.NewMaterialSupplier);

                        if (result.Code != 0)
                        {
                            Supplier supplier = new Supplier()
                            {
                                Key         = ds_supplier1.Data.Tables[0].Rows[0]["CUSCODE"].ToString(),
                                Name        = ds_supplier1.Data.Tables[0].Rows[0]["CUSNAME"].ToString(),
                                NickName    = " ",
                                CreateTime  = now,
                                EditTime    = now,
                                Creator     = User.Identity.Name,
                                Editor      = User.Identity.Name,
                                Description = ""
                            };
                            rst = await supplierClient1.AddAsync(supplier);

                            if (rst.Code != 0)
                            {
                                return(Json(rst));
                            }
                        }
                    }
                }

                //新增替换规则
                using (MaterialReplaceServiceClient client = new MaterialReplaceServiceClient())
                {
                    MaterialReplace obj = new MaterialReplace()
                    {
                        Key = new MaterialReplaceKey()
                        {
                            ProductCode         = model.ProductCode.ToString().Trim().ToUpper(),
                            OrderNumber         = model.OrderNumber.ToString().Trim().ToUpper(),
                            OldMaterialCode     = model.OldMaterialCode.ToString().Trim().ToUpper(),
                            OldMaterialSupplier = model.OldMaterialSupplier.ToString().Trim().ToUpper()
                        },
                        NewMaterialCode     = model.NewMaterialCode.ToString().Trim().ToUpper(),
                        NewMaterialSupplier = model.NewMaterialSupplier.ToString().Trim().ToUpper(),
                        Creator             = User.Identity.Name,
                        Editor      = User.Identity.Name,
                        CreateTime  = DateTime.Now,
                        EditTime    = DateTime.Now,
                        Description = model.Description
                    };
                    rst = await client.AddAsync(obj);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(ZPVMResources.StringResource.MaterialReplace_Save_Success);
                    }
                    return(Json(rst));
                }
            }
        }