예제 #1
0
 public static LocalProcess GetLocalProcess(Guid localProcessId)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         LocalProcess localProcess = QueryUtil.First <LocalProcess>((from p in entities.LocalProcess where p.LocalProcessId == localProcessId select p));
         entities.Detach(localProcess);
         return(localProcess);
     }
 }
예제 #2
0
 public static ObjectType GetObjectType(Guid objectTypeId)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         ObjectType objectType = QueryUtil.First <ObjectType>((from o in entities.ObjectType where o.ObjectTypeId == objectTypeId select o));
         entities.Detach(objectType);
         return(objectType);
     }
 }
예제 #3
0
 public static Participant GetParticipant(Guid participantId)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         Participant participant = QueryUtil.First <Participant>(from p in entities.Participant where p.ParticipantId == participantId select p);
         entities.Detach(participant);
         return(participant);
     }
 }
예제 #4
0
 public static Bubble GetBubble(Guid bubbleId)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         Bubble bubble = QueryUtil.First <Bubble>((from b in entities.Bubble where b.BubbleId == bubbleId select b));
         entities.Detach(bubble);
         return(bubble);
     }
 }
예제 #5
0
 public static void UpdateObject(CloudObject cloudObject)
 {
     using (DaemonEntities entities = new DaemonEntities())
     {
         try
         {
             entities.Attach(cloudObject);
             ObjectType  objectType  = QueryUtil.First <ObjectType>(from o in entities.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.ObjectType);
             Participant participant = QueryUtil.First <Participant>(from o in entities.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.Participant);
             cloudObject.Modified = DateTime.Now;
             entities.SaveChanges();
         }
         finally
         {
             entities.Detach(cloudObject);
         }
     }
 }
예제 #6
0
        public static Participant AttachParticipantProfileToOpenIdIdentity(int userId, string openIdUrl)
        {
            using (DaemonEntities entities = new DaemonEntities())
            {
                OpenIdUser  user        = (from u in entities.OpenIdUser where u.UserId == userId select u).First <OpenIdUser>();
                Participant participant = QueryUtil.First <Participant>(from p in entities.Participant where p.User.UserId == user.UserId select p);

                // If participant is not attached try to find existing participant with openIdUrl
                if (participant == null)
                {
                    participant = QueryUtil.First <Participant>(from p in entities.Participant where p.OpenIdUrl == openIdUrl select p);
                    if (participant != null)
                    {
                        // If participant is not attached to user then attach it.
                        if (participant.User == null)
                        {
                            participant.User = user;
                            entities.SaveChanges();
                        }
                        else
                        {
                            throw new ArgumentException("Participant exists with the same OpenId but already connected to different user.");
                        }
                    }
                }

                // If participant is still null then create new participant and attach to user.
                if (participant == null)
                {
                    participant = new Participant
                    {
                        ParticipantId = new Guid(UUIDGenerator.Current.GenerateNameBasedUUID(new UUID(MxpConstants.MxpNamespaceId.ToString()), openIdUrl).ToString()),
                        OpenIdUrl     = openIdUrl,
                        User          = user
                    };
                    entities.AddToParticipant(participant);
                    entities.SaveChanges();
                }

                entities.Detach(participant);
                return(participant);
            }
        }