Пример #1
0
        public string SaveAsDummy(string code, string editor, string customer, Boolean isNeedCheck)
        {
            try
            {
                IModelBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IModelBOMRepository, BOMNodeData>();
                IModelRepository iModelRepository = RepositoryFactory.GetInstance().GetRepository<IModelRepository>();
                IPartRepository iPartRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository>();
                IMiscRepository iMiscRepository = RepositoryFactory.GetInstance().GetRepository<IMiscRepository>();
                Model model = iModelRepository.Find(code);
                if (model == null)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("Input:" + code + " Error");
                    throw ex;
                }

                IList<FisObject.Common.Model.ModelInfo> modelInfoList = iModelRepository.GetModelInfoByModelAndName(code, "RealModel");
                if (modelInfoList.Count != 0)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("Model:" + code + " This Model is not RealModel ,can't Save as Dummy!");
                    throw ex;
                }

                DataTable ret = null;
                string getDummyModel = "";
                SqlParameter[] paramsArray = new SqlParameter[2];
                paramsArray[0] = new SqlParameter("@Model", SqlDbType.VarChar);
                paramsArray[0].Value = code;
                paramsArray[1] = new SqlParameter("@Customer", SqlDbType.VarChar);
                paramsArray[1].Value = customer;
                ret = IMES.Infrastructure.Repository._Schema.SqlHelper.ExecuteDataFill(IMES.Infrastructure.Repository._Schema.SqlHelper.ConnectionString_BOM, CommandType.StoredProcedure, "GetDummyModel", paramsArray);
                if (ret == null || ret.Rows.Count == 0)
                {
                    throw new Exception("SP:GetDummyModel Exec Error");
                }
                getDummyModel = ret.Rows[0][0].ToString();
                IUnitOfWork uow = new UnitOfWork();
                Model newmodel = iModelRepository.Find(getDummyModel);
                if (newmodel == null)
                {
                    iModelRepository.CopyModelDefered(uow, code, getDummyModel, 0, editor);
                }
                else
                {
                    List<string> erpara = new List<string>();
                    erpara.Add(getDummyModel);
                    FisException ex;
                    ex = new FisException("CHK1252", erpara);
                    throw ex;
                }

                IMES.FisObject.Common.Model.ModelInfo item = new IMES.FisObject.Common.Model.ModelInfo();
                item.ModelName = getDummyModel;
                item.Name = "RealModel";
                item.Value = code;
                item.Description = "RealModel";
                item.Editor = editor;
                item.Cdt = DateTime.Now;
                item.Udt = DateTime.Now;
                iModelRepository.AddModelInfoDefered(uow, item);
                DataTable result = itemRepository.GetMaterialById(getDummyModel);
                if (result.Rows.Count > 0)
                {
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT012", erpara);
                    throw ex;
                }
                itemRepository.SaveModelBOMAsDefered(uow, code, getDummyModel, editor);
                uow.Commit();
                return getDummyModel;
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// 删除Model属性
        /// </summary>
        /// <param name="item">属性名</param>
        public void DeleteAttribute(ModelInfo item)
        {
            if (item == null)
                return;

            lock (_syncObj_attributes)
            {
                object naught = Attributes;
                if (_attributes != null)
                {
                    ModelInfo miFound = null;
                    foreach (ModelInfo mi in _attributes)
                    {
                        if (mi.Key.Equals(item.Key))
                        {
                            miFound = mi;
                            break;
                        }
                    }
                    if (miFound != null)
                    {
                        //this._attributes.Remove(miFound);
                        miFound.Tracker = null;
                        _tracker.MarkAsDeleted(miFound);
                        _tracker.MarkAsModified(this);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 增加Model属性
        /// </summary>
        /// <param name="item">属性</param>
        public void AddAttribute(ModelInfo item)
        {
            if (item == null)
                return;

            lock (_syncObj_attributes)
            {
                object naught = Attributes;
                if (_attributes != null)
                {
                    if (_attributes.Contains(item))
                        return;

                    item.Tracker = _tracker.Merge(item.Tracker);
                    _attributes.Add(item);
                    _tracker.MarkAsAdded(item);
                    _tracker.MarkAsModified(this);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 更新Model属性
        /// </summary>
        /// <param name="item">属性</param>
        public void ChangeAttribute(ModelInfo item)
        {
            if (item == null)
                return;

            lock (_syncObj_attributes)
            {
                object naught = Attributes;
                if (this._attributes != null)
                {
                    int idx = 0;
                    bool find = false;
                    foreach (ModelInfo mi in _attributes)
                    {
                        if (mi.Key.Equals(item.Key))
                        {
                            find = true;
                            break;
                        }
                        idx++;
                    }
                    if (find)
                    {
                        _attributes[idx] = item;
                        _tracker.MarkAsModified(_attributes[idx]);
                        _tracker.MarkAsModified(this);
                    }
                }
            }
        }
Пример #5
0
        private IMES.FisObject.Common.Model.ModelInfo convertToModelInfoObjFromModelInfoMaintainInfo(ModelInfoMaintainInfo temp)
        {
            IMES.FisObject.Common.Model.ModelInfo modelinfo = new IMES.FisObject.Common.Model.ModelInfo();

            modelinfo.Name = temp.Name;
            modelinfo.Value = temp.Value;
            modelinfo.ID = temp.Id;
            modelinfo.Editor = temp.Editor;
            modelinfo.Cdt = temp.Cdt;
            modelinfo.Udt = temp.Udt;
            modelinfo.ModelName = temp.Model;

            return modelinfo;
        }