Example #1
0
        private void timer_Init_Tick(object sender, EventArgs e)
        {
            this.timer_Init.Enabled = false;

            if (File.Exists(str_cfgIniPath))
            {
                ArrayList al_sections = ClassLib_RML.ReadSectionsFromINI(str_cfgIniPath);
                if (al_sections.Count > 0)
                {
                    for (int idx = 0; idx < al_sections.Count; idx++)
                    {
                        String str_bundle = ClassLib_RML.ReadeValueFromINI(al_sections[idx].ToString(), "Bundle", str_cfgIniPath);
                        String str_Folder = ClassLib_RML.ReadeValueFromINI(al_sections[idx].ToString(), "Folder", str_cfgIniPath);

                        if (String.IsNullOrEmpty(str_bundle) || String.IsNullOrWhiteSpace(str_bundle))
                        {
                            str_bundle = "N/A";
                        }

                        if (String.IsNullOrEmpty(str_Folder) || String.IsNullOrWhiteSpace(str_Folder))
                        {
                            str_Folder = "N/A";
                        }

                        al_Bundles.Add(str_bundle);
                        al_Folders.Add(str_Folder);
                    }
                }
            }
            else
            {
                File.Create(str_cfgIniPath);
            }
            this.btn_addSrc.Enabled = true;
        }
        private void initApp()
        {
            if (!System.IO.File.Exists(str_cfgfile))
            {
                ClassLib_RML.WriteValueToINI("Server", "Server1", "10.204.16.168:1667", str_cfgfile);
                ClassLib_RML.WriteValueToINI("User", "User1", "L10N02_Hisoft", str_cfgfile);
                ClassLib_RML.WriteValueToINI("Workspace", "Workspace1", "TM_ENG04", str_cfgfile);
                ClassLib_RML.WriteValueToINI("Password", "CurrentPWD", "Trend2018!", str_cfgfile);
            }

            var servers = ClassLib_RML.ReadKeysFromINI("Server", str_cfgfile);

            foreach (String server in servers)
            {
                this.comBox_Server.Items.Add(ClassLib_RML.ReadeValueFromINI("Server", server, str_cfgfile));
            }

            var users = ClassLib_RML.ReadKeysFromINI("User", str_cfgfile);

            foreach (String user in users)
            {
                this.comBox_User.Items.Add(ClassLib_RML.ReadeValueFromINI("User", user, str_cfgfile));
            }

            var workspaces = ClassLib_RML.ReadKeysFromINI("Workspace", str_cfgfile);

            foreach (String workspace in workspaces)
            {
                this.comBox_Workspace.Items.Add(ClassLib_RML.ReadeValueFromINI("Workspace", workspace, str_cfgfile));
            }

            this.tb_Password.Text = ClassLib_RML.ReadeValueFromINI("Password", "CurrentPWD", str_cfgfile);
        }
        private void initApp()
        {
            if (!File.Exists(str_cfgfile))
            {
                ClassLib_RML.WriteValueToINI("StringList", "Str1", "en_US", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str2", "en-US", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str3", "MM/dd/yyyy", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str4", "MM-dd-yyyy", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str5", "yyyy/MM/dd", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str6", "yyyy-MM-dd", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str7", "%M/%D/%Y", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str8", "%M-%D-%Y", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str9", "%Y/%M/%D", str_cfgfile);
                ClassLib_RML.WriteValueToINI("StringList", "Str10", "%Y-%M-%D", str_cfgfile);
            }

            specStrs.Clear();
            var strKeys = ClassLib_RML.ReadKeysFromINI("StringList", str_cfgfile);

            this.dataGridView_strList.Rows.Add(strKeys.Count);
            int rowcount = 0;

            foreach (String strKey in strKeys)
            {
                var str = ClassLib_RML.ReadeValueFromINI("StringList", strKey, str_cfgfile);
                this.dataGridView_strList.Rows[rowcount].Cells[0].Value = str;
                specStrs.Add(str);
                rowcount++;
            }
        }
Example #4
0
        private void btn_run_Click(object sender, EventArgs e)
        {
            str_path = this.tb_path.Text;
            l_fileList.Clear();

            if (Directory.Exists(str_path))
            {
                ClassLib_RML.GetFilesListOfFolder(str_path, b_subF, l_fileList);
                if (l_fileList.Count > 0)
                {
                    this.panel_set.Enabled    = false;
                    this.btn_run.Enabled      = false;
                    this.timer_Change.Enabled = true;
                }
                else
                {
                    MessageBox.Show("No file exists in the path:\r\n" + str_path, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.tb_path.Text = "";
                }
            }
            else
            {
                MessageBox.Show("The path does not exist.\r\n" + str_path, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.tb_path.Text = "";
            }
        }
        private void tb_bundles_TextChanged(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(this.tb_bundles.Text) && !String.IsNullOrWhiteSpace(this.tb_bundles.Text))
            {
                if (!String.IsNullOrEmpty(this.tb_folders.Text) && !String.IsNullOrWhiteSpace(this.tb_folders.Text))
                {
                    this.btn_save.Enabled = true;
                }
                else
                {
                    this.btn_save.Enabled = false;
                }
            }
            else
            {
                this.btn_save.Enabled = false;
            }

            ArrayList al_tmp  = ClassLib_RML.SplitString(this.tb_bundles.Text, "\r\n");
            int       int_cot = 0;

            for (int idx = 0; idx < al_tmp.Count; idx++)
            {
                if (!String.IsNullOrEmpty(al_tmp[idx].ToString()) && !String.IsNullOrWhiteSpace(al_tmp[idx].ToString()))
                {
                    int_cot++;
                }
            }
            this.lab_bundCount.Text = int_cot.ToString() + " item(s)";
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            int    int_addCount = 0;
            String str_keyName  = "";

            Form_RemoveSentence.al_addSen.Clear();
            File.Delete(Form_RemoveSentence.str_cfgfile);

            for (int idx = 0; idx < this.lb_addSen.Items.Count; idx++)
            {
                int_addCount++;
                if (int_addCount < 10)
                {
                    str_keyName = "Sentence_0" + int_addCount.ToString();
                }
                else
                {
                    str_keyName = "Sentence_" + int_addCount.ToString();
                }

                Form_RemoveSentence.al_addSen.Add(this.lb_addSen.Items[idx]);
                ClassLib_RML.WriteValueToINI("REMOVE_SENTENCES", str_keyName, "$$Rem$$" + this.lb_addSen.Items[idx].ToString() + "$$Rem$$", Form_RemoveSentence.str_cfgfile);
            }
            this.Close();
        }
        private void timer_listFiles_Tick(object sender, EventArgs e)
        {
            this.timer_listFiles.Enabled = false;
            List <FileInfo> l_tmp = new List <FileInfo>();

            ClassLib_RML.GetFilesListOfFolder(str_filePath, b_subfolder, l_tmp);
            foreach (FileInfo fInfo in l_tmp)
            {
                if (Regex.IsMatch(fInfo.Extension, @"(?i)^\.xml$"))
                {
                    l_fileList.Add(fInfo);
                }
            }
            proBar_step.Value++;
            if (l_fileList.Count < 1)
            {
                MessageBox.Show("No XML type files found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.panel_set.Enabled = true;
                this.tb_filepath.Text  = "";
                this.panel_progress.Controls.Clear();
            }
            else
            {
                this.timer_check.Enabled = true;
                proBar_step.Value++;
            }
        }
Example #8
0
        private void timer_listFiles_Tick(object sender, EventArgs e)
        {
            this.timer_listFiles.Enabled = false;
            List <FileInfo> l_files     = new List <FileInfo>();
            ArrayList       al_fileType = new ArrayList();

            al_fileType = ClassLib_RML.SplitString(str_fileType, ";");
            ClassLib_RML.GetFilesListOfFolder(str_path, true, l_files);

            foreach (FileInfo finfo in l_files)
            {
                for (int index = 0; index < al_fileType.Count; index++)
                {
                    if (finfo.Extension == "." + al_fileType[index])
                    {
                        lfi_fileList.Add(finfo);
                    }
                }
            }

            if (lfi_fileList.Count > 0)
            {
                this.timer_move.Enabled = true;
            }
            else
            {
                MessageBox.Show("Can not find file to move!\r\nPlease check your file type setting.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #9
0
        private void timer_listFiles_Tick(object sender, EventArgs e)
        {
            this.timer_listFiles.Enabled = false;
            addMsgToLab(this.lab_msg, "Filtering files......", Color.Blue);
            List <FileInfo> l_tmp = new List <FileInfo>();

            ClassLib_RML.GetFilesListOfFolder(str_FilePath, b_subFolder, l_tmp);
            foreach (FileInfo fInfo in l_tmp)
            {
                if (Regex.IsMatch(fInfo.Extension, @"(?i)^\.xml$"))
                {
                    l_fileList.Add(fInfo);
                }
            }

            if (l_fileList.Count < 1)
            {
                MessageBox.Show("No file need to check!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                addMsgToLab(this.lab_msg, "No XML type files found.", Color.Black);
                this.panel_setting.Enabled = true;
                this.tb_filePath.Text      = "";
            }
            else
            {
                addMsgToLab(this.lab_msg, "Please wait! Checking files......", Color.Blue);
                this.timer_check.Enabled = true;
            }
        }
 private void btn_updPassword_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(this.tb_Password.Text) && !String.IsNullOrWhiteSpace(this.tb_Password.Text))
     {
         ClassLib_RML.WriteValueToINI("Password", "CurrentPWD", this.tb_Password.Text, str_cfgfile);
         addRunInfo("Password updated successfully.");
     }
     else
     {
         this.tb_Password.Text = ClassLib_RML.ReadeValueFromINI("Password", "CurrentPWD", str_cfgfile);
     }
 }
Example #11
0
 private void btn_check_Click(object sender, EventArgs e)
 {
     str_filepath = this.tb_filePath.Text;
     str_filetype = this.tb_fileType.Text;
     l_filelist.Clear();
     al_filetype.Clear();
     addLabInfo(this.lab_info, "Reading file type......", Color.White);
     al_filetype = ClassLib_RML.SplitString(str_filetype, ";");
     this.grpBox_settings.Enabled = false;
     this.btn_check.Enabled       = false;
     this.timer_listfiles.Enabled = true;
 }
Example #12
0
        /*获取指定节点下的所有Key的Value*/
        public static ArrayList ReadAllValues(String sectionName, String fPath)
        {
            String    rd_tmp   = "";
            ArrayList al_keys  = new ArrayList();
            ArrayList al_value = new ArrayList();

            al_keys = ClassLib_RML.ReadKeysFromINI(sectionName, fPath);

            for (int idx = 0; idx < al_keys.Count; idx++)
            {
                rd_tmp = ClassLib_RML.ReadeValueFromINI(sectionName, al_keys[idx].ToString(), fPath);
                al_value.Add(rd_tmp);
            }
            return(al_value);
        }
 private void timer_listFile_Tick(object sender, EventArgs e)
 {
     this.timer_listFile.Enabled = false;
     Form_Main.AddTextToListbox(this.lb_info, "Getting files list......");
     ClassLib_RML.GetFilesListOfFolder(str_filepath, b_subfolder, l_listfiles);
     if (l_listfiles.Count > 0)
     {
         this.timer_remove.Enabled = true;
     }
     else
     {
         MessageBox.Show("No file found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Form_Main.AddTextToListbox(this.lb_info, "Can not find any file in the path: " + str_filepath);
         this.grpBox_settings.Enabled = true;
         this.tb_filepath.Text        = "";
     }
 }
Example #14
0
        private void timer_listfiles_Tick(object sender, EventArgs e)
        {
            this.timer_listfiles.Enabled = false;
            addLabInfo(this.lab_info, "Getting files list......", Color.White);
            String          str_tmppath = "";
            List <FileInfo> l_tmplist   = new List <FileInfo>();

            str_tmppath = Path.Combine(str_filepath, "programassets");
            if (Directory.Exists(str_tmppath))
            {
                ClassLib_RML.GetFilesListOfFolder(str_tmppath, true, l_tmplist);
            }

            str_tmppath = "";
            str_tmppath = Path.Combine(str_filepath, "seed");
            if (Directory.Exists(str_tmppath))
            {
                ClassLib_RML.GetFilesListOfFolder(str_tmppath, true, l_tmplist);
            }

            addLabInfo(this.lab_info, "Filtering files......", Color.White);
            foreach (FileInfo finfo in l_tmplist)
            {
                for (int idx = 0; idx < al_filetype.Count; idx++)
                {
                    if (finfo.Extension == "." + al_filetype[idx])
                    {
                        l_filelist.Add(finfo);
                    }
                }
            }

            if (l_filelist.Count > 0)
            {
                this.timer_check.Enabled = true;
            }
            else
            {
                MessageBox.Show("Can not find the file need to check.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.grpBox_settings.Enabled = true;
                this.tb_filePath.Text        = "";
                addLabInfo(this.lab_info, "Failed operation.", Color.Red);
            }
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            specStrs.Clear();
            foreach (DataGridViewRow row in this.dataGridView_strList.Rows)
            {
                if (!row.IsNewRow && row.Cells[0].Value != null)
                {
                    var str = row.Cells[0].Value.ToString();
                    if (!String.IsNullOrEmpty(str) && !String.IsNullOrWhiteSpace(str))
                    {
                        specStrs.Add(str);
                    }
                }
            }

            if (specStrs.Count < 1)
            {
                MessageBox.Show("The String List can not be empty.\r\nThe default list will be used.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                initApp();
            }
            else
            {
                File.Delete(str_cfgfile);
                int strCount = 0;
                foreach (var specStr in specStrs)
                {
                    strCount++;
                    ClassLib_RML.WriteValueToINI("StringList", "Str" + strCount.ToString(), specStr, str_cfgfile);
                }
            }

            this.btn_save.Enabled = false;

            if (!String.IsNullOrEmpty(this.tb_pathInput.Text) && !String.IsNullOrWhiteSpace(this.tb_pathInput.Text))
            {
                this.btn_check.Enabled = true;
            }
            else
            {
                this.btn_check.Enabled = false;
            }
        }
 private void btn_addServer_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(this.comBox_Server.Text) && !String.IsNullOrWhiteSpace(this.comBox_Server.Text))
     {
         if (!this.comBox_Server.Items.Contains(this.comBox_Server.Text))
         {
             this.comBox_Server.Items.Add(this.comBox_Server.Text);
             ClassLib_RML.WriteValueToINI("Server", "Server" + this.comBox_Server.Items.Count.ToString(), this.comBox_Server.Text, str_cfgfile);
             addRunInfo("New server added successfully.");
         }
         else
         {
             MessageBox.Show("This server has existed in the list and no need to add again.", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         this.comBox_Server.SelectedIndex = 0;
     }
 }
        private void btn_save_Click(object sender, EventArgs e)
        {
            ArrayList al_budTmp = ClassLib_RML.SplitString(this.tb_bundles.Text, "\r\n");
            ArrayList al_fodTmp = ClassLib_RML.SplitString(this.tb_folders.Text, "\r\n");

            if (al_budTmp.Count == al_fodTmp.Count)
            {
                Form_moveBundle.al_Bundles.Clear();
                Form_moveBundle.al_Folders.Clear();
                File.Delete(str_cfgPath);

                for (int idx = 0; idx < al_budTmp.Count; idx++)
                {
                    String str_bTmp = al_budTmp[idx].ToString();
                    String str_fTmp = al_fodTmp[idx].ToString();

                    if (String.IsNullOrEmpty(str_bTmp) || String.IsNullOrWhiteSpace(str_bTmp))
                    {
                        str_bTmp = "N/A";
                    }

                    if (String.IsNullOrEmpty(str_fTmp) || String.IsNullOrWhiteSpace(str_fTmp))
                    {
                        str_fTmp = "N/A";
                    }

                    Form_moveBundle.al_Bundles.Add(str_bTmp);
                    Form_moveBundle.al_Folders.Add(str_fTmp);

                    ClassLib_RML.WriteValueToINI("BUNDLE" + idx.ToString(), "Bundle", str_bTmp, str_cfgPath);
                    ClassLib_RML.WriteValueToINI("BUNDLE" + idx.ToString(), "Folder", str_fTmp, str_cfgPath);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("The number of bundle is not same with folder's.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btn_run_Click(object sender, EventArgs e)
        {
            this.panel_proBar.Controls.Clear();
            ProgressBar proBar_steps = new ProgressBar();

            this.panel_proBar.Controls.Add(proBar_steps);
            proBar_steps.Dock = DockStyle.Fill;

            var str_pathIn      = this.tb_path.Text;
            var str_OrigSrcPath = this.tb_OriginalSrc.Text;
            var pathOut         = this.tb_pathOut.Text;

            if (Directory.Exists(str_pathIn) && Directory.Exists(str_OrigSrcPath))
            {
                var str_type     = this.tb_type.Text;
                var al_fileType  = ClassLib_RML.SplitString(str_type, ";");
                var filesIn      = getFilesByTypes(str_pathIn, al_fileType, true);
                var origSrcFiles = getFilesByTypes(str_OrigSrcPath, al_fileType, true);

                if (filesIn.Count < 1 || origSrcFiles.Count < 1)
                {
                    MessageBox.Show("Please enter the directory paths containing the operable files.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.tb_path.Text        = "";
                    this.tb_OriginalSrc.Text = "";
                    this.panel_proBar.Controls.Clear();
                }
                else
                {
                    this.grpBox_set.Enabled = false;
                    this.btn_run.Enabled    = false;

                    proBar_steps.Maximum = filesIn.Count;
                    proBar_steps.Minimum = 0;
                    foreach (var fileIn in filesIn)
                    {
                        var nameFileIn = Path.GetFileName(fileIn);
                        var textFileIn = File.ReadAllText(fileIn);
                        var langFileIn = Regex.Match(textFileIn, @"(?<=target-language[ \t]*=[ \t]*"")[^""]+?(?="")").Value;
                        var fileOut    = fileIn.Replace(str_pathIn, pathOut);
                        if (File.Exists(fileOut))
                        {
                            File.Delete(fileOut);
                        }

                        if (!Directory.Exists(Path.GetDirectoryName(fileOut)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(fileOut));
                        }

                        foreach (var origSrcFile in origSrcFiles)
                        {
                            var nameOrigSrc = Path.GetFileName(origSrcFile);
                            var textOrigSrc = File.ReadAllText(origSrcFile);
                            var langOrigSrc = Regex.Match(textOrigSrc, @"(?<=target-language[ \t]*=[ \t]*"")[^""]+?(?="")").Value;
                            if (nameOrigSrc.ToLower() == nameFileIn.ToLower() && langOrigSrc.ToLower() == langFileIn.ToLower())
                            {
                                regularFile(fileIn, origSrcFile, fileOut, b_remnoupd);
                                origSrcFiles.Remove(origSrcFile);
                                proBar_steps.Value++;
                                break;
                            }
                        }
                    }

                    if (proBar_steps.Value == filesIn.Count)
                    {
                        MessageBox.Show("Done!!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.grpBox_set.Enabled = true;
                        this.btn_run.Enabled    = true;
                    }
                    else
                    {
                        var undo = filesIn.Count - proBar_steps.Value;
                        MessageBox.Show(undo.ToString() + " file(s) did not be processed. \r\nPlease check if they have Original Source for reference.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.grpBox_set.Enabled  = true;
                        this.tb_OriginalSrc.Text = "";
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter the valid directory paths.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.tb_path.Text        = "";
                this.tb_OriginalSrc.Text = "";
                this.panel_proBar.Controls.Clear();
            }
        }
Example #19
0
        private void btn_run_Click(object sender, EventArgs e)
        {
            int    int_moveCount  = 0;
            int    int_stillCount = 0;
            String str_basePath   = this.tb_basePath.Text;

            if (Directory.Exists(str_basePath))
            {
                List <FileInfo> l_fi = new List <FileInfo>();
                ClassLib_RML.GetFilesListOfFolder(str_basePath, true, l_fi);
                if (l_fi.Count > 0)
                {
                    ProgressBar pb_move = new ProgressBar();
                    this.panel_Progress.Controls.Add(pb_move);
                    pb_move.Dock    = DockStyle.Fill;
                    pb_move.Value   = 0;
                    pb_move.Minimum = 0;
                    pb_move.Maximum = l_fi.Count;

                    this.grpBox_settings.Enabled = false;
                    this.btn_run.Enabled         = false;
                    foreach (FileInfo fInfo in l_fi)
                    {
                        for (int idx = 0; idx < al_Bundles.Count; idx++)
                        {
                            String str_bundleName = al_Bundles[idx].ToString();
                            String str_folderName = al_Folders[idx].ToString();
                            if (fInfo.Name == str_bundleName)
                            {
                                if (str_folderName != "N/A")
                                {
                                    String str_newPath = Path.Combine(fInfo.DirectoryName, str_folderName);
                                    str_newPath = Path.Combine(str_newPath, "ForTrans");
                                    if (!Directory.Exists(str_newPath))
                                    {
                                        Directory.CreateDirectory(str_newPath);
                                    }

                                    str_newPath = Path.Combine(str_newPath, fInfo.Name);
                                    if (File.Exists(str_newPath))
                                    {
                                        File.Delete(str_newPath);
                                    }

                                    fInfo.MoveTo(str_newPath);
                                    int_moveCount++;
                                    break;
                                }
                            }
                        }
                        pb_move.Value += 1;
                    }
                    int_stillCount = l_fi.Count - int_moveCount;
                    MessageBox.Show("Total Count: " + l_fi.Count.ToString() + "\r\nMoved Count: " + int_moveCount.ToString() + "\r\nNot Moved Count: " + int_stillCount.ToString(), "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.grpBox_settings.Enabled = true;
                    this.panel_Progress.Controls.Clear();
                }
                else
                {
                    MessageBox.Show("Can not find files in the Base Path!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Can not find the path:\r\n" + str_basePath, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }