public override void PostRefresh() { foreach (string key in _Markets.Data.Keys) { if (_Summary.Data.ContainsKey(key)) { MarketInfo m = _Markets.Data[key]; SummaryInfo s = _Summary.Data[key]; m.Ask = s.Ask; m.BaseVolume = s.BaseVolume; m.Bid = s.Bid; m.High = s.High; m.Last = s.Last; m.Low = s.Low; m.Volume = s.Volume; m.BuyVolume = s.OpenBuyOrders; m.SellVolume = s.OpenSellOrders; if (s.PrevDay > s.Last) { m.Change = -1 * (1 - (s.Last / s.PrevDay)) * 100; } else { m.Change = ((s.Last / s.PrevDay) - 1) * 100; } } } }
public void SummaryCommandServiceBase_UpdateSummary() { CreateArrestSummary(); var summaryQueryService = GetDependency <ISummaryQueryService>(); Assert.IsInstanceOfType(summaryQueryService, typeof(ISummaryQueryService)); SummaryInfo arrestSummaryInfo = summaryQueryService.GetSummaryInfo(summaryGuid); Assert.IsNotNull(arrestSummaryInfo); var arrestSummary = MockObjects.NewArrestSummary; arrestSummary.Id = arrestSummaryInfo.Id; arrestSummary.Status = new CodeValue("Updated Code", "Updated Description"); var summariesUnitOfWork = GetDependency <ISummariesUnitOfWork>(); Assert.IsInstanceOfType(summariesUnitOfWork, typeof(ISummariesUnitOfWork)); var masterIndexService = GetDependency <IMasterIndexService>(); Assert.IsInstanceOfType(masterIndexService, typeof(IMasterIndexService)); var arrestSummaryCommandService = new ArrestSummaryCommandService( summariesUnitOfWork, masterIndexService, Mock.Of <ILog>()); arrestSummaryCommandService.UpdateSummary(arrestSummary); SummaryInfo summary = summaryQueryService.GetSummaryInfo(summaryGuid); Assert.IsNotNull(summary); }
private void DecodeSummaryInfo(SummaryInfo transformSummaryInfo) { try { string[] rev = transformSummaryInfo.RevisionNumber.Split(new char[] { ';' }, 3); this.targetProductCode = rev[0].Substring(0, 38); this.targetProductVersion = rev[0].Substring(38); this.upgradeProductCode = rev[1].Substring(0, 38); this.upgradeProductVersion = rev[1].Substring(38); this.upgradeCode = rev[2]; string[] templ = transformSummaryInfo.Template.Split(new Char[] { ';' }, 2); this.targetPlatform = templ[0]; this.targetLanguage = 0; if (templ.Length >= 2 && templ[1].Length > 0) { this.targetLanguage = Int32.Parse(templ[1], CultureInfo.InvariantCulture.NumberFormat); } this.validateFlags = (TransformValidations)transformSummaryInfo.CharacterCount; } catch (Exception ex) { throw new InstallerException("Invalid transform summary info", ex); } }
public void CheckSumamaryTest() { AssetType assetType = AssetType.Bond; int quantity = 100; decimal price = 100m; portfolio.AddStock(assetType, price, quantity); SummaryInfo bondSummary = portfolio.SummaryInfoCollections.Where(x => x.Type == AssetType.Bond.ToString()).First(); Assert.AreEqual(bondSummary.TotalMarketValue, quantity * price); Assert.AreEqual(bondSummary.TotalQuantity, quantity); Assert.AreEqual(bondSummary.TotalStockWeight, 1); AssetType assetTypeEquity = AssetType.Equity; int quantityEquity = 100; decimal priceEquity = 100m; portfolio.AddStock(assetTypeEquity, priceEquity, quantityEquity); Assert.AreEqual(bondSummary.TotalStockWeight, 0.5m); SummaryInfo equitySummary = portfolio.SummaryInfoCollections.Where(x => x.Type == AssetType.Equity.ToString()).First(); Assert.AreEqual(equitySummary.TotalStockWeight, 0.5m); Assert.AreEqual(equitySummary.TotalQuantity, quantityEquity); Assert.AreEqual(equitySummary.TotalMarketValue, quantityEquity * priceEquity); SummaryInfo totalSummary = portfolio.SummaryInfoCollections.Where(x => x.Type == "Total").First(); Assert.AreEqual(totalSummary.TotalStockWeight, 1m); Assert.AreEqual(totalSummary.TotalQuantity, quantityEquity + quantity); Assert.AreEqual(totalSummary.TotalMarketValue, (2 * (quantityEquity * priceEquity))); }
public void Totals() { var summaryInfo = new SummaryInfo { Selector = "p", SummaryType = "sum" }; var source = new[] { new { p = 1 }, new { p = 2 } }; var loadOptions = new SampleLoadOptions { GuardNulls = false, RemoteGrouping = true, TotalSummary = Enumerable .Repeat(summaryInfo, 123) .ToArray() }; var loadResult = DataSourceLoader.Load(source, loadOptions); Assert.Equal(3m, loadResult.summary[122]); Assert.Contains(loadOptions.ExpressionLog, line => line.Contains(".Select(g => new <>f__AnonymousType") && line.Contains("I100 = g.Sum(obj => obj.p)") ); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { Require.NotDisposed(Database.IsDisposed, nameof(AcadDatabase)); if (commitTransaction) { transaction.Commit(); if (SummaryInfo.Changed) { SummaryInfo.Commit(); } if (saveOnCommit) { Database.SaveAs(saveAsFileName, GetDwgVersion()); } } if (disposeTransaction) { transaction.Dispose(); } if (disposeDatabase) { Database.Dispose(); } }
private void DecodeSummaryInfo(SummaryInfo transformSummaryInfo) { try { string[] rev = transformSummaryInfo.RevisionNumber.Split(new char[] { ';' }, 3); this.targetProductCode = rev[0].Substring(0, 38); this.targetProductVersion = rev[0].Substring(38); this.upgradeProductCode = rev[1].Substring(0, 38); this.upgradeProductVersion = rev[1].Substring(38); this.upgradeCode = rev[2]; string[] templ = transformSummaryInfo.Template.Split(new Char[] { ';' }, 2); this.targetPlatform = templ[0]; this.targetLanguage = 0; if (templ.Length >= 2 && templ[1].Length > 0) { this.targetLanguage = Int32.Parse(templ[1], CultureInfo.InvariantCulture.NumberFormat); } this.validateFlags = (TransformValidations) transformSummaryInfo.CharacterCount; } catch (Exception ex) { throw new InstallerException("Invalid transform summary info", ex); } }
public void GenerateReportsData_2(Infrastructure.Constants.ModuleType moduleType) { //Arrange var summaryInfo = new SummaryInfo() { Id = Guid.NewGuid(), Number = "Number", SummaryType = "SummaryType", Agency = new Contracts.Core.References.AgencyReference() { AgencyId = fixtures.agency.AgencyId, IsActive = true, Name = "Test Agency" } }; fixtures.fakes.summaryQueryService.Setup(m => m.GetSummaryInfo(summaryInfo.Id)).Returns(summaryInfo); fixtures.fakes.templateQueryService.Setup(m => m.GetDefaultTemplate(summaryInfo.Agency.AgencyId, moduleType)).Returns(fixtures.template); //Act var result = fixtures.reportService.GenerateReportsData(summaryInfo.Id, Contracts.DataEntry.RelatedTo.DTO.RelatedToType.Summary, moduleType); //Assert result.Should().NotBeNull(); }
public void GroupSummary() { var summaryInfo = new SummaryInfo { Selector = "p", SummaryType = "sum" }; var loadOptions = new SampleLoadOptions { GuardNulls = false, RemoteGrouping = true, Group = new[] { new GroupingInfo { Selector = "g", IsExpanded = false }, }, GroupSummary = Enumerable .Repeat(summaryInfo, 123) .ToArray() }; var source = new[] { new { g = 1, p = 1 }, new { g = 1, p = 2 }, }; var loadResult = DataSourceLoader.Load(source, loadOptions); var group = loadResult.data.Cast <Group>().First(); Assert.Equal(3m, group.summary[122]); Assert.Contains(loadOptions.ExpressionLog, line => line.Contains(".Select(g => new <>f__AnonymousType") && line.Contains("I100 = g.Sum(obj => obj.p)") ); }
/// <summary> /// /// </summary> /// <param name="agentcode"></param> /// <param name="express_service"></param> /// <param name="sku"></param> /// <param name="warehouse"></param> /// <param name="to_region"></param> /// <param name="to_country"></param> /// <param name="to_zip_code"></param> /// <param name="to_city"></param> /// <param name="weight"></param> /// <param name="size"></param> /// <returns></returns> public SummaryInfo GetDirectExpressShippingFee(PriceRequest requst) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("Packing", requst.Packing.Length.ToString() + "*" + requst.Packing.Width.ToString() + "*" + requst.Packing.Height.ToString()); param.Add("weight_in_gram", requst.Weight.ToString()); param.Add("Country", requst.ShipToCountryName); param.Add("service", requst.ExpressService); CK1V3Request request = new CK1V3Request { Category = "direct-express", Handler = "package", Action = "pricing", Parameters = param }; //Packing packing = new Packing(); string json = ResponseJson(request); PriceResponse response = JsonConvert.DeserializeObject <PriceResponse>(json); SummaryInfo summary = new SummaryInfo(); summary = response.body.Summary[0]; return(summary); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <param name="force">True, if the drawing database and the transaction should be disposed of, even if keepOpen was used.</param> private void DisposeInternal(bool force) { if (!transaction.IsDisposed) { if (commitTransaction) { transaction.Commit(); if (SummaryInfo.Changed) { SummaryInfo.Commit(); } } if (disposeTransaction || force) { transaction.Dispose(); } } if ((disposeDatabase || force) && !Database.IsDisposed) { Database.Dispose(); } }
public static RemoteGroupingResult Run(IEnumerable<IRemoteGroup> flatGroups, int groupCount, SummaryInfo[] totalSummary, SummaryInfo[] groupSummary) { var accessor = new RemoteGroupAccessor(); List<Group> hierGroups = null; if(groupCount > 0) { hierGroups = new GroupHelper<IRemoteGroup>(accessor).Group( flatGroups, Enumerable.Range(0, groupCount).Select(i => new GroupingInfo { Selector = "K" + i }).ToArray() ); } IEnumerable dataToAggregate = hierGroups; if(dataToAggregate == null) dataToAggregate = flatGroups; var transformedTotalSummary = TransformSummary(totalSummary, "T"); var transformedGroupSummary = TransformSummary(groupSummary, "G"); transformedTotalSummary.Add(new SummaryInfo { SummaryType = "remoteCount" }); var totals = new AggregateCalculator<IRemoteGroup>(dataToAggregate, accessor, transformedTotalSummary, transformedGroupSummary).Run(); var totalCount = (int)totals.Last(); totals = totals.Take(totals.Length - 1).ToArray(); if(totals.Length < 1) totals = null; return new RemoteGroupingResult { Groups = hierGroups, Totals = totals, TotalCount = totalCount }; }
public StatisticsInfo() { VariableId = null; StatisticsType = StatisticsTypes.Unknown; SummaryInfo = new SummaryInfo(); CategoryInfos = new List <CategoryInfo>(); Scale = EDOConstants.DEF_SCALE; }
/// <summary> /// Reads transform information from a transform package. /// </summary> /// <param name="mstFile">Path to a transform package (.MST file).</param> public TransformInfo(string mstFile) { this.name = Path.GetFileName(mstFile); using (SummaryInfo transformSummInfo = new SummaryInfo(mstFile, false)) { this.DecodeSummaryInfo(transformSummInfo); } }
private void method_5() { this.class617_1.MaxDecompressedPageSize = 256; MemoryStream memoryStream = new MemoryStream(); SummaryInfo summaryInfo = this.dxfModel_0.SummaryInfo; Class611.Write(Class889.Create((Stream)memoryStream, this.dxfVersion_0, this.encoding_0), summaryInfo); this.method_23(this.class617_1, memoryStream, false); }
public void SummaryQueryService_GetSummaryInfoFieldInterviewFromAgencyId() { CreateFieldInterviewSummary(); var arrestSummaryQueryService = GetDependency <ISummaryQueryService>(); Assert.IsInstanceOfType(arrestSummaryQueryService, typeof(ISummaryQueryService)); summary = arrestSummaryQueryService.GetSummaryInfo(agencyId, number); Assert.IsNotNull(summary); }
public void SummaryQueryService_GetSummaryInfoForFieldInterviewFromId() { CreateFieldInterviewSummary(); var summaryQueryService = GetDependency <ISummaryQueryService>(); Assert.IsInstanceOfType(summaryQueryService, typeof(ISummaryQueryService)); summary = summaryQueryService.GetSummaryInfo(summaryGuid); Assert.IsNotNull(summary); }
private static void ProcessSummaryInfo(SummaryInfo si, XmlWriter xmlw) { xmlw.WriteStartElement("SummaryInfo"); xmlw.WriteAttributeString("KeywordsInReport", si.KeywordsInReport); xmlw.WriteAttributeString("ReportAuthor", si.ReportAuthor); xmlw.WriteAttributeString("ReportComments", si.ReportComments); xmlw.WriteAttributeString("ReportSubject", si.ReportSubject); xmlw.WriteAttributeString("ReportTitle", si.ReportTitle); xmlw.WriteEndElement(); }
private static StatisticsInfo CreateNumberStatisticsInfo(RawData data, VariableVM variable) { return(CreateSimpleStatisticsInfo(data, variable, (values, info) => { info.StatisticsType = StatisticsTypes.Number; NumberHelper numericHelper = NumberHelper.Create(variable); SummaryInfo summaryInfo = CreateSummaryInfo(values, numericHelper); info.SummaryInfo = summaryInfo; })); }
private void WriteMenu(Summary summary, SummaryInfo calculatedHeaders, StreamWriter textFile) { var categoryDictionary = new Dictionary <string, List <Tuple <string, BenchmarkInfo> > >(); foreach (var calculatedHeadersBenchmark in calculatedHeaders.Benchmarks) { foreach (var category in calculatedHeadersBenchmark.Categories) { if (!categoryDictionary.TryGetValue(category, out List <Tuple <string, BenchmarkInfo> > list)) { list = new List <Tuple <string, BenchmarkInfo> >(); categoryDictionary[category] = list; } list.Add(new Tuple <string, BenchmarkInfo>(calculatedHeadersBenchmark.DisplayName, calculatedHeadersBenchmark)); } } var sortList = new List <KeyValuePair <string, List <Tuple <string, BenchmarkInfo> > > >(categoryDictionary); sortList.Sort((x, y) => string.Compare(x.Key, y.Key)); var standard = sortList.Find(k => k.Key == "Standard"); if (standard.Key != null) { sortList.Remove(standard); sortList.Insert(0, standard); } var menuString = new StringBuilder(); foreach (var pair in sortList) { pair.Value.Sort((x, y) => string.CompareOrdinal(x.Item1, y.Item1)); menuString.AppendLine("<li class=\"dropdown\">"); menuString.AppendLine($"<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\">{pair.Key} <span class=\"caret\"></span></a>"); menuString.AppendLine("<ul class=\"dropdown-menu\">"); foreach (var tuple in pair.Value) { menuString.AppendLine($"<li><a href=\"{tuple.Item2.BenchmarkName.Replace('|', '_')}.html\">{tuple.Item1}</a></li>"); } menuString.AppendLine("</ul>"); menuString.AppendLine("</li>"); } var menu = _menuHtml.Replace("{menu_tags}", menuString.ToString()); textFile.Write(menu); }
public string PrepareSummaryText(Transaction ti) { if (RecordFamilyAttendance()) { return(SummarizeFamilyAttendance()); } var om = GetOrgMember(); var si = new SummaryInfo(DbUtil.Db, om.PeopleId, om.OrganizationId); return(si.ToString()); }
public void ReturnsModelFromService() { var summaryInfo = new SummaryInfo(); svc .Setup(it => it.GetSummary()) .Returns(summaryInfo); var result = sut.Stats() as ViewResult; Assert.AreEqual(summaryInfo, result.Model); }
public void PrintSummary(SummaryInfo si, RowsInfo ri) { rprtCostSummary rprt = new rprtCostSummary(); FPreviewAR pv = new FPreviewAR(); pv.projNumber = si.project; rprt.SummaryInformation = si; rprt.RowsInfo = ri; rprt.Run(); rprt.Document.Print(true, false); }
/// <summary> /// 填充汇总UI的数据源 /// </summary> /// <param name="summaryInfo"></param> private void fillSummaryInfoDataSource(SummaryInfo summaryInfo) { if (summaryInfo.InvokeDataSourceDesc == null) { return; } if (string.IsNullOrEmpty(summaryInfo.InvokeDataSourceDesc.Method)) { throw new MB.Util.APPException(string.Format("Summray {0} 的InvokeDataSourceDesc配置中Method 的 配置不能为空 ", summaryInfo.Name), Util.APPMessageType.SysErrInfo); } string[] descs = summaryInfo.InvokeDataSourceDesc.Type.Split(','); string[] method = summaryInfo.InvokeDataSourceDesc.Method.Split(','); string[] conPars = null; if (method.Length == 0) { throw new MB.Util.APPException(string.Format("Summray{0}的调用方法没有配置", summaryInfo.Name), MB.Util.APPMessageType.SysErrInfo); } if (!string.IsNullOrEmpty(summaryInfo.InvokeDataSourceDesc.TypeConstructParams)) { conPars = summaryInfo.InvokeDataSourceDesc.TypeConstructParams.Split(','); } object instance = MB.Util.DllFactory.Instance.LoadObject(descs[0], conPars, descs[1]); if (instance == null) { throw new MB.Util.APPException(string.Format("Summray在获取数据源时根据 {0}, {1} 实例化类出错", descs[1], descs[0]), Util.APPMessageType.SysErrInfo); } object val = method.Length == 1 ? MB.Util.MyReflection.Instance.InvokeMethod(instance, method[0]) : MB.Util.MyReflection.Instance.InvokeMethod(instance, method[0], method[1].Split(';')); if (val == null) { return; } if (val.GetType().Equals(typeof(DataSet))) { throw new MB.Util.APPException("Summray 的 InvokeDataSourceDesc 配置有误,配置的方法返回值必须是 IList", MB.Util.APPMessageType.SysErrInfo); } IList lst = val as IList; if (lst != null) { summaryInfo.DataSource = lst; return; } }
public AnswerMatchSummerizer() { string content = Utils.Utils.ReadEmbeddedResourceFile("Education.Engine.Res.examanswers.json"); Dictionary <string, SummaryInfo> summaryDict = JsonConvert.DeserializeObject <Dictionary <string, SummaryInfo> >(content); foreach (string key in summaryDict.Keys) { if (key == this.GetType().FullName) { this.info = summaryDict[key]; } } }
/// <summary> /// 生成控制器摘要信息 /// </summary> private void GenerateSummaryInfo() { SummaryNodes.Clear(); if (TheController != null) { ControllerManager controllerManager = new ControllerManager(); controllerManager.InitializeAllControllerOperation(null); IControllerOperation controllerOperation = controllerManager.GetController(TheController.Type); //controllerOperation SummaryInfo controllerSummary = controllerOperation.GetSummaryNodes(TheController, 1); SummaryNodes.Add(controllerSummary); } }
public static void ProcessSummaryInfo(SummaryInfo si, XmlWriter xmlw) { xmlw.WriteStartElement("SummaryInfo"); xmlw.WriteAttributeString("Author", si.Author); xmlw.WriteAttributeString("Comments", si.Comments); xmlw.WriteAttributeString("IsSavingWithPreview", si.IsSavingWithPreview.ToStringSafe()); xmlw.WriteAttributeString("Keywords", si.Keywords); xmlw.WriteAttributeString("LastSavedBy", si.LastSavedBy); xmlw.WriteAttributeString("RevisionNumber", si.RevisionNumber); xmlw.WriteAttributeString("Subject", si.Subject); xmlw.WriteAttributeString("Title", si.Title); xmlw.WriteEndElement(); }
public void AddTypeSummary(DataResult result) { var typeSummay = SummaryInfo.FindLast(x => x.TypeName == result.TypeInfo); if (typeSummay != null) { typeSummay.Count++; } else { SummaryInfo.Add(new TypeSummary(result.TypeInfo)); } }
public void PreviewSummary(SummaryInfo si, RowsInfo ri) { rprtCostSummary rprt = new rprtCostSummary(); FPreviewAR pv = new FPreviewAR(); rprt.SummaryInformation = si; rprt.RowsInfo = ri; rprt.Run(); pv.projNumber = si.project; //*******************************Added 9/30/2015 pv.ViewReport(rprt); pv.ShowDialog(); }
/// <summary> /// FormLoad是调用的函数 /// </summary> private void myFormLoad() { //if (_ClientRule != null) // _XmlFile = _ClientRule.ClientLayoutAttribute.UIXmlConfigFile; _ColProps = LayoutXmlConfigHelper.Instance.GetColumnPropertys(_XmlFile); _SummaryInfo = LayoutXmlConfigHelper.Instance.GetSummaryInfo(_XmlFile); if (_SummaryInfo == null) { throw new MB.Util.APPException("请检查<Summary>节点是否配置,读不到配置信息", Util.APPMessageType.DisplayToUser); } bindToSummaryLevel(); }
static List<SummaryInfo> TransformSummary(SummaryInfo[] original, string fieldPrefix) { var result = new List<SummaryInfo>(); if(original != null) { for(var i = 0; i < original.Length; i++) { result.Add(new SummaryInfo { Selector = fieldPrefix + i, SummaryType = TransformSummaryType(original[i].SummaryType) }); } } return result; }
public static void ProcessSummaryInfo(SummaryInfo si, Utf8JsonWriter jsonw) { jsonw.WritePropertyName("SummaryInfo"); jsonw.WriteStartObject(); jsonw.WriteString("Author", si.Author); jsonw.WriteString("Comments", si.Comments); jsonw.WriteString("IsSavingWithPreview", si.IsSavingWithPreview.ToStringSafe()); jsonw.WriteString("Keywords", si.Keywords); jsonw.WriteString("LastSavedBy", si.LastSavedBy); jsonw.WriteString("RevisionNumber", si.RevisionNumber); jsonw.WriteString("Subject", si.Subject); jsonw.WriteString("Title", si.Title); jsonw.WriteEndObject(); }
public static ObservableCollection <StatisticsInfoRowVM> CreateNumberRows(StatisticsInfo statisticsInfo) { ObservableCollection <StatisticsInfoRowVM> rows = new ObservableCollection <StatisticsInfoRowVM>(); SummaryInfo summaryInfo = statisticsInfo.SummaryInfo; rows.Add(CreateNumberRow(Resources.ValidFrequency, summaryInfo.ValidCasesString)); rows.Add(CreateNumberRow(Resources.InvalidFrequency, summaryInfo.InvalidCasesString)); rows.Add(CreateNumberRow(Resources.SampleFrequency, summaryInfo.TotalCasesString)); rows.Add(CreateNumberRow(Resources.Mean, summaryInfo.MeanString)); rows.Add(CreateNumberRow(Resources.Median, summaryInfo.MedianString)); rows.Add(CreateNumberRow(Resources.StandardDeviation, summaryInfo.StandardDeviationString)); rows.Add(CreateNumberRow(Resources.Minimum, summaryInfo.MinimumString)); rows.Add(CreateNumberRow(Resources.Maximum, summaryInfo.MaximumString)); return(rows); }
/// <summary> /// Writes a <see cref="SummaryInfo"/> object for each supported file type to the pipeline. /// </summary> /// <param name="item">A <see cref="PSObject"/> representing the file system object to process.</param> protected override void ProcessItem(PSObject item) { var path = item.GetPropertyValue<string>("PSPath"); var providerPath = this.SessionState.Path.GetUnresolvedProviderPathFromPSPath(path); // Make sure the file exists and is a patch. var type = FileInfo.GetFileTypeInternal(providerPath); if (FileType.Package == type || FileType.Patch == type || FileType.Transform == type) { using (var info = new Deployment.WindowsInstaller.SummaryInfo(providerPath, false)) { var copy = new SummaryInfo(info); var obj = PSObject.AsPSObject(copy); // Add the class type as the first type name. var name = typeof(SummaryInfo).FullName + "#" + type; obj.TypeNames.Insert(0, name); // Attach the original PSPath and write to the pipeline. obj.SetPropertyValue("PSPath", path); this.WriteObject(obj); } } // Enumerate transforms in the patch. if (FileType.Patch == type && this.IncludeTransforms) { using (var patch = new PatchPackage(providerPath)) { foreach (var transform in patch.GetTransformsInfo(true)) { var obj = PSObject.AsPSObject(transform); // Attach the original patch path and write to the pipeline. obj.SetPropertyValue("Patch", providerPath); this.WriteObject(obj); } } } }
internal override ListViewItem AddToListView(ListView list, XmlDocument dom, byte[] baTimestamp, string strRecPath, string strBiblioRecPath, string[] summary_col_names, SummaryInfo summary) { string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode"); ListViewItem item = new ListViewItem(strBarcode, 0); SetListViewItemText(dom, baTimestamp, false, strRecPath, strBiblioRecPath, summary_col_names, summary, item); list.Items.Add(item); return item; }
internal override void SetListViewItemText(XmlDocument dom, byte[] baTimestamp, bool bSetBarcodeColumn, string strRecPath, string strBiblioRecPath, string[] summary_col_names, SummaryInfo summary, ListViewItem item) { string strBiblioSummary = ""; string strISBnISSN = ""; string strTargetRecPath = ""; if (summary != null && summary.Values != null) { if (summary.Values.Length > 0) strBiblioSummary = summary.Values[0]; if (summary.Values.Length > 1) strISBnISSN = summary.Values[1]; if (summary.Values.Length > 2) strTargetRecPath = summary.Values[2]; } OriginItemData data = null; data = (OriginItemData)item.Tag; if (data == null) { data = new OriginItemData(); item.Tag = data; } else { data.Changed = false; } data.Xml = dom.OuterXml; // data.Timestamp = baTimestamp; string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location"); string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price"); string strBookType = DomUtil.GetElementText(dom.DocumentElement, "bookType"); string strRegisterNo = DomUtil.GetElementText(dom.DocumentElement, "registerNo"); string strComment = DomUtil.GetElementText(dom.DocumentElement, "comment"); string strMergeComment = DomUtil.GetElementText(dom.DocumentElement, "mergeComment"); string strBatchNo = DomUtil.GetElementText(dom.DocumentElement, "batchNo"); string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower"); string strBorrowDate = DomUtil.GetElementText(dom.DocumentElement, "borrowDate"); string strAccessNo = DomUtil.GetElementText(dom.DocumentElement, "accessNo"); // 2007/6/20 strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u"); string strBorrowPeriod = DomUtil.GetElementText(dom.DocumentElement, "borrowPeriod"); ListViewUtil.ChangeItemText(item, COLUMN_SUMMARY, strBiblioSummary); ListViewUtil.ChangeItemText(item, COLUMN_ACCESSNO, strAccessNo); ListViewUtil.ChangeItemText(item, COLUMN_ISBNISSN, strISBnISSN); ListViewUtil.ChangeItemText(item, COLUMN_STATE, strState); ListViewUtil.ChangeItemText(item, COLUMN_LOCATION, strLocation); ListViewUtil.ChangeItemText(item, COLUMN_PRICE, strPrice); ListViewUtil.ChangeItemText(item, COLUMN_BOOKTYPE, strBookType); ListViewUtil.ChangeItemText(item, COLUMN_REGISTERNO, strRegisterNo); ListViewUtil.ChangeItemText(item, COLUMN_COMMENT, strComment); ListViewUtil.ChangeItemText(item, COLUMN_MERGECOMMENT, strMergeComment); ListViewUtil.ChangeItemText(item, COLUMN_BATCHNO, strBatchNo); ListViewUtil.ChangeItemText(item, COLUMN_BORROWER, strBorrower); ListViewUtil.ChangeItemText(item, COLUMN_BORROWDATE, strBorrowDate); ListViewUtil.ChangeItemText(item, COLUMN_BORROWPERIOD, strBorrowPeriod); ListViewUtil.ChangeItemText(item, COLUMN_RECPATH, strRecPath); ListViewUtil.ChangeItemText(item, COLUMN_BIBLIORECPATH, strBiblioRecPath); ListViewUtil.ChangeItemText(item, COLUMN_TARGETRECPATH, strTargetRecPath); bool bBarcodeChanged = false; if (bSetBarcodeColumn == true) { string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode"); string strOldBarcode = ListViewUtil.GetItemText(item, COLUMN_BARCODE); if (strBarcode != strOldBarcode) { ListViewUtil.ChangeItemText(item, COLUMN_BARCODE, strBarcode); bBarcodeChanged = true; } } if (item.ImageIndex != TYPE_VERIFIED || bBarcodeChanged == true) // 2012/4/8 原来不是验证后状态,或者条码号栏内容修改过,均可以重设置颜色。否则不应港重设颜色 --- 主要目的是保留以前验证后的状态 SetItemColor(item, TYPE_NORMAL); }
// 根据册条码号或者记录路径,装入册记录 // parameters: // strBarcodeOrRecPath 册条码号或者记录路径。如果内容前缀为"@path:"则表示为路径 // strMatchLocation 附加的馆藏地点匹配条件。如果==null,表示没有这个附加条件(注意,""和null含义不同,""表示确实要匹配这个值) // return: // -2 册条码号或者记录路径已经在list中存在了(行没有加入listview中) // -1 出错(注意表示出错的行已经加入listview中了) // 0 因为馆藏地点不匹配,没有加入list中 // 1 成功 internal virtual int LoadOneItem( string strPubType, bool bFillSummaryColumn, string[] summary_col_names, string strBarcodeOrRecPath, RecordInfo info, ListView list, string strMatchLocation, out string strOutputItemRecPath, ref ListViewItem item, out string strError) { strError = ""; strOutputItemRecPath = ""; long lRet = 0; // 判断是否有 @path: 前缀,便于后面分支处理 bool bIsRecPath = StringUtil.HasHead(strBarcodeOrRecPath, "@path:"); string strItemText = ""; string strBiblioText = ""; // string strItemRecPath = ""; string strBiblioRecPath = ""; XmlDocument item_dom = null; #if NO string strBiblioSummary = ""; string strISBnISSN = ""; #endif SummaryInfo summary = null; byte[] item_timestamp = null; if (info == null) { REDO_GETITEMINFO: lRet = Channel.GetItemInfo( stop, strBarcodeOrRecPath, "xml", out strItemText, out strOutputItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", this.FormCaption, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETITEMINFO; } if (lRet == -1 || lRet == 0) { SetError(list, ref item, strBarcodeOrRecPath, strError); goto ERROR1; } summary = (SummaryInfo)this.m_summaryTable[strBiblioRecPath]; if (summary != null) { #if NO strBiblioSummary = summary.Summary; strISBnISSN = summary.ISBnISSn; #endif } if (summary == null && bFillSummaryColumn == true) { string[] results = null; byte[] timestamp = null; stop.SetMessage("正在装入书目记录 '" + strBiblioRecPath + "' 的摘要 ..."); Debug.Assert(String.IsNullOrEmpty(strBiblioRecPath) == false, "strBiblioRecPath值不能为空"); REDO_GETBIBLIOINFO: lRet = Channel.GetBiblioInfos( stop, strBiblioRecPath, "", summary_col_names, out results, out timestamp, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", this.FormCaption, MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETBIBLIOINFO; } if (lRet == -1 || lRet == 0) { if (lRet == 0 && String.IsNullOrEmpty(strError) == true) strError = "书目记录 '" + strBiblioRecPath + "' 不存在"; // strBiblioSummary = "获得书目摘要时发生错误: " + strError; summary = new SummaryInfo(); summary.Values = new string[1]; summary.Values[0] = "获得书目摘要时发生错误: " + strError; } else { Debug.Assert(results != null && results.Length == summary_col_names.Length, "results必须包含 " + summary_col_names.Length + " 个元素"); #if NO strBiblioSummary = results[0]; strISBnISSN = results[1]; #endif // 避免cache占据的内存太多 if (this.m_summaryTable.Count > 1000) this.m_summaryTable.Clear(); if (summary == null) { summary = new SummaryInfo(); summary.Values = new string[summary_col_names.Length]; for (int j = 0; j < summary_col_names.Length; j++) { summary.Values[j] = results[j]; } this.m_summaryTable[strBiblioRecPath] = summary; } } } // 剖析一个册的xml记录,取出有关信息放入listview中 if (item_dom == null) { item_dom = new XmlDocument(); try { item_dom.LoadXml(strItemText); } catch (Exception ex) { strError = "册记录的XML装入DOM时出错: " + ex.Message; goto ERROR1; } } } else { // record 不为空调用时,对调用时参数strBarcodeOrRecPath不作要求 strBarcodeOrRecPath = "@path:" + info.Record.Path; bIsRecPath = true; if (info.Record.RecordBody.Result.ErrorCode != ErrorCodeValue.NoError) { SetError(list, ref item, strBarcodeOrRecPath, info.Record.RecordBody.Result.ErrorString); goto ERROR1; } strItemText = info.Record.RecordBody.Xml; strOutputItemRecPath = info.Record.Path; // 2013/4/3 if (info.Record.RecordBody != null) item_timestamp = info.Record.RecordBody.Timestamp; // item_dom = info.Dom; strBiblioRecPath = info.BiblioRecPath; if (info.SummaryInfo != null) { #if NO strBiblioSummary = info.SummaryInfo.Summary; strISBnISSN = info.SummaryInfo.ISBnISSn; #endif summary = info.SummaryInfo; } } // 附加的馆藏地点匹配 if (strMatchLocation != null) { // TODO: #reservation, 情况如何处理? string strLocation = DomUtil.GetElementText(item_dom.DocumentElement, "location"); // 2013/3/26 if (strLocation == null) strLocation = ""; if (strMatchLocation != strLocation) return 0; } if (item == null) { item = AddToListView(list, item_dom, item_timestamp, strOutputItemRecPath, strBiblioRecPath, #if NO strBiblioSummary, strISBnISSN, #endif summary_col_names, summary); // 将新加入的事项滚入视野 list.EnsureVisible(list.Items.Count - 1); #if NO // 填充需要从订购库获得的栏目信息 if (this.checkBox_load_fillOrderInfo.Checked == true) FillOrderColumns(item, strPubType); #endif } else { SetListViewItemText(item_dom, item_timestamp, true, strOutputItemRecPath, strBiblioRecPath, #if NO strBiblioSummary, strISBnISSN, #endif summary_col_names, summary, item); } int nRet = VerifyItem( strPubType, strBarcodeOrRecPath, item, item_dom, out strError); if (nRet == -1) goto ERROR1; return 1; ERROR1: return -1; }
/// <summary> /// Reads transform information from the summary information of a transform package. /// </summary> /// <param name="name">Filename of the transform (optional).</param> /// <param name="transformSummaryInfo">Handle to the summary information of a transform package (.MST file).</param> public TransformInfo(string name, SummaryInfo transformSummaryInfo) { this.name = name; this.DecodeSummaryInfo(transformSummaryInfo); }
public void SendEventReminders(Guid id) { var org = Db.LoadOrganizationById(Db.CurrentOrgId0); var setting = Db.CreateRegistrationSettings(org.OrganizationId); const string noSubject = "no subject"; const string noBody = "no body"; var subject = Util.PickFirst(setting.ReminderSubject, noSubject); var message = Util.PickFirst(setting.ReminderBody, noBody); if (subject == noSubject || message == noBody) throw new Exception("no subject or body"); var q = from p in Db.PeopleQuery(id) join om in Db.OrganizationMembers on new {p.PeopleId, org.OrganizationId} equals new {om.PeopleId, om.OrganizationId} into j from om in j select om; var notify = Db.StaffPeopleForOrg(org.OrganizationId).FirstOrDefault(); if (notify == null) throw new Exception("no notify person"); foreach (var om in q) { var si = new SummaryInfo(Db, om.PeopleId, om.OrganizationId); var details = si.ToString(); var organizationName = org.OrganizationName; subject = Util.PickFirst(setting.ReminderSubject, noSubject); message = Util.PickFirst(setting.ReminderBody, noBody); string location = org.Location; message = MessageReplacements(Db, om.Person, null, org.OrganizationId, organizationName, location, message); message = message.Replace("{phone}", org.PhoneNumber.FmtFone7()); message = message.Replace("{details}", details); Db.Email(notify.FromEmail, om.Person, subject, message); } }
public void SendEventReminders(int id) { var org = Db.LoadOrganizationById(id); Db.SetCurrentOrgId(id); var setting = Db.CreateRegistrationSettings(id); const string noSubject = "no subject"; const string noBody = "no body"; var subject = Util.PickFirst(setting.ReminderSubject, noSubject); var message = Util.PickFirst(setting.ReminderBody, noBody); if (subject == noSubject || message == noBody) throw new Exception("no subject or body"); var currmembers = from om in org.OrganizationMembers where (om.Pending ?? false) == false where om.MemberTypeId != CmsData.Codes.MemberTypeCode.InActive select om; var notify = Db.StaffPeopleForOrg(org.OrganizationId).FirstOrDefault(); if (notify == null) throw new Exception("no notify person"); foreach (var om in currmembers) { var si = new SummaryInfo(Db, om.PeopleId, om.OrganizationId); var details = si.ToString(); var organizationName = org.OrganizationName; subject = Util.PickFirst(setting.ReminderSubject, noSubject); message = Util.PickFirst(setting.ReminderBody, noBody); string location = org.Location; message = MessageReplacements(Db, om.Person, null, org.OrganizationId, organizationName, location, message); message = message.Replace("{phone}", org.PhoneNumber.FmtFone7()); message = message.Replace("{details}", details); Db.Email(notify.FromEmail, om.Person, subject, message); } }
// 根据册记录 DOM 设置 ListViewItem 除第一列以外的文字 // parameters: // baTimestamp 册记录的时间戳。如果需要这个信息,则要在 获取册信息阶段注意包含这个要求 // bSetBarcodeColumn 是否要设置条码列内容(第一列) internal virtual void SetListViewItemText(XmlDocument dom, byte[] baTimestamp, bool bSetBarcodeColumn, string strRecPath, string strBiblioRecPath, string[] summary_col_names, SummaryInfo summary, ListViewItem item) { throw new Exception("尚未重载 SetListViewItemText() "); }
internal virtual ListViewItem AddToListView(ListView list, XmlDocument dom, byte[] baTimestamp, string strRecPath, string strBiblioRecPath, string[] summary_col_names, SummaryInfo summary) { throw new Exception("尚未重载 AddToListView() "); }
// 根据册记录 DOM 设置 ListViewItem 除第一列以外的文字 // parameters: // bSetBarcodeColumn 是否要设置条码列内容(第一列) internal override void SetListViewItemText(XmlDocument dom, byte[] baTimestamp, bool bSetBarcodeColumn, string strRecPath, string strBiblioRecPath, string[] summary_col_names, SummaryInfo summary, ListViewItem item) { string strBiblioSummary = ""; string strISBnISSN = ""; if (summary != null && summary.Values != null) { if (summary.Values.Length > 0) strBiblioSummary = summary.Values[0]; if (summary.Values.Length > 1) strISBnISSN = summary.Values[1]; } string strState = DomUtil.GetElementText(dom.DocumentElement, "state"); string strPublishTime = DomUtil.GetElementText(dom.DocumentElement, "publishTime"); string strVolume = DomUtil.GetElementText(dom.DocumentElement, "volume"); string strLocation = DomUtil.GetElementText(dom.DocumentElement, "location"); string strPrice = DomUtil.GetElementText(dom.DocumentElement, "price"); string strBookType = DomUtil.GetElementText(dom.DocumentElement, "bookType"); string strRegisterNo = DomUtil.GetElementText(dom.DocumentElement, "registerNo"); string strComment = DomUtil.GetElementText(dom.DocumentElement, "comment"); string strMergeComment = DomUtil.GetElementText(dom.DocumentElement, "mergeComment"); string strBatchNo = DomUtil.GetElementText(dom.DocumentElement, "batchNo"); string strAccessNo = DomUtil.GetElementText(dom.DocumentElement, "accessNo"); string strRefID = DomUtil.GetElementText(dom.DocumentElement, "refID"); /* string strBorrower = DomUtil.GetElementText(dom.DocumentElement, "borrower"); string strBorrowDate = DomUtil.GetElementText(dom.DocumentElement, "borrowDate"); // 2007/6/20 strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u"); string strBorrowPeriod = DomUtil.GetElementText(dom.DocumentElement, "borrowPeriod"); * */ // 2011/6/13 string strSeller = DomUtil.GetElementText(dom.DocumentElement, "seller"); string strSource = DomUtil.GetElementText(dom.DocumentElement, "source"); ListViewUtil.ChangeItemText(item, COLUMN_SUMMARY, strBiblioSummary); ListViewUtil.ChangeItemText(item, COLUMN_STATE, strState); ListViewUtil.ChangeItemText(item, COLUMN_ACCESSNO, strAccessNo); ListViewUtil.ChangeItemText(item, MERGED_COLUMN_PUBLISHTIME, strPublishTime); ListViewUtil.ChangeItemText(item, MERGED_COLUMN_VOLUME, strVolume); ListViewUtil.ChangeItemText(item, COLUMN_ISBNISSN, strISBnISSN); ListViewUtil.ChangeItemText(item, COLUMN_LOCATION, strLocation); ListViewUtil.ChangeItemText(item, COLUMN_PRICE, strPrice); ListViewUtil.ChangeItemText(item, COLUMN_BOOKTYPE, strBookType); ListViewUtil.ChangeItemText(item, COLUMN_REGISTERNO, strRegisterNo); ListViewUtil.ChangeItemText(item, COLUMN_COMMENT, strComment); ListViewUtil.ChangeItemText(item, COLUMN_MERGECOMMENT, strMergeComment); ListViewUtil.ChangeItemText(item, COLUMN_BATCHNO, strBatchNo); /* ListViewUtil.ChangeItemText(item, COLUMN_BORROWER, strBorrower); ListViewUtil.ChangeItemText(item, COLUMN_BORROWDATE, strBorrowDate); ListViewUtil.ChangeItemText(item, COLUMN_BORROWPERIOD, strBorrowPeriod); * */ ListViewUtil.ChangeItemText(item, COLUMN_RECPATH, strRecPath); ListViewUtil.ChangeItemText(item, COLUMN_BIBLIORECPATH, strBiblioRecPath); ListViewUtil.ChangeItemText(item, COLUMN_REFID, strRefID); ListViewUtil.ChangeItemText(item, EXTEND_COLUMN_SELLER, strSeller); ListViewUtil.ChangeItemText(item, EXTEND_COLUMN_SOURCE, strSource); if (bSetBarcodeColumn == true) { string strBarcode = DomUtil.GetElementText(dom.DocumentElement, "barcode"); ListViewUtil.ChangeItemText(item, COLUMN_BARCODE, strBarcode); } SetItemColor(item, TYPE_NORMAL); }
public int RefreshOneItem(ListViewItem item, bool bFillBiblioSummary, out string strError) { strError = ""; string strItemText = ""; string strBiblioText = ""; string strItemRecPath = ""; string strBiblioRecPath = ""; byte[] item_timestamp = null; string strBarcode = ""; string strBarcodeOrRecPath = item.Text; if (StringUtil.HasHead(strBarcodeOrRecPath, "@path:") == true) strBarcode = strBarcodeOrRecPath; else strBarcode = "@path:" + item.SubItems[COLUMN_RECPATH].Text; REDO_GETITEMINFO: long lRet = Channel.GetItemInfo( stop, strBarcode, "xml", out strItemText, out strItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "AccountBookForm", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETITEMINFO; } if (lRet == -1 || lRet == 0) { ListViewUtil.ChangeItemText(item, 1, strError); SetItemColor(item, TYPE_ERROR); goto ERROR1; } string strBiblioSummary = ""; string strISBnISSN = ""; SummaryInfo info = (SummaryInfo)this.m_summaryTable[strBiblioRecPath]; if (info != null) { strBiblioSummary = info.Summary; strISBnISSN = info.ISBnISSn; } if (strBiblioSummary == "" && (this.checkBox_load_fillBiblioSummary.Checked == true || bFillBiblioSummary == true ) ) { string[] formats = new string[2]; formats[0] = "summary"; formats[1] = "@isbnissn"; string[] results = null; byte[] timestamp = null; Debug.Assert( String.IsNullOrEmpty(strBiblioRecPath) == false, "strBiblioRecPath值不能为空"); REDO_GETBIBLIOINFO: lRet = Channel.GetBiblioInfos( stop, strBiblioRecPath, formats, out results, out timestamp, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "AccountBookForm", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETBIBLIOINFO; } if (lRet == -1 || lRet == 0) { if (lRet == 0 && String.IsNullOrEmpty(strError) == true) strError = "书目记录 '" + strBiblioRecPath + "' 不存在"; strBiblioSummary = "获得书目摘要时发生错误: " + strError; // TODO: 如果results.Length表现正常,其实还可以继续处理 } else { Debug.Assert(results != null && results.Length == 2, "results必须包含2个元素"); strBiblioSummary = results[0]; strISBnISSN = results[1]; // 避免cache占据的内存太多 if (this.m_summaryTable.Count > 1000) this.m_summaryTable.Clear(); if (info == null) { info = new SummaryInfo(); info.Summary = strBiblioSummary; info.ISBnISSn = strISBnISSN; this.m_summaryTable[strBiblioRecPath] = info; } } } // 剖析一个册的xml记录,取出有关信息放入listview中 XmlDocument dom = new XmlDocument(); try { dom.LoadXml(strItemText); } catch (Exception ex) { strError = ex.Message; goto ERROR1; } { SetListViewItemText(dom, true, strItemRecPath, strBiblioSummary, strISBnISSN, strBiblioRecPath, item); } // 图标 // item.ImageIndex = TYPE_NORMAL; SetItemColor(item, TYPE_NORMAL); // 2009/7/25 // 填充需要从订购库获得的栏目信息 if (this.checkBox_load_fillOrderInfo.Checked == true) FillOrderColumns(item, this.comboBox_load_type.Text); return 1; ERROR1: return -1; }
// 准备DOM和书目摘要等 int GetSummaries( List<DigitalPlatform.CirculationClient.localhost.Record> records, out List<RecordInfo> infos, out string strError) { strError = ""; infos = new List<RecordInfo>(); // 准备DOM和书目摘要 for (int i = 0; i < records.Count; i++) { if (stop != null) { if (stop.State != 0) { strError = "用户中断1"; return -1; } } RecordInfo info = new RecordInfo(); info.Record = records[i]; infos.Add(info); if (info.Record.RecordBody == null) { strError = "请升级dp2Kernel到最新版本"; return -1; } if (info.Record.RecordBody.Result.ErrorCode != ErrorCodeValue.NoError) continue; info.Dom = new XmlDocument(); try { info.Dom.LoadXml(info.Record.RecordBody.Xml); } catch (Exception ex) { strError = "册记录的XML装入DOM时出错: " + ex.Message; return -1; } // 准备书目记录路径 string strParentID = DomUtil.GetElementText(info.Dom.DocumentElement, "parent"); string strBiblioDbName = this.MainForm.GetBiblioDbNameFromItemDbName(Global.GetDbName(info.Record.Path)); if (string.IsNullOrEmpty(strBiblioDbName) == true) { strError = "根据册记录路径 '" + info.Record.Path + "' 获得书目库名时出错"; return -1; } info.BiblioRecPath = strBiblioDbName + "/" + strParentID; } // 准备摘要 if (this.checkBox_load_fillBiblioSummary.Checked == true) { // 归并书目记录路径 List<string> bibliorecpaths = new List<string>(); foreach (RecordInfo info in infos) { bibliorecpaths.Add(info.BiblioRecPath); } // 去重 StringUtil.RemoveDupNoSort(ref bibliorecpaths); // 看看cache中是否已经存在,如果已经存在则不再从服务器取 for (int i = 0; i < bibliorecpaths.Count; i++ ) { string strPath = bibliorecpaths[i]; SummaryInfo summary = (SummaryInfo)this.m_summaryTable[strPath]; if (summary != null) { bibliorecpaths.RemoveAt(i); i--; } } // 从服务器获取 if (bibliorecpaths.Count > 0) { REDO_GETBIBLIOINFO_0: string strCommand = "@path-list:" + StringUtil.MakePathList(bibliorecpaths); string[] formats = new string[2]; formats[0] = "summary"; formats[1] = "@isbnissn"; string[] results = null; byte[] timestamp = null; // stop.SetMessage("正在装入书目记录 '" + bibliorecpaths[0] + "' 等的摘要 ..."); // TODO: 有没有可能希望取的事项数目一次性取得没有取够? REDO_GETBIBLIOINFO: long lRet = Channel.GetBiblioInfos( stop, strCommand, "", formats, out results, out timestamp, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "AccountBookForm", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETBIBLIOINFO; } if (lRet == -1 || lRet == 0) { if (lRet == 0 && String.IsNullOrEmpty(strError) == true) strError = "书目记录 '" + StringUtil.MakePathList(bibliorecpaths) + "' 不存在"; strError = "获得书目摘要时发生错误: " + strError; // 如果results.Length表现正常,其实还可以继续处理 if (results != null /* && results.Length == 2 * bibliorecpaths.Count */) { } else return -1; } if (results != null/* && results.Length == 2 * bibliorecpaths.Count*/) { // Debug.Assert(results != null && results.Length == 2 * bibliorecpaths.Count, "results必须包含 " + (2 * bibliorecpaths.Count).ToString() + " 个元素"); // 放入缓存 for (int i = 0; i < results.Length / 2; i++) { SummaryInfo summary = new SummaryInfo(); summary.Summary = results[i*2]; summary.ISBnISSn = results[i*2+1]; this.m_summaryTable[bibliorecpaths[i]] = summary; } } if (results != null && results.Length != 2 * bibliorecpaths.Count) { // 没有取够,需要继续处理 bibliorecpaths.RemoveRange(0, results.Length / 2); goto REDO_GETBIBLIOINFO_0; } } // 挂接到每个记录附近 foreach (RecordInfo info in infos) { SummaryInfo summary = (SummaryInfo)this.m_summaryTable[info.BiblioRecPath]; if (summary == null) { strError = "缓存中找不到书目记录 '" + info.BiblioRecPath + "' 的摘要事项"; return -1; } info.SummaryInfo = summary; } // 避免cache占据的内存太多 if (this.m_summaryTable.Count > 1000) this.m_summaryTable.Clear(); } return 0; }
// 根据册条码号或者记录路径,装入册记录 // parameters: // strBarcodeOrRecPath 册条码号或者记录路径。如果内容前缀为"@path:"则表示为路径 // strMatchLocation 附加的馆藏地点匹配条件。如果==null,表示没有这个附加条件(注意,""和null含义不同,""表示确实要匹配这个值) // return: // -2 册条码号或者记录路径已经在list中存在了(行没有加入listview中) // -1 出错(注意表示出错的行已经加入listview中了) // 0 因为馆藏地点不匹配,没有加入list中 // 1 成功 int LoadOneItem( string strPubType, string strBarcodeOrRecPath, RecordInfo info, ListView list, string strMatchLocation, out string strOutputItemRecPath, ref ListViewItem item, out string strError) { strError = ""; strOutputItemRecPath = ""; long lRet = 0; // 判断是否有 @path: 前缀,便于后面分支处理 bool bIsRecPath = StringUtil.HasHead(strBarcodeOrRecPath, "@path:"); string strItemText = ""; string strBiblioText = ""; // string strItemRecPath = ""; string strBiblioRecPath = ""; XmlDocument item_dom = null; string strBiblioSummary = ""; string strISBnISSN = ""; if (info == null) { byte[] item_timestamp = null; REDO_GETITEMINFO: lRet = Channel.GetItemInfo( stop, strBarcodeOrRecPath, "xml", out strItemText, out strOutputItemRecPath, out item_timestamp, "recpath", out strBiblioText, out strBiblioRecPath, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "AccountBookForm", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETITEMINFO; } if (lRet == -1 || lRet == 0) { #if NO if (item == null) { item = new ListViewItem(strBarcodeOrRecPath, 0); list.Items.Add(item); } else { Debug.Assert(item.ListView == list, ""); } // item.SubItems.Add(strError); ListViewUtil.ChangeItemText(item, COLUMN_ERRORINFO, strError); SetItemColor(item, TYPE_ERROR); // 将新加入的事项滚入视野 list.EnsureVisible(list.Items.IndexOf(item)); #endif SetError(list, ref item, strBarcodeOrRecPath, strError); goto ERROR1; } SummaryInfo summary = (SummaryInfo)this.m_summaryTable[strBiblioRecPath]; if (summary != null) { strBiblioSummary = summary.Summary; strISBnISSN = summary.ISBnISSn; } if (strBiblioSummary == "" && this.checkBox_load_fillBiblioSummary.Checked == true) { string[] formats = new string[2]; formats[0] = "summary"; formats[1] = "@isbnissn"; string[] results = null; byte[] timestamp = null; stop.SetMessage("正在装入书目记录 '" + strBiblioRecPath + "' 的摘要 ..."); Debug.Assert(String.IsNullOrEmpty(strBiblioRecPath) == false, "strBiblioRecPath值不能为空"); REDO_GETBIBLIOINFO: lRet = Channel.GetBiblioInfos( stop, strBiblioRecPath, "", formats, out results, out timestamp, out strError); if (lRet == -1) { DialogResult temp_result = MessageBox.Show(this, strError + "\r\n\r\n是否重试?", "AccountBookForm", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (temp_result == DialogResult.Retry) goto REDO_GETBIBLIOINFO; } if (lRet == -1 || lRet == 0) { if (lRet == 0 && String.IsNullOrEmpty(strError) == true) strError = "书目记录 '" + strBiblioRecPath + "' 不存在"; strBiblioSummary = "获得书目摘要时发生错误: " + strError; } else { Debug.Assert(results != null && results.Length == 2, "results必须包含2个元素"); strBiblioSummary = results[0]; strISBnISSN = results[1]; // 避免cache占据的内存太多 if (this.m_summaryTable.Count > 1000) this.m_summaryTable.Clear(); if (summary == null) { summary = new SummaryInfo(); summary.Summary = strBiblioSummary; summary.ISBnISSn = strISBnISSN; this.m_summaryTable[strBiblioRecPath] = summary; } } } // 剖析一个册的xml记录,取出有关信息放入listview中 if (item_dom == null) { item_dom = new XmlDocument(); try { item_dom.LoadXml(strItemText); } catch (Exception ex) { strError = "册记录的XML装入DOM时出错: " + ex.Message; goto ERROR1; } } } else { // record 不为空调用时,对调用时参数strBarcodeOrRecPath不作要求 strBarcodeOrRecPath = "@path:" + info.Record.Path; bIsRecPath = true; if (info.Record.RecordBody.Result.ErrorCode != ErrorCodeValue.NoError) { #if NO if (item == null) item = new ListViewItem(strBarcodeOrRecPath, 0); item.SubItems.Add(info.Record.RecordBody.Result.ErrorString); SetItemColor(item, TYPE_ERROR); list.Items.Add(item); // 将新加入的事项滚入视野 list.EnsureVisible(list.Items.Count - 1); #endif SetError(list, ref item, strBarcodeOrRecPath, info.Record.RecordBody.Result.ErrorString); goto ERROR1; } strItemText = info.Record.RecordBody.Xml; strOutputItemRecPath = info.Record.Path; // item_dom = info.Dom; strBiblioRecPath = info.BiblioRecPath; if (info.SummaryInfo != null) { strBiblioSummary = info.SummaryInfo.Summary; strISBnISSN = info.SummaryInfo.ISBnISSn; } } // 附加的馆藏地点匹配 if (strMatchLocation != null) { // TODO: #reservation, 情况如何处理? string strLocation = DomUtil.GetElementText(item_dom.DocumentElement, "location"); // 2013/3/26 if (strLocation == null) strLocation = ""; if (strMatchLocation != strLocation) return 0; } if (item == null) { item = AddToListView(list, item_dom, strOutputItemRecPath, strBiblioSummary, strISBnISSN, strBiblioRecPath); // 图标 // item.ImageIndex = TYPE_NORMAL; SetItemColor(item, TYPE_NORMAL); // 将新加入的事项滚入视野 list.EnsureVisible(list.Items.Count - 1); #if NO // 填充需要从订购库获得的栏目信息 if (this.checkBox_load_fillOrderInfo.Checked == true) FillOrderColumns(item, strPubType); #endif } else { SetListViewItemText(item_dom, true, strOutputItemRecPath, strBiblioSummary, strISBnISSN, strBiblioRecPath, item); SetItemColor(item, TYPE_NORMAL); } return 1; ERROR1: return -1; }
/// <summary> /// Gets information about a transforms included in the patch package. /// </summary> /// <param name="transform">Name of the transform to extract; this may optionally be a /// special transform prefixed by "#"</param> /// <returns>Information about the transform</returns> public TransformInfo GetTransformInfo(string transform) { string tempTransformFile = null; try { tempTransformFile = Path.GetTempFileName(); this.ExtractTransform(transform, tempTransformFile); using(SummaryInfo transformSummInfo = new SummaryInfo(tempTransformFile, false)) { return new TransformInfo(transform, transformSummInfo); } } finally { if(tempTransformFile != null && File.Exists(tempTransformFile)) { File.Delete(tempTransformFile); } } }