Exemplo n.º 1
0
        private static void Initialize(int versionState, bool isVet)
        {
            string newArchFlag = Path.Combine(ServiceManager.ImageRepositoryPath, "NewSqliteArch.dat");

            int isCorrectUpdate = versionState;

            //If sql data not exist, then do no initialize.
            if (isCorrectUpdate == 2)
            {
                return;
            }

            //Cancel updating if flag exists.
            if (VinnoFile.Exists(newArchFlag))
            {
                return;
            }

            if (!isVet && isCorrectUpdate == 1)
            {
                //Human, same type, nothing to do.
                return;
            }

            if (isVet && isCorrectUpdate == 1)
            {
                //Vet, same type, at start, move all old vet files into clean vet folder.
                if (!VinnoDirectory.Exists(ImageRepository))
                {
                    return;
                }

                TryToMoveFiles(new VinnoDirectoryInfo(ImageRepository), new VinnoDirectoryInfo(VetImageRepository));

                try
                {
                    VinnoDirectory.Delete(ImageRepository, true);
                }
                catch (Exception e)
                {
                    Logger.ForceWriteLine("Delete UltrasoundImage file is failed, detailed log is {0}", e.InnerException?.Message);
                }

                return;
            }

            if (!isVet)
            {
                //SqlRestore can not show messageBox normally, so it is called outside in Main exe.
                UpdateNoVetNoCorrectInfo();
                return;
            }

            //SqlRestore can not show messageBox normally, so it is called outside in Main exe.
            UpdateIsVetNoCorrectInfo();
        }
Exemplo n.º 2
0
        private static void UpdateNoVetNoCorrectInfo()
        {
            var result = ServiceManager.Instance.GetService <IMessageBoxService>()
                         .ShowMessageBox("Waring", "DeleteOrSaveOldDataVP", MessageBoxButtonEnum.YesNo);

            switch (result)
            {
            case MessageBoxResultExtend.No:
                //Delete images.
                if (VinnoDirectory.Exists(ImageRepository))
                {
                    TryToMoveFiles(new VinnoDirectoryInfo(ImageRepository), new VinnoDirectoryInfo(OldVetImageRepository));
                    try
                    {
                        VinnoDirectory.Delete(ImageRepository, true);
                    }
                    catch (Exception e)
                    {
                        Logger.ForceWriteLine("Delete UltrasoundImage file is failed, detailed log is {0}", e.InnerException?.Message);
                    }
                }

                if (VinnoDirectory.Exists(VetImageRepository))
                {
                    TryToMoveFiles(new VinnoDirectoryInfo(VetImageRepository), new VinnoDirectoryInfo(OldVetImageRepository));

                    try
                    {
                        VinnoDirectory.Delete(VetImageRepository, true);
                    }
                    catch (Exception e)
                    {
                        Logger.ForceWriteLine("Delete UltrasoundImage_Vet file is failed, detailed log is {0}", e.InnerException?.Message);
                    }
                }

                UpdateNoVetNoCorrectDatabase(false);
                break;

            case MessageBoxResultExtend.Yes:
                //Delete images.
                try
                {
                    VinnoDirectory.Delete(ImageRepository, true);
                }
                catch (Exception e)
                {
                    Logger.ForceWriteLine("Delete UltrasoundImage file is failed, detailed log is {0}", e.InnerException?.Message);
                }

                UpdateNoVetNoCorrectDatabase(true);
                break;
            }
        }