コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 public string AffiliateFilesPath(int AffID, bool instDir)
 {
     try
     {
         return(WSCommon.GetAffiliateSubFolder(AffID, instDir));
     }
     catch (Exception ex)
     {
         CLog.stLogException(ex);
         return("");
     }
 }
コード例 #4
0
        public bool ExecCommand(int execType, int affiliateID, int waitMillisec)
        {
            bool bRes = true;

            try
            {
                if (execType < 0 || execType > 1)
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, string.Format("Bad execute type: {0}.", execType));
                    return(false);
                }
                if (execType == 0 && affiliateID <= 0)
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, string.Format("Error Skin's ID: {0}.", affiliateID));
                    return(false);
                }

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow  = true;
                startInfo.UseShellExecute = false;

                if (!SetStartupInfo(execType, affiliateID, ref startInfo) && execType != 1)
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, string.Format("Error create startup parameters. Execute type: {0}.", execType));
                    return(false);
                }
                switch (execType)
                {
                case 0:
                    bRes = WSCommon.RunCommand(ref startInfo, waitMillisec, this);
                    break;

                case 1:
                    Affiliate aff = new Affiliate(waitMillisec, affiliateID);
                    bRes = aff.UpdateSkin();
                    aff.Dispose();
                    break;

                default:
                    bRes = false;
                    break;
                }
            }
            catch (Exception ex)
            {
                CLog.stLogException(new Exception("ExecCommand:", ex));
                bRes = false;
            }
            return(bRes);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        public int UpdateAvatarData(int UserID, string file, string size)
        {
            CSQL oDB = null;

            try
            {
                string cnString = CConfig.stGetConfigValue("DatabaseConnectionString", false);
                oDB = new CSQL(cnString);
                DataRow dt = oDB.GetFirstRow("admGetUserLoginName", CommandType.StoredProcedure,
                                             CSQL.GetArrayListParameters(new object [] { "@id", UserID }));
                if (dt == null)
                {
                    return(-1);
                }
                string lName = dt[0].ToString();
                string mPath = CConfig.stGetConfigValue("AvatarUploadURL", false);
                if (mPath == String.Empty)
                {
                    return(-2);
                }
                mPath += lName;               //+"/"+file;
                int ret = oDB.ExecuteNonQueryWithReturnID("admSaveAvatar", CommandType.StoredProcedure,
                                                          CSQL.GetArrayListParameters(new object [] { "@UserID", UserID, "@Path", mPath, "@File", file, "@Size", size }));
                mPath  = GetDestinationPath("");
                mPath += "\\Avatars";
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow   = true;
                startInfo.UseShellExecute  = false;
                startInfo.WorkingDirectory = mPath;
                startInfo.FileName         = mPath + "\\" + CConfig.stGetConfigValue("FileSecurityBat", false);
                startInfo.Arguments        = string.Format("{0} {1}", mPath, mPath + "\\" + lName);
                bool bRes = WSCommon.RunCommand(ref startInfo, 60000, this);
                return(bRes?ret:-100);
            }
            catch (Exception ex)
            {
                CLog.stLogException(ex);
                return(-100);
            }
            finally
            {
                if (oDB != null)
                {
                    oDB.CloseConnection(true);
                }
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        public string StartPostFile(string fileName)
        {
            string fName = "";

            try
            {
                fName = WSCommon.GetTempFilePath(Path.GetFileName(fileName));
                if (CIO.FileExists(fName))
                {
                    CIO.blRemoveFile(fName);
                }
                return(fName);
            }
            catch (Exception ex)
            {
                CLog.stLogException(new Exception("StartPostFile : ", ex));
                return("");
            }
        }
コード例 #9
0
        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);
            }
        }