Esempio n. 1
0
        /// <summary>
        /// Create a new scopde domain service instance
        /// </summary>
        /// <param name="authenticatedUser">Authenticated user object</param>
        /// <param name="uow">Unit of Work object</param>
        /// <param name="repository">User repository service</param>
        /// <param name="credentialRepository">Credential repository service</param>
        /// <param name="tokenRepository">User credential token repository service</param>
        /// <param name="scopeRepository">Scope repository</param>
        /// <param name="roleRepository">Role repository</param>
        /// <param name="securityOptions">Security options configuration</param>
        /// <param name="credentialOptions">Credential options configuration</param>
        /// <param name="localizer">Language string localizer</param>
        public UserDomainService
        (
            IAuthenticatedUser authenticatedUser,
            IUnitOfWork uow,
            IUserRepository repository,
            IUserCredentialRepository credentialRepository,
            IUserCredentialTokenRepository tokenRepository,
            IScopeRepository scopeRepository,
            IRoleRepository roleRepository,
            IOptions <SecurityOptions> securityOptions,
            IOptions <CredentialOptions> credentialOptions,
            IStringLocalizer <UserDomainService> localizer
        ) : base(repository, authenticatedUser)
        {
            _uow                  = uow;
            _repository           = repository;
            _credentialRepository = credentialRepository;
            _tokenRepository      = tokenRepository;
            _scopeRepository      = scopeRepository;
            _roleRepository       = roleRepository;

            _securityOptions   = securityOptions?.Value;
            _credentialOptions = credentialOptions?.Value;
            _localizer         = localizer;
        }
 protected internal virtual NetworkCredential CreateNetworkCredential(CredentialOptions options)
 {
     return(options != null
                         ? new NetworkCredential(
                options.UserName,
                new NetworkCredential("UserName", options.Password).SecurePassword,
                options.Domain)
                         : null);
 }
        /// <summary>
        /// Allows getting the server version, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// This function returns the following information
        /// <list type="definition">
        /// <item><term>LKMVCOMPONENTSVERSION</term><description>MV Components version.</description></item>
        /// <item><term>LKSERVERVERSION</term><description>Linkar SERVER version.</description></item>
        /// <item><term>LKCLIENTVERSION</term><description>Used client library version.</description></item>
        /// <item><term>DATABASE</term><description>Database.</description></item>
        /// <item><term>OS</term><description>Operating system.</description></item>
        /// <item><term>DATEZERO</term><description>Date zero base in YYYYMMDD format.</description></item>
        /// <item><term>DATEOUTPUTCONVERSION</term><description>Output conversion for date used by Linkar Schemas.</description></item>
        /// <item><term>TIMEOUTPUTCONVERSION</term><description>Output conversion for time used by Linkar Schemas.</description></item>
        /// <item><term>MVDATETIMESEPARATOR</term><description>DateTime used separator used by Linkar Schemas, for instance 18325,23000.</description></item>
        /// <item><term>MVBOOLTRUE</term><description>Database used char for the Boolean true value used by Linkar Schemas.</description></item>
        /// <item><term>MVBOOLFALSE</term><description>Database used char for the Boolean false value used by Linkar Schemas.</description></item>
        /// <item><term>OUTPUTBOOLTRUE</term><description>Used char for the Boolean true value out of the database used by Linkar Schemas.</description></item>
        /// <item><term>OUTPUTBOOLFALSE</term><description>Used char for the Boolean false value out of the database used by Linkar Schemas.</description></item>
        /// <item><term>MVDECIMALSEPARATOR</term><description>Decimal separator in the database. May be point, comma or none when the database does not store decimal numbers. Used by Linkar Schemas.</description></item>
        /// <item><term>OTHERLANGUAGES</term><description>Languages list separated by commas.</description></item>
        /// <item><term>TABLEROWSEPARATOR</term><description>It is the decimal char that you use to separate the rows in the output table format. By default 11.</description></item>
        /// <item><term>TABLECOLSEPARATOR</term><description>It is the decimal char that you use to separate the columns in the output table format. By default 9.</description></item>
        /// </list>
        /// </remarks>
        /// <seealso href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">Schemas Parameter</seealso>
        public static string GetVersion(CredentialOptions credentialOptions, DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV, int receiveTimeout = 0)
        {
            string versionArgs      = OperationArguments.GetVersionArgs();
            byte   opCode           = (byte)OPERATION_CODE.VERSION;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, versionArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Resets the COMMON variables with the 100 most used files, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string ResetCommonBlocks(CredentialOptions credentialOptions, DATAFORMAT_TYPE outputFormat, int receiveTimeout = 0)
        {
            string resetCommonBlocksArgs = OperationArguments.GetResetCommonBlocksArgs();
            byte   opCode           = (byte)OPERATION_CODE.RESETCOMMONBLOCKS;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, resetCommonBlocksArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Starts the communication with a server allowing making use of the rest of functions until the Close method is executed or the connection with the server gets lost, in a asynchronous way.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <remarks>
        /// Login is actually a "virtual" operation which creates a new Client Session ID. No DBMS login is performed unless Linkar SERVER determines new Database Sessions are required - these operations are not related.
        /// </remarks>
        public Task LoginAsync(CredentialOptions credentialOptions, string customVars = "", int receiveTimeout = 0)
        {
            var task = new Task(() =>
            {
                this.Login(credentialOptions, customVars, receiveTimeout);
            });

            task.Start();
            return(task);
        }
        /// <summary>
        /// Allows a variety of asynchronous direct operations using standard XML templates, asynchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="command">Content of the operation you want to send.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <example>
        /// <code lang="CS">
        /// using Linkar;
        /// using Linkar.Commands.Direct;
        ///
        /// class Test
        ///     {
        ///         public string MySendCommand()
        ///         {
        ///             string result = "";
        ///             try
        ///             {
        ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
        ///                 string command =
        ///                     "&lt;COMMAND NAME=\"READ\"&gt;" +
        ///                     "   &lt;CALCULATED&gt;True&lt;/CALCULATED&gt;" +
        ///                     "   &lt;OUTPUT_FORMAT&gt;XML_DICT&lt;/OUTPUT_FORMAT&gt;" +
        ///                     "   &lt;FILE_NAME&gt;LK.CUSTOMERS&lt;/FILE_NAME&gt;" +
        ///                     "   &lt;RECORDS&gt;" +
        ///                     "       &lt;RECORD&gt;" +
        ///                     "           &lt;LKITEMID&gt;2&lt;/LKITEMID&gt;" +
        ///                     "       &lt;/RECORD&gt;" +
        ///                     "   &lt;/RECORDS&gt;" +
        ///                     "&lt;/COMMAND&gt;";
        ///                 result = DirectCommands.SendXmlCommandAsync(credentials, command).Result;
        ///             }
        ///             catch (Exception ex)
        ///             {
        ///                 string error = ex.Message;
        ///                 // Do something
        ///             }
        ///             return result;
        ///         }
        ///     }
        /// </code>
        /// <code lang="VB">
        /// Imports Linkar
        /// using Linkar.Commands.Direct;
        ///
        /// Class Test
        ///
        ///     Public Function MySendCommand() As String
        ///
        ///         Dim result As String = ""
        ///
        ///         Try
        ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
        ///
        ///             string command =
        ///                     "&lt;COMMAND NAME=\"READ\"&gt;" +
        ///                     "   &lt;CALCULATED&gt;True&lt;/CALCULATED&gt;" +
        ///                     "   &lt;OUTPUT_FORMAT&gt;XML_DICT&lt;/OUTPUT_FORMAT&gt;" +
        ///                     "   &lt;FILE_NAME&gt;LK.CUSTOMERS&lt;/FILE_NAME&gt;" +
        ///                     "   &lt;RECORDS&gt;" +
        ///                     "       &lt;RECORD&gt;" +
        ///                     "           &lt;LKITEMID&gt;2&lt;/LKITEMID&gt;" +
        ///                     "       &lt;/RECORD&gt;" +
        ///                     "   &lt;/RECORDS&gt;" +
        ///                     "&lt;/COMMAND&gt;"
        ///             result = DirectCommands.SendXmlCommandAsync(credentials, command).Result
        ///
        ///         Catch ex As Exception
        ///             Dim[error] As String = ex.Message
        ///             ' Do something
        ///         End Try
        ///
        ///         Return result
        ///   End Function
        /// End Class
        /// </code>
        /// </example>
        public static Task <string> SendXmlCommandAsync(CredentialOptions credentialOptions, string command, int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(SendXmlCommand(credentialOptions, command, receiveTimeout));
            });

            task.Start();
            return(task);
        }
        /// <summary>
        /// Allows a variety of direct operations using standard JSON or XML templates, asynchronously.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="command">Content of the operation you want to send.</param>
        /// <param name="commandFormat">Indicates in what format you are doing the operation: XML or JSON.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static Task <string> SendCommandAsync(CredentialOptions credentialOptions, string command, ENVELOPE_FORMAT commandFormat = ENVELOPE_FORMAT.XML, int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(SendCommand(credentialOptions, command, commandFormat, receiveTimeout));
            });

            task.Start();
            return(task);
        }
Esempio n. 8
0
        /// <summary>
        /// Returns a list of all the Schemas defined in Linkar Schemas, or the EntryPoint account data files, in a asynchronous way with TABLE output format.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="lkSchemasOptions">This object defines the different options in base of the asked Schema Type: LKSCHEMAS, SQLMODE o DICTIONARIES.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <example>
        /// <code lang="CS">
        /// using Linkar;
        /// using Linkar.Functions.Direct.TABLE;
        ///
        /// class Test
        ///     {
        ///         public string MyLkSchemas()
        ///         {
        ///             string result = "";
        ///             try
        ///             {
        ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
        ///                 LkSchemasOptions options = new LkSchemasOptions(RowHeaders.TYPE.MAINLABEL, false, false);
        ///                 result = Functions.LkSchemasAsync(credentials, options).Result;
        ///             }
        ///             catch (Exception ex)
        ///             {
        ///                 string error = ex.Message;
        ///                 // Do something
        ///             }
        ///             return result;
        ///         }
        ///     }
        /// </code>
        /// <code lang="VB">
        /// Imports Linkar
        /// Imports Linkar.Functions.Direct.TABLE
        ///
        /// Class Test
        ///
        ///     Public Function MyLkSchemas() As String
        ///         Dim result As String = ""
        ///
        ///         Try
        ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
        ///
        ///             Dim options As LkSchemasOptions = New LkSchemasOptions(RowHeaders.TYPE.MAINLABEL, False, False);
        ///             result = Functions.LkSchemasAsync(credentials, options).Result
        ///     Catch ex As Exception
        ///         Dim[error] As String = ex.Message
        ///             ' Do something
        ///
        ///         End Try
        ///
        ///         Return result
        ///   End Function
        /// End Class
        /// </code>
        /// </example>
        /// <remarks>
        /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
        /// <para>By default:
        /// <list type="bullet">
        /// <item>TAB char (9) for columns.</item>
        /// <item>VT char (11) for rows.</item>
        /// </list>
        /// </para>
        /// </remarks>
        public static Task <string> LkSchemasAsync(CredentialOptions credentialOptions, LkSchemasOptions lkSchemasOptions = null,
                                                   string customVars = "", int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(LkSchemas(credentialOptions, lkSchemasOptions, customVars, receiveTimeout));
            });

            task.Start();
            return(task);
        }
Esempio n. 9
0
        /// <summary>
        /// Returns the Schema properties list defined in Linkar Schemas or the file dictionaries, in a asynchronous way with TABLE output format.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File name to LkProperties</param>
        /// <param name="lkPropertiesOptions">This object defines the different options in base of the asked Schema Type: LKSCHEMAS, SQLMODE o DICTIONARIES.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <example>
        /// <code lang="CS">
        /// using Linkar;
        /// using Linkar.Functions.Direct.TABLE;
        ///
        /// class Test
        ///     {
        ///         public string MyLkProperties()
        ///         {
        ///             string result = "";
        ///             try
        ///             {
        ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
        ///                 LkPropertiesOptions options = new LkPropertiesOptions(RowHeaders.TYPE.MAINLABEL, false, false, false);
        ///                 result = Functions.LkPropertiesAsync(credentials, "LK.CUSTOMERS", options).Result;
        ///             }
        ///             catch (Exception ex)
        ///             {
        ///                 string error = ex.Message;
        ///                 // Do something
        ///             }
        ///             return result;
        ///         }
        ///     }
        /// </code>
        /// <code lang="VB">
        /// Imports Linkar
        /// Imports Linkar.Functions.Direct.TABLE
        ///
        /// Class Test
        ///
        ///     Public Function MyLkProperties() As String
        ///         Dim result As String = ""
        ///
        ///         Try
        ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
        ///
        ///             Dim options As LkPropertiesOptions = New LkPropertiesOptions(RowHeaders.TYPE.MAINLABEL, False, False, False);
        ///             result = Functions.LkPropertiesAsync(credentials, "LK.CUSTOMERS",options).Result
        ///         Catch ex As Exception
        ///
        ///             Dim[error] As String = ex.Message
        ///             ' Do something
        ///         End Try
        ///
        ///         Return result
        ///   End Function
        /// End Class
        /// </code>
        /// </example>
        /// <remarks>
        /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
        /// <para>By default:
        /// <list type="bullet">
        /// <item>TAB char (9) for columns.</item>
        /// <item>VT char (11) for rows.</item>
        /// </list>
        /// </para>
        /// </remarks>
        public static Task <string> LkPropertiesAsync(CredentialOptions credentialOptions, string filename, LkPropertiesOptions lkPropertiesOptions = null,
                                                      string customVars = "", int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(LkProperties(credentialOptions, filename, lkPropertiesOptions, customVars, receiveTimeout));
            });

            task.Start();
            return(task);
        }
        /// <summary>
        /// Returns a query result in a table format, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File or table name defined in Linkar Schemas. Table notation is: MainTable[.MVTable[.SVTable]]</param>
        /// <param name="selectClause">Statement fragment specifies the selection condition. For example WITH CUSTOMER = '1'</param>
        /// <param name="dictClause">Space-delimited list of dictionaries to read. If this list is not set, all fields are returned. For example CUSTOMER DATE ITEM. In NONE mode you may use the format LKFLDx where x is the attribute number.</param>
        /// <param name="sortClause">Statement fragment specifies the selection order. If there is a selection rule Linkar will execute a SSELECT, otherwise Linkar will execute a SELECT. For example BY CUSTOMER</param>
        /// <param name="tableOptions">Detailed options to be used, including: rowHeaders, rowProperties, onlyVisibe, usePropertyNames, repeatValues, applyConversion, applyFormat, calculated, pagination, regPage, numPage.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
        /// <para>By default:
        /// <list type="bullet">
        /// <item>TAB char (9) for columns.</item>
        /// <item>VT char (11) for rows.</item>
        /// </list>
        /// </para>
        /// </remarks>
        public static string GetTable(CredentialOptions credentialOptions, string filename, string selectClause = "", string dictClause = "", string sortClause = "",
                                      TableOptions tableOptions = null, string customVars = "", int receiveTimeout = 0)
        {
            string getTableArgs     = OperationArguments.GetGetTableArgs(filename, selectClause, dictClause, sortClause, tableOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.GETTABLE;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)DATAFORMATSCH_TYPE.TABLE;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, getTableArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Reads one or several records of a file in synchronous way.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File name to read.</param>
        /// <param name="recordIds">A list of item IDs to read, separated by the Record Separator character (30). Use StringFunctions.ComposeRecordIds to compose this string</param>
        /// <param name="dictionaries">List of dictionaries to read, separated by space. If this list is not set, all fields are returned. You may use the format LKFLDx where x is the attribute number.</param>
        /// <param name="readOptions">Object that defines the different reading options of the Function: Calculated, dictClause, conversion, formatSpec, originalRecords.</param>
        /// <param name="inputFormat">Indicates in what format you wish to send the record ids: MV, XML or JSON.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Read(CredentialOptions credentialOptions, string filename, string recordIds, string dictionaries = "", ReadOptions readOptions = null,
                                  DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMATCRU_TYPE outputFormat = DATAFORMATCRU_TYPE.MV, string customVars = "", int receiveTimeout = 0)
        {
            string readArgs         = OperationArguments.GetReadArgs(filename, recordIds, dictionaries, readOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.READ;
            byte   byteInputFormat  = (byte)inputFormat;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, readArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
Esempio n. 12
0
        /// <summary>
        /// Returns a query result in a table format, synchronously only, in a asynchronous way with TABLE output format.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File or table name defined in Linkar Schemas. Table notation is: MainTable[.MVTable[.SVTable]]</param>
        /// <param name="selectClause">Statement fragment specifies the selection condition. For example WITH CUSTOMER = '1'</param>
        /// <param name="dictClause">Space-delimited list of dictionaries to read. If this list is not set, all fields are returned. For example CUSTOMER DATE ITEM. In NONE mode you may use the format LKFLDx where x is the attribute number.</param>
        /// <param name="sortClause">Statement fragment specifies the selection order. If there is a selection rule Linkar will execute a SSELECT, otherwise Linkar will execute a SELECT. For example BY CUSTOMER</param>
        /// <param name="tableOptions">Detailed options to be used, including: rowHeaders, rowProperties, onlyVisibe, usePropertyNames, repeatValues, applyConversion, applyFormat, calculated, pagination, regPage, numPage.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <example>
        /// <code lang="CS">
        /// using Linkar;
        /// using Linkar.Functions.Direct.TABLE;
        ///
        /// class Test
        ///     {
        ///         public string MyGetTable()
        ///         {
        ///             string result = "";
        ///             try
        ///             {
        ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
        ///                 TableOptions options = new TableOptions(RowHeaders.TYPE.MAINLABEL, false, false, false, false, false, false, false);
        ///                 result = Functions.GetTableAsync(credentials, "LK.CUSTOMERS", options).Result;
        ///             }
        ///             catch (Exception ex)
        ///             {
        ///                 string error = ex.Message;
        ///                 // Do something
        ///             }
        ///             return result;
        ///         }
        ///     }
        /// </code>
        /// <code lang="VB">
        /// Imports Linkar
        /// Imports Linkar.Functions.Direct.TABLE
        ///
        /// Class Test
        ///
        ///     Public Function MyGetTable() As String
        ///         Dim result As String = ""
        ///
        ///         Try
        ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
        ///
        ///             Dim options As TableOptions = New TableOptions(RowHeaders.TYPE.MAINLABEL, False, False, False, False, False, False, False);
        ///             result = Functions.GetTableAsync(credentials, "LK.CUSTOMERS",options).Result
        ///         Catch ex As Exception
        ///
        ///             Dim[error] As String = ex.Message
        ///             ' Do something
        ///         End Try
        ///
        ///         Return result
        ///   End Function
        /// End Class
        /// </code>
        /// </example>
        /// <remarks>
        /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
        /// <para>By default:
        /// <list type="bullet">
        /// <item>TAB char (9) for columns.</item>
        /// <item>VT char (11) for rows.</item>
        /// </list>
        /// </para>
        /// </remarks>
        public static Task <string> GetTableAsync(CredentialOptions credentialOptions, string filename, string selectClause = "", string dictClause = "", string sortClause = "",
                                                  TableOptions tableOptions = null, string customVars = "", int receiveTimeout = 0)
        {
            var task = new Task <string>(() =>
            {
                return(GetTable(credentialOptions, filename, selectClause, dictClause, sortClause, tableOptions, customVars, receiveTimeout));
            });

            task.Start();
            return(task);
        }
        /// <summary>
        /// Returns the result of executing the FMT function in a expressions list in the Database, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="expression">The data or expression to format. If multiple values are present, the operation will be performed individually on all values in the expression.</param>
        /// <param name="formatSpec">Specified format</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Format(CredentialOptions credentialOptions, string expression, string formatSpec,
                                    DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                    string customVars            = "", int receiveTimeout = 0)
        {
            string formatArgs       = OperationArguments.GetFormatArgs(expression, formatSpec, customVars);
            byte   opCode           = (byte)OPERATION_CODE.FORMAT;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, formatArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Update one or more attributes of one or more file records, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">Name of the file being updated.</param>
        /// <param name="records">Buffer of record data to update. Inside this string are the recordIds, the modified records, and the originalRecords. Use StringFunctions.ComposeUpdateBuffer (Linkar.Strings library) function to compose this string.</param>
        /// <param name="dictionaries">List of dictionaries to write, separated by space. In MV output format is mandatory. You may use the format LKFLDx where x is the attribute number.</param>
        /// <param name="updateOptions">Object with write options, including optimisticLockControl, readAfter, calculated, dictionaries, conversion, formatSpec, originalRecords.</param>
        /// <param name="inputFormat">Indicates in what format you wish to send the resultant writing data: MV, XML or JSON.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// Inside the records argument, the recordIds and the modified records always must be specified. But the originalRecords not always.
        /// When <see cref="UpdateOptions">updateOptions</see> argument is specified and the <see cref="UpdateOptions.OptimisticLockControl"/> property is set to true, a copy of the record must be provided before the modification (originalRecords argument)
        /// to use the Optimistic Lock technique. This copy can be obtained from a previous <see cref="Read"/> operation. The database, before executing the modification,
        /// reads the record and compares it with the copy in originalRecords, if they are equal the modified record is executed.
        /// But if they are not equal, it means that the record has been modified by other user and its modification will not be saved.
        /// The record will have to be read, modified and saved again.
        /// </remarks>
        public static string UpdatePartial(CredentialOptions credentialOptions, string filename, string records, string dictionaries = "", UpdateOptions updateOptions = null,
                                           DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMATCRU_TYPE outputFormat = DATAFORMATCRU_TYPE.MV,
                                           string customVars           = "", int receiveTimeout = 0)
        {
            string updateArgs       = OperationArguments.GetUpdatePartialArgs(filename, records, dictionaries, updateOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.UPDATEPARTIAL;
            byte   byteInputFormat  = (byte)inputFormat;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, updateArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Deletes one or several records in file, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">The file name where the records are going to be deleted. DICT in case of deleting a record that belongs to a dictionary.</param>
        /// <param name="records">Buffer of records to be deleted. Use StringFunctions.ComposeDeleteBuffer (Linkar.Strings library) function to compose this string.</param>
        /// <param name="deleteOptions">Object with options to manage how records are deleted, including optimisticLockControl, recoverRecordIdType.</param>
        /// <param name="inputFormat">Indicates in what format you wish to send the resultant writing data: MV, XML or JSON.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// Inside the records argument, the recordIds always must be specified. But the originalRecords not always.
        /// When <see cref="DeleteOptions">deleteOptions</see> argument is specified and the <see cref="DeleteOptions.OptimisticLockControl"/> property is set to true,
        /// a copy of the record must be provided before the deletion to use the Optimistic Lock technique.
        /// This copy can be obtained from a previous <see cref="Read"/> operation. The database, before executing the deletion,
        /// reads the record and compares it with the copy in originalRecords, if they are equal the record is deleted.
        /// But if they are not equal, it means that the record has been modified by other user and the record will not be deleted.
        /// The record will have to be read, and deleted again.
        /// </remarks>
        public static string Delete(CredentialOptions credentialOptions, string filename, string records, DeleteOptions deleteOptions = null,
                                    DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                    string customVars           = "", int receiveTimeout = 0)
        {
            string deleteArgs       = OperationArguments.GetDeleteArgs(filename, records, deleteOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.DELETE;
            byte   byteInputFormat  = (byte)inputFormat;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, deleteArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Executes a Query in the Database, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">Name of file on which the operation is performed. For example LK.ORDERS</param>
        /// <param name="selectClause">Statement fragment specifies the selection condition. For example WITH CUSTOMER = '1'</param>
        /// <param name="sortClause">Statement fragment specifies the selection order. If there is a selection rule, Linkar will execute a SSELECT, otherwise Linkar will execute a SELECT. For example BY CUSTOMER</param>
        /// <param name="dictClause">Space-delimited list of dictionaries to read. If this list is not set, all fields are returned. For example CUSTOMER DATE ITEM. You may use the format LKFLDx where x is the attribute number.</param>
        /// <param name="preSelectClause">An optional command that executes before the main Select</param>
        /// <param name="selectOptions">Object with options to manage how records are selected, including calculated, dictionaries, conversion, formatSpec, originalRecords, onlyItemId, pagination, regPage, numPage.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// In the preSelectClause argument these operations can be carried out before executing the Select statement:
        ///  <list type="bullet">
        ///   <item>Previously call to a saved list with the GET.LIST command to use it in the Main Select input</item>
        ///   <item>Make a previous Select to use the result as the Main Select input, with the SELECT or SSELECT commands.In this case the entire sentence must be indicated in the PreselectClause. For example:SSELECT LK.ORDERS WITH CUSTOMER = '1'</item>
        ///   <item>Exploit a Main File index to use the result as a Main Select input, with the SELECTINDEX command. The syntax for all the databases is SELECTINDEX index.name.value. For example SELECTINDEX ITEM,"101691"</item>
        /// </list>
        /// </remarks>
        public static string Select(CredentialOptions credentialOptions, string filename, string selectClause = "", string sortClause = "", string dictClause = "", string preSelectClause = "", SelectOptions selectOptions = null,
                                    DATAFORMATCRU_TYPE outputFormat = DATAFORMATCRU_TYPE.MV,
                                    string customVars = "", int receiveTimeout = 0)
        {
            string selectArgs       = OperationArguments.GetSelectArgs(filename, selectClause, sortClause, dictClause, preSelectClause, selectOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.SELECT;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, selectArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Allows the execution of any command from the Database synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="statement">The command you want to execute in the Database.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Execute(CredentialOptions credentialOptions, string statement,
                                     DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                     string customVars            = "", int receiveTimeout = 0)
        {
            string executeArgs      = OperationArguments.GetExecuteArgs(statement, customVars);
            byte   opCode           = (byte)OPERATION_CODE.EXECUTE;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, executeArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Returns all the dictionaries of a file, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File name</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Dictionaries(CredentialOptions credentialOptions, string filename,
                                          DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                          string customVars            = "", int receiveTimeout = 0)
        {
            string dictionariesArgs = OperationArguments.GetDictionariesArgs(filename, customVars);
            byte   opCode           = (byte)OPERATION_CODE.DICTIONARIES;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, dictionariesArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Executes a subroutine, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="subroutineName">Name of BASIC subroutine to execute.</param>
        /// <param name="argsNumber">Number of arguments.</param>
        /// <param name="arguments">The subroutine arguments list. Each argument is a substring separated with the ASCII char DC4 (20).</param>
        /// <param name="inputFormat">Indicates in what format you wish to send the subroutine arguments: MV, XML or JSON.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Subroutine(CredentialOptions credentialOptions, string subroutineName, int argsNumber, string arguments,
                                        DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                        string customVars           = "", int receiveTimeout = 0)
        {
            string subroutineArgs   = OperationArguments.GetSubroutineArgs(subroutineName, argsNumber, arguments, customVars);
            byte   opCode           = (byte)OPERATION_CODE.SUBROUTINE;
            byte   byteInputFormat  = (byte)inputFormat;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, subroutineArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Returns the result of executing ICONV() or OCONV() functions from a expression list in the Database, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="conversionType">Indicates the conversion type, input or output: INPUT=ICONV(); OUTPUT=OCONV()</param>
        /// <param name="expression">The data or expression to convert. May include MV marks (value delimiters), in which case the conversion will execute in each value obeying the original MV mark.</param>
        /// <param name="code">The conversion code. Must obey the Database conversions specifications.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML or JSON.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string Conversion(CredentialOptions credentialOptions, string expression, string code, CONVERSION_TYPE conversionType,
                                        DATAFORMAT_TYPE outputFormat = DATAFORMAT_TYPE.MV,
                                        string customVars            = "", int receiveTimeout = 0)
        {
            string conversionArgs   = OperationArguments.GetConversionArgs(expression, code, conversionType, customVars);
            byte   opCode           = (byte)OPERATION_CODE.CONVERSION;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, conversionArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
        /// <summary>
        /// Returns the Schema properties list defined in Linkar Schemas or the file dictionaries, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="filename">File name to LkProperties.</param>
        /// <param name="lkPropertiesOptions">This object defines the different options in base of the asked Schema Type: LKSCHEMAS, SQLMODE o DICTIONARIES.</param>
        /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the operation: MV, XML, JSON or TABLE.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        /// <remarks>
        /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
        /// <para>By default:
        /// <list type="bullet">
        /// <item>TAB char (9) for columns.</item>
        /// <item>VT char (11) for rows.</item>
        /// </list>
        /// </para>
        /// </remarks>
        public static string LkProperties(CredentialOptions credentialOptions, string filename, LkPropertiesOptions lkPropertiesOptions = null,
                                          DATAFORMATSCH_TYPE outputFormat = DATAFORMATSCH_TYPE.MV,
                                          string customVars = "", int receiveTimeout = 0)
        {
            string lkPropertiesArgs = OperationArguments.GetLkPropertiesArgs(filename, lkPropertiesOptions, customVars);
            byte   opCode           = (byte)OPERATION_CODE.LKPROPERTIES;
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)outputFormat;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, lkPropertiesArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
Esempio n. 22
0
        /// <summary>
        /// Starts the communication with a server allowing making use of the rest of functions until the Close method is executed or the connection with the server gets lost, synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <remarks>
        /// Login is actually a "virtual" operation which creates a new Client Session ID. No DBMS login is performed unless Linkar SERVER determines new Database Sessions are required. These operations are not related.
        /// </remarks>
        public void Login(CredentialOptions credentialOptions, string customVars = "", int receiveTimeout = 0)
        {
            if (this._ConnectionInfo == null)
            {
                string options          = "";
                string US_str           = "\x1F";
                string loginArgs        = customVars + US_str + options;
                byte   byteOpCode       = (byte)OPERATION_CODE.LOGIN;
                byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
                byte   byteOutputFormat = (byte)DATAFORMAT_TYPE.MV;
                if (receiveTimeout <= 0)
                {
                    if (this._ReceiveTimeout > 0)
                    {
                        receiveTimeout = this._ReceiveTimeout;
                    }
                }
                ConnectionInfo connectionInfo = new ConnectionInfo("", "", "", credentialOptions);
                string         loginResult    = Linkar.ExecutePersistentOperation(connectionInfo, byteOpCode, loginArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

                if (!string.IsNullOrEmpty(loginResult))
                {
                    const string RECORD_IDS_KEY = "RECORD_ID";
                    const char   FS             = '\x1C';
                    const char   AM             = '\xFE';

                    string   sessionId = "";
                    string[] parts     = loginResult.Split(FS);
                    if (parts.Length >= 1)
                    {
                        string[] headersList = parts[0].Split(AM);
                        for (int i = 1; i < headersList.Length; i++)
                        {
                            if (headersList[i].ToUpper() == RECORD_IDS_KEY)
                            {
                                sessionId = parts[i];
                                break;
                            }
                        }
                    }

                    string lkConnectionId = connectionInfo.LkConnectionId;
                    string publicKey      = connectionInfo.PublicKey;
                    this._ConnectionInfo = new ConnectionInfo(sessionId, lkConnectionId, publicKey, credentialOptions);
                }
            }
        }
Esempio n. 23
0
        public async Task <string> LoginAsync()
        {
            short             EntryPointPort     = 11200;
            CredentialOptions credentialsOptions = new CredentialOptions("<Linkar server IP address>", "<Entry Point Name>", EntryPointPort, "<User Name>", "<Password>", "<Language>", "<FreeText>"); //NEWFRAMEWORK: Replace CredentialsOptions for CredentialOptions, add "<Language>" and "<FreeText>"

            return(await Task.Run(() =>
            {
                try
                {
                    App.linkarClt.Login(credentialsOptions);
                    return null;
                }
                catch (Exception ex)
                {
                    return App.GetException(ex);
                }
            }));

            //var json = await client.GetStringAsync($"api/Linkar/Login?user=linkar&pass=linkar");
            //return await Task.Run(() => JsonConvert.DeserializeObject<Login>(json));
        }
        /// <summary>
        /// Allows a variety of direct operations using standard templates (XML, JSON), synchronously only.
        /// </summary>
        /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
        /// <param name="command">Content of the operation you want to send.</param>
        /// <param name="commandFormat">Indicates in what format you are doing the operation: XML or JSON.</param>
        /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
        /// <returns>The results of the operation.</returns>
        public static string SendCommand(CredentialOptions credentialOptions, string command, ENVELOPE_FORMAT commandFormat = ENVELOPE_FORMAT.XML, int receiveTimeout = 0)
        {
            string customVars      = "";
            string options         = "";
            string US_str          = "\x1F";
            string sendCommandArgs = customVars + US_str + options + US_str + command;
            byte   opCode;

            if (commandFormat == ENVELOPE_FORMAT.JSON)
            {
                opCode = (byte)OPERATION_CODE.COMMAND_JSON;
            }
            else
            {
                opCode = (byte)OPERATION_CODE.COMMAND_XML;
            }
            byte   byteInputFormat  = (byte)DATAFORMAT_TYPE.MV;
            byte   byteOutputFormat = (byte)DATAFORMAT_TYPE.MV;
            string result           = Linkar.ExecuteDirectOperation(credentialOptions, opCode, sendCommandArgs, byteInputFormat, byteOutputFormat, receiveTimeout);

            return(result);
        }
 /// <summary>
 /// Returns the Schema properties list defined in Linkar Schemas or the file dictionaries, synchronously only, with TABLE output format.
 /// </summary>
 /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
 /// <param name="filename">File name to LkProperties</param>
 /// <param name="lkPropertiesOptions">This object defines the different options in base of the asked Schema Type: LKSCHEMAS, SQLMODE o DICTIONARIES.</param>
 /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <returns>The results of the operation.</returns>
 /// <example>
 /// <code lang="CS">
 /// using Linkar;
 /// using Linkar.Functions.Direct.TABLE;
 ///
 /// class Test
 ///     {
 ///         public string MyLkProperties()
 ///         {
 ///             string result = "";
 ///             try
 ///             {
 ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
 ///                 LkPropertiesOptions options = new LkPropertiesOptions(RowHeaders.TYPE.MAINLABEL, false, false, false);
 ///                 result = Functions.LkProperties(credentials, "LK.CUSTOMERS", options);
 ///             }
 ///             catch (Exception ex)
 ///             {
 ///                 string error = ex.Message;
 ///                 // Do something
 ///             }
 ///             return result;
 ///         }
 ///     }
 /// </code>
 /// <code lang="VB">
 /// Imports Linkar
 /// Imports Linkar.Functions.Direct.TABLE
 ///
 /// Class Test
 ///
 ///     Public Function MyLkProperties() As String
 ///         Dim result As String = ""
 ///
 ///         Try
 ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
 ///
 ///             Dim options As LkPropertiesOptions = New LkPropertiesOptions(RowHeaders.TYPE.MAINLABEL, False, False, False);
 ///             result = Functions.LkProperties(credentials, "LK.CUSTOMERS",options)
 ///         Catch ex As Exception
 ///
 ///             Dim[error] As String = ex.Message
 ///             ' Do something
 ///         End Try
 ///
 ///         Return result
 ///   End Function
 /// End Class
 /// </code>
 /// </example>
 /// <remarks>
 /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
 /// <para>By default:
 /// <list type="bullet">
 /// <item>TAB char (9) for columns.</item>
 /// <item>VT char (11) for rows.</item>
 /// </list>
 /// </para>
 /// </remarks>
 public static string LkProperties(CredentialOptions credentialOptions, string filename, LkPropertiesOptions lkPropertiesOptions = null,
                                   string customVars = "", int receiveTimeout = 0)
 {
     return(DirectFunctions.LkProperties(credentialOptions, filename, lkPropertiesOptions, DATAFORMATSCH_TYPE.TABLE, customVars, receiveTimeout));
 }
 /// <summary>
 /// Returns a query result in a table format, synchronously only.
 /// </summary>
 /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
 /// <param name="filename">File or table name defined in Linkar Schemas. Table notation is: MainTable[.MVTable[.SVTable]]</param>
 /// <param name="selectClause">Statement fragment specifies the selection condition. For example WITH CUSTOMER = '1'</param>
 /// <param name="dictClause">Space-delimited list of dictionaries to read. If this list is not set, all fields are returned. For example CUSTOMER DATE ITEM. In NONE mode you may use the format LKFLDx where x is the attribute number.</param>
 /// <param name="sortClause">Statement fragment specifies the selection order. If there is a selection rule Linkar will execute a SSELECT, otherwise Linkar will execute a SELECT. For example BY CUSTOMER</param>
 /// <param name="tableOptions">Detailed options to be used, including: rowHeaders, rowProperties, onlyVisibe, usePropertyNames, repeatValues, applyConversion, applyFormat, calculated, pagination, regPage, numPage.</param>
 /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <returns>The results of the operation.</returns>
 /// <example>
 /// <code lang="CS">
 /// using Linkar;
 /// using Linkar.Functions.Direct.TABLE;
 ///
 /// class Test
 ///     {
 ///         public string MyGetTable()
 ///         {
 ///             string result = "";
 ///             try
 ///             {
 ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
 ///                 TableOptions options = new TableOptions(RowHeaders.TYPE.MAINLABEL, false, false, false, false, false, false, false);
 ///                 result = Functions.GetTable(credentials, "LK.CUSTOMERS", options);
 ///             }
 ///             catch (Exception ex)
 ///             {
 ///                 string error = ex.Message;
 ///                 // Do something
 ///             }
 ///             return result;
 ///         }
 ///     }
 /// </code>
 /// <code lang="VB">
 /// Imports Linkar
 /// Imports Linkar.Functions.Direct.TABLE
 ///
 /// Class Test
 ///
 ///     Public Function MyGetTable() As String
 ///         Dim result As String = ""
 ///
 ///         Try
 ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
 ///
 ///             Dim options As TableOptions = New TableOptions(RowHeaders.TYPE.MAINLABEL, False, False, False, False, False, False, False);
 ///             result = Functions.GetTable(credentials, "LK.CUSTOMERS",options)
 ///         Catch ex As Exception
 ///
 ///             Dim[error] As String = ex.Message
 ///             ' Do something
 ///         End Try
 ///
 ///         Return result
 ///   End Function
 /// End Class
 /// </code>
 /// </example>
 /// <remarks>
 /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
 /// <para>By default:
 /// <list type="bullet">
 /// <item>TAB char (9) for columns.</item>
 /// <item>VT char (11) for rows.</item>
 /// </list>
 /// </para>
 /// </remarks>
 public static string GetTable(CredentialOptions credentialOptions, string filename, string selectClause = "", string dictClause = "", string sortClause = "",
                               TableOptions tableOptions = null, string customVars = "", int receiveTimeout = 0)
 {
     return(DirectFunctions.GetTable(credentialOptions, filename, selectClause, dictClause, sortClause, tableOptions, customVars, receiveTimeout));
 }
Esempio n. 27
0
 public SmtpOptions()
 {
     Credentials = new CredentialOptions();
     Sender      = new MailAddress();
     Receiver    = new MailAddress();
 }
 /// <summary>
 /// Starts the communication with a server allowing making use of the rest of functions until the Close method is executed or the connection with the server gets lost, synchronously only.
 /// </summary>
 /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
 /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <remarks>
 /// Login is actually a "virtual" operation which creates a new Client Session ID. No DBMS login is performed unless Linkar SERVER determines new Database Sessions are required - these operations are not related.
 /// </remarks>
 public void Login(CredentialOptions credentialOptions, string customVars = "", int receiveTimeout = 0)
 {
     this._LinkarClt.Login(credentialOptions, customVars, receiveTimeout);
 }
 /// <summary>
 /// Returns a list of all the Schemas defined in Linkar Schemas, or the EntryPoint account data files, synchronously only, with TABLE output format.
 /// </summary>
 /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
 /// <param name="lkSchemasOptions">This object defines the different options in base of the asked Schema Type: LKSCHEMAS, SQLMODE o DICTIONARIES.</param>
 /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <returns>The results of the operation.</returns>
 /// <example>
 /// <code lang="CS">
 /// using Linkar;
 /// using Linkar.Functions.Direct.TABLE;
 ///
 /// class Test
 ///     {
 ///         public string MyLkSchemas()
 ///         {
 ///             string result = "";
 ///             try
 ///             {
 ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
 ///                 LkSchemasOptions options = new LkSchemasOptions(RowHeaders.TYPE.MAINLABEL, false, false);
 ///                 result = Functions.LkSchemas(credentials, options);
 ///             }
 ///             catch (Exception ex)
 ///             {
 ///                 string error = ex.Message;
 ///                 // Do something
 ///             }
 ///             return result;
 ///         }
 ///     }
 /// </code>
 /// <code lang="VB">
 /// Imports Linkar
 /// Imports Linkar.Functions.Direct.TABLE
 ///
 /// Class Test
 ///
 ///     Public Function MyLkSchemas() As String
 ///         Dim result As String = ""
 ///
 ///         Try
 ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
 ///
 ///             Dim options As LkSchemasOptions = New LkSchemasOptions(RowHeaders.TYPE.MAINLABEL, False, False);
 ///             result = Functions.LkSchemas(credentials, options)
 ///     Catch ex As Exception
 ///         Dim[error] As String = ex.Message
 ///             ' Do something
 ///
 ///         End Try
 ///
 ///         Return result
 ///   End Function
 /// End Class
 /// </code>
 /// </example>
 /// <remarks>
 /// TABLE output format uses the defined control characters in <see href="http://kosday.com/Manuals/en_web_linkar/lk_schemas_ep_parameters.html">EntryPoints Parameters</see> Table Row Separator and Column Row Separator.
 /// <para>By default:
 /// <list type="bullet">
 /// <item>TAB char (9) for columns.</item>
 /// <item>VT char (11) for rows.</item>
 /// </list>
 /// </para>
 /// </remarks>
 public static string LkSchemas(CredentialOptions credentialOptions, LkSchemasOptions lkSchemasOptions = null,
                                string customVars = "", int receiveTimeout = 0)
 {
     return(DirectFunctions.LkSchemas(credentialOptions, lkSchemasOptions, DATAFORMATSCH_TYPE.TABLE, customVars, receiveTimeout));
 }
 /// <summary>
 /// Allows a variety of direct operations using standard XML templates, synchronously only.
 /// </summary>
 /// <param name="credentialOptions">Object with data necessary to access the Linkar Server: Username, Password, EntryPoint, Language, FreeText.</param>
 /// <param name="command">Content of the operation you want to send.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <returns>The results of the operation.</returns>
 /// <example>
 /// <code lang="CS">
 /// using Linkar;
 /// using Linkar.Commands.Direct;
 ///
 /// class Test
 ///     {
 ///         public string MySendCommand()
 ///         {
 ///             string result = "";
 ///             try
 ///             {
 ///                 CredentialOptions credentials = new CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin");
 ///                 string command =
 ///                     "&lt;COMMAND NAME=\"READ\"&gt;" +
 ///                     "   &lt;CALCULATED&gt;True&lt;/CALCULATED&gt;" +
 ///                     "   &lt;OUTPUT_FORMAT&gt;XML_DICT&lt;/OUTPUT_FORMAT&gt;" +
 ///                     "   &lt;FILE_NAME&gt;LK.CUSTOMERS&lt;/FILE_NAME&gt;" +
 ///                     "   &lt;RECORDS&gt;" +
 ///                     "       &lt;RECORD&gt;" +
 ///                     "           &lt;LKITEMID&gt;2&lt;/LKITEMID&gt;" +
 ///                     "       &lt;/RECORD&gt;" +
 ///                     "   &lt;/RECORDS&gt;" +
 ///                     "&lt;/COMMAND&gt;";
 ///                 result = DirectCommands.SendXmlCommand(credentials, command);
 ///             }
 ///             catch (Exception ex)
 ///             {
 ///                 string error = ex.Message;
 ///                 // Do something
 ///             }
 ///             return result;
 ///         }
 ///     }
 /// </code>
 /// <code lang="VB">
 /// Imports Linkar
 /// using Linkar.Commands.Direct;
 ///
 /// Class Test
 ///
 ///     Public Function MySendCommand() As String
 ///
 ///         Dim result As String = ""
 ///
 ///         Try
 ///             Dim credentials As CredentialOptions = New CredentialOptions("127.0.0.1", "EPNAME", 11300, "admin", "admin")
 ///
 ///             string command =
 ///                     "&lt;COMMAND NAME=\"READ\"&gt;" +
 ///                     "   &lt;CALCULATED&gt;True&lt;/CALCULATED&gt;" +
 ///                     "   &lt;OUTPUT_FORMAT&gt;XML_DICT&lt;/OUTPUT_FORMAT&gt;" +
 ///                     "   &lt;FILE_NAME&gt;LK.CUSTOMERS&lt;/FILE_NAME&gt;" +
 ///                     "   &lt;RECORDS&gt;" +
 ///                     "       &lt;RECORD&gt;" +
 ///                     "           &lt;LKITEMID&gt;2&lt;/LKITEMID&gt;" +
 ///                     "       &lt;/RECORD&gt;" +
 ///                     "   &lt;/RECORDS&gt;" +
 ///                     "&lt;/COMMAND&gt;"
 ///             result = DirectCommands.SendXmlCommand(credentials, command)
 ///
 ///         Catch ex As Exception
 ///             Dim[error] As String = ex.Message
 ///             ' Do something
 ///         End Try
 ///
 ///         Return result
 ///   End Function
 /// End Class
 /// </code>
 /// </example>
 public static string SendXmlCommand(CredentialOptions credentialOptions, string command, int receiveTimeout = 0)
 {
     return(SendCommand(credentialOptions, command, ENVELOPE_FORMAT.XML, receiveTimeout));
 }