Beispiel #1
0
 /// <summary>
 /// Adds a node to the cluster
 /// </summary>
 /// <param name="Node">The node to add</param>
 public void Add(WSNode node)
 {
     if (Nodes.Contains(node))
     {
         return;
     }
     Nodes.Add(node);
     Max = Math.Max(Max, node.Data);
     Min = Math.Min(Min, node.Data);
     if (StartData == Double.MinValue)
     {
         StartData = node.SIDMeasurement;
         StartID = node.SID;
     }
     else if (StartID != node.SID)
     {
         Console.WriteLine("Holy SHit!");
     }
     //TODO: Add neighboring clusters
 }
Beispiel #2
0
 public WSNode(Int32 id, Int32 parent, Int32 objectIndex, Single ox, Single oy, Single oz, Single ow, Single scale, Single x, Single y, Single z, Single type, Byte[] Unknown)
 {
     this.m_ID = id;
     this.m_ObjectIndex = objectIndex;
     this.m_oW = ow;
     this.m_oX = ox;
     this.m_oY = oy;
     this.m_oZ = oz;
     this.m_ParentID = parent;
     this.m_Scale = scale;
     this.m_Type = type;
     this.m_X = x;
     this.m_Y = y;
     this.m_Z = z;
     this.POBCRC = Unknown;
     this.m_Nodes = new List<WSNode>();
     this.m_Parent = null;
 }
Beispiel #3
0
        private void ParseNodes(Byte[] data)
        {
            MemoryStream memoryStream = new MemoryStream(data);
              BinaryReader binaryReader = new BinaryReader(memoryStream);
              while (memoryStream.Position < memoryStream.Length) {
            String FORM = new String(binaryReader.ReadChars(4));
            Byte[] buffer = binaryReader.ReadBytes(4);
            if (Utilities.IsAlpha(buffer)) {
              FORM += new String(Encoding.ASCII.GetChars(buffer));
              buffer = binaryReader.ReadBytes(4); // Length
            }

            String NODEFORM = new String(binaryReader.ReadChars(8));
            binaryReader.ReadBytes(4); // Length

            String t0000DATA = new String(binaryReader.ReadChars(8));
            binaryReader.ReadBytes(4); // Length

            Int32 ID = binaryReader.ReadInt32();
            Int32 Parent = binaryReader.ReadInt32();
            Int32 ObjectIndex = binaryReader.ReadInt32();
            Single oX = binaryReader.ReadSingle();
            Single oY = binaryReader.ReadSingle();
            Single oZ = binaryReader.ReadSingle();
            Single oW = binaryReader.ReadSingle();
            Single Scale = binaryReader.ReadSingle();
            Single X = binaryReader.ReadSingle();
            Single Y = binaryReader.ReadSingle();
            Single Z = binaryReader.ReadSingle();
            Single Type = binaryReader.ReadSingle();
            Byte[] Unknown = binaryReader.ReadBytes(4);

            WSNode wsNode = new WSNode(ID, Parent, ObjectIndex, oX, oY, oZ, oW, Scale, X, Y, Z, Type, Unknown);
            if (wsNode.ParentID == 0) {
              this.m_Nodes.Add(wsNode);
            } else {
              WSNode tempNode = this.FindNodeByID(wsNode.ParentID);
              tempNode.Nodes.Add(wsNode);
              wsNode.Parent = tempNode;
            }
              }

              binaryReader.Close();
              memoryStream.Close();
        }
Beispiel #4
0
 private Int32 GetNextAvailableID(WSNode[] wsNodes)
 {
     Int32 returnValue = 0;
       foreach (WSNode wsNode in wsNodes) {
     returnValue = Math.Max(returnValue, wsNode.ID);
     if (wsNode.Nodes.Count > 0) {
       returnValue = Math.Max(returnValue, GetNextAvailableID(wsNode.Nodes.ToArray()));
     }
       }
       return returnValue;
 }
Beispiel #5
0
 private Int32 GetMaximumObjectIndex(WSNode[] wsNodes)
 {
     Int32 returnValue = 0;
       foreach (WSNode wsNode in wsNodes) {
     returnValue = Math.Max(returnValue, wsNode.ObjectIndex);
     if (wsNode.Nodes.Count > 0) {
       returnValue = Math.Max(returnValue, GetMaximumObjectIndex(wsNode.Nodes.ToArray()));
     }
       }
       return returnValue;
 }
Beispiel #6
0
        private Byte[] GetChildBytes(WSNode[] wsNodes)
        {
            List<Byte> listBytes = new List<Byte>();
              String NODSFORM = ((wsNodes[0].ParentID == 0) ? "NODSFORM" : "FORM");

              foreach (WSNode wsNode in wsNodes) {
            Byte[] childBytes = new Byte[0];
            if (wsNode.Nodes.Count > 0) {
              childBytes = GetChildBytes(wsNode.Nodes.ToArray());
            }

            MemoryStream tempMemoryStream = new MemoryStream();
            BinaryWriter tempBinaryWriter = new BinaryWriter(tempMemoryStream);
            tempBinaryWriter.Write(wsNode.ID);
            tempBinaryWriter.Write(wsNode.ParentID);
            tempBinaryWriter.Write(wsNode.ObjectIndex);
            tempBinaryWriter.Write(wsNode.oX);
            tempBinaryWriter.Write(wsNode.oY);
            tempBinaryWriter.Write(wsNode.oZ);
            tempBinaryWriter.Write(wsNode.oW);
            tempBinaryWriter.Write(wsNode.Scale);
            tempBinaryWriter.Write(wsNode.X);
            tempBinaryWriter.Write(wsNode.Y);
            tempBinaryWriter.Write(wsNode.Z);
            tempBinaryWriter.Write(wsNode.Type);
            tempBinaryWriter.Write(wsNode.POBCRC);

            Byte[] tempNodeBytes = tempMemoryStream.ToArray();
            tempBinaryWriter.Close();
            tempMemoryStream.Close();

            listBytes.AddRange(Encoding.ASCII.GetBytes(NODSFORM));
            listBytes.AddRange(BitConverter.GetBytes(Utilities.EndianFlip(tempNodeBytes.Length + childBytes.Length + 24)));
            listBytes.AddRange(Encoding.ASCII.GetBytes("NODEFORM"));
            listBytes.AddRange(BitConverter.GetBytes(Utilities.EndianFlip(tempNodeBytes.Length + childBytes.Length + 12)));
            listBytes.AddRange(Encoding.ASCII.GetBytes("0000DATA"));
            listBytes.AddRange(BitConverter.GetBytes(Utilities.EndianFlip(tempNodeBytes.Length)));
            listBytes.AddRange(tempNodeBytes);
            if (wsNode.Nodes.Count > 0) {
              listBytes.AddRange(childBytes);
            }

            NODSFORM = "FORM";
              }
              Byte[] nodeBytes = listBytes.ToArray();

              listBytes.Clear();

              return nodeBytes;
        }
Beispiel #7
0
 private WSNode FindChildren(Int32 ID, WSNode[] wsNodes)
 {
     foreach (WSNode wsNode in wsNodes) {
     if (wsNode.ID == ID) {
       return wsNode;
     } else {
       if (wsNode.Nodes.Count > 0) {
     WSNode returnValue = FindChildren(ID, wsNode.Nodes.ToArray());
     if (returnValue != null) {
       return returnValue;
     }
       }
     }
       }
       return null;
 }
Beispiel #8
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);
        }
Beispiel #9
0
 public MSGReportCluster(int Source, int Target, WSNode OriginalNode, int RID)
     : base(Source, Target, CustomMessageType.MSG_REPORT_CLUSTER, 0)
 {
     this.RID = RID;
     this.OriginalNode = OriginalNode;
 }