public void FillFromSku(WMSBusinessObject entity) { var obj = entity as IWBPos; if (obj == null) { return; } SKU sku = null; using (var mgr = GetManager <SKU>()) sku = mgr.Get(obj.SKUID); if (sku == null) { obj.VArtName = null; obj.VArtDesc = null; obj.VMeasureName = null; obj.IWBPosCount2SKU = 0; return; } obj.VArtName = sku.ArtCode; obj.VArtDesc = sku.VArtDesc; obj.VMeasureName = sku.VMeasureName; obj.IWBPosCount2SKU = sku.SKUCount; }
public void OnSourcePropertyInternalChanged(object newvalue) { if (newvalue == null) { CurrentItem = null; } if (Source == null) { return; } UpdateSource(null); ChildSource.Clear(); if (Source == null || Source.Count == 0) { return; } var keys = Source.Select(item => (object)item.ENTITY2GCKEY).ToList(); var pk = WMSBusinessObject.GetPrimaryKeyPropertyName(_itemType); var pkSourceName = SourceNameHelper.Instance.GetPropertySourceName(_itemType, pk); using (var mgr = GetManager(_itemType)) { var items = mgr.GetFiltered(FilterHelper.GetFilterIn(pkSourceName, keys)); ChildSource.AddRange(items); } }
public PrintReportStatus PrintReport(WMSBusinessObject entity, string reportCode, string printerCode = null, IEnumerable <OutputParam> paramExt = null) { decimal? mandantcode = GetMandantCode(entity); PrinterLogical printerLogical; var output = CreateOutput(entity, reportCode, mandantcode, printerCode, paramExt, out printerLogical); if (printerLogical == null) { throw new DeveloperException("Не настроен логический принтер"); } using (var outputManager = (IOutputManager)GetManager <Output>()) { var result = new PrintReportStatus { Printer = printerLogical.PhysicalPrinter_R }; try { var outTask = outputManager.PrintReport(output); result.Job = outTask.GetKey().ToString(); } catch (Exception ex) { result.Error = ex.Message; } return(result); } }
public void FillData(WMSBusinessObject entity) { var obj = entity as CargoOWB; if (obj == null) { return; } obj.Vehicle = null; obj.WorkerFIO = null; if (obj.InternalTrafficID == null) { return; } InternalTraffic it; using (var mgr = GetManager <InternalTraffic>()) it = mgr.Get(obj.InternalTrafficID, GetModeEnum.Partial); if (it.ExternalTrafficID == null) { return; } ExternalTraffic et = null; using (var mgrET = GetManager <ExternalTraffic>()) et = mgrET.Get(it.ExternalTrafficID); if (et == null) { return; } if (et.VVehicleRN != null) { obj.Vehicle = et.VVehicleRN; } if (et.Driver == null) { return; } Worker worker = null; using (var mgrWorker = GetManager <Worker>()) worker = mgrWorker.Get(et.Driver); if (worker == null) { return; } if (worker.WorkerFIO != null) { obj.WorkerFIO = worker.WorkerFIO; } }
public ReportRedefinition GetDefaultReport(WMSBusinessObject entity, string host, string reportfilename, decimal?mandantcode) { var type = typeof(PrintStreamConfig); var tlist = new List <string> { CreateTparam(ReportRedefinition.Report_RPropertyName, reportfilename, type), CreateTparam(ReportRedefinition.Host_RPropertyName, host, type), CreateTparam(ReportRedefinition.PartnerId_RPropertyName, mandantcode, type) }; if (entity != null) { var entityprdsc = TypeDescriptor.GetProperties(entity.GetType()); var typeofReportRedefinition = typeof(ReportRedefinition); var reportRedefinitionprdsc = TypeDescriptor.GetProperties(typeofReportRedefinition); foreach (PropertyDescriptor p in reportRedefinitionprdsc) { var property = entityprdsc.Find(p.Name, true); if (property != null && !property.Name.EqIgnoreCase(WMSBusinessObject.UserInsPropertyName) && !property.Name.EqIgnoreCase(WMSBusinessObject.DateInsPropertyName) && !property.Name.EqIgnoreCase(WMSBusinessObject.UserUpdPropertyName) && !property.Name.EqIgnoreCase(WMSBusinessObject.DateUpdPropertyName)) { tlist.Add(CreateTparam(p.Name, property.GetValue(entity), typeofReportRedefinition)); } } } return(GetDefaultReport(CreateTListParams(tlist))); }
private void UpdateSource() { WMSBusinessObject sourcebase = null; if (_notClearInputData) { if (_oldSource != null) { sourcebase = (WMSBusinessObject)_oldSource.Clone(); } } else { if (SourceBase != null) { sourcebase = (WMSBusinessObject)SourceBase.Clone(); sourcebase.AcceptChanges(true); } } if (sourcebase != null) { sourcebase.Validate(); Source = (TModel)((object)sourcebase); } }
/// <summary> /// Получение манданта у бизнес объекта /// </summary> /// <param name="obj">бизнес объект</param> /// <returns>код манданта</returns> public static decimal?GetMandantId(WMSBusinessObject obj) { var properties = TypeDescriptor.GetProperties(obj); //HACK: переделать на нормальную схему var property = properties["MANDANTID"]; if (property == null) { return(null); } return((decimal?)property.GetValue(obj)); }
protected void UpdateOldSource() { if (Mode == ObjectViewModelMode.Object) { return; } var source = Source as WMSBusinessObject; if (source != null && source.IsNew) { _oldSource = source; } }
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (DataContext != null) { _parentViewModelSource = DataContext as WMSBusinessObject; } if (_parentViewModelSource != null) { //HACK: Используется для VarFilter и многого другого RaiseCanExecuteChanged(); SubscribeSource(); } }
private static decimal?GetMandantCode(WMSBusinessObject entity) { // decimal? mandantCode = null; // if (entity != null) // { // //Поиск манданта // var mto = IoC.Instance.Resolve<IManagerForObject>(); // var mgrType = mto.GetManagerByTypeName(entity.GetType().Name); // var managerInstance = IoC.Instance.Resolve(mgrType, null) as IMandantHandler; // mandantCode = managerInstance == null ? null : managerInstance.GetMandantCode(entity); // } // return mandantCode; return(BPH.GetMandantId(entity)); }
public void Block(WMSBusinessObject obj, ProductBlocking blocking, string description) { // TODO Здесь должна быть проверка прав на блокировку if (obj == null) { throw new ArgumentNullException("obj"); } var place = (Place)obj; var filter = string.Format("{0} = '{1}' AND {2} = '{3}'", SourceNameHelper.Instance.GetPropertySourceName(typeof(Place2Blocking), Place2Blocking .Place2BlockingPlaceCodePropertyName), place.GetKey().ToString().ToUpper(), SourceNameHelper.Instance.GetPropertySourceName(typeof(Place2Blocking), Place2Blocking .Place2BlockingBlockingCodePropertyName), blocking.GetKey().ToString().ToUpper()); using (var mgr = GetManager <Place2Blocking>()) { var existsBlockings = mgr.GetFiltered(filter); if (existsBlockings.Any()) { throw new OperationException("Для места с кодом '{0}', уже существует блокировка с кодом '{1}'", place.PlaceCode, blocking.BlockingCode); } var place2Block = new Place2Blocking { Place2BlockingDesc = description, Place2BlockingBlockingCode = blocking.BlockingCode, Place2BlockingPlaceCode = place.PlaceCode }; try { ((ISecurityAccess)this).SuspendRightChecking(); mgr.Insert(ref place2Block); } finally { ((ISecurityAccess)this).ResumeRightChecking(); } } }
private void CheckParam(Output output, WMSBusinessObject entity, Report report) { var entitypds = TypeDescriptor.GetProperties(entity); var parameters = report.ConfigRep.Where(p => p != null && !p.EpsConfigLocked); foreach (var configRep in parameters) { var epsConfigParamCode = configRep.EpsConfigParamCode; string str = null; if (epsConfigParamCode.To(EpsTaskParams.None) == EpsTaskParams.None) { if (string.IsNullOrEmpty(epsConfigParamCode)) { continue; } //Variable //Если наименование параметра отчета имеет формат {Параметр}, то в значение такого параметра подставляем значение свойства сущности если есть. var expressions = _regex.Matches(epsConfigParamCode); if (expressions.Count > 0) { var parametername = expressions[0].Groups[1].Value; var entityprop = entitypds.Find(parametername, true); if (entityprop != null) { var value = entityprop.GetValue(entity); str = value == null ? null : value.To <string>(); epsConfigParamCode = parametername; //убираем {} из названия параметра } } } output.ReportParams.Add(new OutputParam { OutputParamCode = epsConfigParamCode, OutputParamValue = str, OutputParamSubvalue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); } }
protected override XmlDocument GetXmlDocument(WMSBusinessObject item) { var mgr = IoC.Instance.Resolve <IXamlManager <T> >(); var xaml = mgr.GetXaml(item.GetKey()); var xmlDocument = XmlDocumentConverter.ConvertFrom(item); if (string.IsNullOrEmpty(xaml)) { return(xmlDocument); } var el = xmlDocument.CreateElement(TagName); el.InnerText = xaml; if (xmlDocument.DocumentElement != null) { xmlDocument.DocumentElement.AppendChild(el); } return(xmlDocument); }
public List <BillOperationCause> GetCause(WMSBusinessObject entity) { if (entity == null) { return(null); } var actD = entity as BillWorkActDetail; if (actD == null || actD.Operation2ContractID == null) { return(null); } var filter = string.Format("OPERATION2CONTRACTID_R = {0}", actD.Operation2ContractID); List <BillOperationCause> res; using (var mgr = GetManager <BillOperationCause>()) res = mgr.GetFiltered(filter).ToList(); return(res); }
public void FillMandantAndFactory(WMSBusinessObject entity) { var obj = entity as IWBPos; if (obj == null) { return; } if (obj.IWBID_R == null) { obj.MandantID = null; obj.FactoryID_R = null; return; } IWB iwb = null; using (var mgr = GetManager <IWB>()) iwb = mgr.Get(obj.IWBID_R); obj.MandantID = iwb == null ? null : iwb.MandantID; obj.FactoryID_R = iwb == null ? null : iwb.FactoryID_R; }
protected static bool Validate(WMSBusinessObject obj) { if (obj != null && !obj.IsPersisted()) { DefaultValueSetter.Instance.SetDefaultValues(obj); } var valid = obj as IValidatable; if (valid == null) { return(true); } valid.Validate(); // если критических ошибок нет - можно продолжать if (!valid.Validator.HasCriticalError()) { return(true); } return(false); }
private void InitializeLookUpCodeEditor() { if (string.IsNullOrEmpty(LookUpCodeEditor)) { throw new DeveloperException("Lookup code is not set."); } LookupInfo = LookupHelper.GetLookupInfo(LookUpCodeEditor); // определяем максимально кол-во элементов, которые нужно получать MaxFetchItemsCount = LookupInfo.FetchRowCount.HasValue ? Convert.ToInt32(LookupInfo.FetchRowCount.Value) : (int?)null; var filtertxt = LookupInfo.Filter; filtertxt += string.IsNullOrEmpty(LookUpCodeEditorVarFilterExt) ? string.Empty : LookUpCodeEditorVarFilterExt; // если извне хотят управлять колонками - пусть сам и управляют if (LookUpColumnsSource == null) { LookUpColumnsSource = DataFieldHelper.Instance.GetDataFields(LookupInfo.ItemType, SettingDisplay.LookUp); } LookupHelper.InitializeVarFilter(filtertxt, out _filter0, out _varFilter); // инстанируем ManagerInstance = LookupHelper.GetItemSourceManager(LookupInfo); ManagerInstance.AllowMonitorChangesInOtherInsances = true; // получим property - primarykey _primaryKeyPropertyName = WMSBusinessObject.GetPrimaryKeyPropertyName(LookupInfo.ItemType); }
public decimal?GetMandantCode(WMSBusinessObject bo) { var entity = bo as Partner; return(entity == null ? null : entity.MandantId); }
protected override void Execute(NativeActivityContext context) { var width = DialogWidth.Get(context); var height = DialogHeight.Get(context); var workings = WorkingProp.Get(context); if (workings == null) { workings = new List <Working>(); } var vm = (InputPlPosListViewModel)IoC.Instance.Resolve(typeof(InputPlPosListViewModel)); vm.PanelCaption = Title.Get(context); vm.ActionWorkflowCode = ActionWorkflowCode.Get(context); var source = Source.Get(context); if (source != null) { source.ForEach(p => p.AcceptChanges()); } ((IModelHandler)vm).SetSource(new ObservableCollection <InputPlPos>(source)); var viewService = IoC.Instance.Resolve <IViewService>(); var dialogResult = viewService.ShowDialogWindow(viewModel: vm, isRestoredLayout: true, isNotNeededClosingOnOkResult: true, width: width, height: height); if (dialogResult == true) { var result = ((IModelHandler)vm).GetSource() as IEnumerable <InputPlPos>; if (result == null) { throw new DeveloperException("Source type is not IEnumerable."); } Result.Set(context, result.ToList()); } DialogResult.Set(context, dialogResult); workings.Clear(); if (vm.Workings != null) { foreach (var w in vm.Workings) { var working = new Working(); try { working.SuspendNotifications(); WMSBusinessObject.Copy(w, working); working.AcceptChanges(); } finally { working.ResumeNotifications(); } workings.Add(working); } } WorkingProp.Set(context, workings); var disposable = vm as IDisposable; if (disposable != null) { disposable.Dispose(); } }
public Stream ExpReport(string reportCode, string fileName, string path, WMSBusinessObject entity, IEnumerable <OutputParam> paramExt = null) { if (string.IsNullOrEmpty(reportCode)) { throw new ArgumentNullException("reportCode"); } Report report; using (var reportManager = GetManager <Report>()) report = reportManager.Get(reportCode); if (report.ReportLocked) { return(null); } //return new PrintReportStatus(wmsMLC.General.Resources.StringResources.FormatReportIsLocked, // report.ReportName); //получаем файл отчета ReportFile reportFile; using (var mgr = IoC.Instance.Resolve <IBaseManager <ReportFile> >()) reportFile = ((IReportFileManager)mgr).GetByReportFile(report.ReportFile_R); //Формируем задание для EPS Output output; var outputManager = (IOutputManager)GetManager <Output>(); output = outputManager.New(); output.Login_R = WMSEnvironment.Instance.AuthenticatedUser == null ? null : WMSEnvironment.Instance.AuthenticatedUser.GetSignature(); output.Host_R = WMSEnvironment.Instance.ClientCode; output.OutputStatus = OutputStatus.OS_NEW.ToString(); output.EpsHandler = report.EpsHandler; if (reportFile != null) { output.ReportFileSubfolder_R = reportFile.ReportFileSubfolder; } //Параметры отчета if (output.ReportParams == null) { output.ReportParams = new WMSBusinessCollection <OutputParam>(); } output.ReportParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.ResultReportFile.ToString(), OutputParamValue = Path.GetFileNameWithoutExtension(fileName), OutputParamSubvalue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); output.ReportParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.EpsReport.ToString(), OutputParamValue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); if (report.ConfigRep != null) { if (entity == null) { foreach (var configRep in report.ConfigRep.Where(p => p != null && !p.EpsConfigLocked)) { output.ReportParams.Add(new OutputParam { OutputParamCode = configRep.EpsConfigParamCode, OutputParamValue = configRep.EpsConfigValue, OutputParamSubvalue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); } } else { CheckParam(output, entity, report); } } // заполним доп. парамтеры отчета if (paramExt != null) { foreach (var p in paramExt) { output.ReportParams.Add(p); } } var outputTask = new OutputTask { //OutputTaskCode = EpsTaskType.OTC_SHARE.ToString(), OutputTaskCode = EpsTaskType.OTC_DCL.ToString(), OutputTaskOrder = 0, TaskParams = new WMSBusinessCollection <OutputParam>() }; outputTask.TaskParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.FileFormat.ToString(), OutputParamValue = "wmsMLC.EPS.wmsEPS.ExportTypes.FRFpx", OutputParamType = EpsParamType.TSK.ToString() }); outputTask.TaskParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.TargetFolder.ToString(), OutputParamValue = path, OutputParamType = EpsParamType.TSK.ToString() }); outputTask.TaskParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.CopyFile.ToString(), OutputParamValue = "1", OutputParamType = EpsParamType.TSK.ToString() }); output.OutputTasks = new WMSBusinessCollection <OutputTask> { outputTask }; return(outputManager.GetReportPreview(output)); //return new PrintReportStatus { Job = output.GetKey().ToString() }; }
public decimal?GetMandantCode(WMSBusinessObject bo) { return(null); }
private Output CreateOutput(WMSBusinessObject entity, string reportCode, decimal?mandantcode, string printerCode, IEnumerable <OutputParam> paramExt, out PrinterLogical printerLogical) { if (string.IsNullOrEmpty(reportCode)) { throw new ArgumentNullException("reportCode"); } Output output = null; printerLogical = null; //Формируем задание для EPS using (var outputManager = GetManager <Output>()) output = outputManager.New(); output.Login_R = WMSEnvironment.Instance.AuthenticatedUser == null ? null : WMSEnvironment.Instance.AuthenticatedUser.GetSignature(); output.Host_R = WMSEnvironment.Instance.ClientCode; output.OutputStatus = OutputStatus.OS_NEW.ToString(); //Определяем отчет //Используем вариант 2: RR -> SC var reportCodeInternal = reportCode; //1. RR var reportRedefinition = GetDefaultReport(entity, output.Host_R, reportCode, mandantcode); decimal reportRedefinitionCopies = 1; if (reportRedefinition != null && !reportRedefinition.ReportRedefinitionLocked && !string.IsNullOrEmpty(reportRedefinition.ReportRedefinitionReport)) { reportCodeInternal = reportRedefinition.ReportRedefinitionReport; reportRedefinitionCopies = reportRedefinition.ReportRedefinitionCopies; } Report report; using (var reportManager = GetManager <Report>()) report = reportManager.Get(reportCodeInternal); if (report == null) { return(output); } if (report.ReportLocked) { return(output); } output.EpsHandler = report.EpsHandler; //получаем файл отчета ReportFile reportFile; using (var mgr = IoC.Instance.Resolve <IBaseManager <ReportFile> >()) reportFile = ((IReportFileManager)mgr).GetByReportFile(report.ReportFile_R); if (reportFile != null) { output.ReportFileSubfolder_R = reportFile.ReportFileSubfolder; } //Параметры отчета if (output.ReportParams == null) { output.ReportParams = new WMSBusinessCollection <OutputParam>(); } output.ReportParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.EpsReport.ToString(), OutputParamValue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); if (report.ConfigRep != null && entity != null) { CheckParam(output, entity, report); } if (paramExt != null) { foreach (var p in paramExt) { output.ReportParams.Add(new OutputParam { OutputParamCode = p.OutputParamCode, OutputParamValue = p.OutputParamValue, OutputParamSubvalue = report.ReportFile_R, OutputParamType = EpsParamType.REP.ToString() }); } } //Задача на печать if (output.OutputTasks == null) { output.OutputTasks = new WMSBusinessCollection <OutputTask>(); } var outputTasks = new OutputTask { OutputTaskCode = EpsTaskType.OTC_PRINT.ToString(), OutputTaskOrder = 1, TaskParams = new WMSBusinessCollection <OutputParam>() }; //Определяем принтер //2. SC //Если ШК задан, то ищем логический принтер по ШК decimal printStreamConfigCopies = 1; using (var printerLogicalManager = GetManager <PrinterLogical>()) { if (!string.IsNullOrEmpty(printerCode)) { var filter = string.Format("({1} = '{0}' OR {2} = '{0}') AND {3} = 0", printerCode, SourceNameHelper.Instance.GetPropertySourceName(typeof(PrinterLogical), PrinterLogical.LOGICALPRINTERPropertyName).ToUpper(), SourceNameHelper.Instance.GetPropertySourceName(typeof(PrinterLogical), PrinterLogical.LogicalPrinterBarCodePropertyName).ToUpper(), SourceNameHelper.Instance.GetPropertySourceName(typeof(PrinterLogical), PrinterLogical.LogicalPrinterLockedPropertyName).ToUpper()); var printers = printerLogicalManager.GetFiltered(filter, GetModeEnum.Partial).ToArray(); if (printers.Length > 1) { throw new OperationException("По коду '{0}' найдено более одного принтера: {1}", printerCode, string.Join(",", printers.Select(i => i.GetKey()))); } if (printers.Length == 1) { printerLogical = printers[0]; } } //Если ШК задан и нашли логический принтер по ШК, то не используем SC if (printerLogical == null) { var printStreamConfig = GetDefaultPrinter(output.Host_R, output.Login_R, reportCodeInternal, mandantcode); if (printStreamConfig == null) { return(output); } if (printStreamConfig.PrintStreamLocked) { return(output); } if (string.IsNullOrEmpty(printStreamConfig.LogicalPrinter_R)) { return(output); } printStreamConfigCopies = printStreamConfig.PrintStreamCopies; printerLogical = printerLogicalManager.Get(printStreamConfig.LogicalPrinter_R, GetModeEnum.Partial); } } if (printerLogical == null) { return(output); } if (printerLogical.LogicalPrinterLocked) { return(output); } //Проверяем физический принтер PrinterPhysical printerPhysical; using (var printerPhysicalManager = GetManager <PrinterPhysical>()) printerPhysical = printerPhysicalManager.Get(printerLogical.PhysicalPrinter_R, GetModeEnum.Partial); if (printerPhysical == null) { return(output); } if (printerPhysical.PhysicalPrinterLocked) { return(output); } outputTasks.TaskParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.PhysicalPrinter.ToString(), OutputParamValue = printerLogical.PhysicalPrinter_R, OutputParamType = EpsParamType.TSK.ToString() }); decimal copies = report.ReportCopies * reportRedefinitionCopies * printStreamConfigCopies * printerLogical.LogicalPrinterCopies; outputTasks.TaskParams.Add(new OutputParam { OutputParamCode = EpsTaskParams.Copies.ToString(), OutputParamValue = copies.ToString(CultureInfo.InvariantCulture), OutputParamType = EpsParamType.TSK.ToString() }); output.OutputTasks.Add(outputTasks); return(output); }
public static T GetKey <T>(this WMSBusinessObject wmsBusinessObject) { return(wmsBusinessObject == null ? default(T) : (T)wmsBusinessObject.GetKey()); }
public static T Get <T>(this WMSBusinessObject wmsBusinessObject, string propertyname) { return((wmsBusinessObject == null || string.IsNullOrEmpty(propertyname)) ? default(T) : wmsBusinessObject.GetProperty <T>(propertyname)); }
public decimal?GetMandantCode(WMSBusinessObject bo) { return(bo == null ? null : bo.GetKey() as decimal?); }