예제 #1
0
        public override string ToString()
        {
            this.Init__jsonIgnore();
            string json = string.Concat(
                __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()),
                __jsonIgnore.ContainsKey("Extends") ? string.Empty : string.Format(", Extends : {0}", Extends == null ? "null" : string.Format("'{0}'", Extends.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Gate") ? string.Empty : string.Format(", Gate : {0}", Gate == null ? "null" : string.Format("'{0}'", Gate.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Guid") ? string.Empty : string.Format(", Guid : {0}", Guid == null ? "null" : string.Format("'{0}'", Guid.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Ip") ? string.Empty : string.Format(", Ip : {0}", Ip == null ? "null" : string.Format("'{0}'", Ip.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("Number") ? string.Empty : string.Format(", Number : {0}", Number == null ? "null" : Number.ToString()),
                __jsonIgnore.ContainsKey("Server") ? string.Empty : string.Format(", Server : {0}", Server == null ? "null" : Server.ToString()),
                __jsonIgnore.ContainsKey("Shareid") ? string.Empty : string.Format(", Shareid : {0}", Shareid == null ? "null" : string.Format("'{0}'", Shareid.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))),
                __jsonIgnore.ContainsKey("State") ? string.Empty : string.Format(", State : {0}", State == null ? "null" : State.ToString()),
                __jsonIgnore.ContainsKey("Time") ? string.Empty : string.Format(", Time : {0}", Time == null ? "null" : Time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()),
                __jsonIgnore.ContainsKey("Used_number") ? string.Empty : string.Format(", Used_number : {0}", Used_number == null ? "null" : Used_number.ToString()),
                __jsonIgnore.ContainsKey("Used_userid") ? string.Empty : string.Format(", Used_userid : {0}", Used_userid == null ? "null" : Used_userid.ToString()),
                __jsonIgnore.ContainsKey("Userid") ? string.Empty : string.Format(", Userid : {0}", Userid == null ? "null" : Userid.ToString()), " }");

            return(string.Concat("{", json.Substring(1)));
        }
            /// <summary>
            /// Allows you to pass an array of strings that contain the IP Addresses
            /// to grant.
            ///
            /// Wildcard IPs should use .* or .0 to indicate grants.
            ///
            /// Note this string list should contain ALL IP addresses to grant
            /// not just new and added ones (ie. use GetList first and then
            /// add to the list.
            /// </summary>
            /// <param name="IPStrings"></param>
            public void SetIpList(string[] IPStrings)
            {
                this.Open();

                object IPSecurity = IIS.Properties["IPSecurity"].Value;

                // *** IMPORTANT: This list MUST be object or COM call will fail!
                List <object> newIpList = new List <object>();

                foreach (string Ip in IPStrings)
                {
                    string newIp;

                    if (Ip.EndsWith(".*.*.*") || Ip.EndsWith(".0.0.0"))
                    {
                        newIp = Ip.Replace(".*", ".0") + ",255.0.0.0";
                    }
                    else if (Ip.EndsWith(".*.*") || Ip.EndsWith(".0.0"))
                    {
                        newIp = Ip.Replace(".*", ".0") + ",255.255.0.0";
                    }
                    else if (Ip.EndsWith(".*") || Ip.EndsWith(".0"))
                    {
                        // *** Wildcard requires different IP Mask
                        newIp = Ip.Replace(".*", ".0") + ",255.255.255.0";
                    }
                    else
                    {
                        newIp = Ip + ", 255.255.255.255";
                    }


                    // *** Check for dupes - nasty but required because
                    // *** object -> string comparison can't do BinarySearch
                    bool found = false;
                    foreach (string tempIp in newIpList)
                    {
                        if (newIp == tempIp)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        newIpList.Add(newIp);
                    }
                }

                //wwUtils.SetPropertyCom(this.IPSecurity, "GrantByDefault", true);

                IPSecurity.GetType().InvokeMember("GrantByDefault",
                                                  BindingFlags.Public |
                                                  BindingFlags.Instance | BindingFlags.SetProperty,
                                                  null, IPSecurity, new object[] { true });


                object[] ipList = newIpList.ToArray();

                IPSecurity.GetType().InvokeMember("GrantByDefault",
                                                  BindingFlags.Public |
                                                  BindingFlags.Instance | BindingFlags.SetProperty,
                                                  null, IPSecurity, new object[] { false });

                // *** Apply the new list
                //wwUtils.SetPropertyCom(this.IPSecurity, "IPGrant",ipList);

                IPSecurity.GetType().InvokeMember("IPGrant",
                                                  BindingFlags.Public |
                                                  BindingFlags.Instance | BindingFlags.SetProperty,
                                                  null, IPSecurity, new object[] { ipList });


                IIS.Properties["IPSecurity"].Value = IPSecurity;
                IIS.CommitChanges();
                IIS.RefreshCache();

                this.Close();
            }