Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Event             = new BllEvent();
            Event.Name        = textBox1.Text;
            Event.FilepathLib = new BllFilepathLib();
            try
            {
                UploadFiles(Event.FilepathLib);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            Event.Type         = Sender.EventTypeLib.SelectedEntities[comboBox2.SelectedIndex].Entity;
            Event.Description  = richTextBox1.Text;
            Event.StatusLib    = new BllStatusLib();
            Event.AttributeLib = new BllAttributeLib();
            foreach (var item in checkedListBox1.CheckedIndices.Cast <int>().ToArray())
            {
                Event.AttributeLib.SelectedEntities.Add(new BllSelectedEntity <BllAttribute>()
                {
                    Entity = Attributes[item]
                });
            }
            Event.RecieverLib = new BllUserLib();
            Event.RecieverLib.SelectedEntities.Add(new BllSelectedUser {
                Entity = Sender, IsEventAccepted = true
            });
            int nodeCount = 0;

            AppConfigManager.ClearTagValues(Event.Type.Id.ToString());
            foreach (TreeNode groupNode in treeView1.Nodes)
            {
                if (groupNode.Checked)
                {
                    SaveUserNodeAccordingEventTypeInConfig(groupNode.Text);
                }
                foreach (TreeNode userNode in groupNode.Nodes)
                {
                    if (userNode.Checked)
                    {
                        Event.RecieverLib.SelectedEntities.Add(new BllSelectedUser {
                            Entity = Users[userNode.Index + nodeCount]
                        });
                        SaveUserNodeAccordingEventTypeInConfig(userNode.Text);
                    }
                }
                nodeCount += groupNode.GetNodeCount(false);
            }

            Event.Sender = this.Sender;
            try
            {
                IEventCRUD eventCRUD = new EventCRUD(serverInstance.server);
                Event = eventCRUD.CreateAndSendOutEvent(Event);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //ConnectToServerUsingParent();
            }
        }