示例#1
0
        public string GetShowVesion()
        {
            const string star = "#";
            string       aua  = UserAgentAppArg;
            const string EQ   = "=";

            string text =
                PAppGuid + EQ + AppId + Environment.NewLine
                + PAppEnc + EQ + AppEnc + Environment.NewLine
                + PAppSsl + EQ + AppSsl + Environment.NewLine
                + PAppTitle + EQ + appName + Environment.NewLine
                + PAppUrl + EQ + this.AppUrl + Environment.NewLine
                + PAppUrl2 + EQ + this.AppUrl2 + Environment.NewLine
                + PSRemDisk + EQ + (checkRemovableDiskType ? "1" : "0") + Environment.NewLine
                + PSReportFileSize + EQ + (reportFileSize ? "1" : "0") + Environment.NewLine
                + PSDHours + EQ + ((long)deltaCheckHours).ToString() + Environment.NewLine
                + PSDHoursRem + EQ + ((long)deltaCheckHoursRemovable).ToString() + Environment.NewLine
                + PSCheckRemoteDate + EQ + (this.checkRemoteFileDate ? "1" : "0") + Environment.NewLine
                + PSCmdPrefix + EQ + this.commandPrefix + Environment.NewLine
                + PSUASuffix + EQ + this.userAgentSuffix + Environment.NewLine
                + PSUASuffixArg + EQ + userAgentSuffixAppArg + Environment.NewLine
                + PSStarterPathArg + EQ + this.starterPathAppArg + Environment.NewLine
                + PSUpdateBeforeStart + EQ + (this.updateBeforeStart ? "1" : "0") + Environment.NewLine
                + PSDownDelay + EQ + this.downloadBufferDelayMls + Environment.NewLine
                + PAppLicW + EQ + licenseWinW.ToString() + Environment.NewLine
                + PAppLicH + EQ + licenseWinH.ToString() + Environment.NewLine;

            string[] lic = this.license.Split('\n');
            for (int i = 0; i < lic.Length; i++)
            {
                string l = lic[i].Trim('\n', '\r');
                if (string.IsNullOrEmpty(l))
                {
                    continue;
                }
                text += PAppLicense + EQ + l + Environment.NewLine;
            }

            text += Environment.NewLine
                    + Str.Def.ToString()
                    + Environment.NewLine
                    + "# internal" + Environment.NewLine
                    + star + starter + "ver: " + Config.WStarterVersion + " " + StarterLastVersion + Environment.NewLine
                    + star + starter + "store.ver: " + Config.WStarterStoreVersion + Environment.NewLine
                    + star + starter + "md5: " + Crc.HashFile(Application.ExecutablePath, true) + Environment.NewLine
                    + star + starter + "useragent" + ": " + this.UserAgent + Environment.NewLine
                    + star + starter + PSUASuffixArg + ":" + (string.IsNullOrEmpty(aua) ? string.Empty : aua) + Environment.NewLine
                    + star + starter + app + "folder: " + this.AppFolder + Environment.NewLine
                    + star + starter + app + "newver: " + (this.NewVersionFileTag ? "1" : "0") + Environment.NewLine
                    + star + starter + "self.newver: " + (IsNewStarterVersion ? "1" : "0") + " " + this.StarterNewVersion + Environment.NewLine
                    + star + starter + "isremovabledisk: " + (this.IsRemovableDiskType ? "1" : "0") + Environment.NewLine
                    + star + starter + "notallowed: " + Utils.NotAllowedCharsStr() + Environment.NewLine
            ;
            return(text);
        }
        public static ArrayList GetNewFiles(ArrayList localFiles, ArrayList remoteFiles, bool checkOnlyPath, bool isTemp)
        {
            if ((remoteFiles == null) || (remoteFiles.Count <= 0))
            {
                return(null);
            }
            if ((localFiles == null) || (localFiles.Count <= 0))
            {
                return(remoteFiles);
            }
            ArrayList newFiles = new ArrayList();

            for (int i = 0; i < remoteFiles.Count; i++)
            {
                RemoteFile rm    = (RemoteFile)remoteFiles[i];
                bool       found = false;
                for (int j = 0; j < localFiles.Count; j++)
                {
                    RemoteFile lc          = (RemoteFile)localFiles[j];
                    bool       sameFile    = false;
                    bool       sameVersion = false;
                    bool       sameName    = lc.IsSamePathFile(rm, ref sameVersion);
                    if (checkOnlyPath)
                    {
                        sameFile = lc.name.Equals(rm.name);
                    }
                    else
                    {
                        sameFile = lc.IsSameFile(rm);
                    }
                    if (sameFile)
                    {
                        if (checkOnlyPath)
                        {
                            found = true;
                        }
                        else
                        {
                            string file   = rm.GetPath(isTemp);
                            bool   exists = File.Exists(file);
                            if (exists)
                            {
                                if (rm.ValidateSize(file))
                                {
                                    if (rm.ShouldCheckCrc)
                                    {
                                        if (Crc.HashFile(file, false).ToLower().Equals(rm.crc))
                                        {
                                            found = true;
                                        }
                                    }
                                    else
                                    {
                                        found = true;
                                    }
                                }
                            }
                            else
                            {
                                // handle partial files
                                string tempFile   = HttpGetter.GetTempFilePath(file);
                                bool   tempExists = File.Exists(tempFile);
                                if (tempExists)
                                {
                                    if (rm.IsSizeValid())
                                    {
                                        if (rm.ValidateSize(tempFile))
                                        {
                                            if (rm.ShouldCheckCrc)
                                            {
                                                if (Crc.HashFile(tempFile, false).ToLower().Equals(rm.crc))
                                                {
                                                    File.Move(tempFile, file);
                                                    found = true;
                                                }
                                                else
                                                {
                                                    Utils.DeleteFile(tempFile);
                                                }
                                            }
                                            else
                                            {
                                                File.Move(tempFile, file);
                                                found = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    }
                    else
                    {
                        if (sameName && !sameVersion)
                        {
                            string file = rm.GetPath(isTemp);
                            Utils.DeleteFile(HttpGetter.GetTempFilePath(file));
                        }
                    }
                }
                if (!found)
                {
                    newFiles.Add(rm);
                }
            }
            return(newFiles);
        }