Posted on 18/10/2016 13:44:23
Hi Dmitriy,
Here is the method code:
private void SyncObject(object sender, EventArgs e)
{
bool bResult;
string sObject = "object";
if (base.Ribbon.DataContext.DataSource is User)
{
var source = (User)Ribbon.DataContext.DataSource;
#if DEBUG
System.Diagnostics.Debug.WriteLine("(AddIn object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
source = User.GetUserByID(source.ID);
System.Diagnostics.Debug.WriteLine("(User object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
#endif
source = User.GetUserBySql("select * from accessuser au where au.AccessUserID = " + source.ID);
#if DEBUG
System.Diagnostics.Debug.WriteLine("(UserSql object) fields without value = {0}", source.CustomFieldValues.Count(x => x.Value == null));
#endif
bResult = source.SynchronizeUsingLiveIntegration();
sObject = "User";
}
else if (base.Ribbon.DataContext.DataSource is Group)
{
var source = (Group)base.Ribbon.DataContext.DataSource;
bResult = source.SynchronizeUsingLiveIntegration();
sObject = "Group";
}
else
return;
HttpContext.Current.Session[SessionKey] = string.Format("The {0} has {1} sync with the ERP!", sObject,
bResult ? "successfully" : "unsuccessfully");
}