Esempio n. 1
0
        internal Guid CreateCrmAppointment(AppointmentEntity outlookAppointment)
        {
            Entity crmAppointment = new Entity(outlookAppointment.CrmEntityLogicalName);

            crmAppointment["description"]    = GetStringWithoutTags(outlookAppointment.Body);
            crmAppointment["scheduledend"]   = outlookAppointment.End;
            crmAppointment["location"]       = outlookAppointment.Location;
            crmAppointment["ylv_outlookid"]  = outlookAppointment.OutlookId;
            crmAppointment["scheduledstart"] = outlookAppointment.Start;
            crmAppointment["subject"]        = outlookAppointment.Subject;

            var crmAttendeesPartyCol = new EntityCollection();

            foreach (var email in outlookAppointment.RequiredAttendeesEmails)
            {
                var attendeesCrmEntity = GetCrmAttendeesByEmail(email);
                if (attendeesCrmEntity != null)
                {
                    var crmAttendeesList = new Entity("activityparty");
                    crmAttendeesList["partyid"] = new EntityReference(attendeesCrmEntity.LogicalName, attendeesCrmEntity.Id);
                    crmAttendeesPartyCol.Entities.Add(crmAttendeesList);
                }
            }

            crmAppointment["requiredattendees"] = crmAttendeesPartyCol;
            crmAppointment.Id = organizationService.Create(crmAppointment);

            foreach (var att in crmAttendeesPartyCol.Entities)
            {
                var response = new Entity("ylv_response");
                response["ylv_name"]         = crmAppointment["subject"].ToString();
                response["ylv_contact"]      = (EntityReference)att["partyid"];
                response["ylv_responsetype"] = new OptionSetValue((int)ResponseType.Unknown);
                response["ylv_responses"]    = crmAppointment.ToEntityReference();
                response.Id = organizationService.Create(response);
            }

            return(crmAppointment.Id);
        }
Esempio n. 2
0
 internal string UpdateCrmAppointment(AppointmentEntity newAppointment)
 {
     try
     {
         Entity updAppointment = new Entity(newAppointment.CrmEntityLogicalName);
         updAppointment.Id = newAppointment.CrmId;
         if (!string.IsNullOrEmpty(newAppointment.Body))
         {
             updAppointment["description"] = newAppointment.Body;
         }
         if (newAppointment.End != null)
         {
             updAppointment["scheduledend"] = newAppointment.End;
         }
         if (newAppointment.Start != null)
         {
             updAppointment["scheduledstart"] = newAppointment.Start;
         }
         if (!string.IsNullOrEmpty(newAppointment.Location))
         {
             updAppointment["location"] = newAppointment.Location;
         }
         if (!string.IsNullOrEmpty(newAppointment.OutlookId))
         {
             updAppointment["ylv_outlookid"] = newAppointment.OutlookId;
         }
         if (!string.IsNullOrEmpty(newAppointment.Subject))
         {
             updAppointment["subject"] = newAppointment.Subject;
         }
         organizationService.Update(updAppointment);
         return("Appointment update success");
     }
     catch (Exception ex)
     {
         return("Appointment update fail\n" + ex.Message);
     }
 }
Esempio n. 3
0
        internal string UpdateOutlookAppointment(AppointmentEntity appointmentEntity)
        {
            Appointment outlookAppointment = Appointment.Bind(exchangeService, appointmentEntity.OutlookId);

            if (!string.IsNullOrEmpty(appointmentEntity.Location))
            {
                outlookAppointment.Location = appointmentEntity.Location;
            }
            if (!string.IsNullOrEmpty(appointmentEntity.Body))
            {
                outlookAppointment.Body = appointmentEntity.Body;
            }
            if (appointmentEntity.Start != null)
            {
                outlookAppointment.Start = (DateTime)appointmentEntity.Start;
            }
            if (appointmentEntity.End != null)
            {
                outlookAppointment.End = (DateTime)appointmentEntity.End;
            }
            outlookAppointment.Update(ConflictResolutionMode.AutoResolve);
            return("Appointment update success");
        }