当前位置: 首页>>代码示例>>C#>>正文


C# Server.Connect方法代码示例

本文整理汇总了C#中Server.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Connect方法的具体用法?C# Server.Connect怎么用?C# Server.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.Connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect

        public void Connect(string serverName)
        {
            /* When the factory creates an HDA server, it passes along 2 parameters:
             *    SerializationInfo info
             *    StreamingContext context
             *
             * The Factory class casts the COM object (pointing to the HDA server) to the IServer interface.
             * All calls to the interface or proxied to the COM object.
             */
            Opc.URL url = new Opc.URL(String.Format("opchda://localhost/{0}", serverName));
            OpcCom.Factory fact = new OpcCom.Factory();
            _hdaServer = new Opc.Hda.Server(fact, url);

            try
            {
                _hdaServer.Connect();
                Console.WriteLine(String.Format("Connect to server {0}", serverName));
            }
            catch(Opc.ConnectFailedException opcConnExc)
            {
                Console.WriteLine(String.Format("Could not connect to server {0}", serverName));
                Console.WriteLine(opcConnExc.ToString());
            }

            Console.WriteLine("Are we connected? " + _hdaServer.IsConnected);
        }
开发者ID:jdecuyper,项目名称:OPC-HDA-Client,代码行数:26,代码来源:OPCHDAClient.cs

示例2: Start

	void Start()
	{
		// find the server so that we can interact with it
		_server = Utility.FindComponent<Server>(Server.NAME);

		// listen for some events we care about
		_server.ConnectionEvent += OnConnectionEvent;
		_server.ConnectionLostEvent += OnConnectionLost;

		_showLogin = false;
		_showStatus = true;

		_username = "";
		_password = "";
		_status = "Connecting to: " + IP + " on port: " + Port + "...";

		// some helper rects to make it easier to draw the gui
		_loginRect = new Rect(Screen.width / 2 - LOGIN_WIDTH / 2, Screen.height / 2 - LOGIN_HEIGHT / 2, LOGIN_WIDTH, LOGIN_HEIGHT);
		_selectRect = new Rect(Screen.width / 2 - SELECT_WIDTH / 2, Screen.height / 2 - SELECT_HEIGHT / 2, SELECT_WIDTH, SELECT_HEIGHT);
		_statusRect = new Rect(Screen.width / 2 - STATUS_WIDTH / 2, Screen.height / 2 + STATUS_HEIGHT, STATUS_WIDTH, STATUS_HEIGHT);
		_charRect = new Rect(Screen.width / 2 - (NUM_CHARS * CHAR_WIDTH + (NUM_CHARS - 1) * CHAR_SPACING) + 10, SELECT_HEIGHT / 2 - CHAR_HEIGHT / 2 - 20, (NUM_CHARS * CHAR_WIDTH + (NUM_CHARS - 1) * CHAR_SPACING), CHAR_HEIGHT);

		// load the resources for character select
		_glow = Resources.Load<Texture2D>("GUI/glow");

		_charTextures = new Texture2D[NUM_CHARS];
		for (int i = 0; i < NUM_CHARS; ++i)
			_charTextures[i] = Resources.Load<Texture2D>("GUI/char" + i + "_select");

		// try and connect to the server
		_server.Connect(IP, Port);
	}
开发者ID:KyleMassacre,项目名称:PlanetServer,代码行数:32,代码来源:LoginController.cs

示例3: AddMiningStructure

        public void AddMiningStructure()
        {
            Server srv = new Server();
            srv.Connect("DataSource=CLARITY-7HYGMQM\\ANA;Initial Catalog=Adventure Works DW 2008");
            Database db = srv.Databases["Adventure Works DW 2008"];
            Cube myCube = db.Cubes["Adventure Works"];

            CubeDimension myDimension = myCube.Dimensions.GetByName("Customer");
            Microsoft.AnalysisServices.MiningStructure myMiningStructure = db.MiningStructures.Add("TestMining", "TestMining");
            myMiningStructure.Source = new CubeDimensionBinding(".", myCube.ID, myDimension.ID);

            // get current mining models
            // Demo code
            foreach (Microsoft.AnalysisServices.MiningStructure ms in db.MiningStructures)
            {
                Console.WriteLine(ms.Name);

                foreach (Microsoft.AnalysisServices.MiningModel mm in ms.MiningModels)
                {
                    Console.WriteLine(mm.Name);
                }
            }

            CubeAttribute basketAttribute;
            CubeAttribute itemAttribute;
            basketAttribute = myCube.Dimensions.GetByName("Customer").Attributes[0];
            itemAttribute = myCube.Dimensions.GetByName("Product").Attributes[0];

            //basket structure column
            ScalarMiningStructureColumn basket = CreateMiningStructureColumn(basketAttribute, true);
            basket.Name = "Basket";
            myMiningStructure.Columns.Add(basket);

            //item structure column - nested table
            ScalarMiningStructureColumn item = CreateMiningStructureColumn(itemAttribute, true);
            item.Name = "Item";

            MeasureGroup measureGroup = myCube.MeasureGroups[0];
            TableMiningStructureColumn purchases = CreateMiningStructureColumn(measureGroup);

            purchases.Name = "Purchases";
            purchases.Columns.Add(item);
            myMiningStructure.Columns.Add(purchases);

            Microsoft.AnalysisServices.MiningModel myMiningModel = myMiningStructure.CreateMiningModel();
            myMiningModel.Name = "MarketBasket";
            myMiningModel.Columns["Purchases"].Usage = MiningModelColumnUsages.PredictOnly;
            myMiningModel.Algorithm = MiningModelAlgorithms.MicrosoftAssociationRules;

            try
            {
                myMiningStructure.Update(UpdateOptions.ExpandFull);
                myMiningStructure.Process(ProcessType.ProcessFull);
            }
            catch (Microsoft.AnalysisServices.OperationException e)
            {
                this.sResult = e.StackTrace;
                Console.WriteLine(e.StackTrace);
            }
        }
开发者ID:xfurry,项目名称:data_mining,代码行数:60,代码来源:OlapMiningManager.cs

示例4: Execute

        public IScriptReponse Execute(AbstractConnection connection, string script, int timeOut = 0) {
            var response = new ScriptResponse();
            var server = new Server();
            var logger = connection.Logger;

            try {
                logger.Debug("Connecting to {0} on {1}.", connection.Database, connection.Server);
                server.Connect(connection.GetConnectionString());

                var results = server.Execute(script);

                foreach (XmlaResult result in results) {
                    foreach (XmlaMessage message in result.Messages) {
                        response.Messages.Add(message.Description);
                    }
                }
                response.Success = response.Messages.Count == 0;
            } catch (Exception e) {
                logger.Debug(e.Message + (e.InnerException != null ? " " + e.InnerException.Message : string.Empty));
                response.Messages.Add(e.Message);
            } finally {
                if (server.Connected) {
                    logger.Debug("Disconnecting from {0} on {1}.", connection.Database, connection.Server);
                    server.Disconnect();
                }
            }
            return response;
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:28,代码来源:AnalysisServicesScriptRunner.cs

示例5: ListDimensionErrors

        public static DataTable ListDimensionErrors(string DimensionName)
        {
            DataTable tableReturn = new DataTable();
            tableReturn.Columns.Add("Dimension");
            tableReturn.Columns.Add("ErrorNumber", typeof(int));
            tableReturn.Columns.Add("ErrorDescription");
            tableReturn.Columns.Add("NumColumns", typeof(int));
            int iNumPriorColumns = tableReturn.Columns.Count;
            int iMaxNumColumns = 9;
            for (int i = 1; i <= iMaxNumColumns; i++)
            {
                tableReturn.Columns.Add("Column" + i + "Name");
                tableReturn.Columns.Add("Column" + i);
            }

            if (AdomdServer.Context.ExecuteForPrepare) return tableReturn;

            Server server = new Server();
            server.Connect("*");
            Dimension d = server.Databases.GetByName(AdomdServer.Context.CurrentDatabaseName).Dimensions.GetByName(DimensionName);
            DimensionError[] errors = Check(d);
            server.Disconnect();

            for (int i = 0; i < errors.Length; i++)
            {
                DimensionError error = errors[i];
                if (error.ErrorTable == null || (error.ErrorTable != null && error.ErrorTable.Rows.Count == 0))
                {
                    DataRow row = tableReturn.NewRow();
                    row["Dimension"] = d.Name;
                    row["ErrorNumber"] = i + 1;
                    row["ErrorDescription"] = error.ErrorDescription;
                    row["NumColumns"] = 0;
                    tableReturn.Rows.Add(row);
                }
                else
                {
                    foreach (DataRow errorRow in error.ErrorTable.Rows)
                    {
                        DataRow row = tableReturn.NewRow();
                        row["Dimension"] = d.Name;
                        row["ErrorNumber"] = i + 1;
                        row["ErrorDescription"] = error.ErrorDescription;
                        row["NumColumns"] = error.ErrorTable.Columns.Count;
                        if (iMaxNumColumns < error.ErrorTable.Columns.Count)
                            throw new Exception("Dimension error dataset contained more than " + iMaxNumColumns + " columns which is not allowed with the current code. Change the code of the sproc to allow more, refresh the report dataset, and change the report layout to allow more.");
                        for (int j = 0; j < error.ErrorTable.Columns.Count; j++)
                        {
                            row[j * 2 + iNumPriorColumns] = error.ErrorTable.Columns[j].ColumnName;
                            if (!Convert.IsDBNull(errorRow[j]))
                                row[j * 2 + iNumPriorColumns + 1] = errorRow[j].ToString();
                        }
                        tableReturn.Rows.Add(row);
                    }
                }
            }
            return tableReturn;
        }
开发者ID:sergey-vdovin,项目名称:Slicing-and-dicing-over-data-differences-between-SSAS-databases,代码行数:58,代码来源:DimensionHealthCheck.cs

示例6: QueryTrace

 // todo - implement operations queue
 //private Queue<TraceOperation> operationQueue;
 //private readonly Dictionary<TraceEventClass, TraceEvent> _traceEvents;
 public QueryTrace(ADOTabularConnection connection, DocumentViewModel document)
 {
     _server = new Server();
     _server.Connect(connection.ConnectionString);
     _connection = connection;
     Status = QueryTraceStatus.Stopped;
     // new Dictionary<TraceEventClass, TraceEvent>();
     _currentDocumentReference = new WeakReference(document);
 }
开发者ID:votrongdao,项目名称:DaxStudio,代码行数:12,代码来源:QueryTrace.cs

示例7: Process

        public void Process(string tempDirectory, IEnumerable<TableData> sourceTables, IJobSpecification job)
        {
            var tables = sourceTables.Select(t => t.Schema).ToArray();

            using (var server = new Server())
            {
                server.Connect(ConnectionString);

                var db = server.Databases.Find(DbName);

                if (!Update)
                {
                    if (db != null)
                    {
                        db.Drop();
                    }

                    CreateSchema(db, server, tables);
                    db = server.Databases.Find(DbName);
                }

                //server.CaptureXml = true; <- Doesn't work with QueryBinding and errors from empty partitions marked as never processed.

                foreach (var table in sourceTables)
                {
                    
                    var processingType = !Update && IncrementalUpdate.HasFlag(
                        table.Schema.IsDimension() ? SqlClearOptions.Dimensions : SqlClearOptions.Facts)
                        ? ProcessType.ProcessAdd
                        : ProcessType.ProcessFull;

                    if (table.Schema.IsDimension())
                    {
                        ProcessPartition(db, table.Name, table.Name, processingType);
                    }
                    else
                    {
                        var partition = SqlUpdateUtil.GetPartitionField(table.Schema);
                        if (partition != null)
                        {
                            ProcessPartition(db, table.Name, GetTransientPartitionName(table.Schema), ProcessType.ProcessFull,
                                string.Format("SELECT [{0}].* FROM [{0}] {1}", table.Name, SqlUpdateUtil.GetUpdateCriteria(table.Schema, partition, true, date: ReferenceDate)));

                            ProcessPartition(db, table.Name, table.Name, processingType,
                                string.Format("SELECT [{0}].* FROM [{0}] {1}", table.Name, SqlUpdateUtil.GetUpdateCriteria(table.Schema, partition, false, date: ReferenceDate, cutoff: CutOff)));
                        }
                        else
                        {
                            ProcessPartition(db, table.Name, table.Name, processingType);
                        }
                    }
                }

                //server.ExecuteCaptureLog(true, true);
            }
        }
开发者ID:vsegrad,项目名称:experience-extractor,代码行数:56,代码来源:SsasExporter.cs

示例8: frmMain

        public frmMain()
        {
            InitializeComponent();

            S = new Server("localhost", 9987, "", "");
            if (!S.Connect())
            {
                Text = "Failed ...";
            }
        }
开发者ID:rinukkusu,项目名称:CrewSpeak,代码行数:10,代码来源:frmMain.cs

示例9: Check

 public bool Check(AbstractConnection connection) {
     bool isReady;
     var server = new Server();
     try {
         server.Connect(connection.GetConnectionString());
         isReady = server.Connected;
         server.Disconnect();
     } catch (Exception e) {
         _logger.Warn("Error checking {0} connection. {1}", connection.Name, e.Message);
         return false;
     }
     return isReady;
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:13,代码来源:AnalysisServicesConnectionChecker.cs

示例10: ConnectPressed

 public RedirectResult ConnectPressed(Models.IndexModel Model)
 {
     // Create the server
     Main = new Server(Port);
     Main.Start();
     if (!Main.Connect(Model.ID))
     {
         Main.Stop();
         // Server failed to connect
         return Redirect("ConnectFailed");
     }
     // Server connected succesfully
     return Redirect("Controller");
 }
开发者ID:hnefatl,项目名称:Iliad-IV,代码行数:14,代码来源:IndexController.cs

示例11: Cancel

 public void Cancel()
 {
     try
     {
         if (!_cancelled)
         {
             _cancelled = true;
             RaiseProgressEvent(99, "Starting cancel...");
             Server s = new Server();
             s.Connect(_currentAggD.ParentServer.ConnectionString);
             s.CancelSession(_sessionID);
             RaiseProgressEvent(100, "Successfully cancelled...");
         }
     }
     catch (Exception ex)
     {
         RaiseProgressEvent(99, "Trying to cancel...\r\n" + ex.Message + " " + ex.StackTrace);
     }
 }
开发者ID:japj,项目名称:bidshelper,代码行数:19,代码来源:AggregationPerformance.cs

示例12: BackupSsasDatabases

        /// <summary>
        /// Backup SSAS Databases.
        /// </summary>
        /// <param name="_serverName"></param>
        public void BackupSsasDatabases(Hashtable args)
        {
            var _serverName = args["ServerName"].ToString();

            using(Server srv = new Server())
            {
                srv.Connect(_serverName);

                foreach(Database db in srv.Databases)
                {
                    Console.WriteLine("Backing up " + db.Name);
                    Console.WriteLine("Start " + DateTime.Now.ToShortTimeString());

                    var backupInfo = GetBackupInfo(db.Name, args);

                    db.Backup(backupInfo);

                    Console.WriteLine("Done " + DateTime.Now.ToShortTimeString());
                }

                srv.Disconnect();
            }
        }
开发者ID:mhenderson442,项目名称:ssas-backup,代码行数:27,代码来源:Processing.cs

示例13: CreateMiningStructureIfCan

        public bool CreateMiningStructureIfCan()
        {
            try
            {
                // init server connection
                Server svr = new Server();
                svr.Connect("integrated security=SSPI;data source=" + sServer + ";persist security info=False;initial catalog=" + sCatalog);

                // Connect to the Analysis Service server
                Database currentDB = GetCurrentDatabase(sCatalog);
                currentDB.Refresh();

                // if current database doesn't exist, then create it
                //if (currentDB == null)
                //    CreateNewDatabase();

                // create a new mining structure
                MiningStructure currentStructure = CreateMiningStructure(currentDB);
                currentStructure.Refresh();

                // create a mining model for the selected structure
                CreateModels(currentStructure);

                // Process Database and structure
                currentStructure.Process();
                //ProcessDatabase(myDB);

                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
                SMiningError = e.StackTrace;
            }

            return false;
        }
开发者ID:xfurry,项目名称:data_mining,代码行数:37,代码来源:SQLMiningManager.cs

示例14: ASPCDimNaturalizer

 public ASPCDimNaturalizer(string ASServer, string ASDatabase, string PCDimension, int ActionLevel)
 {
     try
     {
         srv = new Server();
         srv.Connect("Integrated Security=SSPI;Persist Security Info=False;Data Source=" + ASServer);
         db = srv.Databases.GetByName(ASDatabase);
         dim = db.Dimensions.GetByName(PCDimension);
         if (((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbSchemaName"] != null)
             txtNewView = ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbSchemaName"] + ".[DimNaturalized_" +
                 ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.ExtendedProperties["DbTableName"] + "]";
         else
             txtNewView = "[DimNaturalized_" +
                 ((EnhancedColumnBinding)dim.KeyAttribute.KeyColumns[0].Source).Table.TableName + "]";
         ASNaturalizationActionLevel = ActionLevel;
         InitIDCols();
     }
     catch (Exception e)
     {
         UpdateStatus(BIDSHelper.Resources.Common.ProcessError);
         UpdateStatus("Error initializing naturalizer:\r\n" + e.ToString());
         throw e;
     }
 }
开发者ID:sgtgold,项目名称:bids-helper-extension,代码行数:24,代码来源:PCDimNaturalizer.cs

示例15: GenerateTestSuite

        public void GenerateTestSuite(
            [DefaultValue("..\\..\\Templates")] string templatePath,
            [DefaultValue("..\\..\\RegressionTests")] string outputPath)
        {
            string measureGroupTemplate = File.ReadAllText(Path.Combine(templatePath, "MeasureGroup.template"));
            string dimensionTemplate = File.ReadAllText(Path.Combine(templatePath, "Dimension.template"));
            string measureTemplate = File.ReadAllText(Path.Combine(templatePath, "Measure.template"));

            using (var server = new Server())
            {
                server.Connect(this.connectionBuilder.ConnectionString);

                var database = server.FindDatabases()
                    .Where(x => x.Name == this.connectionBuilder.InitialCatalog)
                    .First();

                foreach (var cube in database.FindCubes())
                {
                    Console.WriteLine("{0} cube", cube.Name);

                    var cubePath = Path.Combine(outputPath, FormatFileName(cube.Name));

                    if (!Directory.Exists(cubePath))
                    {
                        Directory.CreateDirectory(cubePath);
                    }

                    List<CubeDimension> dimensions = new List<CubeDimension>(cube.FindDimensions());

                    foreach (var mg in cube.FindMeasureGroups().OrderBy(x => x.Name))
                    {
                        Console.WriteLine("\t{0}", mg.Name);

                        var mgPath = Path.Combine(cubePath, FormatFileName(mg.Name) + ".cs");

                        List<CubeDimension> mgdims = new List<CubeDimension>(mg.FindDimensions());

                        var dimensionClasses = new List<string>(dimensions.Count + 1);

                        foreach (var d in dimensions)
                        {
                            if (mgdims.Contains(d))
                            {
                                Console.WriteLine("\t\t{0}", d.Name);

                                var dimensionMeasureTests = new List<string>(mg.Measures.Count);

                                foreach (var m in mg.Measures.Cast<Measure>())
                                {
                                    StringBuilder measureBuilder = new StringBuilder(measureTemplate);
                                    measureBuilder.Replace("$(AggregationFunction)", FormatCodeName(m.AggregateFunction.ToString()));
                                    measureBuilder.Replace("$(MeasureName)", FormatCodeName(m.Name));
                                    measureBuilder.Replace("$(Query)", GenerateMdxQueryFor(m, d, cube));

                                    dimensionMeasureTests.Add(measureBuilder.ToString());
                                }

                                StringBuilder dimensionBuilder = new StringBuilder(dimensionTemplate);
                                dimensionBuilder.Replace("$(MeasureGroupName)", FormatCodeName(mg.Name));
                                dimensionBuilder.Replace("$(DimensionName)", FormatCodeName(d.Name));
                                dimensionBuilder.Replace("$(Measure)", string.Join("\n", dimensionMeasureTests));

                                dimensionClasses.Add(dimensionBuilder.ToString());
                            }
                        }

                        var measureTests = new List<string>(mg.Measures.Count);

                        foreach (var m in mg.Measures.Cast<Measure>())
                        {
                            Console.WriteLine("\t\t{0}", m.Name);

                            StringBuilder measureBuilder = new StringBuilder(measureTemplate);
                            measureBuilder.Replace("$(AggregationFunction)", FormatCodeName(m.AggregateFunction.ToString()));
                            measureBuilder.Replace("$(MeasureName)", FormatCodeName(m.Name));

                            measureTests.Add(measureBuilder.ToString());
                        }

                        StringBuilder allDimensionBuilder = new StringBuilder(dimensionTemplate);
                        allDimensionBuilder.Replace("$(MeasureGroupName)", FormatCodeName(mg.Name));
                        allDimensionBuilder.Replace("$(DimensionName)", "All");
                        allDimensionBuilder.Replace("$(Measure)", string.Join("\n", measureTests));

                        dimensionClasses.Add(allDimensionBuilder.ToString());

                        StringBuilder measureGroupBuilder = new StringBuilder(measureGroupTemplate);
                        measureGroupBuilder.Replace("$(MeasureGroupName)", FormatCodeName(mg.Name));
                        measureGroupBuilder.Replace("$(CubeName)", FormatCodeName(cube.Name));
                        measureGroupBuilder.Replace("$(Dimension)", string.Join("\n", dimensionClasses));

                        File.WriteAllText(mgPath, measureGroupBuilder.ToString());
                    }
                }
            }
        }
开发者ID:jsnape,项目名称:pythia,代码行数:96,代码来源:Program.cs


注:本文中的Server.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。