Ejemplo n.º 1
0
        // GET: ChangeLogs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChangeLog changeLog = this.chlmngr.GetChangeLogsById(id);

            if (changeLog == null)
            {
                return(HttpNotFound());
            }
            return(View(changeLog));
        }
        protected override void BeginProcessing()
        {
            base.BeginProcessing();
            using (var db = new CommenceDatabase())
            {
                categoryNames = db.GetCategoryNames();
            }
            logFile = GetLogPath();

            changeLog = new ChangeLog()
            {
                Date = DateTime.Now
            };
        }
Ejemplo n.º 3
0
        protected override void NodeCreationChange(EntityChangeNodeCreation item)
        {
            IEnumerable <EntityChangeDescriptor> temp = ChangeLog.Where(p => p.Entity == item.Entity);

            if (temp.Any(p => p is EntityChangeNodeCreation == false))
            {
                throw new InvalidOperationException("Unable to schedule a node creation for an entity already tracked.");
            }

            if (!temp.Any())
            {
                ChangeLog.Add(item);
            }
        }
Ejemplo n.º 4
0
 public IActionResult Create([Bind("ID,Name,DepartmentComments,Notes,RequiresPermission,RequiresMoodle,CRN,DateArchived,DateCreated,StudentLimit," +
                                   "StartTime,EndTime,PartOfTermID,CourseID,PrimaryInstructorPercent,SecondaryInstructorPercent,ScheduleTypeID,Number" +
                                   "PrimaryInstructorID,SecondaryInstructorID,RoomID")] Section section)
 {
     if (ModelState.IsValid)
     {
         //section number isn't being passed from the form for some reason so it's being grabbed directly from the form
         section.Number             = Request.Form["Number"];
         section.AcademicSemesterID = SessionVariables.GetSessionAcademicSemester(HttpContext).ID;
         if (section.PrimaryInstructorID > 0 && section.SecondaryInstructorID > 0)
         {
             if (section.PrimaryInstructorPercent + section.SecondaryInstructorPercent != 100)
             {
                 ModelState.AddModelError("PrimaryInstructorPercent", "Percentages don't equal 100%");
                 ModelState.AddModelError("SecondaryInstructorPercent", "Percentages don't equal 100%");
                 SetUpSectionViewBags(section, true);
                 return(View(section));
             }
         }
         else
         {
             section.PrimaryInstructorPercent = 100;
         }
         section.ID = DAL.AddSection(section);
         if (section.ID > 0)
         {
             SessionVariables.SetSuccessMessage("Section created");
             if (section.Course.CrossListedCourseID > 0)
             {
                 CreateCrossListedSection(ref section);
             }
             SetUpSectionDays(section);
             SetUpSectionInstructors(section);
             ChangeLog changeLog = new ChangeLog();
             changeLog.SectionID    = section.ID;
             changeLog.DateCreated  = DateTime.Now;
             changeLog.DateDeleted  = DAL.MaximumDateTime;
             changeLog.DateImported = DAL.MinimumDateTime;
             DAL.AddChangeLog(changeLog);
         }
         else
         {
             SessionVariables.SetErrorMessage("Section create failed");
         }
         return(RedirectToAction(nameof(Index)));
     }
     SetUpSectionViewBags(section);
     return(View(section));
 }
Ejemplo n.º 5
0
        public async Task InsertBulkTestData(int integerStandard, string stringStandard, long longStandard, int?integerNullable, long?longNullable)
        {
            ICollection <ChangeLog <int> > changeLogs = new LinkedList <ChangeLog <int> >();

            for (int i = 0; i < 100; i++)
            {
                var changeLog = new ChangeLog <int>()
                {
                    ChangeLogId        = null,
                    ObjectId           = i,
                    ChangedBy          = null,
                    Property           = "integerStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = integerStandard.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem2",
                    PropertySystemType = "System.Int32"
                };
                changeLogs.Add(changeLog);
            }
            var results = await this.Store.StoreAsync(changeLogs);

            var changes = await this.Store.GetChangesAsync(null, "JSCloud.LogPlayer.Tests.SimpleItem2");

            Assert.AreEqual(results.Count, changes.Count);

            changes = await this.Store.GetChangesAsync(changeLogs.ElementAt(0).ObjectId, "JSCloud.LogPlayer.Tests.SimpleItem2");

            Assert.IsTrue(changes.Count == 1);
            Assert.AreEqual(changeLogs.ElementAt(0).ChangeLogId, changes.ElementAt(0).ChangeLogId);

            changeLogs = new LinkedList <ChangeLog <int> >();
            for (int i = 0; i < 100; i++)
            {
                var changeLog = new ChangeLog <int>()
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "integerStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = integerStandard.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int32"
                };
                changeLogs.Add(changeLog);
            }
            var resultsDifferetntType = await this.Store.StoreAsync(changeLogs);

            Assert.AreEqual(100, resultsDifferetntType.Count); //This will ensure that the types are filtered correctly
        }
Ejemplo n.º 6
0
        // 发送Insert或Delete事件类型的变更记录到指定服务的数据存储中
        private void PostRecords(List <Column> columns, Entry entry, string eventType)
        {
            _canalLogger?.LogDebug($"[{_xdpCanalOption.LogSource}]", $"### One {eventType} event on {entry.Header.SchemaName} recording.");

            StringBuilder recordBuilder = new StringBuilder();

            recordBuilder.Append("{");

            for (int i = 0; i < columns.Count; i++)
            {
                var column = columns[i];
                if (i == columns.Count - 1)
                {
                    recordBuilder.Append($"\"{column.Name}\":{column.Value ?? string.Empty}");
                }
                else
                {
                    recordBuilder.Append($"\"{column.Name}\":{column.Value ?? string.Empty},");
                }
            }

            recordBuilder.Append("}");

            List <ChangeLog> changeLogs = new List <ChangeLog>();
            ChangeLog        changeLog  = new ChangeLog
            {
                SchemaName  = entry.Header.SchemaName,
                TableName   = entry.Header.TableName,
                EventType   = entry.Header.EventType.ToString(),
                ExecuteTime = DateConvertUtil.ToDateTime(entry.Header.ExecuteTime)
            };

            switch (entry.Header.EventType)
            {
            case EventType.Insert:
                changeLog.CurrentValue = recordBuilder.ToString();
                break;

            case EventType.Delete:
                changeLog.PreviousValue = recordBuilder.ToString();
                break;
            }

            changeLogs.Add(changeLog);
            _canalRepository = CanalRepositoryFactory.GetCanalRepositoryInstance(_options);
            _canalRepository.SaveChangeHistoriesAsync(changeLogs);

            _canalLogger?.LogDebug($"[{_xdpCanalOption.LogSource}]", $"### One {eventType} event on {entry.Header.SchemaName} recorded.");
        }
Ejemplo n.º 7
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChangeLog changeLog = this.chlmngr.GetChangeLogsById(id);

            if (changeLog == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = new SelectList(db.FileReleases, "Id", "Tittle", changeLog.Id);
            return(View(changeLog));
        }
Ejemplo n.º 8
0
        public async Task <ActionResult <ProductBook> > DeleteProductBook(string id)
        {
            var productBook = await _context.ProductBooks.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "Books", productBook);

            if (productBook == null)
            {
                return(NotFound());
            }
            _context.ProductBooks.Remove(productBook);
            await _context.SaveChangesAsync();

            return(productBook);
        }
Ejemplo n.º 9
0
        public ActionResult ResetPassword(ADUser adUser, string password, string verifiedPassword)
        {
            if (adUser.ResetPassword(password, verifiedPassword, ModelState) == true)
            {
                string description = ChangeLog.PasswordReset(adUser, User, db);

                ViewBag.Description = description;

                return(View("Success"));
            }

            ViewBag.Tooltip = PowerShell.GetHTMLString("ADUsers", "PasswordPolicy", null);

            return(View(adUser));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Put(int id, [FromBody] ChangeLog obj)
        {
            try
            {
                var userContext = (PhyndUserContext)HttpContext.Items["PhyndUserContext"];
                var response    = await service.UpdateAsync(1, obj);

                return(new OkObjectResult(response));
            }
            catch (Exception ex)
            {
                logger.LogException(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 11
0
 public static void ResetData()
 {
     user               = null;
     PlayerList         = new List <Player>();
     sessionCode        = "";
     field              = null;
     log                = new ChangeLog();
     startLobby         = false;
     startGame          = false;
     lobbyStarted       = false;
     records            = new HighscoreRecords();
     sevicebusQueueLogs = new List <string>();
     sevicebusLogs      = new List <string>();
     lastSendMessage    = "";
 }
Ejemplo n.º 12
0
        public IActionResult Put([FromBody] UpdateChangeLogRequest request)
        {
            if (request == null)
            {
                return(BadRequest("Log is null."));
            }
            ChangeLog changeLogToUpdate = request.ToChangeLog();

            if (changeLogToUpdate == null)
            {
                return(NotFound("The ChangeLog  couldn't be found."));
            }
            _dataRepository.Update(changeLogToUpdate);
            return(NoContent());
        }
Ejemplo n.º 13
0
        public async Task UpdateChangeLog()
        {
            var options = TestHelper.GetDbContext("UpdateChangeLog");

            //Given
            var cl1 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "1.0", ReleaseDate = DateTime.Now.AddMonths(-2), Published = false, Log = "Log 1"
            };
            var cl2 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "2.0", ReleaseDate = DateTime.Now.AddMonths(-1), Published = false, Log = "Log 2"
            };

            using (var context = new DataContext(options))
            {
                //Jumbled order
                context.ChangeLog.Add(cl1);
                context.ChangeLog.Add(cl2);

                context.SaveChanges();
            }

            var model = new ChangeLog()
            {
                Id            = cl2.Id,
                VersionNumber = "2.1",
                ReleaseDate   = DateTime.Now.AddMonths(-3),
                Log           = "Log 2 updated",
                Published     = true
            };

            using (var context = new DataContext(options))
            {
                var service = new ChangeLogService(context);

                //When
                var result = await service.UpdateChangeLog(model);

                //Then
                Assert.True(result.Success);

                var actual = await context.ChangeLog.FindAsync(model.Id);

                Assert.Equal(model.VersionNumber, actual.VersionNumber);
                Assert.Equal(model.ReleaseDate, actual.ReleaseDate);
                Assert.Equal(model.Published, actual.Published);
                Assert.Equal(model.Log, actual.Log);
            }
        }
Ejemplo n.º 14
0
    void Update()
    {
        if (_isGameStarted)
        {
            PollMovement();
            ManageHud();
        }

        ReceiveEvent recEvent = base.Receive();

        if (recEvent.type == NetworkEventType.DataEvent)
        {
            Message message = recEvent.message;
            if (message.type == MessageType.SetUp)
            {
                SetUpMessage setupMessage = (SetUpMessage)message.GetData();
                StartGame(setupMessage.activePlayers);
            }
            else if (message.type == MessageType.StateUpdate)
            {
                ChangeLog changes = (ChangeLog)message.GetData();
                foreach (var kvp in _players)
                {
                    if (!changes.PlayerLocations.ContainsKey(kvp.Key))
                    {
                        kvp.Value.isDeadImage.SetActive(true);
                    }
                }

                foreach (var playerTransform in changes.PlayerLocations)
                {
                    CellID  playerNum = playerTransform.Key;
                    Vector2 position  = (Vector2)playerTransform.Value;
                    float   rotation  = playerTransform.Value.z;
                    _players[playerNum].playerObject.transform.position = position;
                    _players[playerNum].playerObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, rotation));
                    if (playerTransform.Key == _myPlayer)
                    {
                        Camera.main.transform.position = new Vector3(position.x, position.y, -10);
                    }
                }
                foreach (var kvp in changes.ChangedCells)
                {
                    Instantiate(_players[kvp.Value].playerTrail, new Vector2(kvp.Key.x, -kvp.Key.y), Quaternion.identity);
                }
            }
        }
    }
Ejemplo n.º 15
0
        public async Task LoadChangeLog(string entityName, int pk)
        {
            ChangeLog.Clear();

            using (var context = new NeoTrackerContext())
            {
                var logs = await context.ChangeLogs.Where(x => x.EntityName == entityName && x.PrimaryKeyValue == pk).OrderByDescending(x => x.UpdatedAt).ToListAsync();

                foreach (var log in logs.Where(x => x.PropertyName.Contains("ID")))
                {
                    switch (log.PropertyName)
                    {
                    case "StatusID":
                        //log.NewValue = !string.IsNullOrEmpty(log.NewValue) ? context.Statuses.Find(int.Parse(log.NewValue)).Name : string.Empty;
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.Statuses.Find(int.Parse(log.OldValue)).Name : string.Empty;
                        break;

                    case "ItemID":
                        //log.NewValue = !string.IsNullOrEmpty(log.NewValue) ? context.Items.Find(int.Parse(log.NewValue)).Name : string.Empty;
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.Items.Find(int.Parse(log.OldValue)).Name : string.Empty;
                        break;

                    case "UserID":
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.Users.Find(int.Parse(log.OldValue)).LongName : string.Empty;
                        break;

                    case "DepartmentID":
                        //log.NewValue = !string.IsNullOrEmpty(log.NewValue) ? context.Departments.Find(int.Parse(log.NewValue)).Name : string.Empty;
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.Departments.Find(int.Parse(log.OldValue)).Name : string.Empty;
                        break;

                    case "EventTypeID":
                        //log.NewValue = !string.IsNullOrEmpty(log.NewValue) ? context.EventTypes.Find(int.Parse(log.NewValue)).Name : string.Empty;
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.EventTypes.Find(int.Parse(log.OldValue)).Name : string.Empty;
                        break;

                    case "ProjectTypeID":
                        //log.NewValue = !string.IsNullOrEmpty(log.NewValue) ? context.ProjectTypes.Find(int.Parse(log.NewValue)).Name : string.Empty;
                        log.OldValue = !string.IsNullOrEmpty(log.OldValue) ? context.ProjectTypes.Find(int.Parse(log.OldValue)).Name : string.Empty;
                        break;

                    default:
                        break;
                    }
                }
                ChangeLog = logs;
            }
        }
Ejemplo n.º 16
0
        public async Task <ActionResult <User> > DeleteUser(Guid id)
        {
            var user = await _context.Users.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "Users", user);

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

            _context.Users.Remove(user);
            await _context.SaveChangesAsync();

            return(user);
        }
        public void doChangeLogging(string type, string username, string permission, string project_id, CookDBDataContext db)
        {
            //if (permission != "PM")
            //{
            ChangeLog newLog = new ChangeLog();

            newLog.project_id  = Convert.ToInt32(project_id);
            newLog.time        = DateTime.Now.ToShortTimeString();
            newLog.date        = DateTime.Now.ToShortDateString();
            newLog.tab         = "TLS";
            newLog.user_name   = username;
            newLog.description = "New record added to " + type + ". ";
            db.ChangeLogs.InsertOnSubmit(newLog);
            db.SubmitChanges();
            //}
        }
Ejemplo n.º 18
0
        internal static void Save(ChangeLog Log, string path)
        {
            //XmlDocument doc = new XmlDocument();
            //doc.Load(path);
            //var test = doc;



            //XmlSerializer writer = new XmlSerializer(typeof(ChangeLog.databaseChangeLog));

            //StreamWriter file = new StreamWriter(path);
            //writer.Serialize(file, Log);
            //file.Close();

            //rewrite this
        }
Ejemplo n.º 19
0
        public async Task <ActionResult <TableConsecutive> > DeleteTableConsecutive(Guid id)
        {
            var tableConsecutive = await _context.TableConsecutives.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "TableConsecutives", tableConsecutive);

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

            _context.TableConsecutives.Remove(tableConsecutive);
            await _context.SaveChangesAsync();

            return(tableConsecutive);
        }
Ejemplo n.º 20
0
        public async Task <ActionResult <SystemConfiguration> > DeleteSystemConfiguration(Guid id)
        {
            var systemConfiguration = await _context.SystemConfigurations.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "SystemConfigurations", systemConfiguration);

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

            _context.SystemConfigurations.Remove(systemConfiguration);
            await _context.SaveChangesAsync();

            return(systemConfiguration);
        }
Ejemplo n.º 21
0
        public async Task <ActionResult <ProductBookSubject> > DeleteProductBookSubject(Guid id)
        {
            var productBookSubject = await _context.ProductBookSubjects.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "BookSubjects", productBookSubject);

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

            _context.ProductBookSubjects.Remove(productBookSubject);
            await _context.SaveChangesAsync();

            return(productBookSubject);
        }
Ejemplo n.º 22
0
        public async Task <ActionResult <ProductMovieActor> > DeleteProductMovieActor(Guid id)
        {
            var productMovieActor = await _context.ProductMovieActors.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "MovieActors", productMovieActor);

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

            _context.ProductMovieActors.Remove(productMovieActor);
            await _context.SaveChangesAsync();

            return(productMovieActor);
        }
        public void MakeRoot()
        {
            T[] array = new T[Lenght];
            _base.CopyTo(array, 0);
            foreach (var changes in _changeLog.GetChanges().Reverse())
            {
                foreach ((int i, T value) in changes)
                {
                    array[i] = value;
                }
            }
            ChangeLog log = new ChangeLog(null);

            _base      = array;
            _changeLog = log;
        }
Ejemplo n.º 24
0
        public async Task <ActionResult <ProductSongGenre> > DeleteProductSongGenre(Guid id)
        {
            var productSongGenre = await _context.ProductSongGenres.FindAsync(id);

            ChangeLog.AddDeletedLog(_context, "SongGenres", productSongGenre);

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

            _context.ProductSongGenres.Remove(productSongGenre);
            await _context.SaveChangesAsync();

            return(productSongGenre);
        }
Ejemplo n.º 25
0
        public async Task <bool> UpdateAsync(int userId, ChangeLog entity)
        {
            bool retVal = false;

            try
            {
                MySqlCommand cmd = new MySqlCommand
                {
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "Proc_Reporting_UpdateChangeLog"
                };

                cmd.Parameters.AddWithValue("@p_ChangeApprovedUserId", entity.ChangeApprovedUserId);
                cmd.Parameters.AddWithValue("@p_ChangeApprovedUserName", entity.ChangeApprovedUserName);
                cmd.Parameters.AddWithValue("@p_ChangeLogId", entity.ChangeLogId);
                cmd.Parameters.AddWithValue("@p_ChangeSubmittedDate", entity.ChangeSubmittedDate);
                cmd.Parameters.AddWithValue("@p_Comments", entity.Comments);
                cmd.Parameters.AddWithValue("@p_DataSourceId", entity.DataSourceId);
                cmd.Parameters.AddWithValue("@p_EntityId", entity.EntityId);
                cmd.Parameters.AddWithValue("@p_FieldName", entity.FieldName);
                cmd.Parameters.AddWithValue("@p_HealthSystemId", entity.HealthSystemId);
                cmd.Parameters.AddWithValue("@p_HealthSystemName", entity.HealthSystemName);
                cmd.Parameters.AddWithValue("@p_IsEditedReverted", entity.IsEditedReverted);
                cmd.Parameters.AddWithValue("@p_IsResolved", entity.IsResolved);
                cmd.Parameters.AddWithValue("@p_NewValue", entity.NewValue);
                cmd.Parameters.AddWithValue("@p_OldValue", entity.OldValue);
                cmd.Parameters.AddWithValue("@p_ProviderId", entity.ProviderId);
                cmd.Parameters.AddWithValue("@p_TableName", entity.TableName);
                cmd.Parameters.AddWithValue("@p_updatedBy", entity.updatedBy);
                cmd.Parameters.AddWithValue("@p_updatedDate", entity.updatedDate);
                cmd.Parameters.AddWithValue("@p_VerificationNotRequiredFlag", entity.VerificationNotRequiredFlag);
                cmd.Parameters.AddWithValue("@p_ModifiedUserId", userId);

                using (MySqlConnection conn = GetConnection())
                {
                    cmd.Connection = conn;
                    conn.Open();
                    retVal = await cmd.ExecuteNonQueryAsync() > 0;
                }
            }
            catch (MySqlException ex)
            {
                throw new DBConcurrencyException("Optimistic Concurrency Error");
            }

            return(retVal);
        }
Ejemplo n.º 26
0
    void OnGUI()
    {
        ChangeLog myWindow = (ChangeLog)GetWindow(typeof(ChangeLog));

        myWindow.minSize = new Vector2(350, 350);
        myWindow.maxSize = myWindow.minSize;
        scrollPos        = EditorGUILayout.BeginScrollView(scrollPos, false, false);

        EditorGUILayout.Space();
        GUILayout.Label(Styles.NewIcon, Styles.centeredVersionLabel);
        EditorGUILayout.Space();

        OneDotOneFold = BeginFold("New in version 1.1.0 (February 2017)", OneDotOneFold);
        if (OneDotOneFold)
        {
            EditorGUILayout.LabelField("• Sound Support");
            EditorGUILayout.LabelField("• New speed system");
            EditorGUILayout.LabelField("• Spherical trigger zones");
            EditorGUILayout.LabelField("• Reset on leave");
            EditorGUILayout.LabelField("• Completely re-written rotation code");
            EditorGUILayout.LabelField("• Swing doors");
            EditorGUILayout.LabelField("• Improved codebase");
            EditorGUILayout.LabelField("• Bug fixes and general improvements");
            EditorGUILayout.LabelField("• New demo scene");
            EditorGUILayout.LabelField("• Reworked asset and forum page");
            EditorGUILayout.LabelField("• Migrated documentation to MkDocs");
        }
        EndFold();

        OneDotZeroFold = BeginFold("New in version 1.0.0 (July 2017)", OneDotZeroFold);
        if (OneDotZeroFold)
        {
            EditorGUILayout.LabelField("• Rotation Timeline");
            EditorGUILayout.LabelField("• Trigger Zones");
            EditorGUILayout.LabelField("• Detection Script");
            EditorGUILayout.LabelField("• 2D Support");
            EditorGUILayout.LabelField("• Support for 3rd party doors");
            EditorGUILayout.LabelField("• Readable and organized source code");
            EditorGUILayout.LabelField("• Intuitive UI");
            EditorGUILayout.LabelField("• Easy set-up process");
            EditorGUILayout.LabelField("• Documentation");
            EditorGUILayout.LabelField("• Demo scene");
        }
        EndFold();

        EditorGUILayout.EndScrollView();
    }
Ejemplo n.º 27
0
        private void SaveLog()
        {
            var now = DateTime.UtcNow;

            var entitiesToLog = ChangeTracker.Entries <IAuditedEntity>()
                                .Where(p => p.State == EntityState.Modified)
                                .ToList();

            var currentObjectValues  = new List <string>();
            var originalObjectValues = new List <object>();

            foreach (var entity in entitiesToLog)
            {
                foreach (var prop in entity.OriginalValues.PropertyNames)
                {
                    var propOriginalValue = entity.OriginalValues[prop].ToString();
                    var propCurrentValue  = entity.CurrentValues[prop].ToString();
                    if (propOriginalValue == propCurrentValue)
                    {
                        continue;
                    }
                    currentObjectValues.Add(propCurrentValue);
                    originalObjectValues.Add(propOriginalValue);
                }

                if (currentObjectValues.Count <= 0 || originalObjectValues.Count <= 0)
                {
                    continue;
                }

                var entityName          = entity.Entity.GetType().Name;
                var primaryKey          = GetPrimaryKeyValue(entity) as string;
                var currentObjectValue  = JsonConvert.SerializeObject(currentObjectValues);
                var originalObjectValue = JsonConvert.SerializeObject(originalObjectValues);

                var log = new ChangeLog
                {
                    Date          = now,
                    CurrentValue  = currentObjectValue,
                    OriginalValue = originalObjectValue,
                    Entity        = entityName,
                    PrimaryKey    = primaryKey
                };

                ChangeLogs.Add(log);
            }
        }
Ejemplo n.º 28
0
        public IActionResult DeleteConfirmed(int id, [Bind("ID,Number,DepartmentComments,Notes,RequiresPermission,RequiresMoodle,CRN,DateArchived,DateCreated,StudentLimit," +
                                                           "StartTime,EndTime,PartOfTermID,CourseID,ScheduleTypeID,PrimaryInstructorID,SectionFeeID,SecondaryInstructorID,RoomID,")] Section section)
        {
            Section sectionToDelete = DAL.GetSection(id);
            User    currentUser     = SessionVariables.GetCurrentUser(HttpContext);

            if (currentUser != null && currentUser.Role != null && currentUser.Role.Sections.CanDelete)
            {
                ChangeLog changeLog = DAL.GetChangeLogBySection(sectionToDelete);
                //checks if the section was created after the spreadsheet import
                changeLog.DateDeleted       = DateTime.Now;
                sectionToDelete.DateDeleted = DateTime.Now;
                if (changeLog.DateCreated >= changeLog.DateImported)
                {
                    //completely delete the section so it isn't put on the spreadsheet as it was created after the import
                    List <InstructorToSection> instructorToSections = DAL.GetInstructorsBySectionID(id);
                    foreach (InstructorToSection its in instructorToSections)
                    {
                        DAL.RemoveInstructorToSection(its.ID);
                    }
                    List <SectionDay> sectionDays = DAL.GetSectionDaysBySectionID(id);
                    foreach (SectionDay sd in sectionDays)
                    {
                        DAL.RemoveSectionDay(sd.ID);
                    }
                    ChangeLog changeLogToDelete = DAL.GetChangeLogBySection(section);
                    DAL.RemoveChangeLog(changeLogToDelete);
                    DAL.RemoveSection(section);
                }
                int updatedChangelog = DAL.UpdateChangeLog(changeLog);
                int updatedSection   = DAL.UpdateSection(sectionToDelete);
                if (updatedChangelog >= 0 && updatedSection >= 0)
                {
                    SessionVariables.SetSuccessMessage("Section deleted");
                }
                else
                {
                    SessionVariables.SetErrorMessage("Section delete failed");
                }
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                SessionVariables.SetErrorMessage("You do not have permission to delete sections");
                return(RedirectToAction("Index"));
            }
        }
        private async Task CreateNewChangeLog(string path)
        {
            VersionController newVC = new VersionController("0", new FileSystemProvider(path));
            ChangeLog         newCL = new ChangeLog(newVC, new List <VersionRef>());

            MainWindow.GetInstance().VersionController = newVC;
            bool seriallizeWorked = await newVC.Serialize(newCL);

            if (!seriallizeWorked)
            {
                MessageBox.Show("The selected directory was not empty!", "New ChangeLog Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                ContentArea.GetInstance().OpenPage(ContentArea.PageType.Empty);
                return;
            }

            ContentArea.GetInstance().OpenPage(ContentArea.PageType.ChangeLog);
        }
Ejemplo n.º 30
0
        public async Task InsertSingleTestData(int integerStandard, string stringStandard, long longStandard, int?integerNullable, long?longNullable)
        {
            var changeLog = new ChangeLog <int>()
            {
                ChangeLogId        = null,
                ObjectId           = 1,
                ChangedBy          = null,
                Property           = "integerStandard",
                ChangedUtc         = DateTime.UtcNow,
                Value              = integerStandard.ToString(),
                FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                PropertySystemType = "System.Int32"
            };
            var result = await this.Store.StoreAsync(changeLog);

            Assert.IsTrue(result.ChangeLogId.HasValue);
        }
Ejemplo n.º 31
0
        public static ChangeLog GetCamlChangeLog(this XElement xmlNode)
        {
            ChangeLog log = new ChangeLog(
                xmlNode.Elements(xmlNode.GetDefaultNamespace() + "Id").Select(c => c.GetCamlChangeItem())
                );

            log.MoreChanges = xmlNode.AttributeBoolOrFalse("MoreChanges");
            log.NextLastChangeToken = xmlNode.AttributeValueOrDefault("LastChangeToken");

            XElement newListDef = xmlNode.Element(xmlNode.GetDefaultNamespace() + "List");

            if (newListDef != null)
                log.NewListDef = newListDef.GetCamlListDef();
            else
                log.NewListDef = null;

            return log;
        }
Ejemplo n.º 32
0
 public static void LogLastChange(ChangeLog entry) {
   if (LastChanges.Count >= 100) {
     ChangeLog temp;
     LastChanges.TryDequeue(out temp);
   }
   LastChanges.Enqueue(entry);
 }
Ejemplo n.º 33
0
 public void SaveChangeLog(ChangeLog changeLog)
 {
     context.ChangeLogs.Add(changeLog);
     context.SaveChanges();
 }
Ejemplo n.º 34
0
        private void Audit(CostProfitCenter c, DateTime stamp)
        {
            var query = from p in context.ApplicationTableFields
                        where p.IsDeleted == false && p.ApplicationTableID == 11 && p.IsAudited == true
                        orderby p.Description
                        select p;

            foreach (var item in query)
            {
                ApplicationTableField f = context.ApplicationTableFields.Find(item.ApplicationTableFieldID);

                ChangeLog cl = new ChangeLog();
                cl.ApplicationTableFieldID = item.ApplicationTableFieldID;
                cl.RecordID = c.CostProfitCenterID;
                cl.ChangeMade = stamp;
                cl.UserName = "******";
                cl.BeforeValue = "NewRecord";

                switch (f.Description)
                {
                    case "Description":
                        cl.AfterValue = c.Description;
                        break;
                    case "IsCostCenter":
                        cl.AfterValue = c.IsCostCenter.ToString();
                        break;
                }
                IChangeLogRepository repo = new EFChangeLogRepository();
                repo.SaveChangeLog(cl);
            }
        }