Beispiel #1
0
        //窗口加载时进行更新检测,并进行更新
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //获取配置文件中服务器地址

            //判断文件是否存在
            try
            {
                if (File.Exists(address))
                {
                    FileStream   file   = new FileStream(address, FileMode.Open);
                    StreamReader reader = new StreamReader(file);
                    String       temp   = reader.ReadLine();
                    serverPath = temp;
                    file.Close();
                    reader.Close();
                }
            }
            catch (IOException)
            {
            }
            ;
            Update update       = new Update();
            String serverDbName = GetFileName.GetFileNameWithonExtension(serverPath);

            if (serverDbName == null)
            {
                return;
            }
            String localDbName = GetFileName.GetFileNameWithonExtension(localPath);

            if (update.AntoUpdateOrNot())
            {
                MessageBoxResult result = MessageBox.Show("当前软件需要更新", "提示", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    String filename = Assembly.GetExecutingAssembly().Location;
                    File.Move(filename, filename + ".delete");
                    File.Copy(serverPath + "\\" + "TeamProjectDevelopment.exe", filename);

                    String          DbName     = GetFileName.getFileName(serverPath);
                    String          conStr     = databaseCon + serverPath + "\\" + DbName;
                    OleDbConnection connection = CreateDb.getConn(conStr);
                    connection.Open();
                    String       selectString = "delete from config1 where fileName=\"TeamProjectDevelopment.exe\"";
                    OleDbCommand command      = new OleDbCommand(selectString, connection);
                    command.ExecuteNonQuery();
                    connection.Close();

                    update.AutoUpdate();
                }
            }
            if (update.UpdateOrNot())
            {
                MessageBoxResult result = MessageBox.Show("当前有版本更新,需要更新吗?", "更新", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    update.update(this);
                }
            }
        }
Beispiel #2
0
        public static OleDbConnection getCon()
        {
            String          localDbName  = GetFileName.getFileName(localPath);
            String          conStr       = databaseCon + localPath + "\\" + localDbName;
            OleDbConnection connection   = getConn(conStr);
            String          selectString = "select * from config1";
            OleDbCommand    command      = new OleDbCommand(selectString, connection);

            return(connection);
        }
        public void GetFileName_getMetadata_ReturnsCorrectString()
        {
            GetFileName name     = new GetFileName();
            string      guid     = "eb31d4ff-be0b-4366-9838-994ed803dd69";
            string      destPath = "Testpfad";

            //act
            string result = name.GetMetadataName(destPath, guid);

            //assert
            Assert.That(result, Is.EqualTo(@"Testpfad\eb31d4ff-be0b-4366-9838-994ed803dd69_Metadata.xml"));
        }
Beispiel #4
0
 // コンストラクタ
 public MainViewModel(GetFileName funcGFN1, GetFileName funcGFN2)
 {
     //
     PreviewImageFlg = PreviewImage.Select(p => p != null).ToReadOnlyReactiveProperty();
     //
     ShowImageDataFlg1.Subscribe(_ => RedrawViewImage());
     ShowImageDataFlg2.Subscribe(_ => RedrawViewImage());
     ShowImageDataFlg3.Subscribe(_ => RedrawViewImage());
     //
     CreateFormationPictureCommand.Subscribe(_ => {
         var image = CreateFormationPicture();
         if (image == null)
         {
             return;
         }
         string filePath = funcGFN2();
         if (filePath != "")
         {
             if (System.IO.Path.GetExtension(filePath) != ".png")
             {
                 filePath += ".png";
             }
             image.Save(filePath, ImageFormat.Png);
         }
     });
     DeleteDataAllCommand.Subscribe(_ => {
         var result = MessageBox.Show("リストの画像を全て消去しますか?", "編成まとめ隊", MessageBoxButtons.YesNo, MessageBoxType.Question);
         if (result == DialogResult.Yes)
         {
             piecePictureData.Clear();
             PiecePictureList1.Clear();
             PiecePictureList2.Clear();
             PiecePictureList3.Clear();
             RedrawViewImage();
         }
     });
     AddPiecePicture1Command.Subscribe(_ => { AddPiecePicture(funcGFN1(), PiecePictureType.Main); });
     AddPiecePicture2Command.Subscribe(_ => { AddPiecePicture(funcGFN1(), PiecePictureType.Support); });
     AddPiecePicture3Command.Subscribe(_ => { AddPiecePicture(funcGFN1(), PiecePictureType.Base); });
     DeletePiecePicture1Command.Subscribe(_ => { DeletePiecePicture(PiecePictureType.Main); });
     DeletePiecePicture2Command.Subscribe(_ => { DeletePiecePicture(PiecePictureType.Support); });
     DeletePiecePicture3Command.Subscribe(_ => { DeletePiecePicture(PiecePictureType.Base); });
     MoveUpPiecePicture1Command.Subscribe(_ => { MoveUpPiecePicture(PiecePictureType.Main); });
     MoveUpPiecePicture2Command.Subscribe(_ => { MoveUpPiecePicture(PiecePictureType.Support); });
     MoveUpPiecePicture3Command.Subscribe(_ => { MoveUpPiecePicture(PiecePictureType.Base); });
     MoveDownPiecePicture1Command.Subscribe(_ => { MoveDownPiecePicture(PiecePictureType.Main); });
     MoveDownPiecePicture2Command.Subscribe(_ => { MoveDownPiecePicture(PiecePictureType.Support); });
     MoveDownPiecePicture3Command.Subscribe(_ => { MoveDownPiecePicture(PiecePictureType.Base); });
     DeletePiecePictureAll1Command.Subscribe(_ => { DeletePiecePictureAll(PiecePictureType.Main); });
     DeletePiecePictureAll2Command.Subscribe(_ => { DeletePiecePictureAll(PiecePictureType.Support); });
     DeletePiecePictureAll3Command.Subscribe(_ => { DeletePiecePictureAll(PiecePictureType.Base); });
 }
Beispiel #5
0
        private void CreateCommands()
        {
            GetProcessesCommand = new RelayCommand(o => { UpdateProcesses(); });

            GetFilesOverviewCommand = new RelayCommand(o => UpdateFiles());

            GetInputFilesFromFolderCommand = new RelayCommand(o => InputDirectory = GetFolderName());

            RefreshJobsCommand = new RelayCommand(o => UpdateJobs());

            AddJobCommand = new RelayCommand(o => AddJob());

            DeleteJobCommand = new RelayCommand(
                async o => await api.DeleteJob(SelectedProcess.Id, SelectedJob.JobId),
                o => SelectedJob != null);

            GetMeCommand = new RelayCommand(o => { UpdateLoginName(); });

            DeleteFileCommand = new RelayCommand <IRemotePath>(async o =>
            {
                if (!(o is IRemotePath remotePath))
                {
                    return;
                }

                var remotePaths = o is RemoteFolder folder
                    ? folder.GetAllSubPathsRecursive().ToArray()
                    : new[] { remotePath };

                foreach (var path in remotePaths)
                {
                    var success = await api.DeleteFile(path.FullPath);
                    if (!success)
                    {
                        ErrorMessage = $"Could not delete {o}";
                    }
                }

                UpdateFiles();
            }, o => o != null);

            DownloadFileCommand = new RelayCommand <IRemotePath>(async remotePath =>
            {
                var fileName = GetFileName?.Invoke(remotePath.Name);
                if (fileName == null)
                {
                    return;
                }

                await api.DownloadFile(remotePath.FullPath, fileName);
            });
        }
        public static OleDbDataReader DbConnect(String path)
        {
            String          DbName       = GetFileName.getFileName(path);
            String          conStr       = databaseCon + path + "\\" + DbName;
            OleDbConnection connection   = getConn(conStr);
            String          selectString = "select * from config1";
            OleDbCommand    command      = new OleDbCommand(selectString, connection);

            connection.Open();
            OleDbDataReader reader = command.ExecuteReader();

            return(reader);
        }
        public void GetFileName_getContent_ReturnsCorrectString()
        {
            //arrange
            GetFileName  name     = new GetFileName();
            const string guid     = "eb31d4ff-be0b-4366-9838-994ed803dd69";
            const string filePath = "Testpfad.txt";
            const string destPath = "Testpfad";

            //act
            string result = name.GetContentName(filePath, guid, destPath);

            //assert
            Assert.That(result, Is.EqualTo(@"Testpfad\eb31d4ff-be0b-4366-9838-994ed803dd69_Content.txt"));
        }
Beispiel #8
0
        public void SoftwareUpdate()
        {
            String filename = Assembly.GetExecutingAssembly().Location;

            File.Move(filename, filename + ".delete");
            File.Copy(serverPath + "\\" + softwareName, filename);

            String          DbName     = GetFileName.getFileName(serverPath);
            String          conStr     = databaseCon + serverPath + "\\" + DbName;
            OleDbConnection connection = CreateDb.getConn(conStr);

            connection.Open();
            String       selectString = "delete from config1 where fileName=\"" + softwareName + "\"";
            OleDbCommand command      = new OleDbCommand(selectString, connection);

            command.ExecuteNonQuery();
            connection.Close();

            AutoUpdate();
        }
        private void BtnOpenFileDialog_Click(object sender, RoutedEventArgs e)
        {
            if (!TbTfs.Text.Equals(""))
            {
                System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
                openFileDialog1.Title            = "Dosya Seçiniz";
                openFileDialog1.InitialDirectory = "C:\\";
                openFileDialog1.ShowDialog();
                TbFileName.Text = openFileDialog1.FileName;

                //OpenAndWorkOnFile(TbFileName.Text);

                OpenXmlPowerTools.GetFileName FileGet = new GetFileName();
                myCollection.AddRange(FileGet.SelectFile(TbFileName.Text));
                Mygrid.IsEnabled = true;
            }

            else
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Please Choose Test Project&Plan");
            }
        }
        public void generateLocalVersion(String DbPath)
        {
            CopyFile copyFile = new CopyFile();

            String          DbName = GetFileName.getFileName(DbPath);
            OleDbDataReader reader = CreateDb.DbConnect(DbPath);

            String path = versionFile;

            System.IO.Directory.CreateDirectory(path + "\\" + "本地版本" + Path.GetFileNameWithoutExtension(DbName));
            DirectoryInfo dir = new DirectoryInfo(path + "\\" + "本地版本" + Path.GetFileNameWithoutExtension(DbName));

            dir.Create();
            while (reader.Read())
            {
                String tempStr   = (String)reader["path"];
                String targetDir = dir + "\\" + Path.GetFileName(tempStr);
                copyFile.copyFile(tempStr, targetDir);
            }
            copyFile.copyFile(DbPath + "\\" + DbName, dir + "\\" + DbName);
            MessageBox.Show("生成版本成功", "提示", MessageBoxButton.OK);
        }
Beispiel #11
0
        public void update(Window oldWindow)
        {
            //判断文件是否存在

            CopyFile        copyFile     = new CopyFile();
            String          serverDbName = GetFileName.getFileName(serverPath);
            OleDbDataReader reader       = CreateDb.DbConnect(serverPath);

            while (reader.Read())
            {
                String tempStr      = (String)reader["fileName"];
                String originFile   = serverPath + "\\" + tempStr;
                String updateMethod = (String)reader["updateMethod"];
                if (updateMethod.Equals("删除") && File.Exists(localPath + "\\" + tempStr))
                {
                    File.Delete(localPath + "\\" + tempStr);
                }
                else
                {
                    copyFile.copyFile(originFile, localPath + "\\" + tempStr);
                }
            }
            if (reader != null)
            {
                reader.Close();
            }

            //最后复制服务器配置文件到本地,并删除原来的配置文件
            String localDbName = GetFileName.getFileName(localPath);

            copyFile.copyFile(serverPath + "\\" + serverDbName, localPath + "\\" + localDbName);

            /*
             * if (serverDbName != localDbName)
             *  File.Delete(localPath + "\\" + localDbName);
             */
            SuccessTips(oldWindow);
        }
Beispiel #12
0
        public bool AntoUpdateOrNot()
        {
            //判断文件是否存在

            String serverDbName = GetFileName.getFileName(serverPath);

            if (serverDbName == null)
            {
                return(false);
            }
            OleDbDataReader serverReader = CreateDb.DbConnect(serverPath);

            while (serverReader.Read())
            {
                if (serverReader["fileName"].Equals(softwareName))
                {
                    serverReader.Close();
                    return(true);
                }
            }
            serverReader.Close();
            return(false);
        }
Beispiel #13
0
        private void Button3_Click(object sender, EventArgs e)
        {
            string imagePath = textBox1.Text;
            string savePath  = textBox2.Text;

            if (textBox3.Text == "" || textBox4.Text == "")
            {
                GetErrorPage.Get("错误:未输入横向像素点跨度或纵向像素点跨度");
                return;
            }
            string w = textBox3.Text;
            string h = textBox4.Text;

            int.TryParse(w, out int wSpan);
            int.TryParse(h, out int hSpan);

            string imageName = GetFileName.Get(imagePath);

            // 使用推荐字符组
            if (checkBox1.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c256.txt", wSpan, hSpan, GrayValueString.c_256);
            }
            if (checkBox2.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c128.txt", wSpan, hSpan, GrayValueString.c_128);
            }
            if (checkBox3.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c64.txt", wSpan, hSpan, GrayValueString.c_64);
            }
            if (checkBox4.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c32.txt", wSpan, hSpan, GrayValueString.c_32);
            }
            if (checkBox5.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c16.txt", wSpan, hSpan, GrayValueString.c_16);
            }
            if (checkBox6.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c8.txt", wSpan, hSpan, GrayValueString.c_8);
            }
            if (checkBox7.Checked)
            {
                Transformation.ImageToChar(imagePath, savePath + imageName + "_c4.txt", wSpan, hSpan, GrayValueString.c_4);
            }

            // 使用自定义字符组
            string[] replaceChars =
            {
                textBox5.Text,  textBox6.Text,  textBox7.Text, textBox8.Text, textBox9.Text,
                textBox10.Text, textBox11.Text,
            };
            int num = 1;

            for (int index = 0; index < replaceChars.Length; ++index)
            {
                if (replaceChars[index] != "")
                {
                    Transformation.ImageToChar(imagePath, savePath + imageName + "_custom_" + num + ".txt", wSpan, hSpan, replaceChars[index]);
                    ++num;
                }
            }
        }
Beispiel #14
0
 public Save(GetFileName files)
 {
     InitializeComponent();
     filePath = files;
 }
Beispiel #15
0
        static void Main(string[] args)
        {
            FileInfo = new FileInformation();


            while (ValueFormatter.isEmpty(FileInfo.InputFileName))
            {
                Out.WriteLine("Please copy and paste file path in .csv or .tsv format");
                FileInfo.InputFileName = ReadLine();
            }

            FileInfo.ReadResults = GetFileName.ReadFileName(FileInfo.InputFileName);



            string numberOfFields = null;
            int    temp2;

            while (ValueFormatter.isEmpty(numberOfFields) || !int.TryParse(numberOfFields, out temp2))
            {
                WriteLine("Enter number of fields");
                numberOfFields = ReadLine();
            }

            int fieldsInRecords = 0;

            try
            {
                fieldsInRecords         = Convert.ToInt32(numberOfFields);
                FileInfo.NumberOfFields = fieldsInRecords;

                FileInfo.Results    = GetLines.ReturnDetailRecords(FileInfo.ReadResults);
                FileInfo.NewResults = FileInfo.Results.Skip(1).ToList();
                char delimiter = GetFileName.CheckFileName(FileInfo.InputFileName);
                //Once you run this, it'll write the files to your bin direcotry
                FileInfo.EnvironmentDirectory = WriteToFile.GetEnvironmentDirectory();

                foreach (var rec in FileInfo.NewResults)
                {
                    var returnedFields  = GetLines.ReturnFields(rec, delimiter);
                    var isRecordCorrect = GetLines.GetFieldCount(returnedFields, fieldsInRecords);
                    if (isRecordCorrect == false)
                    {
                        var pathCombined = Path.Combine(FileInfo.EnvironmentDirectory, "errorrecs.txt");
                        Out.WriteLine($"directory is {pathCombined}");
                        WriteToFile.WriteErrorsToFile(pathCombined, rec);
                    }
                    else
                    {
                        var pathCombined = Path.Combine(FileInfo.EnvironmentDirectory, "correct.txt");
                        Out.WriteLine($"directory is {pathCombined}");
                        WriteToFile.WriteErrorsToFile(pathCombined, rec);
                    }
                }

                Console.WriteLine($"the delimiter is {delimiter}");
                Console.WriteLine(FileInfo.NewResults.Count);
            }
            catch (System.FormatException fe)
            {
                Out.WriteLine($"No fields were read {fe}");
            }

            Console.Out.WriteLine("Bonsoir, Elliot");
            Console.ReadKey();
        }
 public void TestInitialize()
 {
     fut             = GetFileName.ReadFileName(@"C:\Temp\TestFile.csv");
     readFileResults = GetLines.ReturnDetailRecords(fut);
 }
Beispiel #17
0
        //判断是否需要更新
        public bool UpdateOrNot()
        {
            String serverDbName = GetFileName.getFileName(serverPath);

            if (serverDbName == null)
            {
                return(false);
            }
            //String DbName = GetFileName.getFileName(serverPath);
            String          serverConStr       = databaseCon + serverPath + "\\" + serverDbName;
            OleDbConnection serverConnection   = new OleDbConnection(serverConStr);
            String          serverSelectString = "select * from config1";
            OleDbCommand    serverCommand      = new OleDbCommand(serverSelectString, serverConnection);

            serverConnection.Open();
            OleDbDataReader serverReader = serverCommand.ExecuteReader();


            //OleDbDataReader serverReader = CreateDb.DbConnect(serverPath);
            //OleDbDataReader localReader = CreateDb.DbConnect(localPath);

            String          localDbName       = GetFileName.getFileName(localPath);
            String          localConStr       = databaseCon + localPath + "\\" + localDbName;
            OleDbConnection localConnection   = new OleDbConnection(localConStr);
            String          localSelectString = "select * from config1";
            OleDbCommand    localCommand      = new OleDbCommand(localSelectString, localConnection);

            localConnection.Open();
            OleDbDataReader localReader = localCommand.ExecuteReader();

            if (localReader.Read())
            {
                try
                {
                    localVersion = (int)localReader["versionNum"];
                }
                catch
                {
                    localVersion = 1;
                }
            }
            if (serverReader.Read())
            {
                serverVersion = (int)serverReader["versionNum"];
            }
            Console.WriteLine("localVersion:" + localVersion);
            Console.WriteLine("serverVersion:" + serverVersion);
            if (localVersion < serverVersion)
            {
                serverReader.Close();
                localReader.Close();
                localConnection.Close();
                serverConnection.Close();

                return(true);
            }
            else
            {
                serverReader.Close();
                localReader.Close();
                localConnection.Close();
                serverConnection.Close();
                return(false);
            }
        }