Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Copper Super Contributor
Posts: 20
Registered: ‎10-27-2011
Accepted Solution

SData: SDataServiceOperationRequest.Create() produces OleDbException

Hi folks,

could someone tell me the possible reasons why i get the OleDbException with error code E_FAIL(0x80004005)? For the purpose of merging account we created a wrapper method as business rule called MergeAccounts(AccountID, EntityIDs)  on server A. On server B i want to merge accounts per SData/SDataServiceOperationRequest like that: (based on Mike LaSpina's example )

 

try
            {
                SDataServiceOperationRequest sreq = new SDataServiceOperationRequest(SDataServant)
                {
                    ResourceKind = SDataResourceKind.Accounts,
                    OperationName = OpName
                };

                sreq.Entry = new AtomEntry();

                sreq.Entry.SetSDataPayload(
                    new SDataPayload
                    {
                        ResourceName = "Account" + sreq.OperationName,
                        Namespace = "http://schemas.sage.com/dynamic/2007",
                        Values =
                        {
                            {"request",new SDataPayload
                                {
                                    Values =
                                    {
                                        {"AccountID", headerAccountId},
                                        {"EntityIDs", DuplicateIds}
                                    }
                                }
                            }
                        }
                    }
                );

                AtomEntry result = sreq.Create();
                var res = (SDataPayload)result.GetSDataPayload().Values["response"];
                retVal = res.Values["Result"].ToString().ToLower().Equals("true");
            }

 

sreq.Create() causes the OleDbException with the error code E_FAIL(0x80004005). According to RRaebiger's suggestion i've already grant the needed access right to the dir. C:\Windows\SysWOW64\config\systemprofile. But that it not the solution. Trying to see what is going on with SLXProfiler on server A is unsuccessful, i cant see anything there. Debugging our own business rule MergeAccounts(AccountID, EntityIDs) on server A comes to nothing, because the break point could not be reached.

 

Both servers are Windows 2008/R2/64 bits. SDataService works fine. I can confirm it, because of account updating is successfull before account merging.

 

I'm very glad to hear from your idee, what is going wrong in this case and thank a lot for your help in adv!

Copper Super Contributor
Posts: 20
Registered: ‎10-27-2011

Re: SData: SDataServiceOperationRequest.Create() produces OleDbException

Hi,

 

the problem i described is not solved yet, but i known now where the exception is really on the spot. The invoked business rule (OpName, mentioned above) causes the problem:

 

try
                {
                    string[] DuplicateIDs = EntityIDs.Split(new char[] { ',' });
                    Type mergeType = typeof(Sage.Entity.Interfaces.IAccount);
                    //bool success = false;

                    if (DuplicateIDs != null)
                    {
                        foreach (string sourceEntityId in DuplicateIDs)
                        {
                            MergeProvider sessionMergeProvider = null;
                            MergeArguments SessionMergeArguments = new MergeArguments();
                            SessionMergeArguments.SourceEntityId = sourceEntityId;
                            SessionMergeArguments.SourceEntityType = mergeType;
                            SessionMergeArguments.TargetEntityId = AccountID;
                            SessionMergeArguments.TargetEntityType = mergeType;
                            SessionMergeArguments.MergeProviderType = mergeType;

                            if (SessionMergeArguments.MergeProvider == null)
                            {
                                sessionMergeProvider = (MergeProvider)MergeArguments.GetMergeProvider(SessionMergeArguments);
                                sessionMergeProvider.RecordOverwrite = MergeOverwrite.targetWins;

                                IAccount myaccount = (IAccount)SessionMergeArguments.MergeProvider.Target.EntityData;

                                if (myaccount.MergeAccount(SessionMergeArguments.MergeProvider))
                                {
                                    using (ISession session = new Sage.Platform.Orm.SessionScopeWrapper(true))
                                    {
                                        string entityId = SessionMergeArguments.MergeProvider.Source.EntityId;
                                        IPersistentEntity duplicateAccount = Sage.Platform.EntityFactory.GetById(mergeType, entityId) as IPersistentEntity;
                                        duplicateAccount.Delete();
                                    }

                                    result = "Success";
                                }
                            }                            
                        }
                    }
                }

 

sessionMergeProvider = (MergeProvider)MergeArguments.GetMergeProvider(SessionMergeArguments) causes the exception with the error code E_FAIL(0x80004005). Looking after MergeRecords (thank a lot to apfingstl of your tip) you do it the same and it works, but my business not.

 

Maybe someone could tell me why, or where the problem is.

 

Thanks & Regards

Highlighted
Copper Super Contributor
Posts: 20
Registered: ‎10-27-2011

Re: SData: SDataServiceOperationRequest.Create() produces OleDbException

. . . now we've solved it with implementing a job with passing params. This required upgrade to slx 8.1! Calling the job per SData works fine.