private void OnSave()
        {
            if (!Mandants.Any())
            {
                return;
            }

            try
            {
                WaitStart();

                Close();

                var saveArrey = Mandants.Where(m => m.IsDirty);

                using (var bpManager = IoC.Instance.Resolve <IBPProcessManager>())
                {
                    foreach (var m in saveArrey)
                    {
                        bpManager.UpdateEntity(m);
                    }
                }

                IsSave = true;
            }
            finally
            {
                WaitStop();
            }
        }
        private void GetMandants()
        {
            try
            {
                WaitIndicatorVisible = true;

                var user = WMSEnvironment.Instance.AuthenticatedUser;

                Mandants.Clear();
                if (user == null)
                {
                    return;
                }

                using (var mgr = IoC.Instance.Resolve <IBaseManager <User2Mandant> >())
                {
                    var res =
                        mgr.GetFiltered(string.Format("USERCODE_R = '{0}'",
                                                      WMSEnvironment.Instance.AuthenticatedUser.GetSignature())).ToArray();
                    if (!res.Any())
                    {
                        return;
                    }

                    Array.Sort(res, (x, y) => string.Compare(x.MandantCode, y.MandantCode, StringComparison.Ordinal));
                    Mandants.AddRange(res);
                }
            }
            finally
            {
                WaitIndicatorVisible = false;
            }
        }
 private void DeleteSelectedMandant()
 {
     _selectedMandant.DeleteMe = true;
     _db.SetMandant(_selectedMandant);
     Mandants.Remove(_selectedMandant);
     SelectedMandant = null;
     RaisePropertyChangedEvent(nameof(SelectedMandant));
 }
        private void AddMandant()
        {
            Mandant neuerMandant = new Mandant()
            {
                Des = this.Des
            };

            _db.SetMandant(neuerMandant);
            Mandants.Add(neuerMandant);
            RaisePropertyChangedEvent(nameof(Mandants));
        }
        private void OnEdit()
        {
            if (SelectedMandant == null)
            {
                return;
            }

            var man = Mandants.First(m => m.MandantID == SelectedMandant.MandantID);

            man.User2MandantIsActive = !SelectedMandant.User2MandantIsActive;
        }
 private void LoadMandants()
 {
     if (Commons.Statics.CurrentLogin.IsDevLogin)
     {
         Mandants = _db.LoadMandants();
     }
     else
     {
         Mandants.Clear(); Mandants.Add(Commons.Statics.CurrentLogin.Mandant);
         // TODO: Childmandanten anzeigen
     }
 }
        protected override void Dispose(bool disposing)
        {
            if (Mandants != null)
            {
                Mandants.Clear();
            }

            if (Fields != null)
            {
                Fields.Clear();
            }

            SelectedMandant = null;
            base.Dispose(disposing);
        }
Пример #8
0
        protected override void Execute(NativeActivityContext context)
        {
            // получим все параметры
            var teCode = TeCode.Get(context);

            // переведем код ТЕ в верхний регистр
            if (!string.IsNullOrEmpty(teCode))
            {
                teCode = teCode.ToUpper();
            }
            var placeCode  = PlaceCode.Get(context);
            var isPack     = IsPack.Get(context);
            var length     = Length.Get(context);
            var width      = Width.Get(context);
            var height     = Height.Get(context);
            var tareWeight = TareWeight.Get(context);
            var weight     = Weight.Get(context);
            var mandants   = Mandants.Get(context);
            var teTypeCode = TeTypeCode.Get(context);
            var autoTeType = AutoTeType.Get(context);
            var extFilter  = Filter.Get(context);

            _fontSize = FontSize.Get(context);
            var suspendNotifyCollectionChanged = SuspendNotifyCollectionChanged.Get(context);

            var teManager = IoC.Instance.Resolve <IBaseManager <TE> >();

            try
            {
                if (suspendNotifyCollectionChanged)
                {
                    teManager.SuspendNotifications();
                }

                // если поле тип ТЕ пустое и не стоит признак пытаться определить тип ТЕ автоматически
                if (string.IsNullOrEmpty(teTypeCode) && !autoTeType)
                {
                    throw new OperationException("Не указан тип ТЕ");
                }

                // если поле тип ТЕ заполнено и установлен признак получения автоматически
                if (!string.IsNullOrEmpty(teTypeCode) && autoTeType)
                {
                    throw new OperationException("Неверные настройки получения типа ТЕ");
                }

                var uw = BeginTransactionActivity.GetUnitOfWork(context);
                if (uw != null)
                {
                    throw new OperationException("Действие в транзакции запрещено");
                }

                // проверим существование ТЕ
                if (!string.IsNullOrEmpty(teCode))
                {
                    var bpManager = IoC.Instance.Resolve <IBPProcessManager>();
                    var existTe   = bpManager.CheckInstanceEntity("TE", teCode);
                    if (existTe == 1)
                    {
                        var existTeObj = teManager.Get(teCode);
                        if (existTeObj == null)
                        {
                            throw new OperationException("Нет прав на ТЕ с кодом {0}", teCode);
                        }
                        ExceptionResult.Set(context, null);
                        TeCode.Set(context, teCode);
                        OutTe.Set(context, existTeObj);
                        Exist.Set(context, true);
                        Result.Set(context, true);
                        return;
                    }
                }

                // фильтр на тип ТЕ
                var filter = string.Empty;
                // фильтр по мандантам
                if (!string.IsNullOrEmpty(mandants))
                {
                    filter = string.Format(
                        "tetypecode in (select tt2m.tetypecode_r from wmstetype2mandant tt2m where tt2m.partnerid_r in ({0}))",
                        mandants);
                }

                // фильтр по упаковкам
                if (isPack)
                {
                    filter =
                        string.Format(
                            "{0}tetypecode in (select CUSTOMPARAMVAL.cpvkey from wmscustomparamvalue CUSTOMPARAMVAL  where CUSTOMPARAMVAL.CPV2ENTITY = 'TETYPE' and CUSTOMPARAMVAL.CUSTOMPARAMCODE_R = 'TETypeIsPackingL2' and CUSTOMPARAMVAL.CPVVALUE is not null and CUSTOMPARAMVAL.CPVVALUE != '0')",
                            string.IsNullOrEmpty(filter) ? string.Empty : filter + " and ");
                }

                // дополнительный фильтр по типам ТЕ
                if (!string.IsNullOrEmpty(extFilter))
                {
                    filter =
                        string.Format(
                            "{0}{1}",
                            string.IsNullOrEmpty(filter) ? string.Empty : filter + " and ", extFilter);
                }

                // если надо определить тип ТЕ автоматически
                if (autoTeType)
                {
                    teTypeCode = BPH.DetermineTeTypeCodeByTeCode(teCode, filter);
                }

                var teTypeObj = GetTeType(teTypeCode, filter);

                // если не выбрали тип ТЕ
                if (teTypeObj == null)
                {
                    ExceptionResult.Set(context, null);
                    TeCode.Set(context, teCode);
                    OutTe.Set(context, null);
                    Exist.Set(context, false);
                    Result.Set(context, false);
                    return;
                }

                var teObj = new TE();
                teObj.SetKey(teCode);
                teObj.SetProperty(TE.TETypeCodePropertyName, teTypeObj.GetKey());
                teObj.SetProperty(TE.CreatePlacePropertyName, placeCode);
                teObj.SetProperty(TE.CurrentPlacePropertyName, placeCode);
                teObj.SetProperty(TE.StatusCodePropertyName, TEStates.TE_FREE.ToString());
                teObj.SetProperty(TE.TEPackStatusPropertyName,
                                  isPack ? TEPackStatus.TE_PKG_CREATED.ToString() : TEPackStatus.TE_PKG_NONE.ToString());

                teObj.SetProperty(TE.TELengthPropertyName, length ?? teTypeObj.GetProperty(TEType.LengthPropertyName));
                teObj.SetProperty(TE.TEWidthPropertyName, width ?? teTypeObj.GetProperty(TEType.WidthPropertyName));
                teObj.SetProperty(TE.TEHeightPropertyName, height ?? teTypeObj.GetProperty(TEType.HeightPropertyName));
                teObj.SetProperty(TE.TETareWeightPropertyName,
                                  tareWeight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName));
                teObj.SetProperty(TE.TEMaxWeightPropertyName,
                                  tareWeight ?? teTypeObj.GetProperty(TEType.MaxWeightPropertyName));
                teObj.SetProperty(TE.TEWeightPropertyName,
                                  weight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName));

                ((ISecurityAccess)teManager).SuspendRightChecking();
                teManager.Insert(ref teObj);

                ExceptionResult.Set(context, null);
                TeCode.Set(context, teCode);
                OutTe.Set(context, teObj);
                Exist.Set(context, false);
                Result.Set(context, true);
            }
            catch (Exception ex)
            {
                TeCode.Set(context, teCode);
                ExceptionResult.Set(context, ex);
                OutTe.Set(context, null);
                Exist.Set(context, false);
                Result.Set(context, false);
            }
            finally
            {
                if (suspendNotifyCollectionChanged)
                {
                    teManager.ResumeNotifications();
                }
                ((ISecurityAccess)teManager).ResumeRightChecking();
            }
        }