Beispiel #1
0
        /// <summary>
        /// Import MTO 메뉴얼 등록시  
        /// </summary>
        /// <param name="objComponent"></param>
        /// <returns></returns>
        public SigmaResultType AddComponetInfo(TypeComponent objComponent)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();
            SigmaResultType resultComponent = new SigmaResultType();
            ComponentCustomFieldMgr ComCustomFieldMgr = new ComponentCustomFieldMgr();

            using (scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                if (objComponent.ComponentId > 0)
                {
                    resultComponent = UpdateComponent(objComponent);
                }
                else
                {
                    resultComponent = AddComponent(objComponent);

                    objComponent.ComCustomField.ForEach(item => item.ComponentId = resultComponent.ScalarValue);
                }

                if (resultComponent.IsSuccessful && objComponent.ComCustomField.Count > 0)
                {
                    ComponentCustomFieldMgr comcustomfieldMgr = new ComponentCustomFieldMgr();
                    TypeComponentCustomField cutomobj = new TypeComponentCustomField();
                    cutomobj.ComponentId = objComponent.ComponentId;
                    comcustomfieldMgr.RemoveComponentCustomField(cutomobj);

                    foreach (var item in objComponent.ComCustomField)
                    {
                        if (item.CustomFieldId == 0)
                        {
                            TypeCustomField obj = SetTypeCustomFieldObj(item);
                            CustomFieldMgr customFieldMtr = new CustomFieldMgr();
                            obj = customFieldMtr.GetCustomField(obj);
                            item.CustomFieldId = obj.CustomFieldId;
                        }

                        switch (item.SigmaOperation)
                        {
                            case SigmaOperation.INSERT:
                                ComCustomFieldMgr.AddComponentCustomField(item);
                                break;
                            case SigmaOperation.UPDATE:
                                ComCustomFieldMgr.UpdateComponentCustomField(item);
                                break;
                            case SigmaOperation.DELETE:
                                ComCustomFieldMgr.RemoveComponentCustomField(item);
                                break;
                        }
                    }
                }

                result.AffectedRow = resultComponent.AffectedRow;
                result.ScalarValue = resultComponent.ScalarValue;
                result.IsSuccessful = true;

                scope.Complete();
            }
            return result;
        }
        public SigmaResultType RemoveComponentCustomField(TypeComponentCustomField objComponentCustomField)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                ComponentCustomFieldMgr componentCustomFieldMgr = new ComponentCustomFieldMgr();
                result = componentCustomFieldMgr.RemoveComponentCustomField(objComponentCustomField);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }