private IEnumerable <PMConfig> GetProperties(NativeActivityContext context) { var artL = ArtLst.Get(context); var entity = Entity.Get(context); var obj = entity as WMSBusinessObject; if (obj == null) { throw new NotImplementedException(string.Format("Тип '{0}' не поддерживается", entity.GetType())); } var objname = SourceNameHelper.Instance.GetSourceName(obj.GetType()); var operationCode = OperationCode.Get(context); var resLst = new List <PMConfig>(); using (var pmConfigMgr = IoC.Instance.Resolve <IPMConfigManager>()) { SetUnitOfWork(context, pmConfigMgr); // параметры для сверки по артикулу и операции, фильтр по имени сущности foreach (var art in artL) { resLst.AddRange(pmConfigMgr.GetPMConfigByParamListByArtCode(art.ArtCode, operationCode, null).Where(pm => pm.ObjectEntitycode_R == objname.ToUpper())); } } return(resLst); }
private IEnumerable <MustSetShowConfig> GetMustSetProperies(NativeActivityContext context) { SKU sku; var skuId = SKU.Get(context); var operationCode = OperationCode.Get(context); using (var mgr = GetManager <SKU>(context)) sku = mgr.Get(skuId); if (sku == null) { throw new DeveloperException(string.Format("SKU с кодом '{0}' не существует", skuId)); } var art = sku.ArtCode; using (var pmConfigMgr = IoC.Instance.Resolve <IPMConfigManager>()) { SetUnitOfWork(context, pmConfigMgr); var set = pmConfigMgr.GetPMConfigByParamListByArtCode(art, operationCode, "MUST_SET"); var res = set.Select(item => new MustSetShowConfig(item, true)).ToList(); var show = pmConfigMgr.GetPMConfigByParamListByArtCode(art, operationCode, "MUST_SHOW"); foreach (var item in show) { var p = res.FirstOrDefault(i => i.PmConfig.PM2OperationCode_r == item.PM2OperationCode_r && i.PmConfig.ObjectName_r == item.ObjectName_r && i.PmConfig.ObjectEntitycode_R == item.ObjectEntitycode_R); if (p == null) { res.Add(new MustSetShowConfig(item, false) { Show = true }); } else { p.Show = true; } } return(res); } }
private IEnumerable <PMConfig> GetManualCorrectProperies(NativeActivityContext context) { SKU sku; var skuId = SKU.Get(context); var operationCode = OperationCode.Get(context); using (var mgr = GetManager <SKU>(context)) sku = mgr.Get(skuId); if (sku == null) { throw new DeveloperException(string.Format("SKU с кодом '{0}' не существует", skuId)); } var art = sku.ArtCode; using (var pmConfigMgr = IoC.Instance.Resolve <IPMConfigManager>()) { SetUnitOfWork(context, pmConfigMgr); return(pmConfigMgr.GetPMConfigByParamListByArtCode(art, operationCode, "CAN_PRODUCT_MANUAL_CORRECT")); } }
protected override void Execute(NativeActivityContext context) { var width = DialogWidth.Get(context); var height = DialogHeight.Get(context); var placeFilter = PlaceFilter.Get(context); var operationCode = OperationCode.Get(context); var place = InvoicePlace.Get(context); var obj = (IWBPosInputWithPlaceListViewModel)IoC.Instance.Resolve(typeof(IWBPosInputWithPlaceListViewModel)); var mandantId = MandantID.Get(context); obj.PrintTE = CheckPrintTE(mandantId); obj.PlaceFilter = placeFilter; obj.OperationCode = operationCode; obj.MandantId = mandantId; var isMigration = IsMigration.Get(context); obj.IsMigration = isMigration; obj.BatchcodeWorkflowCode = BatchcodeWorkflowCode.Get(context); obj.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context); var model = obj as ICustomListViewModel <IWBPosInput>; if (model == null) { throw new DeveloperException("ViewModel doesn't implement ICustomListViewModel."); } model.PanelCaption = Title; var source = Source.Get(context).Select(p => new IwbPosInputErrorInfo(p) { IsSelected = false }); model.SetSource(new ObservableCollection <IWBPosInput>(source)); obj.CurrentPlace = place; var viewService = IoC.Instance.Resolve <IViewService>(); if (viewService.ShowDialogWindow(model, true, false, width, height) == true) { var result = model.GetSource() as IEnumerable <IWBPosInput>; if (result == null) { throw new DeveloperException("Source type is not IEnumerable."); } if (obj.SelectedItems != null && obj.SelectedItems.Any()) { // пометим выбранные записи foreach (var r in result) { r.IsSelected = obj.SelectedItems.Contains(r); } } Result.Set(context, result.ToArray()); InvoicePlace.Set(context, obj.SelectedPlace); DialogResult.Set(context, true); } else { DialogResult.Set(context, false); } PrintTE.Set(context, ((IWBPosInputWithPlaceListViewModel)model).PrintTE); var disposable = model as IDisposable; if (disposable != null) { disposable.Dispose(); } }
protected override void Execute(NativeActivityContext context) { const string isnullerrorformat = "Свойство '{0}' должно быть задано."; var gridFieldsStr = GridFields.Get(context); if (string.IsNullOrEmpty(gridFieldsStr)) { throw new DeveloperException(isnullerrorformat, GridFieldsDisplayName); } _objNameGrid = new List <string>(gridFieldsStr.Split(new [] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries)); var productList = ProductList.Get(context); var operationCode = OperationCode.Get(context); var needShowGreed = NeedShowSelectGrid.Get(context); try { var productsList = new List <Tuple <string, Product> >(); var userGrpPrd = new List <Product>(); //получим настройки менеджера товара using (var mgr = IoC.Instance.Resolve <IPMConfigManager>()) { foreach (var prd in productList) { var groupKeys = new StringBuilder(); //обязательная группировка по skuid groupKeys.AppendFormat("{0}={1}_", Product.SKUIDPropertyName, prd.SKUID); var confs = mgr.GetPMConfigByParamListByProductId(prd.ProductId, operationCode, null).ToArray(); //формируем группы по товару и настройке менеджера товара foreach (var pmConfig in confs.OrderBy(x => x.ObjectName_r)) { var prdprop = prd.GetProperty(pmConfig.ObjectName_r) ?? string.Empty; _objNameGrid.Add(pmConfig.ObjectName_r); groupKeys.AppendFormat("{0}={1}_", pmConfig.ObjectName_r, prdprop); } productsList.Add(new Tuple <string, Product>(groupKeys.ToString(), prd)); } } //формируем коллекцию товара для отображения + сумма по группам var grpPoductsList = productsList.GroupBy(p => p.Item1, v => v.Item2).ToArray(); foreach (var gr in grpPoductsList) { var product = (Product)gr.First().Clone(); product.ProductCountSKU = gr.Sum(p => p.ProductCountSKU); userGrpPrd.Add(product); } //если всего 1 группа и needShowGreed == false, грид не показываем if (grpPoductsList.Length == 1 && !needShowGreed) { OutGroupProductList.Set(context, userGrpPrd); OutProductList.Set(context, grpPoductsList[0].ToList()); return; } var dialogRet = ShowMain(userGrpPrd); //выбираем товар, в соответствии с выбором пользователя var outGroupProductList = new List <Product>(); var outProductList = new List <Product>(); if (dialogRet && _selectedPrd != null) { outGroupProductList = userGrpPrd.Where(p => p.GetKey <decimal>() == _selectedPrd).ToList(); var grkey = (from gr in grpPoductsList where gr.Any(p => p.GetKey <decimal>() == _selectedPrd) select gr.Key).FirstOrDefault(); outProductList = grpPoductsList.Where(g => g.Key == grkey).SelectMany(p => p).ToList(); } OutGroupProductList.Set(context, outGroupProductList); OutProductList.Set(context, outProductList); DialogResult.Set(context, dialogRet); } catch (Exception ex) { var message = "Ошибка при получении настроек менеджера товара. " + ExceptionHelper.GetErrorMessage(ex, false); ShowWarning(message); } }
protected override void Execute(NativeActivityContext context) { const string isnullerrorformat = "Свойство '{0}' должно быть задано."; var entities = Entities.Get(context); if (entities == null) { throw new DeveloperException(isnullerrorformat, EntitiesDisplayName); } var artcodepropertyname = ArtCodePropertyName.Get(context); if (string.IsNullOrEmpty(artcodepropertyname)) { throw new DeveloperException(isnullerrorformat, ArtCodePropertyNameDisplayName); } var operationCode = OperationCode.Get(context); if (string.IsNullOrEmpty(operationCode)) { throw new DeveloperException(isnullerrorformat, OperationCodeDisplayName); } var boEntities = entities.OfType <WMSBusinessObject>().ToArray(); //Получаем список артикулов из Entities var arts = boEntities.Select(p => p.GetProperty <string>(artcodepropertyname)).Distinct().ToArray(); var result = boEntities.ToArray(); var objFields = DataFieldHelper.Instance.GetDataFields(typeof(T), SettingDisplay.Detail); foreach (var artcode in arts) { var propList = GetPmMethodProperies(artcode, operationCode, context); var boEntity = result.FirstOrDefault(p => p.GetProperty <string>(artcodepropertyname) == artcode); if (boEntity == null) { continue; } foreach (var method in propList.Keys) { foreach (var property in propList[method]) { var compareValues = result.Select(p => p.GetProperty(property)).Distinct().ToArray(); if (compareValues.Length <= 1) { continue; //Пропускаем } var datafield = objFields.FirstOrDefault(i => i.Name.EqIgnoreCase(property)); if (datafield == null) { throw new DeveloperException( "Ошибка в настройках '{0}' PM. Задан неизвестный параметр '{1}'.", method, property); } var field = new ValueDataField(datafield) { LabelPosition = "Top" }; if (method == PMMethods.MUST_COMPARE_VISIBLE) { field.Value = boEntity.GetProperty(property); } if (string.IsNullOrEmpty(field.LookupCode)) { field.CloseDialog = true; } else //Если поле лукап { field.LabelPosition = "None"; field.Set(ValueDataFieldConstants.LookupType, RclLookupType.SelectControl.ToString()); field.Set(ValueDataFieldConstants.MaxRowsOnPage, MaxRowsOnPage.Get(context)); } var model = CreateDialogModel(context, field); while (true) // делаем это для возврата на форму { if (!ShowDialog(model)) { throw new OperationException("Значения полей не были указаны."); } var errorMessage = new StringBuilder(); switch (string.Format("1{0}", model.MenuResult)) { case "1": case "1Return": var value = model[field.Name]; if (!compareValues.Any(p => Equals(value, p))) { errorMessage.AppendLine(string.Format("Неверное значение поля '{0}'.", field.Caption)); } else { result = result.Where(p => Equals(value, p.GetProperty(property))).ToArray(); } break; default: throw new DeveloperException("Неизвестная команда."); } // если были ошибки, то покажем что не так и вернемся на форму if (errorMessage.Length > 0) { var viewService = IoC.Instance.Resolve <IViewService>(); viewService.ShowDialog("Ошибка", errorMessage.ToString(), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } else { break; } } } } } Result.Set(context, result.OfType <T>().ToArray()); }
protected override void Execute(NativeActivityContext context) { var width = DialogWidth.Get(context); var height = DialogHeight.Get(context); var placeFilter = PlaceFilter.Get(context); var operationCode = OperationCode.Get(context); var place = InvoicePlace.Get(context); var iwb = IWB.Get(context); var mandantId = MandantID.Get(context); using (var viewModel = (AcceptanceViewModel)IoC.Instance.Resolve(typeof(AcceptanceViewModel))) { viewModel.PrintTE = CheckPrintTE(mandantId); viewModel.PlaceFilter = placeFilter; viewModel.OperationCode = operationCode; viewModel.MandantId = mandantId; viewModel.CurrentIWB = iwb; viewModel.IsMigration = IsMigration.Get(context); viewModel.BatchcodeWorkflowCode = BatchcodeWorkflowCode.Get(context); viewModel.SkuChangeMpWorkflowCode = SkuChangeMpWorkflowCode.Get(context); viewModel.PanelCaption = Title; viewModel.IsProductsShown = IsNeedShowProducts.Get(context); viewModel.DisplayFieldsFormat = DisplayFieldsFormat.Get(context); if (place != null) { viewModel.AcceptancePlace = new EntityReference(place.PlaceCode, Place.EntityType, new[] { new EntityReferenceFieldValue("PlaceCode", place.PlaceCode), new EntityReferenceFieldValue("PlaceName", place.PlaceName) }); } ((IModelHandler)viewModel).SetSource(Source.Get(context)); var viewService = IoC.Instance.Resolve <IViewService>(); if (viewService.ShowDialogWindow(viewModel, true, false, width, height, noButtons: true) == true && viewModel.IsAllowAccept == true) { if (viewModel.SelectedItems != null && viewModel.SelectedItems.Any()) { // пометим выбранные записи foreach (var r in viewModel.Source) { r.IsSelected = viewModel.SelectedItems.Contains(r); } } Result.Set(context, viewModel.Source.Cast <IWBPosInput>().ToArray()); var acceptancePlace = GetAcceptancePlace(viewModel); InvoicePlace.Set(context, acceptancePlace); IsNeedShowProducts.Set(context, viewModel.IsProductsShown); DialogResult.Set(context, true); } else { DialogResult.Set(context, false); } PrintTE.Set(context, viewModel.PrintTE); } }