// Create a custom data structure to store airfare in a graph-like structure and retrieve airfare based on nodes // Takes departure airport and arrival airport as arguments public static void StoreAirfare(IRIS irisNative) { // Store routes and distance between airports // This API sets the value, for a global, with the following keys // For example, ^AIRPORT("BOS","AUS") = 1698 irisNative.Set("1698", "^AIRPORT", "BOS", "AUS"); irisNative.Set("450", "^AIRPORT", "BOS", "AUS", "AA150"); irisNative.Set("550", "^AIRPORT", "BOS", "AUS", "AA290"); irisNative.Set("200", "^AIRPORT", "BOS", "PHL", "UA110"); irisNative.Set("700", "^AIRPORT", "BOS", "BIS", "AA330"); irisNative.Set("710", "^AIRPORT", "BOS", "BIS", "UA208"); // Start interactive prompt Console.WriteLine("Enter departure airport: "); String fromAirport = Console.ReadLine(); Console.WriteLine("Enter destination airport: "); String toAirport = Console.ReadLine(); // Query for routes based on input String hasRoutes = "This path has no routes"; int isDefined = irisNative.IsDefined("^AIRPORT", fromAirport, toAirport); if (isDefined == 11 || isDefined == 1) { hasRoutes = "This path has routes"; } Console.WriteLine(""); Console.WriteLine("Printed to ^AIRPORT global. The distance in miles between " + fromAirport + " and " + toAirport + " is: " + irisNative.GetString("^AIRPORT", fromAirport, toAirport) + ". " + hasRoutes); }
public GlobalsNativeCollection(IRIS irisNative, string collectionName = "") { _irisNative = irisNative; CollectionName = $"{collectionName}"; Initialize(); }
// Simple interactive method using IRIS native API to consult the data structure populated in storeAirfare() public static void checkAirfare(IRIS irisNative) { // Prompt for input Console.Write("Enter departure airport: (e.g. BOS)"); String fromAirport = Console.ReadLine(); Console.Write("Enter destination airport: (e.g. AUS)"); String toAirport = Console.ReadLine(); // ^airport(from, to) = distance Console.WriteLine(""); Console.WriteLine("The distance in miles between " + fromAirport + " and " + toAirport + " is: " + irisNative.GetString("^airport", fromAirport, toAirport) + "."); // Now loop through routes: ^airport(from, to, flight) = fare int isDefined = irisNative.IsDefined("^airport", fromAirport, toAirport); if (isDefined == 11) { Console.WriteLine("The following routes exist for this path:"); IRISIterator iterator = irisNative.GetIRISIterator("^airport", fromAirport, toAirport); while (iterator.MoveNext()) { String fare = (String)iterator.Current; String flightNumber = (String)iterator.CurrentSubscript; Console.WriteLine(" - " + flightNumber + ": " + fare + " USD"); } } else { Console.WriteLine("No routes exist for this path."); } }
static void Main(string[] args) { // Create a connection to Cache //CacheConnection conn = new CacheConnection(); IRISConnection conn = new IRISConnection(); IRIS iris; // Cache server Connection Information // Set Server to your IP address and port to Cache SuperServer port, Log File is optional conn.ConnectionString = "Server = localhost; Log File=cprovider.log;Port=1972; Namespace=USER; Password = SYS; User ID = _SYSTEM;"; //Open a Connection to Cache conn.Open(); //CacheMethodSignature ms = new CacheMethodSignature(); //ms.SetReturnType(conn, ClientTypeId.tString); iris = IRIS.CreateIRIS(conn); //CacheObject.RunClassMethod(conn, "%SYSTEM.Version", "GetVersion", ms); string ReturnValue = iris.ClassMethodString("%SYSTEM.Version", "GetVersion"); //Console.Write("ReturnValue = " + ms.ReturnValue._Value); Console.Write("ReturnValue = " + ReturnValue); conn.Close(); }
/// <summary> /// Initialize connections /// - Kafka Consumer /// - Reentrancy to InterSystems IRIS /// </summary> public override void OnInit() { LOGINFO("Initialization started"); var conf = new ConsumerConfig { GroupId = "test-consumer-group", BootstrapServers = SERVERS, // Note: The AutoOffsetReset property determines the start offset in the event // there are not yet any committed offsets for the consumer group for the // topic/partitions of interest. By default, offsets are committed // automatically, so in this example, consumption will only start from the // earliest message in the topic 'my-topic' the first time you run the program. AutoOffsetReset = AutoOffsetReset.Earliest }; consumer = new ConsumerBuilder <Ignore, string>(conf).Build(); consumer.Subscribe(TOPIC); if (TargetConfigNames != null) { targets = TargetConfigNames.Split(","); } iris = GatewayContext.GetIRIS(); LOGINFO("Initialized!"); }
public static void SetTestGlobal(IRIS irisNative) { // Write to a test global irisNative.Set(8888, "^testglobal", "1"); int globalValue = (int)irisNative.GetInt32("^testglobal", "1"); Console.WriteLine("The value of ^testglobal(1) is " + globalValue); }
public void init() { adbksrc = new ADBKDatasource(); //adbksrc.connect("localhost", "1972", "_system", "SYS", "user"); configconn consetup = new configconn(); consetup.LoadSetupFile("..\\connectioninfo.json"); adbksrc.connect(consetup.co.hostname, consetup.co.port.ToString(), consetup.co.username, consetup.co.password, consetup.co.irisnamespace); iris = IRIS.CreateIRIS(adbksrc.conn); }
public GlobalsNativeJsonTreeProvider(IRIS irisNative, string globalName) { _irisNative = irisNative; globalName = globalName ?? string.Empty; if (string.IsNullOrEmpty(globalName) || !globalName.StartsWith("^")) { throw new ArgumentException("Invalid global name format."); } GlobalName = globalName; }
public static void PrintNodes(IRIS irisNative, String globalName) { Console.WriteLine("Iterating over " + globalName + " globals"); // Iterate over all nodes forwards IRISIterator iter = irisNative.GetIRISIterator(globalName); Console.WriteLine("walk forwards"); foreach (var v in iter) { Console.WriteLine("subscript=" + iter.CurrentSubscript + ", value=" + iter.Current); } }
public cacheDirectWapper(string constr) { try { conn.ConnectionString = constr; conn.Open(); IRIS iris = IRIS.CreateIRIS(conn); cd = (IRISObject)iris.ClassMethodObject("CacheDirect.Emulator", "%New"); } finally { } }
public cacheDirectWapper(IRISConnection irisconn) { try { conn = irisconn; iris = IRIS.CreateIRIS(conn); cd = (IRISObject)iris.ClassMethodObject("CacheDirect.Emulator", "%New"); } finally { } }
static void Main(string[] args) { IRIS iris = new IRIS(@"~\..\..\..\data\input\iris.data.csv"); iris.start(iris.Dane); Normal norm = new Normal(); double next = norm.CumulativeDistribution(1 - 1.96); // Console.WriteLine("dystriusa: " + next); Console.ReadKey(); }
public CashCollectionSearchReturnValue CashCollectionSearch(HostSecurityToken oHostSecurityToken, IRIS.Law.WebServiceInterfaces.CollectionRequest collectionRequest, CashCollectionSearchCriteria criteria) { CashCollectionSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oMatterService = new MatterService(); returnValue = oMatterService.CashCollectionSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new CashCollectionSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
static void Main(String[] args) { // If you are using a remote instance, update IP and password here String user = "******"; String password = "******"; String IP = "localhost"; int port = 51773; try { // Connect to database using EventPersister, which is based on IRISDataSource // For more details on EventPersister, visit // https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=BNETXEP_xep EventPersister xepPersister = PersisterFactory.CreatePersister(); xepPersister.Connect(IP, port, "User", user, password); Console.WriteLine("Connected to InterSystems IRIS"); xepPersister.DeleteExtent("Demo.Airport"); // Remove old test data xepPersister.ImportSchemaFull("Demo.Airport"); // Import flat schema // Create XEP Event for object access Event xepEvent = xepPersister.GetEvent("Demo.Airport"); // Create IRIS Native object IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection(); IRIS irisNative = IRIS.CreateIRIS(connection); Console.WriteLine("Generating airport table..."); // Populate 5 airport objects and save to the database using XEP populateAirports(xepEvent); // Get all airports using ADO.NET getAirports(connection); // Store natively - Uncomment the following line for task 3 // StoreAirfare(irisNative); Console.ReadLine(); // Close everything xepEvent.Close(); xepPersister.Close(); } catch (Exception e) { Console.WriteLine("Error creating airport listing: " + e); } }
public static void StoreStockData(IRIS irisNative, IRISConnection dbconnection) { // Clear global from previous runs irisNative.Kill("^nyse"); Console.WriteLine("Storing stock data using Native API..."); // Get stock data using JDBC and write global try { String sql = "select top 1000 TransDate, Name, StockClose, StockOpen, High, Low, Volume from Demo.Stock"; IRISCommand cmd = new IRISCommand(sql, dbconnection); IRISDataReader reader = cmd.ExecuteReader(); ArrayList list = new ArrayList(); string result; while (reader.Read()) { DateTime dt = (DateTime)reader[reader.GetOrdinal("TransDate")]; result = (string)reader[reader.GetOrdinal("Name")] + dt.ToString("MM/dd/yyyy") + reader[reader.GetOrdinal("High")] + reader[reader.GetOrdinal("Low")] + reader[reader.GetOrdinal("StockOpen")] + reader[reader.GetOrdinal("StockClose")] + (int)reader[reader.GetOrdinal("Volume")]; list.Add(result); } Console.WriteLine("Duong"); int id = list.Count; long startConsume = DateTime.Now.Ticks; for (int i = 0; i < id; i++) { irisNative.Set(list[i], "^nyse", i + 1); } long totalConsume = DateTime.Now.Ticks - startConsume; Console.WriteLine("Stored natively successfully. Execution time: " + totalConsume / TimeSpan.TicksPerMillisecond + " ms"); } catch (Exception e) { Console.WriteLine("Error either retrieving data using JDBC or storing to globals: " + e); } }
public static void Task4(IRISADOConnection connection, IRIS native, Event xepEvent){ String sql = "SELECT distinct name FROM demo.stock"; IRISCommand cmd = new IRISCommand(sql, connection); IRISDataReader reader = cmd.ExecuteReader(); var array = new List<StockInfo>(); while(reader.Read()){ StockInfo stock = new StockInfo(); stock.name = (string) reader[reader.GetOrdinal("Name")]; Console.WriteLine("created stockinfo array."); // Generate mission and founder names (Native API) stock.founder = native.ClassMethodString("%PopulateUtils", "Name"); stock.mission = native.ClassMethodString("%PopulateUtils", "Mission"); Console.WriteLine("Adding object with name " + stock.name + " founder " + stock.founder + " and mission " + stock.mission); array.Add(stock); } xepEvent.Store(array.ToArray()); }
static void Main(string[] args) { String ip = "localhost"; int port = 51773; String username = "******"; String password = "******"; String Namespace = "USER"; String className = "myApp.StockInfo"; try { // Connect to database using EventPersister EventPersister xepPersister = PersisterFactory.CreatePersister(); xepPersister.Connect(ip, port, Namespace, username, password); Console.WriteLine("Connected to InterSystems IRIS."); xepPersister.DeleteExtent(className); // remove old test data xepPersister.ImportSchema(className); // import flat schema // Create Event Event xepEvent = xepPersister.GetEvent(className); IRISADOConnection connection = (IRISADOConnection) xepPersister.GetAdoNetConnection(); IRIS native = IRIS.CreateIRIS(connection); // Task 2 // Uncomment the line below to run task 2 // Task2(connection); // Task 3 // Uncomment the line below to run task 3 // Task3(connection, xepEvent); // Task 4 // Comment out Task 2, Task 3 and uncomment the line below to run task 4 // Task4(connection, native, xepEvent); xepEvent.Close(); xepPersister.Close(); } catch (Exception e) { Console.WriteLine("Interactive prompt failed:\n" + e); } }
// Create a custom data structure to store airport distance and airfare information in a graph-like structure. // Query this information with the interactive checkAirfare() method public static void storeAirfare(IRIS irisNative) { // Store routes and distance between airports // The global we'll populate has two levels: // ^airport(from, to) = distance // ^airport(from, to, flight) = fare // This IRIS native API sets the value for a global at the specified subscript level(s) // For example, to set ^airport("BOS","AUS") = 1698 irisNative.Set("1698", "^airport", "BOS", "AUS"); irisNative.Set("450", "^airport", "BOS", "AUS", "AA150"); irisNative.Set("550", "^airport", "BOS", "AUS", "AA290"); irisNative.Set("280", "^airport", "BOS", "PHL"); irisNative.Set("200", "^airport", "BOS", "PHL", "UA110"); irisNative.Set("1490", "^airport", "BOS", "BIS"); irisNative.Set("700", "^airport", "BOS", "BIS", "AA330"); irisNative.Set("710", "^airport", "BOS", "BIS", "UA208"); Console.WriteLine("Stored fare and distance data in ^airport global."); }
public static Trade[] GenerateData(IRIS irisNative, int objectCount) { Trade[] data = new Trade[objectCount]; try{ for (int i = 0; i < objectCount; i++) { DateTime tempDate = Convert.ToDateTime("2018-01-01"); double tempAmount = (double)irisNative.ClassMethodDouble("%PopulateUtils", "Currency"); String tempName = irisNative.ClassMethodString("%PopulateUtils", "String") + irisNative.ClassMethodString("%PopulateUtils", "String") + irisNative.ClassMethodString("%PopulateUtils", "String"); String tempTrader = irisNative.ClassMethodString("%PopulateUtils", "Name"); int tempShares = new Random().Next(1, 20); data[i] = new Trade(tempName, tempDate, tempAmount, tempShares, tempTrader); Console.WriteLine("New trade: " + tempName + " , " + tempDate + " , " + tempAmount + " , " + tempShares + " , " + tempTrader); } } catch (Exception e) { Console.WriteLine(e); } return(data); }
private void btnConnect_Click(object sender, EventArgs e) { //Retrieve connection information from form string ip = txtServer.Text; int port = Convert.ToInt32(txtPort.Text); string Namespace = txtNamespace.Text; string username = txtUsername.Text; string password = txtPassword.Text; /// // Making connection using IRISConnecion connection = new IRISConnection(); // Create connection string connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " + Namespace + "; Password = "******"; User ID = " + username; connection.Open(); txtLog.AppendText("Connected to " + connection.ConnectionString); irisNativeCn = IRIS.CreateIRIS(connection); /// grpUpload.Enabled = true; }
public static void Main(String[] args) { try { // open connection to InterSystems IRIS instance using connection string IRISConnection conn = new IRISConnection(); // edit this ConnectionString to match your environment conn.ConnectionString = "Server=localhost; Port=51773; Namespace=User; Password=SYS; User ID=_system; SharedMemory=false; logfile=./dbnative.log"; conn.Open(); // create IRIS Native object IRIS iris = IRIS.CreateIRIS(conn); Console.WriteLine("[1. Setting and getting a global]"); // setting and getting a global // ObjectScript equivalent: set ^testglobal("1") = 8888 iris.Set(8888, "^testglobal", "1"); // ObjectScript equivalent: set globalValue = $get(^testglobal("1")) Int16?globalValue = iris.GetInt16("^testglobal", "1"); Console.WriteLine("The value of ^testglobal(1) is " + globalValue); Console.WriteLine(); Console.WriteLine("[2. Iterating over a global]"); // modify global to iterate over // ObjectScript equivalent: set ^testglobal("1") = 8888 // ObjectScript equivalent: set ^testglobal("2") = 9999 iris.Set(8888, "^testglobal", "1"); iris.Set(9999, "^testglobal", "2"); // iterate over all nodes forwards Console.WriteLine("walk forwards"); IRISIterator subscriptIter = iris.GetIRISIterator("^testglobal"); foreach (var node in subscriptIter) { Console.WriteLine("subscript=" + subscriptIter.CurrentSubscript + ", value=" + node); } Console.WriteLine(); Console.WriteLine("[3. Calling a class method]"); // calling a class method // ObjectScript equivalent: set returnValue = ##class(%Library.Utility).Date(5) String returnValue = iris.ClassMethodString("%Library.Utility", "Date", 5); Console.WriteLine(returnValue); Console.WriteLine(); // close IRIS object and connection iris.Close(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Get a list of ethnicity values that match the search criteria /// </summary> /// <param name="logonId">Logon id obtained when logging on to the logon service.</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Ethnicity search criteria</param> /// <returns></returns> public EthnicitySearchReturnValue EthnicitySearch(Guid logonId, IRIS.Law.WebServiceInterfaces.CollectionRequest collectionRequest, EthnicitySearchCriteria criteria) { EthnicitySearchReturnValue returnValue = new EthnicitySearchReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: // Can do everything break; default: throw new Exception("Access denied"); } // Create a data list creator for a list of ethnicity values DataListCreator<EthnicitySearchItem> dataListCreator = new DataListCreator<EthnicitySearchItem>(); // Declare an inline event (annonymous delegate) to read the dataset dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvEthnicityLookup.GetEthnicity(); DataTable dt = Functions.SortDataTable(e.DataSet.Tables[0], "EthnicDesc"); e.DataSet.Tables.Remove(e.DataSet.Tables[0]); e.DataSet.Tables.Add(dt); }; // Create the data list returnValue.Ethnicity = dataListCreator.Create(logonId, // Give the query a name so it can be cached "EthnicitySearch", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("Id", "EthnicID"), new ImportMapping("Description", "EthnicDesc"), } ); } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception Ex) { returnValue.Success = false; returnValue.Message = Ex.Message; } return returnValue; }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // Initialize dictionary to store connection details from config.txt IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary = generateConfig("..\\..\\..\\config.txt"); // Retrieve connection information from configuration file string ip = dictionary["ip"]; int port = Convert.ToInt32(dictionary["port"]); string Namespace = dictionary["namespace"]; string username = dictionary["username"]; string password = dictionary["password"]; String className = "myApp.StockInfo"; try { // Connect to database using EventPersister EventPersister xepPersister = PersisterFactory.CreatePersister(); xepPersister.Connect(ip, port, Namespace, username, password); Console.WriteLine("Connected to InterSystems IRIS."); xepPersister.DeleteExtent(className); // Remove old test data xepPersister.ImportSchema(className); // Import flat schema // Create Event Event xepEvent = xepPersister.GetEvent(className); IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection(); IRIS native = IRIS.CreateIRIS(connection); // Starting interactive prompt bool always = true; while (always) { Console.WriteLine("1. Retrieve all stock names"); Console.WriteLine("2. Create objects"); Console.WriteLine("3. Populate properties"); Console.WriteLine("4. Quit"); Console.WriteLine("What would you like to do? "); String option = Console.ReadLine(); switch (option) { // Task 2 case "1": Task2(connection); break; // Task 3 case "2": Task3(connection, xepEvent); break; // Task 4 case "3": Task4(connection, native, xepEvent); break; case "4": Console.WriteLine("Exited."); always = false; break; default: Console.WriteLine("Invalid option. Try again!"); break; } } xepEvent.Close(); xepPersister.Close(); } catch (Exception e) { Console.WriteLine("Interactive prompt failed:\n" + e); } }
/// <summary> /// Get a list of ethnicity values that match the search criteria /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Information about the collection being requested.</param> /// <param name="criteria">Ethnicity search criteria</param> /// <returns></returns> public EthnicitySearchReturnValue EthnicitySearch(HostSecurityToken oHostSecurityToken, IRIS.Law.WebServiceInterfaces.CollectionRequest collectionRequest, EthnicitySearchCriteria criteria) { EthnicitySearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oContactService = new ContactService(); returnValue = oContactService.EthnicitySearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new EthnicitySearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
static void Main(string[] args) { Console.WriteLine("Hello World!"); String ip = "localhost"; int port = 51773; String username = "******"; String password = "******"; String Namespace = "USER"; try { // Making connection IRISConnection connection = new IRISConnection(); connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " + Namespace + "; Password = "******"; User ID = " + username; connection.Open(); Console.WriteLine("Connected to InterSystems IRIS."); IRIS irisNative = IRIS.CreateIRIS(connection); // Task 5 - Uncomment below line to run task 5 // Console.WriteLine("on InterSystems IRIS version: " + irisNative.FunctionString("PrintVersion","^StocksUtil")); bool always = true; while (always) { Console.WriteLine("1. Test"); Console.WriteLine("2. Store stock data"); Console.WriteLine("3. View stock data"); Console.WriteLine("4. Generate Trades"); Console.WriteLine("5. Quit"); Console.WriteLine("What would you like to do? "); String option = Console.ReadLine(); switch (option) { // Task 1 case "1": // Uncomment below line to run task 1 // SetTestGlobal(irisNative); break; // Task 2 case "2": // Uncomment below line to run task 2 // StoreStockData(irisNative, connection); break; // Task 3 case "3": // Uncomment 5 lines below to run task 3 // Console.WriteLine("Printing nyse globals..."); // long startPrint = DateTime.Now.Ticks; //To calculate execution time // PrintNodes(irisNative, "nyse"); // long totalPrint = DateTime.Now.Ticks - startPrint; // Console.WriteLine("Execution time: " + totalPrint/TimeSpan.TicksPerMillisecond + " ms"); break; // Task 4 case "4": // Uncomment below line to run task 4 // GenerateData(irisNative, 10); break; case "5": Console.WriteLine("Exited."); always = false; break; default: Console.WriteLine("Invalid option. Try again!"); break; } } irisNative.Close(); } catch (Exception e) { Console.WriteLine("Error - Exception thrown: " + e); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // Initialize dictionary to store connection details from config.txt IDictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary = generateConfig("..\\..\\..\\config.txt"); // Retrieve connection information from configuration file string ip = dictionary["ip"]; int port = Convert.ToInt32(dictionary["port"]); string Namespace = dictionary["namespace"]; string username = dictionary["username"]; string password = dictionary["password"]; try { // Making connection using IRISConnecion IRISConnection connection = new IRISConnection(); // Create connection string connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " + Namespace + "; Password = "******"; User ID = " + username; connection.Open(); Console.WriteLine("Connected to InterSystems IRIS."); IRIS irisNative = IRIS.CreateIRIS(connection); // Starting interactive prompt bool always = true; while (always) { Console.WriteLine("1. Test"); Console.WriteLine("2. Store stock data"); Console.WriteLine("3. View stock data"); Console.WriteLine("4. Generate Trades"); Console.WriteLine("5. Call Routines"); Console.WriteLine("6. Quit"); Console.WriteLine("What would you like to do? "); String option = Console.ReadLine(); switch (option) { // Task 1 case "1": SetTestGlobal(irisNative); break; // Task 2 case "2": StoreStockData(irisNative, connection); break; // Task 3 case "3": Console.WriteLine("Printing nyse globals..."); long startPrint = DateTime.Now.Ticks; // To calculate execution time // Iterate over all nodes PrintNodes(irisNative, "nyse"); long totalPrint = DateTime.Now.Ticks - startPrint; Console.WriteLine("Execution time: " + totalPrint / TimeSpan.TicksPerMillisecond + " ms"); break; // Task 4 case "4": GenerateData(irisNative, 10); break; // Task 5 case "5": Console.WriteLine("on InterSystems IRIS version: " + irisNative.FunctionString("PrintVersion", "^StocksUtil")); break; case "6": Console.WriteLine("Exited."); always = false; break; default: Console.WriteLine("Invalid option. Try again!"); break; } } irisNative.Close(); } catch (Exception e) { Console.WriteLine("Error - Exception thrown: " + e); } }
/// <summary> /// Search for a user /// </summary> /// <param name="logonId"></param> /// <param name="collectionRequest"></param> /// <param name="criteria"></param> /// <returns></returns> public UserSearchReturnValue UserSearch(Guid logonId, CollectionRequest collectionRequest, IRIS.Law.WebServiceInterfaces.Utilities.UserSearchCriteria criteria) { IRIS.Law.WebServiceInterfaces.Utilities.UserSearchReturnValue returnValue = new IRIS.Law.WebServiceInterfaces.Utilities.UserSearchReturnValue(); try { // Get the logged on user from the current logons and add their // ApplicationSettings the list of concurrent sessions. Host.LoadLoggedOnUser(logonId); try { Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid); switch (UserInformation.Instance.UserType) { case DataConstants.UserType.Staff: // Can do everything break; case DataConstants.UserType.Client: case DataConstants.UserType.ThirdParty: throw new Exception("Access denied"); default: throw new Exception("Access denied"); } // Create a data list creator for a list of Users DataListCreator<IRIS.Law.WebServiceInterfaces.Utilities.UserSearchItem> dataListCreator = new DataListCreator<IRIS.Law.WebServiceInterfaces.Utilities.UserSearchItem>(); // Declare an inline event (annonymous delegate) to read the // dataset if it is required dataListCreator.ReadDataSet += delegate(object Sender, ReadDataSetEventArgs e) { e.DataSet = SrvUserLookup.UserSearch(criteria.UserType, criteria.Name); }; // Create the data list returnValue.Users = dataListCreator.Create(logonId, // Give the query a name so it can be cached "UserSearch", // Tell it the query criteria used so if the cache is accessed // again it knows if it is the same query criteria.ToString(), collectionRequest, // Import mappings to map the dataset row fields to the data // list entity properties new ImportMapping[] { new ImportMapping("UserId", "uid"), new ImportMapping("UserName", "name"), new ImportMapping("Forename", "PersonName"), new ImportMapping("Surname", "PersonSurname") } ); } finally { // Remove the logged on user's ApplicationSettings from the // list of concurrent sessions Host.UnloadLoggedOnUser(); } } catch (System.Data.SqlClient.SqlException) { returnValue.Success = false; returnValue.Message = Functions.SQLErrorMessage; } catch (Exception Ex) { returnValue.Success = false; returnValue.Message = Ex.Message; } return returnValue; }