CRM 2011,日期在插件和DST [英] CRM 2011, Date in plugin and DST

查看:129
本文介绍了CRM 2011,日期在插件和DST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我通过自己解决,但尚未需要一些确认的话无论我是对我的想法100%正确的,只是因为没有我找到证明自己正确的任何文件。



我的服务器是在DST的时间目前,CRM UI也带图片的1小时可达然后储存在​​DB数据。这很好。



当我计算和存储日期插件,我的插件更新操作结束后,CRM平台扣除从数据1小时,我得救了。我已阅读,当我们通过SDK相关的日期和时间的一些操作,CRM店,因为它是日期时间。难道是当时间是在DST,平台还可以获得包括通过再扣除1小时的情况下?



作为决议,我评论了我的扣除1的线小时,让CRM现在就做。



我是正确的我的理解还是会明显的,如果有人可以提供任何文档的URL。


解决方案

任何你在SDK工作时间,DateTime是否被检索和存储UTC。 CRM的网络平台将UTC时间转换到用户的时间。你不应该需要做的任何时间转换,只用UTC。



让我们假设你的本地时间为UTC -1(DST与UTC起不遵守它)。因此,如果UTC时间为14:00,当地的时间是13:00。
让我们假设在要填充的是当前时间,明天实体日期属性你的插件。如果你的代码看起来是这样的:

  entity.new_SomeDate = DateTime.Now.AddDays(1); 
service.Update(实体);



假设DateTime.Now是13:00,它会存储在13:00数据库(如如果它是UTC)。然后,当你去看看从CRM网站的时间价值,因为你是UTC - 1,它会显示12:00,即使你想要13:00



  entity.new_SomeDate = DateTime.UtcNow.AddDays(1):如果你的代码看起来像这样

现在
service.Update(实体);



假设DateTime.Now是13:00,它会存储在14:00日期时间以来数据库.UtcNow为14:00。然后,当你去看看从CRM网站的时间价值,因为你是UTC - 1,它会显示13:00,因为它会采取UTC值 - 1


$如果你的代码看起来像本b $ b

现在:

  entity.new_SomeDate = entity.new_UserEnteredDateFromCrm.AddDays(1) ; 
service.Update(实体);



new_UserEnteredDateFromCrm将已经被从用户的时区转换为UTC,它会作为工作预计。



这让你宁愿保存为日期很困难,虽然DateTime是否(生日的人?),你可能会通过多一点思考的深度。


I have one issue which I resolved by myself but yet need some confirming words whether I am 100% correct on my thought, just because there is not any documentation I found to prove myself correct.

My server is in DST time currently, CRM UI is also showing 1 hour up then data stored in db. that's fine.

When I calculate and store date with plugin, after my plugin update operation finishes, CRM platform deducts 1 hour from data I saved. I have read that when we do some operation via SDK related date time, CRM stores date time as it is. is it the case that when time is in DST, platform also get involves to deduct 1 hour by then ?

As a resolution, I have commented out my line of deducting 1 hour and letting CRM to do it now.

Am I correct on my understanding or it would be appreciable if some one can provide any documentation URL.

解决方案

Any time you're working in the SDK, DateTimes are retrieved and stored as UTC. The CRM web platform will convert the UTC time into the user's time. You shouldn't need to be doing any Conversions of time, just using UTC.

Let's assume your local time is UTC -1 (with DST since UTC doesn't observe it). So if UTC is 14:00, your local time is 13:00. Let's also assume your plugin in going to populate a date attribute on the entity that is for the current time, tomorrow. If your code looks like this:

entity.new_SomeDate = DateTime.Now.AddDays(1);
service.Update(entity);

Assuming DateTime.Now is 13:00, it'll store 13:00 in the database (as if it was UTC). Then when you go to look at the time value from the CRM website, since you're UTC - 1 it'll display 12:00, even though you wanted 13:00.

Now if your code looks like this:

entity.new_SomeDate = DateTime.UtcNow.AddDays(1);
service.Update(entity);

Assuming DateTime.Now is 13:00, it'll store 14:00 in the database since DateTime.UtcNow is 14:00. Then when you go to look at the time value from the CRM website, since you're UTC - 1 it'll display 13:00, since it'll take the UTC value - 1.

Now if your code looks like this:

entity.new_SomeDate = entity.new_UserEnteredDateFromCrm.AddDays(1);
service.Update(entity);

The new_UserEnteredDateFromCrm will already have been converted from the users' Time Zone to UTC and it'll work as expected.

This makes DateTimes that you would prefer to store as Dates very difficult though (birthdays anyone?) and you may have to think through it a little more in depth.

这篇关于CRM 2011,日期在插件和DST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆