コード例 #1
0
        /// <summary>
        /// Gets the DiaryAppointment from DB for a DiaryAppointmentID
        /// </summary>
        /// <param name="AppointmentID">DiaryAppointmentID</param>
        /// <returns>true/false</returns>
        public bool GetAppointmentbyID(int AppointmentID)
        {
            bool diaryResult = false;
            AppointmentResult result = new AppointmentResult();

            AquariumDiaryManagement.SessionDetails sd = SDKHelper.GetSessionDetails<AquariumDiaryManagement.SessionDetails>("User");
            result = DiarySdk.GetAppointment(sd, AppointmentID);
            if (result.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.OK)
            {
                diaryResult = true;
                Appointments = new List<DiaryAppointment>();
                ReminderValues = new List<string>();

                GetAllLeads();
                GetAllUsers();
                GetAllTimeshiftValues();

                Appointments.Add(ToDiaryAppointment(result.Appointment));
                Reminders = result.Reminders.ToList();

                int leadTypeID = this.GetLeadTypeIDbyLeadID((int)Appointments[0].LeadID);
                if (Appointments[0].DiaryAppointmentTitle.Contains("\n"))
                    this.GetDiaryTitlebyTitle(Appointments[0].DiaryAppointmentTitle.Replace("\n", string.Empty));
                else
                    this.GetDiaryTitlebyTitle(Appointments[0].DiaryAppointmentTitle);

                if (Appointments[0].DiaryAppointmentText.Contains("\n"))
                    this.GetDiaryTextbyText(Appointments[0].DiaryAppointmentText.Replace("\n", string.Empty), leadTypeID, DiaryTitles.DiaryTitleID);
                else
                    this.GetDiaryTextbyText(Appointments[0].DiaryAppointmentText, leadTypeID, DiaryTitles.DiaryTitleID);

                Appointments[0].DiaryAppointmentText = DiaryTexts.DiaryTextID.ToString();
                Appointments[0].DiaryAppointmentTitle = DiaryTitles.DiaryTitleID.ToString();

                DiaryPriorityLink dpl = new DiaryPriorityLink();

                dpl.GetPriorityLinkbyID(AppointmentID);

                DiaryPriority dp = new DiaryPriority();
                dp.GetDiaryPriority(dpl.DiaryPriorityID);
                dp.GetAllDiaryPriorities();

                DiaryPriorities = new List<DiaryPriority>();
                DiaryPriorities.Add(dp);

                GetAllDiaryTitles();
                GetDefaultDiaryText();

                if (Reminders.Count == 0)
                    Reminders.Add(new Reminder { ClientPersonnelID = Appointments[0].CreatedBy, DiaryReminderID = 0 });
            }
            else if (result.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.Failed)
            {
                throw new System.ApplicationException("Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description);
            }
            return diaryResult;
        }
コード例 #2
0
        /// <summary>
        /// Converts data from SDK to DiaryAppointment List
        /// </summary>
        /// <param name="Data">AquariumReportManagement.ReportData</param>
        /// <returns>DiaryAppointment List</returns>
        private List<DiaryAppointment> ToList(IR_Dashboard_SDK.AquariumCustomProcessing.ReportData Data)
        {
            List<DiaryAppointment> TempList = new List<DiaryAppointment>();
            DiaryPriorities = new List<DiaryPriority>();

            DataTable dt = SDKHelper.GetDataTableFromSdkResult(Data.Columns, Data.Rows);
            foreach (DataRow dr in dt.Rows)
            {
                if (dr["DiaryAppointmentID"] != null)
                {
                    if (Convert.ToInt32(dr["DiaryAppointmentID"]) != 0)
                    {
                        DiaryPriorityLink dpl = new DiaryPriorityLink();

                        dpl.GetPriorityLinkbyID(Convert.ToInt32(dr["DiaryAppointmentID"]));

                        DiaryPriority dp = new DiaryPriority();
                        dp.GetDiaryPriority(dpl.DiaryPriorityID);
                        DiaryPriorities.Add(dp);

                        if (dr.Table.Columns.Contains("CustomerName"))
                            TempList.Add(new DiaryAppointment { DiaryAppointmentID = Convert.ToInt32(dr["DiaryAppointmentID"]), CustomerName = dr["CustomerName"].ToString(), DiaryAppointmentTitle = dr["DiaryAppointmentTitle"].ToString(), DiaryAppointmentText = dr["DiaryAppointmentText"].ToString(), DueDate = Convert.ToDateTime(dr["DueDate"]), EndDate = Convert.ToDateTime(dr["EndDate"]), AllDayEvent = Convert.ToBoolean(dr["AllDayEvent"]), Completed = Convert.ToBoolean(dr["Completed"]), LeadID = Convert.ToInt32(dr["LeadID"]), ResourceInfo = dr["ResourceInfo"].ToString() });
                        else
                            TempList.Add(new DiaryAppointment { DiaryAppointmentID = Convert.ToInt32(dr["DiaryAppointmentID"]), DiaryAppointmentTitle = dr["DiaryAppointmentTitle"].ToString(), DiaryAppointmentText = dr["DiaryAppointmentText"].ToString(), DueDate = Convert.ToDateTime(dr["DueDate"]), EndDate = Convert.ToDateTime(dr["EndDate"]), AllDayEvent = Convert.ToBoolean(dr["AllDayEvent"]), Completed = Convert.ToBoolean(dr["Completed"]), LeadID = Convert.ToInt32(dr["LeadID"]), ResourceInfo = dr["ResourceInfo"].ToString() });
                    }
                }
            }

            return TempList;
        }
コード例 #3
0
        /// <summary>
        /// Add DiaryAppointment to DB
        /// </summary>
        /// <returns>true/false</returns>
        public bool AddDiaryAppointment()
        {
            bool diaryresult = false;
            bool isupdate = true;
            MsgLabel = "Task not added!";
            IsError = true;

            AppointmentResult AppointmentResult = new AquariumDiaryManagement.AppointmentResult();
            SessionDetails sd = SDKHelper.GetSessionDetails<AquariumDiaryManagement.SessionDetails>("User");

            Reminder TempReminder = new Reminder();
            TempReminder = Reminders[0];

            Reminders.Remove(TempReminder);
            GetRemindersfromList(TempReminder);

            if (Appointments[0].DiaryAppointmentID == 0)
                isupdate = false;

            this.GetDiaryTextbyID(Convert.ToInt32(Appointments[0].DiaryAppointmentText));
            this.GetDiaryTitlebyID(Convert.ToInt32(Appointments[0].DiaryAppointmentTitle));

            Appointments[0].DiaryAppointmentText = DiaryTexts.Text;
            Appointments[0].DiaryAppointmentTitle = DiaryTitles.Title;
            Appointments[0].DueDate = Appointments[0].EndDate.AddHours(-1);
            //Appointments[0].DueDate = Convert.ToDateTime(String.Format("{0:MM/dd/yyyy HH:mm}", Appointments[0].DueDate));
            //Appointments[0].EndDate = Convert.ToDateTime(String.Format("{0:MM/dd/yyyy HH:mm}", Appointments[0].EndDate));

            Appointments[0].AllDayEvent = false;

            Appointment tempAppointment = ToAppointment(Appointments[0]);

            AppointmentResult = DiarySdk.SaveAppointment(sd, tempAppointment, Reminders.ToArray());
            if (AppointmentResult.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.OK)
            {
                //AddReminderstoList();
                diaryresult = true;
                MsgLabel = "Task added Successfully!";
                IsError = false;

                if (isupdate)
                {
                    DiaryPriorityLink dpl = new DiaryPriorityLink();

                    dpl.GetPriorityLinkbyID(tempAppointment.DiaryAppointmentID);

                    dpl.DiaryAppointmentID = tempAppointment.DiaryAppointmentID;
                    dpl.DiaryPriorityID = DiaryPriorities[0].DiaryPriorityID;

                    dpl.UpdatePriorityLink();

                    Appointments = new List<DiaryAppointment>();
                    ReminderValues = new List<string>();
                    DiaryPriorities = new List<DiaryPriority>();
                    DiaryPriority dp = new DiaryPriority();
                    dp.GetDiaryPriority(dpl.DiaryPriorityID);
                    dp.GetAllDiaryPriorities();

                    DiaryPriorities.Add(dp);

                    GetAllLeads();
                    GetAllUsers();
                    GetAllTimeshiftValues();
                    GetAllDiaryTitles();
                    GetDefaultDiaryText();

                    Appointments.Add(ToDiaryAppointment(AppointmentResult.Appointment));
                    Reminders = AppointmentResult.Reminders.ToList();

                    int leadTypeID = this.GetLeadTypeIDbyLeadID((int)Appointments[0].LeadID);
                    this.GetDiaryTitlebyTitle(Appointments[0].DiaryAppointmentTitle);
                    this.GetDiaryTextbyText(Appointments[0].DiaryAppointmentText, leadTypeID, DiaryTitles.DiaryTitleID);

                    Appointments[0].DiaryAppointmentText = DiaryTexts.DiaryTextID.ToString();
                    Appointments[0].DiaryAppointmentTitle = DiaryTitles.DiaryTitleID.ToString();

                    if (Reminders.Count == 0)
                        Reminders.Add(new Reminder { ClientPersonnelID = Appointments[0].CreatedBy, DiaryReminderID = 0 });
                    MsgLabel = "Task updated Successfully!";
                    IsError = false;
                }
                else
                {
                    DiaryPriorityLink dpl = new DiaryPriorityLink();

                    dpl.DiaryAppointmentID = AppointmentResult.Appointment.DiaryAppointmentID;
                    dpl.DiaryPriorityID = DiaryPriorities[0].DiaryPriorityID;

                    dpl.AddPriorityLink();

                    DiaryPriorities = new List<DiaryPriority>();
                    DiaryPriority dp = new DiaryPriority();
                    dp.GetAllDiaryPriorities();
                    dp.GetDiaryPriority(3);
                    DiaryPriorities.Add(dp);

                    this.AddDiaryLog(AppointmentResult.Appointment.DiaryAppointmentID, 1, DateTime.Now, Appointments[0].CreatedBy, "Task Added");
                }
            }
            else if (AppointmentResult.ResultInfo.ReturnCode == AquariumDiaryManagement.BasicCode.Failed)
            {
                MsgLabel = "Error ID:" + AppointmentResult.ResultInfo.Errors[0].ResultCodeID + ", Description:" + AppointmentResult.ResultInfo.Errors[0].Description;
                IsError = true;
            }

            return diaryresult;
        }