Ejemplo n.º 1
0
        public void RemoveDraft(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            //Get exist
            var existMail = DraftList.FirstOrDefault(item =>
            {
                return(item.ID == id);
            });

            if (existMail == null)
            {
                return;
            }
            //Delete Attachments
            string folder  = DraftFolder.CombinePath(id);
            var    dirInfo = new DirectoryInfo(folder);

            if (dirInfo.Exists)
            {
                dirInfo.Delete(true);
            }
            //Delete Mail Content
            DraftList.Remove(existMail);
            SerializeAssistant.Serialize(draftBinPath, DraftList);
            System.Diagnostics.Debug.WriteLine("Remove " + existMail.ID);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lists the drafts in the user's inbox.
        /// </summary>
        /// <param name="service">Gmail API service instance</param>
        /// <returns>A list of Drafts</returns>
        public static async Task <IList <Draft> > ListAsync(this DraftService service)
        {
            DraftList draftIds = await service.ListIdsAsync();

            var tasks = draftIds.Drafts.Select(async draft => (await service.GetAsync(draft.Id)));

            return((await Task.WhenAll(tasks)).ToList());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Current_screen_LB.Text = "Manage/Check Consent Forms";
                //CreateFormBtn.Visible = true;
                //ManageFormBtn.Visible = false;
                classListDiv.Visible          = false;
                FormInfoDiv.Visible           = false;
                confirmationOverlay.Visible   = false;
                foodprefcard.Visible          = false;
                foodprefcardupdate.Visible    = false;
                updateFormDiv.Visible         = false;
                modalOverlay.Visible          = false;
                FoodRadioButton.SelectedIndex = 0;
                CreateConsentFormDiv.Visible  = false;
                DraftList.Visible             = false;
                UserBO        userbo              = new UserBO();
                ConsentFormBO consentformbo       = new ConsentFormBO();
                String        currentLoggedInUser = Request.Cookies["CurrentLoggedInUser"].Value;
                List <String> TeachingClasses     = userbo.getTeachersTeachingClasses(currentLoggedInUser);

                List <ConsentForm> consentFormRecordsDrafts = consentformbo.getDraftConsentFormsBySenderID(currentLoggedInUser);

                if (consentFormRecordsDrafts == null || consentFormRecordsDrafts.Count == 0)
                {
                    DraftFormErrorMsg.Text = "There are no drafts created.";
                }
                DraftFormErrorMsg.Visible = false;
                List <ConsentForm> consentFormRecords = consentformbo.getConsentFormsBySenderID(currentLoggedInUser);
                if (consentFormRecords == null || consentFormRecords.Count == 0)
                {
                    formErrorMsg.Text = "There are no forms created.";
                }
                else
                {
                    consentFormRecords.Reverse(); //sorts by latest at the top
                }
                classesDropDownList.DataSource = TeachingClasses;
                classesDropDownList.DataBind();

                string currentSchool = userbo.getUserById(Request.Cookies["CurrentLoggedInUser"].Value).school;
                classesDropDownList.SelectedIndex = 0;
                string      selectedClass    = classesDropDownList.SelectedValue;
                List <user> studentClassList = userbo.retrieveClassListBySchoolAndClass(currentSchool, selectedClass);
                classListGridView.DataSource = studentClassList;
                classListGridView.DataBind();

                SelectedClassesListBox.DataSource = TeachingClasses;
                SelectedClassesListBox.DataBind(); //binds the data of classes that the user teaches
                updateSelectedClassesListBox.DataSource = TeachingClasses;
                updateSelectedClassesListBox.DataBind();
                DraftList.DataSource = consentFormRecordsDrafts;
                DraftList.DataBind();
                ConsentFormList.DataSource = consentFormRecords;
                ConsentFormList.DataBind(); //bind entries
            }
        }
        protected void DraftList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            ConsentFormBO      consentformbo       = new ConsentFormBO();
            String             currentLoggedInUser = Request.Cookies["CurrentLoggedInUser"].Value;
            List <ConsentForm> consentFormRecords  = consentformbo.getDraftConsentFormsBySenderID(currentLoggedInUser);

            consentFormRecords.Reverse();
            DraftList.DataSource = consentFormRecords;
            DraftList.PageIndex  = e.NewPageIndex;
            DraftList.DataBind();
        }
Ejemplo n.º 5
0
        public void SaveDraftChanges(MailBase mail)
        {
            string mailId = mail.ID;

            if (string.IsNullOrEmpty(mailId))
            {
                mail.ID = CreateId();
                this.AddDraft(mail);
            }
            else
            {
                var existMail = DraftList.FirstOrDefault(item =>
                {
                    return(item.ID == mailId);
                });
                if (existMail == null)
                {
                    this.AddDraft(mail);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Save changes of " + mail.ID);
                    if (string.IsNullOrEmpty(mail.Subject) &&
                        string.IsNullOrEmpty(mail.BodyHtml) &&
                        string.IsNullOrEmpty(mail.BodyText))
                    {
                        RemoveDraft(mail.ID);
                    }
                    else
                    {
                        existMail.SyncButNoIdTo(mail);
                        SerializeAssistant.Serialize(draftBinPath, DraftList);
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public void AddDraft(MailBase mail)
 {
     if (null == mail)
     {
         return;
     }
     if (DraftList.Contains(mail))
     {
         return;
     }
     if (string.IsNullOrEmpty(mail.Subject) &&
         string.IsNullOrEmpty(mail.BodyHtml) &&
         string.IsNullOrEmpty(mail.BodyText))
     {
         return;
     }
     if (string.IsNullOrEmpty(mail.ID))
     {
         mail.ID = CreateId();
     }
     System.Diagnostics.Debug.WriteLine("Add " + mail.ID);
     DraftList.Add(mail);
     SerializeAssistant.Serialize(draftBinPath, DraftList);
 }
Ejemplo n.º 7
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     DraftList.Remove((sender as FrameworkElement).DataContext as DraftModel);
     await DraftManager.DeleteDraft((sender as FrameworkElement).DataContext as DraftModel);
 }