Exemple #1
0
        public IEnumerable <AppointmentInfo> GetAppointmentEntitiesFromId(int appointmentId, string ticket,
                                                                          string contextIdentifier, string netserverUrl, Dictionary <string, WishlistElement> infoWishList)
        {
            using (SoDatabaseContext.EnterDatabaseContext(contextIdentifier))
            {
                ConfigFile.WebServices.RemoteBaseURL = netserverUrl;
                using (SoSession.Authenticate(new SoCredentials(ticket)))
                    using (var appAgent = new AppointmentAgent())
                        //using (new AssociateAgent())
                        using (var personAgent = new PersonAgent())
                        {
                            var               appEnts = new List <AppointmentInfo>();
                            AppointmentInfo   appInfo;
                            AppointmentEntity appEntity;
                            do
                            {
                                appEntity = appAgent.GetAppointmentEntity(appointmentId);
                                if (appEntity?.Associate == null)
                                {
                                    continue;
                                }

                                var associatePerson   = personAgent.GetPersonEntity(appEntity.Associate.PersonId);
                                var appointmentPerson = personAgent.GetPersonEntity(appEntity.Person.PersonId);

                                appInfo = new AppointmentInfo
                                {
                                    AppointmentId      = appEntity.AppointmentId,
                                    EmailReceiver      = appointmentPerson.Emails.FirstOrDefault()?.Value,
                                    MessageDescription = appEntity.Description,
                                    Receptionist       = associatePerson.FullName,
                                    RecepTitle         = associatePerson.Title,
                                    SmsPhoneNumber     = appointmentPerson.MobilePhones.FirstOrDefault()?.Value,
                                    CustWantsCallBack  = ResolveVariableInfo(appEntity,
                                                                             infoWishList.FirstOrDefault(k => k.Key == "CustWantsCallBack").Value),
                                    SendSms = ResolveVariableInfo(appointmentPerson,
                                                                  infoWishList.FirstOrDefault(k => k.Key == "SendSms").Value),
                                    CustCallsBack = ResolveVariableInfo(appEntity,
                                                                        infoWishList.FirstOrDefault(k => k.Key == "CustCallsBack").Value),
                                    CustomerHighPriority = ResolveVariableInfo(appEntity,
                                                                               infoWishList.FirstOrDefault(k => k.Key == "CustomerHighPriority").Value),
                                    Customer = ResolveVariableInfo(appEntity,
                                                                   infoWishList.FirstOrDefault(k => k.Key == "Customer").Value),
                                    CustomerContact = ResolveVariableInfo(appEntity,
                                                                          infoWishList.FirstOrDefault(k => k.Key == "CustomerContact").Value),
                                    CustomerContactPhone = ResolveVariableInfo(appEntity,
                                                                               infoWishList.FirstOrDefault(k => k.Key == "CustomerContactPhone").Value),
                                };

                                appEnts.Add(appInfo);
                                appointmentId++;
                                Debug.WriteLine($"AppEntity desc {appInfo.MessageDescription} with ID {appointmentId}");
                            } while (appEntity != null);

                            return(appEnts);
                        }
            }
        }
        public override void Load(string CarrierId)
        {
            if (CarrierId == PERSONAL_COLOR && _dataCarriers[PERSONAL_COLOR] == null)
            {
                _personalColorCarrier = newPersonalColorCarrier();
                //"person", set in the ctor
                int    currentPersonId = SuperStateManager.GetCurrentId(PrimaryCurrent);
                string id = Id;

                if (currentPersonId > 0)
                {
                    PersonEntity p = _personAgent.GetPersonEntity(currentPersonId);
                    _dataCarriers[PERSON_CARRIER] = p;

                    if (!string.IsNullOrEmpty(p.UserDefinedFields[UDFieldProgId + ":DisplayText"]))
                    {
                        _personalColorCarrier.SelectedColor = (BasicColor)Enum.Parse(typeof(BasicColor), p.UserDefinedFields[UDFieldProgId + ":DisplayText"]);
                    }

                    _personalColorCarrier.Name      = p.FullName;
                    _personalColorCarrier.BirthDate = p.BirthDate;
                }
                else
                {
                    _personalColorCarrier.SelectedColor = BasicColor.White;
                    _personalColorCarrier.Name          = "";
                    _personalColorCarrier.BirthDate     = DateTime.MinValue;
                }
                _dataCarriers[PERSONAL_COLOR] = _personalColorCarrier;
            }
        }