I'm having a couple of issues with InstallScript that I can not seem to figure out. The main one is that I need to add the following to the machine.config file:
<system.transactions>
<machineSettings maxTimeout="02:00:00" />
</system.transactions>
but it is adding it as such:
<system.transactions>
<machineSettings>
<maxTimeout>"02:00:00"</maxTimeout>
</machineSettings>
</system.transactions>
Here is the code I'm using to update the file (the messages boxes are for debugging purposes).
function STRING GetMachineConfigPath(hMSI)
STRING strRetVal;
NUMBER nSize, nType;
begin
nSize = MAX_PATH - 1;
MsiGetProperty(ISMSI_HANDLE, "MACHINECONFIGPATH", strRetVal, nSize);
return strRetVal;
end;
function SaveMachineConfigSettings(hMSI)
OBJECT oDoc; // XML Document object
OBJECT oNode; // A node in the XML DOM tree
OBJECT CurrParent; // Current parent node
STRING szFilename;
BOOL successfulLoad;
begin
szFilename = GetMachineConfigPath(hMSI) + "config\\machine.config";
if Is(FILE_EXISTS, szFilename) = FALSE then
MessageBox("Could not find machine.config file.", 0);
return -1;
endif;
set oDoc = CreateObject("Msxml2.DOMDocument");
if (IsObject(oDoc) = FALSE) then
MessageBox("Could not open machine.config file.", 0);
return -1;
endif;
oDoc.Async = FALSE;
oDoc.setProperty("SelectionLanguage", "XPath");
successfulLoad = oDoc.load(szFilename);
MessageBox("File loaded successfully.", 0);
if (successfulLoad = FALSE) then
MessageBox("File did not load successfully.", 0);
return -1;
endif;
set CurrParent = oDoc.documentElement;
set oNode = AddSetting(oDoc, CurrParent, "system.transactions", "");
set CurrParent = oNode;
set oNode = AddSetting(oDoc, CurrParent, "machineSettings", "");
set CurrParent = oNode;
set oNode = AddSetting(oDoc, CurrParent, "maxTimeout", '"02:00:00"');
// Write the XML document to a file.
oDoc.save(szFilename);
MessageBox("File updated successfully.", 0);
set oNode = NOTHING;
set oDoc = NOTHING;
return 0;
end;
function OBJECT AddSetting(oDoc, oParent, szNodeName, szValue)
OBJECT oNode;
begin
// Add a carriage return & line feed to make the output easier to read.
set oNode = oDoc.createTextNode("\n");
oParent.appendChild(oNode);
// Create the new setting node and value.
set oNode = oDoc.createElement(szNodeName);
oNode.text = szValue;
oParent.appendChild(oNode);
MessageBox("Node created successfully.", 0);
return oNode;
end;
Any help you could provide is really appreciated!
I ended up creating a C# console application to modify the file and then running that EXE from the InstallShield installation. This gave me a lot more flexibility and control over the modifying of the file to avoid causing issues.
Related
the file is xlsx and the column format is date MM-DD-YYYY
I have tried several different ways to determine if the value is a date.
PHPExcel_Shared_Date::isDateTime just is not working and do not know why. The data is being save in database and is showing the numbers as such:
41137
41618
42206
42076
41137
42206
41137
41988
my code:
$inputFileType = PHPExcel_IOFactory::identify($fullFilePath);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(false);
$objPHPExcel = $objReader->load($fullFilePath);
$objPHPExcel->setActiveSheetIndex(0);
$worksheetIndex = 1;
$worksheetName = '';
$actualRows = 0;
foreach($objPHPExcel->getWorksheetIterator() as $worksheet)
{
$lineNumber = 1;
$worksheetName = $worksheet->getTitle();
$columnSum = array();
foreach($worksheet->getRowIterator() as $row)
{
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(true); // Loop all cells, even if it is not set = true else set to false
$columnNumber = 1;
foreach($cellIterator as $cell)
{
$dataValue = $cell->getCalculatedValue();
//$dataValue = $cell->getFormattedValue();
if(!empty($dataValue))
{
if(PHPExcel_Shared_Date::isDateTime($cell))
{
$dataValue = date('Y-m-d H', PHPExcel_Shared_Date::ExcelToPHP($dataValue));
}
else
{
// do something
}
}
}
}
}
Analysing the file, there's a few problems.... it doesn't validate cleanly under the Microsoft's Open XML SDK 2.0 productivity tool for MS Office.
Initial problem (which should trigger a loader error in PHPExcel) is the SheetView Zoom Scale, which should be a minimum value of 1. This problem can by "bypassed" by editing Classes/PHPExcel/Worksheet/SheetView.php and modifying the setZoomScaleNormal() method to avoid throwing the exception if the supplied argument value is out of range.
public function setZoomScaleNormal($pValue = 100)
{
if (($pValue >= 1) || is_null($pValue)) {
$this->zoomScaleNormal = $pValue;
// } else {
// throw new PHPExcel_Exception("Scale must be greater than or equal to 1.");
}
return $this;
}
The second problem is that custom number formats are defined with ids in the range 100-118, but all format ids below 164 are documented as reserved for Microsoft use. Excel itself is obviously more forgiving about breaking its documented rules.
You can resolved this by hacking the Classes/PHPExcel/Reader/Excel2007.php file and modifying the load() method, around line 512, by commenting out the check that tells PHPExcel to use the built-in number formats:
// if ((int)$xf["numFmtId"] < 164) {
// $numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
// }
or
if ((int)$xf["numFmtId"] < 164 &&
PHPExcel_Style_NumberFormat::builtInFormatCodeIndex((int)$xf["numFmtId"]) !== false) {
$numFmt = PHPExcel_Style_NumberFormat::builtInFormatCode((int)$xf["numFmtId"]);
}
There are also issues with font size definitions, but these won't prevent the file from loading
I'd like to insert all Labels from a labelModuleId in an AX2009 table.
I have this job, that does nearly everything I need. But I have to enter the max Id (toLabel = 1000):
static void OcShowAllLabel(Args _args)
{
xInfo xinfo;
LanguageId currentLanguageId;
LabelModuleId labelModuleId = 'OCM'; // hier evt eine Eingabe durch Benutzer zur Auswahl
LabelIdNum frLabel;
LabelIdNum toLabel = 1000;
LabelId labelId;
OcShowAllLabels_RS tab;
Label blub = new Label();
str label;
;
xInfo = new xInfo();
currentLanguageId = xInfo.language();
delete_from tab
where tab.LanguageId == currentLanguageId
&& tab.LabelModuleId == labelModuleId;
for (frLabel = 1; frLabel <= toLabel; frLabel++)
{
labelId = strfmt('#%1%2', labelModuleId, frLabel);
label = SysLabel::labelId2String(labelId, currentLanguageId);
if (labelId != label)
{
tab.initValue();
tab.LabelId = labelId;
tab.Label = label;
tab.LanguageId = currentLanguageId;
tab.LabelModuleId = labelModuleId;
tab.insert();
}
}
Info('done');
}
If this is a one-time job, you can just stop the AOS and open the label file in notepad. It's in your application folder called axXXXen-us.ald, where XXX is your label file name and en-us is your language.
Look at classes\Tutorial_ThreadWork\doTheWork to see where they use a while(sLabel) instead of a for loop like you have.
container doTheWork(Thread t,LabelType searchFor)
{
container retVal;
SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage());
str slabel;
;
slabel = sysLabel.searchFirst(searchFor);
while (slabel)
{
retVal += sLabel;
slabel = sysLabel.searchNext();
}
return retVal;
}
Since the label file is a text file, it would make sense that you can't just select the last one, but you have to iterate through the file. AX caches the labels however, but I don't believe you can just readily access the label cache as far as I know.
Lastly, hopefully you won't try this, but don't try to just read in the label text file, because AX sometimes has labels that it hasn't flushed to that file from the cache. I think Label::Flush(...) will flush them, but I'm not sure.
Here is another option I suppose. You can insert a label to get the next label number and then just immediately delete it:
static void Job32(Args _args)
{
SysLabel sysLabel = new SysLabel(LanguageTable::defaultLanguage());
SysLabelEdit sysLabelEdit = new SysLabeLEdit();
LabelId labelid;
;
labelId = syslabel.insert('alextest', '', 'OCM');
info(strfmt("%1", labelId));
sysLabelEdit.labelDelete(labelId, false);
}
It does seem to consume the number from the number sequence though. You could just do a Label::Flush(...) and then check the text file via code. Look at Classes\SysLabel* to see some of how the system deals with labels. It doesn't look very simple by any means.
Here is another option that might work for you. This will identify missing labels too. Change 'en-us' to your language. This is a "dirty" alternative I suppose. You might need to add something to say "if we find 5 labels in a row where they're like '#OCM'".
for (i=1; i<999; i++)
{
labelId = strfmt("#%1%2", 'OCM', i);
s = SysLabel::labelId2String(labelId, 'en-us');
if (s like '#OCM*')
{
info (strfmt("%1: Last is %2", i, s));
break;
}
info(strfmt("%1: %2", i, s));
}
i have written the code of jsp,servlet for uploading the Doc file in database.
here is my code,but i am getting the error like this==java.io.FileNotFoundException: insert into resume(resume) values(?) (The filename, directory name, or volume label syntax is incorrect) .please help me how to remove this error???
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
con=DriverManager.getConnection("jdbc:jtds:sqlserver://W2K8SERVER:1433/career","sa","Alpha#123" );
pst = con.prepareStatement("select * from data1 where email=? and password=?");
pst = con.prepareStatement
("insert into resume(resume) "+ "values(?)");
File re = new File("" + pst);
fis = new FileInputStream(re);
pst.setBinaryStream(3, (InputStream)fis, (int)(re.length()));
pst.setString (1,upload);
//rs = pst.executeQuery();
while (rs.next())
cnt ++;
int s = pst.executeUpdate();
if(s>0) {
System.out.println("Uploaded successfully !");
}
else {
System.out.println("unsucessfull to upload image.");
}
rs.close();
pst.close();
con.close();
}
It is because insert into resume(resume) values(?) is probably not the name of a file on your disk.
pst = con.prepareStatement ("insert into resume(resume) "+ "values(?)");
File re = new File("" + pst);
You are creating a File from ""+ pst, which is the result of toString() being called on a PreparedStatement. Did you put in the "" to get rid of the informative compilation error?
You probably have the real filename in some other variable.
File re = new File(theRealFileNameVariable);
File re = new File("" + pst);
please make sure the "pst" value is a valid file path, apparently the value "insert into resume(resume) values(?)" is not a valid file path
The java.io.File class has four (4) constructors
File(File parent, String child)
File(String pathname)
File(String parent, String child)
File(URI uri)
In your case you are trying to pass to the constructor an object or type java.sql.PreparedStatement that you trying to cast into a String. I don't see how (even if you arrived to convert pst into a string) pst will reference a path to a file. Please go back and read a little bit about java.io.
.
My requirement is if the user click on update data with out changing any field on the form i would like to show as No changes made and if any changes i would like to update the data
I have written a Routine for updating data as follows
CREATE DEFINER=`root`#`%` PROCEDURE `uspEmployeeFaxDetailsUpdate`(_EmpID int(11),
_FaxNumberTypeID varchar(45),
_FaxNumber decimal(10,0),
_EndDate datetime)
BEGIN
declare p_ecount int;
set p_ecount= (select count(1) from tblemployeefaxdetails where
FaxNumberTypeID=_FaxNumberTypeID and
FaxNumber=_FaxNumber and
EndDate='9999-12-31');
if p_ecount=0 then
begin
update tblemployeefaxdetails
set
EndDate=_EndDate WHERE EmpID=_EmpID and EndDate="9999-12-31";
insert into tblemployeefaxdetails(EmpID,FaxNumberTypeID,FaxNumber,StartDate,EndDate) values
(_EmpID,_FaxNumberTypeID,_FaxNumber,curdate(),'9999-12-31');
end;
end if;
END
I am getting some time my required message but some time it is showing the update message
This is my code on update
oEmployeePersonalData.EmpID = EmpID;
oEmployeePersonalData.FaxNumberTypeID = ddlFaxTypeID.SelectedItem.Text;
oEmployeePersonalData.FaxNumber = Convert.ToInt64(txtFaxNumber.Text);
oEmployeePersonalData.EndDate = DateTime.Today.AddDays(-1);
if (oEmployeePersonalData.FaxDetailUpdate())
{
oMsg.Message = "Updated Sucessfully";
Label m_locallblMessage;
oMsg.AlertMessageBox(out m_locallblMessage);
Page.Controls.Add(m_locallblMessage);
}
else
{
oMsg.Message = "Not Sucessfully";
Label m_locallblMessage;
oMsg.AlertMessageBox(out m_locallblMessage);
Page.Controls.Add(m_locallblMessage);
}
Updated code
public bool FaxDetailUpdate()
{
m_bFlag = false;
try
{
m_oCmd = new MySqlCommand(StoredProcNames.tblEmployeeFaxdetails_uspEmployeeFaxdetailsUpdate, m_oConn);
m_oCmd.CommandType = CommandType.StoredProcedure;
m_oCmd.Parameters.AddWithValue("_EmpID", EmpID);
m_oCmd.Parameters.AddWithValue("_FaxNumberTypeID", FaxNumberTypeID);
m_oCmd.Parameters.AddWithValue("_FaxNumber", FaxNumber);
m_oCmd.Parameters.AddWithValue("_EndDate", EndDate);
if (m_oConn.State == ConnectionState.Closed)
{
m_oConn.Open();
}
if ((m_oCmd.ExecuteNonQuery()) > 0)
{
this.m_bFlag = true;
}
}
catch (MySqlException oSqlEx)
{
m_sbErrMsg.Length = 0;
m_sbErrMsg = Utilities.SqlErrorMessage(oSqlEx);
//DB write the Error Log
m_oErrlog.Add(m_sbErrMsg.ToString(), DateTime.Now);
}
catch (Exception oEx)
{
m_sbErrMsg = Utilities.ErrorMessage(oEx);
//DB write the Error Log
m_oErrlog.Add(m_sbErrMsg.ToString(), DateTime.Now);
}
finally
{
m_oConn.Close();
}
return this.m_bFlag;
}
I am not getting any error but i would like to be done as per i said
Can any one tell what changes i have to made in this
I do not really understand the routine, what the magic date 9999-12-31 represents, and why a new record is inserted every time, instead of updating the old one.
What you can do, is have the routine return a indicator if the row was changed or not, returning the value of p_ecount through a OUT parameter.
For more information on how to use OUT parameters using the .net MySql client see http://dev.mysql.com/doc/refman/5.0/en/connector-net-programming-stored.html
Note: This question can also be found on the WiX mailing list.
I need to be able to check for the existence of an IIS7 website based on the website's description. If the website does not exist I need to cancel the installation. If the website exists I want to continue the installation. I also need to be able to save the site id of the website so that I may use it during an uninstall.
For debugging purposes I have hard coded the website's description. I do not see any indication that a check for the website is being made within the MSI log file. This is the code I am using:
<iis:WebSite Id="IISWEBSITE" Description="Default Web Site" SiteId="*">
<iis:WebAddress Id="IisWebAddress" Port="1"/>
</iis:WebSite>
<Condition Message="Website [IISWEBSITE] not found.">
<![CDATA[IISWEBSITE]]>
</Condition>
Using ORCA I can see that IIsWebAddress and IIsWebSite tables are added to the MSI. The values are:
IIsWebsite
WEB: IISWEBSITE
Description: Default Web Site
KeyAddress: IisWebAddress
Id: -1
IIsWebAddress
Address: IisWebAddress
Web_: IISWEBSITE
Port: 1
Secure: 0
With the above code, the installation is halted with the error message "Website not found". It appears that IISWEBSITE is never getting set. Though, I know that "Default Web Site" exists. I know that I must be missing something, but what?
How can I perform a simple check for the existence of a website in IIS 7?
I too had same problem.
I wrote a custom action to check the version of IIS from registry.
On the basis of registry value create virtual directory
I wrote a custom action in Javascript to do this. If you are assuming IIS7, then you can use the appcmd.exe tool, and just invoke it from within Javascript to get the list of sites. In theory, it's pretty simple to do. But in practice, there's a bunch of hoops you need to jump through.
Here's what I came up with:
function RunAppCmd(command, deleteOutput) {
var shell = new ActiveXObject("WScript.Shell"),
fso = new ActiveXObject("Scripting.FileSystemObject"),
tmpdir = fso.GetSpecialFolder(SpecialFolders.TemporaryFolder),
tmpFileName = fso.BuildPath(tmpdir, fso.GetTempName()),
windir = fso.GetSpecialFolder(SpecialFolders.WindowsFolder),
appcmd = fso.BuildPath(windir,"system32\\inetsrv\\appcmd.exe") + " " + command,
rc;
deleteOutput = deleteOutput || false;
LogMessage("shell.Run("+appcmd+")");
// use cmd.exe to redirect the output
rc = shell.Run("%comspec% /c " + appcmd + "> " + tmpFileName, WindowStyle.Hidden, true);
LogMessage("shell.Run rc = " + rc);
if (deleteOutput) {
fso.DeleteFile(tmpFileName);
}
return {
rc : rc,
outputfile : (deleteOutput) ? null : tmpFileName
};
}
// GetWebSites_Appcmd()
//
// Gets website info using Appcmd.exe, only on IIS7+ .
//
// The return value is an array of JS objects, one per site.
//
function GetWebSites_Appcmd() {
var r, fso, textStream, sites, oneLine, record,
ParseOneLine = function(oneLine) {
// split the string: capture quoted strings, or a string surrounded
// by parens, or lastly, tokens separated by spaces,
var tokens = oneLine.match(/"[^"]+"|\(.+\)|[^ ]+/g),
// split the 3rd string: it is a set of properties separated by colons
props = tokens[2].slice(1,-1),
t2 = props.match(/\w+:.+?(?=,\w+:|$)/g),
bindingsString = t2[1],
ix1 = bindingsString.indexOf(':'),
t3 = bindingsString.substring(ix1+1).split(','),
L1 = t3.length,
bindings = {}, i, split, obj, p2;
for (i=0; i<L1; i++) {
split = t3[i].split('/');
obj = {};
if (split[0] == "net.tcp") {
p2 = split[1].split(':');
obj.port = p2[0];
}
else if (split[0] == "net.pipe") {
p2 = split[1].split(':');
obj.other = p2[0];
}
else if (split[0] == "http") {
p2 = split[1].split(':');
obj.ip = p2[0];
if (p2[1]) {
obj.port = p2[1];
}
obj.hostname = "";
}
else {
p2 = split[1].split(':');
obj.hostname = p2[0];
if (p2[1]) {
obj.port = p2[1];
}
}
bindings[split[0]] = obj;
}
// return the object describing the website
return {
id : t2[0].split(':')[1],
name : "W3SVC/" + t2[0].split(':')[1],
description : tokens[1].slice(1,-1),
bindings : bindings,
state : t2[2].split(':')[1] // started or not
};
};
LogMessage("GetWebSites_Appcmd() ENTER");
r = RunAppCmd("list sites");
if (r.rc !== 0) {
// 0x80004005 == E_FAIL
throw new Exception("ApplicationException", "exec appcmd.exe returned nonzero rc ("+r.rc+")", 0x80004005);
}
fso = new ActiveXObject("Scripting.FileSystemObject");
textStream = fso.OpenTextFile(r.outputfile, OpenMode.ForReading);
sites = [];
// Read from the file and parse the results.
while (!textStream.AtEndOfStream) {
oneLine = textStream.ReadLine();
record = ParseOneLine(oneLine);
LogMessage(" site: " + record.name);
sites.push(record);
}
textStream.Close();
fso.DeleteFile(r.outputfile);
LogMessage("GetWebSites_Appcmd() EXIT");
return sites;
}