コード例 #1
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        /// <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();
        }
コード例 #2
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        /// <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();
        }
コード例 #3
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String descStr = String.Empty;

            if (Description != null)
            {
                descStr = Description.Replace("\n", "\n\t");
            }

            String Type = _type.ToString(StringEnumCase.Lower);

            String ParentPath = String.Empty;

            if (Parent != null)
            {
                ParentPath = Parent.Path.ToString();
                if (ParentPath == "None")
                {
                    ParentPath = ParentPath.ToLower();
                }
            }

            String pathsView = String.Empty;

            if (Paths != null)
            {
                pathsView = Paths.ToString().Replace("\r\n", "\r\n\t").Trim();
            }

            String remappedView = String.Empty;

            if (Remapped != null)
            {
                remappedView = Remapped.ToString().Replace("\r\n", "\r\n\t").Trim();
            }

            String ignoredView = String.Empty;

            if (Ignored != null)
            {
                ignoredView = Ignored.ToString().Replace("\r\n", "\r\n\t").Trim();
            }

            string customFieldsString = String.Empty;

            if (CustomFields.Count != 0)
            {
                customFieldsString = CustomFieldsToString();
            }

            String ParentView = _parentView.ToString(StringEnumCase.Lower);

            String value = String.Format(StreamSpecFormat, Id,
                                         FormBase.FormatDateTime(Updated), FormBase.FormatDateTime(Accessed),
                                         OwnerName, Name, ParentPath, Type, descStr, _options.ToString(),
                                         ParentView, pathsView, remappedView, ignoredView, customFieldsString);

            return(value);
        }
コード例 #4
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"];
            }
        }
コード例 #5
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"];
            }
        }
コード例 #6
0
ファイル: Depot.cs プロジェクト: startere/p4api.net
        /// <summary>
        /// Parse the fields from a depot specification
        /// </summary>
        /// <param name="spec">Text of the depot specification in server format</param>
        /// <returns></returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();

            _baseForm.Parse(spec);             // parse the values into the underlying dictionary

            if (_baseForm.ContainsKey("Depot"))
            {
                Id = _baseForm["Depot"] as string;
            }

            if (_baseForm.ContainsKey("Owner"))
            {
                Owner = _baseForm["Owner"] as string;
            }

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

            if (_baseForm.ContainsKey("Description"))
            {
                Description = _baseForm["Description"] as string;
            }

            if (_baseForm.ContainsKey("Type"))
            {
                _type = _baseForm["Type"] as string;
            }

            if (_baseForm.ContainsKey("Address"))
            {
                Address = new ServerAddress(_baseForm["Address"] as string);
            }

            if (_baseForm.ContainsKey("Map"))
            {
                Map = _baseForm["Map"] as string;
            }

            if (_baseForm.ContainsKey("StreamDepth"))
            {
                StreamDepth = _baseForm["StreamDepth"] as string;
            }

            if (_baseForm.ContainsKey("Suffix"))
            {
                Suffix = _baseForm["Suffix"] as string;
            }

            return(true);
        }
コード例 #7
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        private string ParseSingleString(FormBase _baseForm, string field)
        {
            string result = null;

            if (_baseForm.ContainsKey(field))
            {
                result = _baseForm[field] as string;
                specDef.Remove(field);
            }
            return(result);
        }
コード例 #8
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        private DateTime ParseDate(FormBase _baseForm, string field)
        {
            DateTime d = new DateTime();

            if (DateTime.TryParse(_baseForm[field] as string, out d))
            {
                specDef.Remove(field);
            }

            return(d);
        }
コード例 #9
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"];
            }
        }
コード例 #10
0
ファイル: Depot.cs プロジェクト: startere/p4api.net
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String DepotType = _type.ToString(StringEnumCase.Lower);
            //String Address = ToString();

            String value = String.Format(DepotSpecFormat, Id, Owner,
                                         FormBase.FormatDateTime(Modified), Description, DepotType,
                                         Address, Suffix, Map, StreamDepth);

            return(value);
        }
コード例 #11
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"];
            }
        }
コード例 #12
0
ファイル: BranchSpec.cs プロジェクト: startere/p4api.net
        /// <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"];
            }
        }
コード例 #13
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        /// <summary>
        /// Parse the fields from a stream specification
        /// </summary>
        /// <param name="spec">Text of the stream specification in server format</param>
        /// <returns></returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();
            _baseForm.Parse(spec); // parse the values into the underlying dictionary
            GetSpecDefinition(_baseForm);

            Id          = ParseSingleString(_baseForm, "Stream");
            OwnerName   = ParseSingleString(_baseForm, "Owner");
            Name        = ParseSingleString(_baseForm, "Name");
            Description = ParseDescription(_baseForm);
            Ignored     = ParseView(_baseForm, "Ignored");
            Paths       = ParseView(_baseForm, "Paths");
            Remapped    = ParseView(_baseForm, "Remapped");
            View        = ParseView(_baseForm, "View");
            ChangeView  = ParseView(_baseForm, "ChangeView");
            Updated     = ParseDate(_baseForm, "Update");
            Accessed    = ParseDate(_baseForm, "Access");

            if (_baseForm.ContainsKey("Options"))
            {
                _options = _baseForm["Options"] as string;
                specDef.Remove("Options");
            }

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

            if (_baseForm.ContainsKey("ParentView"))
            {
                _parentView = (_baseForm["ParentView"].ToString() == "inherit") ? ParentView.Inherit : ParentView.NoInherit;
                //_parentView = _baseForm["ParentView"] as string;
                specDef.Remove("ParentView");
            }

            if (_baseForm.ContainsKey("Parent"))
            {
                string line = _baseForm["Parent"] as string;
                Parent = new DepotPath(line);
                specDef.Remove("Parent");
            }

            SetCustomFields();

            return(true);
        }
コード例 #14
0
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String viewStr = String.Empty;

            if (ViewMap != null)
            {
                viewStr = ViewMap.ToString().Replace("\r\n", "\r\n\t").Trim();
            }
            String OptionsStr = string.Empty;

            if (Locked)
            {
                OptionsStr = "locked";
            }
            else
            {
                OptionsStr = "unlocked";
            }

            if (IncludeAutoreloadOption)
            {
                if (Autoreload)
                {
                    OptionsStr += " autoreload";
                }
                else
                {
                    OptionsStr += " noautoreload";
                }
            }
            String revStr = String.Empty;

            if (Revision != null)
            {
                revStr = string.Format("Revision:\t{0}\r\n\r\n", Revision);
            }
            String serveridStr = String.Empty;

            if (ServerId != null)
            {
                serveridStr = string.Format("ServerID:\t{0}\r\n\r\n", ServerId);
            }
            String value = String.Format(LabelFormat, Id,
                                         FormBase.FormatDateTime(Update), FormBase.FormatDateTime(Access),
                                         Owner, Description, OptionsStr, revStr, serveridStr, viewStr);

            return(value);
        }
コード例 #15
0
ファイル: User.cs プロジェクト: startere/p4api.net
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String reviewsView = String.Empty;

            if (Reviews != null)
            {
                for (int idx = 0; idx < Reviews.Count; idx++)
                {
                    reviewsView += String.Format("\t{0}\r\n", Reviews[idx]);
                }
            }
            String value = String.Format(UserSpecFormat, Id, EmailAddress,
                                         FormBase.FormatDateTime(Updated), FormBase.FormatDateTime(Accessed),
                                         FullName, JobView, reviewsView, Password);

            return(value);
        }
コード例 #16
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;
            }
        }
コード例 #17
0
        /// <summary>
        /// Get a list of streams from the repository
        /// </summary>
        /// <param name="options">options for the streams command<see cref="StreamsCmdOptions"/></param>
        /// <param name="files">files to filter results by</param>
        /// <returns>A list containing the matching streams</returns>
        /// <remarks>
        /// <br/><b>p4 help streams</b>
        /// <br/>
        /// <br/>     streams -- Display list of streams
        /// <br/>
        /// <br/>     p4 streams [-U -F filter -T fields -m max] [streamPath ...]
        /// <br/>
        /// <br/>   Reports the list of all streams currently known to the system.  If
        /// <br/>   a 'streamPath' argument is specified, the list of streams is limited
        /// <br/>   to those matching the supplied path. Unloaded task streams are not
        /// <br/>   listed by default.
        /// <br/>
        /// <br/>   For each stream, a single line of output lists the stream depot path,
        /// <br/>   the type, the parent stream depot path, and the stream name.
        /// <br/>
        /// <br/>   The -F filter flag limits the output to files satisfying the expression
        /// <br/>   given as 'filter'.  This filter expression is similar to the one used
        /// <br/>   by 'jobs -e jobview',  except that fields must match those above and
        /// <br/>   are case sensitive.
        /// <br/>
        /// <br/>           e.g. -F "Parent=//Ace/MAIN &amp; Type=development"
        /// <br/>
        /// <br/>   Note: the filtering takes place post-compute phase; there are no
        /// <br/>   indexes to optimize performance.
        /// <br/>
        /// <br/>   The -T fields flag (used with tagged output) limits the fields output
        /// <br/>   to those specified by a list given as 'fields'.  These field names can
        /// <br/>   be separated by a space or a comma.
        /// <br/>
        /// <br/>           e.g. -T "Stream, Owner"
        /// <br/>
        /// <br/>   The -m max flag limits output to the first 'max' number of streams.
        /// <br/>
        /// <br/>   The -U flag lists unloaded task streams (see 'p4 help unload').
        /// <br/>
        /// <br/>
        /// </remarks>
        /// <example>
        ///         To get the first 3 development type streams with the parent //flow/mainline:
        ///
        /// <code>
        ///         IList&#60;Stream&#62; = rep.GetStreams(new Options(StreamsCmdFlags.None,
        ///                    "Parent=//flow/mainline &amp; Type=development", null, "//...", 3));
        /// </code>
        /// </example>
        public IList <Stream> GetStreams(Options options, params FileSpec[] files)
        {
            P4Command cmd = null;

            if ((files != null) && (files.Length > 0))
            {
                cmd = new P4Command(this, "streams", true, FileSpec.ToStrings(files));
            }
            else
            {
                cmd = new P4Command(this, "streams", true);
            }

            P4CommandResult results = cmd.Run(options);

            if (results.Success)
            {
                if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
                {
                    return(null);
                }
                List <Stream> value = new List <Stream>();

                bool   dst_mismatch = false;
                string offset       = string.Empty;

                if (Server != null && Server.Metadata != null)
                {
                    offset       = Server.Metadata.DateTimeOffset;
                    dst_mismatch = FormBase.DSTMismatch(Server.Metadata);
                }

                foreach (TaggedObject obj in results.TaggedOutput)
                {
                    Stream stream = new Stream();
                    stream.FromStreamsCmdTaggedOutput(obj, offset, dst_mismatch);
                    value.Add(stream);
                }
                return(value);
            }
            else
            {
                P4Exception.Throw(results.ErrorList);
            }
            return(null);
        }
コード例 #18
0
        /// <summary>
        /// Get a list of users from the repository
        /// </summary>
        /// <param name="options">Options for the users command. See: <see cref="UsersCmdFlags"/></param>
        /// <param name="user">Optional list of users. </param>
        /// <returns>A list containing the matching users</returns>
        /// <remarks>
        /// <br/><b>p4 help users</b>
        /// <br/>
        /// <br/>     users -- List Perforce users
        /// <br/>
        /// <br/>     p4 users [-l -a -r -c] [-m max] [user ...]
        /// <br/>
        /// <br/>   Lists all Perforce users or users that match the 'user' argument.
        /// <br/>   The report includes the last time that each user accessed the system.
        /// <br/>
        /// <br/>   The -m max flag limits output to the first 'max' number of users.
        /// <br/>
        /// <br/>   The -a flag includes service and operator users in the output.
        /// <br/>
        /// <br/>   The -l flag includes additional information in the output.  The -l
        /// <br/>   flag requires 'super' access, which is granted by 'p4 protect'.
        /// <br/>
        /// <br/>   The -r and -c flags are only allowed on replica servers.  When
        /// <br/>   -r is given only users who have used a replica are reported and
        /// <br/>   when -c is given only the user information from the central server
        /// <br/>   is reported.  Otherwise on a replica server, the user list will
        /// <br/>   be slightly different from the master server as the user access times
        /// <br/>   will reflect replica usage or master usage whichever is newer.
        /// <br/>
        /// <br/>
        /// </remarks>
        /// <example>
        ///		To get the first 10 users that start with the letter 'A':
        ///		<code>
        ///			UsersCmdOptions opts = new UsersCmdOptions(UsersCmdFlags.None, 10);
        ///			IList&#60;User&#62; users = Repository.getUsers(opts, "A*");
        ///		</code>
        ///		To get the users for 'Bob', 'Ted', 'Carol' and 'Alice':
        ///		<code>
        ///			UsersCmdOptions opts = new UsersCmdOptions(UsersCmdFlags.None, -1);
        ///			IList&#60;User&#62; users = Repository.getUsers(opts, "Bob", "Ted", "Carol", "Alice");
        ///		</code>
        ///		To get all the users (WARNING, will fetch all users from the repository):
        ///		<code>
        ///			UsersCmdOptions opts = new UsersCmdOptions(UsersCmdFlags.IncludeAll, -1);
        ///         IList&#60;User&#62; users = Repository.getUsers(opts, null);
        ///		</code>
        /// </example>
        /// <seealso cref="UsersCmdFlags"/>
        public IList <User> GetUsers(Options options, params string[] user)
        {
            P4Command cmd = null;

            if ((user != null) && (user.Length > 0))
            {
                cmd = new P4Command(this, "users", true, user);
            }
            else
            {
                cmd = new P4Command(this, "users", true);
            }

            P4CommandResult results = cmd.Run(options);

            if (results.Success)
            {
                if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
                {
                    return(null);
                }
                List <User> value = new List <User>();
                foreach (TaggedObject obj in results.TaggedOutput)
                {
                    bool   dst_mismatch = false;
                    string offset       = string.Empty;

                    if (Server != null && Server.Metadata != null)
                    {
                        offset       = Server.Metadata.DateTimeOffset;
                        dst_mismatch = FormBase.DSTMismatch(Server.Metadata);
                    }
                    User u = new User();
                    u.FromUserCmdTaggedOutput(obj, offset, dst_mismatch);
                    value.Add(u);
                }
                return(value);
            }
            else
            {
                P4Exception.Throw(results.ErrorList);
            }
            return(null);
        }
コード例 #19
0
        /// <summary>
        /// Convert to a string for display
        /// </summary>
        /// <param name="includeTime">Include the time as well as the date</param>
        /// <returns></returns>
        public string ToString(bool includeTime)
        {
            String dateTime;

            if (includeTime)
            {
                dateTime = String.Format("{0} {1}", ModifiedDate.ToShortDateString(), ModifiedDate.ToShortTimeString());
            }
            else
            {
                dateTime = ModifiedDate.ToShortDateString();
            }

            String desc = String.Empty;

            if (Description != null)
            {
                desc = FormBase.FormatMultilineField(Description.ToString());
            }
            return(String.Format("Change {0} on {1} by {2}: {3}", Id, dateTime, OwnerName, desc));
        }
コード例 #20
0
        public IList <Depot> GetDepots(Options options)
        {
            P4Command cmd = new P4Command(this, "depots", true);


            P4CommandResult results = cmd.Run(options);

            if (results.Success)
            {
                if ((results.TaggedOutput == null) || (results.TaggedOutput.Count <= 0))
                {
                    return(null);
                }

                bool   dst_mismatch = false;
                string offset       = string.Empty;

                if (Server != null && Server.Metadata != null)
                {
                    offset       = Server.Metadata.DateTimeOffset;
                    dst_mismatch = FormBase.DSTMismatch(Server.Metadata);
                }

                List <Depot> value = new List <Depot>();
                foreach (TaggedObject obj in results.TaggedOutput)
                {
                    Depot depot = new Depot();
                    depot.FromDepotsCmdTaggedOutput(obj, offset, dst_mismatch);
                    value.Add(depot);
                }
                return(value);
            }
            else
            {
                P4Exception.Throw(results.ErrorList);
            }
            return(null);
        }
コード例 #21
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        private void GetSpecDefinition(FormBase _baseForm)
        {
            if (_baseForm.ContainsKey("specdef"))
            {
                string   tmp    = _baseForm["specdef"] as string;
                string[] fields = tmp.Split(new string[] { ";;" }, StringSplitOptions.None);

                foreach (string field in fields)
                {
                    string   value = "word";
                    string[] line  = field.Split(';');
                    foreach (string x in line)
                    {
                        if (x.Contains("type"))
                        {
                            string[] typeTmp = x.Split(':');
                            value = typeTmp[1];
                        }
                    }
                    specDef.Add(line[0], value);
                }
            }
        }
コード例 #22
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        private string ParseDescription(FormBase _baseForm)
        {
            string result = string.Empty;
            string key    = "Description";

            if (_baseForm.ContainsKey(key))
            {
                SimpleList <string> _list = (SimpleList <string>)_baseForm[key];
                string[]            list  = _list.ToArray();
                foreach (string line in list)
                {
                    result += line + "\r\n\t";
                }
                result = result.Substring(0, result.Length - 3);
            }

            if (specDef.ContainsKey(key))
            {
                specDef.Remove(key);
            }

            return(result);
        }
コード例 #23
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
        private ViewMap ParseView(FormBase _baseForm, string field)
        {
            ViewMap view = new ViewMap();

            if (_baseForm.ContainsKey(field))
            {
                SimpleList <string> _list = (SimpleList <string>)_baseForm[field];
                string[]            list  = _list.ToArray();
                foreach (string line in list)
                {
                    view.Add(line);
                }
            }
            else
            {
                view = null;
            }

            if (specDef.ContainsKey(field))
            {
                specDef.Remove(field);
            }
            return(view);
        }
コード例 #24
0
ファイル: BranchSpec.cs プロジェクト: startere/p4api.net
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String viewStr = String.Empty;

            if (ViewMap != null)
            {
                viewStr = ViewMap.ToString().Replace("\r\n", "\r\n\t").Trim();
            }
            String OptionsStr = string.Empty;

            if (Locked)
            {
                OptionsStr = "locked";
            }
            else
            {
                OptionsStr = "unlocked";
            }
            String value = String.Format(BranchSpecFormat, Id,
                                         FormBase.FormatDateTime(Updated), FormBase.FormatDateTime(Accessed),
                                         Owner, Description, OptionsStr, viewStr);

            return(value);
        }
コード例 #25
0
ファイル: BranchSpec.cs プロジェクト: startere/p4api.net
        /// <summary>
        /// Parse the fields from a branch specification
        /// </summary>
        /// <param name="spec">Text of the branch specification in server format</param>
        /// <returns></returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();

            _baseForm.Parse(spec);             // parse the values into the underlying dictionary

            if (_baseForm.ContainsKey("Branch"))
            {
                Id = _baseForm["Branch"] as string;
            }

            if (_baseForm.ContainsKey("Owner"))
            {
                if (_baseForm["Owner"] is string)
                {
                    Owner = _baseForm["Owner"] as string;
                }
                if (_baseForm["Owner"] is IList <string> )
                {
                    IList <string> strList = _baseForm["Owner"] as IList <string>;
                    Owner = string.Empty;
                    for (int idx = 0; idx < strList.Count; idx++)
                    {
                        if (idx > 0)
                        {
                            Owner += "\r\n";
                        }
                        Owner += strList[idx];
                    }
                }
                if (_baseForm["Owner"] is SimpleList <string> )
                {
                    SimpleList <string> strList = _baseForm["Owner"] as SimpleList <string>;
                    Owner = string.Empty;
                    SimpleListItem <string> current = strList.Head;
                    bool addCRLF = false;
                    while (current != null)
                    {
                        if (addCRLF)
                        {
                            Owner += "\r\n";
                        }
                        else
                        {
                            addCRLF = true;
                        }
                        Owner  += current.Item;
                        current = current.Next;
                    }
                }
            }

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

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

            if (_baseForm.ContainsKey("Description"))
            {
                if (_baseForm["Description"] is string)
                {
                    Description = _baseForm["Description"] as string;
                }
                if (_baseForm["Description"] is IList <string> )
                {
                    IList <string> strList = _baseForm["Description"] as IList <string>;
                    Description = string.Empty;
                    for (int idx = 0; idx < strList.Count; idx++)
                    {
                        if (idx > 0)
                        {
                            Description += "\r\n";
                        }
                        Description += strList[idx];
                    }
                }
                if (_baseForm["Description"] is SimpleList <string> )
                {
                    SimpleList <string> strList = _baseForm["Description"] as SimpleList <string>;
                    Description = string.Empty;
                    SimpleListItem <string> current = strList.Head;
                    bool addCRLF = false;
                    while (current != null)
                    {
                        if (addCRLF)
                        {
                            Description += "\r\n";
                        }
                        else
                        {
                            addCRLF = true;
                        }
                        Description += current.Item;
                        current      = current.Next;
                    }
                }
            }


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

            if (_baseForm.ContainsKey("View"))
            {
                if (_baseForm["View"] is IList <string> )
                {
                    IList <string> lines = _baseForm["View"] as IList <string>;
                    ViewMap = new ViewMap(lines.ToArray());
                }
                else if (_baseForm["View"] is SimpleList <string> )
                {
                    SimpleList <string> lines = _baseForm["View"] as SimpleList <string>;
                    ViewMap = new ViewMap(lines.ToArray());
                }
            }
            return(true);
        }
コード例 #26
0
ファイル: BranchSpec.cs プロジェクト: startere/p4api.net
        /// <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;
            }
        }
コード例 #27
0
        /// <summary>
        /// Convert to specification in server format
        /// </summary>
        /// <returns></returns>
        override public String ToString()
        {
            String descStr = String.Empty;

            if (Description != null)
            {
                descStr = FormBase.FormatMultilineField(Description.ToString());
            }

            // only add the files field if it is a pending changelist
            //
            // #  Jobs:        What opened jobs are to be closed by this changelist.
            // #               You may delete jobs from this list.  (New changelists only.)
            // #  Files:       What opened files from the default changelist are to be added
            // #               to this changelist.  You may delete files from this list.
            // #               (New changelists only.)
            String jobsStr = String.Empty;

            if (Jobs != null)
            {
                foreach (string jobId in Jobs.Keys)
                {
                    jobsStr += string.Format("\t{0}\r\n", jobId);
                }
            }

            String filesStr = String.Empty;

            if (Files != null && Pending)
            {
                foreach (FileSpec file in Files)
                {
                    filesStr += String.Format("\t{0}\r\n", file.ToEscapedString());
                }
            }

            String ChangeNumbeStr = "new";

            if (Id != -1)
            {
                ChangeNumbeStr = Id.ToString();
            }

            String restrictedStr = String.Empty;

            if (_type == ChangeListType.Restricted)
            {
                restrictedStr = "Type:\trestricted\n\n";
            }
            if (_type == ChangeListType.Public)
            {
                restrictedStr = "Type:\tpublic\n\n";
            }

            String statusStr = Pending ? "pending" : "submitted";

            if (Id == -1)
            {
                statusStr = "new";
            }

            String value = String.Format(ChangelistSpecFormat, ChangeNumbeStr,
                                         FormBase.FormatDateTime(ModifiedDate), ClientId, OwnerName,
                                         statusStr,
                                         restrictedStr, descStr, jobsStr, filesStr);

            return(value);
        }
コード例 #28
0
        /// <summary>
        /// Parse the fields from a changelist specification
        /// </summary>
        /// <param name="spec">Text of the changelist specification in server format</param>
        /// <returns>true if parse successful</returns>
        public bool Parse(String spec)
        {
            _baseForm = new FormBase();
            _baseForm.Parse(spec);             // parse the values into the underlying dictionary

            if (_baseForm.ContainsKey("Change"))
            {
                int v = -1;
                int.TryParse((string)_baseForm["Change"], out v);
                Id = v;
            }
            if (_baseForm.ContainsKey("Date"))
            {
                DateTime v;
                DateTime.TryParse((string)_baseForm["Date"], out v);
                ModifiedDate = v;
            }
            if (_baseForm.ContainsKey("Client"))
            {
                ClientId = (string)_baseForm["Client"];
            }

            if (_baseForm.ContainsKey("User"))
            {
                OwnerName = (string)_baseForm["User"];
            }

            if (_baseForm.ContainsKey("Status"))
            {
                Pending = true;
                String v = (string)_baseForm["Status"];
                if (v == "submitted")
                {
                    Pending = false;
                }
            }

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

            if (_baseForm.ContainsKey("Description"))
            {
                if (_baseForm["Description"] is string)
                {
                    Description = (string)_baseForm["Description"];
                }
                else if (_baseForm["Description"] is SimpleList <string> )
                {
                    SimpleList <string> strList = _baseForm["Description"] as SimpleList <string>;
                    Description = string.Empty;
                    SimpleListItem <string> current = strList.Head;
                    bool addCRLF = false;
                    while (current != null)
                    {
                        if (addCRLF)
                        {
                            Description += "\r\n";
                        }
                        else
                        {
                            addCRLF = true;
                        }
                        Description += current.Item;
                        current      = current.Next;
                    }
                }
                else if (_baseForm["Description"] is IList <string> )
                {
                    IList <string> strList = _baseForm["Description"] as IList <string>;
                    Description = string.Empty;
                    for (int idx = 0; idx < strList.Count; idx++)
                    {
                        if (idx > 0)
                        {
                            Description += "\r\n";
                        }
                        Description += strList[idx];
                    }
                }
            }
            if (_baseForm.ContainsKey("Jobs"))
            {
                if (_baseForm["Jobs"] is IList <string> )
                {
                    IList <string> strList = _baseForm["Jobs"] as IList <string>;
                    Jobs = new Dictionary <string, string>(strList.Count);
                    foreach (string job in strList)
                    {
                        if (job.Contains('#'))
                        {
                            string[] parts = job.Split('#');
                            Jobs[parts[0].Trim()] = null;
                        }
                        else
                        {
                            Jobs[job] = null;
                        }
                    }
                }
                else if (_baseForm["Jobs"] is SimpleList <string> )
                {
                    SimpleList <string> strList = _baseForm["Jobs"] as SimpleList <string>;
                    Jobs = new Dictionary <string, string>(strList.Count);
                    SimpleListItem <string> current = strList.Head;
                    while (current != null)
                    {
                        string job = current.Item;
                        if (job.Contains('#'))
                        {
                            string[] parts = job.Split('#');
                            Jobs[parts[0].Trim()] = null;
                        }
                        else
                        {
                            Jobs[job] = null;
                        }
                        current = current.Next;
                    }
                }
            }
            if (_baseForm.ContainsKey("Files"))
            {
                if (_baseForm["Files"] is IList <string> )
                {
                    IList <string> files = (IList <string>)_baseForm["Files"];
                    Files = new List <FileMetaData>(files.Count);
                    foreach (string path in files)
                    {
                        FileMetaData file = new FileMetaData();
                        if (path.Contains('#'))
                        {
                            string[] parts = path.Split('#');
                            file.DepotPath = new DepotPath(parts[0].Trim());
                        }
                        else
                        {
                            file.DepotPath = new DepotPath(path);
                        }
                        Files.Add(file);
                    }
                }
                else if (_baseForm["Files"] is SimpleList <string> )
                {
                    SimpleList <string> files = (SimpleList <string>)_baseForm["Files"];
                    Files = new List <FileMetaData>(files.Count);
                    SimpleListItem <string> current = files.Head;
                    while (current != null)
                    {
                        FileMetaData file = new FileMetaData();
                        if (current.Item.Contains('#'))
                        {
                            string[] parts = current.Item.Split('#');
                            file.DepotPath = new DepotPath(parts[0].Trim());
                        }
                        else
                        {
                            file.DepotPath = new DepotPath(current.Item);
                        }
                        Files.Add(file);
                        current = current.Next;
                    }
                }
            }
            return(true);
        }
コード例 #29
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));
            }
        }
コード例 #30
0
ファイル: Stream.cs プロジェクト: perforce/p4api.net
 private void GetSpecDefinition(TaggedObject objectInfo)
 {
     _baseForm = new FormBase();
     _baseForm.SetValues(objectInfo);
     GetSpecDefinition(_baseForm);
 }