public AddJobsViewModel(ServerLib.JTypes.Server.ResponseJobClass AJob)
 {
     Job           = AJob;
     JobName       = Job.Name;
     EditAddButton = "Сохранить";
     Notify("EditAddButton");
     AddJobCommand = new SimpleCommand(EditJob);
     CancelCommand = new SimpleCommand(Cancel);
 }
示例#2
0
        /// <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);
            }
        }