Пример #1
0
        private void UpdateContent()
        {
            CitationStyle style = (CitationStyle)cbStyle.SelectedItem;
            CitationType  type  = (CitationType)cbType.SelectedItem;

            citationDetails.title   = tbTitle.Text;
            citationDetails.authors = GetAuthors();
            citationDetails.year    = tbYear.Text;

            if (type == CitationType.Book)
            {
                citationDetails.publisher = new Publisher(tbPublisher.Text);
            }

            if (type == CitationType.Article)
            {
                citationDetails.journal = new Journal(tbJournal.Text);
                citationDetails.doi     = tbDoi.Text;
            }

            citationDetails.style = style;
            citationDetails.type  = type;

            Citation citation = citationFactory.CreateCitation(citationDetails);

            commandFactory.Execute(citation);

            Close();
        }
Пример #2
0
        private static void AddCitationType(CitationUniSofiaContext db)
        {
            var citationType = new string[]
            {
                "Книгa",
                "Сборници и енциклопедии",
                "Официални и служебни издания",
                "Стандарти",
                "Електронни книги",
                "Глави или части от книги и сборници",
                "Дипломни работи и дисертации"
            };


            var citationTypeCollection = new List <CitationType>();

            foreach (var ct in citationType)
            {
                var currCt = new CitationType
                {
                    Name = ct
                };

                citationTypeCollection.Add(currCt);
            }

            db.CitationTypes.AddRange(citationTypeCollection);
            db.SaveChanges();
        }
Пример #3
0
        public JsonResult GetCitationForm(long id, long articleid)
        {
            try
            {
                if (id == 0)
                {
                    return(Json("error"));
                }
                CitationType data = new CitationType();

                data = _ContentServices.GetContentOfItem <CitationType>(ContentServices.ServiceTables.Citation, 1, id).Contents.FirstOrDefault();
                string        source    = data.Text;
                List <string> attrname  = source.EverythingBetween("[[[", "]]]");
                List <string> attrvalue = new List <string>();


                DynamicResponse <SubmissionLO> submission = _HomeServices.GetArticle((long)articleid);

                string value = "";
                var    t     = source;
                //StringBuilder s = StringBuilder(source);
                for (int i = 0; i < attrname.Count; i++)
                {
                    value  = Helper.GetPropValue <string>(submission.Data, attrname[i]);
                    source = source.Replace("[[[" + attrname [i] + "]]]", value);
                }

                return(Json(source));
            }
            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
Пример #4
0
 public Citation(CitationType type, string url, string name, string description)
 {
     Type        = type;
     Url         = url;
     Name        = name;
     Description = description;
 }
Пример #5
0
        private void SetUiByType(CitationType type)
        {
            List <Control> bookControls = new List <Control>()
            {
                tbPublisher, lblPublisher
            };
            List <Control> articleControls = new List <Control>()
            {
                tbJournal, lblJournal, tbDoi, lblDoi
            };

            if (type == CitationType.Book)
            {
                bookControls.ForEach(x => x.Show());
                articleControls.ForEach(x => x.Hide());
            }
            else if (type == CitationType.Article)
            {
                articleControls.ForEach(x => x.Show());
                bookControls.ForEach(x => x.Hide());
            }
            else if (type == CitationType.Webpage)
            {
                // TODO fix these controls
            }
        }
Пример #6
0
 public Citation(List <Author> authors, string title, string year, Publisher publisher, CitationStyle style, CitationType type)
 {
     this.authors   = authors;
     this.year      = year;
     this.publisher = publisher;
     this.Style     = style;
     this.Type      = type;
     this.title     = title;
 }
Пример #7
0
 public Citation(List <Author> authors, string title, string year, CitationStyle style, CitationType type, Journal journal, string doi)
 {
     this.authors = authors;
     this.year    = year;
     this.Style   = style;
     this.Type    = type;
     this.title   = title;
     this.journal = journal;
     this.doi     = doi;
 }
Пример #8
0
        //
        // GET: /CitationType/Details/5

        public ActionResult Details(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, read))
            {
                return(RedirectToAction("Index", "Home"));
            }

            CitationType citationtype = db.CitationTypes.Single(c => c.ID == id && (c.IsDeleted == null || c.IsDeleted == false));

            return(View(citationtype));
        }
Пример #9
0
        //
        // GET: /CitationType/Edit/5

        public ActionResult Edit(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write))
            {
                return(RedirectToAction("Index", "Home"));
            }

            CitationType citationtype = db.CitationTypes.Single(c => c.ID == id && (c.IsDeleted == null || c.IsDeleted == false));

            ViewBag.CreatedBy  = new SelectList(db.Users, "ID", "UserName", citationtype.CreatedBy);
            ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", citationtype.ModifiedBy);
            return(View(citationtype));
        }
Пример #10
0
        protected override string InternalCitationFactory(CitationType type)
        {
            if (type == CitationType.Book)
            {
                return(InternalBookCitation());
            }
            if (type == CitationType.Article)
            {
                return(InternalArticleCitation());
            }
            //if(type == CitationType.Webpage)

            return(null);
        }
Пример #11
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, delete))
            {
                return(RedirectToAction("Index", "Home"));
            }

            CitationType citationtype = db.CitationTypes.Single(c => c.ID == id && (c.IsDeleted == null || c.IsDeleted == false));

            citationtype.ModifiedBy = Guid.Parse(Session["userid"].ToString());
            citationtype.ModifiedOn = DateTime.Now;
            citationtype.IsDeleted  = true;
            db.ObjectStateManager.ChangeObjectState(citationtype, EntityState.Modified);
            //db.CitationTypes.DeleteObject(citationtype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #12
0
 private static string TransformType(CitationType type)
 {
     return(type switch
     {
         CitationType.ArticleMagazine => "article-magazine",
         CitationType.ArticleNewspaper => "article-newspaper",
         CitationType.ArticleJournal => "article-journal",
         CitationType.EntryDictionary => "entry-dictionary",
         CitationType.EntryEncyclopedia => "entry-encyclopedia",
         CitationType.LegalCase => "legal_case",
         CitationType.MotionPicture => "motion_picture",
         CitationType.MusicalScore => "musical_score",
         CitationType.PaperConference => "paper-conference",
         CitationType.PostWeblog => "post-webblog",
         CitationType.PersonalCommunication => "personal_communication",
         CitationType.ReviewBook => "review-book",
         _ => EnumUtility.GetName(type)?.ToLowerInvariant() ?? string.Empty
     });
Пример #13
0
        public ActionResult Edit(CitationType citationtype)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                citationtype.ModifiedBy = Guid.Parse(Session["userid"].ToString());
                citationtype.ModifiedOn = DateTime.Now;
                db.CitationTypes.Attach(citationtype);
                db.ObjectStateManager.ChangeObjectState(citationtype, EntityState.Modified);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CreatedBy  = new SelectList(db.Users, "ID", "UserName", citationtype.CreatedBy);
            ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", citationtype.ModifiedBy);
            return(View(citationtype));
        }
Пример #14
0
 // TODO move to partial
 public Citation(CitationType type, string url)
 {
     Type = type;
     Url  = url;
     Name = type == CitationType.Pdf ? "Open a PDF copy" : "Citation link";
 }
Пример #15
0
 public CitationBuilder(string key, CitationType type) : this(key, TransformType(type))
 {
 }
Пример #16
0
 protected abstract string InternalCitationFactory(CitationType type);
        /// <summary>
        /// Logic used for determining the ticket a driver will recieve.
        /// </summary>
        /// <param name="driver">Driver the officer has just pulled over.</param>
        /// <returns>The citation the driver recieved.</returns>
        public Citation PullOver(string officerRank, string officerFirstName, string officerLastName, int officerBadgeId, string officerNegativeComment, string officerPositiveComment, string driverFirstName, string driverLastName, string driverAddressOne, string driverAddressTwo, string driverCity, string driverState, string driverZipCode, DateTime driverDateOfBirth, bool driverIsImpaired)
        {
            var driversSpeed      = LocalRandom.GetRandomNumber(25, 95);
            var currentSpeedLimit = LocalRandom.GetRandomNumber(25, 75);
            var officersMood      = LocalRandom.GetRandomNumber(1, 10);
            var reasonNumber      = LocalRandom.GetRandomNumber(1, 4);
            var reason            = (ViolationReason)reasonNumber;


            Citation newCitation = new Citation()
            {
                OfficerRank            = officerRank,
                OfficerFirstName       = officerFirstName,
                OfficerLastName        = officerLastName,
                OfficerBadgeId         = officerBadgeId,
                OfficerComments        = string.Empty,
                DriverFirstName        = driverFirstName,
                DriverLastName         = driverLastName,
                DriverAddressOne       = driverAddressOne,
                DriverAddressTwo       = driverAddressTwo,
                DriverCity             = driverCity,
                DriverDateOfBirth      = driverDateOfBirth,
                DriverState            = driverState,
                DriverZip              = driverZipCode,
                CurrentViolationReason = reason,
            };

            CitationType  currentCitationType  = CitationType.Warning;
            ViolationType currentViolationType = ViolationType.Moving;
            var           speeding             = ViolationReason.Speeding; // Habit since linq does not like using Violation.foo in queries.
            var           impariment           = ViolationReason.SuspicionOfImpairment;

            // Handle speeding.
            if (newCitation.CurrentViolationReason == speeding)
            {
                var speedDifference = driversSpeed - currentSpeedLimit;

                newCitation.OfficerComments += string.Format("\r\n SpeedLimit: {0} Driver Speed: {1}  Speed: {2}\r\n"
                                                             , currentSpeedLimit, driversSpeed, speedDifference < 0 ? Math.Abs(speedDifference) + " under" : speedDifference + " over");


                // Cut a break if needed.
                string comment = string.Empty;
                speedDifference              = speedDifference = CheckBirthdaySpeed.GetSpeed(currentSpeedLimit, driversSpeed, driverDateOfBirth, out comment);
                newCitation.OfficerComments += comment;


                if (speedDifference > 0)
                {
                    if (speedDifference >= 5 && speedDifference <= 10)
                    {
                        currentCitationType = CitationType.SmallTicket;
                    }
                    else if (speedDifference >= 11 && speedDifference <= 15)
                    {
                        currentCitationType = CitationType.MediumTicket;
                    }
                    else if (speedDifference >= 16)
                    {
                        currentCitationType = CitationType.BigTicket;
                    }
                }
                else
                {
                    currentCitationType  = CitationType.Warning;
                    currentViolationType = ViolationType.Moving;
                }
            }
            else if (newCitation.CurrentViolationReason == impariment)
            {
                if (driverIsImpaired)
                {
                    currentCitationType          = CitationType.Ticket;
                    currentViolationType         = ViolationType.Moving;
                    newCitation.OfficerComments += "Driver was visibly impaired. \r\n";
                }
                else
                {
                    currentCitationType          = CitationType.Warning;
                    currentViolationType         = ViolationType.Moving;
                    newCitation.OfficerComments += "Driver was not visibly impaired. \r\n";
                }
            }
            else
            {
                // Other infractions are random chance.
                if (officersMood >= 5)
                {
                    currentCitationType = CitationType.Ticket;
                }
                else
                {
                    currentCitationType = CitationType.Warning;
                }
                if (reasonNumber <= 2)
                {
                    currentViolationType = ViolationType.Moving;
                }
                else
                {
                    currentViolationType = ViolationType.NonMoving;
                }
            }

            newCitation.CurrentCitationType  = currentCitationType;
            newCitation.CurrentViolationType = currentViolationType;

            if (currentCitationType == CitationType.Warning)
            {
                newCitation.OfficerComments += officerPositiveComment;
            }
            else
            {
                newCitation.OfficerComments += officerNegativeComment;
            }

            return(newCitation);
        }
Пример #18
0
 public APACitation(List <Author> authors, string title, string year, CitationStyle style, CitationType type, Journal journal, string doi)
     : base(authors, title, year, style, type, journal, doi)
 {
 }
Пример #19
0
 public APACitation(List <Author> authors, string title, string year, Publisher publisher, CitationStyle style, CitationType type)
     : base(authors, title, year, publisher, style, type)
 {
 }
Пример #20
0
 public Citation(CitationType type, string url, string name)
 {
     Type = type;
     Url  = url;
     Name = name;
 }
Пример #21
0
 public CitationBuilder(string key, CitationType type)
 {
     citation = new Citation(key);
     citation[nameof(type)] = new TextVariable(TransformType(type));
 }