How to fix the issue of output file not appearing, after having launched a run configuration? - optimization

I work on CVRP in combinatorial optimization, where the goal is to compare several models on several instances, using the OPL language. For this to e done, I first wrote and tested the said models; then I wrote an main flow control supposed to run each instance for a 2 hours duration.
My problem is that after 2 hours, and this for each model, the output file appears for some instances, containing the desired information; but for other instances, the output files do not appear, as if these instances do not exist. This problem persists even when you launch one or more of these instances in isolation.
below is the main flow control code, where BPF designates the name of the .mod file, which is simply modified in the code, when one wishes to switch to another model.
{string} datFiles=...;
main {
var source = new IloOplModelSource("BPF.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
cplex.tilim=2*60*60;
cplex.threads=1;
for(var datFile in thisOplModel.datFiles)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataSource(datFile);
opl.addDataSource(data2);
opl.generate();
var o=new IloOplOutputFile("BPF "+datFile+".txt");
if (cplex.solve()) {
if(cplex.getCplexStatus()==11){
o.writeln("instance : " + datFile
+" / opt = "
+ " / UB = " + cplex.getObjValue()
+ " / LB = " + cplex.getBestObjValue()
+" / time = " + " - "
+" / Gap = "+cplex.getMIPRelativeGap()*100+"%");
}
else {
o.writeln("instance : " + datFile
+ " / opt = " + cplex.getObjValue()
+ " / UB = " + cplex.getBestObjValue()+"*"
+" / time = " + cplex.getSolvedTime()
+ " / Gap : -");
}
o.close();
}
opl.end();
}
}

Related

RDLC report Index was outside the bounds of the array asp net core

I got Index was outside the bounds of the array error when use debug mode in asp net core mvc, but its ok when run in non-debug mode (Shift+F5).
Here details of error description :
An unhandled exception occurred while processing the request.
IndexOutOfRangeException: Index was outside the bounds of the array.
AspNetCore.ReportingServices.RdlExpressions.ExpressionHostObjectModel.RemoteArrayWrapper.get_Item(int
index)
ReportProcessingException: An unexpected error occurred in Report
Processing. Index was outside the bounds of the array.
AspNetCore.ReportingServices.ReportProcessing.Execution.RenderReport.Execute(IRenderingExtension
newRenderer)
LocalProcessingException: An error occurred during local report
processing.;An unexpected error occurred in Report Processing. Index
was outside the bounds of the array.
AspNetCore.Reporting.InternalLocalReport.InternalRender(string format,
bool allowInternalRenderers, string deviceInfo, PageCountMode
pageCountMode, CreateAndRegisterStream createStreamCallback, out
Warning[] warnings)
Here my export to pdf code :
int extension = 1;
var path = $"{this._webHostEnvironment.WebRootPath}\\Report\\RptDO2.rdlc";
Dictionary<string, string> parameters = new Dictionary<string, string>();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Encoding.GetEncoding("windows-1252");
parameters.Add("txtto", inv.Quotation.CustomerContact.Customer.CompanyName);
parameters.Add("txtaddress_detail", inv.Quotation.CustomerContact.Customer.Address1 + "\r\n"
+ inv.Quotation.CustomerContact.Customer.Address2 + "- "
+ inv.Quotation.CustomerContact.Customer.City + "- "
+ inv.Quotation.CustomerContact.Customer.State + " ("
+ inv.Quotation.CustomerContact.Customer.Zip + ")\r\n"
+ "Phone : " + inv.Quotation.CustomerContact.Customer.PhoneNumber
+ ", Email : " + inv.Quotation.CustomerContact.Customer.Email);
parameters.Add("txtdo_no", inv.Id.Replace("INV", "DO"));
parameters.Add("txtdate", inv.Quotation.CreatedAt.ToShortDateString());
parameters.Add("txtrefnum", inv.QuotationId);
parameters.Add("txtfrom", us.FirstName + " " + us.LastName);
parameters.Add("txtUP", TextUp);
parameters.Add("kop_nama", c.CpName);
parameters.Add("kop_alamat", c.CpStreetAddress);
parameters.Add("kop_alamat2", c.CpCity + " " + c.CpState + " (" + c.CpZip + ")");
parameters.Add("kop_contact", c.CpPhone);
parameters.Add("kop_email", c.CpEmail);
parameters.Add("kop_logo", Convert.ToBase64String(c.CpFoto));
parameters.Add("txtjabatan", us.Designation);
parameters.Add("txtPrintedBy", lgnuser.FirstName + " " + lgnuser.LastName);
List<vwQuotationDetail> vwQuotationDetails = new List<vwQuotationDetail>();
foreach (TblquotationDetail quos in inv.Quotation.TblquotationDetail.OrderBy(o => o.Id))
{
vwQuotationDetail quotationDetail = new vwQuotationDetail
{
id = quos.Id,
quotation_id = quos.QuotationId,
order_number = quos.OrderNumber,
product_name = quos.Product.ProductName,
product_id = quos.ProductId,
product_comments = string.IsNullOrEmpty(quos.ProductComments) ? "" : quos.ProductComments,
quantity = quos.Quantity,
unit_price = quos.UnitPrice,
unit_name = quos.Product.Unit.UnitName,
sub_total = quos.SubTotal,
product_desc = quos.Product.ProductDesc,
category_name = quos.Product.Category.CategoryName
};
vwQuotationDetails.Add(quotationDetail);
}
LocalReport localReport = new LocalReport(path);
localReport.AddDataSource("dsDO", vwQuotationDetails.ToArray());
//var result = localReport.Execute(RenderType.Pdf, extension, parameters, mimtype);
var result = localReport.Execute(RenderType.Pdf, extension, parameters);
return File(result.MainStream, "application/pdf");
Any suggestion will appreciated, thanks in advance.
Just Dont Pass extension as 1 in:
var result = localReport.Execute(RenderType.Pdf, extension, parameters);
The Solution is:
int ext = (int)(DateTime.Now.Ticks >> 10);
var result = localReport.Execute(RenderType.Pdf, ext, param);
In other words, Extension should not be same for every report.

Acrobat DC preflight processes non-PDF files

I want to process and verify that PDFs within a folder are valid PDF/A files. The problem is that I need to process a folder with piles of files including word and excel among others that preflight converts to PDFs, processes, and then hangs for user input to discard the temperary file. There are some hundred files, so waiting for user input isn't doable.
Perhaps I'm not using the correct phrases when I search, but I can't find out how to force Adobe Acrobat DC to only process PDF files. I've found that in Acrobat X you can specify source files https://www.evermap.com/ActionWizardX.asp, but I've not found an equivalent in DC.
Is there a way to force an action to only process PDF files?
Edit:
Following #Joel Geraci's suggestion and finding this post, I've created the following script that runs in an action. At this point, It seems to run the profile, but I don't know if it actually modifies the document, since the call to this.closeDoc() doesn't prompt to save the document, and the resulting document doesn't seem to be saved as a PDF/A file.
/* Convert PDF/A-3a */
try
{
if(this.path.split('.').pop() === 'pdf')
{
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile);
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
this.closeDoc();
}
}
}
catch(theError)
{
$error = theError;
this.closeDoc( {bNoSave : true} );
}
Edit 2:
I ended up settling on using the saveAs function. I'm not sure how to export the XML data to a file, but this seems to be sufficient.
/* Convert PDF/A-3a */
try
{
if(this.path.split('.').pop() === 'pdf')
{
var oThermometer = app.thermometer;
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile, false, oThermometer );
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
if(myPreflightResult.numErrors > 0) {
var cXMLData = myPreflightResult.report(oThermometer);
console.println(cXMLData);
}
this.saveAs(path,"com.callas.preflight.pdfa");
}
}
}
catch(theError)
{
$error = theError;
this.closeDoc( {bNoSave : true} );
}
Edit 3:
So the problem is that non-PDF files are converted and read before my JavaScript is executed, which means that the this.path.split('.').pop() === 'pdf' doesn't actually filter out anything. I found that the requiresFullSave property of the Doc class specifies whether the document is a temp file or not. I have, however, found that I am still asked if I want to save the temp file, which doesn't help.
Edit 4
Calling Doc.closeDoc(true) on a temporary file causes Acrobat to crash and there doesn't seem to be another way to close a document without saving. I've found there is no clear way (that I've found) to close a temp document without prompting the user to save and have resorted to deleting all non-PDF files.
Final script:
/* Convert PDF/A-3a */
try
{
console.println(path + " is temp: " + requiresFullSave);
if(!requiresFullSave)
{
var oThermometer = app.thermometer;
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile, false, oThermometer );
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
if(myPreflightResult.numErrors > 0) {
var cXMLData = myPreflightResult.report(oThermometer);
console.println(cXMLData);
}
this.saveAs(path,"com.callas.preflight.pdfa");
}
}
else{
// As noted in the documentation found [here][2]
// Note:If the document is temporary or newly created, setting dirty to false has no effect. That is, the user is still asked to save changes before closing the document. See requiresFullSave.
// this.dirty = false;
// this.closeDoc(true);
}
}
catch(theError)
{
}
Rather than creating an action that runs preflight, try creating an action that runs some JavaScript. The JavaScript would test for the file extension of the file being processed and then execute preflight via JavaScript if it's a PDF, skipping it if not.

LiveCycle dynamic PDF - how to enforce Acrobat version?

I have a dynamic PDF that doesn't display correctly in Firefox, Chrome, or lower versions of Adobe. Is there a way to show blank page with error message when the user opens it with anything less than Acrobat version X?
I tried searching on this site and Googling but couldn't find anything..
Help much appreciated!!
This can be achieved with a PDF cover page but can also be achieved with your own subform combo and a bit of script. Creating a cover page that is hidden only to reveal your form content if a script executes correctly and is inside a full feature XFA form viewer is one way to tackle this.
function detect(){
//Sample platform detection
var viewerType = xfa.host.appType;
var versionNo = xfa.host.version;
var variation = xfa.host.variation;
var plugIns = app.plugIns;
var nplugIns = plugIns.length;
var msg = "";
if((viewerType == "Reader") && (nplugIns > 0)){
msg = "This PDF was opened in Reader " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else if((viewerType == "Exchange") && (nplugIns > 0)){
msg = "This PDF was opened in Acrobat " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else if((viewerType == "Exchange-Pro") && (nplugIns > 0)){
msg = "This PDF was opened in Acrobat Pro " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else{
msg = "This PDF was opened in an unrecognized platform";
}
xfa.host.messageBox(msg); //Throw prompt.
form1.Top.Content.TextField1.rawValue = msg; //Write message to form.
}
Most of the function above relies on xfa.host.appType but some PDF viewers developped using the Adobe Acrobat code base will return valid platform values but will not load any plug-ins which is a way to detect and unsupported platform.

Recorded Skeleton Data

The following is code I have used to try to record skeleton frame data
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame == null)
return;
this.Recorder.Record(skeletonFrame);
}
if the code above is run, what information is recorded?
If I were to save this information to an external file, what would I see?
Would there be coordinate information and a specific timestamp associated with each coordinate information?
Are you looking at recording the X, Y, Z data of the skeleton into a text file? It is generally easier to record the information separately in readable format. If you are looking at doing the aforementioned then this may help:
//save the XYZ of the skeleton data, but also save the XZ of depth data
private void saveCoordinates(Skeleton skeleton, string textFile)
{
StreamWriter coordinatesStream = new StreamWriter(newPath + "\\" + textFile);
foreach (Joint joint in skeleton.Joints)
{
coordinatesStream.WriteLine(joint.JointType + ", " + joint.TrackingState + ", " + joint.Position.X + ", " + joint.Position.Y + ", " + joint.Position.Z);
}
coordinatesStream.Close();
}

Get web methods dynamically for an asmx service

We have number of asmx services. I want to give an user a page with a textbox to input service url like http://abc.win.com/myservice/customerdata.asmx. When user hit "Load" button, dynamically I add all the web methods to the dropdown. I need some pointers:
1. How to dynamically get all the methods?
2. How can I get the SOAP request for the method selected? So that, we can replace the parameter values with actual values?
Appreciate your help.
Kuul13 : You need to modify your webservice URL like http://abc.win.com/myservice/customerdata.asmx?wsdl when user clicks on load button. then you can use we "ServiceDescription" class to get wsdl description and then iterate that to get method names in 'WebMethodInfoCollection' class.
To get SOAP request you need to use SOAPExtension class.This will give you SOAP Request and Response XML.Refere this link for that : http://blog.encoresystems.net/articles/how-to-capture-soap-envelopes-when-consuming-a-web-service.aspx?www.microsoft.com
For dynamically calling webservice look a this V.Good article
http://www.codeproject.com/KB/webservices/webservice_.aspx
Please reply me for any comment.
System.Net.WebClient client = new System.Net.WebClient();
System.IO.Stream stream = client.OpenRead("http://www.webservicex.net/globalweather.asmx?wsdl");
ServiceDescription description = ServiceDescription.Read(stream);
ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
importer.ProtocolName = "Soap12";
importer.AddServiceDescription(description, null, null);
importer.Style = ServiceDescriptionImportStyle.Client;
importer.CodeGenerationOptions = System.Xml.Serialization.CodeGenerationOptions.GenerateProperties;
CodeNamespace nmspace = new CodeNamespace();
CodeCompileUnit unit1 = new CodeCompileUnit();
unit1.Namespaces.Add(nmspace);
ServiceDescriptionImportWarnings warning = importer.Import(nmspace, unit1);
if (warning == 0)
{
CodeDomProvider provider1 = CodeDomProvider.CreateProvider("CSharp");
string[] assemblyReferences = new string[2] { "System.Web.Services.dll", "System.Xml.dll" };
CompilerParameters parms = new CompilerParameters(assemblyReferences);
CompilerResults results = provider1.CompileAssemblyFromDom(parms, unit1);
object[] args = new object[1];
args[0] = "India";
object wsvcClass = results.CompiledAssembly.CreateInstance("GlobalWeather");
MethodInfo mi = wsvcClass.GetType().GetMethod("GetCitiesByCountry");
RegExpForCountryCity(mi.Invoke(wsvcClass, args).ToString());
}
else
{
Console.WriteLine("Warning: " + warning);
}
void RegExpForCountryCity(string strHTML)
{
Regex qariRegex = new Regex(#"<Table>\s*<Country>(?<Country>[\s\S]*?)</Country>\s*<City>(?<City>[\s\S]*?)</City>\s*</Table>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
MatchCollection mc = qariRegex.Matches(strHTML);
string strCountryCity = "";
for (int i = 0; i < mc.Count; i++)
{
if (string.IsNullOrEmpty(strCountryCity))
strCountryCity = "Country: " + "<b>" + mc[i].Groups["Country"].Value + "</b>" + " " + "City: " + "<b>" + mc[i].Groups["City"].Value + "</b>" + "</br>";
else
strCountryCity += "</br>" + "Country: " + "<b>" + mc[i].Groups["Country"].Value + "</b>" + " " + "City: " + "<b>" + mc[i].Groups["City"].Value + "</b>" + "</br>";
}
Response.Write(strCountryCity);
}