public BindResult Bind(WixToolset.Extensibility.IBindContext context) { var extensionManager = context.ServiceProvider.GetService <IExtensionManager>(); var backendExtensions = extensionManager.Create <IWindowsInstallerBackendExtension>(); foreach (var extension in backendExtensions) { extension.PreBackendBind(context); } var validator = Validator.CreateFromContext(context, "darice.cub"); var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); var result = new BindResult { FileTransfers = command.FileTransfers, ContentFilePaths = command.ContentFilePaths }; foreach (var extension in backendExtensions) { extension.PostBackendBind(result, command.Pdb); } if (!String.IsNullOrEmpty(context.OutputPdbPath)) { command.Pdb?.Save(context.OutputPdbPath); } return(result); }
private void BindIterationGrid(IList projectTasks, IList projectIterations, BindResult bindResult) { IList taskIterationList = projectTasks.AsQueryable().Where("ProjectIterationId != null").Select("ProjectIterationId").Cast <Guid>().Distinct().ToArrayList(); List <ProjectSummary> IterationSummaryList = new List <ProjectSummary>(); var displayNameFormat = "{0} ({1:yy/MM/dd} - {2:yy/MM/dd})"; foreach (var iterationId in taskIterationList) { IList iterationList = projectIterations.AsQueryable().Where("ProjectIterationId=@0", iterationId).ToArrayList(); IList iterationNameList = iterationList.AsQueryable().Select("Name").Cast <string>().ToArrayList(); if (iterationNameList.Count <= 0) { continue; } ProjectSummary iterationItem = new ProjectSummary(); iterationItem.Name = iterationNameList[0].ToString(); IList taskList = projectTasks.AsQueryable().Where("ProjectIterationId=@0", iterationId).ToArrayList(); SumEntity(iterationItem, taskList); iterationItem.Id = (Guid)iterationId; var iteration = ConvertData.Convert <Katrin.Domain.Impl.ProjectIteration>(iterationList[0]); iterationItem.NameAndDate = string.Format(displayNameFormat, iterationItem.Name, iteration.StartDate, iteration.Deadline); iterationItem.StartDate = iteration.StartDate ?? DateTime.Today; IterationSummaryList.Add(iterationItem); } IterationSummaryList = IterationSummaryList.AsQueryable().OrderBy("StartDate desc ").ToList(); bindResult.IterationSummaryList = IterationSummaryList; }
public void ShowGrid(BindResult r, int num, Spectrum spec, int numOfId) { this._spec = spec; this._num = num; switch (r.MethodType) { case PredictMethod.Fitting: this.ShowfitGrid(r.GetResult <FittingResult>()); break; case PredictMethod.Identify: this.ShowIdGrid(r.GetResult <IdentifyResult>(), num, numOfId); break; case PredictMethod.PLSBind: this.ShowPLSGrid(r.GetResult <List <PLS1Result> >()); break; case PredictMethod.Integrate: this.ShowItgGrid(r.GetResult <List <IntegrateResultItem> >()); break; default: this.gridFit.Visible = false; this.gridId.Visible = false; this.gridItg.Visible = false; this.gridPLS.Visible = false; break; } }
public BindResult Bind(IBindContext context) { var extensionManager = context.ServiceProvider.GetService <IExtensionManager>(); var backendExtensions = extensionManager.Create <IWindowsInstallerBackendBinderExtension>(); foreach (var extension in backendExtensions) { extension.PreBackendBind(context); } var validator = Validator.CreateFromContext(context, "darice.cub"); var command = new BindDatabaseCommand(context, backendExtensions, validator); command.Execute(); var result = new BindResult { FileTransfers = command.FileTransfers, TrackedFiles = command.TrackedFiles }; foreach (var extension in backendExtensions) { extension.PostBackendBind(result, command.Pdb); } return(result); }
internal static CommandBinding CreateComplexNormalBinding( string name, Func <KeyInput, bool> predicate, KeyRemapMode remapMode = null, CommandFlags flags = CommandFlags.None) { var remapModeOption = FSharpOption.CreateForReference(remapMode); Func <KeyInput, BindResult <NormalCommand> > func = null; func = keyInput => { if (predicate(keyInput)) { var data = new BindData <NormalCommand>( remapModeOption, func.ToFSharpFunc()); return(BindResult <NormalCommand> .NewNeedMoreInput(data)); } return(BindResult <NormalCommand> .NewComplete(NormalCommand.NewPutAfterCaret(false))); }; var bindData = new BindData <NormalCommand>( remapModeOption, func.ToFSharpFunc()); var bindDataStorage = BindDataStorage <NormalCommand> .NewSimple(bindData); return(CommandBinding.NewComplexNormalBinding( KeyNotationUtil.StringToKeyInputSet(name), flags, bindDataStorage)); }
public void BindRockAccount(string username, string password, BindResult bindResult) { MobileAppApi.Login(username, password, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { // if we received Ok (nocontent), we're logged in. if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { UserID = username; RockPassword = password; AccessToken = ""; AccountType = BoundAccountType.Rock; // save! SaveToDevice( ); bindResult(true); } else { bindResult(false); } }); }
private BindResult BindModelInternal(ModelBindingContext bindingContext) => BindResult .Create(GetOptionGuidValue(bindingContext) .Match( s => s.Match(v => _data.WithMappedValue(v), () => _data.WithUncheckedValue(Option.None <MappedGuid>())), e => _data.WithErrors(e) ));
internal static async Task <BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, bool enabled, IEnumerable <Checksum> checksums, AD7PendingBreakpoint pbreak) { process.VerifyNotDebuggingCoreDump(); string compilerSrcName; if (!process.MapCurrentSrcToCompileTimeSrc(documentName, out compilerSrcName)) { compilerSrcName = Path.GetFileName(documentName); } BindResult bindResults = EvalBindResult(await process.MICommandFactory.BreakInsert(compilerSrcName, process.UseUnixSymbolPaths, line, condition, enabled, checksums, ResultClass.None), pbreak); // On GDB, the returned line information is from the pending breakpoint instead of the bound breakpoint. // Check the address mapping to make sure the line info is correct. if (process.MICommandFactory.Mode == MIMode.Gdb && bindResults.BoundBreakpoints != null) { foreach (var boundBreakpoint in bindResults.BoundBreakpoints) { string matchFile = compilerSrcName; if (!string.IsNullOrEmpty(boundBreakpoint.CompiledFileName)) { matchFile = boundBreakpoint.CompiledFileName; // get the file name as it appears in the symbolic info } boundBreakpoint.Line = await process.LineForStartAddress(matchFile, boundBreakpoint.Addr); } } return(bindResults); }
protected override Expression VisitSelect(SelectExpression select) { bool saveIsOuterMostSelect = this.isOuterMostSelect; try { this.isOuterMostSelect = false; select = (SelectExpression)base.VisitSelect(select); bool hasOrderBy = select.OrderBy != null && select.OrderBy.Count > 0; bool hasGroupBy = select.GroupBy != null && select.GroupBy.Count > 0; bool canHaveOrderBy = saveIsOuterMostSelect || select.Take != null || select.Skip != null; bool canReceiveOrderings = canHaveOrderBy && !hasGroupBy && !select.IsDistinct && !AggregateChecker.HasAggregates(select); if (hasOrderBy) { this.PrependOrderings(select.OrderBy); } if (select.IsReverse) { this.ReverseOrderings(); } IEnumerable <OrderExpression> orderings = null; if (canReceiveOrderings) { orderings = this.gatheredOrderings; } else if (canHaveOrderBy) { orderings = select.OrderBy; } bool canPassOnOrderings = !saveIsOuterMostSelect && !hasGroupBy && !select.IsDistinct; ReadOnlyCollection <ColumnDeclaration> columns = select.Columns; if (this.gatheredOrderings != null) { if (canPassOnOrderings) { var producedAliases = DeclaredAliasGatherer.Gather(select.From); // reproject order expressions using this select's alias so the outer select will have properly formed expressions BindResult project = this.RebindOrderings(this.gatheredOrderings, select.Alias, producedAliases, select.Columns); this.gatheredOrderings = null; this.PrependOrderings(project.Orderings); columns = project.Columns; } else { this.gatheredOrderings = null; } } if (orderings != select.OrderBy || columns != select.Columns || select.IsReverse) { select = new SelectExpression(select.Alias, columns, select.From, select.Where, orderings, select.GroupBy, select.IsDistinct, select.Skip, select.Take, false); } return(select); } finally { this.isOuterMostSelect = saveIsOuterMostSelect; } }
public bool Initialize(ISsgController controller, ISsgMasterModel mainModel, IControlCreatorAndBinder createAndBind) { this.controller = controller; this.mainModel = mainModel; var mo = new Model(); this.model = mo; BindResult init = BindResult.Null; init += mainModel.Files.BindExpression( () => this.Files_Value( mainModel.SiteRoot.Value, mainModel.FileRelativePath.Value, mo.UpdateCname.Value, mo.UpdateConfigYml.Value)); var cname = createAndBind.ForBool(this.model.UpdateCname, "Update CNAME", Messages.ToolTipForCname); var configYml = createAndBind.ForBool(this.model.UpdateConfigYml, "Update _config.yml", Messages.ToolTipForConfigYml); init += cname.BindResult; init += configYml.BindResult; init.InitAction?.Invoke(); this.bindResult = new BindResult(null, init.UnbindAction); this.removeUI = cname.RemoveTooltips + cname.RemoveControls + configYml.RemoveTooltips + configYml.RemoveControls; return(true); }
public static HttpStatusCode ToHttpStatusCode(this BindResult result) { switch (result) { case BindResult.UrlMismatch: return(HttpStatusCode.NotFound); case BindResult.ArgsMismatch: return(HttpStatusCode.NotAcceptable); case BindResult.MethodMismatch: return(HttpStatusCode.MethodNotAllowed); case BindResult.NotAuthenticated: return(HttpStatusCode.Unauthorized); case BindResult.NotAuthorized: return(HttpStatusCode.Forbidden); case BindResult.Success: return(HttpStatusCode.OK); default: throw AssertionHelper.Fail(); } }
protected override Expression VisitSelect(SelectExpression select) { Expression expression; bool isOuterMostSelect = this.isOuterMostSelect; try { this.isOuterMostSelect = false; select = (SelectExpression)base.VisitSelect(select); bool flag2 = (select.OrderBy != null) && (select.OrderBy.Count > 0); bool flag3 = (select.GroupBy != null) && (select.GroupBy.Count > 0); bool flag4 = (isOuterMostSelect || (select.Take != null)) || (select.Skip != null); bool flag5 = ((flag4 && !flag3) && !select.IsDistinct) && !AggregateChecker.HasAggregates(select); if (flag2) { this.PrependOrderings(select.OrderBy); } if (select.IsReverse) { this.ReverseOrderings(); } IEnumerable <OrderExpression> orderBy = null; if (flag5) { orderBy = this.gatheredOrderings; } else if (flag4) { orderBy = select.OrderBy; } bool flag6 = (!isOuterMostSelect && !flag3) && !select.IsDistinct; ReadOnlyCollection <ColumnDeclaration> columns = select.Columns; if (this.gatheredOrderings != null) { if (flag6) { HashSet <TableAlias> existingAliases = DeclaredAliasGatherer.Gather(select.From); BindResult result = this.RebindOrderings(this.gatheredOrderings, select.Alias, existingAliases, select.Columns); this.gatheredOrderings = null; this.PrependOrderings(result.Orderings); columns = result.Columns; } else { this.gatheredOrderings = null; } } if (((orderBy != select.OrderBy) || (columns != select.Columns)) || select.IsReverse) { select = new SelectExpression(select.Alias, columns, select.From, select.Where, orderBy, select.GroupBy, select.IsDistinct, select.Skip, select.Take, false); } expression = select; } finally { this.isOuterMostSelect = isOuterMostSelect; } return(expression); }
protected override Expression VisitSelect(SelectExpression select) { var saveIsOuterMostSelect = _isOutermostSelect; try { _isOutermostSelect = false; select = (SelectExpression)base.VisitSelect(select); var hasOrderBy = select.OrderBy != null && select.OrderBy.Count > 0; var hasGroupBy = select.GroupBy != null; var canHaveOrderings = saveIsOuterMostSelect || select.Take != null || select.Skip != null; var canReceivedOrderings = canHaveOrderings && !hasGroupBy && !select.IsDistinct; if (hasOrderBy) { PrependOrderings(select.OrderBy); } IEnumerable <OrderExpression> orderings = null; if (canReceivedOrderings) { orderings = _gatheredOrderings; } else if (canHaveOrderings) { orderings = select.OrderBy; } var canPassOnOrderings = !saveIsOuterMostSelect && !hasGroupBy && !select.IsDistinct; ReadOnlyCollection <FieldDeclaration> fields = select.Fields; if (_gatheredOrderings != null) { if (canPassOnOrderings) { var producedAliases = new DeclaredAliasGatherer().Gather(select.From); BindResult project = RebindOrderings(_gatheredOrderings, select.Alias, producedAliases, select.Fields); _gatheredOrderings = null; PrependOrderings(project.Orderings); fields = project.Fields; } else { _gatheredOrderings = null; } } if (orderings != select.OrderBy || fields != select.Fields) { select = new SelectExpression(select.Alias, fields, select.From, select.Where, orderings, select.GroupBy, select.IsDistinct, select.Skip, select.Take); } return(select); } finally { _isOutermostSelect = saveIsOuterMostSelect; } }
public virtual void Set <T>(T target) where T : class { _values[typeof(T)] = new BindResult { Value = target, Problems = new List <ConvertProblem>() }; }
public void Set(Type type, object target) { _values[type] = new BindResult() { Value = target, Problems = new List <ConvertProblem>() }; }
private void WorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { BindResult bindResult = (BindResult)e.Result; _chartView.BindSummaryData(bindResult.ProjectEntity, bindResult.projectSummaryEntity); _chartView.BindMemberGrid(bindResult.memberSummaryList); _chartView.BindScheduler(bindResult.schedulerDataList, bindResult.resourceDataList); _chartView.BindIterationGrid(bindResult.IterationSummaryList); }
public static BindResult <T> Run <T>(this BindResult <T> result, params VimKey[] keys) { foreach (var cur in keys) { var keyInput = KeyInputUtil.VimKeyToKeyInput(cur); Assert.IsTrue(result.IsNeedMoreInput); result = result.AsNeedMoreInput().Item.BindFunction.Invoke(keyInput); } return(result); }
private BindResult <CommandRunData> Run(string command) { BindResult <CommandRunData> last = null; foreach (var c in command) { last = _runner.Run(KeyInputUtil.CharToKeyInput(c)); } return(last); }
public override Task <BindResult> BindModel(ModelBindingContext bindingContext) => Task.FromResult( BindResult.Create( GetValue(bindingContext) .Match( s => s.Match(i => GetData().WithUncheckedValue(i), () => GetData().WithNull()), () => GetData().WithErrors(new[] { MappingError.Create("Not an Int", typeof(string), typeof(int)) }) ) ) );
public override Task <BindResult> BindModel(ModelBindingContext bindingContext) => Task.FromResult( BindResult.Create( GetValue(bindingContext) .Match( s => GetData().WithValue(s.Match(_ => _, () => (int?)null)), () => GetData().WithErrors(new[] { MappingError.Create("Not an Int", typeof(string), typeof(int)) }) ) ) );
public static BindResult <T> Run <T>(this BindResult <T> result, string text) { for (var i = 0; i < text.Length; i++) { var keyInput = KeyInputUtil.CharToKeyInput(text[i]); Assert.IsTrue(result.IsNeedMoreInput); result = result.AsNeedMoreInput().Item.BindFunction.Invoke(keyInput); } return(result); }
public object SettingsFor(Type settingsType) { IBindingContext context = new BindingContext(new AppSettingsRequestData(), _locator) .PrefixWith(settingsType.Name + "."); BindResult result = _resolver.BindModel(settingsType, context); result.AssertNoProblems(settingsType); return(result.Value); }
protected override void beforeEach() { result = new BindResult { Value = new object() }; context = new InMemoryBindingContext(); MockFor <ObjectResolver>().Expect(x => x.BindModel(typeof(BinderTarget), context)).Return(result); ClassUnderTest.BindModel(typeof(BinderTarget), context).ShouldBeTheSameAs(result); }
protected override Expression VisitSelect(SelectExpression select) { bool saveIsOuterMostSelect = _isOuterMostSelect; try { _isOuterMostSelect = false; select = (SelectExpression)base.VisitSelect(select); bool hasOrderBy = select.OrderBy != null && select.OrderBy.Count > 0; if (hasOrderBy) { PrependOrderings(select.OrderBy); } bool canHaveOrderBy = saveIsOuterMostSelect; bool canPassOnOrderings = !saveIsOuterMostSelect; IEnumerable <OrderExpression> orderings = (canHaveOrderBy) ? _gatheredOrderings : null; ReadOnlyCollection <ColumnDeclaration> columns = select.Columns; if (_gatheredOrderings != null) { if (canPassOnOrderings) { HashSet <string> producedAliases = AliasesProduced.Gather(select.From); // reproject order expressions using this select’s alias so the outer select will have properly formed expressions BindResult project = RebindOrderings(_gatheredOrderings, select.Alias, producedAliases, select.Columns); _gatheredOrderings = project.Orderings; columns = project.Columns; } else { _gatheredOrderings = null; } } if (orderings != select.OrderBy || columns != select.Columns) { select = new SelectExpression(select.Alias, columns, select.From, select.Where, select.GroupBy, select.Having, orderings, select.Offset, select.Limit, select.IsDistinct); } return(select); } finally { _isOuterMostSelect = saveIsOuterMostSelect; } }
/// <summary> /// API 2,根据混兑比例和切割方案获取数据 /// </summary> /// <param name="s"></param> /// <returns></returns> private OilInfoBEntity getByRate(Specs s, BindResult pr, ref List <PropertyTable> result) { var r = pr.GetResult <FittingResult>(); if (r != null) { var oilApplyBll = new OilApplyAPIBll(); //切割比率 var cutOilRates = new List <CutOilRateEntity>(); foreach (var l in r.Specs) { cutOilRates.Add(new CutOilRateEntity() { crudeIndex = l.Spec.UUID, rate = (float)(l.Rate * 100) }); } var cuts = new List <CutMothedAPIEntity>(); foreach (var t in this._initP) { if (t.Table == PropertyType.NIR) { continue; } cuts.Add(new CutMothedAPIEntity() { ICP = (int)t.BoilingStart, ECP = (int)t.BoilingEnd, Name = this.convertEnum(t.Table) }); } try { log.Info(string.Join(";", cutOilRates.Select(d => string.Format("{0},{1}", d.crudeIndex, d.rate)))); log.Info(string.Join(";", cuts.Select(d => string.Format("ICP={0},ECP={1},Name={2}", d.ICP, d.ECP, d.Name)))); var oil = oilApplyBll.GetCutResultAPI(cutOilRates, cuts); if (oil != null) { var lst = oil.OilDataTableBAPIEntityList; convertEntity(lst, ref result, IntegrateModel.GetConfidence(r.TQ, r.MinTQ, r.SQ, r.MinSQ)); } return(oil); } catch (Exception ex) { log.Error(ex.ToString()); } } return(null); }
public override Task <BindResult> BindModel(ModelBindingContext bindingContext) { var result = BindResult .Create( TryParseInt(bindingContext?.ValueProvider?.GetValue(bindingContext.FieldName).FirstValue) .Match ( success => GetData().WithMappedValue(success), e => GetData().WithErrors(e) ) ); return(Task.FromResult(result)); }
private void BindSummaryData() { var prjectId = Guid.Empty; if (_chartView == null) { return; } if (_chartView.Context.CurrentObject != null) { prjectId = ConvertData.Convert <Katrin.Domain.Impl.Project>(_chartView.Context.CurrentObject).ProjectId; } var worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.DoWork += (s, ex) => { var entity = (Katrin.Domain.Impl.Project)_objectSpace.GetOrNew("Project", prjectId, "Manager,SaleService,ProjectTasks,ProjectIterations"); ProjectSummary projectSummaryEntity = new ProjectSummary(); var projectTasks = entity.ProjectTasks.ToList(); projectTasks = projectTasks.Where(c => c.IsDeleted == false).ToList(); SumEntity(projectSummaryEntity, projectTasks); // Type entityType = entity.GetType(); Type listGenericType = typeof(List <>); Type listType = listGenericType.MakeGenericType(entityType); var list = (IList)Activator.CreateInstance(listType); list.Add(entity); BindResult bindResult = new BindResult(); bindResult.ProjectEntity = list; bindResult.projectSummaryEntity = new List <ProjectSummary>() { projectSummaryEntity }; BindMemberGrid(projectTasks, bindResult); IList projectIterations = entity.ProjectIterations.ToList(); BindIterationGrid(projectTasks, projectIterations, bindResult); BindIterationScheduler(projectTasks, projectIterations, bindResult); ex.Result = bindResult; }; worker.RunWorkerCompleted += WorkerRunWorkerCompleted; worker.RunWorkerAsync(); }
/// <summary> /// Run the multi-input command /// </summary> public static BindResult <CommandRunData> Run(this ICommandRunner runner, string command) { BindResult <CommandRunData> result = null; for (var i = 0; i < command.Length; i++) { result = runner.Run(command[i]); if (i + 1 < command.Length) { Assert.IsTrue(result.IsNeedMoreInput); } } return(result); }
protected override void beforeEach() { theResult = new BindResult { Problems = new List <ConvertProblem> { new ConvertProblem(), new ConvertProblem() }, Value = new BinderTarget() }; MockFor <IObjectResolver>().Stub(x => x.BindModel(typeof(BinderTarget), MockFor <IRequestData>())) .Return(theResult); ClassUnderTest.Get <BinderTarget>().ShouldBeTheSameAs(theResult.Value); }
public BindResult BindModel(Type type, IBindingContext context) { try { _report.StartModelBinding(type); BindResult result = _resolver.BindModel(type, context); _report.EndModelBinding(result.Value); return(result); } catch (Exception) { _report.EndModelBinding(null); throw; } }
public void BindRockAccount( string username, string password, BindResult bindResult ) { RockApi.Instance.Login( username, password, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { // if we received Ok (nocontent), we're logged in. if( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true ) { UserID = username; RockPassword = password; AccessToken = ""; AccountType = BoundAccountType.Rock; // save! SaveToDevice( ); bindResult( true); } else { bindResult( false ); } }); }
public void FacebookCredentialResult( string response, FacebookClient session, BindResult result ) { // make sure we got a valid access token FacebookOAuthResult oauthResult; if( session.TryParseOAuthCallbackUrl (new Uri ( response ), out oauthResult) == true ) { if ( oauthResult.IsSuccess ) { // now attempt to get their basic info FacebookClient fbSession = new FacebookClient( oauthResult.AccessToken ); string infoRequest = FacebookManager.Instance.CreateInfoRequest( ); fbSession.GetTaskAsync( infoRequest ).ContinueWith( t => { // if there was no problem, we are logged in and can send this up to Rock if ( t.IsFaulted == false || t.Exception == null ) { // now login via rock with the facebook credentials to verify we're good RockApi.Instance.LoginFacebook( t.Result, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true ) { UserID = "facebook_" + FacebookManager.Instance.GetUserID( t.Result ); RockPassword = ""; AccessToken = oauthResult.AccessToken; AccountType = BoundAccountType.Facebook; // save! SaveToDevice( ); result( true ); } else { result( false ); } }); } else { // didn't work out. result( false ); } } ); } else { result( false ); } } else { // didn't work out. result( false ); } }
/// <summary> /// /// </summary> /// <param name="r"></param> public BindException(BindResult r) { m_result = r; }
internal static async Task<BindResult> Bind(string documentName, uint line, uint column, DebuggedProcess process, string condition, AD7PendingBreakpoint pbreak) { string basename = System.IO.Path.GetFileName(documentName); // get basename from Windows path Results bindResult = await process.MICommandFactory.BreakInsert(process.EscapePath(basename), line, condition, ResultClass.None); string errormsg = "Unknown error"; if (bindResult.ResultClass == ResultClass.error) { if (bindResult.Contains("msg")) { errormsg = bindResult.FindString("msg"); } if (String.IsNullOrWhiteSpace(errormsg)) { errormsg = "Unknown error"; } return new BindResult(errormsg); } else if (bindResult.ResultClass != ResultClass.done) { return new BindResult(errormsg); } TupleValue bkpt = null; ValueListValue list = null; if (bindResult.Contains("bkpt")) { ResultValue b = bindResult.Find("bkpt"); if (b is TupleValue) { bkpt = b as TupleValue; } else if (b is ValueListValue) { // "<MULTIPLE>" sometimes includes a list of bound breakpoints list = b as ValueListValue; bkpt = list.Content[0] as TupleValue; } } else { // If the source file is not found, "done" is the result without a binding // (the error is sent via an "&" string and hence lost) return new BindResult(errormsg); } Debug.Assert(bkpt.FindString("type") == "breakpoint"); string number = bkpt.FindString("number"); string addr = bkpt.TryFindString("addr"); PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr)); if (list == null) // single breakpoint { BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt); if (bbp == null) { return new BindResult(bp, MICoreResources.Status_BreakpointPending); } return new BindResult(bp, bbp); } else // <MULTIPLE> with list of addresses { BindResult res = new BindResult(bp); for (int i = 1; i < list.Content.Length; ++i) { BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue); res.BoundBreakpoints.Add(bbp); } return res; } }
/// <summary> /// 绑定数据源,把模板的标签写入数据 /// </summary> public void DataBind() { if (string.IsNullOrEmpty(this.TemplateFileName)) { this.bindBlankTemplate(); return; } this.initTemplate(); //有参数表,更新模板的参数表数据字段 if (this.dataSource.Tables.Contains("参数表")) { DataTable tabparam = this.dataSource.Tables["参数表"]; if (tabparam.Rows.Count > 0) { DataRow drparam = tabparam.Rows[0]; XmlNodeList xncells = this.xmldoc.SelectNodes("/*/ss:Worksheet/ss:Table/ss:Row/ss:Cell/ss:Data", this.xmlNsMgl); foreach (XmlNode xn in xncells) { if (!(xn is XmlElement)) continue; this.BindData(xn as XmlElement, drparam); } } } XmlElement xeTemplate = this.xmldoc.SelectSingleNode("/*/ss:Worksheet", this.xmlNsMgl) as XmlElement; XmlElement xeTpClone = xeTemplate.Clone() as XmlElement; //清除模板表格 XmlNode xnRow = xeTemplate.SelectSingleNode(".//ss:Row", this.xmlNsMgl); while (null != xnRow) { XmlNode xnT = xnRow.NextSibling; if ("Row" == xnRow.LocalName) xnRow.ParentNode.RemoveChild(xnRow); xnRow = xnT; } //初始化绑定区域结果主从关系 IDictionary<string, BindResult> listResult = new Dictionary<string, BindResult>(); BindResult rootResult = new BindResult(); rootResult.boundResult = Bound.ParseBound("A1:A1"); foreach (PrintInfo pinfo in this.printInfos) { string key = pinfo.DbName; if (!this.dataSource.Tables.Contains(key) && PrintType.Data==pinfo.RegionType) continue; BindResult bindInstance = new BindResult(); bindInstance.rowIndex = 0; bindInstance.printInfo = pinfo; listResult.Add(pinfo.DbName, bindInstance); } for (int i=0;i<this.printInfos.Count;i++) { string key = this.printInfos[i].DbName; PrintInfo pinfo = this.printInfos[i]; DataRelation rf = null; if (PrintType.Text == pinfo.RegionType) { foreach (PrintInfo p in this.printInfos) { if (PrintType.Data != p.RegionType || !this.dataSource.Tables.Contains(p.DbName)) continue; if (pinfo.GroupName != p.GroupName) continue; if (this.dataSource.Tables[p.DbName].ParentRelations.Count < 1) continue; rf = this.dataSource.Tables[p.DbName].ParentRelations[0]; break; } } else { if (this.dataSource.Tables[key].ParentRelations.Count < 1) continue; rf = this.dataSource.Tables[key].ParentRelations[0]; } if (null == rf) continue; BindResult rsParent = listResult[rf.ParentTable.TableName]; BindResult bindrs = listResult[key]; rsParent.resultChildren.Add(key, bindrs); bindrs.parentResult = rsParent; } for (int i = 0; i < this.printInfos.Count; i++) { string key = this.printInfos[i].DbName; BindResult bindrs = listResult[key]; if (rootResult.boundResult.Right < bindrs.printInfo.PgBound.Right) rootResult.boundResult.Right = bindrs.printInfo.PgBound.Right; if (rootResult.boundResult.Bottom < bindrs.printInfo.PgBound.Bottom) rootResult.boundResult.Bottom = bindrs.printInfo.PgBound.Bottom; if (null != bindrs.parentResult) listResult.Remove(key); else rootResult.resultChildren.Add(key,bindrs); } string pagePrint = "类型=文本\n数据表=页\n页范围=A1:{0}{1}\n行范围=A1:{0}{1}"; string col=""; int colindex = rootResult.boundResult.Right; while (colindex > 0) { int mod = colindex % 27; if (colindex > 26) mod += 1; col = Convert.ToString(Convert.ToChar(mod + Convert.ToInt16('A') - 1)) + col; colindex = colindex / 27; } pagePrint = string.Format(pagePrint, col , rootResult.boundResult.Bottom); rootResult.printInfo = PrintInfo.SerialFromString(pagePrint); rootResult.boundRow = rootResult.boundResult; //按照数据源的表个数循环,行号-1表示已经绑定完,子级数据递归绑定 //把结果页xeTp加入文档 XmlElement xeTable = this.xmldoc.SelectSingleNode("/*/ss:Worksheet/ss:Table", this.xmlNsMgl) as XmlElement; while (true) { bool isBreak = true; foreach (BindResult bindInstance in listResult.Values) { if (bindInstance.rowIndex < 0) continue; isBreak = false; break; } if (isBreak) break; //分页绑定 XmlElement xeTp = xeTpClone.CloneNode(true) as XmlElement; foreach (BindResult rs in listResult.Values) { rs.boundResult = null; rs.boundRow = null; } foreach (PrintInfo pinfo in this.printInfos) { if (!listResult.ContainsKey(pinfo.DbName)) continue; BindResult rs = listResult[pinfo.DbName]; if (rs.rowIndex < 0 && PrintType.Data == rs.printInfo.RegionType) continue; rs.xeTemplate = xeTp; rootResult.initChildBound(pinfo.DbName); if (null == rs.boundResult) continue; //子级范围 if (PrintType.Text == pinfo.RegionType && !rootResult.isComplete(pinfo.DbName)) { this.CopyCell(xeTpClone, pinfo.RowBound, rs.xeTemplate, rs.boundResult.Left, rs.boundResult.Top); rs.rowIndex = -1; } else if (PrintType.Data == pinfo.RegionType && this.dataSource.Tables.Contains(pinfo.DbName)) { DataRow[] drs = this.dataSource.Tables[pinfo.DbName].Select(); this.BindNode(xeTpClone, drs, rs); } } xnRow = xeTp.SelectSingleNode(".//ss:Row", this.xmlNsMgl); while (null != xnRow) { XmlNode xnT = xnRow.NextSibling; if ("Row" == xnRow.LocalName) xeTable.AppendChild(xnRow); xnRow = xnT; } }//while (true) //合并单元格 this.MergeCell(xeTemplate); }
private static BindResult EvalBindResult(Results bindResult, AD7PendingBreakpoint pbreak) { string errormsg = "Unknown error"; if (bindResult.ResultClass == ResultClass.error) { if (bindResult.Contains("msg")) { errormsg = bindResult.FindString("msg"); } if (String.IsNullOrWhiteSpace(errormsg)) { errormsg = "Unknown error"; } return new BindResult(errormsg); } else if (bindResult.ResultClass != ResultClass.done) { return new BindResult(errormsg); } TupleValue bkpt = null; ValueListValue list = null; if (bindResult.Contains("bkpt")) { ResultValue b = bindResult.Find("bkpt"); if (b is TupleValue) { bkpt = b as TupleValue; } else if (b is ValueListValue) { // "<MULTIPLE>" sometimes includes a list of bound breakpoints list = b as ValueListValue; bkpt = list.Content[0] as TupleValue; } } else { // If the source file is not found, "done" is the result without a binding // (the error is sent via an "&" string and hence lost) return new BindResult(errormsg); } Debug.Assert(bkpt.FindString("type") == "breakpoint"); string number = bkpt.FindString("number"); string addr = bkpt.TryFindString("addr"); PendingBreakpoint bp = new PendingBreakpoint(pbreak, number, StringToBreakpointState(addr)); if (list == null) // single breakpoint { BoundBreakpoint bbp = bp.GetBoundBreakpoint(bkpt); if (bbp == null) { return new BindResult(bp, MICoreResources.Status_BreakpointPending); } return new BindResult(bp, bbp); } else // <MULTIPLE> with list of addresses { BindResult res = new BindResult(bp); for (int i = 1; i < list.Content.Length; ++i) { BoundBreakpoint bbp = bp.GetBoundBreakpoint(list.Content[i] as TupleValue); res.BoundBreakpoints.Add(bbp); } return res; } }
/// <summary> /// 数据源页内绑定模板,完成绑定则返回-1,非法返回null,内范围超限返回 /// </summary> /// <param name="xeTemplate">独立模板</param> /// <param name="drs">数据记录集</param> /// <param name="bindEnv">当前绑定结果:当前行及范围</param> /// <returns>绑定结果:rowIndex=-1表示绑定完毕</returns> private BindResult BindNode(XmlElement xeTemplate, DataRow[] drs, BindResult bindEnv) { //检查 if (null == xeTemplate || null == drs || drs.Length < 1 || null == bindEnv || null == bindEnv.xeTemplate || bindEnv.rowIndex < 0 || bindEnv.rowIndex >= drs.Length) { if (null != bindEnv) bindEnv.rowIndex = -1; return bindEnv; } DataTable tab=drs[0].Table; string dbName = tab.TableName; if (!this.printInfoList.Keys.Contains(dbName)) { if (null != bindEnv) bindEnv.rowIndex = -1; return bindEnv; } ICollection<String> pinfoKeys = this.printInfoList.Keys; PrintInfo pinfo = this.printInfoList[dbName]; if (null == bindEnv.boundResult) bindEnv.boundResult = Bound.ParseBound(pinfo.RowBound); bindEnv.boundRow = new Bound(); //当前行位置ileft,itop int ileft = bindEnv.boundResult.Left; int itop = bindEnv.boundResult.Top; while (bindEnv.rowIndex < drs.Length) { //复制模板区域 bindEnv.boundRow.Left = ileft; bindEnv.boundRow.Top = itop; bindEnv.boundResult.Right = bindEnv.boundRow.Right = ileft + (pinfo.RwBound.Right - pinfo.RwBound.Left); bindEnv.boundResult.Bottom =bindEnv.boundRow.Bottom = itop + (pinfo.RwBound.Bottom - pinfo.RwBound.Top); this.CopyCell(xeTemplate, pinfo.RowBound, bindEnv.xeTemplate, ileft, itop); //更新父项的结果区域 BindResult childResult = bindEnv; BindResult parentResult = bindEnv.parentResult; while (null != parentResult) { Bound bdP = parentResult.boundResult; Bound bdC = childResult.boundResult; if (bdP.Right >= bdC.Right && bdP.Bottom >= bdC.Bottom) break; if (bdC.Right > bdP.Right) bdP.Right = bdC.Right; if (bdC.Bottom > bdP.Bottom) bdP.Bottom = bdC.Bottom; childResult = parentResult; parentResult = parentResult.parentResult; } //绑定字段值(父级字段或自身字段) string strTabFind = "ss:Table/ss:Row/ss:Cell[@r='{0}']"; string strRowFind = "ss:Cell[@c='{0}']"; XmlNode xnField=null, xnRowF=null; for (int i = itop; i <= bindEnv.boundResult.Bottom; i++) { if (null == xnRowF) { xnField = bindEnv.xeTemplate.SelectSingleNode(string.Format(strTabFind, i), this.xmlNsMgl); if (null == xnField) continue; xnRowF = xnField.ParentNode; } xnField = xnRowF.SelectSingleNode(string.Format(strRowFind, ileft), this.xmlNsMgl); for (int j = ileft; j <= bindEnv.boundResult.Right; j++) { if (null == xnField) xnField = xnRowF.SelectSingleNode(string.Format(strRowFind, j), this.xmlNsMgl); if (null == xnField) continue; if (null != xnField.FirstChild && null != xnField.FirstChild.Attributes["field"]) this.BindData((XmlElement)xnField.FirstChild, drs[bindEnv.rowIndex]); xnField = xnField.NextSibling; if (null == xnField || null == xnField.FirstChild || null == xnField.FirstChild.Attributes["c"] || Convert.ToString(j+1) != xnField.FirstChild.Attributes["c"].Value) xnField = null; } xnRowF = xnRowF.NextSibling; } //页内绑定子级 foreach (BindResult rs in bindEnv.resultChildren.Values) { rs.boundResult = null; rs.boundRow = null; } foreach (BindResult rs in bindEnv.resultChildren.Values) { PrintInfo pinfoChild = rs.printInfo; string key = pinfoChild.DbName; DataRelation rlChild = null; foreach (DataRelation rl in tab.ChildRelations) { if (key != rl.ChildTable.TableName) continue; rlChild = rl; break; } //检查配置区域是否合理,不在当前区域忽略 if (pinfoChild.RwBound.Left < pinfo.RwBound.Left || pinfoChild.RwBound.Top < pinfo.RwBound.Top || pinfoChild.RwBound.Right > pinfo.RwBound.Right || pinfoChild.RwBound.Bottom > pinfo.RwBound.Bottom) continue; rs.xeTemplate = bindEnv.xeTemplate; if (rs.parentRowIndex != bindEnv.rowIndex) { rs.parentRowIndex = bindEnv.rowIndex; rs.rowIndex = 0; } //初始化计算子区域,超界则为空 bindEnv.initChildBound(key); if (null == rs.boundResult) continue; //子级范围 if (PrintType.Text == pinfoChild.RegionType && !bindEnv.isComplete(key)) { this.CopyCell(xeTemplate, pinfoChild.RowBound, rs.xeTemplate, rs.boundResult.Left, rs.boundResult.Top); rs.rowIndex = -1; } else if (PrintType.Data == pinfoChild.RegionType && null != rlChild) this.BindNode(xeTemplate, drs[bindEnv.rowIndex].GetChildRows(rlChild), rs); } //检查是否下一行 bool isNext = true; foreach(BindResult srChild in bindEnv.resultChildren.Values) if (srChild.rowIndex > -1) { isNext=false; break; } if (isNext) bindEnv.rowIndex++; if (bindEnv.rowIndex >= drs.Length) break; //根据行输出方式计算下一条记录的区域位置 if (OutRowModel.VeriNextHori == pinfo.OutRowType) { itop = bindEnv.boundResult.Bottom + 1; if (itop + pinfo.RwBound.Bottom - pinfo.RwBound.Top > pinfo.PgBound.Bottom) { itop = bindEnv.boundResult.Top; ileft = bindEnv.boundResult.Right + 1; } } else { ileft = bindEnv.boundResult.Right+1; if (ileft + pinfo.RwBound.Right - pinfo.RwBound.Left > pinfo.PgBound.Right) { ileft = bindEnv.boundResult.Left; itop = bindEnv.boundResult.Bottom + 1; } } //检查下一个记录是否页面超限 if (bindEnv.boundResult.Right > pinfo.PgBound.Right || bindEnv.boundResult.Bottom > pinfo.PgBound.Bottom || (itop + pinfo.RwBound.Bottom - pinfo.RwBound.Top) > pinfo.PgBound.Bottom || (ileft + pinfo.RwBound.Right - pinfo.RwBound.Left) > pinfo.PgBound.Right) return bindEnv; }//for (int i = 0; bindEnv.rowIndex < drs.Length; i++) //子项重置 bindEnv.rowIndex = -1; foreach (BindResult srChild in bindEnv.resultChildren.Values) srChild.parentRowIndex = srChild.rowIndex = -1; return bindEnv; }