Inheritance: IdentifiedEntity
        private SelectServiceButton[] CreateControlsForGroupsAndSituations(LifeSituationGroup[] groups, LifeSituation[] 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) => SetSelectedLifeSituation(service)
                    ));
                }
            }

            return buttons.ToArray();
        }
Ejemplo n.º 2
0
        private async void loadGroup(TreeNodeCollection nodes, LifeSituationGroup group = null)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    var serviceGroups = group != null
                        ? await taskPool.AddTask(channel.Service.GetGroups(group.Id))
                        : await taskPool.AddTask(channel.Service.GetRootGroups());

                    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.GetLifeSituations(group.Id))
                        : await taskPool.AddTask(channel.Service.GetRootLifeSituations());

                    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);
                }
            }
        }
Ejemplo n.º 3
0
        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.GetGroup(parenGrouptId));
                    }

                    if (groupId != Guid.Empty)
                    {
                        Group = await taskPool.AddTask(channel.Service.GetGroup(groupId));
                    }
                    else
                    {
                        Group = new LifeSituationGroup()
                        {
                            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);
                }
            }
        }
Ejemplo n.º 4
0
        private async void saveButton_Click(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    saveButton.Enabled = false;

                    group = await taskPool.AddTask(channel.Service.EditGroup(group));
                    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;
                }
            }
        }
Ejemplo n.º 5
0
        private async void EditLifeSituationForm_Load(object sender, EventArgs e)
        {
            using (var channel = ChannelManager.CreateChannel())
            {
                try
                {
                    Enabled = false;

                    if (groupId != Guid.Empty)
                    {
                        group = await taskPool.AddTask(channel.Service.GetGroup(groupId));
                    }

                    if (lifeSituationId != Guid.Empty)
                    {
                        LifeSituation = await taskPool.AddTask(channel.Service.GetLifeSituation(lifeSituationId));
                    }
                    else
                    {
                        LifeSituation = new LifeSituation()
                        {
                            IsActive = true,
                            LifeSituationGroup = group,
                            Code = "0.0",
                            Name = "Новая жизненная ситуация",
                            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 void OnServiceGroupSelected(LifeSituationGroup group)
 {
     LoadGroup(group.Id, group.Columns, group.Rows);
 }