Example #1
0
	public static IEnumerable ShowMaintenanceInfo(UIPanelUpdate updatePanel, ProgramUpdate.MaintenanceInfo maintenanceInfo)
	{
		if (maintenanceInfo.status)
		{
			updatePanel.gameObject.SetActive(false);

			//add ui
			UIPanelMaintenanceInfo panel = ECUpdateUIManagerInstance.Value.CreateDialog("ui/prefab/panel_maintenanceinfo").AddComponent<UIPanelMaintenanceInfo>();
			UpdateMsgBoxSleepControl.AddSleepControl(panel.gameObject, 30, (Int32)SleepTimeoutManager.Priority.MessageBox);

			panel.reason_text.text = maintenanceInfo.reason;

			yield return new WaitForSeconds(Single.MaxValue);
		}
	}
Example #2
0
        // Update specific item
        public ProgramUpdate UpdateProgram(ProgramUpdate updatedProgram)
        {
            var p = ds.Programs.Find(updatedProgram.Id);

            if (p == null)
            {
                return(null);
            }
            else
            {
                // For the object fetched from the data store,
                // set its values to those provided
                // (the method ignores missing properties, and navigation properties)
                ds.Entry(p).CurrentValues.SetValues(updatedProgram);
                ds.SaveChanges();
                return(updatedProgram);
            }
        }
Example #3
0
        /// <summary>
        /// Validates the integrity of an update file.
        /// </summary>
        /// <param name="fileName">The full path of the local file to validate.</param>
        /// <param name="update">The upgrade the file is associated with.</param>
        /// <returns>true if the hashes match, false if not.</returns>
        private bool ValidateUpgradeFile(string fileName, ProgramUpdate update)
        {
            bool retval = false;

            if (File.Exists(fileName))
            {
                SHA1Managed   sha1 = new SHA1Managed();
                StringBuilder sb   = new StringBuilder(41);
                byte[]        data = File.ReadAllBytes(fileName);
                byte[]        hash = sha1.ComputeHash(data);

                for (int i = 0; i < hash.Length; i++)
                {
                    sb.Append(hash[i].ToString("X2"));
                }

                retval = sb.ToString().Equals(update.Hash, StringComparison.OrdinalIgnoreCase);
            }

            return(retval);
        }
Example #4
0
        /// <summary>
        /// Initialises a new instance of the <see cref="UpdateInformationDialog"/> class.
        /// </summary>
        /// <param name="update">The update to show information about.</param>
        public UpdateInformationDialog(ProgramUpdate update)
        {
            this.InitializeComponent();

            this.client = new WebClient();
            this.client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.Client_DownloadProgressChanged);
            this.client.DownloadFileCompleted   += new AsyncCompletedEventHandler(this.Client_DownloadFileCompleted);

            this.update = update;

            this.update.ReleaseNotes.ForEach(notes =>
            {
                string section = string.Format(
                    "-- Version {0}, Released {1} --\r\n{2}\r\n\r\n",
                    notes.Version,
                    notes.Date,
                    notes.Summary.Replace("\n", Environment.NewLine));

                this.summaryTextBox.Text += section;
            });

            this.Localise();
        }
Example #5
0
	private IEnumerable PopYYBCoroutineInner(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.NotSuccess;

		StartSaveUpdate();

		foreach (var item in ShowProgressCoroutine(versionParam, updatePanel, result))
			yield return item;
	}
Example #6
0
	public static IEnumerable PopYYBCoroutine(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		Debug.Log("PopYYBCoroutine");

		var self = Instance;
		foreach (var item in self.PopYYBCoroutineInner(versionParam, updatePanel, result))
			yield return item;
		self.CleanupCallbacks();

	}
Example #7
0
	private IEnumerable ShowProgressCoroutine(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("preparing to update");

		//显示下载进度
		Boolean bFailed = false;
		String failMsg = "";

		m_OnDownloadAppStateChangedEvent = (state, errorCode, errorMsg) =>
		{
			if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_FAILED)
			{
				Debug.LogWarning(String.Format("DownloadApp failed, state={0}, errorCode={1}, errorMsg={2}", state, errorCode, errorMsg));
				CleanupCallbacks();

				failMsg = String.Format(GameUpdateManager.Instance.GetString("download error: {0}"), errorMsg);
				bFailed = true;
			}
			else if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_SUCCEED)
			{
				updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("waiting for finish install");
				updatePanel.sub_progress.value = 1.0f;
				updatePanel.sub_progressText.text = "";
			}
		};

		m_OnDownloadAppProgressChangedEvent = (receiveDataLen, totalDataLen) =>
		{
			updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("downloading installer");
			updatePanel.sub_progress.value = (float)receiveDataLen / Math.Max((float)totalDataLen, 1.0f);
			updatePanel.sub_progressText.text = FormatProgressSize(receiveDataLen, totalDataLen);
		};

		m_OnDownloadYYBStateChangedEvent = (url, state, errorCode, errorMsg) =>
		{
			if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_FAILED)
			{
				Debug.LogWarning(String.Format("DownloadYYB failed, state={0}, errorCode={1}, errorMsg={2}", state, errorCode, errorMsg));
				CleanupCallbacks();

				failMsg = String.Format(GameUpdateManager.Instance.GetString("download error: {0}"), errorMsg);
				bFailed = true;
			}
			else if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_SUCCEED)
			{
				updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("waiting for finish install");
				updatePanel.sub_progress.value = 1.0f;
				updatePanel.sub_progressText.text = "";
			}
		};

		m_OnDownloadYYBProgressChangedEvent = (url, receiveDataLen, totalDataLen) =>
		{
			updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("downloading yyb");
			updatePanel.sub_progress.value = (float)receiveDataLen / Math.Max((float)totalDataLen, 1.0f);
			updatePanel.sub_progressText.text = FormatProgressSize(receiveDataLen, totalDataLen);
		};

		while (!bFailed)
			yield return null;

		foreach (var item in UpdateMessageBox.Pop(String.IsNullOrEmpty(failMsg) ? GameUpdateManager.Instance.GetString("update failed") : failMsg, UpdateMessageBox.MessageBoxType.None))
			yield return item;

		yield return new WaitForSeconds(Single.MaxValue);
	}
Example #8
0
	private IEnumerable UpdateCoroutineInner(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.NotSuccess;

		//load string table
		var stringTable = GameUpdateManager.Instance.StringTable;

		//check runtime platform ? Not quite needed

		var checkNeedUpdateResult = new ReturnTuple<Boolean, Int64, String, Int64, Int32, String, Int32>();
		foreach (var item in CheckNeedUpdateCoroutine(10.0f, checkNeedUpdateResult))
			yield return item;

		if (!checkNeedUpdateResult.value_0)
		{
			Debug.LogWarning("CheckNeedUpdate timeout");
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}

		Debug.Log("CheckNeedUpdate success");


		//Boolean hasPatch = false;

		var updateMethod = checkNeedUpdateResult.value_6;
		if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_NoUpdate)
		{
			//判断有更新,但应用宝无更新可下载
			Debug.LogWarning("No Update Available");
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("no update available"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}
		//else if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_Normal)
		//{
		//    hasPatch = false;
		//}
		//else if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_ByPatch)
		//{
		//    hasPatch = true;
		//}
		//else
		//{
		//    Debug.LogWarning("Invalid update method");
		//    foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
		//        yield return item;

		//    yield return new WaitForSeconds(Single.MaxValue);
		//}

		var chooseYYBUpdateStyleResult = new ReturnTuple<UpdateChooseBox.YYBUpdateStyle>();
		foreach (var item in UpdateChooseBox.ChooseYYBUpdateStyle(chooseYYBUpdateStyleResult))
			yield return item;

		if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.InGame)
		{
			//游戏内更新且没用wifi需要提示
			ReturnTuple<Boolean> confirmWirelessDownloadingResult = new ReturnTuple<Boolean>();
			foreach (var item in GameUpdateManager.Instance.ConfirmWirelessDownloading(confirmWirelessDownloadingResult))
				yield return item;

			if (!confirmWirelessDownloadingResult.value_0)
			{
				result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.Fail;	//用户取消
				yield break;
			}
		}

		if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.PopYYB)
		{
			StartSaveUpdate();
		}
		else if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.InGame)
		{
			StartCommonUpdate();
		}
		else
		{
			result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.Fail;	//用户取消
			yield break;
		}

		foreach (var item in ShowProgressCoroutine(versionParam, updatePanel, result))
			yield return item;
	}