What is the equivalent method of ExecuteQuerySegmentedAsync in Azure.Data.Tables? - azure-sdk-.net

What is the equivalent method of ExecuteQuerySegmentedAsync in Azure.Data.Tables?
Recently Microsoft azure sdk deprecated Microsoft.Azure.Cosmos.Table package and recommended to use Azure.Data.Tables package.
But, I couldn't find equivalent ExecuteQuerySegmentedAsync method in Azure.Data.Tables package.
Current code using Microsoft.Azure.Cosmos.Table package below:
var srcTableName = "TestTable";
var tableBatchResults = new List<TableBatchResult>();
CloudTable srcCloudTable = tableClient.GetTableReference(srcTableName);
var tableContinuationToken = new TableContinuationToken();
do
{
var entities = new List<T>();
var segment = await srcCloudTable.ExecuteQuerySegmentedAsync<T>(tableQuery, tableContinuationToken);
entities.AddRange(segment.Results);
}while (tableContinuationToken != null);
How to convert this code with Azure.Data.Tables package.

Related

How to remove the extra page at the end of a word document which created during mail merge

I have written a piece of code to create a word document by mail merge using Syncfusion (Assembly Syncfusion.DocIO.Portable, Version=17.1200.0.50,), Angular 7+ and .NET Core. Please see the code below.
private MemoryStream MergePaymentPlanInstalmentsScheduleToPdf(List<PaymentPlanInstalmentReportModel>
PaymentPlanDetails, byte[] templateFileBytes)
{
if (templateFileBytes == null || templateFileBytes.Length == 0)
{
return null;
}
var templateStream = new MemoryStream(templateFileBytes);
var pdfStream = new MemoryStream();
WordDocument mergeDocument = null;
using (mergeDocument = new WordDocument(templateStream, FormatType.Docx))
{
if (mergeDocument != null)
{
var mergeList = new List<PaymentPlanInstalmentScheduleMailMergeModel>();
var obj = new PaymentPlanInstalmentScheduleMailMergeModel();
obj.Applicants = 0;
if (PaymentPlanDetails != null && PaymentPlanDetails.Any()) {
var applicantCount = PaymentPlanDetails.GroupBy(a => a.StudentID)
.Select(s => new
{
StudentID = s.Key,
Count = s.Select(a => a.StudentID).Distinct().Count()
});
obj.Applicants = applicantCount?.Count() > 0 ? applicantCount.Count() : 0;
}
mergeList.Add(obj);
var reportDataSource = new MailMergeDataTable("Report", mergeList);
var tableDataSource = new MailMergeDataTable("PaymentPlanDetails", PaymentPlanDetails);
List<DictionaryEntry> commands = new List<DictionaryEntry>();
commands.Add(new DictionaryEntry("Report", ""));
commands.Add(new DictionaryEntry("PaymentPlanDetails", ""));
MailMergeDataSet ds = new MailMergeDataSet();
ds.Add(reportDataSource);
ds.Add(tableDataSource);
mergeDocument.MailMerge.ExecuteNestedGroup(ds, commands);
mergeDocument.UpdateDocumentFields();
using (var converter = new DocIORenderer())
{
using (var pdfDocument = converter.ConvertToPDF(mergeDocument))
{
pdfDocument.Save(pdfStream);
pdfDocument.Close();
}
}
mergeDocument.Close();
}
}
return pdfStream;
}
Once the document is generated, I notice there is a blank page (with the footer) at the end. I searched for a solution on the internet over and over again, but I was not able to find a solution. According to experts, I have done the initial checks such as making sure that the initial word template file has no page breaks, etc.
I am wondering if there is something that I can do from my code to remove any extra page breaks or anything like that, which can cause this.
Any other suggested solution for this, even including MS Word document modifications also appreciated.
Please refer the below documentation link to remove empty page at the end of Word document using Syncfusion Word library (Essential DocIO).
https://www.syncfusion.com/kb/10724/how-to-remove-empty-page-at-end-of-word-document
Please reuse the code snippet before converting Word to PDF in your sample application.
Note: I work for Syncfusion.

TypeError: Cannot read property 'getRow' of undefined

Tried with
cellValue= worksheet.getRow(1).getCell(1).value;
and
cellValue=console.log(worksheet.getCell('A1'))
please find below my code :
cellread2=function(){
var Excel;
var filePath = path.resolve(__dirname,'E:/excel.xlsx');
if (typeof require !== 'undefined') {
Excel = require('C:/Users/user/AppData/Roaming/npm/node_modules/exceljs/dist/exceljs');
}
var wb = new Excel.Workbook();
console.log(wb);
wb.xlsx.readFile(filePath);
var worksheet = wb.getWorksheet('Sheet1');
//cellValue= worksheet.getRow(1).getCell(1).value;//Error :TypeError: Cannot read property 'getRow' of undefined
cellValue=console.log(worksheet.getCell('A1'))// TypeError: Cannot read property 'getCell' of undefined
console.log(cellValue);
}
There is a problem with the existing library code. If you want to make it work you will have to make few changes in the existing code in file AppData\Roaming\npm\node_modules\exceljs\dist\es5\xlsx\xform\sheet\worksheet-xform.js. Replace the code at line 284 with the following :
if (drawing.anchors && drawing.anchors.length > 0) {
drawing.anchors.forEach(function (anchor) {
if (anchor.medium && anchor.range) {
var image = {
type: 'image',
imageId: anchor.medium.index,
range: anchor.range
};
model.media.push(image);
}
});
}
And as for the code for reading the file use the following code.
Note: I installed exceljs library globally and I am using version 4.6.1
var path = require('path');
var Excel = require('exceljs');
var cellread2 = function () {
var filePath = path.resolve('E:', 'excel.xlsx');
var wb = new Excel.Workbook();
wb.xlsx.readFile(filePath).then(function (data) {
var worksheet = wb.getWorksheet('Sheet1');
var cellValue = worksheet.getRow(1).getCell(1).value;
console.log('cellValue', cellValue);
}).catch(function (e) {
console.log(e);
});
}
cellread2();
It may occurs due to objects are mapped into the excel sheet instead of textual data.
Please create another excel sheet and check it again will resolve this issue.'
Sample code to read excel sheet using node.js is given below,
var Excel = require('exceljs');
var wb = new Excel.Workbook();
var path = require('path');
var filePath = path.resolve(__dirname,'sample.xlsx');
wb.xlsx.readFile(filePath).then(function(){
var sh = wb.getWorksheet("Sheet1");
sh.getRow(1).getCell(2).value = 32;
wb.xlsx.writeFile("sample2.xlsx");
console.log("Row-3 | Cell-2 - "+sh.getRow(3).getCell(2).value);
console.log(sh.rowCount);
//Get all the rows data [1st and 2nd column]
for (i = 1; i <= sh.rowCount; i++) {
console.log(sh.getRow(i).getCell(1).value);
console.log(sh.getRow(i).getCell(2).value);
}
});
In my case the sheet name did not match with 'Sheet1', since I was modifying an existing excel file. Replacing the sheet name resolved the issue.

How to tokenize a text in lucene 3.0.3

I need to translate this code from lucene.net 2.3.2 to 3.0.3.
This code works fine in 2.3.2 but in 3.0.3 the method tokenStream.Next() does not return a token but a boolean. What I need to understand is where to read the token object when next() returns true.
Analyzer analyzer = new StandardAnalyzer();
StringReader stringReader = new StringReader("the house id red");
TokenStream tokenStream = analyzer.TokenStream("", stringReader);
Token token = tokenStream.Next();
while (token != null)
{
System.Diagnostics.Debug.Write(token.TermText());
token = tokenStream.Next();
}
The TokenStreams in Lucene 3+ can now represent a whole set of values (called attributes) for each position in the stream. So you need to modify your example to be attribute aware...
var analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);
var stringReader = new StringReader("the house id red");
var tokenStream = analyzer.TokenStream(string.Empty, stringReader);
var termAtt = tokenStream.GetAttribute<ITermAttribute>();
while (tokenStream.IncrementToken())
{
Console.WriteLine(termAtt.Term);
}

nDepend - how to modify "JustMyCode" queries using nDepend API?

My goal is to modify "JustMyCode" queries using nDepend API. I am using code like:
var justMyCodeGroup = prj.CodeQueries.CodeQueriesSet.ChildGroups.Single(x => x.Name.Contains("JustMyCode"));
var originalQuery = justMyCodeGroup.ChildQueries
.Single(x => x.QueryString.Contains("Discard generated Types from JustMyCode"));
var changedQuery = originalQuery.Controller.CreateQuery(originalQuery.IsActive,
query,
originalQuery.
DisplayStatInReport,
originalQuery.DisplayListInReport,
originalQuery.DisplaySelectionViewInReport,
originalQuery.IsCriticalRule);
var justMyCodeGroupWithModifiedQuery = justMyCodeGroup.ReplaceQuery(originalQuery, changedQuery);
prj.CodeQueries.CodeQueriesSet.ReplaceGroup(justMyCodeGroup, justMyCodeGroupWithModifiedQuery);
However, when I run the code above I get ArgumentException with message:
newGroup.Controller is different than this groupOfGroups.Controller
Any help ?
Update 1:
I also tried code:
var justMyCodeGroup = prj.CodeQueries.CodeQueriesSet.ChildGroups.Single(x => x.Name.Contains("JustMyCode"));
var originalQuery = justMyCodeGroup.ChildQueries
.Single(x => x.QueryString.Contains("Discard generated Types from JustMyCode"));
var changedQuery = originalQuery.Controller.CreateQuery(originalQuery.IsActive,
query,
originalQuery.
DisplayStatInReport,
originalQuery.DisplayListInReport,
originalQuery.DisplaySelectionViewInReport,
originalQuery.IsCriticalRule);
var justMyCodeGroupWithModifiedQuery = justMyCodeGroup.ReplaceQuery(originalQuery, changedQuery);
var newQueries = new List<IQuery>();
foreach (var q in justMyCodeGroup.ChildQueries)
{
if (q.QueryString.Contains("Discard generated Types from JustMyCode"))
{
continue;
}
newQueries.Add(prj.CodeQueries.CodeQueriesSet.Controller.CreateQuery(q.IsActive, q.QueryString,
q.DisplayStatInReport, q.DisplayListInReport, q.DisplaySelectionViewInReport, q.IsCriticalRule));
}
newQueries.Add(prj.CodeQueries.CodeQueriesSet.Controller.CreateQuery(originalQuery.IsActive, query, originalQuery.DisplayStatInReport, originalQuery.DisplayListInReport, originalQuery.DisplaySelectionViewInReport, originalQuery.IsCriticalRule));
var newGroup = prj.CodeQueries.CodeQueriesSet.Controller.CreateGroup(justMyCodeGroup.Name,
justMyCodeGroup.IsActive, justMyCodeGroup.ShownInReport, newQueries, new List<IGroup>());
prj.CodeQueries.CodeQueriesSet.RemoveGroup(justMyCodeGroup);
prj.CodeQueries.CodeQueriesSet.AddGroup(newGroup);
Right now, RemoveGroup throws exception:
this group of groups doesn't contain groupToRemove.
Update 2:
And I also wonder, why does this code return false ?
var justMyCodeGroup = prj.CodeQueries.CodeQueriesSet.ChildGroups.Single(x => x.Name.Contains("JustMyCode"));
prj.CodeQueries.CodeQueriesSet.ContainsGroup(justMyCodeGroup)
Refer to the PowerTools source file:
$NDependInstallDir$\NDepend.PowerTools.SourceCode\CQL2CQLinq\CQL2CQLinqPowerTool.cs
This PowerTools convert code queries written with old CQL syntax into code queries written with new CQLinq syntax, hence it loads the queries set from a project, update CQL queries, and then save the new queries set in the project.
The queriesController is gathered this way...
var queriesSet = project.CodeQueries.CodeQueriesSet;
var queriesController = queriesSet.Controller;
... and then used this way to modify the queries set:
queriesController.DoUpdateQueryObject(query, newQuery);

Using DynamicActivityProperty as OutArgument in ActivityBuilder

Greetings,
I'm trying to create a workflow using a ActivityBuilder, and then get the XAML.
This flow use a custom activity (WaitForInput) to handle bookmarks. This class inherits from NativeActivity.
I'm having a hard time finding a way to set 'Result' property of my WaitForInput activity, which expects a OutArgument.
Creating this same workflow by the VS designer, I could associate the boolean property 'MyResult' InOutArgument called 'wrapper'. Like this : [Wrapper.MyResult]
I would do this by code, and according to my research, I have to use DynamicActivityProperty.
The problem is that I don't know how to use my DynamicActivityProperty as OutArgument in this case.
This is an simplified version of the code:
var wrapper = new DynamicActivityProperty
{
Name = "Wrapper",
Type = typeof(InOutArgument<CommunicationWrapper>),
};
var activityBuilder = new ActivityBuilder();
activityBuilder.Properties.Add(wrapper);
var step1 = new FlowStep
{
//here's my problem
Action = new WaitForInput<bool> { BookmarkName = "step1", Result = ??? }
};
var flow = new Flowchart
{
StartNode = step1,
Nodes = { step1 }
};
I have founded a solution to my own problem
Result = new OutArgument<bool>(new VisualBasicReference<bool>
{ ExpressionText = "Wrapper.MyResult" }); }