Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials

7018 Articles
article-image-connecting-microsoft-sql-server-compact-35-visual-studio
Packt
13 Jul 2010
3 min read
Save for later

Connecting to Microsoft SQL Server Compact 3.5 with Visual Studio

Packt
13 Jul 2010
3 min read
SQL Server Compact Edition 3.5 can be used to create applications that are useful for a number of business uses such as: Portable applications; Occasionally connected clients and embedded applications and devices. SQL Server Compact differs from other SQL Servers in that there is just one file which can be password protected and features 128-bit file level encryption. It is referential integrity compliant; supports multiple connections; has transactions support with rich data types. In this tutorial by Jayaram Krishnaswamy, various scenarios where you may need to connect to SQL Server Compact using Visual Studio IDE (both 2008 and 2010) are described in detail. Connecting to SQL Server Compact 4.5 using Visual Studio 2010 Express (free version of Visual Studio) is also described. The connection is the starting point for any database related program and therefore mastering the connection task is crucial to work with the SQL Server Compact. (For more resources on Microsoft, see here.) If you are familiar with SQL Server you already know much of SQL Server Compact. It can be administered from SSMS and, using SQL Syntax and ADO.NET technology you can be immediately productive with SQL Server Compact.It is free to download (also free to deploy and redistribute) and comes in the form of just one code-free file. Its small foot print makes it easily deployable to a variety of device sizes and requires no administration. It also supports a subset of T-SQL and a rich set of data types. It can be used in creating desktop/web applications using Visual Studio 2008 and Visual Studio 2010. It also comes with a sample Northwind database. Download details Microsoft SQL Server Compact 3.5 may be downloaded from this site here. Make sure you download detailed features of this program from the same site. Also several bugs have been fixed in the program as detailed in the two SP's. Link to the latest service pack SP2 is here. By applying SP2 the installed version on the machine is upgraded to the latest version. Connecting to SQL Server Compact from Windows and Web projects You can use the Server Explorer in Visual Studio to drag and drop objects from SQL Server Compact provided you add a connection to the SQL Server Compact. In fact, in Visual Studio 2008 IDE you can configure a data connection without even starting a project from the View menu as shown here. When you click Add Connection... the following window will be displayed. This brings up the Add Connection dialog shown here. Click Change... to choose the correct data source for SQL Server Compact. The default is SQL Server client. The Change Data Source window is displayed as shown. Highlight Microsoft SQL Server Compact 3.5 and click OK. You are returned to Add Connection where you can browse or create a database or, choose also from a ActiveSync connected device such as a Smart phone which has a SQL Server Compact for devices installed. Presently connect to one on the computer (My Computer default option)-the sample database Northwind. Click Browse.... The Select SQL Server Compact 3.5 Database File dialog opens where your sample database Northwind is displayed as shown. Click Open. The database file is entered in the Add Connection dialogue. You may test the connection. You should get a Test connection succeeded message from Microsoft Visual Studio. Click OK. The Northwind.sdf file is displayed as a tree with Tables and View as shown in the next figure. Right click Northwind.sdf in the Server Explorer above and click Properties drop-down menu item. You will see the connection string for this conneciton as shown here.
Read more
  • 0
  • 1
  • 18109

article-image-associating-images-words-moodle-19-special-kids
Packt
12 Jul 2010
6 min read
Save for later

Associating Images with Words in Moodle 1.9 for Special kids

Packt
12 Jul 2010
6 min read
(Read more interesting articles on Moodle 1.9 here.) Writing a sentence using two images It was such a beautiful day on the beach. The sun was shining in the sky, the sand was clean and glittering, the sea was clear, blue, and full of waves to play with. A perfect day to go for a swim. Alice and her little brother Kevin ran towards the sea together. They played, jumped, and slid with their body surfing boards and the waves. Suddenly, an animal appeared swimming between them. It was a dolphin. It jumped and threw water at them. Awesome! Alice was so happy because she had a new and very special friend on this vacation. Time for action – looking for two images to generate the exercise We are going to search for two royalty-free photos related to the beach in two specialized web pages. We are then going to use them to create a rich activity. Create a new folder in Windows Explorer (C:Beach). Open your default web browser and go to http://animalphotos.info. This web page allows us to search for royalty-free animal photos. Enter dolphin in the textbox and then click on the Search button. Browse through the results and select the desired photo of a single dolphin, as shown in the next image: Right-click on the desired image with the dolphin and select Save picture as in the context menu that appears. Save the file as image030101.jpg in the previously created folder, C:Beach. Open your default web browser and go to http://freedigitalphotos.net.This web page allows us to search for, and download, royalty-free photos. Enter sea in the textbox and then click on the Go button. The available photo thumbnails related to the entered keyword will appear. Browse through the results and select the desired photo of the sea, as shown in the next image: Right-click on the desired image thumbnail with the sea and select Save picture as in the context menu that appears. Save the file as image030102.jpg in the previously created folder, C:Beach. What just happened? We searched for two royalty-free photos related to the beach. In this case, we worked with two web pages, http://animalphotos.info and http://freedigitalphotos.net. We now have the following two digital photos ready to be used in our writing sentences using two images exercise: image030101.png: A dolphin image030102.png: The sea and the shore It is very important to use photos in this exercise because the idea is to train the description of real-life scenarios. Time for action – searching for related sounds We have two digital photos and we want to add related sounds to them. We are going to search for MP3 files to use as sound effects for the scenes in The Freesound Project website (http://www.freesound.org/): Open your default web browser and go to http://www.freesound.org. This web page allows us to search for, and download, sound files. It is necessary to register on this website in order to be able to download its files. The registration and access to its content are both free of cost. The Freesound Project website offers high-quality sounds with a Creative Commons License. The website offers thousands of samples.However, it does not offer songs. Click on Search under Search/Browse. Activate the Filenames checkbox. This way, the website will also search the file names of its sound files database. Enter sea mp3 in the textbox and then click on the Submit button. The results with the details of many sound files will appear. You can click on the Play button on the left-hand side of each sound file's name and preview the recorded sound, as shown in the next screenshot: Click on the selected file name (WavesOnBeach.mp3) or on its waveform. A new page with more detailed information will appear (http://www.freesound.org/samplesViewSingle.php?id=14777), as shown in the next screenshot: Check the license information about the chosen file. Right-click on the Download label, located on the upper right-hand corner, and select Save target as in the context menu that appears. Save the file as sound030102.mp3 in the previously created folder, C:Beach. As this sound is related to the sea represented by the photo named image030102.jpg, we use the same name and another extension (.mp3 instead of .jpg). Next, go back to the web browser and repeat the aforementioned steps (2 to 7) to find and download sound related to a dolphin in MP3 format. In this case,repeat those steps searching for dolphin mp3 and save the sound file as sound030101.mp3 in the same folder. A nice recording of dolphins found on this website is common_dolphins_isla_san_jose_16jan2002.mp3 (http://www.freesound.org/samplesViewSingle.php?id=52099). What just happened? We searched for two sound files in MP3 format because it is easy to integrate it into a Moodle exercise. We now have the following two digitalized sounds ready to be used in our writing sentences using two images and their related sounds exercise: sound030101.mp3: Dolphins on San Jose island sound030102.mp3: Waves on the beach Time for action – activating the MP3 player in Moodle As we are going to add the aforementioned sound files to our exercise in Moodle, we have to make sure that its multimedia plugins are enabled. Log in to your Moodle server. Click on Modules Filters | Manage| filters on the Site Administration panel. If the Multimedia Plugins filter appears in grey and displays a closed eye icon in the Disable/Enable column, you must click on this icon to change it to an opened eye icon. This way, Moodle will enable the multimedia plugins, as shown in the next screenshot: If you made changes, click on the Save changes button. Next, click on Modules Filters | Multimedia Plugins| in the Site Administration panel. Make sure that the Enable .mp3 filter checkbox is activated. If it is not, activate it and then click on the Save changes button. What just happened? We made the necessary changes in Moodle's configuration in order to make it possible to use its MP3 player. This way, we are going to be able to embed the sound files associated with the photographs, offering both visual and auditory perception resources in the exercise.
Read more
  • 0
  • 0
  • 1669

article-image-teaching-special-kids-how-write-simple-sentences-and-paragraphs-using-moodle-19
Packt
12 Jul 2010
8 min read
Save for later

Teaching Special Kids How to Write Simple Sentences and Paragraphs using Moodle 1.9

Packt
12 Jul 2010
8 min read
Creating a sentence using certain words Last Saturday, Alice went to the circus with her mother. Today is Priscilla's birthday and Alice cannot wait to tell her friends about the funny and dangerous things she saw in the circus. She was really scared when she saw the lions jumping through the flaming hoops. She enjoyed the little dogs jumping and twirling, and the big seals spinning balls. However, she has to remember some of the shows. Shall we help her? Time for action – choosing and preparing the words to be used in a sentence We are first going to choose the words to be used in a sentence and then add a new advanced uploading of files activity to an existing Moodle course. Log in to your Moodle server. Click on the desired course name (Circus). As previously learned, follow the necessary steps to edit the summary for a desired week. Enter Exercise 1 in the Summary textbox and save the changes. Click on the Add an activity combo box for the selected week and choose Advanced uploading of files. Enter Creating a sentence using certain words in Assignment name. Select Verdana in font and 5 (18) in size—the first two combo boxes below Description. Click on the Font Color button (a T with six color boxes) and select your desired color for the text. Click on the big text box below Description and enter the following description of the student's goal for this exercise. You can use the enlarged editor window as shown in the next screenshot. Use a different font color for each of the three words: Lion, Hoops, and Flaming. Close the enlarged editor's window. Select 10MB in Maximum size. This is the maximum size for the file that each student is going to be able to upload as a result for this activity. However, it is very important to check the possibilities offered by your Moodle server with its Moodle administrator. Select 1 in Maximum number of uploaded files. Select Yes in Allow notes. This way, the student will be able to add notes with the sentence. Scroll down and click on the Save and display button. The web browser will show the description for the advanced uploading of files activity. What just happened? We added an advanced uploading of files activity to a Moodle course that will allow a student to write a sentence that has to include the three words specified in the notes section. The students are now going to be able to read the goals for this activity by clicking on its hyperlink on the corresponding week. They are then going to write the sentence and upload their voices with the description of the situation. We added the description of the goal and the three words to use in the sentence with customized fonts and colors using the online text activity editor features. Time for action – writing and recording the sentence We must first download and install Audacity 1.2. We will then help Alice to write a sentence, read it, and record her voice by using Audacity's features. If you do not have it yet, download and install Audacity 1.2 (http://audacity.sourceforge.net/download/). This software will allow the student to record his/her voice and save the recording as an MP3 file compatible with the previously explained Moodle multimedia plugins. In this case, we are covering a basic installation and usage for Audacity 1.2. The integration of sound and music elements for Moodle, including advanced usages for Audacity, is described in depth in Moodle 1.9 Multimedia by João Pedro Soares Fernandes, Packt Publishing. Start Audacity. Next, it is necessary to download the LAME MP3 encoder to make it possible for Audacity to export the recorded audio in the MP3 file format. Open your default web browser and go to the Audacity web page that displays the instructions to install the correct version of the LAME MP3 encoder, http://audacity.sourceforge.net/help/faq?s=install&item=lame-mp3. Click on the LAME download page hyperlink and click on the hyperlink under For Audacity on Windows, in this case, Lame_v3.98.2_for_Audacity_on_Windows.exe. Run the application, read the license carefully, and follow the necessary steps to finish the installation. The default folder for the LAME MP3 encoder is C:Program FilesLame for Audacity, as shown in the following screenshot: Minimize Audacity. Log in to your Moodle server using the student role. Click on the course name (Circus). Click on the Creating a sentence using certain words link on the corresponding week. The web browser will show the description for the activity and the three words to be used in the sentence. Click on the Edit button below Notes. Moodle will display a big text area with an HTML editor. Select Verdana in font and 5 (18) in size. Write a sentence, The lion jumps through the flaming hoops., as shown in the next screenshot: Go back to Audacity. Resize and move its window in order to be able to see the sentence you have recently written. Click on the Record button (the red circle) and start reading the sentence. Audacity will display the waveform of the audio track being recorded, as shown in the next screenshot: You need a microphone connected to the computer in order to record your voice with Audacity. Once you finish reading the sentence, click on the Stop button (the yellow square). Audacity will stop recording your voice. Select File | Export As MP3 from Audacity's main menu. Save the MP3 audio file as mysentence.mp3 in your documents folder. Audacity will display a message indicating that it uses the freely available LAME library to handle MP3 file encoding, as shown in the next screenshot: Click on Yes and browse to the folder where you installed the LAME MP3 encoder, by default, C:Program FilesLame for Audacity. Click on Open and Audacity will display a dialog box to edit some properties for the MP3 file. Click on OK and it will save the MP3 file, mysentence.mp3, in your documents folder. Next, go back to your web browser with the Moodle activity, scroll down, and click on the Save changes button. Click on the Browse button below Submission draft. Browse to the folder that holds your MP3 audio file with the recorded sentence, your documents folder, select the file to upload, mysentence.mp3, and click on Open. Then, click on Upload this file to upload the MP3 audio file to the Moodle server. The file name, mysentence.mp3, will appear below Submission draft if the MP3 file could finish the upload process without problems, as shown in the next screenshot. Next, click on Continue. Click on Send for marking and then on Yes. A new message, Assignment was already submitted for marking and cannot be updated, will appear below the Notes section with the sentence. Log out and log in with your normal user and role. You can check the submitted assignments by clicking on the Creating a sentence using certain words link on the corresponding week and then on View x submitted assignments. Moodle will display the links for the notes and the uploaded file for each student that submitted this assignment, as shown in the next screenshot. You will be able to read the notes and listen to the recorded sentence by clicking on the corresponding links. Once you have checked the results, click on Grade in the corresponding row in the grid. A feedback window will appear with a text editor and a drop-down list with the possible grades. Select the grade in the Grade drop-down list and write any feedback in the text editor, as shown in the next screenshot. Then click on Save changes. The final grade will appear in a corresponding cell in the grid. What just happened? In this activity, we defined a simple list of words and we asked the student to write a simple sentence. In this case, there is no image or multimedia resource, and therefore, they have to use their imagination. The child has to read and understand the three words. He/she has to associate them, imagine a situation and say and/or write a sentence. Sometimes, it is going to be too difficult for the child to write the sentence. In this case, he/she can work with the help of a therapist or a family member to run the previously explained software and record the sentence. This way, it is going to be possible to evaluate the results of this exercise even if the student cannot write a complete sentence with the words. Have a go hero – discussing the results in Moodle forums The usage of additional software to record the voice in order to solve the exercises can be challenging for the students and their parents. Prepare answers of frequently asked questions in the forums offered by Moodle. This way, you can interact with the students and their parents through other channels in Moodle, with different feedback possibilities. You can access the forums for each Moodle course by clicking on Forums in the Activities panel.
Read more
  • 0
  • 0
  • 5349

article-image-tcl-handling-email
Packt
12 Jul 2010
13 min read
Save for later

Tcl: Handling Email

Packt
12 Jul 2010
13 min read
(For more resources on Tcl, see here.) Before working with e-mail, we need to understand a bit about how e-mail works, as well as what it provides and what our application needs to perform on its own. In general, e-mails are easy to understand—someone sends a message, the e-mailing system takes care of delivering it to the correct target machine(s), and the recipients are then able to retrieve that message. From the e-mail system's perspective, it does not care about what the e-mail contains, as long as it knows who it is from and who it should be delivered to. From the user's perspective, he/she does not need to know how it is delivered—their mail application delivers the message to the server handling their e-mail, and all messages can be retrieved from that same server. When we interact with e-mails, it works the same way for us. In the majority of cases, our application only needs to interact with our e-mail server. All e-mail messages are built using a common structure—each message consists of headers that describe the message and the body. Headers describe who the message is from, its recipients, and the subject of the message. They also provide the content type, which tells e-mail applications what type of data the message contains. Message headers can also contain a history of the servers it passed, additional information such as the e-mail application used to generate this message, and any other information that the e-mail application has added. The message body is the actual text and/or data that was sent. Information about what is in the message body is described in the headers, for example we can send plain text, HTML message, or simply an image. Learning MIME Multipurpose Internet Mail Extensions (MIME) is a standard that extends the e-mail format. It defines how messages can include character sets other than 7-bit ASCII in the message headers and body, and introduces the concept of multiple parts of an e-mail along with attachments. Over time, MIME became such an integral part of e-mail handling that all e-mails are now sent in accordance with MIME standards. Content type MIME introduced the concept of content type, which was originally meant for defining types of files in an e-mail. This was introduced so that e-mail applications could present the content of a message differently, depending on the actual file type. This grew to other protocols and can now be referred to as the Internet media type standard. The standard consists of two parts—MIME type and MIME subtype separated by a slash. The content type describes the type of a piece of media, for example, image. The subtype defines file format—for example, jpeg. In this example, the MIME type is image/jpeg. A full list of standardized format types can be found on the following page: http://www.iana.org/assignments/media-types/ Whenever an application needs to use its own content type, it is recommended that an x- prefix is appended to the subtype—for example, application/x-tcl-dict could be used to transmit a dictionary's contents. The MIME standard defines several possibilities for embedding data that is outside a 7-bit ASCII character set, that is, data such as binary files, messages using different character sets, and so on. The Base64 standard is commonly used for encoding binary files within an e-mail—this standard uses 64 characters only, and requires 4 bytes to encode 3 bytes of actual data. This means that a 1M file will use up over 1.3M when sent via e-mail. Base64 is described in more detail at: http://en.wikipedia.org/wiki/Base64 The standard also defines the quoted-printable standard that is used for sending 8-bit data. Characters outside of 7-bit character set are encoded as multiple characters; this idea is described in more detail at: http://en.wikipedia.org/wiki/Quoted-printable For the purpose of this article, we do not need to go into details of how both Base64 and quoted-printable encodings work. Multipart messages MIME also introduces the concept of multipart content. An e-mail message can only consist of a single item. However, the MIME standard provides ways to send multipart content by enclosing multiple items in a single message. It can also be used recursively, one of the elements can also contain additional parts. We'll see this in the following example: There are multiple types of multipart contents: multipart/related is used to send messages that should be treated as a whole. The first part is the content that the e-mail application should use and other parts are related to it, for example, images that are used in a HTML message. However, adding a part that should be inline requires that this element also has specific headers, which is discussed in more detail later in this article. multipart/ mixed is used for sending mixed content types. It is up to the e-mail application to decide how to handle this, but parts that it can show inline will be shown within e-mail application, and parts that it cannot show directly will be shown only as attachments. A typical example is attaching images and documents—e-mail applications will show images inline, but require documents to be opened in an external application. multipart/alternative is used to define multiple parts, where each part is an alternate version of the same content. A typical example is sending plain text and HTML messages. E-mail applications choose the best format that they can handle. Representations should be sent in a way they are ordered by—preferable representation should be the last part. Multipart content types allow each part to have its own individual headers—this is required in order to define which content type each part is, along with how it should be treated. Also, as each part can have its own type, each part can also be a multipart element on its own. The following diagram illustrates how both multipart/mixed, multipart/ alternative, and multipart/related can be used to send e-mail that contains plain text message and HTML message, inlined images as well as attachments. This is actually how the majority of e-mail applications will embed such a message. The structure of the entire message would look as follows: Now that we know how our e-mail might appear, let's proceed to building such a structure from within Tcl. MIME in Tcl In order to send such an e-mail from within Tcl, we will need to use Tcl's mime package. It is a part of the tcllib package and is available in ActiveTcl distributions of Tcl. This package allows the building and parsing of messages and handles all aspects of a message—headers, content, and support for multipart messages. It also handles conversion between various content encodings such as base64 and quoted-printable. Thanks to this we'll only need to build the message parts and combine them into a final message. Creating messages The command mime::initialize is used to set up a part or the content of the entire message. This command accepts one or more options and returns a new token that identifies the new MIME part. Based on the options specified, there are two modes in which it can be used— the first is to parse content (such as parse a received e-mail message), and the second is to create content. We will focus on the second case and leave parsing for sections that talk about receiving e-mail. Whenever we want to create a MIME part we need to specify the -canonical option and provide the content type for this part. Type is the MIME type described earlier. There are three possibilities for creating MIME objects—from a file or from a string, and when creating multipart content. To create it from a file or a string, we need to specify the -file or -string option and provide either the path to the file or the content of this part as string or binary data. We should also specify the -encoding option that states how content should be handled so that it can be passed over a 7-bit protocol such as SMTP. For binary files, we should usually use base64 encoding and for text files, it is best to use quoted-printable. When creating a MIME part, we can also specify one or more headers that it should have by adding the -header option. This option can be specified multiple times and each parameter to this option should be a list containing a header name and corresponding value. These headers are then added to the actual MIME body. Their names and corresponding values are part of MIME's specifications. We'll cover a small subset that we need to know in order to send an e-mail with both inlined elements and attachments. For example, in order to create a simple plaintext element, we can run the following command: set token [mime::initialize -canonical "text/html" string "Hello world!"] If we want to send it, all we would need to do is use the smtp package: smtp::sendmessage $token -recipients "someone@domain.com" Sending e-mails is described in more detail later in this section—the preceding code simply shows that both packages can be combined very easily. Multipart elements In order to multipart content, we should provide the -parts option to the mime:: initialize command. The value for this option should contain a list of all parts that should be included in this multipart content. Parts are included in the same order as provided in the list. Let's walk through an exercise of building up an e-mail that we described earlier. This code uses several files, mainly message.html and message.txt for the text of the e-mail, companylogo.gif for logo that is used in message.html, and attachment.jpg as an attachment. First we have to load the mime package and create an HTML part: package require mime# create actual HTML part# (1.2.1.2.1 from diagram)set part_html [mime::initialize -canonical "text/html" -encoding quoted-printable -file message.html]# create logo as inlined image# (1.2.1.2.2 from diagram)set part_logo [mime::initialize -canonical "image/gif" -encoding base64 -file companylogo.gif -header [list Content-Disposition "inline"] -header [list Content-ID "companylogo.gif"] ] This code builds up two elements—a part containing HTML version of the message and an image that we add, inline, in the message. Following that, we use these to build up the multipart/related part (element 1.2.1.2 from preceding diagram) that contains two elements created using the preceding code: set part_htmlrelated [mime::initialize -canonical multipart/related -parts [list $part_html $part_logo]] Next it's time to create a plain text version of the e-mail (element 1.2.1.1 from diagram) and build the multipart/alternative element that binds the HTML message and the plain text message into one piece, which is element 1.2.1. set part_txt [mime::initialize -canonical "text/plain" -encoding quoted-printable -file message.txt]set part_alternative [mime::initialize -canonical multipart/alternative -parts [list $part_txt $part_htmlrelated]] Finally, we create a part for the attachment (element 1.2.2 from diagram) and create an element that combines the previously created container for the plain text and HTML message along with the attachment—element 1.2 from diagram. set part_attachment [mime::initialize -canonical "image/jpeg" -header [list Content-Disposition "attachment; filename=attachment.jpg"] -header [list Content-ID "attachment.jpg"] -encoding base64 -file attachment.jpg]set all [mime::::initialize -canonical multipart/mixed -parts [list $part_alternative $part_attachment]] This makes our code complete and a full version of the message is now ready. There are three types of elements that we are building: HTML and plain text messages: Their context is defined by multipart elements they are included in, therefore, we only need to define content type. JPEG image: It is an attachment, therefore, we need to provide more information in the part headers—filename, Content-ID, and disposition. Multipart elements: These are used to combine other types of elements into a structure that we've described earlier. Sending text messages also relates to character sets, encodings, and issues with internationalization. When sending messages that contain characters outside of 7-bit ASCII, we need to be aware of two things. First of all, Tcl sends both strings and file contents in binary form. If we want to send text from a file, then that file needs to be encoded properly, using encodings such as UTF-8. If we want to send text from Tcl, we need to convert that text to proper encoding. Secondly, we need to specify the encoding of a part when specifying the canonical type—usually this means appending a semi-colon and charset=<charsetName>. For example: set part_html [mime::initialize -canonical "text/html; charset=UTF-8" -encoding quoted-printable –string [encoding convertto utf-8 "u25ba Omega symbol: u2126 u25c4"]] Next we have an inlined image—in this case, we need to define additional headers. The first header is Content-Disposition, which specifies how this part should be handled. Specifying inline means that this is an element that will be referenced from the main document and should not be shown as an attachment. The second header is Content-ID, which identifies and names an element. This is how an element can then be referenced from other parts. Any references should be made in the format of cid:<Content-ID>, so in our case, it would be cid:companylogo.gif. For example, our message.html file can contain the following HTML tag: <img src="cid:companylogo.gif" width="400" height="40" /> Elements that are regular attachments should have Content-Disposition set to attachment. Also, it is recommended to add filename=<name> to this parameter, separated from the disposition type by a semi-colon. Content-ID in this case specifies an attachment name and should be the same as the filename specified in the Content-Disposition header. This is how the attachment.jpg file is sent. There is also a difference between naming parts within an e-mail and actual filenames. However, this example names files from MIME's perspective in the same way as files are named on disk. It is common to add prefixes and/or suffixes to avoid naming collisions, especially when a message contains parts from different sources. For example, we add create inlined image in the following way: set part_logo [mime::initialize -canonical "image/gif" -encoding base64 -file "/path/to/template/logo.gif" -header [list Content-Disposition "inline"] -header [list Content-ID "template.logo.gif@$messageId"] ] We can then build the HTML to include such an image from Tcl by doing something like: set html "<img src="cid:template.logo.gif@$messageId" />" It is a good idea to generate unique identifiers for each message and append them to inlined parts' identifiers. This prevents poorly written e-mail applications from having issues with forwarding or replying to e-mails with such images. It can be done using the uuid package and the uuid::uuid generate command, but any mechanism for generating a unique ID, such as from a related database entry, will work. Cleaning up a MIME item requires running the mime::finalize command and passing the token of a MIME part to it. In order to delete all elements that are used in that element recursively, we can add the -subordinates option with the value all. For example: mime::finalize $all -subordinates all The preceding code will delete the token created for the entire message along with all other elements we've created. Information about all commands from mime package can be found in its documentation available at: http://tcllib.sourceforge.net/doc/mime.html
Read more
  • 0
  • 1
  • 18846

Packt
12 Jul 2010
10 min read
Save for later

Understanding ShapeSheet™ in Microsoft Visio 2010

Packt
12 Jul 2010
10 min read
In this article by David J. Parker, author of Microsoft Visio 2010 Business Process Diagramming and Validation, we will discuss Microsoft Visio ShapeSheet™ and the key sections, rows, and cells, along with the functions available for writing ShapeSheet™ formulae, where relevant for structured diagrams. Microsoft Visio is a unique data diagramming system, and most of that uniqueness is due to the power of the ShapeSheet, which is a window on the Visio object model. It is the ShapeSheet that enables you to encapsulate complex behavior into apparently simple shapes by adding formulae to the cells using functions. The ShapeSheet was modeled on a spreadsheet, and formulae are entered in a similar manner to cells in an Excel worksheet. Validation rules are written as quasi-ShapeSheet formulae so you will need to understand how they are written. Validation rules can check the contents of ShapeSheet cells, in addition to verifying the structure of a diagram. Therefore, in this article you will learn about the structure of the ShapeSheet and how to write formulae. Where is the ShapeSheet? There is a ShapeSheet behind every single Document, Page, and Shape, and the easiest way to access the ShapeSheet window is to run Visio in Developer mode. This mode adds the Developer tab to the Fluent UI, which has a Show ShapeSheet button. The drop-down list on the button allows you to choose which ShapeSheet window to open. Alternatively, you can use the right-mouse menu of a shape or page, or on the relevant level within the Drawing Explorer window as shown in the following screenshot: The ShapeSheet window, opened by the Show ShapeSheet menu option, displays the requested sections, rows, and cells of the item selected when the window was opened. It does not automatically change to display the contents of any subsequently selected shape in the Visio drawing page—you must open the ShapeSheet window again to do that. The ShapeSheet Tools tab, which is displayed when the ShapeSheet window is active, has a Sections button on the View group to allow you to vary the requested sections on display. You can also open the View Sections dialog from the right-mouse menu within the ShapeSheet window. You cannot alter the display order of sections in the ShapeSheet window, but you can expand/collapse them by clicking the section header. The syntax for referencing the shape, page, and document objects in ShapeSheet formula is listed in the following table. Object ShapeSheet formula Comment Shape Sheet.n! Where n is the ID of the shape Can be omitted when referring to cells in the same shape. Page.PageSheet ThePage! Used in the ShapeSheet formula of shapes within the page.   Pages[page name]! Used in the ShapeSheet formula of shapes in other pages. Document.DocumentSheet TheDoc! Used in the ShapeSheet formula in pages or shapes of the document. What are sections, rows, and cells? There are a finite number of sections in a ShapeSheet, and some sections are mandatory for the type of element they are, whilst others are optional. For example, the Shape Transform section, which specifies the shape's size (that is, angle and position) exists for all types of shapes. However, the 1-D Endpoints section, which specifies the co-ordinates of either end of the line, is only relevant, and thus displayed for OneD shapes. Neither of these sections is optional, because they are required for the specific type of shape. Sections like User-defined Cells and Shape Data are optional and they may be added to the ShapeSheet if they do not exist already. If you press the Insert button on the ShapeSheet Tools tab, under the Sections group, then you can see a list of the sections that you may insert into the selected ShapeSheet. In the above example, User-defined Cells option is grayed out because this optional section already exists. It is possible for a shape to have multiple Geometry, Ellipse, or Infinite line sections. In fact, a shape can have a total of 139 of them. Reading a cell's properties If you select a cell in the ShapeSheet, then you will see the formula in the formula edit bar immediately below the ribbon. Move the mouse over the image to enlarge it. You can view the ShapeSheet Formulas (and I thought the plural was formulae!) or Values by clicking the relevant button in the View group on the ShapeSheet Tools ribbon. Notice that Visio provides IntelliSense when editing formulae. This is new in Visio 2010, and is a great help to all ShapeSheet developers. Also notice that the contents of some of the cells are shown in blue text, whilst others are black. This is because the blue text denotes that the values are stored locally with this shape instance, whilst the black text refers to values that are stored in the Master shape. Usually, the more black text you see, the more memory efficient the shape is, since less is needed to be stored with the shape instance. Of course, there are times when you cannot avoid storing values locally, such as the PinX and PinY values in the above screenshot, since these define where the shape instance is in the page. The following VBA code returns 0 (False): ActivePage.Shapes("Task").Cells("PinX").IsInherited But the following code returns -1 (True) : ActivePage.Shapes("Task").Cells("Width").IsInherited The Edit Formula button opens a dialog to enable you to edit multiple lines, since the edit formula bar only displays a single line, and some formulae can be quite large. You can display the Formula Tracing window using the Show Window button in the Formula Tracing group on the ShapeSheet Tools present in Design tab. You can decide whether to Trace Dependents, which displays other cells that have a formula that refers to the selected cell or Trace Precedents, which displays other cells that the formula in this cell refers to. Of course, this can be done in code too. For example, the following VBA code will print out the selected cell in a ShapeSheet into the Immediate Window: Public Sub DebugPrintCellProperties ()'Abort if ShapeSheet not selected in the Visio UI If Not Visio.ActiveWindow.Type = Visio.VisWinTypes.visSheet Then Exit Sub End IfDim cel As Visio.Cell Set cel = Visio.ActiveWindow.SelectedCell'Print out some of the cell properties Debug.Print "Section", cel.Section Debug.Print "Row", cel.Row Debug.Print "Column", cel.Column Debug.Print "Name", cel.Name Debug.Print "FormulaU", cel.FormulaU Debug.Print "ResultIU", cel.ResultIU Debug.Print "ResultStr("""")", cel.ResultStr("") Debug.Print "Dependents", UBound(cel.Dependents)'cel.Precedents may cause an errorOn Error Resume Next Debug.Print "Precedents", UBound(cel.Precedents) End Sub In the previous screenshot, where the Actions.SetDefaultSize.Action cell is selected in the Task shape from the BPMN Basic Shapes stencil, the DebugPrintCellProperties macro outputs the following: Section 240 Row 2 Column 3 Name Actions.SetDefaultSize.Action FormulaU SETF(GetRef(Width),User.DefaultWidth)+SETF(GetRef(Height),User.DefaultHeight) ResultIU 0 ResultStr("") 0.0000 Dependents 0 Precedents 4     Firstly, any cell can be referred to by either its name, or section/row/column indices, commonly referred to as SRC. Secondly, the FormulaU should produce a ResultIU of 0, if the formula is correctly formed and there is no numerical output from it. Thirdly, the Precedents and Dependents are actually an array of referenced cells. Can I print out the ShapeSheet settings? You can download and install the Microsoft Visio SDK from the Visio Developer Center (visit http://msdn.microsoft.com/en-us/office/aa905478.aspx). This will install an extra group, Visio SDK, on the Developer ribbon and one extra button Print ShapeSheet. I have chosen the Clipboard option and pasted the report into an Excel worksheet, as in the following screenshot: The output displays the cell name, value, and formula in each section, in an extremely verbose manner. This makes for many rows in the worksheet, and a varying number of columns in each section. What is a function? A function defines a discrete action, and most functions take a number of arguments as input. Some functions produce an output as a value in the cell that contains the formula, whilst others redirect the output to another cell, and some do not produce a useful output at all. The Developer ShapeSheet Reference in the Visio SDK contains a description of each of the 197 functions available in Visio 2010, and there are some more that are reserved for use by Visio itself. Formulae can be entered into any cell, but some cells will be updated by the Visio engine or by specific add-ons, thus overwriting any formula that may be within the cell. Formulae are entered starting with the = (equals) sign, just as in Excel cells, so that Visio can understand that a formula is being entered rather than just a text. Some cells have been primed to expect text (strings) and will automatically prefix what you type with =" (equals double-quote) and close with "(double-quote) if you do not start typing with an equal sign. For example, the function NOW(), returns the current date time value, which you can modify by applying a format, say, =FORMAT(NOW(),"dd//MM/YYYY"). In fact, the NOW() function will evaluate every minute unless you specify that it only updates at a specific event. You could, for example, cause the formula to be evaluated only when the shape is moved, by adding the DEPENDSON() function: =DEPENDSON(PinX,PinY)+NOW() The normal user will not see the result of any values unless there is something changing in the UI. This could be a value in the Shape Data that could cause linked Data Graphics to change. Or there could be something more subtle, such as the display of some geometry within the shape, like the Compensation symbol in the BPMN Task shape. In the above example, you can see that the Compensation right-mouse menu option is checked, and the IsForCompensation Shape Data value is TRUE. These values are linked, and the Task shape itself displays the two triangles at the bottom edge. The custom right-mouse menu options are defined in the Actions section of the shape's ShapeSheet, and one of the cells, Checked, holds a formula to determine if a tick should be displayed or not. In this case, the Actions.Compensation.Checked cell contains the following formula, which is merely a cell reference: =Prop.BpmnIsForCompensation Prop is the prefix used for all cells in the Shape Data section because this section used to be known as Custom Properties. The Prop.BpmnIsForCompensation row is defined as a Boolean (True/False) Type, so the returned value is going to be 1 or 0 (True or False). Thus, if you were to build a validation rule that required a Task to be for Compensation, then you would have to check this value. You will often need to branch expressions using the following: IF(logical_expression, value_if_true, value_if_false)
Read more
  • 0
  • 0
  • 12345

article-image-creating-visually-rich-activities-special-kids-moodle-19
Packt
12 Jul 2010
9 min read
Save for later

Creating Visually Rich Activities for Special Kids in Moodle 1.9

Packt
12 Jul 2010
9 min read
Putting words inside an image with structure Great! Another vacation day! Alice loved the beach. It was her favorite place to have fun, but she was scared of forgetting what she had learned in school after playing so much on the beach. Therefore, she had an idea. She asked her mother to help her write down everything that she found around her.She had so many things to write down, because the beach was full of people: some of them were sunbathing, others swimming in the sea; there were also children building sandcastles and others playing with balls. Can we help her as well? Time for action – creating a scene We are going to create a scene using a background picture and then add other clipart inside it to represent each word. Start Inkscape and minimize it. You will use it later. Start Word 2007. You will be working in a new blank document. In this case, we will use Word 2007 to search for clipart. However, you can also create a scene with other clipart libraries. We will also use other applications that provide high-quality clipart in other visually rich exercises. Click on Insert Clip Art|. The Clip Art panel will appear on the right-hand side of the main window. Click on the Search in combo box and activate the Everywhere checkbox.This way, Word will search for clipart in all the available collections, including the Web Collections. Click on the Search for textbox and enter Beach. Click on the Go button. Position the mouse pointer over the desired clipart's thumbnail. Since you want to change the picture size without losing quality using Inkscape, remember to make sure that it is a WMF or an EMF file. Right-click on the desired clipart's thumbnail and select Preview/Properties in the context menu that appears. Word will display a new dialog box showing a larger preview of the scalable clipart and a temporary file name. Triple-click on the long path and file name shown after File. This way, you will be sure that the temporary file's full path is selected. Then, right-click on it and select Copy in the context menu that appears. Now, activate Inkscape—remember it was running minimized. You can use Alt + Tab or Windows + Tab. Don't close the clipart's preview window. Select File Import| from the main menu. Click on the Type a file name button (the pencil with a paper sheet icon) and paste the previously copied temporary file's full path in the Location: textbox. The path is going to be similar to C:UsersvanesaAppDataLocalMicrosoftWindowsTemporary InternetFilesContent.IE5WL240QUNMCj04354940000[1].wmf. Click on the Open button. The previously previewed clipart, the background for our scene, will appear in Inkscape's drawing area, as shown in the next screenshot: Return to Word 2007, and close the Preview/Properties dialog box. Repeat the aforementioned steps (6 to 13) for each vector graphic to add to the previously shown background picture, the beach. The next image shows three possible pictures: A bucket and a shovel A beach ball A sandcastle Click on one of the recently added pictures to select it. Eight double-headed arrows will appear in a rectangle around the selection. Drag-and-drop one of the diagonal double-headed arrows and scale the drawing both in the horizontal (X) and vertical(Y) directions. You can do it holding down the Ctrl key in order to maintain the original aspect ratio. Then, drag-and-drop the picture to the appropriate position inside the beach background. Repeat the aforementioned step for the other two pictures to create a scene as shown in the next image: Select File Save| from Inkscape's main menu. Save the file as image030201.svg in the previously created folder, C:Beach. What just happened? We combined several scalable vector clipart images to create a representation of a scene on the beach. Inkscape allowed us to define a background and add different elements on top of it. Each element represents a different word. Time for action – adding floating labels to the image Click on the Create and edit text objects button (a big A with a cursor on the lefthand side) or press F8. This function allows you to add text with different fonts and colors in Inkscape's drawing area. Select the desired font and size using the two combo boxes that appear on the upper left-hand corner of the window, below the main toolbar. Repeat the aforementioned steps (1 to 2) to write the following words as labels, with a layout similar to the one shown in the next image: Sandcastle Umbrella Beach ball Sea Shovel Bucket Once you enter each word, you can click on the desired color in the color palette. It is a good idea to use diverse colors to make it clear that they are different words. Select File Save| from Inkscape's main menu in order to save the changes made to the original Inkscape SVG file. Select File Export Bitmap|. A dialog box showing many export options will appear.Enter 72 on the first dpi (Dots Per Inch) textbox. Click on the Drawing button, and then on Export. Inkscape will export the drawing in PNG format. The exported bitmap graphics with the beach scene and the words at the bottom will be saved at C:Beachimage030201.png. What just happened? We created a representation of a scene on the beach using Inkscape and scalable vector clipart. We first added a background picture and then used vector graphics to add different elements related to specific words. We could change their size without losing quality and we could put them on top of the existing background. We added text labels for each word that represents an element in the scene. Finally, we exported the resulting image to the PNG format. Time for action – uploading the scene to Moodle We now have to upload the original SVG file and its bitmap representation, in order to add our exercise to an existing Moodle course. Log in to your Moodle server. Click on the desired course name (Beach). You can create a new course or use an existing one. As previously learned, follow the necessary steps to edit the summary for a desired week. Enter Exercise 2 in the Summary textbox and save the changes. Click on the Add an activity combo box for the selected week and select Upload a single file. Enter Dragging and dropping words in Assignment name. Select Verdana in font and 5 (18) in size—the first two combo boxes below Description. Next, select your desired color for the text. Click on the big textbox below Description and enter Putting words inside an image with structure. This is the description of the student's goal for this exercise. Press Enter and click on the Insert Image button (a mountain or a tree, according to the Moodle version). A new web page will appear displaying the title Insert image. Click on the chapter03 folder link and then click on the Browse button. Browse to the folder that holds the exported drawing and select the file to upload, image030201.png. Then click on Open and on the Upload button. The label File uploaded successfully will appear inside the File browser box. Next, click on the recently uploaded file name, image030201.png. The image will appear in the Preview box. Enter image in Alternate text and click on OK. The image will appear below the previously entered title. Remember that you can click on the Enlarge editor button to view more information on the screen. Press Enter and click on the Ordered list button (a list of 1, 2, and 3). Write the detailed steps to complete the exercise. Open this picture using Inkscape Drag-and-drop each word to match the corresponding element in the picture Save and upload the new picture Next, select the picture word written in the sentence that describes the first step. Click on the Insert Web Link button (a chain). A new web page will appear displaying the title Insert Link. Click on the Browse button and then on the chapter03 folder link. Click on the new Browse button that appears. Browse to the folder that holds the previously created Inkscape drawing with the scene (C:Beach) and select the file to upload, image030201.svg. Next, click on Open, on Upload, and on the file name link, as shown in the next screenshot: Moodle will display the URL for this Inkscape file in the URL textbox. Enter picture in the title textbox and click on OK. This way, the student is going to be able to download the Inkscape drawing by clicking on the word picture with a hyperlink, as shown in the next screenshot: Select 100 in the Grade combo box. Select 10MB in Maximum size. This is the maximum size for the file that each student is going to be able to upload as a result for this activity. However, it is very important to check the possibilities offered by your Moodle server with its Moodle administrator. Finally, scroll down and select Save and return to course. What just happened? We added the putting words inside an image with structure exercise to a Moodle course.The students are now going to be able to follow the instructions explained in the upload a single file assignment and download the Inkscape drawing to drag-and-drop words. We defined a hyperlink to the Inkscape drawing because the students are going to use it to drag-and-drop each word to the corresponding zone of the scene. The upload a single file assignment allowed us to describe the necessary steps to complete the activity, and it's also going to enable the students to upload their results as an Inkscape drawing. In this case, the necessary steps to complete the activity are just a few sentences in order to simplify the example. However, sometimes, it is necessary to write more instructions when you have to work with other applications such as Inkscape.
Read more
  • 0
  • 0
  • 2385
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
article-image-fine-tune-view-layer-your-fusion-web-application
Packt
08 Jul 2010
5 min read
Save for later

Fine Tune the View layer of your Fusion Web Application

Packt
08 Jul 2010
5 min read
(For more resources on Oracle, see here.) The following diadram illustrates the roles of each layer. Use AJAX to boost up the performance of your web pages Asynchronous JavaScript and XML (AJAX) avoid the full page refresh and minimize the data that being transferred between client and server during each round trip. ADF Faces is packaged with 150+ AJAX enabled components which adds AJAX capability to your applications with zero effort. Certain events on an ADF Faces component trigger Partial Page Rendering (PPR) by default. However action components, by default, triggers full page refresh which is quite expensive and may not be required in most of the cases. Make sure that you set partialSubmit attribute to true whenever possible to optimize the page lifecycle. When partialSubmit is set to true, then only the components that have values for their partialTriggers attribute will be processed through the lifecycle. Avoid mixing of html tags with ADF Faces components Don’t mix html tags and ADF Faces components though JSF design let you to do so using <f:verbatim> tag. Mixing row html contents with ADF Faces components may produce undesired output, especially when you have complex layout design for your page. It's highly discouraged to use <f:verbatim> to embed JavaScript or CSS, instead you can use <af:resource> which adds the resource to the document element and optimizes further processing during tree rendering. Avoid long Ids for User Interface components It's always recommended to use short Ids for your User Interface (UI) components. Your JSF page finally boils down to html contents, whose size decides the network bandwidth usage for your web application. If you use long Ids for UI (User Interface) component, that increases the size of the generated html content. This becomes even worse, if you have many UI elements with long Ids. If there's no Id is set for a UI component explicitly, ADF Faces runtime auto generates Ids for you. ADF Faces let you to control the auto generation of component ids by setting context parameter 'oracle.adf.view.rich.SUPPRESS_IDS' in the web.xml file. The <context-param> entry in the web.xml file may look like as shown below. <context-param> <param-name> oracle.adf.view.rich.SUPPRESS_IDS </param-name> <param-value>auto or explicit </param-value></context-param> Possible values for oracle.adf.view.rich.SUPPRESS_IDS are listed below. auto: Components can suppress auto generated IDs, but explicitly set ID will be honored. explicit: This is the default value for oracle.adf.view.rich.SUPPRESS_IDS parameter. In this case both auto generated IDs and explicitly set IDs would get suppressed. Avoid inline usage of JavaScript/Cascading Style Sheets (CSS) whenever possible If you need to use custom JavaScript functions or CSS in your application, try using external files to hold the same. Avoid inline usage of JavaScripts/CSS as much as possible. A better idea is to logically group them in external files and embed the required one in the candidate page using <af:resource> tag. If you keep JavaScript and CSS in external files, they are cached by the browser. Apparently, subsequent requests for these resources are served from the cache. This in turn reduces the network usage and improves the performance. Avoid mixing JSF/ADF Faces and JavaServer Pages Standard Tag Library (JSTL) tags Stick on JSF/ADF Faces components for building your UI as much as you can. JSF component may not work properly with some JSTL tags as they are not designed to co-exist. Relying on JSF/ADF Faces components may give you better extensibility and portability for your application as bonus. Don't generate client component unless it's really needed ADF Faces runtime generates the client components only when they are really required on the client. However you can override this behavior by setting the attribute clientComponent to true, as shown in the following code snippet. <af:commandButton text="DoSomething" clientComponent="true"> <af:clientListener method="doSomething" type="action"/></af:commandButton> Set clientComponent to true only if you need to access the component on the client side using JavaScript. Otherwise this may result in increased Document Object Model (DOM) size at the client side and may affect the performance of your web page. The following diagram shows the runtime coordination between client side and server side component trees. In the above diagram, you can see that no client side component is generated for the server component whose clientComponent attribute is set to false. Prefer not to render the components over hiding components from DOM tree If you need to hide UI components conditionally on a page, try achieving this with rendered property of the component instead of using visible property. Because the later creates the component instance and then hides the same from client side DOM tree, where as the first approach skips the component creation at the server side itself and client side DOM does not have this element added. Apparently setting rendered to false, reduces the client content size and gives better performance as bonus.
Read more
  • 0
  • 0
  • 2831

article-image-organizing-microsoft-dynamics-gp-2010
Packt
08 Jul 2010
7 min read
Save for later

Organizing Microsoft Dynamics GP 2010

Packt
08 Jul 2010
7 min read
(For more resources on Microsoft, see here.) Speeding up account entry with Account Aliases As organizations grow the chart of accounts tends to grow larger and more complex as well. Companies want to segment their business by departments, locations, or divisions. All of this means that more and more accounts get added to the chart. As the chart of accounts grows it gets more difficult to select the right account. Dynamics GP provides the Account Alias feature as a way to quickly select the right account. The account aliases provide a way to create shortcuts to specific accounts. This can dramatically speed up the process of selecting the correct account. We'll look at how this works in this recipe. Getting ready Setting up Account Aliases requires a user with access to the Account Maintenance window. To get to this window: Select Financial from the Navigation Pane on the left. In the Cards section of the Financial Area Page click on Accounts. This will open the Account Maintenance window. Click on the lookup button (indicated by a magnifying glass) next to the Account field. Find and select Account No. 000-2100-00. Enter AP in the Alias field, which is in the middle of the Account Maintenance window. This associates the letters AP with the Accounts Payable account selected. This means that the user now only has to enter AP instead of the full account number to use the Accounts Payable account: How to do it... Once aliases have been set up, let's see how the user can quickly select an account using the alias. To demonstrate how this works, click on Financial from the Navigation Pane on the left. Select Transaction Entry from the Financial Area Page under Transactions. In the Transaction Entry window select the top line in the grid area on the lower half of the window. Click on the blue arrow next to the Account heading to open the Account Entry window. In the Alias field type AP and press Enter: The Account Entry window will close and the account represented by the alias will appear in the Transaction Entry window: How it works... Account Aliases provide quick shortcuts for account entry. Keeping them short and obvious makes them easy to use. Aliases are less useful if users have to think about them. Limiting them to the most commonly used accounts make these more useful. Most users don't mind occasionally looking up the odd account. However, they wouldn't want to memorize long account strings for regularly used account numbers. It's counter-productive to put an alias on every account as that would make finding the right alias as difficult as finding the right account number. The setup process should be performed on the most commonly used accounts to provide easy access. See also Gaining visibility with Horizontal Scroll Arrows Gaining visibility with Horizontal Scroll Arrows A consequence of company growth is that not only does the chart of accounts grow larger and less intuitive, but the actual lengths of account numbers tend to grow longer as well. Companies want to be able to report by account, department, location, and so on. This results in a proliferation of segments added to the main account number and can create very long account names. Dynamics GP can accommodate an account number as long as 66 characters. The longest I've seen used in practice was 27 characters and even that was unwieldy. Most users only need a portion of that length for their day-to-day work. This presents a problem because very long account numbers won't fit into the account number field on most screens. For this recipe, we'll look at how Dynamics GP provides a solution to this in the User Preferences window. How to do it... Here we'll see how to increase the visibility of long account numbers: On the Navigation Pane on the left select Home. Click on User Preferences on the Shortcut Bar. Select the checkbox for Horizontal Scroll Arrows: This turns on the functionality to allow users to scroll horizontally within the Account field and lets them see the full account number: How it works... Once Horizontal Scroll Arrows are activated small arrows appear at the left-hand and right-hand side of the Account field letting users scroll right and left to see the full account number. There's more... Horizontal Scroll Arrows are implemented on a per-user basis, meaning each user has to turn this on individually. Administrators can make this active for all users with an SQL script. Additionally, for companies using alphanumeric characters in their chart of accounts, wide letters such as M or W are often difficult to see. There is also an option to increase the visible width of a particular segment. Activating Horizontal Scroll Arrows for all users Horizontal Scroll Arrows are activated by the user. However, an administrator can turn this feature on for all users in all companies by running the following SQL script against the Dynamics database: Update SY01400Set HSCRLARW=1 Widening segments for better visibility When companies use alphanumeric characters in their chart of accounts wide letters, such as M or W, are often cut off. Horizontal scroll arrows don't help because the problem is that the segment field is too narrow, not the entire account field. To resolve this problem Dynamics GP provides an option to widen the segment fields as well. On the Navigation Pane click on Administration. Select Account Format. For each segment that needs to be wider, select the field under the Display Width column and change it from Standard to Expansion 1, Expansion 2, or Expansion 3 to widen the field. Expansion 3 represents the widest option. Companies using only numbers in their chart of accounts won't need to widen the segment field. However, firms that include letters as part of their chart will need to increase the width. Following is a list of the expansion options and the letters these are designed to accommodate: Expansion 1: A,B,E,K,P,S,V,X, and Y Expansion 2: C,D,G,H,M,N,O, Q,R, and U Expansion 3: W Streamlining payables processing by prioritizing vendors Management of vendor payments is a critical activity for any firm. It's even more critical in difficult economic times. Companies need to understand and control payments. A key component of that is prioritizing vendors. Every firm has both critical and expendable vendors. Paying critical vendors on time is a key business driver. For example, a newspaper company that doesn't pay their newsprint supplier won't be in business for long. However, they can safely delay payments to their janitorial vendor without worrying about going under. Dynamics GP provides a mechanism to prioritize vendors and apply those priorities when selecting which checks to print. That is the focus of this recipe. Getting ready Setting this up first requires that the company figure out who the priority vendors are. That part is beyond the scope of this book. The Vendor Priority field in Dynamics GP is a 3-character field. Users shouldn't be tempted by the possibilities of 3 characters. A best practice is to keep the priorities simple by using 1, 2, and 3 or A, B, and C. Anything more complicated than this tends to confuse users and actually makes it harder to prioritize vendors. Once the vendor priorities have been determined the priority needs to be set in Dynamics GP. Attaching a priority to a vendor is the first step. To do that: Select Purchasing from the Navigation Pane. In the Purchasing Area Page, under Cards, click on Vendor Maintenance. Once the Vendor Maintenance window opens, click on the lookup button (indicated by a magnifying glass) next to Vendor ID. Select a vendor and click on OK. Once the vendor information is populated, click on the Options button. This opens the Vendor Maintenance Options window. In the center left is the Payment Priority field. Enter 1 in the Payment Priority field and click on Save:
Read more
  • 0
  • 0
  • 1423

article-image-java-oracle-database
Packt
07 Jul 2010
5 min read
Save for later

Java in Oracle Database

Packt
07 Jul 2010
5 min read
"The views expressed in this article are the author's own and do not necessarily reflect the views of Oracle." (For more resources on Oracle, see here.) Introduction This article is better understood by people who have some familiarity with Oracle database, SQL, PL/SQL, and of course Java (including JDBC). Beginners can also understand the article to some extent, because it does not contain many specifics/details. The article can be useful to software developers, designers and architects working with Java. Oracle database provides a Java runtime in its database server process. Because of this, it is possible not only to store Java sources and Java classes in an Oracle database, but also to run the Java classes within the database server. Such Java classes will be 'executed' by the Java Virtual Machine embedded in the database server. The Java platform provided is J2SE-compliant, and in addition to the JVM, it includes all the Java system classes. So, conceptually, whatever Java code that can be run using the JREs (like Sun's JRE) on the operating system, can be run within the Oracle database too. Java stored procedure The key unit of the Java support inside the Oracle database is the 'Java Stored Procedure' (that may be referred to as JSP, as long as it is not confused with JavaServer Pages). A Java stored procedure is an executable unit stored inside the Oracle database, and whose implementation is in Java. It is similar to PL/SQL stored procedures and functions. Creation Let us see an example of how to create a simple Java stored procedure. We will create a Java stored procedure that adds two given numbers and returns the sum. The first step is to create a Java class that looks like the following: public class Math{ public static int add(int x, int y) { return x + y; }} This is a very simple Java class that just contains one static method that returns the sum of two given numbers. Let us put this code in a file called Math.java, and compile it (say, by doing 'javac Math.java') to get Math.class file. The next step is to 'load' Math.class into the Oracle database. That is, we have to put the class file located in some directory into the database, so that the class file gets stored in the database. There are a few ways to do this, and one of them is to use the command-line tool called loadjava provided by Oracle, as follows: loadjava -v -u scott/tiger Math.class Generally, in Oracle database, things are always stored in some 'schema' (also known as 'user'). Java classes are no exception. So, while loading a Java class file into the database, we need to specify the schema where the Java class should be stored. Here, we have given 'scott' (along with the password). There are a lot of other things that can be done using loadjava, but we will not go into them here. Next, we have to create a 'PL/SQL wrapper' as follows: SQL> connect scott/tigerConnected.SQL>SQL> create or replace function addition(a IN number, b IN number) return number 2 as language java name 'Math.add(int, int) return int'; 3 /Function created.SQL> We have created the PL/SQL wrapper called 'addition', for the Java method Math.add(). The syntax is same as the one used to create a PL/SQL function/procedure, but here we have specified that the implementation of the function is in the Java method Math.add(). And that's it. We've created a Java stored procedure! Basically, what we have done is, implemented our requirement in Java, and then exposed the Java implementation via PL/SQL. Using Jdeveloper, an IDE from Oracle, all these steps (creating the Java source, compiling it, loading it into the database, and creating the PL/SQL wrapper) can be done easily from within the IDE. One thing to remember is that, we can create Java stored procedures for Java static methods only, but not for instance methods. This is not a big disadvantage, and in fact makes sense, because even the main() method, which is the entry point for a Java program, is also 'static'. Here, since Math.add() is the entry point, it has to be 'static'. So, we can write as many static methods in our Java code as needed and make them entry points by creating the PL/SQL wrappers for them. Invocation We can call the Java stored procedure we have just created, just like any PL/SQL procedure/function is called, either from SQL or PL/SQL: SQL> select addition(10, 20) from dual;ADDITION(10,20)--------------- 30SQL>SQL> declare 2 s number; 3 begin 4 s := addition(10, 20); 5 dbms_output.put_line('SUM = ' || s); 6 end; 7 /SUM = 30PL/SQL procedure successfully completed.SQL> Here, the 'select' query, as well as the PL/SQL block, invoked the PL/SQL function addition(), which in turn invoked the underlying Java method Math.add(). A main feature of the Java stored procedure is that, the caller (like the 'select' query above) has no idea that the procedure is indeed implemented in Java. Thus, the stored procedures implemented in PL/SQL and Java can be called alike, without requiring to know the language in which the underlying implementation is. So, in general, whatever Java code we have, can be seamlessly integrated into the PL/SQL code via the PL/SQL wrappers. Putting in other words, we now have more than one language option to implement a stored procedure - PL/SQL and Java. If we have any project where stored procedures are to be implemented, then Java is a good option, because today it is relatively easier to find a Java programmer.
Read more
  • 0
  • 0
  • 4635

article-image-tools-and-techniques-solving-least-privilege-security-problems
Packt
07 Jul 2010
5 min read
Save for later

Tools and Techniques for Solving Least Privilege Security Problems

Packt
07 Jul 2010
5 min read
(For more resources on Microsoft products, see here.) Granting temporary administrative privileges One of the primary concerns for system administrators when implementing Least Privilege Security on notebook computers is how to solve problems that require administrative access if a remote connection cannot be established. Consider a scenario where a user arrives at a conference center but can't connect their notebook to the local network because there isn't a DHCP server available. The only way to make a successful connection is to manually configure an IP address. While we could add users to the Network Configuration Operators group on each notebook so that they can configure local network settings, the requirement to manually configure network options is rare and granting this access is likely to create more support problems than it solves. If you've ever worked on a help desk, you'll know that a high percentage of calls from mobile workers are related to network connection problems, often caused by a misconfiguration. Windows doesn't have any built-in mechanism that allows system administrators to temporarily grant administrative privileges, leaving IT nervous to commit to Least Privilege on notebook computers. In this section, we'll look at a couple of simple techniques that can be used to grant temporary administrative access to mobile users when all else fails. Neither method is perfect, and could potentially be hijacked by savvy users to install unsanctioned software or grant themselves permanent administrative access, but there must be a back door for system administrators to ensure confidence in the ability to provide support in any situation. The instructions that follow use local user accounts and local policy settings, but are intended for use in a domain environment. If you wish to manage the accounts and policy settings centrally, domain users and domain-based Group Policy Objects can be used as an alternative. The following techniques shouldn't be used in high security environments. Granting temporary administrative access using a separate logon (Vista and Windows 7 only) For each notebook in our organization, we need to create a set of accounts that have administrative access. Let's create three accounts on each notebook—Support1, Support2, and Support 3. Creating three support accounts You can do this easily from the command prompt or by adding the appropriate commands to a batch file. Log on to the notebook as an administrator and run the following two commands from the command prompt: net user Support1 ******** /expires:never /passwordchg:no /ADDnet localgroup Administrators Support1 /ADD Replace ******** with a random password for each account. The passwords for each support account must be recorded somewhere for future reference. The password for each account should be completely random and differ on every notebook. Creating a policy setting to automatically delete the support account at logoff To ensure that the support account is deleted at log off, we need to create a local policy setting for each support account. Type MMC into the Search programs and files box on the Start menu and press Enter. Press Ctrl+M to add a snap-in. In the Add or Remove Snap-ins dialog box, select Group Policy Object Editor from the list on the left and click Add. In the Select Group Policy Object dialog box, click Browse. In the Browse for a Group Policy Object window, switch to the Users tab. Select Support1 in the list and click OK. In the Select Group Policy Object dialog box, the Group Policy Object will now read Local ComputerSupport1. Click Finish. In the Add or Remove Snap-ins dialog box, click OK. In the MMC console window, expand Local ComputerSupport1 Policy, User Configuration, Windows Settings under Console Root in the left pane. Click Scripts (Logon/Logoff) under Windows Settings. In the central pane, double-click Logoff. In the Logoff Properties dialog box, click Add. In the Add a Script window, type net in the Script Name field. In the Script Parameters field type user support1 /delete and click OK. Click OK in the Logoff Properties dialog box. Close the MMC window. These steps need to be repeated for each support account. Testing the support accounts To test the configuration, log in to Windows using the Support1 account. You'll need to click Switch User on the log on screen and then select Other User. When entering the username, specify that it's a local user account using the format COMPUTERNAMEUSERNAME. In this case, the computer is called WIN7. Check that Support1 has administrative access by performing a task such as changing the date or time. If Support1 has administrative privileges, UAC will not prompt for elevation. Log off Support1 and then try to log in again using the same account. This time you should be presented with The user name or password is incorrect as an error message because the Support1 account no longer exists.   To repeat the support procedure, the password for Support2 must be known by the user. Putting into practice The procedure outlined here can be used by help desk staff when a user requires a temporary administrative login for support:
Read more
  • 0
  • 0
  • 2323
article-image-using-javascript-effects-enhance-your-joomla-website-visitors
Packt
06 Jul 2010
5 min read
Save for later

Using Javascript Effects to enhance your Joomla! website for Visitors

Packt
06 Jul 2010
5 min read
(Read more interesting articles on Joomla! 1.5 here.) Introduction Joomla! is a feature-rich content management system, but there are some things it can't do out of the box. This is where JavaScript can become useful in improving the experience of your website to its visitors. Including a JavaScript file in your Joomla! template One of the most basic aspects of using JavaScript with your Joomla! template is including it within the page. There are two ways to do this—within the <head> element of your template, or within the <body> element of your template (best placed just above the </body> element). We'll make use of the method that uses the <head> template. (The reasons to do so are covered in another recipe of this article.) Getting ready Open your template's index.php template, located in your template's subdirectory within your Joomla! installation's templates directory. How to do it... Locate the <head> element of your Joomla! template in the index.php file and insert a <script> element that references the JavaScript file(s) that you wish to use: <!-- some HTML omitted for brevity --><script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/js/javascript-file.js"></script></head> Note that the base directory of your Joomla! installation is inserted automatically to help prevent any problems with changing directory paths to the JavaScript file, should you change your website's location.You will need to change the template's path if you choose to rename your template. For valid XHTML, you need to specify the type attribute, as shown: <script type="text/javascript" src="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/js/javascript-file.js"></script> How it works... When a browser encounters a <script> element in your page, it loads the required behavior included in the JavaScript file, assuming that your browser has it enabled. See also Including a JavaScript file in your Joomla! template Maximizing backward compatibility with JavaScript Installing Google Analytics Integrating AddThis social bookmarking tool with your Joomla! template Tips and tricks for minimizing page load time when using JavaScript While JavaScript can be used to enhance your visitors' experience of your Joomla! website, it can have a negative impact in terms of both real and envisaged loading times of pages.JavaScript slows down the loading of a page because it's a single-threaded language. This means that nothing else can occur while JavaScript is being loaded or something in JavaScript is being evaluated. As such, a single, slow-loading JavaScript file can prevent a whole website from loading quickly! How to do it... The most obvious thing that you can do to make your Joomla! template load more efficiently is to compress any JavaScript you do use. As such, there are a number of online compression tools that you can use, including the JavaScript Compressor (http://javascriptcompressor.com): Once you've inserted your JavaScript into the Paste your code input area, click on Compress. In this example, we've used a function that creates a slideshow with the use of the jQuery library: // Requires jQuery to run$(document).ready(function() { $('#slideshow-wrapper').cycle({ fx: 'fade', speed: 'normal', timeout: 0, next: '#next', prev: '#prev' }); $('#slidie').cycle({ fx: 'fade' }); }); As you can see, quite a compression is noticeable even with a relatively compact piece of JavaScript, around half the size of the original in terms of memory required to store it (and thus, resources required to load it for a visitor visiting your website). $(document).ready(function(){$('#slideshow-wrapper').cycle({fx:'fade',speed:'normal',timeout:0,next:'#next',prev:'#prev'});$('#slidie').cycle({fx:'fade'})}); Many JavaScript libraries (such as jQuery and MooTools) and features are available in a compressed format already. There is also a Joomla! extension called JCH Optimize that you can use. You can download it from http://extensions.joomla.org/extensions/site-management/site-performance/12088. How it works... As you've seen, JavaScript is a single-threaded language, so one technique to minimize its impact on your Joomla! website's loading times for visitors is to make the JavaScript the last possible item in the page to load. Additionally, compressing JavaScript can greatly reduce page-loading times with larger JavaScript files. It's also worth keeping a backup of the uncompressed JavaScript file, as this makes it easier to change and recompress in the future. There's more... Another way to minimize your Joomla! template's page load time is to reference JavaScript and other template files from different hostnames. Browsers including Internet Explorer and Firefox have been known to limit the number of simultaneous connections to a hostname, slowing down the loading of the page. Moving <script>tags to the bottom of the page The other major factor that can slow down the page load times for visitors to your Joomla! website is the necessity for their browser to have to stop while it deals with any JavaScript included in your page. You can overcome this by reordering the HTML elements in your Joomla! template's index.php file to move the <script> elements to the bottom of the page where they appear inline. See also Maximizing backward compatibility with JavaScript Installing Google Analytics
Read more
  • 0
  • 0
  • 2778

article-image-extending-applications-tcl
Packt
06 Jul 2010
12 min read
Save for later

Extending Applications in Tcl

Packt
06 Jul 2010
12 min read
(For more resources on Tcl, see here.) Very often applications need to be extended with additional functionalities. In many cases it is also necessary to run different code on various types of machines. A good solution to this problem is to introduce extensibility to our application. We'll want to allow additional modules to be deployed to specified clients—this means delivering modules to clients, keeping them up to date, and handling loading and unloading of modules. The following sections will introduce how Starkits and Tcl's VFS can be used to easily create modules for our application, and how these can be used to deploy additional code. We'll also introduce a simple implementation of handling modules, both on server side and client side. This requires creating code for downloading modules themselves, loading them, and the mechanism for telling clients what actions they should be performing. The server will be responsible for telling clients when they should load or unload any of the modules. They will also inform clients if any of the modules are out of date. Clients will use this information to make sure modules that are loaded are consistent, with what server expects. The following steps will be performed by the client: The client sends a list of loaded modules and a list of all available modules along with their MD5 checksums to server The server responds with the list of modules to load, unload, and which need to be downloaded The client downloads modules that it needs to download; if the client already has downloaded all modules it needs, no action is taken The client unloads modules that it should unload and loads modules that it should load; if the client has already loaded all modules it should have, no action is taken Handling security is an additional consideration when creating pluggable applications. Clients should check if files are authentic whenever they download any code, which will be run on the client. This can be achieved using SSL and Certificate Authorities. Starkits as extensions One of the features Tcl offers is its VFS and using single file archives for staging entire archives. We've used these technologies to create our clients as single file executables. Now we'll reuse similar mechanisms to create modules for our application. All modules will simply be a Starkit VFS—this will allow embedding all types of files, creating complex scripts, and easily manage whatever a module contains. Our modules will have their MD5 checksum calculated, similar to the automatic update feature. This will allow the application to easily check whether a module needs to be updated or not. In order to deliver modules to a client, the server will allow downloading modules, similar to retrieving binaries for automatic update. Building modules Our modules will be built similar to how binaries were built, with a minor exception. Modules will have their MD5 checksum stored as the first 32 bytes of the file; this does not cause problems for MK4 VFS package and allows easy checking of whether a package is up to date or not. The source code for each module will be stored in the mod-<modulename> directories. For the purpose of this implementation, clients will source the load.tcl script when loading the package and will source the unload.tcl script when unloading it. It will be up to the module to initialize and finalize itself properly. The directory and file structure in the following screenshot show how files for modules are laid out. It is based on previous example and only the mod-comm and mod-helloworld directories are new. We'll need to modify the build.tcl script and the add code responsible for building of modules. We can do this after the initial binaries have been built. First let's create the modules directory: file mkdir modules Then we'll iterate over each module to build and create name of the target file: foreach module {helloworld comm} { set modfile [file join modules $module.kit] W e'll start off by creating a 32 byte file: set fh [open $modfile w]fconfigure $fh -translation binaryputs -nonewline $fh [string repeat " " 32]close $fh Next we'll create the VFS, copy the source code of the module, and unmount it: vfs::mk4::Mount $modfile $modfile docopy mod-$module $modfile vfs::unmount $modfile Now, calculate the MD5 checksum of the newly created module: set md5 [md5::md5 -hex -file $modfile] And set the first 32 bytes to the checksum: set fh [open $modfile r+] fconfigure $fh -translation binary seek $fh 0 start puts -nonewline $fh $md5 close $fh } We'll create two modules—helloworld and comm. The first one will simply log "Hello world!" every 30 seconds. The second one will set up a comm interface that can be used for testing and debugging purposes. Let's start with creating the mod-helloworld/load.tcl script which will be responsible for initializing the helloworld module: csa::log::info "Loading helloworld module"namespace eval helloworld {}proc helloworld::hello {} { csa::log::info "Hello world!" after cancel helloworld::hello after 30000 helloworld::hello}helloworld::hello Our module will log the information that it has been loaded ,and write out hello world to the log. The helloworld::hello command also schedules itself to be run every 30 seconds. The mod-helloworld/unload.tcl script that cleans up the module looks like this: csa::log::info "Unloading helloworld module"after cancel helloworld::hellonamespace delete helloworld This will log information about the unloading of a module, cancel the next invocation of the helloworld::hello command, and remove the entire helloworld namespace. Implementing the comm module is also simple. The mod-comm/load.tcl script is as follows: csa::log::info "Loading comm module"package require commcomm::comm configure -port 1992 -listen 1 -local 1 This script simply loads the comm package, sets it up to listen on port 1992, and only accepts connections on the local interface. Unloading the package (in mod-comm/load.tcl) will configure the comm interface not to listen for incoming connections: csa::log::info "Unloading comm module"comm::comm configure -listen 0 As the comm package cannot be simply unloaded, the best solution is for load.tcl to configure it to listen for connections and unload.tcl to disable listening. Server side The server side of extensibility needs to perform several activities. First of all we need to track which clients should be using which modules. The second function is providing clients with modules to download. The third functionality is telling clients which modules they need to fetch from the server, and which ones that they need to load or unload from the environment. Let's start off with adding initialization of the modules directory to our server. We need to add it to src-server/main.tcl: set csa::binariesdirectory [file join [pwd] binaries]set csa::modulesdirectory [file join [pwd] modules]set csa::datadirectory [file join [pwd] data] We'll also need to load an additional script for handling this functionality: csa::log::debug "Sourcing remaining files"source [file join $starkit::topdir commapi.tcl]source [file join $starkit::topdir database.tcl]source [file join $starkit::topdir clientrequest.tcl]source [file join $starkit::topdir autoupdate.tcl]source [file join $starkit::topdir clientmodules.tcl] Next we'll also need to modify src-server/database.tcl to add support for storing the modules list. We'll need to add a new table definition to script that creates all tables: CREATE TABLE clientmodules ( client CHAR(36) NOT NULL, module VARCHAR(255) NOT NULL ); In order to work on the data we'll also need commands to add or remove a module for a specified client: proc csa::setClientModule {client module enabled} { if {[llength [db eval {SELECT guid FROM clients WHERE guid=$client AND status=1}]] == 0} { return false } db eval {DELETE FROM clientmodules WHERE client=$client AND module=$module} if {$enabled} { db eval {INSERT INTO clientmodules (client, module) VALUES($client, $module)} } return true} Our command starts off by checking if a client exists and returns immediately if it does not. In the next step, we delete any existing entries and insert a new row if we've been asked to enable a particular module for a specified client. We'll also need to be able to list modules associated with a particular client, which means executing a simple SQL query to list modules: proc csa::getClientModules {client} { return [lsort [db eval {SELECT module FROM clientmodules WHERE client=$client}]]} Then we'll need to create the clientmodules.tcl file that will have functionality related to handling modules, and providing them to clients. The first thing required is a function to read MD5 checksums from modules. We'll first check if the file exists and return an empty string if it does not, otherwise we'll read and return the first 32 bytes of the file: proc csa::getModuleMD5 {name} { variable modulesdirectory set filename [file join $modulesdirectory $name] if {![file exists $filename]} { return "" } set fh [open $filename r] fconfigure $fh -translation binary set md5 [read $fh 32] close $fh return $md5} Next we'll create a function that takes a client identifier, queries the database for modules for that client and returns a list of module-md5sum pairs, which can be treated as a dictionary – where the key is the module name and the value is its md5 checksum. proc csa::getClientModulesMD5 {client} { set rc [list] foreach module [getClientModules $client] { lappend rc $module [getModuleMD5 $module] } return $rc} Another function will handle requests for a particular module. Similar to how it is implemented for automatic updates, we'll provide files only from a single directory and handle cases where a file does not exist, and register a prefix for the requests in TclHttpd: proc csa::handleClientModule {sock suffix} { variable modulesdirectory set filename [file join $modulesdirectory [file tail $suffix]] log::debug "handleClientModule: File name: $filename" if {[file exists $filename]} { Httpd_ReturnFile $sock application/octet-stream $filename } else { log::warn "handleClientModule: $filename not found" Httpd_Error $sock 404 }}Url_PrefixInstall /client/module csa::handleClientModule For communication with the clients, we'll reuse the protocol for requesting jobs. We also need a function that given a client identifier, request dictionary, and name of the response variable will provide information to the client. It will also return whether a client should be provided with a list of jobs or not. If a client will need to download new or updated modules first, we do not need to provide a list of jobs as the client will need to have updated modules first. Let's start by making sure that both the modules available on the client and the list of loaded modules has been sent to the client: proc csa::csaHandleClientModules {guid req responsevar} { upvar 1 $responsevar response set ok true if {[dict exists $req availableModules] && [dict exists $req loadedModules]} { Then we copy the values to local variables for convenience, and get a list of modules that a client should have along with their MD5 checksums. set rAvailable [dict get $req availableModules] set rLoaded [dict get $req loadedModules] set lAvailable [getClientModulesMD5 $guid] We'll also create a list of actions we want to pass back to the client— the list of modules it needs to download and the list of modules to load and unload. By default, all lists are empty and we'll add items only if we detect that the client should perform actions: set downloadList [list] set loadList [list] set unloadList [list] As the first step, we'll iterate over the modules that the client should have and check if it has them—if the client either does not have a module or its checksum differs, we'll tell the client to download it. foreach {module md5} $lAvailable { if {(![dict exists $rAvailable $module]) || ([dict get $rAvailable $module] != $md5)} { lappend downloadList $module } After this we check if the client has already loaded this module. If not, we'll tell him to load the module. if {[lsearch -exact $rLoaded $module] < 0} { lappend loadList $module } } We'll also iterate over the modules that the client currently has loaded and if any of them should not be loaded according to our list, we'll tell the client to unload it. foreach module $rLoaded { if {![dict exists $lAvailable $module]} { lappend unloadList $module } } Once we've conducted our comparison, we tell the agent what should be done. If he needs to download any modules, we only return this information and return that there is no point in providing the list of jobs to perform: if {[llength $downloadList] > 0} { dict set response moduleDownload $downloadList set ok false } else { Otherwise if all modules on the client are updated, we provide a list of modules to load or unload if this is needed. if {[llength $loadList] > 0} { dict set response moduleLoad $loadList } if {[llength $unloadList] > 0} { dict set response moduleUnload $unloadList } } Finally, we return whether or not we should provide the client with a list of jobs to perform or not: } return $ok} Now we'll need to modify the csa::handleClientProtocol command in the src-server/clientrequest.tcl file to invoke our newly created csa::csaHandleClientModules command: if {[csaHandleClientModules $guid $req response]} { # only specify jobs if client # has all the modules if {[dict exists $req joblimit]} { set joblimit [dict get $req joblimit] } else { set joblimit 10 } dict set response jobs [getJobs $guid $joblimit] log::debug "handleClientProtocol: Jobs: [llength [dict get $response jobs]]"} This will cause jobs to be added only if the csaHandleClientModules command returned true. We can also modify the csa::apihandle command in the src-server/commapi.tcl file to allow adding or removing a module from a client. The following needs to be added inside the main switch responsible for handling commands: switch -- $cmd { addClientModule { lassign $command cmd client module return [setClientModule $client $module 1] } removeClientModule { lassign $command cmd client module return [setClientModule $client $module 0] } These commands simply invoke the csa::setClientModule command created earlier.
Read more
  • 0
  • 0
  • 10618

article-image-new-oracle-books
Packt
05 Jul 2010
1 min read
Save for later

New Oracle Books

Packt
05 Jul 2010
1 min read
Oracle E-Business Suite 12 Financials Cookbook Take the hard work out of your daily interactions with Oracle E-Business Suite Financials with this book and eBook Oracle WebCenter 11g PS3 Administration Cookbook Over 100 advanced recipes to secure, support, manage and administer Oracle WebCenter
Read more
  • 0
  • 0
  • 2771
article-image-adding-random-background-image-your-joomla-template
Packt
02 Jul 2010
2 min read
Save for later

Adding a Random Background Image to your Joomla! Template

Packt
02 Jul 2010
2 min read
(Read more interesting articles on Joomla! 1.5 here.) Adding a random background image to your Joomla! template In distinguishing your Joomla! template from others, there are a number of extensions for Joomla! to help you, including one that allows you to display a random image as your template's background image for the <body> element. Getting ready You need to install the extension called Random Background. You can find the file's download link on the Joomla! website at http://extensions.Joomla.org/extensions/style-a-design/templating/6054. Once you have saved the extension files somewhere on your computer, log in to your website's Joomla! administration panel (if Joomla! is installed at example.com, the administration panel is typically accessible at example.com/administrator), and select the Install/Uninstall option from the Extensions option in the primary navigation: You will then be presented with a form, from where you can upload the extension's .zip file. Select the file from your computer, and then click on the Upload file & install button: Once complete, you should receive a confirmation message: Setting relevant permissions for installing the module If you have problems installing the module, you may receive an error message like the following one: The error is most likely because two directories on your server do not have sufficient permissions: /tmp /modules Use Joomla!'s FTP layer to manage the necessary file permissions for you. You can edit Joomla!'s configuration file, which is called configuration.php, in the root of your Joomla! website. Simply add these variables into the file if they don't exist already: var $ftp_host = ''; // your FTP host, e.g. ftp.example.com or just example.com, depending on your hostvar $ftp_port = ''; // usually 21var $ftp_user = ''; // your FTP usernamevar $ftp_pass = ''; // your FTP passwordvar $ftp_root = ''; // usually / or the directory of your Joomla! installvar $ftp_enable = '1'; // 1 = enabled
Read more
  • 0
  • 0
  • 5344

article-image-maintaining-microsoft-dynamics-gp-2010
Packt
02 Jul 2010
9 min read
Save for later

Maintaining Microsoft Dynamics GP 2010

Packt
02 Jul 2010
9 min read
(For more resources on Microsoft, see here.) Preventing entry of wrong dates by Closing Periods An important step in maintaining any accounting system is controlling access to financial periods. Financial period balances control how financial statements are presented. Once financial statements are complete they shouldn't change except in very specific, controlled circumstances. If a firm doesn't properly control access to financial periods the company's frustration of trying to compare results to a moving target, continually changing fi nancial statements can cause Securities and Exchange Commission (SEC) issues, audit problems, and a loss of confidence in the firm's financial reporting. The way to control access to financial periods in Dynamics GP is to close financial periods that are not being used. In some systems, closing a period is a time-consuming and irreversible process. This is not the case with Dynamics GP. Dynamics GP provides an easy way to close periods and reopen them for adjustments prior to finalizing financial statements. Typically, companies have the current period open for transaction entry. As transactions arrive for the next period, firms typically open the next period as well to allow entry of next period's transactions. This leaves two periods open at around month-end close but otherwise, only one period is open at a time. Once a period is complete it's important to close that fi scal period to prevent further transactions. In this recipe, we will look at the process to close fiscal periods in Dynamics GP. How to do it... To close a fiscal period in Dynamics GP: Select Administration from the Navigation Pane. Select Fiscal Periods under the Setup and Company sections on the Administration Area Page. Select the checkbox next to the period and module to close. Typically, the Financial series, which includes the General Ledger, is the last series to be closed: Deselecting the checkbox under a series reopens the period for subsequent adjusting of entries. How it works... Closing the period is an important monthly maintenance procedure. It is critical to preventing transactions from posting in the wrong period and it's an important step to ensuring the correctness of the financial statements. There's more... By default, the Fiscal Periods Setup window controls posting transactions to a period for all transactions in a module. Sometimes though, the module level is too high and companies need the ability to allow certain types of transactions to post while preventing others. Mass Close Closing fiscal periods based on series is easy. However, there are times when a company isn't ready to close an entire series, but does need to prevent the posting of certain transaction types. This can be accomplished using the Mass Close button on the Fiscal Periods Setup window. For example, if accounts payable needs an extra day to finish cutting checks but the company wants to prevent the entry of new payable vouchers in the period, the Mass Close button presents a list of all of the posting transaction types and allows a user to close the period, not for a series, but for one or more transaction types within that series. To demonstrate closing only a particular transaction type: In the Fiscal Periods Setup window click on Mass Close. Set the Series to Purchasing. Scroll to Payables Trx Entry and select the checkbox next to it: Click on Save to close the period for that transaction type. Notice that the entire series is marked as closed. There is no visual cue that only part of this module has been closed. Improving performance by adjusting AutoComplete settings Microsoft Dynamics GP provides AutoComplete functionality that remembers previous entries and displays them to users during subsequent data entry. Users can select the appropriate item without having to type the entire text. This is a great feature but the entries are stored per user and per fi eld. This means that each time the system saves a vendor number that has been keyed it's saved as one entry for that user. By default, Dynamics GP is set up to hold ten thousand entries, per user, for each field. As you can imagine, over a long period of time, and in organizations with heavy entry volume, the number of entries can build up slowing down AutoComplete performance significantly. Additionally, the number of choices presented to users can become unwieldy. For this recipe, we will look at a two-part solution to this problem. First we will set up a maintenance routine to clean out any entries not used over the last sixty days and then we will reduce the number of results being saved per field to a more manageable one thousand. How to do it... To get control over AutoComplete entries: Select Home from the Navigation Pane. Select User Preferences in the Shortcut Bar. Click on the AutoComplete button. Set Remove Unused Entries After to 60 days. Click on OK to finish. Change the Max. Number of Entries to Store per Field setting to 1,000: The new settings will take effect once the user logs out and back in How it works... Companies can help prevent system slowdowns by controlling the volume of entries that Dynamics GP uses for AutoComplete. This setting is a per user setting so each user needs to make the change for their own login. There's more... Administrators can change this setting for all users with an SQL command. Making the change for all users Some users obviously make greater use of the AutoComplete feature than others. Consequently, companies may not want to set all users to the same settings. If a firm wants to globally set the number of days to remove unused entries after and the maximum number of entries to store per field, they can do that by executing the following code in SQL Management Studio against the Dynamics database: Update Dynamics..sy01402Set syUSERDFSTR='TRUE-60-1000'Where syDefaultType=30 The middle line turns AutoComplete on with the TRUE setting, removes unused entries after 60 days, and sets the maximum number of entries to store per field to 1,000. Cleaning up Accounts Receivable with Paid Transaction Removal An important maintenance item that is often overlooked is Accounts Receivable Paid Transaction Removal. Perhaps it is overlooked because the name is somewhat misleading. Paid Transaction Removal only removes receivable transactions for companies that are not keeping receivables history. Most firms do keep history, and in that case Paid Transaction Removal moves Accounts Receivable transactions to history. This significantly reduces the number of transactions to be processed by Dynamics GP when running Accounts Receivable Aging and it can provide tremendous speed improvements to the aging process because the aging routine no longer has to work through the pile of completed paid transactions. Once Paid Transaction Removal is run companies can no longer unapply payments to a receivables invoice. Additionally, once a check is moved to history via Paid Transaction Removal, it can no longer be marked as Non-Sufficient Funds (NSF). With these restrictions it's commonly recommended that the Paid Transaction Removal process be run with a date in arrears. A misapplied invoice will typically be picked up within an invoicing cycle or two. Using a delay provides a buffer to allow for easy corrections of recent transactions while still providing the efficiency of removing completed transactions. Companies typically run Paid Transaction Removal monthly. The routine is set to remove paid transactions older than a set date and most firms set this date 30 to 90 days before the current date. I've seen firms use time frames of six months or longer when they have significant issues with misapplied payments. The key to an efficient AR aging process isn't in the interval used; it is in running the process regularly to control the number of open receivables that keeps the AR aging process efficient. In this recipe we'll look at how to process Paid Transaction Removal. Getting ready To ensure that history is being kept prior to running Paid Transaction Removal: In Dynamics GP select Sales from the Navigation Pane. Select Receivables under the Setup section on the Sales Area Page. Select the Print Historical Aged Trial Balance checkbox to ensure that transaction history is kept regardless of other customer history options. Click on OK to save: How to do it... To run Paid Transaction Removal in Dynamics GP: In Dynamics GP select Sales from the Navigation Pane. Select Paid Transaction Removal under the Routines section on the Sales Area Page. The process can be limited to certain customers and classes but most firms run the process for all of their customers. In the sample company change the Cut Off date next to NSF to 2/12/2017. This cutoff date applies to all of the items from NSF down to the next cutoff date. This includes: NSF Void Waived Paid Transactions Change the cutoff date next to Checks to 2/12/2017. Select the Print Register checkbox to print the transactions being moved to history: Click on Process. Choose to print the report to the screen and click on Yes to remove paid transactions. A report will print with the specifi c transactions moved to history by the customer. How it works... Regularly running Paid Transaction Removal reduces the workload on Dynamics GP when processing receivables aging. Reports based on open receivables transactions will also run faster. All of these improvements allow receivable employees to spend less time waiting for information and more time collecting open invoices. There's more... This process behaves differently for companies tracking receivables using the Balance Forward method. Balance Forward For companies using the Balance Forward balance type there are only two aging buckets— current and non-current. Most firms do not use the Balance Forward setting for receivables. For those fi rms that do use the Balance Forward method the Paid Sales Transaction Removal window is used to consolidate balances and move current transactions to the non-current bucket. To consolidate balances for Balance Forward customers: Select the Balance Forward Consolidation checkbox. Deselect the other checkboxes and click on Process:
Read more
  • 0
  • 0
  • 1567
Modal Close icon
Modal Close icon