Exemplo n.º 1
0
        public new XmlDocument GetDatabases([NotNull] Credentials credentials)
        {
            Assert.ArgumentNotNull(credentials, nameof(credentials));

            LoginUser(credentials);

            var packet = new Packet();

            try
            {
                foreach (var databaseName in Factory.GetDatabaseNames())
                {
                    var connectionString = string.Empty;

                    try
                    {
                        var settings = ConfigurationManager.ConnectionStrings[databaseName];
                        if (settings != null)
                        {
                            connectionString = settings.ConnectionString ?? string.Empty;
                        }
                    }
                    catch
                    {
                    }

                    packet.AddElement("database", databaseName, "connectionstring", connectionString);
                }
            }
            catch
            {
            }

            return(packet.XmlDocument);
        }
        private static Packet GetSavePacket(Hashtable fieldInfo)
        {
            Assert.ArgumentNotNull(fieldInfo, "fieldInfo");
            Packet result = new Packet();

            foreach (FieldInfo info in fieldInfo.Values)
            {
                System.Web.UI.Control control = Context.ClientPage.FindSubControl(info.ID);
                if (control != null)
                {
                    string str;
                    if (control is IContentField)
                    {
                        str = StringUtil.GetString(new string[] { (control as IContentField).GetValue() });
                    }
                    else
                    {
                        str = StringUtil.GetString(ReflectionUtil.GetProperty(control, "Value"));
                    }
                    if (str != "__#!$No value$!#__")
                    {
                        result.StartElement("field");
                        result.SetAttribute("itemid", info.ItemID.ToString());
                        result.SetAttribute("language", info.Language.ToString());
                        result.SetAttribute("version", info.Version.ToString());
                        switch (info.Type.ToLowerInvariant())
                        {
                        case "rich text":
                        case "html":
                            str = str.TrimEnd(new char[] { ' ' });
                            break;
                        }

                        result.SetAttribute("fieldid", info.FieldID.ToString());
                        result.AddElement("value", str, new string[0]);
                        result.EndElement();
                    }
                }
            }
            return(Assert.ResultNotNull <Packet>(result));
        }
Exemplo n.º 3
0
        public new XmlDocument GetDatabases([NotNull] Credentials credentials)
        {
            Assert.ArgumentNotNull(credentials, nameof(credentials));

            LoginUser(credentials);

            var packet = new Packet();

            try
            {
                foreach (var databaseName in Factory.GetDatabaseNames())
                {
                    packet.AddElement("database", databaseName);
                }
            }
            catch
            {
            }

            return(packet.XmlDocument);
        }
        private static Packet GetSavePacket(Hashtable fieldInfo)
        {
            Assert.ArgumentNotNull(fieldInfo, "fieldInfo");
            Packet result = new Packet();
            foreach (FieldInfo info in fieldInfo.Values)
            {
                System.Web.UI.Control control = Context.ClientPage.FindSubControl(info.ID);
                if (control != null)
                {
                    string str;
                    if (control is IContentField)
                    {
                        str = StringUtil.GetString(new string[] { (control as IContentField).GetValue() });
                    }
                    else
                    {
                        str = StringUtil.GetString(ReflectionUtil.GetProperty(control, "Value"));
                    }
                    if (str != "__#!$No value$!#__")
                    {
                        result.StartElement("field");
                        result.SetAttribute("itemid", info.ItemID.ToString());
                        result.SetAttribute("language", info.Language.ToString());
                        result.SetAttribute("version", info.Version.ToString());
                        switch (info.Type.ToLowerInvariant())
                        {
                            case "rich text":
                            case "html":
                                str = str.TrimEnd(new char[] { ' ' });
                                break;
                        }

                        result.SetAttribute("fieldid", info.FieldID.ToString());
                        result.AddElement("value", str, new string[0]);
                        result.EndElement();
                    }
                }
            }
            return Assert.ResultNotNull<Packet>(result);
        }