Ejemplo n.º 1
0
 public ServerMetaData(string name,
                       ServerAddress address,
                       string root,
                       DateTime date,
                       string dateTimeOffset,
                       int uptime,
                       ServerVersion version,
                       ServerLicense license,
                       string licenseIp,
                       bool caseSensitive,
                       bool unicodeEnabled,
                       bool moveEnabled
                       )
 {
     Name           = name;
     Address        = address;
     Root           = root;
     Date           = date;
     DateTimeOffset = dateTimeOffset;
     Uptime         = uptime;
     Version        = version;
     License        = license;
     LicenseIp      = licenseIp;
     CaseSensitive  = caseSensitive;
     UnicodeEnabled = unicodeEnabled;
     MoveEnabled    = moveEnabled;
 }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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"];
            }
        }
Ejemplo n.º 4
0
        /// <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"];
            }
        }
Ejemplo n.º 5
0
 public ServerMetaData(ServerAddress address)
 {
     Name           = null;
     Address        = address;
     Root           = null;
     Date           = DateTime.Now;
     DateTimeOffset = null;
     Uptime         = -1;
     Version        = null;
     License        = null;
     LicenseIp      = null;
     CaseSensitive  = true;
     UnicodeEnabled = false;
     MoveEnabled    = true;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Detailed constructor
 /// </summary>
 /// <param name="id">depot name</param>
 /// <param name="type">depot type</param>
 /// <param name="modified">modified DateTime</param>
 /// <param name="address">server address</param>
 /// <param name="owner">string owner</param>
 /// <param name="description">description of depot</param>
 /// <param name="suffix">suffix field</param>
 /// <param name="map">map field</param>
 /// <param name="streamdepth">stream depth</param>
 /// <param name="spec">FormSpec</param>
 public Depot(string id,
              DepotType type,
              DateTime modified,
              ServerAddress address,
              string owner,
              string description,
              string suffix,
              string map,
              string streamdepth,
              FormSpec spec
              )
 {
     Id          = id;
     Type        = type;
     Modified    = modified;
     Address     = address;
     Owner       = owner;
     Description = description;
     Suffix      = suffix;
     Map         = map;
     StreamDepth = streamdepth;
     Spec        = spec;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Compare ServerAddresses
        /// </summary>
        /// <param name="obj">ServerAddress to compare to</param>
        /// <returns>true if both ServerAddresses are equal</returns>
        public override bool Equals(object obj)
        {
            if ((obj is ServerAddress) == false)
            {
                return(false);
            }
            ServerAddress o = obj as ServerAddress;

            if (o.Uri != null)
            {
                if (o.Uri.Equals(this.Uri) == false)
                {
                    return(false);
                }
            }
            else
            {
                if (this.Uri != null)
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 8
0
 public Server(ServerAddress address)
 {
     State   = ServerState.Unknown;
     Address = address;
 }
Ejemplo n.º 9
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;;
            }
        }