Esempio n. 1
0
 public void AddForecast(string temp, string summary)
 {
     AddForecastButton.ClickExtension(Js);
     TempInput.ClickClearAndSendKeys(temp);
     SummaryInput.ClickClearAndSendKeys(summary);
     UpdateButton.ClickExtension(Js);
 }
Esempio n. 2
0
        /// <summary>
        /// Takes all of the data in the stream and returns it as an array of bytes
        /// </summary>
        /// <param name="input">Input stream</param>
        /// <returns>A byte array</returns>
        public static async Task <byte[]> ReadAllBinaryAsync(this Stream input)
        {
            if (input is null)
            {
                return(Array.Empty <byte>());
            }

            if (input is MemoryStream TempInput)
            {
                return(TempInput.ToArray());
            }

            var Pool   = ArrayPool <byte> .Shared;
            var Buffer = Pool.Rent(4096);

            using var Temp = new MemoryStream();
            while (true)
            {
                var Count = await input.ReadAsync(Buffer.AsMemory(0, Buffer.Length)).ConfigureAwait(false);

                if (Count <= 0)
                {
                    Pool.Return(Buffer);
                    return(Temp.ToArray());
                }
                Temp.Write(Buffer, 0, Count);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Takes all of the data in the stream and returns it as an array of bytes
        /// </summary>
        /// <param name="input">Input stream</param>
        /// <returns>A byte array</returns>
        public static byte[] ReadAllBinary(this Stream input)
        {
            if (input is null)
            {
                return(Array.Empty <byte>());
            }

            if (input is MemoryStream TempInput)
            {
                return(TempInput.ToArray());
            }

            var Pool   = ArrayPool <byte> .Shared;
            var Buffer = Pool.Rent(4096);

            using var Temp = new MemoryStream();
            while (true)
            {
                var Count = input.Read(Buffer, 0, Buffer.Length);
                if (Count <= 0)
                {
                    Pool.Return(Buffer);
                    return(Temp.ToArray());
                }
                Temp.Write(Buffer, 0, Count);
            }
        }
Esempio n. 4
0
 private void buttonReset_Click(object sender, EventArgs e)
 {
     TempInput.Clear();
     TempOutput.Text      = "";
     rbCelToFaren.Checked = false;
     rbFarenToCel.Checked = false;
     rbKevin.Checked      = false;
 }
Esempio n. 5
0
        public ActionResult Update(TempInput sendInfo)
        {
            //var post = RavenSession.Load<Post>(input.Id) ?? new Post { CreatedAt = DateTimeOffset.Now };//Post is an empty tool here
            ////////////////

            sendInfo.Id = "0";
            var post = RavenSession.Load<Post>(sendInfo.Id) ?? new Post { CreatedAt = DateTimeOffset.Now };//Post is an empty tool here

            //input.MapPropertiesToInstance(post);//Entering data  ///////////////////////

            post.Title = sendInfo.Title;
            if (sendInfo.AllowComments == "on")
                post.AllowComments = true;
            else post.AllowComments = false;
            post.Body = sendInfo.Body;
            post.CreatedAt = DateTimeOffset.Now;

            //Convert PublishAt (string) into dateTime
            string mm = sendInfo.PublishAt.Substring(0, 2);
            int mmInt = int.Parse(mm);
            string dd = sendInfo.PublishAt.Substring(3,2);
            int ddInt = int.Parse(dd);
            string yy = sendInfo.PublishAt.Substring(6, 4);
            int yyInt = int.Parse(yy);
            // Convert into date
            DateTime TempDate=new DateTime(yyInt,mmInt,ddInt);
            // Convert into DateTimeOffset
            DateTimeOffset TempDateOffSet=new DateTimeOffset(TempDate);
            // Entering the date into post
            post.PublishAt = TempDateOffSet;

               // Entering the tag
            string tempTag = sendInfo.Tags;
            ICollection<string> t=new Collection<string>();
            t.Add(tempTag);
            post.Tags.Add(tempTag);

            //if (!ModelState.IsValid)             ////////////////////
            //    return View("Edit", input);    //////////////////

            // Be able to record the user making the actual post
            var user = RavenSession.GetCurrentUser();
            if (string.IsNullOrEmpty(post.AuthorId))
            {
                post.AuthorId = user.Id;
            }
            else
            {
                post.LastEditedByUserId = user.Id;
                post.LastEditedAt = DateTimeOffset.Now;
            }

            if (post.PublishAt <= DateTimeOffset.Now)

            {
                var postScheduleringStrategy = new PostSchedulingStrategy(RavenSession, DateTimeOffset.Now);
                post.PublishAt = postScheduleringStrategy.Schedule();
                post.PublishAt = DateTimeOffset.Now;
                post.CreatedAt = DateTimeOffset.Now;
            }

            // Actually save the post now
            RavenSession.Store(post);

            //if (input.IsNewPost())    //////////////////////
            //{
                // Create the post comments object and link between it and the post
                var comments = new PostComments
                               {
                                   Comments = new List<PostComments.Comment>(),
                                   Spam = new List<PostComments.Comment>(),
                                   Post = new PostComments.PostReference
                                          {
                                              Id = post.Id,
                                              PublishAt = post.PublishAt,
                                          }
                               };

                RavenSession.Store(comments);
                post.CommentsId = comments.Id;
            //}                   ////////////////

            return RedirectToAction("Details", new { Id = post.MapTo<PostReference>().DomainId });
        }