private string getScope(WSAggregateTranslationScope aggscope, WSAssetTranslationScope scope, WSLocale locale, BaseExtendable mtdProject, IMTDService service, int sequence) { //create Quote Section // TODO: This line should probably go away. We should pass the correct entity relation so that the words counts are loaded in the correct Assessment and Quote sections. EntityVersion newVersion = new EntityVersion(); // I don't think we need this here. We don't want to create a new quote and assessment section for every locale. // createQuoteSectionAndAssessment(service, mtdProject, newVersion, projName, projDescription); TranslationMemory memory = new TranslationMemory(); int total_word_count = 0; if (scope != null) { memory.Words_XTrans += scope.getIceWordCount; memory.Words_Rep += scope.getRepetitionWordCount; memory.Words_100 += scope.getPerfectWordCount; memory.Words_95 += scope.getFuzzyWordCount[0]; memory.Words_85 += scope.getFuzzyWordCount[1]; memory.Words_75 += scope.getFuzzyWordCount[2]; memory.Words_50 += scope.getFuzzyWordCount[3]; memory.Words_NM += scope.getFuzzyWordCount[4]; total_word_count += memory.Words_XTrans + memory.Words_Rep + memory.Words_100 + memory.Words_95 + memory.Words_85 + memory.Words_75 + memory.Words_50 + memory.Words_NM; } else //aggregate scopes for 'auto' quote { foreach (WSAssetTranslationScope ats in aggscope.getScopes) { memory.Words_XTrans += ats.getIceWordCount; memory.Words_Rep += ats.getRepetitionWordCount; memory.Words_100 += ats.getPerfectWordCount; memory.Words_95 += ats.getFuzzyWordCount[0]; memory.Words_85 += ats.getFuzzyWordCount[1]; memory.Words_75 += ats.getFuzzyWordCount[2]; memory.Words_50 += ats.getFuzzyWordCount[3]; memory.Words_NM += ats.getFuzzyWordCount[4]; total_word_count += memory.Words_XTrans + memory.Words_Rep + memory.Words_100 + memory.Words_95 + memory.Words_85 + memory.Words_75 + memory.Words_50 + memory.Words_NM; } } string custIID = ConfigurationSettings.AppSettings["CUSTOMER_IID"]; int customerIID = Convert.ToInt32(custIID); string lang = locale.getName.ToUpper(); lang = lang.Replace(" - UTF8", ""); //Code lang names are LANG_LOCATION unlike lang name in WS lang = lang.Replace(" (", "_"); lang = lang.Replace(")", ""); //Code test = Code.FindAltType("LOC", "ar_EG"); //use alternate_type to find code in MDL Code langCode = Code.Find("LOC", lang); QuoteItem[] existingItems = null; Rate currRate = null; string retValue = null; if (langCode != null) //it should never be null, otherwise what is the translation? { currRate = service.LoadRate(customerIID, langCode); } else { retValue = "missing langCode for " + lang; return(retValue); } // Now do Translation memory Items Code wordCode = Code.Find("QUOTE_UNIT", "WORDS"); if (total_word_count > 0) { // If separate ICE matches selected, split them into their own category, otherwise add them to REPS if (memory.Words_XTrans > 0) { Code repCode = Code.Find("QUOTE_ITEM", "TRANSLATION_ICE"); QuoteItem storeItem = fetchMemItemMatch(newVersion, langCode, repCode, wordCode, memory.Words_XTrans, 0 /* currRate.Reps_Rate */, ref sequence, existingItems); service.Store(storeItem); retValue = retValue + " XTrans Quote IID " + storeItem.Quote_Item_IID; } if ((memory.Words_Rep + memory.Words_100) > 0) { Code repCode = Code.Find("QUOTE_ITEM", "TRANSLATION_REPS"); QuoteItem storeItem = fetchMemItemMatch(newVersion, langCode, repCode, wordCode, (memory.Words_Rep + memory.Words_100), currRate.Reps_Rate, ref sequence, existingItems); service.Store(storeItem); retValue = retValue + " 100 Quote IID " + storeItem.Quote_Item_IID; } if ((memory.Words_95 + memory.Words_85 + memory.Words_75) > 0) { Code fuzzyCode = Code.Find("QUOTE_ITEM", "TRANSLATION_FUZZY"); QuoteItem storeItem = fetchMemItemMatch(newVersion, langCode, fuzzyCode, wordCode, memory.Words_95 + memory.Words_85 + memory.Words_75, currRate.Fuzzy_Rate, ref sequence, existingItems); service.Store(storeItem); retValue = retValue + " 95 Quote IID " + storeItem.Quote_Item_IID; } if ((memory.Words_50 + memory.Words_NM) > 0) { Code newCode = Code.Find("QUOTE_ITEM", "TRANSLATION_NEW"); QuoteItem storeItem = fetchMemItemMatch(newVersion, langCode, newCode, wordCode, memory.Words_50 + memory.Words_NM, currRate.New_Rate, ref sequence, existingItems); service.Store(storeItem); retValue = retValue + " 50 Quote IID " + storeItem.Quote_Item_IID; } } // TODO: This should be imported into the assessment and quote section matching the Entity Relation return(retValue); }
public string[] getScopeInfo(string srcName, string projName, string projDescription, string file, Code srcLocale, Code[] dstLocales, int localeCount, string datatype, BaseExtendable mtdProject, IMTDService service, string WS_Client_Name, string Project_Type, string quoteType, string WSurl, string ProjectNum, string[] projectAttribs) { string retVal = "success"; string FILE_NAME = "473263"; string workgroupName = "default"; string workflowName = "1. Translation Only"; string[] entityIIDArray = new string[4]; string update = "no"; string review = "no"; string client_review = "no"; if (projectAttribs != null) { foreach (string projectAtrib in projectAttribs) { if (projectAtrib == "update") { update = "yes"; } else if (projectAtrib == "review") { review = "yes"; } else if (projectAtrib == "client_review") { client_review = "yes"; } } } projName = projName.Replace("\\", "-"); projName = projName.Replace("/", "-"); projName = projName.Replace(":", "-"); string src_asset = srcName.Replace("\\", "/"); string WSuserName = ConfigurationSettings.AppSettings["WS_USR"]; string WSpwd = ConfigurationSettings.AppSettings["WS_PWD"]; WSContext ctx = new WSContext(WSuserName, WSpwd, WSurl); //http://172.20.20.36:8585/ws/services string debugLine = DateTime.Now + " Got WS context "; WriteDebugfile(debugLine); debugLine = DateTime.Now + " source asset name = " + src_asset; WriteDebugfile(debugLine); WSAisManager aisManager = ctx.getAisManager(); WSUserManager userMgr = ctx.getUserManager(); WSAssetManager assetMgr = ctx.getAssetManager(); WSWorkflowManager workflowMgr = ctx.getWorkflowManager(); WSQuoteManager quoteMgr = ctx.getQuoteManager(); WSScopeManager scopeMgr = ctx.getScopeManager(); Code mdlCode = null; Base.Text codeID = null; int ID = 0; codeID = srcLocale.Description_TID; ID = Convert.ToInt32(codeID.Text_IID.ToString()); debugLine = DateTime.Now + " Got src locale id= " + ID.ToString(); WriteDebugfile(debugLine); WSLocale wslocale = null; if (WS_Client_Name == "Seagate") { wslocale = userMgr.getLocale2(GetSeagateLocID(ID)); } else { wslocale = userMgr.getLocale2(ID); } if (wslocale == null) { throw new System.InvalidOperationException("Invalid src locale"); } try { WSWorkgroup workgroup = userMgr.getWorkgroup(workgroupName); WSWorkflow workflow = workflowMgr.getWorkflow(workflowName); //int pId = 13066; //tokenize dest locales //char[] sep = { ';' }; //String[] res = dstLocales.Split(sep); int numLocs = localeCount; //dstLocales.Length; WSLocale[] locales = null; Code targCode; locales = new WSLocale[numLocs]; for (int i = 0; i < numLocs; i++) { //string localeName = res[i].Trim(); targCode = dstLocales[i]; debugLine = DateTime.Now + " Got target locale code= " + targCode; WriteDebugfile(debugLine); if (targCode != null) { //mdlCode = Code.FindAltType("LOC", localeName); codeID = targCode.Description_TID; debugLine = DateTime.Now + " Got target locale codeID= " + codeID; WriteDebugfile(debugLine); ID = Convert.ToInt32(codeID.Text_IID.ToString()); debugLine = DateTime.Now + " Got target locale id= " + ID.ToString(); WriteDebugfile(debugLine); WSLocale locale = null; if (WS_Client_Name == "Seagate") { locale = userMgr.getLocale2(GetSeagateLocID(ID)); } else { locale = userMgr.getLocale2(ID); } locales[i] = locale; if (locale == null) { throw new System.InvalidOperationException("Error in target locale " + locale); } } else { throw new System.InvalidOperationException("Error in target code " + targCode); } } if (locales[0] == null) { throw new System.InvalidOperationException("No target locales defined"); } // WSClient[] ctxclients = ctx.getUser.get.getClients(); WSWorkflow DefaultWF = null; WSTm DefaultTm = null; WSClient client = userMgr.getClient(WS_Client_Name); WSProjectType projectType = null; // for (int o = 0; o < ctxclients.Length; o++) // { if (!(client == null)) { // client = ctxclients[o]; // WSProjectType[] ctxtypes = client.; String inProjType = Project_Type.Trim(); // inProjType = inProjType.Replace(" ",""); projectType = workflowMgr.getProjectType(inProjType); if (projectType == null) { throw new System.InvalidOperationException("No match in WS found for project type " + Project_Type); } // for (int p = 0; p < ctxtypes.Length; p++) // { // String projType = ctxtypes[p].getName.Trim(); // projType = projType.Replace(" ",""); // //if (String.Compare(projType, Project_Type) == 0) // if (projType.Equals(inProjType) ) // { // projectType = ctxtypes[p]; DefaultWF = projectType.getDefaultWorkflow; DefaultTm = projectType.getDefaultTm; debugLine = DateTime.Now + " Got project type " + projectType.getDisplayString; WriteDebugfile(debugLine); // break; // } // // } } else { throw new System.InvalidOperationException("Client Name does not exist \"" + WS_Client_Name + "\""); } // } string[] attachedFile = new string[1]; attachedFile[0] = src_asset; //file to 'attach' to project string[] custom = new string[2]; custom[0] = null; custom[1] = null; //custom ais properties try { string clientPath = "/Client Files/" + WS_Client_Name; if (clientPath == null) { debugLine = DateTime.Now + " Parameter clientPath cannot be null = " + clientPath; WriteDebugfile(debugLine); throw new System.ArgumentException("Parameter clientPath cannot be null", clientPath); } WSNode clientNode = aisManager.getNode(clientPath); string clientTempPath = clientPath + "/Temp"; if (clientTempPath == null) { aisManager.create(clientTempPath, clientNode); } WSNode clientTempNode = aisManager.getNode(clientTempPath); string aisPath = clientTempPath + "/Upload"; if (aisPath == null) { aisManager.create(aisPath, clientTempNode); } string oldPath = aisPath; WSNode oldNode = aisManager.getNode(oldPath); WSProjectGroup projectGroup = workflowMgr.createProjectGroup(ProjectNum + "-" + WS_Client_Name + "-" + projName, projDescription, locales, attachedFile, client, projectType, custom); WSProject[] theProjects = projectGroup.getProjects; foreach (WSProject theProject in theProjects) { theProject.setAttribute("update", update); theProject.setAttribute("review", review); theProject.setAttribute("creview", client_review); //string theLocaleString = "Target-" + theProject.getTargetLocale.getDisplayString; //WSTask[] theProjectTasks = theProject.getTasks(); //string theNodeString = ""; //string [] theNodeStringArray = theProjectTasks[0].getTargetPath.Split('/'); //int countHolder = 0; //for (int i = theNodeStringArray.Length -1; theNodeStringArray.Length > 0; i--) //{ // if ( theNodeStringArray[i].Equals(theLocaleString)) // { // countHolder = i; // break; // } //} //for (int j=1; j <= countHolder; j++) //{ // theNodeString += "/" + theNodeStringArray[j]; //} } debugLine = DateTime.Now + " Created WS Project Group = " + projectGroup.getId; WriteDebugfile(debugLine); entityIIDArray = createProjectScope(mtdProject, service, projectGroup, projName, projDescription, locales, attachedFile, client, projectType); } catch (Exception e) { debugLine = DateTime.Now + " " + e.Message; WriteDebugfile(debugLine); throw new System.InvalidOperationException(e.Message); } } catch (Exception e) { throw new System.InvalidOperationException(e.Message); } return(entityIIDArray); }