Пример #1
0
        private void ToggleVersionStatus(VersionStatus version)
        {
            try
            {
                switch (version)
                {
                case VersionStatus.NotFound:
                    uStatusUpdate("Please install Panacea");
                    txtLabelUpToDate.Text       = "Not Found";
                    txtLabelUpToDate.Foreground = new SolidColorBrush(Colors.Red);
                    ToggleFixMeButton(FixMeStatus.NotInstalled);
                    break;

                case VersionStatus.UpdateAvailable:
                    uStatusUpdate("Update found and now available!");
                    txtLabelUpToDate.Text       = "Update Available";
                    txtLabelUpToDate.Foreground = new SolidColorBrush(Colors.Cyan);
                    ToggleFixMeButton(FixMeStatus.NeedUpdate);
                    break;

                case VersionStatus.UpToDate:
                    uStatusUpdate("Panacea is at the most up to date version!");
                    txtLabelUpToDate.Text       = "Up To Date";
                    txtLabelUpToDate.Foreground = new SolidColorBrush(Colors.LawnGreen);
                    ToggleFixMeButton(FixMeStatus.Shrug);
                    break;

                case VersionStatus.Verifying:
                    txtLabelUpToDate.Text       = "Verifying";
                    txtLabelUpToDate.Foreground = new SolidColorBrush(Colors.Yellow);
                    break;

                default:
                    txtLabelUpToDate.Text       = "?????";
                    txtLabelUpToDate.Foreground = new SolidColorBrush(Colors.OrangeRed);
                    uDebugLogAdd("Unknown state triggered for install status", DebugType.FAILURE);
                    uStatusUpdate("Unknown state triggered for version status, please let the developer know");
                    break;
                }
                uDebugLogAdd($"Version status toggled to: {version.ToString()}");
            }
            catch (Exception ex)
            {
                LogException(ex);
            }
        }
Пример #2
0
 /// <summary>
 /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
 /// </returns>
 public override string ToString()
 {
     //TODO: VersionStatus
     return(String.Concat("V", _major, ".", _minor, ".", _status.ToString()[0]));
 }
Пример #3
0
 /// <summary>
 /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
 /// </summary>
 /// <returns>
 /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>.
 /// </returns>
 public override string ToString()
 {
     return(String.Concat("V", _major, ".", _minor, ".", _status.ToString()[0]));
 }
Пример #4
0
        /// <summary>
        /// 程序下载
        /// </summary>
        /// <param name="modelCode">车型代码</param>
        /// <param name="status">软件版本状态</param>
        /// <param name="percent">下载进度</param>
        /// <returns>成功返回TRUE, 失败返回False</returns>
        public bool DownloadFile(string modelCode, VersionStatus status, DownloadPercent percent)
        {
            try
            {
                if (modelCode == null || status == VersionStatus.Null)
                {
                    throw new Exception("参数值无效");
                }

                string currerntFilePath = System.Environment.CurrentDirectory + "\\TCU程序\\" + modelCode + "\\" + status.ToString() + "\\";

                if (!Directory.Exists(currerntFilePath))
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(currerntFilePath);
                    directoryInfo.Create();
                }

                System.IO.DirectoryInfo dir = new DirectoryInfo(currerntFilePath);
                bool isDownload             = false;

                if (dir.GetFiles().Length == 0)
                {
                    isDownload = true;
                }
                else
                {
                    List <FileInfo> lstFile = dir.GetFiles().Where(k => k.Name.Contains("TCU程序")).ToList();

                    if (lstFile.Count() == 0)
                    {
                        isDownload = true;
                    }
                    else
                    {
                        string fileName = lstFile[0].Name;

                        DataTable tempTable = GetSoftWareInfo(modelCode, status);

                        if (tempTable == null || tempTable.Rows.Count == 0)
                        {
                            throw new Exception("无法获得文件信息");
                        }

                        fileName = fileName.Substring(fileName.IndexOf("(") + 1, fileName.IndexOf(")") - fileName.IndexOf("(") - 1);
                        string version = tempTable.Rows[0]["Version"].ToString();

                        if (string.Compare(version, fileName) > 0)
                        {
                            isDownload = true;
                        }
                    }
                }

                if (isDownload)
                {
                    foreach (FileInfo fi in dir.GetFiles())
                    {
                        fi.Delete();
                    }

                    Download_TxtFile(modelCode, status, currerntFilePath);
                    Download_SoftFile(modelCode, status, currerntFilePath, percent);
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #5
0
        /// <summary>
        /// 获取文件存放路径
        /// </summary>
        /// <returns>返回文件存放路径</returns>
        public string GetFilePath(string modelCode, VersionStatus status)
        {
            try
            {
                string path = null;

                if (modelCode == null || status == VersionStatus.Null)
                {
                    throw new Exception("参数值无效");
                }

                path = System.Environment.CurrentDirectory + "\\TCU程序\\" + modelCode + "\\" + status.ToString() + "\\";

                return(path);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }