Skip to content

Instantly share code, notes, and snippets.

View smarenich's full-sized avatar

Sergey Marenich smarenich

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Web;
<?xml version="1.0" encoding="UTF-8"?>
<sm:SiteMap xmlns:sm="http://acumatica.com/mobilesitemap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sm:Screen Id="GL301000" Type="SimpleScreen" DisplayName="Journal Transactions" Visible="true" Icon="system://NewsPaper" IsDefaultFavorite="true">
<sm:Container Name="BatchSummary" FieldsToShow="3">
<sm:Attachments Disabled="true" />
<sm:Field Name="BatchNumber" />
<sm:Field Name="TransactionDate" />
<sm:Field Name="Description" />
@smarenich
smarenich / Logger.cs
Last active September 17, 2015 12:00
public static class Logger
{
private const uint HRFileLocked = 0x80070020;
private const uint HRPortionOfFileLocked = 0x80070021;
[ThreadStatic]
private static bool IsRecursive;
public static void Initialise()
{
@smarenich
smarenich / TableValuedSQL.sql
Last active September 18, 2015 16:25
Table-Valued Function SQL
if exists(select * from sys.objects where object_id = object_id('sp_GetBalanceSheet'))
drop function sp_GetBalanceSheet
go
CREATE FUNCTION dbo.sp_GetBalanceSheet(@period char(6))
RETURNS @statistics TABLE (
CompanyID int not null default(0),
Code int not null Identity(1,1),
BranchID int not null,
Description nvarchar(255) not null,
Balance decimal(19,4) not Null
@smarenich
smarenich / TableValuedDAC.cs
Created September 18, 2015 16:25
Table-Valued Function DAC
namespace PX.Objects.GL
{
using System;
using PX.Data;
[System.SerializableAttribute()]
public class StatisticsView : PX.Data.IBqlTable
{
#region Code
public abstract class code : PX.Data.IBqlField
public class YearGroupMaint : PXGraph<YearGroupMaint>
{
public PXFilter<YearFilter> Filter;
//[PXVirtualDAC]
public PXSelect<VirtualComparasion> Comparasions;
public PXSelect<YearGroup, Where<YearGroup.year, Equal<Required<YearGroup.year>>, Or<YearGroup.year, Equal<Required<YearGroup.year>>>>> YearGroups;
public PXCancel<YearFilter> Cancel;
public IEnumerable comparasions()
public class SOOrderExtension : PXCacheExtension<PX.Objects.SO.SOOrder>
{
#region CustomerLocationID
public abstract class customerLocationID : PX.Data.IBqlField
{
}
[PXMergeAttributesAttribute(Method = MergeMethod.Merge)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.Location.locationCD),
typeof(PX.Objects.CR.Location.descr),
create table #space
(
tn varchar(128),
rows varchar(128),
reserved varchar(128),
data varchar(128),
indexp varchar(128),
unused varchar(128)
)
SELECT
db_name(s2.dbid),
( SELECT TOP 1 SUBSTRING(s2.text, r.statement_start_offset / 2,
( (CASE WHEN r.statement_end_offset = -1 THEN (LEN(CONVERT(nvarchar(max),s2.text)) * 2)
ELSE r.statement_end_offset END) - r.statement_start_offset) / 2) ) AS sql_statement,
r.logical_reads
FROM
sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s2
SELECT top 30 total_worker_time/execution_count AS AvgCPU
, total_worker_time AS TotalCPU
, total_elapsed_time/execution_count AS AvgDuration
, total_elapsed_time AS TotalDuration
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads
, (total_logical_reads+total_physical_reads) AS TotalReads
, execution_count
, SUBSTRING(st.TEXT, (qs.statement_start_offset/2)+1
, ((CASE qs.statement_end_offset WHEN -1 THEN datalength(st.TEXT)
ELSE qs.statement_end_offset