Ejemplo n.º 1
0
        /// <summary>
        /// Read the fields from the tagged output of an info command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'info' command</param>
        public void FromGetServerMetaDataCmdTaggedOutput(TaggedObject objectInfo)
        {
            RawData = objectInfo;

            if (objectInfo.ContainsKey("serverName"))
            {
                Name = objectInfo["serverName"];
            }

            if (objectInfo.ContainsKey("serverAddress"))
            {
                Address = new ServerAddress(objectInfo["serverAddress"]);
            }

            if (objectInfo.ContainsKey("serverRoot"))
            {
                Root = objectInfo["serverRoot"];
            }

            if (objectInfo.ContainsKey("serverDate"))
            {
                string   dateTimeString = objectInfo["serverDate"];
                string[] dateTimeArray  = dateTimeString.Split(' ');
                DateTime v;
                DateTime.TryParse(dateTimeArray[0] + " " + dateTimeArray[1], out v);
                Date = v;
                for (int idx = 2; idx < dateTimeArray.Count(); idx++)
                {
                    DateTimeOffset += dateTimeArray[idx] + " ";
                }
                DateTimeOffset = DateTimeOffset.Trim();
            }

            if (objectInfo.ContainsKey("serverUptime"))
            {
                int v;
                int.TryParse(objectInfo["serverUptime"], out v);
                Uptime = v;
            }


            if (objectInfo.ContainsKey("serverVersion"))
            {
                string   serverVersion = objectInfo["serverVersion"];
                string[] info          = serverVersion.Split('/', ' ');
                string   product       = info[0];
                string   platform      = info[1];
                string   major         = info[2];
                string   minor         = info[3];
                char[]   trimChars     = { '(', ')' };
                string   dateString    = info[4] + "-" + info[5] + "-" + info[6];
                dateString = dateString.Trim(trimChars);
                DateTime date = new DateTime(1, 1, 1);
                DateTime.TryParse(dateString, out date);
                Version = new ServerVersion(product, platform, major, minor, date);
            }



            if (objectInfo.ContainsKey("serverLicence"))
            {
                string   lic  = objectInfo["serverLicence"];
                string[] info = lic.Split(' ');
                int      users;
                int.TryParse(info[0], out users);
                DateTime expires;
                DateTime.TryParse(info[2], out expires);
                License = new ServerLicense(users, expires);
            }

            if (objectInfo.ContainsKey("serverLicenceIp"))
            {
                LicenseIp = objectInfo["serverLicenceIp"];
            }

            if (objectInfo.ContainsKey("caseHandling"))
            {
                if (objectInfo["caseHandling"] == "sensitive")
                {
                    CaseSensitive = true;
                }
            }


            if (objectInfo.ContainsKey("unicode"))
            {
                if (objectInfo["unicode"] == "enabled")
                {
                    UnicodeEnabled = true;
                }
            }

            if (objectInfo.ContainsKey("move"))
            {
                if (objectInfo["move"] == "disabled")
                {
                    MoveEnabled = false;
                }
            }
            else
            {
                MoveEnabled = true;;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given tagged output from an "fstat" command instantiate this object.
        /// </summary>
        /// <param name="obj">Tagged output from fstat</param>
        public void FromFstatCmdTaggedData(TaggedObject obj)
        {
            if (obj.ContainsKey("clientFile"))
            {
                string path = obj["clientFile"];
                if (path.StartsWith("//"))
                {
                    ClientPath = new ClientPath(obj["clientFile"]);
                }
                else
                {
                    ClientPath = new ClientPath(obj["clientFile"]);
                    LocalPath  = new LocalPath(obj["clientFile"]);
                }
            }

            if (obj.ContainsKey("path"))
            {
                LocalPath = new LocalPath(obj["path"]);
            }

            if (obj.ContainsKey("depotFile"))
            {
                string p = PathSpec.UnescapePath(obj["depotFile"]);
                DepotPath = new DepotPath(p);
            }

            if (obj.ContainsKey("movedFile"))
            {
                MovedFile = new DepotPath(obj["movedFile"]);
                if (obj.ContainsKey("movedRev"))
                {
                    int movedrev = -1;
                    if (int.TryParse(obj["movedRev"], out movedrev))
                    {
                        MovedRev = movedrev;
                    }
                }
            }

            if (obj.ContainsKey("isMapped"))
            {
                IsMapped = true;
            }

            if (obj.ContainsKey("shelved"))
            {
                Shelved = true;
            }

            if (obj.ContainsKey("headAction"))
            {
                _headAction = obj["headAction"];
            }

            if (obj.ContainsKey("headChange"))
            {
                int r = -1;
                if (int.TryParse(obj["headChange"], out r))
                {
                    HeadChange = r;
                }
            }

            if (obj.ContainsKey("headRev"))
            {
                int r = -1;
                if (int.TryParse(obj["headRev"], out r))
                {
                    HeadRev = r;
                }
            }

            if (obj.ContainsKey("headType"))
            {
                HeadType = new FileType(obj["headType"]);
            }

            if (obj.ContainsKey("headTime"))
            {
                HeadTime = FormBase.ConvertUnixTime(obj["headTime"]);
            }

            if (obj.ContainsKey("headModTime"))
            {
                HeadModTime = FormBase.ConvertUnixTime(obj["headModTime"]);
            }

            if (obj.ContainsKey("haveRev"))
            {
                int r = -1;
                if ((int.TryParse(obj["haveRev"], out r)) && (r > 0))
                {
                    HaveRev = r;
                }
            }

            if (obj.ContainsKey("desc"))
            {
                Desc = obj["desc"];
            }

            if (obj.ContainsKey("digest"))
            {
                Digest = obj["digest"];
            }

            if (obj.ContainsKey("fileSize"))
            {
                long s = -1;
                if (long.TryParse(obj["fileSize"], out s))
                {
                    FileSize = s;
                }
            }

            if (obj.ContainsKey("action"))
            {
                _action = obj["action"];
            }

            if (obj.ContainsKey("type"))
            {
                Type = new FileType(obj["type"]);
            }
            else if (obj.ContainsKey("headType"))
            {
                // If not on mapped in current client, will not have
                //the Type filed so User the HeadType
                Type = new FileType(obj["headType"]);
            }
            else
            {
                Type = new FileType(BaseFileType.Text, FileTypeModifier.None);
            }

            if (obj.ContainsKey("actionOwner"))
            {
                ActionOwner = obj["actionOwner"];
            }

            if (obj.ContainsKey("change"))
            {
                int c = -1;
                if (int.TryParse(obj["change"], out c))
                {
                    Change = c;
                }
                else
                {
                    Change = 0;
                }
            }

            if (obj.ContainsKey("resolved"))
            {
                Resolved = true;
            }

            if (obj.ContainsKey("unresolved"))
            {
                Unresolved = true;
            }

            if (obj.ContainsKey("reresolvable"))
            {
                Reresolvable = true;
            }


            if (obj.ContainsKey("otherLock"))
            {
                OtherLock = true;
            }

            if (obj.ContainsKey("otherOpen"))
            {
                int cnt = 0;
                if (int.TryParse(obj["otherOpen"], out cnt))
                {
                    OtherOpen            = cnt;
                    OtherLockUserClients = new List <string>();
                }

                if (cnt > 0)
                {
                    OtherUsers = new OtherUsers();

                    OtherOpenUserClients = new List <String>();
                    OtherActions         = new List <FileAction>();
                    OtherChanges         = new List <int>();

                    for (int idx = 0; idx < cnt; idx++)
                    {
                        string        key             = String.Format("otherOpen{0}", idx);
                        string        otherClientName = null;
                        OtherFileUser ofi             = null;

                        if (obj.ContainsKey(key))
                        {
                            otherClientName = obj[key];
                            OtherOpenUserClients.Add(otherClientName);
                        }

                        ofi        = OtherUsers[otherClientName];
                        ofi.Client = otherClientName;

                        key = String.Format("otherAction{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            StringEnum <FileAction> otheraction = obj[key];
                            OtherActions.Add(otheraction);
                            ofi.Action = otheraction;
                        }

                        key = String.Format("otherChange{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            int otherchange;
                            if (!int.TryParse(obj[key], out otherchange))
                            {
                                otherchange = 0;
                            }
                            OtherChanges.Add(otherchange);

                            ofi.ChangelistId = otherchange;
                        }

                        key = String.Format("otherLock{0}", idx);

                        if (obj.ContainsKey(key))
                        {
                            string s = obj[key];
                            OtherLockUserClients.Add(s);

                            OtherUsers[s].hasLock = true;
                        }
                    }
                }
            }

            if (obj.ContainsKey("ourLock"))
            {
                OurLock = true;
            }

            if (obj.ContainsKey("resolved") || obj.ContainsKey("unresolved"))
            {
                int idx = 0;
                StringEnum <ResolveAction> resolveaction = ResolveAction.Unresolved;
                FileSpec          resolvebasefile        = null;
                FileSpec          resolvefromfile        = null;
                int               resolvestartfromrev    = -1;
                int               resolveendfromrev      = -1;
                FileResolveAction resolverecord          = null;

                ResolveRecords = new List <FileResolveAction>();

                while (true)
                {
                    string key = String.Format("resolveAction{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        resolveaction = obj[key];
                    }
                    else
                    {
                        break;
                    }

                    key = String.Format("resolveBaseFile{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        string basefile       = obj[key];
                        int    resolvebaserev = -1;
                        int.TryParse(obj[String.Format("resolveBaseRev{0}", idx)], out resolvebaserev);
                        resolvebasefile = new FileSpec(new DepotPath(basefile), new Revision(resolvebaserev));
                    }
                    else
                    {
                        break;
                    }

                    key = String.Format("resolveFromFile{0}", idx);

                    if (obj.ContainsKey(key))
                    {
                        string fromfile = obj[key];
                        int    startfromrev, endfromrev = -1;
                        int.TryParse(obj[String.Format("resolveStartFromRev{0}", idx)], out startfromrev);
                        int.TryParse(obj[String.Format("resolveEndFromRev{0}", idx)], out endfromrev);
                        resolvefromfile = new FileSpec(new DepotPath(fromfile),
                                                       new VersionRange(new Revision(startfromrev), new Revision(endfromrev)));
                    }
                    else
                    {
                        break;
                    }

                    resolverecord = new FileResolveAction
                                        (resolveaction, resolvebasefile, resolvefromfile, resolvestartfromrev, resolveendfromrev);
                    ResolveRecords.Add(resolverecord);

                    idx++;
                }
            }

            Attributes = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attr-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("attr-", "");
                    Attributes.Add(atrib, val);
                }
            }

            AttributesProp = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attrProp-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("attrProp-", "");
                    AttributesProp.Add(atrib, val);
                }
            }

            AttributeDigests = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("attrDigest-"))
                {
                    object val         = obj[key];
                    string atribDigest = key.Replace("attrDigest-", "");
                    AttributeDigests.Add(atribDigest, val);
                }
            }

            OpenAttributes = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("openattr-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("openattr-", "");
                    OpenAttributes.Add(atrib, val);
                }
            }

            OpenAttributesProp = new Dictionary <string, object>();

            foreach (string key in obj.Keys)
            {
                if (key.StartsWith("openattrProp-"))
                {
                    object val   = obj[key];
                    string atrib = key.Replace("openattrProp-", "");
                    OpenAttributesProp.Add(atrib, val);
                }
            }

            if (obj.ContainsKey("totalFileCount"))
            {
                long s = -1;
                if (long.TryParse(obj["totalFileCount"], out s))
                {
                    TotalFileCount = s;
                }
            }

            if (obj.ContainsKey("dir"))
            {
                Directory = PathSpec.UnescapePath(obj["dir"]);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read the fields from the tagged output of a 'streams' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'streams' command</param>
        /// <param name="offset">Date processing</param>
        /// <param name="dst_mismatch">DST for date</param>
        public void FromStreamsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
            }

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Update"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Updated = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime UTC = FormBase.ConvertUnixTime(objectInfo["Access"]);
                DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                            DateTimeKind.Unspecified);
                Accessed = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
            }

            if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
            }

            int    idx = 0;
            string key = String.Format("Paths{0}", idx);

            if (objectInfo.ContainsKey(key))
            {
                ViewMap Paths                  = new ViewMap();
                StringEnum <MapType> map       = null;
                PathSpec             LeftPath  = null;
                PathSpec             RightPath = null;
                MapEntry             Path      = new MapEntry(map, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    map       = p[0];
                    LeftPath  = new DepotPath(p[1]);
                    RightPath = new DepotPath(p[2]);
                    Path      = new MapEntry(map, LeftPath, RightPath);
                    Paths.Add(Path);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Remapped{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                ViewMap  Remapped  = new ViewMap();
                PathSpec LeftPath  = null;
                PathSpec RightPath = null;
                MapEntry Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath  = new DepotPath(p[0]);
                    RightPath = new DepotPath(p[1]);
                    Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Remapped.Add(Remap);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                List <FileSpec> Ignored = new List <FileSpec>();
                FileSpec        ignore  = new FileSpec(new DepotPath(string.Empty), null);

                while (objectInfo.ContainsKey(key))
                {
                    string i = (objectInfo[key]);
                    ignore = new FileSpec(new DepotPath(i), null);
                    Ignored.Add(ignore);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Read the fields from the tagged output of a 'stream' command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'stream' command</param>
        public void FromStreamCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
            }

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Update"], out v);
                Updated = v;
            }

            if (objectInfo.ContainsKey("Access"))
            {
                DateTime v = DateTime.MinValue;
                DateTime.TryParse(objectInfo["Access"], out v);
                Accessed = v;
            }

            if (objectInfo.ContainsKey("Owner"))
            {
                OwnerName = objectInfo["Owner"];
            }

            if (objectInfo.ContainsKey("Name"))
            {
                Name = objectInfo["Name"];
            }

            if (objectInfo.ContainsKey("Parent"))
            {
                Parent = new DepotPath(objectInfo["Parent"]);
            }

            if (objectInfo.ContainsKey("baseParent"))
            {
                BaseParent = new DepotPath(objectInfo["baseParent"]);
            }

            if (objectInfo.ContainsKey("Type"))
            {
                _type = (objectInfo["Type"]);
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                String optionsStr = objectInfo["Options"];
                _options = optionsStr;
            }

            if (objectInfo.ContainsKey("firmerThanParent"))
            {
                FirmerThanParent = objectInfo["firmerThanParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsToParent"))
            {
                ChangeFlowsToParent = objectInfo["changeFlowsToParent"];
            }

            if (objectInfo.ContainsKey("changeFlowsFromParent"))
            {
                ChangeFlowsFromParent = objectInfo["changeFlowsFromParent"];
            }

            int    idx = 0;
            string key = String.Format("Paths{0}", idx);

            if (objectInfo.ContainsKey(key))
            {
                Paths = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    Paths.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("Paths{0}", idx);
                }
            }
            else
            {
                Paths = null;
            }

            idx = 0;
            key = String.Format("Remapped{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                Remapped = new ViewMap();
                PathSpec LeftPath  = new ClientPath(string.Empty);
                PathSpec RightPath = new ClientPath(string.Empty);
                MapEntry Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath  = new ClientPath(p[0]);
                    RightPath = new ClientPath(p[1]);
                    Remap     = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Remapped.Add(Remap);
                    idx++;
                    key = String.Format("Remapped{0}", idx);
                }
            }
            else
            {
                Remapped = null;
            }

            idx = 0;
            key = String.Format("Ignored{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                Ignored = new ViewMap();
                PathSpec LeftPath  = new ClientPath(string.Empty);
                PathSpec RightPath = new ClientPath(string.Empty);
                MapEntry Ignore    = new MapEntry(MapType.Include, LeftPath, RightPath);

                while (objectInfo.ContainsKey(key))
                {
                    string   l = (objectInfo[key]);
                    string[] p = l.Split(' ');
                    LeftPath = new ClientPath(p[0]);
                    if (p.Length > 1)
                    {
                        RightPath = new ClientPath(p[1]);
                    }
                    Ignore = new MapEntry(MapType.Include, LeftPath, RightPath);
                    Ignored.Add(Ignore);
                    idx++;
                    key = String.Format("Ignored{0}", idx);
                }
            }
            else
            {
                Ignored = null;
            }

            idx = 0;
            key = String.Format("View{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                View = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    View.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("View{0}", idx);
                }
            }
            else
            {
                View = null;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a FormSpec from the tagged output of the 'spec' command
        /// </summary>
        /// <param name="obj">Tagged object returned by the 'spec' command</param>
        /// <returns></returns>
        public static FormSpec FromSpecCmdTaggedOutput(TaggedObject obj)
        {
            FormSpec val = new FormSpec();
            int      idx = 0;

            // Check for each property in the tagged data, and use it to set the
            // appropriate filed in the object

            string key = String.Format("Fields{0}", idx);

            while (obj.ContainsKey(key))
            {
                string fieldDef = obj[key];
                val.Fields.Add(SpecField.FromSpecCmdTaggedData(fieldDef));
                key = String.Format("Fields{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Fields{0}", idx);
            while (obj.ContainsKey(key))
            {
                string   line  = obj[key];
                string[] parts = line.Split(new char[] { ' ' }, 3);
                val.FieldMap[parts[1]] = line;
                key = String.Format("Fields{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Words{0}", idx);
            while (obj.ContainsKey(key))
            {
                string word = obj[key];
                val.Words.Add(word);
                key = String.Format("Words{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Formats{0}", idx);
            while (obj.ContainsKey(key))
            {
                string word = obj[key];
                val.Formats.Add(word);
                key = String.Format("Formats{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Values{0}", idx);
            while (obj.ContainsKey(key))
            {
                string   line  = obj[key];
                string[] parts = line.Split(new char[] { ' ' }, 2);
                val.Values[parts[0]] = parts[1];
                key = String.Format("Values{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Presets{0}", idx);
            while (obj.ContainsKey(key))
            {
                string   line  = obj[key];
                string[] parts = line.Split(new char[] { ' ' }, 2);
                val.Presets[parts[0]] = parts[1];
                key = String.Format("Presets{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Openable{0}", idx);
            while (obj.ContainsKey(key))
            {
                string word = obj[key];
                val.Openable.Add(word);
                key = String.Format("Openable{0}", ++idx);
            }

            idx = 0;
            key = String.Format("Maxwords{0}", idx);
            while (obj.ContainsKey(key))
            {
                string word = obj[key];
                val.Maxwords.Add(word);
                key = String.Format("Maxwords{0}", ++idx);
            }

            if (obj.ContainsKey("Comments"))
            {
                val.Comments = obj["Comments"];
            }

            return(val);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="obj">Source object</param>
 public TaggedObject(TaggedObject obj) : base(obj)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Fill in the fields for the changelist using the tagged output of a "change' command
 /// </summary>
 /// <param name="objectInfo">The tagged output of a "change' command</param>
 /// <param name="offset">Offset within array</param>
 /// <param name="dst_mismatch">Daylight savings time for conversions</param>
 public void FromChangeCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
 {
     FromChangeCmdTaggedOutput(objectInfo, false, offset, dst_mismatch);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Fill in the fields for the changelist using the tagged output of a "change' command
        /// </summary>
        /// <param name="objectInfo">The tagged output of a "change' command</param>
        /// <param name="GetShelved">Access shelved files or not</param>
        /// <param name="offset">Offset within array</param>
        /// <param name="dst_mismatch">Daylight savings time for conversions</param>
        public void FromChangeCmdTaggedOutput(TaggedObject objectInfo, bool GetShelved, string offset, bool dst_mismatch)
        {
            // need to check for tags starting with upper and lower case, it the 'change' command's
            //  output the tags start with an uppercase character whereas with the 'changes' command
            //  they start with a lower case character, i.e. "Change" vs "change"

            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Change"))
            {
                int v = -1;
                if (int.TryParse(objectInfo["Change"], out v))
                {
                    Id = v;
                }
            }
            else if (objectInfo.ContainsKey("change"))
            {
                int v = -1;
                if (int.TryParse(objectInfo["change"], out v))
                {
                    Id = v;
                }
            }

            if (objectInfo.ContainsKey("Date"))
            {
                DateTime v;
                DateTime.TryParse(objectInfo["Date"], out v);
                ModifiedDate = v;
            }
            else if (objectInfo.ContainsKey("time"))
            {
                long v;
                if (long.TryParse(objectInfo["time"], out v))
                {
                    DateTime UTC = FormBase.ConvertUnixTime(v);
                    DateTime GMT = new DateTime(UTC.Year, UTC.Month, UTC.Day, UTC.Hour, UTC.Minute, UTC.Second,
                                                DateTimeKind.Unspecified);
                    ModifiedDate = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
                }
            }
            if (objectInfo.ContainsKey("Client"))
            {
                ClientId = objectInfo["Client"];
            }
            else if (objectInfo.ContainsKey("client"))
            {
                ClientId = objectInfo["client"];
            }

            if (objectInfo.ContainsKey("User"))
            {
                OwnerName = objectInfo["User"];
            }
            else if (objectInfo.ContainsKey("user"))
            {
                OwnerName = objectInfo["user"];
            }

            if (objectInfo.ContainsKey("ImportedBy"))
            {
                ImportedBy = objectInfo["ImportedBy"];
            }
            else if (objectInfo.ContainsKey("importedby"))
            {
                ImportedBy = objectInfo["importedby"];
            }
            else if (objectInfo.ContainsKey("Importedby"))
            {
                ImportedBy = objectInfo["Importedby"];
            }
            else if (objectInfo.ContainsKey("importedBy"))
            {
                ImportedBy = objectInfo["importedBy"];
            }

            if (objectInfo.ContainsKey("Identity"))
            {
                Identity = objectInfo["Identity"];
            }
            else if (objectInfo.ContainsKey("changeIdentity"))
            {
                Identity = objectInfo["changeIdentity"];
            }

            if (objectInfo.ContainsKey("Stream"))
            {
                Identity = objectInfo["Stream"];
            }
            else if (objectInfo.ContainsKey("stream"))
            {
                Identity = objectInfo["stream"];
            }

            if (objectInfo.ContainsKey("Status"))
            {
                Pending = true;
                String v = objectInfo["Status"];
                if (v == "submitted")
                {
                    Pending = false;
                }
            }
            else if (objectInfo.ContainsKey("status"))
            {
                Pending = true;
                String v = objectInfo["status"];
                if (v == "submitted")
                {
                    Pending = false;
                }
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
            }
            else if (objectInfo.ContainsKey("desc"))
            {
                Description = objectInfo["desc"];
            }
            char[] array = { '\r', '\n' };
            Description = Description.TrimEnd(array);
            Description = Description.Replace("\r", "");
            Description = Description.Replace("\n", "\r\n");

            if (objectInfo.ContainsKey("Type"))
            {
                _type = objectInfo["Type"];
            }
            else if (objectInfo.ContainsKey("changeType"))
            {
                _type = objectInfo["changeType"];
            }

            if (objectInfo.ContainsKey("shelved"))
            {
                Shelved = true;
            }

            int    idx = 0;
            String key = "Jobs0";

            if (objectInfo.ContainsKey(key))
            {
                idx  = 1;
                Jobs = new Dictionary <string, string>();
                do
                {
                    Jobs.Add(objectInfo[key], null);
                    key = String.Format("Jobs{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
            else
            {
                key = "jobs0";
                if (objectInfo.ContainsKey(key))
                {
                    idx  = 1;
                    Jobs = new Dictionary <string, string>();
                    do
                    {
                        Jobs.Add(objectInfo[key], null);
                        key = String.Format("jobs{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                }
            }

            key = "Files0";
            if (objectInfo.ContainsKey(key))
            {
                idx   = 1;
                Files = new List <FileMetaData>();
                do
                {
                    FileMetaData file = new FileMetaData();
                    file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                    Files.Add(file);
                    key = String.Format("Files{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
            else
            {
                key = "files0";
                if (objectInfo.ContainsKey(key))
                {
                    idx = 1;
                    SimpleList <FileMetaData> files = new SimpleList <FileMetaData>();
                    do
                    {
                        FileMetaData file = new FileMetaData();
                        file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        Files.Add(file);
                        key = String.Format("files{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    Files = (List <FileMetaData>)files;
                }
            }
            if (GetShelved)
            {
                key = "depotFile0";
                String actionKey = "action0";
                String typeKey   = "type0";
                String revKey    = "rev0";
                String sizeKey   = "fileSize0";
                String digestKey = "digest0";

                if (objectInfo.ContainsKey(key))
                {
                    SimpleList <ShelvedFile> shelvedFiles = new SimpleList <ShelvedFile>();
                    idx = 1;
                    do
                    {
                        ShelvedFile file = new ShelvedFile();
                        file.Path = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        StringEnum <FileAction> action = objectInfo[actionKey];
                        file.Action = action;
                        file.Type   = new FileType(objectInfo[typeKey]);
                        string revstr = objectInfo[revKey];
                        if (revstr == "none")
                        {
                            revstr = "0";
                        }
                        int rev = Convert.ToInt32(revstr);
                        file.Revision = rev;

                        if (objectInfo.ContainsKey(sizeKey))
                        {
                            long size = -1;
                            long.TryParse(objectInfo[sizeKey], out size);
                            file.Size = size;
                        }

                        if (objectInfo.ContainsKey(digestKey))
                        {
                            file.Digest = objectInfo[digestKey];
                        }

                        shelvedFiles.Add(file);

                        key       = String.Format("depotFile{0}", idx);
                        actionKey = String.Format("action{0}", idx);
                        typeKey   = String.Format("type{0}", idx);
                        revKey    = String.Format("rev{0}", idx);
                        sizeKey   = String.Format("fileSize{0}", idx);
                        digestKey = String.Format("digest{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    ShelvedFiles = (List <ShelvedFile>)shelvedFiles;
                }
            }
            else
            {
                key = "depotFile0";
                String actionKey = "action0";
                String typeKey   = "type0";
                String revKey    = "rev0";
                String sizeKey   = "fileSize0";
                String digestKey = "digest0";

                if (objectInfo.ContainsKey(key))
                {
                    idx = 1;
                    SimpleList <FileMetaData> fileList = new SimpleList <FileMetaData>();
                    do
                    {
                        FileMetaData file = new FileMetaData();
                        file.DepotPath = new DepotPath(PathSpec.UnescapePath(objectInfo[key]));
                        StringEnum <FileAction> action = objectInfo[actionKey];
                        file.Action = action;
                        file.Type   = new FileType(objectInfo[typeKey]);
                        string revstr = objectInfo[revKey];
                        int    rev    = Convert.ToInt32(revstr);
                        file.HeadRev = rev;

                        if (objectInfo.ContainsKey(sizeKey))
                        {
                            long size = -1;
                            long.TryParse(objectInfo[sizeKey], out size);
                            file.FileSize = size;
                        }

                        if (objectInfo.ContainsKey(digestKey))
                        {
                            file.Digest = objectInfo[digestKey];
                        }

                        fileList.Add(file);

                        key       = String.Format("depotFile{0}", idx);
                        actionKey = String.Format("action{0}", idx);
                        typeKey   = String.Format("type{0}", idx);
                        revKey    = String.Format("rev{0}", idx);
                        sizeKey   = String.Format("fileSize{0}", idx);
                        digestKey = String.Format("digest{0}", idx++);
                    } while (objectInfo.ContainsKey(key));
                    Files = (List <FileMetaData>)fileList;
                }
            }

            key = "job0";
            String statKey = "jobstat0";

            if (objectInfo.ContainsKey(key))
            {
                idx  = 1;
                Jobs = new Dictionary <string, string>();
                do
                {
                    string jobStatus = string.Empty;
                    string jobId     = objectInfo[key];
                    if (objectInfo.ContainsKey(statKey))
                    {
                        jobStatus = objectInfo[statKey];
                    }
                    Jobs.Add(jobId, jobStatus);
                    key     = String.Format("job{0}", idx);
                    statKey = String.Format("jobstat{0}", idx++);
                } while (objectInfo.ContainsKey(key));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Read the fields from the tagged output of a group command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'user' command</param>
        public void FromGroupCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

            if (objectInfo.ContainsKey("Group"))
            {
                Id = objectInfo["Group"];
            }

            if (objectInfo.ContainsKey("MaxResults"))
            {
                int v = -1;
                int.TryParse(objectInfo["MaxResults"], out v);
                MaxResults = v;
            }

            if (objectInfo.ContainsKey("MaxScanRows"))
            {
                int v = -1;
                int.TryParse(objectInfo["MaxScanRows"], out v);
                MaxScanRows = v;
            }

            if (objectInfo.ContainsKey("MaxLockTime"))
            {
                int v = -1;
                int.TryParse(objectInfo["MaxLockTime"], out v);
                MaxLockTime = v;
            }

            if (objectInfo.ContainsKey("MaxOpenFiles"))
            {
                int v = -1;
                int.TryParse(objectInfo["MaxOpenFiles"], out v);
                MaxOpenFiles = v;
            }

            if (objectInfo.ContainsKey("Timeout"))
            {
                int v = -1;
                int.TryParse(objectInfo["Timeout"], out v);
                TimeOut = v;
            }

            if (objectInfo.ContainsKey("PasswordTimeout"))
            {
                int v = -1;
                int.TryParse(objectInfo["PasswordTimeout"], out v);
                PasswordTimeout = v;
            }
            String key = "Users0";

            if (objectInfo.ContainsKey(key))
            {
                int idx = 1;
                UserNames = new StringList();
                while (objectInfo.ContainsKey(key))
                {
                    UserNames.Add(objectInfo[key]);
                    key = String.Format("Users{0}", idx++);
                }
            }
            key = "Owners0";
            if (objectInfo.ContainsKey(key))
            {
                int idx = 1;
                OwnerNames = new StringList();
                while (objectInfo.ContainsKey(key))
                {
                    OwnerNames.Add(objectInfo[key]);
                    key = String.Format("Owners{0}", idx++);
                }
            }
            key = "Subgroups0";
            if (objectInfo.ContainsKey(key))
            {
                int idx = 1;
                SubGroups = new StringList();
                while (objectInfo.ContainsKey(key))
                {
                    SubGroups.Add(objectInfo[key]);
                    key = String.Format("Subgroups{0}", idx++);
                }
            }
        }
Ejemplo n.º 10
0
        public static FileResolveRecord FromResolvedCmdTaggedOutput(TaggedObject obj)
        {
            FileResolveRecord frr = new FileResolveRecord();
            int startRev          = -1;
            int endRev            = -1;

            if (obj.ContainsKey("path"))
            {
                frr.LocalFilePath = new LocalPath(obj["path"]);
            }

            if (obj.ContainsKey("startToRev"))
            {
                int.TryParse(obj["startToRev"].Trim('#'), out startRev);
            }
            if (obj.ContainsKey("endToRev"))
            {
                int.TryParse(obj["endToRev"].Trim('#'), out endRev);
            }
            if (obj.ContainsKey("clientFile"))
            {
                VersionRange versions = null;
                if ((startRev >= 0) && (endRev >= 0))
                {
                    versions = new VersionRange(startRev, endRev);
                }

                frr.BaseFileSpec = new FileSpec(new LocalPath(obj["clientFile"]), versions);
            }
            else if (obj.ContainsKey("toFile"))
            {
                VersionRange versions = null;
                if ((startRev >= 0) && (endRev >= 0))
                {
                    versions = new VersionRange(startRev, endRev);
                }
                frr.BaseFileSpec = new FileSpec(new ClientPath(obj["toFile"]), versions);
            }

            if (obj.ContainsKey("startFromRev"))
            {
                int.TryParse(obj["startFromRev"].Trim('#'), out startRev);
            }
            if (obj.ContainsKey("endFromRev"))
            {
                int.TryParse(obj["endFromRev"].Trim('#'), out endRev);
            }
            if (obj.ContainsKey("fromFile"))
            {
                VersionRange versions = null;
                if ((startRev >= 0) && (endRev >= 0))
                {
                    versions = new VersionRange(startRev, endRev);
                }
                frr.FromFileSpec = new FileSpec(new DepotPath(obj["fromFile"]), versions);
            }
            if (obj.ContainsKey("how"))
            {
                frr._action = obj["how"];
            }
            return(frr);
        }
Ejemplo n.º 11
0
        public static FileResolveRecord FromResolveCmdTaggedOutput(TaggedObject obj)
        {
            FileResolveRecord frr = new FileResolveRecord();
            int startRev          = -1;
            int endRev            = -1;

            if (obj.ContainsKey("clientFile"))
            {
                frr.LocalFilePath = new LocalPath(obj["clientFile"]);
            }
            if (obj.ContainsKey("baseFile"))
            {
                int         baseRev = -1;
                VersionSpec vs      = null;
                if (obj.ContainsKey("baseRev"))
                {
                    if (int.TryParse(obj["baseRev"], out baseRev))
                    {
                        vs = new Revision(baseRev);
                    }
                }
                frr.BaseFileSpec = new FileSpec(new DepotPath(obj["baseFile"]), vs);
            }

            if (obj.ContainsKey("startFromRev"))
            {
                int.TryParse(obj["startFromRev"], out startRev);
            }
            if (obj.ContainsKey("endFromRev"))
            {
                int.TryParse(obj["endFromRev"], out endRev);
            }
            if (obj.ContainsKey("fromFile"))
            {
                VersionRange versions = null;
                if ((startRev >= 0) && (endRev >= 0))
                {
                    versions = new VersionRange(startRev, endRev);
                }
                frr.FromFileSpec = new FileSpec(new DepotPath(obj["fromFile"]), versions);
            }
            if (obj.ContainsKey("how"))
            {
                frr._action = obj["how"];
            }
            else
            {
                frr.Action = FileAction.None;
            }
            if (obj.ContainsKey("resolveType"))
            {
                frr._resolveType = obj["resolveType"];
            }
            else
            {
                frr.ResolveType = ResolveType.None;
            }
            if (obj.ContainsKey("contentResolveType"))
            {
                switch (obj["contentResolveType"])
                {
                case "3waytext":
                    frr.ResolveSubtype = ResolveSubtype.ThreeWayText;
                    break;

                case "3wayraw":
                    frr.ResolveSubtype = ResolveSubtype.ThreeWayRaw;
                    break;

                case "2wayraw":
                    frr.ResolveSubtype = ResolveSubtype.TwoWayRaw;
                    break;

                default:
                    frr.ResolveSubtype = ResolveSubtype.None;
                    break;
                }
            }
            else
            {
                frr.ResolveSubtype = ResolveSubtype.None;
            }
            return(frr);
        }
Ejemplo n.º 12
0
 public void FromTaggedOutput(TaggedObject obj)
 {
 }
Ejemplo n.º 13
0
 public FileResolveRecord(TaggedObject obj)
 {
     FromTaggedOutput(obj);
 }