예제 #1
0
        /// <summary>
        /// Read the fields from the tagged output of a diff2 command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'diff2' command</param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        public void FromGetDepotFileDiffsCmdTaggedOutput(TaggedObject objectInfo, Connection connection, Options options)
        {
            DepotFileDiff ParsedDepotFileDiff = new DepotFileDiff();
            string        ldepotfile          = string.Empty;
            string        rdepotfile          = string.Empty;
            int           lrev = -1;
            int           rrev = -1;

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

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

            if (objectInfo.ContainsKey("rev"))
            {
                int.TryParse(objectInfo["rev"], out lrev);
            }

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

            if (objectInfo.ContainsKey("rev2"))
            {
                int.TryParse(objectInfo["rev2"], out rrev);
            }

            LeftFile = new FileSpec(new DepotPath(ldepotfile), new Revision(lrev));

            RightFile = new FileSpec(new DepotPath(rdepotfile), new Revision(rrev));

            if (objectInfo["status"] == "content")
            {
                string       filepathl   = ldepotfile + "#" + lrev;
                string       filepathr   = rdepotfile + "#" + rrev;
                P4.P4Command getDiffData = new P4Command(connection, "diff2", false, filepathl, filepathr);

                P4.P4CommandResult r = getDiffData.Run(options);
                if (r.Success != true)
                {
                    P4Exception.Throw(r.ErrorList);
                }
                if (r.TextOutput != null)
                {
                    Diff = r.TextOutput.ToString();
                }
                else if (r.InfoOutput != null)
                {
                    Diff = r.InfoOutput.ToString();
                }
            }

            ParsedDepotFileDiff = new DepotFileDiff(Type, LeftFile, RightFile, Diff);
        }
예제 #2
0
        public void ParseGrepCmdTaggedData(TaggedObject obj)
        {
            if (obj.ContainsKey("depotFile"))
            {
                int rev = -1;
                if (obj.ContainsKey("rev"))
                {
                    int.TryParse(obj["rev"], out rev);
                    FileSpec = new FileSpec(new DepotPath(obj["depotFile"]), new Revision(rev));
                }
            }

            Type = MatchType.Match;
            if (obj.ContainsKey("type"))
            {
                StringEnum <MatchType> matchtype = obj["type"];
                Type = matchtype;
            }

            if (obj.ContainsKey("matchedLine"))
            {
                Line = obj["matchedLine"];
            }

            if (obj.ContainsKey("line"))
            {
                int v = -1;
                int.TryParse(obj["line"], out v);
                LineNumber = v;
            }
        }
예제 #3
0
        public static Fix FromFixCmdTaggedOutput(TaggedObject obj)
        {
            Fix val = new Fix();

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

            if (obj.ContainsKey("change"))
            {
                int v = -1;
                int.TryParse(obj["change"], out v);
                val.ChangeId = v;
            }

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

            if (obj.ContainsKey("action"))
            {
                val._action = obj["action"];
            }
            return(val);
        }
예제 #4
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);

            GetSpecDefinition(objectInfo);

            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);
                specDef.Remove("Update");
            }

            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);
                specDef.Remove("Access");
            }

            PopulateCommonFields(objectInfo);

            SetCustomFields();
        }
예제 #5
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);

            GetSpecDefinition(objectInfo);

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

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

            Paths      = ReadViewField(objectInfo, "Paths");
            Remapped   = ReadViewField(objectInfo, "Remapped");
            Ignored    = ReadViewField(objectInfo, "Ignored");
            View       = ReadViewField(objectInfo, "View");
            ChangeView = ReadViewField(objectInfo, "ChangeView");

            PopulateCommonFields(objectInfo);

            SetCustomFields();
        }
예제 #6
0
파일: File.cs 프로젝트: startere/p4api.net
        /// <summary>
        /// Given a Tagged object from the server, instantiate this File from the object
        /// </summary>
        /// <param name="obj">Tagged Object to Parse</param>
        public void ParseFilesCmdTaggedData(TaggedObject obj)
        {
            if (obj.ContainsKey("depotFile"))
            {
                base.DepotPath = new DepotPath(obj["depotFile"]);
            }

            if (obj.ContainsKey("clientFile"))
            {
                base.ClientPath = new ClientPath(obj["clientFile"]);
            }

            if (obj.ContainsKey("rev"))
            {
                int rev = -1;
                int.TryParse(obj["rev"], out rev);
                base.Version = new Revision(rev);
            }

            if (obj.ContainsKey("haveRev"))
            {
                int rev = -1;
                int.TryParse(obj["haveRev"], out rev);
                HaveRev = new Revision(rev);
            }

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

            if (obj.ContainsKey("action"))
            {
                Action = (FileAction) new StringEnum <FileAction>(obj["action"], true, true);
            }

            if (obj.ContainsKey("type"))
            {
                Type = new FileType(obj["type"]);
            }

            if (obj.ContainsKey("time"))
            {
                SubmitTime = FormBase.ConvertUnixTime(obj["time"]);
            }

            if (obj.ContainsKey("user"))
            {
                User = obj["user"];
            }

            if (obj.ContainsKey("client"))
            {
                Client = obj["client"];
            }
        }
예제 #7
0
파일: Depot.cs 프로젝트: startere/p4api.net
        /// <summary>
        /// Read the fields from the tagged output of a depots command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'depots' command</param>
        /// <param name="offset">offset in time</param>
        /// <param name="dst_mismatch"></param>
        public void FromDepotsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

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

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

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

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

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

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

            if (objectInfo.ContainsKey("Suffix"))
            {
                Suffix = objectInfo["Suffix"];
            }
        }
예제 #8
0
        /// <summary>
        /// Read the fields from the tagged output of a labels command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'labels' command</param>
        /// <param name="offset">Date handling</param>
        /// <param name="dst_mismatch">DST</param>
        public void FromLabelsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

            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);
                Access = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            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);
                Update = FormBase.ConvertFromUTC(GMT, offset, dst_mismatch);
            }

            if (objectInfo.ContainsKey("Options"))
            {
#pragma warning disable 618
                Options = objectInfo["Options"] as string;
#pragma warning restore 618
            }
            else
            {
                Locked = false;
            }

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

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

            if (objectInfo.ContainsKey("ServerID"))
            {
                ServerId = objectInfo["ServerID"];
            }
        }
예제 #9
0
파일: Depot.cs 프로젝트: startere/p4api.net
        /// <summary>
        /// Read the fields from the tagged output of a depot command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'depot' command</param>
        public void FromDepotCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

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

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

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

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

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

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

            if (objectInfo.ContainsKey("Suffix"))
            {
                Suffix = objectInfo["Suffix"];
            }
        }
예제 #10
0
파일: Job.cs 프로젝트: startere/p4api.net
        /// <summary>
        /// Parse the tagged output of a 'job' command
        /// </summary>
        /// <param name="obj"></param>
        public virtual void FromJobCmdTaggedOutput(TaggedObject obj)
        {
            SetValues(obj);

            if (obj.ContainsKey("Job"))
            {
                Id = obj["Job"];
            }
        }
예제 #11
0
        private ViewMap ReadViewField(TaggedObject objectInfo, String field)
        {
            if (specDef.ContainsKey(field))
            {
                specDef.Remove(field);
            }


            ViewMap map        = new ViewMap();
            int     idx        = 0;
            int     mapIdx     = 0;
            string  key        = String.Format("{0}{1}", field, idx);
            string  commentKey = String.Format("{0}Comment{1}", field, idx);

            if (!objectInfo.ContainsKey(key))
            {
                return(null);
            }

            while (objectInfo.ContainsKey(key))
            {
                bool haveComment = objectInfo.ContainsKey(commentKey);
                if ((objectInfo[key] != "") || (haveComment))
                {
                    map.Add(objectInfo[key]);
                    if (haveComment)
                    {
                        map[mapIdx].Comment = objectInfo[commentKey].TrimEnd();
                    }
                    mapIdx++;
                }
                idx++;
                key        = String.Format("{0}{1}", field, idx);
                commentKey = String.Format("{0}Comment{1}", field, idx);
            }
            return(map);
        }
예제 #12
0
        /// <summary>
        /// Read the fields from the tagged output of a diff command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'diff' command</param>
        /// <param name="connection"></param>
        /// <param name="options"></param>
        public void FromGetFileDiffsCmdTaggedOutput(TaggedObject objectInfo, Connection connection, Options options)
        {
            FileDiff ParsedFileDiff = new FileDiff();
            string   depotfile      = string.Empty;
            string   clienttfile    = string.Empty;
            int      rev            = -1;
            string   type           = string.Empty;

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

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

            if (objectInfo.ContainsKey("rev"))
            {
                int.TryParse(objectInfo["rev"], out rev);
            }

            if (objectInfo.ContainsKey("type"))
            {
                Type = new FileType(objectInfo["type"]);
            }

            LeftFile = new FileSpec(new DepotPath(depotfile), new Revision(rev));

            RightFile = new FileSpec(new DepotPath(clienttfile), null);

            Diff = connection.LastResults.TextOutput;

            ParsedFileDiff = new FileDiff(Type, LeftFile, RightFile, Diff);
        }
예제 #13
0
        public void ParseFixesCmdTaggedData(TaggedObject obj, string offset, bool dst_mismatch)
        {
            if (obj.ContainsKey("Job"))
            {
                JobId = obj["Job"];
            }

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

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

            if (obj.ContainsKey("User"))
            {
                UserName = obj["User"];
            }

            if (obj.ContainsKey("Client"))
            {
                ClientName = obj["Client"];
            }

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

            if (obj.ContainsKey("Action"))
            {
                _action = obj["Action"];
            }
            else
            {
                Action = FixAction.Fixed;
            }
        }
예제 #14
0
        /// <summary>
        /// Read the fields from the tagged output of a branches command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'branches' command</param>
        /// <param name="offset">Offset within array</param>
        /// <param name="dst_mismatch">Daylight savings time for conversions</param>
        public void FromBranchSpecsCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

            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("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("Options"))
            {
                if (objectInfo["Options"] == "locked")
                {
                    Locked = true;
                }
            }
            else
            {
                Locked = false;
            }

            if (objectInfo.ContainsKey("Description"))
            {
                Description = objectInfo["Description"];
            }
        }
예제 #15
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;
            }
        }
예제 #16
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;;
            }
        }
예제 #17
0
        private void PopulateCommonFields(TaggedObject objectInfo)
        {
            if (objectInfo.ContainsKey("Stream"))
            {
                Id = objectInfo["Stream"];
                specDef.Remove("Stream");
            }

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

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

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

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

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

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

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

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

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

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

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

            if (objectInfo.ContainsKey("ParentView"))
            {
                _parentView = (objectInfo["ParentView"]);
                specDef.Remove("ParentView");
            }
        }
예제 #18
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"]);
            }
        }
예제 #19
0
        /// <summary>
        /// Read the fields from the tagged output of a label command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'label' command</param>
        public void FromLabelCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

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

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

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

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

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

            if (objectInfo.ContainsKey("Options"))
            {
#pragma warning disable 618
                Options = objectInfo["Options"] as string;
#pragma warning restore 618
            }
            else
            {
                Locked = false;
            }

            int    idx = 0;
            string key = String.Format("View{0}", idx);
            if (objectInfo.ContainsKey(key))
            {
                ViewMap = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    ViewMap.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("View{0}", idx);
                }
            }
            else
            {
                ViewMap = null;
            }
        }
예제 #20
0
        public void ParseIntegratedCmdTaggedData(TaggedObject obj)
        {
            DepotPath   tp         = null;
            VersionSpec starttorev = null;
            VersionSpec endtorev   = null;

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

            if (obj.ContainsKey("startToRev"))
            {
                string str = obj["startToRev"];
                starttorev = new Revision(-1);

                if (str.StartsWith("#h")
                    |
                    str.StartsWith("#n"))
                {
                    if (str.Contains("#none"))
                    {
                        starttorev = Revision.None;
                    }

                    if (str.Contains("#have"))
                    {
                        starttorev = Revision.Have;
                    }

                    if (str.Contains("#head"))
                    {
                        starttorev = Revision.Head;
                    }
                }
                else
                {
                    str = str.Trim('#');
                    int rev = Convert.ToInt16(str);
                    starttorev = new Revision(rev);
                }
            }

            if (obj.ContainsKey("endToRev"))
            {
                string etr = obj["endToRev"];
                endtorev = new Revision(-1);

                if (etr.StartsWith("#h")
                    |
                    etr.StartsWith("#n"))
                {
                    if (etr.Contains("#none"))
                    {
                        endtorev = Revision.None;
                    }

                    if (etr.Contains("#have"))
                    {
                        endtorev = Revision.Have;
                    }

                    if (etr.Contains("#head"))
                    {
                        endtorev = Revision.Head;
                    }
                }
                else
                {
                    etr = etr.Trim('#');
                    int rev = Convert.ToInt16(etr);
                    endtorev = new Revision(rev);
                }
            }

            ToFile = new FileSpec(tp, null, null, new VersionRange(starttorev, endtorev));

            DepotPath   fp           = null;
            VersionSpec startfromrev = null;
            VersionSpec endfromrev   = null;

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

            if (obj.ContainsKey("startFromRev"))
            {
                string sfr = obj["startFromRev"];
                startfromrev = new Revision(-1);

                if (sfr.StartsWith("#h")
                    |
                    sfr.StartsWith("#n"))
                {
                    if (sfr.Contains("#none"))
                    {
                        startfromrev = Revision.None;
                    }

                    if (sfr.Contains("#have"))
                    {
                        startfromrev = Revision.Have;
                    }

                    if (sfr.Contains("#head"))
                    {
                        startfromrev = Revision.Head;
                    }
                }
                else
                {
                    sfr = sfr.Trim('#');
                    int rev = Convert.ToInt16(sfr);
                    startfromrev = new Revision(rev);
                }
            }

            if (obj.ContainsKey("endFromRev"))
            {
                string efr = obj["endFromRev"];
                endfromrev = new Revision(-1);

                if (efr.StartsWith("#h")
                    |
                    efr.StartsWith("#n"))
                {
                    if (efr.Contains("#none"))
                    {
                        endfromrev = Revision.None;
                    }

                    if (efr.Contains("#have"))
                    {
                        endfromrev = Revision.Have;
                    }

                    if (efr.Contains("#head"))
                    {
                        endfromrev = Revision.Head;
                    }
                }
                else
                {
                    efr = efr.Trim('#');
                    int rev = Convert.ToInt16(efr);
                    endfromrev = new Revision(rev);
                }
            }

            FromFile = new FileSpec(fp, null, null, new VersionRange(startfromrev, endfromrev));

            if (obj.ContainsKey("how"))
            {
                How = (IntegrateAction) new StringEnum <IntegrateAction>(obj["how"], true, true);
            }

            if (obj.ContainsKey("change"))
            {
                int change = -1;
                int.TryParse(obj["change"], out change);
                ChangeId = change;
            }
        }
예제 #21
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;
            }
        }
예제 #22
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("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));
            }
        }
예제 #23
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);
            }

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

            return(val);
        }
예제 #24
0
        /// <summary>
        /// Read the fields from the tagged output of a branch command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'branch' command</param>
        public void FromBranchSpecCmdTaggedOutput(TaggedObject objectInfo)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

            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("Description"))
            {
                Description = objectInfo["Description"];
            }

            if (objectInfo.ContainsKey("Options"))
            {
                if (objectInfo["Options"] == "locked")
                {
                    Locked = true;
                }
            }
            else
            {
                Locked = false;
            }

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

            if (objectInfo.ContainsKey(key))
            {
                ViewMap = new ViewMap();
                while (objectInfo.ContainsKey(key))
                {
                    ViewMap.Add(objectInfo[key]);
                    idx++;
                    key = String.Format("View{0}", idx);
                }
            }
            else
            {
                ViewMap = null;
            }
        }
예제 #25
0
 public void FromIstatCmdTaggedData(TaggedObject obj)
 {
     if (obj.ContainsKey("stream"))
     {
         string p = PathSpec.UnescapePath(obj["stream"]);
         Stream = new DepotPath(p);
     }
     if (obj.ContainsKey("parent"))
     {
         string p = PathSpec.UnescapePath(obj["parent"]);
         Parent = new DepotPath(p);
     }
     if (obj.ContainsKey("type"))
     {
         _type = (obj["type"]);
     }
     if (obj.ContainsKey("parentType"))
     {
         _parenttype = (obj["parentType"]);
     }
     if (obj.ContainsKey("firmerThanParent"))
     {
         bool value;
         bool.TryParse(obj["firmerThanParent"], out value);
         FirmerThanParent = value;
     }
     if (obj.ContainsKey("changeFlowsToParent"))
     {
         bool value;
         bool.TryParse(obj["changeFlowsToParent"], out value);
         ChangeFlowsToParent = value;
     }
     if (obj.ContainsKey("changeFlowsFromParent"))
     {
         bool value;
         bool.TryParse(obj["changeFlowsFromParent"], out value);
         ChangeFlowsFromParent = value;
     }
     if (obj.ContainsKey("integToParent"))
     {
         bool value;
         bool.TryParse(obj["integToParent"], out value);
         IntegToParent = value;
     }
     if (obj.ContainsKey("integToParentHow"))
     {
         _integtoparenthow = (obj["integToParentHow"]);
     }
     if (obj.ContainsKey("toResult"))
     {
         ToResult = obj["toResult"];
     }
     if (obj.ContainsKey("integFromParent"))
     {
         bool value;
         bool.TryParse(obj["integFromParent"], out value);
         IntegFromParent = value;
     }
     if (obj.ContainsKey("integFromParentHow"))
     {
         _integfromparenthow = (obj["integFromParentHow"]);
     }
     if (obj.ContainsKey("fromResult"))
     {
         FromResult = obj["fromResult"];
     }
 }
예제 #26
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);
        }
예제 #27
0
파일: Group.cs 프로젝트: perforce/p4api.net
        /// <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++);
                }
            }
        }
예제 #28
0
파일: User.cs 프로젝트: startere/p4api.net
        /// <summary>
        /// Read the fields from the tagged output of a user command
        /// </summary>
        /// <param name="objectInfo">Tagged output from the 'user' command</param>
        /// <param name="offset">Date processing</param>
        /// <param name="dst_mismatch">DST for date</param>
        public void FromUserCmdTaggedOutput(TaggedObject objectInfo, string offset, bool dst_mismatch)
        {
            _baseForm = new FormBase();

            _baseForm.SetValues(objectInfo);

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

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

            if (objectInfo.ContainsKey("Update"))
            {
                DateTime d;

                if (DateTime.TryParse(objectInfo["Update"] as string, out d))
                {
                    Updated = d;
                }

                else
                {
                    long unixTime = 0;
                    if (Int64.TryParse(objectInfo["Update"], out unixTime))
                    {
                        DateTime UTC = FormBase.ConvertUnixTime(unixTime);
                        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 d;

                if (DateTime.TryParse(objectInfo["Access"] as string, out d))
                {
                    Updated = d;
                }

                else
                {
                    long unixTime = 0;
                    if (Int64.TryParse(objectInfo["Access"], out unixTime))
                    {
                        DateTime UTC = FormBase.ConvertUnixTime(unixTime);
                        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("FullName"))
            {
                FullName = objectInfo["FullName"];
            }

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

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

            Reviews = new StringList();

            while (objectInfo.ContainsKey((key =
                                               String.Format("Reviews{0}", idx))))
            {
                idx++; Reviews.Add(objectInfo[key]);
            }

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

            if (objectInfo.ContainsKey("Type"))
            {
                _type = objectInfo["Type"];
            }
        }
예제 #29
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);
        }