/// <UpdateDrafts>
 /// Update existing Draft
 /// </summary>
 /// <param name="d">Set Values in a Draft Class Property and Pass the same Object of Draft Class (SocioBoard.Domain.Draft).</param>
 public void UpdateDrafts(Drafts d)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 session.CreateQuery("Update Drafts set Message =:mess,ModifiedDate =:mod where UserId =:userid")
                 .SetParameter("mess", d.Message)
                 .SetParameter("mod", d.ModifiedDate)
                 .SetParameter("userid", d.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Trasaction
     }     //End session
 }
        public virtual void Add(TEvent theEvent)
        {
            if (string.IsNullOrEmpty(theEvent.EventId))
            {
                theEvent.EventId = Guid.NewGuid().ToString();
            }

            if (theEvent.IsFinal)
            {
                theEvent.Created = DateTime.Now;
                Latest           = theEvent;
                History.Add(theEvent);
                Drafts.Clear();
                return;
            }
            else
            {
                theEvent.Created = theEvent.Created == null ? DateTime.Now : theEvent.Created;
                var usersDraft = Drafts.SingleOrDefault(draft => draft.UserId == theEvent.UserId);
                if (usersDraft != null)
                {
                    Drafts.Remove(usersDraft);
                    Drafts.Add(theEvent);
                    return;
                }

                Drafts.Add(theEvent);
            }
        }
 /// <DeleteDrafts>
 /// Delete Draft
 /// </summary>
 /// <param name="d">Set Values in a Draft Class Property and Pass the Object of Draft Class (SocioBoard.Domain.Draft).</param>
 /// <returns>Return 1 for successfully deleted or 0 for failed.</returns>
 public int DeleteDrafts(Drafts d)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action ,
                 //To delete draft, by user id and message.
                 NHibernate.IQuery query = session.CreateQuery("delete from Drafts where UserId = :userid and Message =:mess")
                                           .SetParameter("userid", d.UserId)
                                           .SetParameter("mess", d.Message);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return(isUpdated);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         } //End transaction
     }     //End session
 }
示例#4
0
 public bool HasDraftAt(int i)
 {
     if (HasDrafts)
     {
         return(Drafts.Any(x => Drafts.IndexOf(x) == i));
     }
     return(false);
 }
示例#5
0
 public DraftItem(Drafts draft)
 {
     this.Draft   = draft;
     this.Text    = Draft.Content;
     this.Width   = 200;
     this.Height  = 60;
     this.Visible = true;
 }
示例#6
0
        public virtual IEnumerable <string> GetNodeFlags(ContentItem item)
        {
            var type = item.GetContentType();
            var tags = new List <string>();

            tags.Add(item.State.ToString());
            foreach (var possibleState in Enum.GetValues(typeof(CollectionState)).Cast <CollectionState>())
            {
                if (possibleState != CollectionState.Unknown && item.ChildState.HasFlag(possibleState))
                {
                    tags.Add(possibleState.ToString());
                }
            }

            if (!item.IsPublished())
            {
                tags.Add("NotPublished");
            }
            if (item.IsExpired())
            {
                tags.Add("Expired");
            }
            if (!item.Visible)
            {
                tags.Add("Invisible");
            }
            if (item.AlteredPermissions != Permission.None && item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0)
            {
                tags.Add("Locked");
            }

            if (Drafts.HasDraft(item))
            {
                tags.Add("HasDraft");
            }

            if (item.Created.AddDays(3) > Utility.CurrentTime())
            {
                tags.Add("Recent");
            }

            tags.Add(type.Assembly.GetName().Name);

            tags.AddRange(Utility.GetBaseTypesAndSelf(type).Where(t => t != typeof(object)).Select(t => t.Name));
            tags.AddRange(type.GetInterfaces().Where(t => t.Namespace.Contains("Definition")).Select(t => t.Name));

            var d = Definitions.GetDefinition(item);

            tags.AddRange(d.AdditionalFlags);
            if (d.RemovedFlags.Any())
            {
                tags.RemoveAll(f => d.RemovedFlags.Contains(f));
            }

            return(tags);
        }
示例#7
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            Context db   = new Context();
            Drafts  item = db.Drafts.Where(w => w.Id == Draft.Id).FirstOrDefault();

            item.Content = txt_content.Text;
            item.Status  = Convert.ToInt32((cbx_status.SelectedItem as Item).Value);
            db.SaveChanges();
            this.Close();
        }
示例#8
0
 public void Delete(Context db)
 {
     // TODO Delete inherited forms
     foreach (var draft in Drafts.ToList())
     {
         draft.Delete(db);
     }
     foreach (var section in Sections.ToList())
     {
         section.Delete(db);
     }
     db.Entry(this).State = EntityState.Deleted;
 }
 /// <AddDrafts>
 /// Add new draft
 /// </summary>
 /// <param name="d">Set Values in a Draft Class Property and Pass the Object of Draft Class (SocioBoard.Domain.Draft).</param>
 public void AddDrafts(Drafts d)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action , to save data.
             session.Save(d);
             transaction.Commit();
         } //End transaction
     }     //End session
 }
示例#10
0
        public void LetterTextEdit()
        {
            Drafts           drafts           = new Drafts(driver);
            EmailBox         emailBox         = new EmailBox(driver);
            CreateLetterPage createLetterPage = new CreateLetterPage(driver);

            emailBox.DraftsButton.Click();
            drafts.LetterToEdit.Click();
            Assert.AreEqual("Нередагований текст листа", createLetterPage.LetterTextField);
            createLetterPage.LetterTextField.SendKeys("Вже редагований текст листа");
            createLetterPage.SaveInDraftsButton.Click();
            emailBox.DraftsButton.Click();

            Assert.AreEqual("EditedLetter", drafts.LetterSubject);
        }
示例#11
0
        public void LetterSubjectEdit()
        {
            Drafts           drafts           = new Drafts(driver);
            EmailBox         emailBox         = new EmailBox(driver);
            CreateLetterPage createLetterPage = new CreateLetterPage(driver);

            emailBox.DraftsButton.Click();
            drafts.LetterToEdit.Click();
            //Assert.AreEqual(topic, createLetterPage.LetterSubjectField);
            createLetterPage.LetterSubjectField.SendKeys(editedTopic);
            createLetterPage.SaveInDraftsButton.Click();
            emailBox.DraftsButton.Click();
            Assert.AreEqual(editedTopic, drafts.LetterSubject);
            topic = editedTopic;
        }
示例#12
0
        public void LetterReceiverEdit()
        {
            Drafts           drafts           = new Drafts(driver);
            EmailBox         emailBox         = new EmailBox(driver);
            CreateLetterPage createLetterPage = new CreateLetterPage(driver);

            emailBox.DraftsButton.Click();
            driver.WaitForElementDisplayed(drafts.DraftsHeader);
            drafts.LetterToEdit.Click();
            createLetterPage.LetterReciverField.Clear();
            createLetterPage.LetterReciverField.SendKeys("*****@*****.**");
            createLetterPage.SaveInDraftsButton.Click();
            emailBox.DraftsButton.Click();
            Assert.AreEqual("*****@*****.**", drafts.LetterReceiver);
        }
示例#13
0
        public EditDraft(Drafts draft)
        {
            this.Draft = draft;
            InitializeComponent();
            foreach (Item item in _get())
            {
                cbx_status.Items.Add(item);
            }
            cbx_status.DisplayMember = "Text";
            cbx_status.ValueMember   = "Value";

            txt_content.Text         = Draft.Content;
            cbx_status.SelectedIndex = Draft.Status;
            //cbx_status.SelectedValue = this.Draft.Status;
        }
示例#14
0
        public CommonFixtureCreator(Mock <Context> _mockContext)
        {
            //mockContext = new Mock<Context>();
            mockContext = _mockContext;
            context     = mockContext.Object;

            Forms.Create(mockContext);
            Parentings.Create(mockContext);
            form         = Form.Load(context, 2); // child
            form1        = Form.Load(context, 1); // parent
            sections     = Sections.Create(mockContext, form);
            fields       = Fields.Create(mockContext, form, sections[0]);
            validataions = Validations.Create(mockContext, form, fields);

            Drafts.Create(mockContext, form);

            TestBase.CalcVirtualAttributes(context);
        }
示例#15
0
        public override void Add(OtherEvent theEvent)
        {
            if (string.IsNullOrEmpty(theEvent.EventId))
            {
                theEvent.EventId = Guid.NewGuid().ToString();
            }

            if (theEvent.IsFinal)
            {
                theEvent.Created = DateTime.Now;
                Latest           = theEvent;
                History.Add(theEvent);
                var draft = Drafts.SingleOrDefault(d => d.EventId == theEvent.EventId);
                if (draft != null)
                {
                    Drafts.Remove(draft);
                }

                return;
            }
            else
            {
                theEvent.Created = theEvent.Created == null ? DateTime.Now : theEvent.Created;
                var userHasDraft = Drafts.Any(draft => draft.UserId == theEvent.UserId);
                if (userHasDraft)
                {
                    var usersDraft = Drafts.SingleOrDefault(draft => draft.EventId == theEvent.EventId);

                    if (usersDraft == null)
                    {
                        throw new ArgumentException(nameof(theEvent.EventId));
                    }

                    Drafts.Remove(usersDraft);
                    Drafts.Add(theEvent);
                    return;
                }

                Drafts.Add(theEvent);
            }
        }
示例#16
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter?.ToString() == "Tut")
            {
                isTutorialPlaying = true;
                CurrentBatch      = new BatchedFeedbackModel();
                LoadTeacherTask   = FetchTeachers().ContinueWith(x => UpdateIncludedTeacher());

                FBStatusCount = IncludedTeachers.Count.ToString();
                DataContext   = this;

                await Task.Delay(500);

                ttForms.IsOpen = true;
            }
            else
            {
                if (Drafts.Count == 0)
                {
                    Drafts.Add(new BatchedFeedbackModel()
                    {
                        FeedbackerAccountEmail = Provider.CurrentAccount.Email
                    });
                }

                CurrentBatch    = Drafts.Last(x => x.FeedbackerAccountEmail == Provider.CurrentAccount.Email);
                LoadTeacherTask = FetchTeachers().ContinueWith(x => UpdateIncludedTeacher());
                await Task.Delay(1000);

                await LoadTeacherTask;
                FBStatusCount = IncludedTeachers.Count.ToString();
                DataContext   = this;
            }
        }
示例#17
0
 public async Task <Draft> GetDraft(int id) =>
 await Drafts.Include(x => x.Post).SingleOrDefaultAsync(x => x.Id == id);
示例#18
0
 public EmailsContainer GoToDrafts()
 {
     Drafts.Click();
     return(new EmailsContainer(driver));
 }
示例#19
0
        protected virtual IDictionary <string, MetaInfo> GetMetaInformation(ContentItem item)
        {
            var mi = new Dictionary <string, MetaInfo>();

            if (Languages.IsLanguageRoot(item) && Languages.GetLanguage(item) != null)
            {
                mi["language"] = new MetaInfo {
                    Text = Languages.GetLanguage(item).LanguageCode
                }
            }
            ;

            if (!item.IsPage)
            {
                mi["zone"] = new MetaInfo {
                    Text = item.ZoneName
                }
            }
            ;

            if (!item.Visible)
            {
                mi["hidden"] = new MetaInfo {
                    Text = "", ToolTip = "Hidden"
                }
            }
            ;

            if (item.AlteredPermissions != Permission.None && item.AuthorizedRoles != null && item.AuthorizedRoles.Count > 0)
            {
                mi["locked"] = new MetaInfo {
                    Text = "", ToolTip = "Locked"
                }
            }
            ;

            if (Host.IsStartPage(item))
            {
                mi["authority"] = new MetaInfo {
                    Text = string.IsNullOrEmpty(Host.GetSite(item).Authority) ? "*" : Host.GetSite(item).Authority
                }
            }
            ;

            if (item.Parent == null)
            {
                mi["root"] = new MetaInfo {
                    Text = ""
                }
            }
            ;

            var draftInfo = Drafts.GetDraftInfo(item);

            if (draftInfo != null && draftInfo.Saved > item.Updated)
            {
                mi["draft"] = new DraftMetaInfo(draftInfo);
            }
            else if (item.State <= ContentState.Draft && item.VersionIndex == 0)
            {
                mi["draft"] = new DraftMetaInfo(item);
            }

            if (item is ISystemNode)
            {
                mi["system"] = new MetaInfo {
                    ToolTip = Definitions.GetDefinition(item).Title
                }
            }
            ;

            return(mi);
        }