Ejemplo n.º 1
0
        public static AfConnectionMgr ConnectAndGetDatabase(string server, string databaseName, out AFDatabase database)
        {
            var manager = new AfConnectionMgr(server, databaseName);

            manager.Connect();
            database = manager.GetDatabase();
            return(manager);
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            try
            {

                var connection = new AfConnectionMgr(Server, Database);
                connection.Connect();

                AFDatabase database = connection.GetDatabase();

                var afObject = AFObject.FindObject(AttributePath, database);

                var separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator;

                if (afObject is AFAttribute)
                {
                    var attribute = (AFAttribute)afObject;
                    AFValue value = attribute.GetValue();
                    Console.WriteLine("{0}{1}{2}{3}{4}", GetStringValue(value), separator, value.Timestamp,separator, attribute.Name);
                }

                if (afObject is AFElement)
                {

                    var element = (AFElement)afObject;

                    // the attibute list object allows a single GetValue() call for all attributes at same time.
                    // We call this a "Bulk Call"
                    var attributes = new AFAttributeList(element.Attributes);
                    var values=attributes.GetValue();

                    // prints the results
                    values.ForEach((afvalue)=> Console.WriteLine("{0}{1}{2}{3}{4}", GetStringValue(afvalue),separator, afvalue.Timestamp,separator,afvalue.Attribute.Name));
                }

            }

            catch (Exception ex)
            {
                this.Logger.Error(ex);
            }
        }
 public static AfConnectionMgr ConnectAndGetDatabase(string server, string databaseName, out AFDatabase database)
 {
     var manager=new AfConnectionMgr(server,databaseName);
     manager.Connect();
     database=manager.GetDatabase();
     return manager;
 }
Ejemplo n.º 4
0
        public override void Run()
        {
            try
            {

                var connection = new AfConnectionMgr(Server, DatabaseName);
                connection.Connect();
                var afDatabase = connection.GetDatabase();

                // Parsing options
                if (OptionList)
                {
                    ListElements(afDatabase,ElementPath);
                }

                if (NewElementParams!=null && NewElementParams.Count>0)
                {
                    var elementName = NewElementParams[0];
                    var elementPath=NewElementParams.Count >= 2 ? NewElementParams[1]:null;
                    var elementTemplate=NewElementParams.Count >= 3 ? NewElementParams[2]:null;
                    CreateElement(afDatabase, elementName, elementPath, elementTemplate);
                }

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }