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 string CreateFollowUp() { SaleEntity sale = AgentFactory.GetSaleAgent().GetSaleEntity(SuperStateManager.GetCurrentId("sale")); if (sale != null) { AppointmentAgent agent = new AppointmentAgent(); AppointmentEntity app = agent.CreateDefaultAppointmentEntityByType(SuperOffice.Data.TaskType.Appointment); app.Contact = sale.Contact; app.Person = sale.Person; app.Associate = sale.Associate; app.Description = "Sample Follow-up from Sale " + sale.SaleId; app.StartDate = DateTime.Today.AddDays(7); app.EndDate = app.StartDate; app = agent.SaveAppointmentEntity(app); return(app.AppointmentId.ToString()); } else { return(String.Empty); } }
protected void datesBtn_Click(object sender, EventArgs e) { using (SoSession mySession = SoSession.Authenticate(Session["UserName"].ToString().Trim(), Session["passWord"].ToString().Trim())) { //retrieve user inputs and store them in variables TextBox ai = form1.FindControl("assoicateID") as TextBox; TextBox ad = form1.FindControl("activeDate") as TextBox; TextBox ed = form1.FindControl("endDate") as TextBox; //converting the values to the format required by the method int personID = int.Parse(ai.Text); DateTime activeDate = DateTime.Parse(ad.Text); DateTime endDate = DateTime.Parse(ed.Text); //retrive the appointments list using the Agent AppointmentAgent newAppAgt = new AppointmentAgent(); ActivityInformationListItem[] newAppArr = newAppAgt.GetActivityInformationListByDatesAndAssociate(activeDate, endDate, 103); //Displaying the Appointments between a given date range of and Associate for (int i = 0; i < newAppArr.Length; i++) { //Instantiate table rows and table cells HtmlTableCell tblcelldate = new HtmlTableCell(); HtmlTableCell tblcellday = new HtmlTableCell(); HtmlTableRow tblrow = new HtmlTableRow(); //Assigning data to the table tblcelldate.Controls.Add(new LiteralControl(newAppArr[i].Date.Date.ToString("dd/MM/yyyy"))); tblcellday.Controls.Add(new LiteralControl(newAppArr[i].Date.DayOfWeek.ToString())); tblrow.Controls.Add(tblcelldate); tblrow.Controls.Add(tblcellday); tblid.Controls.Add(tblrow); datesBtn.Visible = false; } } }