/// <summary> /// Обновление данных /// </summary> public override void RefreshData() { ServerLib.JTypes.Server.ResponseUsersClass OutputList = new ServerLib.JTypes.Server.ResponseUsersClass(); DatabaseParameterValuesClass Params = new DatabaseParameterValuesClass(); Params.CreateParameterValue("Token", UserSession.Login.Token); DatabaseTableClass ReadTable = new DatabaseTableClass { Table = (System.Data.DataTable)UserSession.Project.Database.Execute("Users", ref Params) }; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { ServerLib.JTypes.Server.ResponseUserClass Item = new ServerLib.JTypes.Server.ResponseUserClass { ID = ReadTable.AsInt64(row, "ID"), Login = ReadTable.AsString(row, "LOGIN"), FirstName = ReadTable.AsString(row, "FIRST_NAME"), LastName = ReadTable.AsString(row, "LAST_NAME"), MidleName = ReadTable.AsString(row, "MIDLE_NAME"), JobID = ReadTable.AsInt64(row, "POSITION_ID"), JobName = ReadTable.AsString(row, "POSITION"), Active = (UserActive)ReadTable.AsInt32(row, "ACTIVE") }; if (ReadCollection.TryGetValue(Item.ID, out ServerLib.JTypes.Server.ResponseUserClass ExistItem)) { if (ExistItem.Hash != Item.Hash) { Item.Command = ItemCommands.edit; ReadCollection.TryUpdate(Item.ID, Item, ExistItem); OutputList.Items.Add(Item); } } else { Item.Command = ItemCommands.add; ReadCollection.TryAdd(Item.ID, Item); OutputList.Items.Add(Item); } } foreach (System.Collections.Generic.KeyValuePair <long, ServerLib.JTypes.Server.ResponseUserClass> Item in ReadCollection) { bool IsExist = false; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { if (Item.Value.ID == ReadTable.AsInt64(row, "ID")) { IsExist = true; break; } } if (!IsExist) { Item.Value.Command = ItemCommands.delete; OutputList.Items.Add(Item.Value); ReadCollection.TryRemove(Item.Value.ID, out ServerLib.JTypes.Server.ResponseUserClass DeletingUser); } } if (OutputList.Items.Count > 0) { UserSession.OutputQueueAddObject(OutputList); } }
/// <summary> /// Обновление данных /// </summary> public override void RefreshData() { ServerLib.JTypes.Server.ResponseRolesObjectsClass OutputList = new ServerLib.JTypes.Server.ResponseRolesObjectsClass(); DatabaseParameterValuesClass Params = new DatabaseParameterValuesClass(); Params.CreateParameterValue("Token", UserSession.Login.Token); DatabaseTableClass ReadTable = new DatabaseTableClass { Table = (System.Data.DataTable)UserSession.Project.Database.Execute("RolesObjects", ref Params) }; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { ServerLib.JTypes.Server.ResponseRoleObjectClass Item = new ServerLib.JTypes.Server.ResponseRoleObjectClass { ID = ReadTable.AsInt64(row, "ID"), RoleID = ReadTable.AsInt64(row, "ROLE_ID"), ObjectID = ReadTable.AsInt64(row, "OBJECT_ID"), OperationRead = ReadTable.AsInt64(row, "OPERATION_READ") == 1, OperationAdd = ReadTable.AsInt64(row, "OPERATION_ADD") == 1, OperationEdit = ReadTable.AsInt64(row, "OPERATION_EDIT") == 1, OperationDelete = ReadTable.AsInt64(row, "OPERATION_DELETE") == 1 }; if (ReadCollection.TryGetValue(Item.ID, out ServerLib.JTypes.Server.ResponseRoleObjectClass ExistItem)) { if (ExistItem.Hash != Item.Hash) { Item.Command = ItemCommands.edit; ReadCollection.TryUpdate(Item.ID, Item, ExistItem); OutputList.Items.Add(Item); } } else { Item.Command = ItemCommands.add; ReadCollection.TryAdd(Item.ID, Item); OutputList.Items.Add(Item); } } foreach (System.Collections.Generic.KeyValuePair <long, ServerLib.JTypes.Server.ResponseRoleObjectClass> Item in ReadCollection) { bool IsExist = false; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { if (Item.Key == ReadTable.AsInt64(row, "ID")) { IsExist = true; break; } } if (!IsExist) { Item.Value.Command = ItemCommands.delete; OutputList.Items.Add(Item.Value); ReadCollection.TryRemove(Item.Value.ID, out ServerLib.JTypes.Server.ResponseRoleObjectClass DeletingItem); } } if (OutputList.Items.Count > 0) { UserSession.OutputQueueAddObject(OutputList); } }
/// <summary> /// Обновление данных /// </summary> public override void RefreshData() { ServerLib.JTypes.Server.ResponseJobsClass OutputList = new ServerLib.JTypes.Server.ResponseJobsClass(); DatabaseParameterValuesClass Params = new DatabaseParameterValuesClass(); Params.CreateParameterValue("Token", UserSession.Login.Token); DatabaseTableClass ReadTable = new DatabaseTableClass { Table = (System.Data.DataTable)UserSession.Project.Database.Execute("Jobs", ref Params) }; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { ServerLib.JTypes.Server.ResponseJobClass Item = new ServerLib.JTypes.Server.ResponseJobClass { ID = ReadTable.AsInt64(row, "ID"), Name = ReadTable.AsString(row, "JOB_NAME") }; if (JobsCollection.TryGetValue(Item.ID, out ServerLib.JTypes.Server.ResponseJobClass ExistItem)) { if (ExistItem.Hash != Item.Hash) { Item.Command = ItemCommands.edit; JobsCollection.TryUpdate(Item.ID, Item, ExistItem); OutputList.Jobs.Add(Item); } } else { Item.Command = ItemCommands.add; JobsCollection.TryAdd(Item.ID, Item); OutputList.Jobs.Add(Item); } } foreach (System.Collections.Generic.KeyValuePair <long, ServerLib.JTypes.Server.ResponseJobClass> Item in JobsCollection) { bool IsExist = false; foreach (System.Data.DataRow row in ReadTable.Table.Rows) { if (Item.Value.ID == ReadTable.AsInt64(row, "ID")) { IsExist = true; break; } } if (!IsExist) { Item.Value.Command = ItemCommands.delete; OutputList.Jobs.Add(Item.Value); JobsCollection.TryRemove(Item.Value.ID, out ServerLib.JTypes.Server.ResponseJobClass DeletingItem); } } if (OutputList.Jobs.Count > 0) { UserSession.OutputQueueAddObject(OutputList); } }