private bool CreateRelationshipsSync(string scenario, string expressionProfileResourceId, string documentResourceId) { if (string.IsNullOrEmpty(expressionProfileResourceId) || string.IsNullOrEmpty(documentResourceId)) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateRelationships error: expression profile Id or document resource Id is empty."); return(false); } MsnServiceState serviceState = new MsnServiceState(scenario, "CreateRelationships", false); StorageService storageService = (StorageService)CreateService(MsnServiceType.Storage, serviceState); CreateRelationshipsRequestType createRelationshipRequest = new CreateRelationshipsRequestType(); Relationship relationship = new Relationship(); relationship.RelationshipName = "ProfilePhoto"; relationship.SourceType = "SubProfile"; //From SubProfile relationship.TargetType = "Photo"; //To Photo relationship.SourceID = expressionProfileResourceId; //From Expression profile relationship.TargetID = documentResourceId; //To Document createRelationshipRequest.relationships = new Relationship[] { relationship }; try { ChangeCacheKeyAndPreferredHostForSpecifiedMethod(storageService, MsnServiceType.Storage, serviceState, createRelationshipRequest); storageService.CreateRelationships(createRelationshipRequest); } catch (Exception ex) { OnServiceOperationFailed(storageService, new ServiceOperationFailedEventArgs("CreateRelationships", ex)); Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateRelationships error: " + ex.Message, GetType().Name); return(false); } return(true); }
private bool CreateRelationshipsSync(string scenario, string expressionProfileResourceId, string documentResourceId) { if (string.IsNullOrEmpty(expressionProfileResourceId) || string.IsNullOrEmpty(documentResourceId)) { Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateRelationships error: expression profile Id or document resource Id is empty."); return false; } MsnServiceState serviceState = new MsnServiceState(scenario, "CreateRelationships", false); StorageService storageService = (StorageService)CreateService(MsnServiceType.Storage, serviceState); CreateRelationshipsRequestType createRelationshipRequest = new CreateRelationshipsRequestType(); Relationship relationship = new Relationship(); relationship.RelationshipName = "ProfilePhoto"; relationship.SourceType = "SubProfile"; //From SubProfile relationship.TargetType = "Photo"; //To Photo relationship.SourceID = expressionProfileResourceId; //From Expression profile relationship.TargetID = documentResourceId; //To Document createRelationshipRequest.relationships = new Relationship[] { relationship }; try { ChangeCacheKeyAndPreferredHostForSpecifiedMethod(storageService, MsnServiceType.Storage, serviceState, createRelationshipRequest); storageService.CreateRelationships(createRelationshipRequest); } catch (Exception ex) { OnServiceOperationFailed(storageService, new ServiceOperationFailedEventArgs("CreateRelationships", ex)); Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "CreateRelationships error: " + ex.Message, GetType().Name); return false; } return true; }