Ejemplo n.º 1
0
        /// #################################################################
        /// <summary>
        ///     获取所有发明人名称
        ///     Kevin Wang(2010-10-25)
        /// </summary>
        /// <returns>所有发明人名称</returns>
        public string GetInventorNames(string sSplit)
        {
            string sNames = "";

            IOrderedEnumerable <Inventor> Invertors = from e in Inventors.Cast
                                                      <Inventor>()
                                                      orderby e.n_Sequence
                                                      select e;

            switch (sSplit)
            {
            case "1":
                foreach (Inventor app in Invertors)
                {
                    sNames += app.s_Name + ";";
                }
                sNames = sNames.TrimEnd(new[] { ';' });
                break;

            case "2":
                foreach (Inventor app in Invertors)
                {
                    sNames += app.s_Name + "    ";
                }
                sNames = sNames.Trim();
                break;

            case "3":
                foreach (Inventor app in Invertors)
                {
                    sNames += app.s_Name + "、";
                }
                sNames = sNames.TrimEnd(new[] { '、' });
                break;

            case "4":
                foreach (Inventor app in Invertors)
                {
                    sNames += app.s_Name + ";";
                }
                sNames = sNames.TrimEnd(new[] { ';' });
                break;

            case "5":
                int iCount = 1;
                sNames = " ";
                foreach (Inventor app in Invertors)
                {
                    sNames += " " + iCount + "." + app.s_Name;
                }
                break;
            }
            return(sNames);
        }
Ejemplo n.º 2
0
        public override Task Init()
        {
            // generate random order when the page is loaded the first time
            if (!Context.IsPostBack)
            {
                Inventions = Inventors
                             .OrderBy(i => Guid.NewGuid())
                             .Select(i => i.Invention)
                             .ToList();
            }

            return(base.Init());
        }
Ejemplo n.º 3
0
        public IHttpActionResult DeleteInventors(int id)
        {
            Inventors inventors = db.Inventors.Find(id);

            if (inventors == null)
            {
                return(NotFound());
            }

            db.Inventors.Remove(inventors);
            db.SaveChanges();

            return(Ok(inventors));
        }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = RegNumber;
         hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Inventors != null ? Inventors.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ AppDate.GetHashCode();
         hashCode = (hashCode * 397) ^ PubDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Note != null ? Note.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CountPages;
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
        public void CheckAnswer()
        {
            var selectedInventor = Inventors.First(i => i.Id == SelectedInventor);

            if (selectedInventor.Invention == SelectedInvention)
            {
                Inventors.Remove(selectedInventor);
                Inventions.Remove(selectedInventor.Invention);

                SelectedInventor  = null;
                SelectedInvention = null;

                Points++;
            }
            else
            {
                Points = Points - 2;
            }
        }
Ejemplo n.º 6
0
        /// #################################################################
        /// <summary>
        ///     获取所有发明人其他名称
        ///     Kevin Wang(2010-10-25)
        /// </summary>
        /// <returns>所有发明人其他名称</returns>
        public string GetInventorOtherNames()
        {
            string sNames = "";

            //2013-01-29 lixin for bug 26607
            IOrderedEnumerable <Inventor> Invertors = from e in Inventors.Cast
                                                      <Inventor>()
                                                      orderby e.n_Sequence
                                                      select e;

            foreach (Inventor app in Invertors)
            {
                sNames += app.s_NativeName + ";";
            }

            //foreach (Inventor person in this.Inventors)
            //{
            //    sNames += person.s_NativeName + ";";
            //}
            sNames = sNames.TrimEnd(new[] { ';' }); //去掉最后一个分号
            return(sNames);
        }
Ejemplo n.º 7
0
        public IHttpActionResult PostInventors(Inventors inventors)
        {
            db.Inventors.Add(inventors);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (InventorsExists(inventors.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = inventors.ID }, inventors));
        }
Ejemplo n.º 8
0
        public IHttpActionResult PutInventors(int id, Inventors inventors)
        {
            if (id != inventors.ID)
            {
                return(BadRequest());
            }

            string        procedure = "";
            int           number;
            string        connectionString = @"Data Source=DESKTOP-RDKB255\SQLEXPRESS;Initial Catalog=articles;Integrated Security=True";
            SqlConnection connection       = new SqlConnection(connectionString);

            try
            {
                string commandStr =
                    $"EXEC InventorsRating @id = '{inventors.ID}'," +
                    $" @rating = '{inventors.Rating}'";
                connection.Open();
                SqlCommand command = new SqlCommand(commandStr, connection);
                number = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                return(BadRequest(ex.Message));
            }
            finally
            {
                connection.Close();
            }
            if (number != null)
            {
                return(Ok());
            }

            return(null);
        }
Ejemplo n.º 9
0
        public int CompareTo(object obj)
        {
            var newObj = obj as Patent;

            if (ReferenceEquals(this, newObj))
            {
                return(0);
            }
            else if (newObj == null)
            {
                return(1);
            }


            var cmp = DateTime.Compare(PubDate, newObj.PubDate);

            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Inventors.OrderBy(t => t).SequenceEqual(newObj.Inventors.OrderBy(t => t)) ? 1 : 0;
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = DateTime.Compare(AppDate, newObj.AppDate);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = string.Compare(Country, newObj.Country, StringComparison.Ordinal);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = string.Compare(Name, newObj.Name, StringComparison.Ordinal);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = RegNumber.CompareTo(newObj.RegNumber);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = string.Compare(Note, newObj.Note, StringComparison.Ordinal);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = CountPages.CompareTo(newObj.CountPages);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = Price.CompareTo(newObj.Price);
            if (cmp != 0)
            {
                return(cmp);
            }

            cmp = PubYear.CompareTo(newObj.PubYear);
            if (cmp != 0)
            {
                return(cmp);
            }

            return(0);
        }