Inheritance: IdentifiedEntity
Beispiel #1
0
        private async Task<Service[]> getServices(ServiceGroup serviceGroup = null)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                var serviceGroups = serviceGroup != null
                    ? await taskPool.AddTask(channel.Service.GetServiceGroups(serviceGroup.Id))
                    : await taskPool.AddTask(channel.Service.GetRootServiceGroups());

                var services = new List<Service>();

                foreach (var g in serviceGroups)
                {
                    services.AddRange(await getServices(g));
                }

                if (serviceGroup != null)
                {
                    services.AddRange(await taskPool.AddTask(channel.Service.GetServices(serviceGroup.Id)));
                }
                else
                {
                    services.AddRange(await taskPool.AddTask(channel.Service.GetRootServices()));
                }

                return services.ToArray();
            }
        }
        private SelectServiceButton[] CreateControlsForGroupsAndServices(ServiceGroup[] groups, Service[] services)
        {
            var buttons = new List<SelectServiceButton>();
            if (groups != null)
            {
                foreach (var group in groups.Where(g => g.IsActive))
                {
                    buttons.Add(CreateSelectServiceButton(group.Code, group.Name, group.Color, group.FontSize, (s, a) => OnServiceGroupSelected(group)));
                }
            }
            if (services != null)
            {
                foreach (var service in services.Where(s => s.IsActive))
                {
                    buttons.Add(CreateSelectServiceButton(service.Code,
                                                        service.Name,
                                                        service.GetColor(),
                                                        service.FontSize,
                                                        (s, a) => SetSelectedService(service)
                    ));
                }
            }

            return buttons.ToArray();
        }
Beispiel #3
0
        private async void loadGroup(TreeNodeCollection nodes, ServiceGroup group = null)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    var serviceGroups = group != null
                        ? await taskPool.AddTask(channel.Service.GetServiceGroups(group.Id))
                        : await taskPool.AddTask(channel.Service.GetRootServiceGroups());

                    foreach (var g in serviceGroups)
                    {
                        var node = new TreeNode()
                        {
                            Text = g.ToString(),
                            Checked = g.IsActive,
                            Tag = g
                        };

                        node.Nodes.Add(new TreeNode("загрузка...") { Tag = g });
                        nodes.Add(node);
                    }

                    var services = group != null
                        ? await taskPool.AddTask(channel.Service.GetServices(group.Id))
                        : await taskPool.AddTask(channel.Service.GetRootServices());

                    foreach (var s in services)
                    {
                        var node = new TreeNode()
                        {
                            Text = s.ToString(),
                            Checked = s.IsActive,
                            Tag = s
                        };
                        nodes.Add(node);
                    }

                    if (group != null)
                    {
                        nodes.RemoveAt(0);
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
            }
        }
 private void OnServiceGroupSelected(ServiceGroup group)
 {
     LoadServiceGroup(group.Id, group.Columns, group.Rows);
 }
        private async void ServiceGroupEdit_Load(object sender, EventArgs e)
        {
            Enabled = false;

            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    if (parenGrouptId != Guid.Empty)
                    {
                        parentGroup = await taskPool.AddTask(channel.Service.GetServiceGroup(parenGrouptId));
                    }

                    if (serviceGroupId != Guid.Empty)
                    {
                        ServiceGroup = await taskPool.AddTask(channel.Service.GetServiceGroup(serviceGroupId));
                    }
                    else
                    {
                        ServiceGroup = new ServiceGroup()
                        {
                            IsActive = true,
                            ParentGroup = parentGroup,
                            Code = "0.0",
                            Name = "Новая группа услуг",
                            Columns = 2,
                            Rows = 5,
                            Color = "#FFFFFF",
                            FontSize = 1
                        };
                    }

                    Enabled = true;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
            }
        }
        private async void saveButton_Click(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    saveButton.Enabled = false;

                    ServiceGroup = await taskPool.AddTask(channel.Service.EditServiceGroup(serviceGroup));

                    if (Saved != null)
                    {
                        Saved(this, EventArgs.Empty);
                    }
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
                finally
                {
                    saveButton.Enabled = true;
                }
            }
        }
Beispiel #7
0
        private async void EditServiceForm_Load(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    Enabled = false;

                    if (serviceGroupId != Guid.Empty)
                    {
                        serviceGroup = await taskPool.AddTask(channel.Service.GetServiceGroup(serviceGroupId));
                    }

                    if (serviceId != Guid.Empty)
                    {
                        Service = await taskPool.AddTask(channel.Service.GetService(serviceId));
                    }
                    else
                    {
                        var all = ClientRequestRegistrator.Terminal
                            | ClientRequestRegistrator.Manager
                            | ClientRequestRegistrator.Portal;

                        Service = new Service()
                        {
                            IsActive = true,
                            ServiceGroup = serviceGroup,
                            Code = "0.0",
                            Name = "Новая услуга",
                            LiveRegistrator = all,
                            EarlyRegistrator = all,
                            TimeIntervalRounding = TimeSpan.FromMinutes(5),
                            MaxSubjects = 5,
                            Color = "#FFFFFF",
                            FontSize = 1
                        };
                    }

                    Enabled = true;
                }
                catch (OperationCanceledException) { }
                catch (CommunicationObjectAbortedException) { }
                catch (ObjectDisposedException) { }
                catch (InvalidOperationException) { }
                catch (FaultException exception)
                {
                    UIHelper.Warning(exception.Reason.ToString());
                }
                catch (Exception exception)
                {
                    UIHelper.Warning(exception.Message);
                }
            }
        }
            private async Task<Guid[]> GetGroupServices(Channel<IServerTcpService> channel, ServiceGroup group)
            {
                var result = new List<Guid>();

                result.AddRange((await form.taskPool.AddTask(channel.Service.GetServices(Group.Id))).Select(s => s.Id));

                foreach (var child in await form.taskPool.AddTask(channel.Service.GetServiceGroups(Group.Id)))
                {
                    result.AddRange(await GetGroupServices(channel, child));
                }

                return result.ToArray();
            }
            public ServiceGroupTreeNode(ServiceRatingReportForm form, ServiceGroup group)
            {
                this.form = form;

                Group = group;
                Text = group.ToString();
                Checked = group.IsActive;

                Nodes.Add(new TreeNode("загрузка..."));
                IsLoaded = false;
            }