/// <summary> /// It updates install shields for particular affiliate. /// </summary> public bool CreateSkin(int nScID, int nAffID) { bool bRes = false; try { //Create Directory string directoryPath = WSCommon.GetAffiliatePath(nScID, false); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = true; startInfo.UseShellExecute = false; startInfo.WorkingDirectory = directoryPath; string sDir = WSCommon.GetAffiliatePath(nScID, true); startInfo.FileName = sDir + "\\" + CConfig.stGetConfigValue("FileSkinsBat", false); startInfo.Arguments = string.Format("{0} {1}", sDir, nAffID); //string.Format("{0} {1} {2}", sDir, sDir, nAffID); //Create InstallShield bRes = WSCommon.RunCommand(ref startInfo, m_waitMillisec, this); } catch (Exception oEx) { CLog.stLogException(new Exception("CreateSkin:", oEx)); bRes = false; } return(bRes); }
/// <summary> /// It updates install shields for affiliates. /// </summary> public bool UpdateSkin() { bool ret = true; try { ArrayList ar = new ArrayList(); //1. Create file list xml string xmlString = ""; string filePath = ""; ar.Clear(); ar.Add("@SkinsID"); ar.Add(m_SkinsID); DataTable oDTXML = oDB.GetDataTable(DbGetClientApplicationFileListForXML, CommandType.StoredProcedure, ar); foreach (DataRow bRow in oDTXML.Rows) { xmlString += bRow[0].ToString(); } xmlString = String.Format("<{0}>{1}</{0}>", xmlTopRoot, xmlString); filePath = WSCommon.GetAffiliatePath(m_SkinsID, false); if (!filePath.Trim().EndsWith("\\")) { filePath += "\\"; } filePath += xmlFileName; CIO.WriteToFile(filePath, xmlString); //2. Parse installation code file ParseInstallFile(m_SkinsID); DataTable tbAff = oDB.GetDataTable(DbGetAffiliateList, CommandType.StoredProcedure, new object[] { "@SkinID", m_SkinsID }); foreach (DataRow dr in tbAff.Rows) { //3. Rebuild installation for affiliate if (Convert.ToInt32(dr["StatusID"]) == 4) { int AffID = Convert.ToInt32(dr["id"]); bool bRet = CreateSkin(m_SkinsID, AffID); if (!bRet) { CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, String.Format("Error occured for Skin {0}, AffID {1}<br>", m_SkinsID, AffID)); ret = false; } } } } catch (Exception oEx) { CLog.stLogException(new Exception("UpdateSkin:", oEx)); ret = false; } return(ret); }
/// <summary> /// Parse installation code file. /// </summary> protected void ParseInstallFile(int SkinID) { string installStr = ""; string unInstallStr = ""; string fileListInstallStr = ""; string fileExecutableInstallStr = ""; string fileListUnInstallStr = ""; string fileExecutableUnInstallStr = ""; ArrayList ar = new ArrayList(); ar.Add("@SkinsID"); ar.Add(SkinID); DataTable oDTList = oDB.GetDataTable(DbGetClientApplicationFileList, CommandType.StoredProcedure, ar); foreach (DataRow oRow in oDTList.Rows) { installStr = String.Format("{0} {1}{2}{3}", instCommand, instBeforeFileName, oRow["FileName"].ToString(), instAfterFileName); unInstallStr = String.Format("{0} {1}{2}{3}", unInstCommand, unInstBeforeFileName, oRow["FileName"].ToString(), unInstAfterFileName); if (Convert.ToInt32(oRow["contentTypeID"]) == ContentTypeExecutable) { fileExecutableInstallStr = installStr; fileExecutableUnInstallStr = String.Format("{0} {1}{2}{3}", unInstCommand, unInstBeforeExecutableFileName, oRow["FileName"].ToString(), unInstAfterFileName); } else { fileListInstallStr += installStr; fileListUnInstallStr += unInstallStr; } } //Add xmlFile fileListInstallStr += String.Format("{0} {1}{2}{3}", instCommand, instBeforeFileName, xmlFileName, instAfterFileName); fileListUnInstallStr += String.Format("{0} {1}{2}{3}", unInstCommand, unInstBeforeFileName, xmlFileName, unInstAfterFileName); string templateNsi = CIO.ReadAllFile(WSCommon.GetAffiliatePath(SkinID, true) + "\\" + CConfig.stGetConfigValue("NsiTemplateFile", false)); templateNsi = templateNsi.Replace(fileExecutableInstall, fileExecutableInstallStr); templateNsi = templateNsi.Replace(fileListInstall, fileListInstallStr); templateNsi = templateNsi.Replace(fileExecutableUnInstall, fileExecutableUnInstallStr); templateNsi = templateNsi.Replace(fileListUnInstall, fileListUnInstallStr); CIO.WriteToFile(WSCommon.GetAffiliatePath(SkinID, true) + "\\" + CConfig.stGetConfigValue("NsiFile", false), templateNsi); }
public bool RemoveFile(int affiliateID, string fileName) { string fPath = WSCommon.GetAffiliatePath(affiliateID, false); if (File.Exists(fPath + "\\" + Path.GetFileName(fileName)) == false) { return(true); } try { File.Delete(fPath + "\\" + Path.GetFileName(fileName)); return(true); } catch { return(false); } }
protected bool SetStartupInfo(int execType, int affID, ref ProcessStartInfo startInfo) { try { switch (execType) { case 0: startInfo.FileName = WSCommon.GetAffiliatePath(affID, true) + "\\" + CConfig.stGetConfigValue("FileSecurityBat", false); startInfo.WorkingDirectory = Path.GetDirectoryName(startInfo.FileName); startInfo.Arguments = string.Format("{0} {1}", startInfo.WorkingDirectory, WSCommon.GetAffiliatePath(affID, false)); break; default: return(false); } return(true); } catch (Exception ex) { CLog.stLogException(ex); return(false); } }