Noutați

Learn How To Use Connection Pooling With A Multi-threaded Environment In Delphi

This sample implements a multithreaded application, where each thread uses the IFDPhysConnection interface to establish a connection. The multiple connection establishments may lead to performance degradation across the whole system. To avoid this, you can enable the Pooled property to use the connection pooling. Location You can find the Pooling sample project at: Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to: Object PascalDatabaseFireDACSamplesPhys LayerIFDPhysConnectionPooling Subversion Repository: You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. How to Use the Sample Navigate to the location given above and open IFDPhys_Pooling.dproj. Press F9 or choose Run > Run. Interact with the sample: Select an option from the Use Connection Definition combo box. Click the Run button and see the execution time. Select the Run Pooled check box, click the Run button and see the execution time. Compare both execution times. Files File in Delphi Contains IFDPhys_Pooling.dprojIFDPhys_Pooling.dpr The project itself. fPooling.pasfPooling.fmx The main form. Implementation When you run the application, you can interact with the sample using the following objects: A TComboBox object labeled as Use Connection Definition.Click the Use Connection Definition combo box and select an option in order to define a connection to a database. The menu shows all the persistent connections defined on the file C:UsersPublicDocumentsEmbarcaderoStudioFireDACFDConnectionDefs.ini. Once you select a connection definition, the sample enables the Run button and the Run Pooled check box. A TButton object labeled as Run.If you click the Run button, the sample launches 10 threads. Each thread uses the CreateConnection method of IFDPhysManager to create a connection to the database. Moreover, each thread uses the CreateCommand method of IFDPhysConnection to create a command for each connection. Finally, each thread uses the Prepare method of IFDPhysCommand to execute 50 SQL queries. The executed SQL query is the following SELECT command: ‘select count(*) from {id Region}’. Therefore, in this case, each thread creates and uses a dedicated connection object working with the database. A TCheckBox object labeled as Run Pooled.If you select this check box, the Pooled property of the connection setting is set to True. The database connection pooling is a method used to keep database connections open so they can be reused by others. Therefore, if you select the option, the threads can reuse the current opened connection.Note: The connection pooling can be enabled only for a persistent or private connection definition. A TMemo object.The sample uses the memo object to display the type of connection. If you select the Pooled property, the memo displays the following message: ‘Run pooled…’. On the other hand, if you uncheck the Pooled property, the memo displays the following message: ‘Run non pooled…’. Through the link below you can visit the original post about this sample: http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.IFDPhysConnection.Pooling_Sample

Read More

Quickly Log Python Script Output To The Delphi Debug Log In Your Windows Apps

Sometimes developers need to log the output messages in Delphi for debugging purposes. You might aware this can be achieved by the windows API OutputDebugStringA . How about direct your python output messages to the Delphi Events Log Window? Yes, Python4Delphi has a flexible component PythonInputOutput to redirect your python output to the Delphi Events Log window with less code. You can also use Python4Delphi with C++Builder. Python4Delphi Demo23 Sample App shows how to create a Python script in Delphi Application which demonstrates creating thread and output the result in the Delphi Event log window. You can find the Demo23 source on GitHub. Prerequisites: Download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out this video Getting started with Python4Delphi. Components used in Python4Delphi Demo23 App: TPythonEngine: A collection of relatively low-level routines for communicating with Python, creating Python types in Delphi, etc. It’s a singleton class. TPythonInputOutput: Inherited from TPythonInputOutput (which works as a console for python outputs) Using this component event you can direct your Python Output to the Delphi Event log window. You can find the Python4Delphi Demo23 sample project from the extracted GitHub repository ..Python4DelphiDemosDemo23.dproj. Open this project in RAD Studio 10.4.1 and run the application. Implementation Details: PythonEngine1 provides the connection to Python or rather the Python API. This project uses Python3.9 which can be seen in TPythonEngine DllName property. It uses a Python Script file threading_test.py where the below list of modules was used. threading: This module constructs higher-level threading interfaces on top of the lower level _thread module.  collections: This module implements specialized container datatypes providing alternatives to Python’s general-purpose built-in containers, dict, list, set, and tuple. In this sample, deque is used. time: This module provides various time-related functions. threading_test.py contains, ProducerThread, ConsumerThread, BoundedQueue class within the function _test. Memo1, used for providing the Python Script to execute. On Clicking Execute Button the below code executes the python script. procedure TForm1.Button1Click(Sender: TObject); begin PythonEngine1.ExecStrings( Memo1.Lines ); end; procedure TForm1.Button1Click(Sender: TObject); begin   PythonEngine1.ExecStrings( Memo1.Lines ); end; The script below is executed which will opens a window console, create threads put in a queue and execute one after other. import threading_test import sys # the following is needed to use the newly allocated console! sys.stdout = sys.stderr= open(‘CONOUT$’, ‘wt’) try: count = int(sys.argv[1]) except: count = 3 for i in range(count): print (“**** Pass”, i) threading_test._test() print (“**** Done.”) import threading_test   import sys # the following is needed to use the newly allocated console! sys.stdout = sys.stderr= open(‘CONOUT$’, ‘wt’)   try:   count = int(sys.argv[1]) except:   count = 3   for i in range(count):   print (“**** Pass”, i)   threading_test._test() print (“**** Done.”) PythonInputOutput1 provides a conduit for routing input and output between the Graphical User Interface (GUI) and the currentlyexecuting Python script. The OnSendData event helps to send the python output data to the Delphi Event log window using the below code. procedure TForm1.PythonInputOutput1SendData(Sender: TObject; const Data: AnsiString); begin {$IFDEF MSWINDOWS} OutputDebugStringA( PAnsiChar(Data) ); {$ENDIF} {$IFDEF LINUX} WriteLn( ErrOutput, Data ); {$ENDIF} end; procedure TForm1.PythonInputOutput1SendData(Sender: TObject;   const Data: AnsiString); begin {$IFDEF MSWINDOWS}   OutputDebugStringA( PAnsiChar(Data) ); {$ENDIF} {$IFDEF LINUX}   WriteLn( ErrOutput, Data ); {$ENDIF} end; Python4Delphi Demo23 You can customize your Events Debug Output messages background and foreground colors easily to differentiate your output messages with Delphi IDE. Right-click in the Events Tab -> Properties->Event Log->Colors -> Output Debug String-> Select Foreground and Background.

Read More

Powerful Petroleum And Mining Software For Surface And Subsurface Data Visualization Is Built In Delphi

Over the past three decades, Golden, Colorado-based RockWare, Inc. has established itself as a leader in the highly specialized geological mapping and modeling sector. Its flagship product, RockWorks, creates 3-dimensional geological models of the earth’s subsurface for customers in environmental (toxic cleanup, contamination audits), hydrogeology (surface and sub-surface water), and industrial minerals (e.g. gypsum, sand gravel) segments and it is built in Delphi. One of the key benefits of Delphi according to Jim Reed, Director R&D is that “It allows us to put in millions of lines of code and do it in an efficient way without maxing out memory. Because of that, we can have a monster program that does 50 zillion different things, but can be downloaded comfortably in a reasonable amount of time. Given that 65% of our business is outside of North America, executable files have to be small enough so that someone in Sudan can download data over a lousy connection.” He attributes this capability to the overlay features in Delphi, which allow for exceptional memory management. “Delphi allows you to easily load and unload things in memory so our software can run on any basic machine. In fact with a low-end PC you could have our application up and running in an hour. We couldn’t live without that.” Case Study https://www.embarcadero.com/case-study/rockware-inc-case-study Website https://www.rockware.com/ Screenshot Gallery

Read More

New Major Release for Delphi Code Analyzer v2.4 with Free Download

Delphi Parser has a new major release … Download Free The New & Powerful Delphi Parser Static Code Analyzer 2.4 & Get Your Delphi Code Analyzed in Minutes! This is an exciting year for Delphi programmers with one of the more significant new RAD Studio releases. With multiple new features and quality improvements, the time to upgrade your Delphi projects has never been better. Delphi Parser is the premier tool to support a wide range of Upgrade needs from simple projects to ones with millions of lines of code. We built it and improved it based on multiple projects. RAD Studio 10.4 allows developers to create amazing modern applications and Delphi Parser is the tool to get you there faster and cheaper. The Delphi Parser Analyzer 2.4 is the Newest Most Valuable Tool For Delphi Developers. It is built & aimed for dealing with huge legacy Delphi projects with hundreds of applications, thousands of unit files & libraries with millions of lines of code & decades of development & developers. It is a must-have tool in every development team through all the development life cycle. No Hard Work. You just need to provide the Delphi Parser Analyzer 2.4 the project source or code base folder you want to analyze, and the search path for the libraries & the Analyzer wizard will do the rest. The Delphi Parser’s Analyzer 2.4 is an automatic code analyzing wizard. It scans & analyzes an entire code base against all available Delphi’s system units, 3rd party components, libraries & even DCUs (using a special De-Compiler). Delphi Parser 2.4 – A Full Blown Independent Parser & Linker. The Analyzer 2.4 is built on the all new Delphi Parser 2.4 framework that has the ability to read millions of lines of code & parse the code into a unified run-time object mode. Multi Pass Parser – The Delphi Parser runs in several phases in order to remove all unnecessary compiler directives while stepping over syntax errors & bridging all Delphi versions differences, from Delphi 2 to 10.4 Sydney In order to build a unifying structured code in an object model in run-time memory. Built-in Linker & Semantic Objects Tree. As the New Delphi Parser v2.4 core technology reads all the code, it links between objects, find source declaration, links implementation code to objects & methods, checks for code dependencies, count references & usage, discover missing objects, and provides the developer an ability to review & drill down into the parsing & linking process in run-time like never been done before (as well as in any other language compilers). The Delphi Parser Analyzer 2.4 Wizard is available for all Delphi versions, as Express & Enterprise edition & also in an open-source edition based on the Delphi Parser 2.4 Developer’s Framework. The Delphi Parser Analyzer 2.4 helps your development team maintain a cleaned project’s codebase. Run it whenever you wish to release a new version update & removes unnecessary files & libraries from code before it is deployed. Take Control Over Your Code. Every software project contains many components that may become unnecessary or obsolete over the development process & stay there untouched, cause no one knows what to do with them & the fear of taking them out leaves them there for eternity. Today, with the Delphi Parser Analyzer 2.4 you can easily & quickly analyze your code on any given Delphi version, from the Legacy Borland to the Newest Embarcadero’s Delphi 10.4 Sydney – and get a true insight into what is going on in your code & […]

Read More

Combine Front End, Back End, And Business Logic In Modern Full-Stack Development With Delphi

Many application developers are building a web version of their services to get more users. For instance, you do not always have the same phone or same laptop to utilize the application, if the application has a web version everything is done.  In this webinar, you can see what is new with TMS Software and how you can use their full range of components to modernize your Windows 10 application and building web apps with Delphi.  New challenges today: Development for multiple platforms Desktop Client Applications need to interact with servers. Less RAD, more OOP Loosely-coupled Software Building Blocks Front-End – TMS VCL, FMX, FNC UI Pack & TMS Web Core Business Logic – TMS Aurelius, FlexCel, ANalytics, and more Back-End – TMS RemoteDB, Sparkle, XData If you are interested in building backend services with Delphi and TMS, you can utilize TMS XData to write custom services. TMS XData has several major features which you should know: Can be autogenerated from an existing database Open for any desktop, web, or mobile app Standardized REST protocol using JSON for data transport Fully documented REST API with SwaggerUI Be sure to watch the session Q&A learn more about the specific information. Head over and check out all of the different components available from TMS Software!

Read More

The Role of SAST in DevSecOps

Published November 25, 2020 WRITTEN BY MICHAEL SOLOMON Michael G. Solomon, PhD, CISSP, PMP, CISM, PenTest+, is a security, privacy, blockchain, and data science author, consultant, educator and speaker who specializes in leading organizations toward achieving and maintaining compliant and secure IT environments. Most people involved in the process of creating and deploying software applications today are familiar with DevSecOps, which integrates security and operations into the software development process. In figurative terms, we think of the software development lifecycle as a timeline, starting with the design on the left and the deployment (and post-deployment activities) on the right. Historically, security was overlooked until as late as possible in the process; it was something to consider once you had a viable product. But the truth is, ignoring security early on makes it harder and more costly to add on later. As DevSecOps continuously pushes security “to the left” in the software development process, autonomous assessment can provide assurance of security compliance from development’s earliest stages. One type of autonomous assessment, static application security testing (SAST), can help identify software flaws early on. Let’s explore how using SAST helps DevSecOps achieve its stated goals while minimizing friction. What SAST offers Experienced software developers can integrate correctness, robustness, efficiency, elegance and even security into the code they create. However, even the best developers don’t get it right every time. And less experienced developers tend to deviate from standards and best practices in order to get the job done. In today’s push to deliver products quickly and efficiently, it gets harder and harder to pay attention to all the details, including security. SAST can provide a valuable tool in the software developer’s toolbox for writing quality code. Far from some initial developers’ perception, SAST isn’t just one more hoop to jump through. Strategically laced SAST assessments can alert developers and management that potential flaws exist and should be addressed early in the process. Developers commonly find that SAST helps them to be more efficient. The last thing you want to find is a critical design flaw that stays hidden until the final testing before release. SAST can increase the likelihood you’ll find flaws long before they get “baked in.” One great way to leverage SAST’s value is to require assessment of all code before the initial check-in. You don’t (or shouldn’t) ever commit code that doesn’t compile, so why should you be able to commit code with security flaws? Find the flaws and fix them before committing work to the pipeline. Instead of increasing each developer’s workload, you’ll decrease (in many cases dramatically) the time required down the road in rework to fix flaws someone else finds. Plus, complete SAST codebase scans may take hours. Individual and small-batch scanning is much faster. Requiring developers to carry out SAST scans locally distributes the overall workload and reduces friction along the development pipeline. Although giving individual developers the ability to automatically flag potential issues is a huge benefit, management and auditors enjoy SAST’s help in doing their jobs as well. Developers can fix flagged issues before committing code, but some errors won’t be found until more comprehensive tests, including integration tests, get carried out. For example, pre-build SAST assessments may identify flaws that unit-based SAST assessments couldn’t see. Each time SAST identifies new flaws, management has […]

Read More

Get Free Responsive Cross-Platform Login Screen Templates For Android And iOS

This FireMonkey UI template designs for implementing a login screen in a multi-device application. And shows how to utilize FireMonkey designing guidelines. As you can see, this FireMonkey UI template is responsive and ready to utilize in any kind of project that requires a login screen like this! The templates should be cross-platform and work on Android, iOS, macOS, Windows, and Linux with a single UI and single codebase. From this demo project, you can learn: How to utilize ScrollBox Utilizing Layouts Making a blurred background image Changes to the layout should be made inside of the TFrame itself. Once changes are made to the TFrame you can delete it from the TForm and re-add it. Set its Align property to Client. Optionally, it’s ClipChildren property can be set to True if there are any overlapping background images. You can get this FireMonkey UI template from GetIt Package Manager Head over and get more information for the templates from GetIt and then download them in the Delphi IDE.

Read More

Easy Steps To Connect To A MS Access Database With FireDAC In This Windows Sample App

Do you want your Delphi and C++ Builder Applications to connect with Access Database ? Do you need to manage some of the Access Database services such as creating, compacting database? How to start ? Don’t worry, FireDAC components offers robust components to connect with Access Database. FireDAC.Access Sample app demonstrates how to use FireDAC to work with access Database. You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version. Components used in the Sample App: TFDQuery : To execute SQL queries, browse the result sets, and edit the result set records. TFDPhysMSAccessDriverLink: To link the Microsoft Access driver to an application and set it up. In general, it is enough to only include the FireDAC.Phys.MSAcc unit into your application uses clause. It is used to specify access ODBC driver name and access the ODBC driver connection parameter common for all connections. TFDConnection : To establish a connection to a DBMS and to manage associated datasets. TFDAccessService: Class Implementing Microsoft Access database for creating, dropping, compacting, and repairing services. And some of the UI components, like TDBGrid,TDBComboBox, TFDGUIxWaitCursor1,TFDGUIxLoginDialog1,TFDGUIxErrorDialog1 Implementation Details: The simplest way to configure connection to MS Access database at run time is to build a temporary connection definition: In the sample, the temporary definition is created when the  item is selected in the Connection combo box.  Open the following database: C:UsersPublicDocumentsEmbarcaderoStudio20.0SamplesdataFDDemo.mdb. In the demo database, the Categories and Products tables have one-to-many relation by CategoryID field. Mention the query to the qryCategories.SQL property and qryProducts.SQL property. Finally, qryProducts.MasterSource property is set to dsCategories, while the MasterFields property is set to CategoryID. This creates a master-details relationship between the datasets. Simple queries execution is demonstrated via the ExecSQL method of TFDConnection. The management of databases, such as: creating, dropping, compacting/repairing, and setting a password is done using TFDMSAccessService component. This demo demonstrates how to create and compact the user database.  Check out the full article in the DocWiki about the FireDAC.Access Sample. FireDAC.Access Sample App Check out the full source code for the FireDAC.Access projects for Delphi and C++Builder over on GitHub.

Read More

Black Friday 2020

And we are back with our best deals for Black Friday 2020!Buy one product and get a second same or lower priced product at 50% discount! (new licenses only) Enjoy this super deal this Friday, all day long! Purchase your first product and just contact our team at sales@tmssoftware.com for your coupon code for the second license. Don’t wait and take advantage now! Share your excitement:

Read More

Flexible Brotli Compression Library For Your Windows Delphi/C++ Builder VCL And FMX Apps

Most of Delphi and C++ Builder developers utilize preinstalled components and libraries to compress and decompress files. For instance, the System.Zlib which supports gzip and deflate, the System.Zip is also helpful to handle .zip archive files. Moreover, Indy’s TIdCompressorZLib which is based on Zlib.  But that is not it. There are more different libraries based on different compression algorithms and more modern techniques, for instance, the Brotli – Brotli is similar in speed with deflate but offers more impenetrable compression. Brotli is open-sourced under the MIT License by Google. Brotli compressed files have .br extension. To connect your Delphi or C++ Builder VCL and FMX application with the Brotli library we can rely on Brotli Compress library from WINSOFT which offers to use the Brotli library easily. Brotli itself is free to use and distribute, but the Brotli Compress by WINSOFT is a commercial library and if you would like to use that library you should get a license! Uses Brotli library Supports Windows 32 and Windows 64 Available for Delphi/C++ Builder 6 – 10.4 After downloading the Brotli from WINSOFT you should configure the library into your RAD Studio. You can follow the tutorial here that shows the steps to configure without errors. Since the Brotli itself is a whole compression library your application should have brotlilib.dll – Dynamic-link library. You will get those files within the Brotli Compressor by WINSOFT in a Library Folder. Brotli Compressor Library has two main classes: TBrotliEncoder  TBrotliDecoder As you can observe the TBrotliEncoder encodes and TBrotliDecoder decodes the files with the given parameters. Furthermore, the OnProgress event provides the decompression and compression progress info. Additionally, you can set encoding quality with the Quality property. Here is the Brotli library demonstration video that shows the demo application in action.  These are demo projects’ UI: DEMO UI This is how you can encode with Brotli: InputStream := TFileStream.Create(EditFileName.Text, 0); try OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.br’), fmCreate); try with TBrotliEncoder.Create do try if RadioButtonGeneric.IsChecked then Mode := emGeneric else if RadioButtonText.IsChecked then Mode := emText else Mode := emFont; Quality := Round(TrackBarQuality.Value); OnProgress := Self.OnProgress; Compress(InputStream, OutputStream); finally Free; end; finally OutputStream.Free; end; finally InputStream.Free; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 InputStream := TFileStream.Create(EditFileName.Text, 0);     try       OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.br’), fmCreate);       try         with TBrotliEncoder.Create do         try           if RadioButtonGeneric.IsChecked then             Mode := emGeneric           else if RadioButtonText.IsChecked then             Mode := emText           else             Mode := emFont;           Quality := Round(TrackBarQuality.Value);           OnProgress := Self.OnProgress;           Compress(InputStream, OutputStream);         finally           Free;         end;       finally         OutputStream.Free;       end;     finally       InputStream.Free;     end; Here is how you can decode with the Brotli: InputStream := TFileStream.Create(EditFileName.Text, 0); try if CheckBoxCheckIntegrity.IsChecked then OutputStream := nil else OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.uncompressed’), fmCreate); try with TBrotliDecoder.Create do try OnProgress := Self.OnProgress; Decompress(InputStream, OutputStream); finally Free; end; finally OutputStream.Free; end; finally InputStream.Free; end; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 InputStream := TFileStream.Create(EditFileName.Text, 0);     try       if CheckBoxCheckIntegrity.IsChecked then         OutputStream := nil       else         OutputStream := TFileStream.Create(ChangeFileExt(EditFileName.Text, ‘.uncompressed’), fmCreate);       try         with TBrotliDecoder.Create do         try           OnProgress := Self.OnProgress;           Decompress(InputStream, OutputStream);         finally           Free;         end;       finally         OutputStream.Free;       end;     finally       InputStream.Free;     end; As you can see this is uncomplicated and you just need to implement the file selection […]

Read More