private void getSimpleTMlist() { TMListResponse[] TMlist = RAPI_Session.generateTMlist(); Program.mainWindow.updateProgress(50); Worksheet ws; Workbook wb = new Workbook(); string wsName = "TM list"; if (wb.Worksheets.Count == 0) { ws = wb.Worksheets.Add(wsName); } else { ws = wb.Worksheets[0]; ws.Name = wsName; } WriteHeader(ref ws); int rowCount = 1; foreach (TMListResponse tmListObj in TMlist) { if (client == "***All***" || tmListObj.Client == client) { WriteTM(tmListObj, ref ws, rowCount); rowCount++; } } Helper.autoFitColumns(ref ws); wb.Save(exportFile); Program.mainWindow.updateProgress(100); }
private void SetVisibility() { try { Version version = Assembly.GetEntryAssembly().GetName().Version; lblVersion.Text = "v" + version.Major + "." + version.Minor + "." + version.Build; switch (mode) { case Modes.Zaradekolas: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; string[] WMOptions = new string[] { "TRANSLATION", "FORDÍTÁS", "ÜBERSETZUNG" }; cbWMText.DataSource = WMOptions; cbWMText.DropDownStyle = ComboBoxStyle.DropDown; break; case Modes.Logfile: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; List <string> gridnames = new List <string>(); foreach (string x in Program.grids.Keys) { gridnames.Add(x); } cbWCGrid.DataSource = gridnames; break; case Modes.LangCopier: filePath.Enabled = true; lblFilePath.Text = "Add meg a mappát"; clbLanguageList.Items.Clear(); clbLanguageList.Items.AddRange(LanguageHelper.LanguageNames()); break; case Modes.FolderList: filePath.Enabled = true; lblFilePath.Text = "Add meg a mappát"; break; case Modes.ExcelSplitter: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; break; case Modes.PDF2DOC: filePath.Enabled = true; lblFilePath.Text = "Add meg a mappát"; break; case Modes.TMList: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; WMOptions = new string[] { "Egyszerű lista", "Csoportosított lista" }; cbTMListType.DataSource = WMOptions; cbTMListType.DropDownStyle = ComboBoxStyle.DropDown; break; case Modes.Slashing: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; break; case Modes.TBmgmt: filePath.Enabled = false; lblFilePath.Text = "Add meg a fájlt"; Dictionary <Guid, string> dataSource; dataSource = Helper.TBList2stringArray(RAPI_Session.generateTBlist()); cbTBMgmtTB.DataSource = new BindingSource(dataSource, null); cbTBMgmtTB.ValueMember = "Key"; cbTBMgmtTB.DisplayMember = "Value"; cbTBMgmtTB.DropDownStyle = ComboBoxStyle.DropDown; cbTBMgmtMatching.SelectedIndex = 1; cbTBMgmtCS.SelectedIndex = 1; break; case Modes.Signature: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; break; case Modes.ZaradekFinish: filePath.Enabled = true; lblFilePath.Text = "Add meg a mappát"; break; case Modes.XTRFReport: filePath.Enabled = true; lblFilePath.Text = "Add meg a fájlt"; break; } } catch (Exception ex) { Log.AddLog("UI initialization error: " + ex.Message, true); } }
private void ProcessTB() { int processedEntries = 0; int failedEntries = 0; int tbSize; Dictionary <int, TBEntry> tbEntriesToUpdate = new Dictionary <int, TBEntry>(); int lastID = RAPI_Session.GetLastEntryID(tbID.ToString(), out tbLanguages, out tbSize); lastID = RAPI_Session.GetLastEntryID(tbID.ToString(), out tbLanguages, out tbSize); // need to run two queries due to server bug if (lastID > 0) { foreach (string lang in tbLanguages) { missingTerms.Add(lang, 0); } Program.mainWindow.updateProgress(10); for (int i = 0; i < lastID; i++) { try { TBEntry tbEntry; if (RAPI_Session.getTBEntry(tbID.ToString(), i, out tbEntry)) { processedEntries++; if (CheckEntry(ref tbEntry)) { tbEntriesToUpdate.Add(i, tbEntry); Log.AddLog("TBEntry fixed: " + i + ". Total: " + lastID); } Program.mainWindow.updateProgress(Convert.ToInt32(10 + 90 * processedEntries / tbSize)); } } catch (Exception ex) { Log.AddLog("Error while processing TB entry " + i.ToString() + " - " + ex.Message, true); failedEntries++; } } } foreach (int entryID in tbEntriesToUpdate.Keys) { TBEntry tbe = tbEntriesToUpdate[entryID]; if (!RAPI_Session.UpdateTBEntry(tbID.ToString(), entryID, tbe)) { failedEntries++; } } Log.AddLog(processedEntries.ToString() + " termbase entries processed." + (failedEntries == 0 ? "" : (failedEntries.ToString() + " entries failed")), failedEntries != 0); bool isLangMessageDisplayed = false; foreach (string key in missingTerms.Keys) { if (missingTerms[key] > 0) { Log.AddLog("For " + LanguageHelper.GetLanguageByMemoQCode(key).DisplayName + " " + missingTerms[key] + " term" + (missingTerms[key] == 1 ? " was" : "s were") + " marked with " + substText + ".", false); isLangMessageDisplayed = true; } } if (!isLangMessageDisplayed) { Log.AddLog("No missing terms."); } }
private bool CheckEntry(ref TBEntry tbEntry) { bool result = false; foreach (string tbLang in tbLanguages) { bool isLangInEntry = false; ResourcesAPI_TBEntry.Language entryLangMatching = new ResourcesAPI_TBEntry.Language(); foreach (ResourcesAPI_TBEntry.Language entryLang in tbEntry.Languages) { if (entryLang.language == tbLang) { isLangInEntry = true; entryLangMatching = entryLang; break; } } if (isLangInEntry) { if (entryLangMatching.TermItems == null) { entryLangMatching.TermItems = new List <TermItem>(); } if (entryLangMatching.TermItems.Count == 0) { TermItem tbeTerm = getSubstTermItem(); entryLangMatching.TermItems.Add(tbeTerm); missingTerms[tbLang]++; RAPI_Session.UpdateTBEntry(tbID.ToString(), tbEntry.Id, tbEntry); // This line is to work around the bug that we cannot add multiple terms RAPI_Session.getTBEntry(tbID.ToString(), tbEntry.Id, out tbEntry); // This line is to work around the bug that we cannot add multiple terms result = true; } else if (entryLangMatching.TermItems.Count == 1) { if (entryLangMatching.TermItems[0].Text == searchText) { entryLangMatching.TermItems[0].Text = substText; missingTerms[tbLang]++; result = true; } } } else { ResourcesAPI_TBEntry.Language tbeLang = new ResourcesAPI_TBEntry.Language(); tbeLang.language = tbLang; tbeLang.Id = -1; tbeLang.TermItems = new List <TermItem>(); TermItem tbeTerm = getSubstTermItem(); tbeLang.TermItems.Add(tbeTerm); tbEntry.Languages.Add(tbeLang); missingTerms[tbLang]++; RAPI_Session.UpdateTBEntry(tbID.ToString(), tbEntry.Id, tbEntry); // This line is to work around the bug that we cannot add multiple terms RAPI_Session.getTBEntry(tbID.ToString(), tbEntry.Id, out tbEntry); // This line is to work around the bug that we cannot add multiple terms result = true; } } return(result); }
private void getMergeTMlist() { LanguageHelper.Initialize(); TMListResponse[] TMlist = RAPI_Session.generateTMlist(); Dictionary <string[], ClientTMs> TMGroups = new Dictionary <string[], ClientTMs>(); Dictionary <string[], ClientTMs> sortedTMGroups = new Dictionary <string[], ClientTMs>(); Program.mainWindow.updateProgress(25); foreach (TMListResponse tm in TMlist) { if (tm.Client.Length > 0 && (client == "***All***" || tm.Client == client)) { string[] newid = new string[] { tm.Client, tm.SourceLangCode, tm.TargetLangCode }; string[] existID = null; foreach (string[] id in TMGroups.Keys) { if (tm.Client == TMGroups[id].client && tm.SourceLangCode == TMGroups[id].sLang && tm.TargetLangCode == TMGroups[id].tLang) { existID = id; } } if (existID == null) { ClientTMs newGroup = new ClientTMs(newid); TMGroups.Add(newid, newGroup); TMGroups[newid].TMlist.Add(tm); } else { TMGroups[existID].TMlist.Add(tm); } } } Program.mainWindow.updateProgress(50); IOrderedEnumerable <KeyValuePair <string[], ClientTMs> > linqGroups = from clientTMgroup in TMGroups orderby clientTMgroup.Key[0], clientTMgroup.Key[1], clientTMgroup.Key[2] ascending select clientTMgroup; Worksheet ws; Workbook wb = new Workbook(); string wsName = "TM list"; if (wb.Worksheets.Count == 0) { ws = wb.Worksheets.Add(wsName); } else { ws = wb.Worksheets[0]; ws.Name = wsName; } WriteHeader(ref ws); int rowCount = 0; Program.mainWindow.updateProgress(75); foreach (KeyValuePair <string[], ClientTMs> kvp in linqGroups) { sortedTMGroups.Add(kvp.Key, kvp.Value); } foreach (string[] id in sortedTMGroups.Keys) { if (sortedTMGroups[id].TMlist.Count > 0) { rowCount++; Cell c = ws.Cells[rowCount, 0]; c.Value = sortedTMGroups[id].client + " (" + sortedTMGroups[id].sLang + " > " + sortedTMGroups[id].tLang + ")"; Helper.AddFontColor(c, Color.Purple); rowCount++; sortedTMGroups[id].findMasterTM(); TMListResponse tm = sortedTMGroups[id].getMasterTM(); WriteTM(tm, ref ws, rowCount); FormatLine(tm, rowCount, ref ws); rowCount++; TMListResponse[] resultList = sortedTMGroups[id].getOtherTM(); foreach (TMListResponse tmn in resultList) { WriteTM(tmn, ref ws, rowCount); FormatLine(tmn, rowCount, ref ws); rowCount++; } } } Helper.autoFitColumns(ref ws); wb.Save(exportFile); Program.mainWindow.updateProgress(100); }