Exemplo n.º 1
0
        private static Log getLog(
            LogDataContext dataContext,
            string id,
            string source)
        {
            var logFromDB =
                dataContext.Logs.Where(log => log.ID.Equals(id)).FirstOrDefault();

            if (logFromDB != null)
            {
                return(logFromDB);
            }
            var misparIshi = CurrentMisparIshi.GetCurrentMisparIshi();

            var newLog = new Log();

            newLog.TimeCreated   = DateTime.Now;
            newLog.ID            = id;
            newLog.MailSent      = 0;
            newLog.MorePressed   = 0;
            newLog.RequestsMade  = 0;
            newLog.SeeAllPressed = 0;
            newLog.Shared        = false;
            newLog.MisparIshi    = misparIshi;
            newLog.GivenName     = getGivenNameForMisparIshi(misparIshi);
            newLog.Source        = source;
            dataContext.Logs.InsertOnSubmit(newLog);
            return(newLog);
        }
Exemplo n.º 2
0
        public PersonAndTag(string misparIshi, string tag)
        {
            if (!CurrentMisparIshi.IsCurrentUserOrAdmin(misparIshi) ||
                !TagToPrimeDictionary.TAG_TO_PRIME.ContainsKey(tag))
            {
                this.isValid = false;
                return;
            }
            this.tagPrime = TagToPrimeDictionary.TAG_TO_PRIME[tag];

            this.dataContext = new PersonDataContext();

            var personsFromDb = dataContext.Persons
                                .Where(person => person.MisparIshi.Equals(misparIshi))
                                .ToList();

            if (personsFromDb.Count() != 1)
            {
                this.isValid = false;
                return;
            }

            this.personFromDb = personsFromDb.First();

            this.isValid = true;
        }
Exemplo n.º 3
0
        public static IEnumerable <object> ReportBug(string report)
        {
            var bugReport = new BugReport();

            bugReport.Report             = report;
            bugReport.ReporterMisparIshi =
                CurrentMisparIshi.GetCurrentMisparIshi();
            bugReport.TimeReported = DateTime.Now;

            var dataContext = new LogDataContext();

            dataContext.BugReports.InsertOnSubmit(bugReport);
            dataContext.SubmitChanges();

            return(new object[] { new { Success = "Yes" } });

            // TODO(Josh): Figure out why this isn't working and fix it.

            /*try
             * {
             *  Microsoft.Office.Interop.Outlook.Application app =
             *      new Microsoft.Office.Interop.Outlook.Application();
             *  Microsoft.Office.Interop.Outlook.MailItem mailItem =
             *      app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
             *  mailItem.Subject = "מערכת אנשים - Bug report";
             *  mailItem.To = "*****@*****.**";
             *  mailItem.Body = report;
             *  mailItem.Send();
             *  return new object[] { new { Success = "Yes" } };
             * }
             * catch (Exception exception)
             * {
             *  return new object[] { new { exception } };
             * }*/
        }
Exemplo n.º 4
0
 public static IEnumerable <object> GetInitialMetadata()
 {
     return(new object[] {
         new {
             is_admin = CurrentMisparIshi.IsAdmin(),
             messages = AlertGenerator.GenerateSingleAlertObject(),
             tags_to_add = TagGetter.GetTags()
         }
     });
 }
Exemplo n.º 5
0
        public static IEnumerable <object> GetTags()
        {
            var dataContext = new PersonDataContext();
            var isAdmin     = CurrentMisparIshi.IsAdmin();

            return(dataContext.TagPrimes
                   .Where(tag => tag.AllowNonAdminsToAdd || isAdmin)
                   .Select(tag => new {
                tag = tag.Tag
            })
                   .ToList());
        }
Exemplo n.º 6
0
        public static void Log(LogData logData)
        {
            if (logData.SessionId == null || logData.LogType == null)
            {
                return;
            }

            var dataContext = new LogDataContext();

            if (CurrentMisparIshi.IsSuperAdmin())
            {
                return;
            }

            var log = getLog(dataContext, logData.SessionId, logData.Source);

            switch (logData.LogType.ToLower())
            {
            case "mail":
                log.MailSent++;
                break;

            case "request":
                log.RequestsMade++;
                if (logData.Query != null)
                {
                    var request = new Request();
                    request.ID       = logData.SessionId;
                    request.Request1 = logData.Query;
                    request.Time     = DateTime.Now;
                    dataContext.Requests.InsertOnSubmit(request);
                }
                break;

            case "morepressed":
                log.MorePressed++;
                break;

            case "seeallpressed":
                log.SeeAllPressed++;
                break;

            case "shared":
                log.Shared = true;
                break;
            }
            dataContext.SubmitChanges();
        }
Exemplo n.º 7
0
        private object createMetadataObject(ITemplate template,
                                            IEnumerable <object> persons,
                                            DbRequest dbRequest, string originalInput, string translatedInput)
        {
            // TODO(josh): This is a cheating heuristic that is occasionally
            // incorrect.
            // Fix - Request one more number than you're displaying.
            var listWasCutOff =
                !dbRequest.ShouldShowAll &&
                persons.Count() == dbRequest.NumberToTake;

            return(new {
                //query = template.MetdataDisplayValue(),
                templateData = template.AddMetadata(),
                shouldShowSeeMore = listWasCutOff,
                isAdmin = CurrentMisparIshi.IsAdmin(),
                originalInput = originalInput,
                translatedInput = translatedInput,
                nonAdminsCanAddTags = false
            });
        }
Exemplo n.º 8
0
        public static void AddWhatIDo(string misparIshi, string value)
        {
            var dataContext = new PersonDataContext();

            var personsFromDb = dataContext.Persons
                                .Where(person => person.MisparIshi.Equals(misparIshi))
                                .ToList();

            if (personsFromDb.Count() != 1)
            {
                return;
            }

            var personFromDb = personsFromDb.First();

            if (!CurrentMisparIshi.IsCurrentUserOrAdmin(
                    personFromDb.MisparIshi))
            {
                return;
            }

            personFromDb.WhatIDo = value;
            dataContext.SubmitChanges();
        }
Exemplo n.º 9
0
 private bool getIsMe()
 {
     return(CurrentMisparIshi.GetCurrentMisparIshi().Equals(person.MisparIshi));
 }