Всем привет.
Обнаружилось непонятное поведение представления "Мои действия" со Сроком "Сегодня": если вкратце - выводятся действия с прошедшим сроком (вчера, полгода назад и т.д.)
SQL Profiler показывает следующий запрос (exec sp_executesql ',,,' и параметры с собаками типа @ScheduledEnd0='2014-05-12 07:29:35' заменил для удобочитаемости):
Код:
select
DISTINCT top 251 "activitypointer0".CreatedOn as "createdon"
, "activitypointer0".ActivityTypeCode as "activitytypecode"
, "activitypointer0".RegardingObjectId as "regardingobjectid"
, "activitypointer0".Subject as "subject"
, "activitypointer0".OwnerId as "ownerid"
, "activitypointer0".ScheduledEnd as "scheduledend"
, "activitypointer0".ActivityId as "activityid"
, "activitypointer0".InstanceTypeCode as "instancetypecode"
, "activitypointer0".RegardingObjectIdYomiName as "regardingobjectidyominame"
, "activitypointer0".RegardingObjectTypeCode as "regardingobjecttypecode"
, "activitypointer0".RegardingObjectIdName as "regardingobjectidname"
, "activitypointer0".OwnerIdName as "owneridname"
, "activitypointer0".OwnerIdYomiName as "owneridyominame"
, "activitypointer0".OwnerIdType as "owneridtype"
, "a_18319c3475a64263a23c3195b0b28557".New_sourcecampaignid as "a_18319c3475a64263a23c3195b0b28557.new_sourcecampaignid"
, "a_18319c3475a64263a23c3195b0b28557".New_regionid as "a_18319c3475a64263a23c3195b0b28557.new_regionid"
, "a_18319c3475a64263a23c3195b0b28557".New_cityid as "a_18319c3475a64263a23c3195b0b28557.new_cityid"
, "a_18319c3475a64263a23c3195b0b28557".New_sourcecampaignidName as "a_18319c3475a64263a23c3195b0b28557.new_sourcecampaignid_new_sourcecampaignidname"
, "a_18319c3475a64263a23c3195b0b28557".New_regionidName as "a_18319c3475a64263a23c3195b0b28557.new_regionid_new_regionidname"
, "a_18319c3475a64263a23c3195b0b28557".New_cityidName as "a_18319c3475a64263a23c3195b0b28557.new_cityid_new_cityidname"
from
ActivityPointer as "activitypointer0" (NOLOCK) join ActivityParty as "a_6ff0bed3c2564990a5f59856d8ac3d24" (NOLOCK) on ("activitypointer0".ActivityId = "a_6ff0bed3c2564990a5f59856d8ac3d24".ActivityId
and (("a_6ff0bed3c2564990a5f59856d8ac3d24".PartyId = 'B9A944AE-7CC6-E111-A0BE-001A6433B300')))
left outer join Contact as "a_18319c3475a64263a23c3195b0b28557" (NOLOCK) on ("activitypointer0".RegardingObjectId = "a_18319c3475a64263a23c3195b0b28557".ContactId)
where
((((("activitypointer0".StateCode in (0, 3)) and ("activitypointer0".ActivityTypeCode != 4406 or "activitypointer0".ActivityTypeCode is null))) and
(("activitypointer0".OwnerId = 'B9A944AE-7CC6-E111-A0BE-001A6433B300')) and
(("activitypointer0".ScheduledEnd < '2014-05-12 06:41:15' or "activitypointer0".ScheduledEnd >= '2014-05-11 20:00:00' and "activitypointer0".ScheduledEnd < '2014-05-12 20:00:00' ))))
order by
"activitypointer0".CreatedOn desc
, "activitypointer0".ActivityId asc
в SavedQuery (в БД):
Код:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="activitypointer">
<order attribute="createdon" descending="true" />
<filter type="and">
<condition attribute="statecode" operator="in">
<value>0</value>
<value>3</value>
</condition>
<condition attribute="activitytypecode" operator="ne" value="4406" />
</filter>
<link-entity name="activityparty" from="activityid" to="activityid" alias="a_6ff0bed3c2564990a5f59856d8ac3d24">
<filter type="and">
<condition attribute="partyid" operator="eq-userid" />
</filter>
</link-entity>
<attribute name="createdon" />
<attribute name="activitytypecode" />
<attribute name="regardingobjectid" />
<attribute name="subject" />
<attribute name="ownerid" />
<attribute name="scheduledend" />
<link-entity alias="a_18319c3475a64263a23c3195b0b28557" name="contact" from="contactid" to="regardingobjectid" link-type="outer" visible="false">
<attribute name="new_sourcecampaignid" />
<attribute name="new_regionid" />
<attribute name="new_cityid" />
</link-entity>
<attribute name="activityid" />
<filter type="and">
<condition attribute="ownerid" operator="eq-userid" />
</filter>
</entity>
</fetch>
Фидлер показывает самое интересное:
grid->parameters->dateFilter = Today (ok)
fetchXmlForFilters - такой же как в SavedQuery (предыдущий блок кода)
isFetchXmlNotFinal = FALSE (!)
effectiveFetchXml:
Код:
<fetch distinct="true" no-lock="false" mapping="logical" page="1" count="250" returntotalrecordcount="true">
<entity name="activitypointer">
<attribute name="createdon" />
<attribute name="activitytypecode" />
<attribute name="regardingobjectid" />
<attribute name="subject" />
<attribute name="ownerid" />
<attribute name="scheduledend" />
<attribute name="activityid" />
<attribute name="createdon" />
<attribute name="regardingobjectid" />
<attribute name="subject" />
<attribute name="ownerid" />
<attribute name="scheduledend" />
<attribute name="instancetypecode" />
<filter type="and">
<filter type="and">
<condition attribute="statecode" operator="in">
<value>0</value>
<value>3</value>
</condition>
<condition attribute="activitytypecode" operator="ne" value="4406" />
</filter>
<filter type="and">
<condition attribute="ownerid" operator="eq-userid" />
</filter>
<filter type="or">
<condition attribute="scheduledend" operator="lt" value="2014-05-12T11:05:35+04:00" />
<condition attribute="scheduledend" operator="tomorrow" />
<condition attribute="scheduledend" operator="today" />
</filter>
<filter type="or">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="statecode" operator="eq" value="3" />
</filter>
</filter>
<order attribute="createdon" descending="true" />
<link-entity name="activityparty" to="activityid" from="activityid" link-type="inner" alias="a_6ff0bed3c2564990a5f59856d8ac3d24">
<filter type="and">
<condition attribute="partyid" operator="eq-userid" />
</filter>
</link-entity>
<link-entity name="contact" to="regardingobjectid" from="contactid" link-type="outer" alias="a_18319c3475a64263a23c3195b0b28557">
<attribute name="new_sourcecampaignid" />
<attribute name="new_regionid" />
<attribute name="new_cityid" />
</link-entity>
</entity>
</fetch>
Т.е. где то в СРМе кто-то нахимичил с condition-ом по scheduledEnd. что он выводит такой вот бред.
в какую сторону копать и как с этими кондишенами вообще работать (наверное, в первую очередь интересуют пользовательские\дизайнерские настройки\визарды, но не обязательно)?