Preface:
One and a half months after the official release of V3.5 has passed, and the framework has grown along with the "Autumn garden-QBlog blog" and has never stopped !!!
The main growth of the framework is in the CYQ. Xml namespace, which has many details and no diary records. Therefore, the content of this article is relatively small.
The following describes the updates in the logging section in V4.0.
Update history of this version:
1: added multi-database processing for Case statements
2: MAction: Open the DalType attribute and allow to obtain the Database Type of the current operation. 3: Pager: solve the problem that the order by parameter is too long in the paging storage process. The parameter is extended. 4: Modify the Pager Access Database page, use the top mode for three times. Page 5: Modify the conversion of the bit type to "1" to true6: Modify the custom TABLE statement to query data without data, and return the table architecture 7: xml class added RSS function 8: Proc corrected switching from SQL to bug9 In the stored procedure: Other, CYQ optimized along with the growth of the autumn garden. several Classes in the Xml namespace.
The upgrade records are described below
I. multi-database processing of Case statements
During the development of the autumn garden, I encountered another SQL statement that used Case statements. Therefore, after a long time of thinking, I added multi-statement processing for the Case syntax, which is the same as the previous statement, enter the keyword as [# keyword.
Sample Code: Excerpted from the autumn Garden
String orderByKey = string. format ("{0} + [# CASE] [# WHEN] languageID = {1} [# THEN] {2} [# ELSE] 0 [# END]", key, (int) Language. lanKey, (isHits? 1000: 100 ));
Note:
The same statements can be run in Access, Mssql, and Oracle. How to resolve the statements is a matter inside the framework.
To change to a normal statement, replace.
Ii. MAction: Open the DalType attribute and allow you to obtain the Database Type of the current operation.
The added open attributes allow you to use branch statements in addition to keyword parsing when using multi-database support.
Sample Code:
Public void Demo ()
{
Using (MAction action = new MAction (TableNames. Blog_Content ))
{
Switch (action. DalType)
{
Case CYQ. Data. DAL. DalType. Access:
// Do access something
Break;
Case CYQ. Data. DAL. DalType. Oracle:
// Do Oracle something
Break;
Case CYQ. Data. DAL. DalType. SQL:
// Do SQL something
Break;
}
}
}}
}
3. Pager: solves the problem of long order by parameter and longer parameter in paging storage.
Cause description:
In the paging storage process of mssql provided by the framework, there is an original statement: cast (@ OrderBy as nvarchar)
When the order by statement conditions are very complex and long, the length is not enough [it seems to be 50 by default] will cause problems. Therefore, the internal length of the Framework is changed to 400 length as follows: cast (@ OrderBy as nvarchar (400 ))
If yes, pay attention to it.
4. Modify the Pager Access Database page and use the top three pages.
In the previous top max mode of Access, when a user-defined table is used and the conditions are complex, the paging results are slightly different.
Therefore, two paging statements are used for Internal correction: one is not in paging, and the other is top three times. If there is no data comparison, not in is used, and it continues for a period of time in the autumn garden.
A few days ago, I found that the paging speed of the autumn garden was a little slow, so I switched to the top query page three times, and the speed went up.
5. Modify the bit type to "1" to true.
For the bit type, sometimes the value is 1 or 0. This version is compatible with the numeric type and is automatically converted to true or false.
6. When a custom TABLE statement is modified and no data is queried, the table architecture is also returned.
The source of this requirement comes from the management background of the autumn garden. Because the background uses the traditional webform development method and is displayed on the list page, when there is no data, no header is found.
Therefore, when the query fails or there is no data, the returned MDataTable is automatically filled to make the structure complete.
7. Add the RSS function to the Xml class.
The RSS class in the data framework is a little more code than the previous article I published: Practice-lines to complete the concise Rss output class, because it is used in combination with the MDataTable inside the framework.
Sample Code: Excerpted from the autumn garden-complete RSS processing logic
Public string GetRss (int cacheTime)
{
String cacheKey = "rss _" + DomainID;
Object outXml = Cache. Get (cacheKey );
If (outXml! = Null)
{
Return outXml. ToString ();
}
Else
{
Rss rss = new Rss ();
MutilLanguage seoDoc = new MutilLanguage (MapPath (Config. GlobalSkinPath + IDPage. SiteTitle), true, false );
If (DomainID = 0) // system Rss
{
Rss. Set (seoDoc. Get (IDLang. sitetitle) + "-" + seoDoc. Get (IDLang. powerby), Config. HttpHost, seoDoc. Get (IDLang. description ));
}
Else // user Rss
{
String title = GetLangText (IsUserLang, DomainUser. Get <string> (Users. SpaceName ));
If (string. IsNullOrEmpty (title ))
{
Title = GetLangText (IsUserLang, DomainUser. Get <string> (Users. UserName ));
}
Rss. set (title + "-" + seoDoc. get (IDLang. sitename), Config. httpHost + "/" + Domain, DomainUser. get <string> (Users. spaceIntro ));
}
Rss. setImg (Config. httpHost + Config. systemTechSkinPath + "images/logo _" + seoDoc. lanKey. toString (). substring (3) + ". jpg ", seoDoc. get (IDLang. sitetitle) + "Logo", Config. httpHost );
String SQL = CustomSQL. Rss + (DomainID> 0? "And UserID =" + DomainID :"");
Using (MProc proc = new MProc (SQL ))
{
Rss. LoadData (proc. ExeMDataTable ());
Rss. SetMap (RssItemName. Title, null, Content. Title );
Rss. SetMap (RssItemName. Link, Config. HttpHost + "/{0}/article-detail-{1}", Users. UserName, Content. ID );
Rss. SetMap (RssItemName. Author, null, Users. NickName );
Rss. SetMap (RssItemName. PubDate, null, Content. CreateTime );
Rss. SetMap (RssItemName. Description, null, Content. Body );
}
String xml = rss. OutXml;
Cache. Add (cacheKey, xml, null, cacheTime );
Return xml;
}
}
8: Proc fixed the bug of switching from SQL to Stored Procedure
When MProc is used and the stored procedure is executed, an error is prompted when mproc. ResetProc ("SQL statement") is switched to SQL Execution.
The current version fixes this small bug.
9. Overall framework Optimization
During the development of yiyuan in autumn, after constant reconstruction and optimization, more details will be modified within the framework to adapt to more situations, but the previous functions will not be affected.
Because there are not many people using CYQ. Xml, there are relatively few log records.
However, in the overall application of the autumn Garden, the classes in the CYQ. Xml namespace are core application members. I hope that the big guy will pay more attention to this application.
10. Download The V4.0 framework
: Download center-autumn Garden
Previous Article: QBlog V2.5 released adds Health channels [multi-language, multi-user, multi-database, directory-level URL support]
In the future, I will write one or two sample CYQ. Xml application articles.