Beispiel #1
0
        private string[] createProjectScope(BaseExtendable mtdProject, IMTDService service, WSProjectGroup projectGroup, string projName, string projDescription, WSLocale[] locales, string[] attachedFile, WSClient client, WSProjectType projectType)
        {
            string retVal = null;

            string[] custom = null;
            string   debugLine;
            string   pNum = "";

            EntityVersion newVersion = new EntityVersion();

            string[] entityIIDArray = createQuoteSectionAndAssessment(service, mtdProject, newVersion, projName, projDescription);
            string   mtdProjID      = mtdProject.OID; //to be used for project tracking code
            string   WSProjID       = projectGroup.getId;

//              TODO: the project tracking code should be the identifier for the Quote/Assessment relationship and the project number. As well as the WS project number.
            string projectTrackingCode = mtdProjID + "_" + WSProjID;

            entityIIDArray[2] = mtdProjID;
            entityIIDArray[3] = WSProjID;

            debugLine = DateTime.Now + " Project tracking code: " + projectTrackingCode;  WriteDebugfile(debugLine);
            debugLine = DateTime.Now + " Entiry Array code: " + entityIIDArray[0] + ", " + entityIIDArray[1]; WriteDebugfile(debugLine);

            return(entityIIDArray);
        }
Beispiel #2
0
    private static string BuildTitle(Task emailTask, IMTDService service)
    {
        string retVal = "";

        retVal = emailTask.Task_CID.GetExternalText() + "; ";

        Base.Attribute projectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROJECT"));
        if (projectAttr != null)
        {
            BaseExtendable project = new BaseExtendable(CodeTranslator.Find("ENTITY_TYPE", "PROJECT").Code_IID);
            project.Entity_IID = (int)projectAttr.Value;
            project            = (BaseExtendable)service.Load(project);
            service.LoadAttributes(project);

            Base.Attribute contactAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "CONTACT"));
            if (contactAttr != null)
            {
                Contact targetContact = new Contact((int)contactAttr.Value);
                targetContact = (Contact)service.Load(targetContact);
                retVal       += targetContact.Customer_Name + "; ";

                /*
                 * CustomerSite targetSite = new CustomerSite(targetContact.Site_IID);
                 * targetSite = (CustomerSite)service.Load(targetSite);
                 * Customer targetCustomer = new Customer(targetSite.Customer_IID);
                 * targetCustomer = (Customer)service.Load(targetCustomer);
                 * retVal += targetCustomer.Name + "; ";
                 */
            }

            retVal += project.Description + "; ";

            Base.Attribute projectNumAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"));
            if (projectNumAttr != null)
            {
                retVal += "P#:" + (string)projectNumAttr.Value;
            }
            else
            {
                retVal += "Q#:" + project.OID;
            }
        }
        else
        {
            Base.Attribute prospectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROSPECT"));
            if (prospectAttr != null)
            {
                int          prospectIID = (int)prospectAttr.Value;
                Prospect     propect     = service.LoadProspect(prospectIID);
                CustomerSite site        = service.LoadCustomerSite(propect.Site_IID);
                Customer     cust        = service.LoadCustomer(site.Customer_IID);
                retVal += " " + propect.First_Name + " " + propect.Last_Name + " (" + cust.Name + ")";
            }
        }

        return(retVal);
    }
Beispiel #3
0
        private string[] createQuoteSectionAndAssessment(IMTDService service, BaseExtendable m_project, EntityVersion newVersion, string projName, string projDescription)
        {
            //Quote section
            string[]       returnValue = new string[4];
            BaseExtendable newQuote    = new BaseExtendable(Code.Find(AppCodes.QUOTE_TARGET_TYPE).CID);

            newQuote.Description = projName;
            service.Store(newQuote);


            newVersion.Target_IID      = newQuote.Entity_IID;
            newVersion.Target_Type_CID = Code.Find(AppCodes.QUOTE_TARGET_TYPE);
            newVersion.Version         = "1.0";
            newVersion.Released        = true;
            service.Store(newVersion);

            EntityRelation newRelation = new EntityRelation(Code.Find(AppCodes.QUOTE_TARGET_TYPE));

            newRelation.Entity_IID_1         = m_project.Entity_IID;
            newRelation.Entity_IID_2         = newQuote.Entity_IID;
            newRelation.Entity_2_Version_IID = newVersion.Entity_Version_IID;
            returnValue[0] = Convert.ToString(newVersion.Entity_Version_IID);
            service.Store(newRelation);

            //Assessment
            BaseExtendable newAssessment = new BaseExtendable(Code.Find(AppCodes.ASSESSMENT_TARGET_TYPE).CID);

            newAssessment.Description = projName;
            service.Store(newAssessment);

            EntityRelation newRelation2 = new EntityRelation(Code.Find(AppCodes.ASSESSMENT_TARGET_TYPE));

            newRelation2.Entity_IID_1 = m_project.Entity_IID;
            newRelation2.Entity_IID_2 = newAssessment.Entity_IID;
            returnValue[1]            = Convert.ToString(newAssessment.Entity_IID);
            service.Store(newRelation2);

            return(returnValue);
        }
Beispiel #4
0
    private static string BuildHeader(Task emailTask, IMTDService service)
    {
        string retVal = "<strong>Task Information</strong><br>";

        Base.Attribute projectAttr = emailTask.Attributes.Find(CodeTranslator.Find("TASK_ATTR", "PROJECT"));
        if (projectAttr != null)
        {
            BaseExtendable project = new BaseExtendable(CodeTranslator.Find("ENTITY_TYPE", "PROJECT").Code_IID);
            project.Entity_IID = (int)projectAttr.Value;
            project            = (BaseExtendable)service.Load(project);
            service.LoadAttributes(project);

            retVal += "Quote Number: " + project.OID + "<br>";

            Base.Attribute projectNumAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"));
            if (projectNumAttr != null)
            {
                retVal += "Project Number: " + (string)projectNumAttr.Value + "<br>";
            }

            retVal += "Description: " + project.Description + "<br>";

            Base.Attribute contactAttr = project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "CONTACT"));
            if (contactAttr != null)
            {
                Contact targetContact = new Contact((int)contactAttr.Value);
                targetContact = (Contact)service.Load(targetContact);
                retVal       += "Company: " + targetContact.Customer_Name + "<br>";

                /*
                 * CustomerSite targetSite = new CustomerSite(targetContact.Site_IID);
                 * targetSite = (CustomerSite)service.Load(targetSite);
                 * Customer targetCustomer = new Customer(targetSite.Customer_IID);
                 * targetCustomer = (Customer)service.Load(targetCustomer);
                 * retVal += "Company: " + targetCustomer.Name + "<br>";
                 */
            }
        }

        retVal += "Task Status: " + emailTask.Task_Status_CID.GetExternalText() + "<br>";


        UserRole createRole = service.LoadUserRole(emailTask.Created_User_Role_IID);

        retVal += "Task Created By: " + createRole.User.DisplayName + "<br>";

        if (emailTask.Pending_User_Role_IID != -1)
        {
            UserRole pendingRole = service.LoadUserRole(emailTask.Pending_User_Role_IID);
            retVal += "Task Pending Acceptance: " + pendingRole.User.DisplayName + "<br>";
        }
        if (emailTask.Current_User_Role_IID != -1)
        {
            UserRole currentRole = service.LoadUserRole(emailTask.Current_User_Role_IID);
            retVal += "Task Owned By: " + currentRole.User.DisplayName + "<br>";
        }

        retVal += "<hr><br>";

        return(retVal);
    }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
        public BaseExtendable createMTDQuote(int contact_iid, string projDesc, TMAMessage msg, IMTDService svc, UserSession us, Guid mtdGUID, int srcLangCID, int[] targetLangCIDs)
        {
            BaseExtendable newQuote = new BaseExtendable(Code.Find(AppCodes.PROJECT_TARGET_TYPE).CID);

            if (msg.name != null)
            {
                newQuote.Description = msg.name;
            }
            else
            {
                newQuote.Description = projDesc;
            }
            newQuote.OID = svc.NextSequenceNumber(true);
            svc.Store(newQuote);
            ///// Add Attributes
            /////////////////////////////////////////////////////////////////////////////////////

            //           int contact_iid = Convert.ToInt32(ConfigurationSettings.AppSettings["CONTACT_IID"]);

            Contact      contact        = svc.LoadContact(contact_iid);
            CustomerSite site           = svc.LoadCustomerSite(contact.Site_IID);
            int          salesPersonIID = site.Sales_Employee_IID;

            if (salesPersonIID == -1)
            {
                salesPersonIID = us.Current_User.Employee.Employee_IID; // vilma
            }

            Base.Attribute salesAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SALESPERSON"), salesPersonIID);
            salesAttr.SetParent(newQuote.Attributes);

            Base.Attribute contactAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "CONTACT"), contact_iid);
            contactAttr.SetParent(newQuote.Attributes);
            // msg.status ='approved"
            Base.Attribute statusAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "STATUS"), Code.Find(10033));
            statusAttr.SetParent(newQuote.Attributes);
            // Quoted
            int perCt = 10;

            Base.Attribute pmPercentAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PM_PERCENT"), perCt);
            pmPercentAttr.SetParent(newQuote.Attributes);

            decimal internalRate = 35;

            Base.Attribute internalRateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BASE_INTERNAL_RATE"), internalRate);
            internalRateAttr.SetParent(newQuote.Attributes);

            Base.Attribute sourceAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SOURCE_LANG"), Code.Find(srcLangCID));
            sourceAttr.SetParent(newQuote.Attributes);
            int targetCID;
            int numLangs = targetLangCIDs.Length;

            for (int i = 0; i < numLangs; i++)
            {
                targetCID = targetLangCIDs[i];
                if (targetCID > 0)
                {
                    Base.Attribute targetLang = newQuote.Attributes.Add(CodeTranslator.Find("CTYPE", "LOC"), Code.Find(targetCID), 0);
                    targetLang.SetParent(newQuote.Attributes);
                }
            }

            /*
             * Base.Attribute budgetAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BUDGET"), this.BudgetCheckBox.Checked);
             * budgetAttr.SetParent(newQuote.Attributes);
             * Base.Attribute rushAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "RUSH_JOB"), this.RushCheckBox.Checked);
             * rushAttr.SetParent(newQuote.Attributes);
             * Base.Attribute reverseAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "LANGUAGES_REVERSED"), this.ReverseCheckBox.Checked);
             * reverseAttr.SetParent(newQuote.Attributes);
             * Base.Attribute cleanAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PRE_TRANS_CLEANING"), this.CleanCheckBox.Checked);
             * cleanAttr.SetParent(newQuote.Attributes);
             */

            //DateTime dTime = new DateTime(2012, 09, 01, 12, 00, 00);
            //String dTime;
            //dTime = defDTime.ToString("yyyy-MM-dd HH:mm tt");

            Base.Attribute dateQuoteStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_START_DT"), DateTime.Now);
            dateQuoteStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAssessStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_START_DT"), DateTime.Now);
            dateAssessStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateQuoteDueeAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_DUE_DT"), DateTime.Now.AddDays(1));
            dateQuoteDueeAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAsessDueAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), DateTime.Now.AddDays(1));
            dateAsessDueAttr.SetParent(newQuote.Attributes);

            /*
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             */

            svc.Store(newQuote);


            msg.quoteOID = newQuote.OID;
            // Update Quote if first
            ProspectCollection prospects = svc.LoadProspectCollection(Convert.ToInt32("5157"));

            if (prospects.Count > 0)
            {
                Prospect updateProspect = (Prospect)prospects[0];
                if (updateProspect.Quote_IID == -1)
                {
                    updateProspect.Quote_IID = newQuote.Entity_IID;
                    svc.Store(updateProspect);
                }
            }

            BaseExtendable m_project = newQuote;

            return(m_project);
        }
        public BaseExtendable createMTDProject(int contact_iid, string projDesc, TMAMessage msg, IMTDService svc, UserSession us, Guid mtdGUID, int srcLangCID, int[] targetLangCIDs, bool monthlyFlag)
        {
            BaseExtendable newQuote = new BaseExtendable(Code.Find(AppCodes.PROJECT_TARGET_TYPE).CID);

            if (msg.name != null)
            {
                newQuote.Description = msg.name;
            }
            else
            {
                newQuote.Description = projDesc;
            }
            newQuote.OID = svc.NextSequenceNumber(true);
            svc.Store(newQuote);
            ///// Add Attributes
            /////////////////////////////////////////////////////////////////////////////////////

            //           int contact_iid = Convert.ToInt32(ConfigurationSettings.AppSettings["CONTACT_IID"]);

            Contact      contact        = svc.LoadContact(contact_iid);
            CustomerSite site           = svc.LoadCustomerSite(contact.Site_IID);
            int          salesPersonIID = site.Sales_Employee_IID;

            if (salesPersonIID == -1)
            {
                salesPersonIID = us.Current_User.Employee.Employee_IID; // vilma
            }

            Base.Attribute salesAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SALESPERSON"), salesPersonIID);
            salesAttr.SetParent(newQuote.Attributes);

            Base.Attribute contactAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "CONTACT"), contact_iid);
            contactAttr.SetParent(newQuote.Attributes);
            // msg.status ='approved"
            Base.Attribute statusAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "STATUS"), Code.Find(10033));
            statusAttr.SetParent(newQuote.Attributes);
            // Quoted
            decimal perCt = 10;

            Base.Attribute pmPercentAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PM_PERCENT"), perCt);
            pmPercentAttr.SetParent(newQuote.Attributes);

            decimal internalRate = 35;

            Base.Attribute internalRateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BASE_INTERNAL_RATE"), internalRate);
            internalRateAttr.SetParent(newQuote.Attributes);                                            // use default from MTD web config

            Base.Attribute sourceAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "SOURCE_LANG"), Code.Find(srcLangCID));
            sourceAttr.SetParent(newQuote.Attributes);
            int targetCID;
            int numLangs = targetLangCIDs.Length;

            for (int i = 0; i < numLangs; i++)
            {
                targetCID = targetLangCIDs[i];
                if (targetCID > 0)
                {
                    Base.Attribute targetLang = newQuote.Attributes.Add(CodeTranslator.Find("CTYPE", "LOC"), Code.Find(targetCID), 0);
                    targetLang.SetParent(newQuote.Attributes);
                }
            }

            /*
             * Base.Attribute budgetAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "BUDGET"), this.BudgetCheckBox.Checked);
             * budgetAttr.SetParent(newQuote.Attributes);
             * Base.Attribute rushAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "RUSH_JOB"), this.RushCheckBox.Checked);
             * rushAttr.SetParent(newQuote.Attributes);
             * Base.Attribute reverseAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "LANGUAGES_REVERSED"), this.ReverseCheckBox.Checked);
             * reverseAttr.SetParent(newQuote.Attributes);
             * Base.Attribute cleanAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PRE_TRANS_CLEANING"), this.CleanCheckBox.Checked);
             * cleanAttr.SetParent(newQuote.Attributes);
             */

            //DateTime dTime = new DateTime(2012, 09, 01, 12, 00, 00);
            //String dTime;
            //dTime = defDTime.ToString("yyyy-MM-dd HH:mm tt");

            Base.Attribute dateQuoteStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_START_DT"), DateTime.Now);
            dateQuoteStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAssessStartAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_START_DT"), DateTime.Now);
            dateAssessStartAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateQuoteDueeAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "QUOTE_DUE_DT"), DateTime.Now.AddDays(1));
            dateQuoteDueeAttr.SetParent(newQuote.Attributes);

            Base.Attribute dateAsessDueAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), DateTime.Now.AddDays(1));
            dateAsessDueAttr.SetParent(newQuote.Attributes);

            /*
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "ASSESS_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             *
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             * Base.Attribute dateAttr = newQuote.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_DUE_DT"), dTime);
             *  dateAttr.SetParent(newQuote.Attributes);
             */

            svc.Store(newQuote);


            msg.quoteOID = newQuote.OID;



            //convert Quote to Project
            string projectNum = svc.NextSequenceNumber(false);

            BaseExtendable m_project = newQuote;

            Code statusCode = Code.Find("PROJECT_STATUS", "LINGUISTIC");

            statusAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "STATUS"));
            if (statusAttr == null)
            {
                statusAttr = m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "STATUS"), statusCode);
                statusAttr.SetParent(m_project.Attributes);
            }
            else
            {
                statusAttr.Value = statusCode;
            }
            Base.Attribute projStartDate = m_project.Attributes.Add(Code.Find("PROJECT_ATTR", "PROJECT_START_DT"), DateTime.Now);
            projStartDate.SetParent(m_project.Attributes);

            Base.Attribute prodStartDate = m_project.Attributes.Add(Code.Find("PROJECT_ATTR", "PROD_START_DT"), DateTime.Now);
            prodStartDate.SetParent(m_project.Attributes);


            Base.Attribute monthlyAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "MONTHLY"));
            if (monthlyAttr == null && monthlyFlag == true)
            {
                monthlyAttr = m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "MONTHLY"), monthlyFlag);
                monthlyAttr.SetParent(m_project.Attributes);
            }

            m_project.Attributes.Add(CodeTranslator.Find("PROJECT_ATTR", "PROJECTNUM"), projectNum);

            bool itar = false;

            Base.Attribute itarAttr = m_project.Attributes.Find(CodeTranslator.Find("PROJECT_ATTR", "ITAR"));
            if (itarAttr != null)
            {
                itar = ((bool)itarAttr.Value);
                itarAttr.SetParent(m_project.Attributes);
            }

            svc.Store(m_project);
            return(m_project);
        }