AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: За рубежом > DAX in English
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 17.06.2011, 13:13   #1  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
how to monitor changes on tables automatically
Hello,


I like to do the following:

whenever a field is created on a table (or deleted or some properties changed), i will read the userId of the current user and the company he do the changes in.

So far i tried to work with the class SysDictField\new and added a Info() but in this class i can't get the tableId and fieldId of the changed object.
Same problem on class ReleaseUpdateDB and SysDictTable.
(The System runs through these classes whenever the described action is performed)

My next Idea was to get the information out of table UtilIdElements but this Table is not in the SQL Database so i can't set a trigger to it to monitor changes.

The MorphX VCS can't be used here because i don't want to check in / out the objects manually.

So anyone has an idea how to manage that?


And I'm sorry for the bad english :S

Kind Regards
Robin
Старый 17.06.2011, 14:35   #2  
gl00mie is offline
gl00mie
Участник
MCBMSS
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,684 / 5798 (201) ++++++++++
Регистрация: 28.11.2005
Адрес: Москва
Записей в блоге: 3
Well... you can set a trigger on the SqlDictionary table insert/delete to get an alert when a new field (or table/view!) is kinda created "physically" in the database (or when a table/view/field is dropped). In a database trigger you'll have to somehow connect to an AOS, enumerate user session objects and find an information about a user session that is currently using the database session in which a trigger is running (by the session SPID or something). Then you can find a record with this user session id in the SysClientSessions table and find out the userId.
Note that this way you can't monitor changes that don't alter the database scheme, e.g. changes in a field's label or EDT.

Последний раз редактировалось gl00mie; 17.06.2011 в 14:38.
Старый 17.06.2011, 14:59   #3  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
At first thank you for the answer.
The solution may work well no question but in my case i have to monitor property changes (label, mandatory, EDT) also.

Do you have any other idea or approach how to do that ?

Some more details:

i want to monitor whenever there are changes for a protokoll. Normally we comment our changes e.g. on classes or form methods. But on tablefields (and EDT's etc) it's difficult to insert a comment.
So for that i want to intervene in the insert/update/delete process so i get automatically a protokoll of the changes without doing anything manually expect the changes themselfs
__________________
Kind Regards
Robin

Последний раз редактировалось Dark Smile; 17.06.2011 в 15:05.
Старый 17.06.2011, 15:08   #4  
gl00mie is offline
gl00mie
Участник
MCBMSS
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,684 / 5798 (201) ++++++++++
Регистрация: 28.11.2005
Адрес: Москва
Записей в блоге: 3
I hardly think you can setup any kind of a trigger to monitor such changes. You can periodically copy current application to the old directory, then query for UtilElements for table fields that where changed since the last copying and compare such fields with the ones in the old layer to find out which properties have been changed... Or you can use a VCS.
Старый 17.06.2011, 15:15   #5  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
To copy the application directory is no solution because the size of it is more than 1 GB.

The MorphX VCS can't be used here (or better: i don't want to) because i have to check in / out the objects manually and my goal is to get that done automatically in the background
__________________
Kind Regards
Robin
Старый 17.06.2011, 16:02   #6  
S.Kuskov is offline
S.Kuskov
Участник
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
 
3,435 / 1775 (66) ++++++++
Регистрация: 28.04.2007
Адрес: Калуга
Цитата:
Сообщение от Dark Smile Посмотреть сообщение
To copy the application directory is no solution because the size of it is more than 1 GB.
Copy can be only one layer, which is being developed...
But it is no solution too because then need to restart AOS.

Maybe try catch needed events on GUI in property panel?
Старый 17.06.2011, 16:09   #7  
gl00mie is offline
gl00mie
Участник
MCBMSS
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,684 / 5798 (201) ++++++++++
Регистрация: 28.11.2005
Адрес: Москва
Записей в блоге: 3
Цитата:
Сообщение от Dark Smile Посмотреть сообщение
To copy the application directory is no solution because the size of it is more than 1 GB.
So what? You can run this once per day: stop AOS, copy current application files to the old subdirectory, start AOS, run a report or something that will scan for changes since the last run (you can automate this ). As to triggers that would allow you to be alerted at the same moment when a changed/created field is saved - there are just no such hooks in the kernel, as far as I know.
Старый 17.06.2011, 16:26   #8  
S.Kuskov is offline
S.Kuskov
Участник
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
 
3,435 / 1775 (66) ++++++++
Регистрация: 28.04.2007
Адрес: Калуга
Then it is easier create batch job witch makes check in / out the objects to VCS
Старый 18.06.2011, 15:02   #9  
Alex_KD is offline
Alex_KD
Участник
AxAssist
MCBMSS
Соотечественники
 
522 / 362 (14) ++++++
Регистрация: 06.07.2006
Адрес: Melbourne, Down Under
Цитата:
My next Idea was to get the information out of table UtilIdElements but this Table is not in the SQL Database so i can't set a trigger to it to monitor changes.
Try to stick with this one.
You should be able to get all AOT elements that were modified.

Please find the sample xpp code, which returns all elements that were modified in the last 5 minute (300 second), below:
X++:
 UtilIdElements          utilIdElements;
         utcdatetime        datetime;
         date   modifyDate;
         ;
      
          begin = WinApi::getTickCount();
          modifyDate = systemdateget();

          datetime = DateTimeUtil::newDateTime(modifyDate,  ((timenow() - 300) > 0)?(timenow() - 300):(0));
    
          while select name, id, recordType from utilIdElements
          where  (utilIdElements.createdDateTime > datetime) ||
               (utilIdElements.modifiedDateTime > datetime)
           {
                switch(utilIdElements.recordType)
                 {
                       ......
                 }
           }
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0
За это сообщение автора поблагодарили: Dark Smile (1).
Старый 18.06.2011, 15:29   #10  
Logger is offline
Logger
Участник
Лучший по профессии 2015
Лучший по профессии 2014
 
3,929 / 3227 (115) ++++++++++
Регистрация: 12.10.2004
Адрес: Москва
Записей в блоге: 2
Цитата:
Сообщение от Alex_KD Посмотреть сообщение
Try to stick with this one.
You should be able to get all AOT elements that were modified.

Please find the sample xpp code, which returns all elements that were modified in the last 5 minute (300 second), below:
X++:
 UtilIdElements          utilIdElements;
         utcdatetime        datetime;
         date   modifyDate;
         ;
      
          begin = WinApi::getTickCount();
          modifyDate = systemdateget();

          datetime = DateTimeUtil::newDateTime(modifyDate,  ((timenow() - 300) > 0)?(timenow() - 300):(0));
    
          while select name, id, recordType from utilIdElements
          where  (utilIdElements.createdDateTime > datetime) ||
               (utilIdElements.modifiedDateTime > datetime)
           {
                switch(utilIdElements.recordType)
                 {
                       ......
                 }
           }

It's correct only for build 1500.4570
see
kb2472202 The ChangedDate field and the ChangedTime field on a class are not updated when you change the class in Microsoft Dynamics AX 2009 SP1
За это сообщение автора поблагодарили: Dark Smile (1).
Старый 18.06.2011, 19:40   #11  
Alex_KD is offline
Alex_KD
Участник
AxAssist
MCBMSS
Соотечественники
 
522 / 362 (14) ++++++
Регистрация: 06.07.2006
Адрес: Melbourne, Down Under
Цитата:
Сообщение от Logger Посмотреть сообщение
It's correct only for build 1500.4570
see
kb2472202 The ChangedDate field and the ChangedTime field on a class are not updated when you change the class in Microsoft Dynamics AX 2009 SP1
Thanks for pointing this out.
I think this piece of code is enough to get idea....well it might require some amendments as I just copied it from the old xpo.
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0
Старый 20.06.2011, 11:47   #12  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
Thanks for this code, i will try to stick with this and will give feedback
__________________
Kind Regards
Robin
Старый 21.06.2011, 17:15   #13  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
Hey guys, thanks for the quick help to all.

My solution is a Class, that is called in SysDictField every time a change occures and reads the Data out of table UtilIdElements such as in the hint of Alex_KD.
__________________
Kind Regards
Robin
Старый 30.06.2011, 13:02   #14  
Dark Smile is offline
Dark Smile
Junior AX Developer
 
16 / 10 (1) +
Регистрация: 17.06.2011
I got a new problem:

I created a class that works fine with the monitoring but now my problem is the point to call this class.
I called the class from the SysDictField Class in the past but there is the problematic, that i haven't any info about the created elements in this stack.
So i have to select the records created in the last X seconds from Table UtilIdElements. But what if the user created new fields, forgets to save and then the timespan is over and i don't get the element if you understand what i'm trying to explain.

My new idea is to capture the save-Button Event. But i could not get into the toolbar, do you have any ideas how to break in this case ?

Thanks
__________________
Kind Regards
Robin
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axdaily: SQL temporary tables in AX 2012 Blog bot DAX Blogs 25 06.05.2011 10:18
sumitsaxfactor: AOSAuthorization property on tables Blog bot DAX Blogs 0 06.05.2011 02:19
Prabhats: DAX 2009: Temporary Tables in Enterprise Portal Blog bot DAX Blogs 0 27.04.2011 11:11
axhelper: How to Use Temporary tables in reports Blog bot DAX Blogs 0 29.09.2010 18:05
Microsoft Dynamics AX AIF: Sending Outbound Documents Automatically Blog bot DAX Blogs 0 31.03.2008 11:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 04:27.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.