Esempio n. 1
0
        static void Main(string[] args)
        {
            try
            {
                var aqAquisitionServiceClient = new AQAcquisitionServiceClient("BasicHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc/Basic");
                //var aqAquisitionServiceClient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc");
                var authToken = aqAquisitionServiceClient.GetAuthToken("admin", "admin");
                Console.WriteLine("Token: " + authToken);

                using (var contextScope = new OperationContextScope(aqAquisitionServiceClient.InnerChannel))
                {
                    var runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                    OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    var allLocations = aqAquisitionServiceClient.GetAllLocations();
                    Console.WriteLine("There are " + allLocations.Length + " Locations:");
                    foreach (var location in allLocations)
                    {
                        Console.WriteLine("\t" + location.Identifier);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occurred: " + ex.ToString());
            }
            Console.WriteLine("Enter to quit...");
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                var aqAquisitionServiceClient = new AQAcquisitionServiceClient("BasicHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc/Basic");
                //var aqAquisitionServiceClient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc");
                var authToken = aqAquisitionServiceClient.GetAuthToken("admin", "admin");
                Console.WriteLine("Token: " + authToken);

                using (var contextScope = new OperationContextScope(aqAquisitionServiceClient.InnerChannel))
                {
                    var runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                    OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    var allLocations = aqAquisitionServiceClient.GetAllLocations();
                    Console.WriteLine("There are " + allLocations.Length + " Locations:");
                    foreach (var location in allLocations)
                    {
                        Console.WriteLine("\t" + location.Identifier);
                    }
                }
            }
            catch(Exception ex)
            {
                Console.WriteLine("Error occurred: " + ex.ToString());
            }
            Console.WriteLine("Enter to quit...");
            Console.ReadLine();
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="uid">The user ID for aquarius login</param>
        /// <param name="passwd">The user password for aquaiurs login</param>
        public AquariusClient(string uid, string passwd)
        {
            this.uid    = uid;
            this.passwd = passwd;

            acuisitionClient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService");
            publishClient    = new AquariusPublishServiceClient("BasicHttpBinding_IAquariusPublishService");
        }
        public ContinuousAppendWatcher(TestSuite parent, string label, string location, string param, float[] appVals, bool[] usedVals)
        {
            myParent = parent;

            AASclient = myParent.AASclient;
            APSclient = myParent.APSclient;
            ADSclient = myParent.ADSclient;

            running = false;
            ptCount = 0;

            logPath = AppDomain.CurrentDomain.BaseDirectory + "\\ResultLog";
            logPath += "\\" + DateTime.Today.ToString("yyMMdd") + "_testLog.txt";

            tsLabel = label;
            tsLoc = location;
            tsParam = param;
            tsName = tsParam + " " + tsLabel + " @" + tsLoc;

            useMean = !usedVals[0];
            if (!useMean) ptValue = appVals[1];

            useQ = usedVals[1];
            if (usedVals[1]) ptQ = appVals[2];

            useInterp = usedVals[2];
            if (useInterp) ptInterp = appVals[3];

            useApprov = usedVals[3];
            if (useApprov) ptApprov = appVals[4];

            useFlag = usedVals[4];
            if (useFlag) ptFlag = appVals[5];

            appNum = appVals[6];
            appInterv = appVals[7];
            appInterval = TimeSpan.FromMinutes(appInterv);

            incPts = usedVals[5];
            if (incPts) ptInc = appVals[8];

            timeToStop = usedVals[6];
            if (timeToStop) stopVal = appVals[9];

            if (appVals[10] == 0) stopParam = 1;
            else stopParam = 60;

            ptInterval = TimeSpan.FromMinutes(appVals[0]);

            appendTimer.Elapsed += new ElapsedEventHandler(alarmRing);
            appendTimer.AutoReset = true;
        }
        public void initService()
        {
            if (textBoxHost.Text.Length > 0)
            {
                bool gotDBtype = false;
                try
                {
                    if (gotClients)
                    {
                        AASclient.Close();
                        ADSclient.Close();
                        APSclient.Close();
                        gotClients = false;
                    }

                    host = textBoxHost.Text;
                    string aashost = string.Empty;
                    string adshost = string.Empty;
                    string apshost = string.Empty;

                    if (host.Contains(@"localhost"))
                    {
                        aashost = @"http://*****:*****@"http://localhost:6995/AquariusDataService.svc";
                        apshost = @"http://*****:*****@"http://{0}/AQUARIUS/AQAcquisitionService.svc", host);
                        adshost = string.Format(@"http://{0}/AQUARIUS/AquariusDataService.svc", host);
                        apshost = string.Format(@"http://{0}/AQUARIUS/Publish/AquariusPublishService.svc", host);
                    }

                    AASclient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService", aashost);
                    ADSclient = new AquariusDataServiceClient("BasicHttpBinding_AquariusDataService", adshost);
                    APSclient = new AquariusPublishServiceClient("BasicHttpBinding_IAquariusPublishService", apshost);

                    connectedHost = host;
                    gotClients = true;

                    statusInfo.Text = "Acquiring Authorization Token... ";
                    statusInfo.Refresh();
                    authToken = APSclient.GetAuthToken(user, password);//All 3 services share the same token
                    System.Diagnostics.Trace.WriteLine("AuthToken is: " + authToken);
                    statusInfo.Text += "Done";
                    statusInfo.Refresh();

                    dbType = ADSclient.GetDbType();
                    if (dbType.CompareTo("Oracle") == 0)
                        sqlGetLoc = "select LocationID from Location where rownum =1 AND LocationID > 0";
                    else
                        if (dbType.CompareTo("MySql") == 0)
                            sqlGetLoc = "select LocationID from Location limit 1 where LocationID > 0";
                        else
                            sqlGetLoc = "select TOP 1 LocationID FROM Location WHERE LocationID > 0";
                    gotDBtype = true;

                    //ToDo: we may to improve this head setting logic. Token will expire in an hour.
                    //We can move this authen part to before run test.

                    //Add token to data service:
                    {
                        OperationContextScope context = new OperationContextScope(ADSclient.InnerChannel);
                        MessageHeader runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                        OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    }

                    //Add token to publish service context:
                    {
                        OperationContextScope context = new OperationContextScope(APSclient.InnerChannel);
                        MessageHeader runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                        OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    }

                    //Add acquisition service:
                    {
                        OperationContextScope context = new OperationContextScope(AASclient.InnerChannel);
                        MessageHeader runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                        OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    }

                    servUTCOff_hrs = (ADSclient.GetCurrentServerTime() - ADSclient.GetCurrentServerTime().ToUniversalTime()).Hours;

                    //if (connectedHost == "aiapp1") textboxRootLocationFolder.Text = "WSC";
                    //else if (connectedHost == "chilko") textboxRootLocationFolder.Text = "Third Primary Root";

                }
                catch (Exception ex)
                {
                    string message = "";
                    if (gotClients)
                        if (gotDBtype)
                            message += "PublishClient.GetAuthToken() threw exception: " + ex.Message;
                        else
                            message += "DataServiceClient.GetDbType() threw exception: " + ex.Message;
                    else
                        message += "Client Constructor threw exception: " + ex.Message;
                    MessageBox.Show(message, "Aquarius Server Error");
                    writeLog.AppendLine("@" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + " there was an error in initService() method - " + message);
                    writeToLog();
                    throw ex;
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid server name/address", "Invalid Entry");
            }
        }
        public CustomAppendWatcher(TestSuite parent, object[] tsParam)
        {
            myParent = parent;

            AASclient = myParent.AASclient;
            APSclient = myParent.APSclient;
            ADSclient = myParent.ADSclient;

            logPath = AppDomain.CurrentDomain.BaseDirectory + "\\ResultLog";
            logPath += "\\" + DateTime.Today.ToString("yyMMdd") + "_testLog.txt";

            cLabel = (string)tsParam[0];
            cLoc = (string)tsParam[1];
            cParam = (string)tsParam[2];
            newTS = (bool)tsParam[3];
            cPtArray = (byte[])tsParam[4];

            cName = cParam + " " + cLabel + " @" + cLoc;
        }