Пример #1
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);
        }
Пример #2
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);
        }