Ejemplo n.º 1
0
        /// <summary>
        /// This method reload the values of a DataSet that was previously created.
        /// </summary>
        /// <param name="treeDataSet">
        /// TreeNode of the selected DataSet.
        /// </param>
        /// <param name="sCL">
        /// sCL object that contains the data assigned to the selected DataSet.
        /// </param>
        public void ReloadDataSet(TreeNode treeDataSet, SCL sCL)
        {
            this.bandModify = true;
            this.scl        = sCL;
            this.treeSCL    = treeDataSet;
            tDataSet dataSetSCLDestiny = (tDataSet)treeDataSet.Tag;
            tDataSet dataSetSCLSource;

            this.NameTextBox.Text = dataSetSCLDestiny.name;
            this.DescTextBox.Text = dataSetSCLDestiny.desc;
            this.anyLN            = this.treeViewSCL.SearchUPForBaseTypeAndGetSCLTreeNode(treeDataSet, typeof(tAnyLN)).Tag;
            DataSet dataSet = new DataSet();

            this.node = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(treeDataSet, typeof(tLDevice));
            if (this.node != null)
            {
                this.Name = "ldInst" + (node.Tag as tLDevice).inst;
                if (this.anyLN is tLN)
                {
                    this.LNtypeLabel.Text = ((anyLN as tLN).prefix + (anyLN as tLN).lnClass + (anyLN as tLN).inst);
                    dataSetSCLSource      = dataSet.GetLNFCDAs(node.Tag as tLDevice, this.anyLN as tLN, this.scl.DataTypeTemplates);
                }
                else
                {
                    this.LNtypeLabel.Text = ((anyLN as LN0).lnClass + (anyLN as LN0).inst);
                    dataSetSCLSource      = dataSet.GetLN0FCDAs(node.Tag as tLDevice, this.anyLN as LN0, this.scl.DataTypeTemplates);
                }
                for (int x = 0, y = 0; dataSetSCLSource != null && dataSetSCLSource.FCDA != null && x < dataSetSCLSource.FCDA.Length; x++)
                {
                    if (dataSetSCLDestiny != null && dataSetSCLDestiny.FCDA != null && y < dataSetSCLDestiny.FCDA.Length && this.objectManagement.Compare(dataSetSCLSource.FCDA[x], dataSetSCLDestiny.FCDA[y]))
                    {
                        this.DestinyDataSetListBox.Items.Add(new FCDAListBox(dataSetSCLDestiny.FCDA[y], (this.anyLN as tAnyLN).lnType));
                        y++;
                    }
                    else
                    {
                        this.SourceDataSetListBox.Items.Add(new FCDAListBox(dataSetSCLSource.FCDA[x], (this.anyLN as tAnyLN).lnType));
                    }
                }
            }
            else
            {
                this.LNtypeLabel.Text = ((anyLN as tLN).prefix + (anyLN as tLN).lnClass + (anyLN as tLN).inst);
                dataSetSCLSource      = dataSet.GetLNFCDAs(null, this.anyLN as tLN, this.scl.DataTypeTemplates);
                for (int x = 0, y = 0; dataSetSCLSource != null && dataSetSCLSource.FCDA != null && x < dataSetSCLSource.FCDA.Length; x++)
                {
                    if (dataSetSCLDestiny != null && dataSetSCLDestiny.FCDA != null && y < dataSetSCLDestiny.FCDA.Length && this.objectManagement.Compare(dataSetSCLSource.FCDA[x], dataSetSCLDestiny.FCDA[y]))
                    {
                        this.DestinyDataSetListBox.Items.Add(new FCDAListBox(dataSetSCLDestiny.FCDA[y], (this.anyLN as tAnyLN).lnType));
                        y++;
                    }
                    else
                    {
                        this.SourceDataSetListBox.Items.Add(new FCDAListBox(dataSetSCLSource.FCDA[x], (this.anyLN as tAnyLN).lnType));
                    }
                }
            }
            this.SourceDataSetListBox.DisplayMember  = "DisplayFCDA";
            this.DestinyDataSetListBox.DisplayMember = "DisplayFCDA";
        }
Ejemplo n.º 2
0
        public void CreateIED(SCL sCL, TreeNode nodeSCL)
        {
            tIED iED = new tIED();

            iED.configVersion = "0";
            this.objectManagement.AddObjectToArrayObjectOfParentObject(iED, sCL);
            tAccessPoint accessPoint = new tAccessPoint();

            this.objectManagement.AddObjectToArrayObjectOfParentObject(accessPoint, iED);
            accessPoint.Server = new tServer();
            accessPoint.Server.Authentication = new tServerAuthentication();
            tLDevice lDevice = new tLDevice();

            this.objectManagement.AddObjectToArrayObjectOfParentObject(lDevice, accessPoint.Server);
            lDevice.LN0 = new LN0();
            tLN lN = new tLN();

            lN.lnType  = "LPHD1";
            lN.inst    = 1;
            lN.lnClass = tLNClassEnum.LPHD.ToString();
            lDevice.AddLN(lN);

            this.treeViewSCL.GetNodesItemOfArray(sCL.IED, sCL.GetType(),
                                                 nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]);
            this.CreatingDependenciesLN(sCL, sCL.IED[sCL.IED.Length - 1].AccessPoint[0].Server
                                        .LDevice[0].LN0, nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]
                                        .Nodes["tIED[]"].Nodes[sCL.IED.Length - 1].Nodes["tAccessPoint[]"]
                                        .Nodes[0].Nodes["tServer"].Nodes["tLDevice[]"].Nodes[0].Nodes["LN0"]);
            this.CreatingDependenciesLN(sCL, sCL.IED[sCL.IED.Length - 1].AccessPoint[0].Server
                                        .LDevice[0].LN[0], nodeSCL.TreeView.Nodes["root"].Nodes["SCL"]
                                        .Nodes["tIED[]"].Nodes[sCL.IED.Length - 1].Nodes["tAccessPoint[]"]
                                        .Nodes[0].Nodes["tServer"].Nodes["tLDevice[]"].Nodes[0].Nodes["tLN[]"].Nodes[0]);
        }
Ejemplo n.º 3
0
        private void CreatingDependenciesLN(SCL sCL, tAnyLN anyLN, TreeNode nodeAnyLN)
        {
            bool band = false;
            int  i    = 0;

            for (; sCL.DataTypeTemplates != null && sCL.DataTypeTemplates.LNodeType != null && i < sCL.DataTypeTemplates.LNodeType.Length; i++)
            {
                if (sCL.DataTypeTemplates.LNodeType[i].id.Equals(anyLN.lnType))
                {
                    band = true;
                    break;
                }
            }
            //Español: Se hace un cargado de los valore que conforman al LNodeType 20/11/2009
            if (band)
            {
                TreeViewLNType treeViewLNType = new TreeViewLNType(nodeAnyLN, sCL);
                treeViewLNType.ReloadLNType(anyLN);
                treeViewLNType.EmptyTreeNodeLNType(false);
            }
            //Español: Se hace una creación de los valore que conforman al LNodeType 20/11/2009
            else
            {
                TreeViewLNType treeViewLNType = new TreeViewLNType(nodeAnyLN, sCL);
                treeViewLNType.GetTreeNodeTypesLNs(anyLN);
                treeViewLNType.EmptyTreeNodeLNType(false);
            }
        }
 /// <summary>
 /// This is a constructor method that displays a dialog box to provide
 /// communication configuration.
 /// </summary>
 /// <param name="treeSCL">
 /// Reference of a treeNode to the selected node in the treeview.
 /// </param>
 /// <param name="sCL"></param>
 /// <param name="iedName">
 /// IED's name that will configure his communication parameters.
 /// </param>
 /// <param name="apName">
 /// Access point name that will contain the subnetwork configured.
 /// </param>
 /// <param name="objFound">
 /// Contains a previous subnetwork's configuration of the IED selected.
 /// </param>
 public CommunicationDialog(TreeNode treeSCL, SCL sCL, string iedName, string apName, TreeNode objFound)
 {
     InitializeComponent();
     this.treeSCL = treeSCL;
     this.scl     = sCL;
     this.iedName = iedName;
     this.apName  = apName;
     if (this.scl.Communication != null && this.scl.Communication.SubNetwork != null)
     {
         for (int i = 0; i < this.scl.Communication.SubNetwork.Length; i++)
         {
             this.nameSubNetCB.Items.AddRange(new object[] { this.scl.Communication.SubNetwork[i].name });
             if (objFound != null)
             {
                 if (this.objectManagement.FindVariable(objFound.Parent.Parent.Tag, "name").ToString() == this.scl.Communication.SubNetwork[i].name)
                 {
                     this.nameSubNetCB.SelectedIndex = i;
                     this.descSubNet.Text            = this.objectManagement.FindVariable(objFound.Parent.Parent.Tag, "desc").ToString();
                 }
             }
             else
             {
                 this.nameSubNetCB.SelectedIndex = 0;
             }
         }
     }
     loadValues(objFound);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// This method allows to create a new item of the history to identify when the file of an IED was imported.
        /// </summary>
        /// <param name="treeViewProject">
        /// TreeView of the main SCL where the new nodes of the History will be insert.
        /// </param>
        /// <param name="objectSCLProject">
        /// SCL object of the project file.
        /// </param>
        public void CreateHistory(TreeView treeViewProject, SCL objectSCLProject)
        {
            TreeViewSCL treeViewSCL = new TreeViewSCL();
            TreeNode    sCLObject;

            if (objectSCLProject.Header == null)
            {
                objectSCLProject.Header = new tHeader();
            }
            HistoryDialog historyDlg = new HistoryDialog(objectSCLProject.Header);

            historyDlg.ShowDialog();
            if (historyDlg.DialogResult == DialogResult.OK)
            {
                sCLObject = treeViewProject.Nodes["root"].Nodes["SCL"].Nodes["tHeader"];
                if (sCLObject == null)
                {
                    treeViewSCL.GetNodes(objectSCLProject.Header, treeViewProject.Nodes["root"].Nodes["SCL"]);
                }
                else
                {
                    treeViewSCL.GetNodesItemOfArray(objectSCLProject.Header.History, objectSCLProject.Header.GetType(), sCLObject);
                }
            }
            historyDlg.Dispose();
        }
Ejemplo n.º 6
0
//		void HandleAttrNamehandleKeyPress (object sender, System.EventArgs e)
//		{
//			if (e.KeyCode == Keys.Enter) {
//				this.ChangeAttrName();
//			}
//		}

//		void HandleAttrValuehandleKeyPress (object sender, System.EventArgs e)
//		{
//			if (e.KeyCode == Keys.Enter) {
//				this.ChangeAttrValue();
//			}
//		}

        public static void AddNameSpace(SCL scl, ComboBox nameSpaceList)
        {
            EditDialog dlg = new EditDialog(scl);

            dlg.Text = "Add new Name Space";
            dlg.L1   = "Name:";
            dlg.L2   = "URI:";
            DialogResult res = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (scl.xmlns == null)
                {
                    scl.xmlns = new System.Xml.Serialization.XmlSerializerNamespaces();
                }
                scl.xmlns.Add(dlg.T1, dlg.T2);
                nameSpaceList.Items.Clear();
                for (int i = 0; i < scl.xmlns.ToArray().GetLength(0); i++)
                {
                    nameSpaceList.Items.Add("xmlns:"
                                            + scl.xmlns.ToArray()[i].Name + "="
                                            + scl.xmlns.ToArray()[i].Namespace);
                }
            }
        }
Ejemplo n.º 7
0
 public CustomAttributeDialog(SCL scl, tBaseElement element)
 {
     this.xmldoc = new System.Xml.XmlDocument();              // FIXME: May adding a representation of the
     // xml file in memory could add new attributes
     this.scl     = scl;
     this.element = element;
     this.InitializeComponent();
 }
Ejemplo n.º 8
0
 internal V_SCL(SeamlessViewsContext Context, SCL SCL)
     : base(Context)
 {
     _SCLKEY    = SCL.SCLKEY;
     _SUBJECT   = SCL.SUBJECT;
     _CLASS     = SCL.CLASS;
     _TEACHER01 = SCL.TEACHER01;
     _ROOM01    = SCL.ROOM01;
 }
Ejemplo n.º 9
0
 public EditDialog(SCL scl, string[] namespaces)
 {
     if (namespaces != null)
     {
         this.ns = new System.String[namespaces.Length];
         namespaces.CopyTo(this.ns, 0);
     }
     this.scl = scl;
     this.InitializeComponent();
 }
Ejemplo n.º 10
0
        public void DeleteBook(SCL.Book book)
        {
            string query = "delete from BooksTable where BookId=" + book.Id;

            sqlConnection.Open();
            SqlCommand cmd = new SqlCommand(query, sqlConnection);
            cmd.ExecuteNonQuery();

            cmd.Dispose();
            sqlConnection.Close();
        }
Ejemplo n.º 11
0
        public void CreatetLNode(TreeNode treeSCL, SCL sCLObject)
        {
            this.treeSCL = treeSCL;
            this.scl     = sCLObject;
            this.nodeSCL = sCLObject;

            if (this.scl.IED != null)
            {
                for (int a = 0; a < this.scl.IED.Length; a++)
                {
                    if (this.scl.IED[a].AccessPoint != null)
                    {
                        for (int b = 0; b < this.scl.IED[a].AccessPoint.Length; b++)
                        {
                            if (this.scl.IED[a].AccessPoint[b].Server != null)
                            {
                                for (int c = 0; c < this.scl.IED[a].AccessPoint[b].Server.LDevice.Length; c++)
                                {
                                    if (this.scl.IED[a].AccessPoint[b].Server.LDevice[c].LN != null)
                                    {
                                        for (int d = 0; d < this.scl.IED[a].AccessPoint[b].Server.LDevice[c].LN.Length; d++)
                                        {
                                            this.LNodeSCL         = new tLNode();
                                            this.LNodeSCL.ldInst  = this.scl.IED[a].AccessPoint[b].Server.LDevice[c].inst.ToString();
                                            this.LNodeSCL.iedName = this.scl.IED[a].name;
                                            this.LNodeSCL.lnInst  = this.scl.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].inst.ToString();
                                            this.LNodeSCL.lnClass = this.scl.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].lnClass;
                                            this.LNodeSCL.lnType  = this.scl.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].lnType;
                                            this.comboBoxtLNode.Items.Add(new LNodeComboBox(this.LNodeSCL));
                                        }
                                    }
                                }
                            }
                            if (this.scl.IED[a].AccessPoint[b].LN != null)
                            {
                                for (int d = 0; d < this.scl.IED[a].AccessPoint[b].LN.Length; d++)
                                {
                                    this.LNodeSCL         = new tLNode();
                                    this.LNodeSCL.iedName = this.scl.IED[a].name;
                                    this.LNodeSCL.lnInst  = this.scl.IED[a].AccessPoint[b].LN[d].inst.ToString();
                                    this.LNodeSCL.lnClass = this.scl.IED[a].AccessPoint[b].LN[d].lnClass;
                                    this.LNodeSCL.lnType  = this.scl.IED[a].AccessPoint[b].LN[d].lnType;
                                    this.comboBoxtLNode.Items.Add(new LNodeComboBox(this.LNodeSCL));
                                }
                            }
                        }
                    }
                }
            }
            this.comboBoxtLNode.DisplayMember = "DisplayLNodes";
        }
Ejemplo n.º 12
0
 private static localhost.Book toLocalhostBook(SCL.Book b)
 {
     localhost.Book _Book = new localhost.Book();
     if (b != null)
     {
         _Book.Author = b.Author;
         _Book.Title = b.Title;
         _Book.PhotoPath = b.Author;
         _Book.Photo = b.Photo;
         _Book.Category = b.Category;
         return _Book;
     }
     else return null;
 }
 /// <summary>
 /// This method inicializes the values.
 /// </summary>
 /// <param name="treeNodeLN">
 /// treeNode that contains the LN data that will be used to create them.
 /// </param>
 /// <param name="sCL">
 /// Main SCL class that will get the data selected.
 /// </param>
 /// <param name="lN">
 /// LN selected.
 /// </param>
 /// <param name="title">
 /// Title of the window.
 /// </param>
 public WindowTreeViewLNType(TreeNode treeNodeLN, SCL sCLObject, object lN, string title)
 {
     this.treeNodeLN        = treeNodeLN;
     this.scl.Configuration = sCLObject;
     this.lN = lN;
     // Calling InitializeComponent() is required for Windows Forms designer support.
     InitializeComponent();
     this.Text             = title;
     this.label1.ForeColor = Color.Blue;
     this.treeViewLNType   = new TreeViewLNType(this.treeNodeLN, this.scl.Configuration);
     this.treeLN.Nodes.Add(treeViewLNType.GetTreeNodeTypesLNs(this.lN));
     this.treeLN.Nodes[0].Expand();
     this.bandModify       = false;
     this.objectManagement = new ObjectManagement();
 }
Ejemplo n.º 14
0
        private void nameSubNetCBChange(object sender, System.EventArgs e)
        {
            SCL sc = (SCL)this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;

            if (sc.Communication != null && sc.Communication.SubNetwork != null)
            {
                this.obj = this.treeViewSCL.SeekAssociation(this.treeSCL
                                                            .TreeView.Nodes["root"].Nodes["SCL"]
                                                            .Nodes["tCommunication"].Nodes["tSubNetwork[]"]
                                                            .Nodes[this.nameSubNetCB.SelectedIndex].Nodes,
                                                            this.apName, this.iedName);
                loadValues(obj);
                this.descSubNet.Text = sc.Communication.SubNetwork[this.nameSubNetCB.SelectedIndex].desc;
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This method shows a dialog box that allows to edit a SMV configuration
        /// </summary>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        /// <param name="apParentName">
        /// Name of Access point where configuration will be added according to the LN0 selected.
        /// </param>
        /// <param name="iedParentName">
        /// Name of IED where configuration will be added according to the LN0 selected.
        /// </param>
        /// <param name="smvObject">
        /// Object that contains the information of SMV class
        /// </param>
        /// <param name="optObject">
        /// Object that contains the information of SMV options class
        /// </param>
        public SMVDialog(TreeNode treeSCL, string apParentName, string iedParentName, object smvObject, object optObject, string ldInst)
        {
            SCL sCL = (SCL)treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;

            this.edit          = true;
            this.treeSCL       = treeSCL;
            this.apParentName  = apParentName;
            this.iedParentName = iedParentName;
            // The InitializeComponent() call is required for Windows Forms designer support.
            InitializeComponent();
            this.datSet.DataSource              = this.treeViewSCL.getDataset(this.treeSCL);               //victor
            this.datSet.SelectedIndex           = this.treeViewSCL.getDataSetSelected(treeSCL, smvObject); //victor
            this.oldSMVName                     = this.objectManagement.FindVariable(this.treeSCL.TreeView.SelectedNode.Tag, "name").ToString();
            this.propertySMV.SelectedObject     = smvObject;
            this.propertyOptions.SelectedObject = optObject;
            TreeNode smvNode = null;

            if (sCL.Communication != null)
            {
                this.treeViewSCL = new TreeViewSCL();
                smvNode          = this.treeViewSCL.SeekAssociation(this.treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes, this.objectManagement.FindVariable(smvObject, "name").ToString(), "cbName", "tSMV");
            }
            tSMV tsmv = new tSMV();

            this.ldInst.Enabled = false;
            this.ldInst.Text    = ldInst;
            if (smvNode != null)
            {
                this.desc.Text = this.objectManagement.FindVariable(smvNode.Tag, "desc").ToString();
                if (smvNode.FirstNode != null)
                {
                    object arrayOf = smvNode.FirstNode.Tag;
                    tP[]   arr     = (tP[])this.objectManagement.FindVariable(arrayOf, "P");
                    if (arr != null)
                    {
                        if (arr.Length > 0)
                        {
                            this.mac.Text   = this.objectManagement.GetTpValue(arr, "MAC_Address");
                            this.appID.Text = this.objectManagement.GetTpValue(arr, "APPID");
                            this.vLANP.Text = this.objectManagement.GetTpValue(arr, "VLAN_PRIORITY");
                            this.vLANI.Text = this.objectManagement.GetTpValue(arr, "VLAN_ID");
                        }
                    }
                }
            }
            this.Text = "Edit Sampled Value";
        }
Ejemplo n.º 16
0
 static localhost.Review toLocalHostReview(SCL.Review review)
 {
     localhost.Review _review = new localhost.Review();
     if (review!=null)
     {
         _review.AuthorId = review.AuthorId;
         _review.BookId = review.BookId;
         _review.Id = review.Id;
         _review.Mark = review.Mark;
         _review.Text = review.Text;
         return _review;
     }
     else
     {
         return null;
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// This method creates a DataSet.
        /// </summary>
        /// <param name="treeSCL">
        /// TreeNode that contains the DataSet object.
        /// </param>
        /// <param name="sCLObject">
        /// sCL object of the project.
        /// </param>
        public void CreateDataSet(TreeNode treeSCL, SCL sCLObject)
        {
            this.treeSCL = treeSCL;
            this.scl     = sCLObject;
            this.anyLN   = this.treeViewSCL.SearchUPForBaseTypeAndGetSCLTreeNode(treeSCL, typeof(tAnyLN)).Tag;
            this.node    = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(treeSCL, typeof(tLDevice));
            DataSet dataSet = new DataSet();

            if (this.node != null)
            {
                this.Name = "ldInst" + (node.Tag as tLDevice).inst;
                if (this.anyLN is tLN)
                {
                    this.LNtypeLabel.Text = ((anyLN as tLN).prefix + (anyLN as tLN).lnClass + (anyLN as tLN).inst);
                    this.dataSetSCL       = dataSet.GetLNFCDAs(node.Tag as tLDevice, this.anyLN as tLN, this.scl.DataTypeTemplates);
                }
                else
                {
                    this.LNtypeLabel.Text = ((anyLN as LN0).lnClass + (anyLN as LN0).inst);
                    this.dataSetSCL       = dataSet.GetLN0FCDAs(node.Tag as tLDevice, this.anyLN as LN0, this.scl.DataTypeTemplates);
                }
                for (int x = 0; this.dataSetSCL != null && this.dataSetSCL.FCDA != null && x < this.dataSetSCL.FCDA.Length; x++)
                {
                    this.SourceDataSetListBox.Items.Add(new FCDAListBox(this.dataSetSCL.FCDA[x], (this.anyLN as tAnyLN).lnType));
                }
            }
            else
            {
                this.LNtypeLabel.Text = ((anyLN as tLN).prefix + (anyLN as tLN).lnClass + (anyLN as tLN).inst);
                this.dataSetSCL       = dataSet.GetLNFCDAs(null, this.anyLN as tLN, this.scl.DataTypeTemplates);
                for (int x = 0; this.dataSetSCL != null && this.dataSetSCL.FCDA != null && x < this.dataSetSCL.FCDA.Length; x++)
                {
                    this.SourceDataSetListBox.Items.Add(new FCDAListBox(this.dataSetSCL.FCDA[x], (this.anyLN as tLN).lnType));
                }
            }
            this.SourceDataSetListBox.SelectionMode  = SelectionMode.None;
            this.DestinyDataSetListBox.SelectionMode = SelectionMode.None;
            this.SourceDataSetListBox.SelectionMode  = SelectionMode.MultiSimple;
            this.DestinyDataSetListBox.SelectionMode = SelectionMode.MultiSimple;
            this.SourceDataSetListBox.DisplayMember  = "DisplayFCDA";
            this.DestinyDataSetListBox.DisplayMember = "DisplayFCDA";
        }
Ejemplo n.º 18
0
        public TopIedNode(SCL s)
        {
            if (s == null)
            {
                return;
            }

            Name = "Configured IEDs";
            Tag  = s.IED;
            scl  = s;
            var cxm     = new System.Windows.Forms.ContextMenuStrip();
            var add_dta = new System.Windows.Forms.ToolStripMenuItem("Add IED",
                                                                     null, on_add_ied);

            cxm.Items.Add(add_dta);
            base.ContextMenuStrip = cxm;

            update_nodes();
            this.Expand();
        }
Ejemplo n.º 19
0
        public void DeleteReview(SCL.Review review)
        {
            if (review!=null)
            {
                string query = "delete from ReviewsTable where ReviewId = @ReviewId";
                sqlConnection.Open();
                SqlCommand cmd = new SqlCommand(query, sqlConnection);

                cmd.Parameters.Add("@ReviewId", System.Data.SqlDbType.Int).Value = review.Id;

                cmd.ExecuteNonQuery();

                cmd.Dispose();
                sqlConnection.Close();
                return;
            }
            else
            {
                throw new NullReferenceException("review is null");
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectToInsert">
        ///
        /// </param>
        /// <param name="nodePossibleInsert">
        ///
        /// </param>
        public void Insert(object objectToInsert, TreeNode nodePossibleInsert)
        {
            switch (objectToInsert.GetType().Name)
            {
            case "tFCDA":
                this.nodeSCL = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tLDevice));
                if (this.nodeSCL != null)
                {
                    this.objectManagement.FindVariableAndSetValue(objectToInsert, this.nodeSCL.Tag.GetType().Name, this.nodeSCL.Tag);
                }
                break;

            case "tConnectedAP":
                this.nodeSCL  = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tAccessPoint));
                this.nodeSCL2 = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tIED));
                if (this.nodeSCL != null && this.nodeSCL2 != null)
                {
                    this.objectManagement.FindVariableAndSetValue(objectToInsert, this.nodeSCL.Tag.GetType().Name, this.nodeSCL.Tag);
                    this.objectManagement.FindVariableAndSetValue(objectToInsert, this.nodeSCL2.Tag.GetType().Name, this.nodeSCL2.Tag);
                }
                break;

            case "tServer":
                this.sCL = (SCL)this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(SCL)).Tag;
                if (this.sCL.Communication != null && this.sCL.Communication.SubNetwork != null)
                {
                    object access = (nodePossibleInsert.Tag as tAccessPoint);
                    object ied    = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tIED)).Tag;
                    for (int i = 0; i < this.sCL.Communication.SubNetwork.Length; i++)
                    {
                        for (int j = 0; j < this.sCL.Communication.SubNetwork[i].ConnectedAP.Length; j++)
                        {
                            if ((this.sCL.Communication.SubNetwork[i].ConnectedAP[j].iedName != null && this.sCL.Communication.SubNetwork[i].ConnectedAP[j].apName != null))
                            {
                                if (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].iedName.Equals((ied as tIED).name))
                                {
                                    if (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].apName.Equals((access as tAccessPoint).name))
                                    {
                                        this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j], access.GetType().Name, access);
                                        this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j], ied.GetType().Name, ied);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case "tGSEControl":
            case "tSampledValueControl":
                this.sCL = (SCL)this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(SCL)).Tag;
                if (this.sCL.Communication != null && this.sCL.Communication.SubNetwork != null)
                {
                    object currentTag = nodePossibleInsert.Tag;
                    object tLd        = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tLDevice)).Tag;
                    for (int i = 0; i < this.sCL.Communication.SubNetwork.Length; i++)
                    {
                        for (int j = 0; j < this.sCL.Communication.SubNetwork[i].ConnectedAP.Length; j++)
                        {
                            if (currentTag.GetType().Name.Equals("tGSEControl"))
                            {
                                for (int k = 0; this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE != null && k < this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE.Length; k++)
                                {
                                    if ((this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k].cbName != null) && (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k].ldInst != null))
                                    {
                                        if (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k].cbName.Equals((currentTag as tGSEControl).name) && (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k].ldInst.Equals((tLd as tLDevice).inst)))
                                        {
                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k], currentTag.GetType().Name, currentTag);
                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j].GSE[k], tLd.GetType().Name, tLd);
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int k = 0; this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV != null && k < this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV.Length; k++)
                                {
                                    if ((this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k].cbName != null) && (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k].ldInst != null))
                                    {
                                        if (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k].cbName.Equals((currentTag as tSampledValueControl).name) && (this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k].ldInst.Equals((tLd as tLDevice).inst)))
                                        {
                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k], currentTag.GetType().Name, currentTag);
                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Communication.SubNetwork[i].ConnectedAP[j].SMV[k], tLd.GetType().Name, tLd);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case "tGSE":
            case "tSMV":
                this.nodeSCL = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tLDevice));
                if (this.nodeSCL != null)
                {
                    this.objectManagement.FindVariableAndSetValue(objectToInsert, this.nodeSCL.Tag.GetType().Name, this.nodeSCL.Tag);
                    this.objectManagement.FindVariableAndSetValue(objectToInsert, nodePossibleInsert.Tag.GetType().Name, nodePossibleInsert.Tag);                            //victor, puse esta condicion por el property del GSE está habilitado y hay que actualizar el nombre
                }
                break;

            case "tSubstation":
                this.sCL     = (SCL)this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(SCL)).Tag;
                this.nodeSCL = this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(nodePossibleInsert, typeof(tSubstation));
                if (this.sCL.Substation != null)
                {
                    for (int i = 0; this.sCL.Substation.Length > i; i++)
                    {
                        if (this.sCL.Substation[i].LNode != null)
                        {
                            for (int j = 0; this.sCL.Substation[i].LNode.Length > j; j++)
                            {
                                if (this.sCL.IED != null)
                                {
                                    for (int a = 0; a < this.sCL.IED.Length; a++)
                                    {
                                        if (this.sCL.Substation[i].LNode[j].iedName.Equals(this.sCL.IED[a].name))
                                        {
                                            object ied = (this.sCL.IED[a]  as tIED);
                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ied.GetType().Name, ied);
                                            if (this.sCL.IED[a].AccessPoint != null)
                                            {
                                                for (int b = 0; b < this.sCL.IED[a].AccessPoint.Length; b++)
                                                {
                                                    if (this.sCL.IED[a].AccessPoint[b].Server != null)
                                                    {
                                                        for (int c = 0; c < this.sCL.IED[a].AccessPoint[b].Server.LDevice.Length; c++)
                                                        {
                                                            if (this.sCL.Substation[i].LNode[j].ldInst.Equals(this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].inst))
                                                            {
                                                                object ld = (this.sCL.IED[a].AccessPoint[b].Server.LDevice[c]  as tLDevice);
                                                                this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ld.GetType().Name, ld);

                                                                if (this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN != null)
                                                                {
                                                                    for (int d = 0; d < this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN.Length; d++)
                                                                    {
                                                                        if (this.sCL.Substation[i].LNode[j].lnClass.Equals(this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].lnClass) &&
                                                                            this.sCL.Substation[i].LNode[j].lnInst.Equals(this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].inst.ToString()) &&
                                                                            this.sCL.Substation[i].LNode[j].lnType.Equals(this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN[d].lnType)
                                                                            )
                                                                        {
                                                                            object ln = (this.sCL.IED[a].AccessPoint[b].Server.LDevice[c].LN[d]  as tLN);
                                                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                                            this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    if (this.sCL.IED[a].AccessPoint[b].LN != null)
                                                    {
                                                        for (int d = 0; d < this.sCL.IED[a].AccessPoint[b].LN.Length; d++)
                                                        {
                                                            if (this.sCL.Substation[i].LNode[j].lnClass.Equals(this.sCL.IED[a].AccessPoint[b].LN[d].lnClass) &&
                                                                this.sCL.Substation[i].LNode[j].lnInst.Equals(this.sCL.IED[a].AccessPoint[b].LN[d].inst.ToString()) &&
                                                                this.sCL.Substation[i].LNode[j].lnType.Equals(this.sCL.IED[a].AccessPoint[b].LN[d].lnType)
                                                                )
                                                            {
                                                                object ln = (this.sCL.IED[a].AccessPoint[b].LN[d]  as tLN);
                                                                this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                                this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                                this.objectManagement.FindVariableAndSetValue(this.sCL.Substation[i].LNode[j], ln.GetType().Name, ln);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            }
        }
Ejemplo n.º 21
0
 public EditDialog(SCL scl)
 {
     this.scl = scl;
     this.InitializeComponent();
 }
Ejemplo n.º 22
0
        /// <summary>
        /// This method updates the SCL tree using the SCL object that contains the clases of the
        /// IED imported.
        /// </summary>
        /// <param name="treeViewProject">
        /// TreeView of the main SCL where the new nodes of the IED file will be insert.
        /// </param>
        /// <param name="scl">
        /// SCL object created using the deserializer method on the ICD or CID file of the IED to import.
        /// </param>
        public void ImportIEDUI(TreeView treeViewProject, SCL scl)
        {
            TreeView    treeViewSCLProject;
            TreeViewSCL treeViewSCL = new TreeViewSCL();
            TreeNode    sCLObject;

            treeViewSCLProject = treeViewProject;
            TreeNode treeViewToImport = new TreeNode();

            treeViewToImport = treeViewSCL.GetTreeNodeSCL("TreeNodeToImport", scl);

            if (scl.Substation != null)
            {
                sCLObject = treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tSubstation[]"];
                if (sCLObject != null)
                {
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.RemoveByKey("tSubstation[]");
                    treeViewSCL.GetNodesItemOfArray((treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag as SCL).Substation, treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag.GetType(), treeViewSCLProject.Nodes["root"].Nodes["SCL"]);
                }
                else
                {
                    TreeNode node = new TreeNode();
                    node.Name = "tSubstation[]";
                    node.Text = "Substation";
                    node.Tag  = scl.Header;
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.Add(node);

                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tSubstation[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tSubstation[]"], sCLObject);
                }
            }
            if (scl.Header != null)
            {
                sCLObject = treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tHeader"];
                if (sCLObject != null)
                {
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.RemoveByKey("tHeader");
                    treeViewSCL.GetNodes((treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag as SCL).Header, treeViewSCLProject.Nodes["root"].Nodes["SCL"]);
                }
                else
                {
                    TreeNode node = new TreeNode();
                    node.Name = "tHeader";
                    node.Text = "Header";
                    node.Tag  = scl.Header;
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.Add(node);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tHeader"],
                                   treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tHeader"], sCLObject);
                }
            }
            if (scl.IED != null)
            {
                sCLObject = treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tIED[]"];
                if (sCLObject != null)
                {
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.RemoveByKey("tIED[]");
                    treeViewSCL.GetNodesItemOfArray((treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag as SCL).IED,
                                                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag.GetType(),
                                                    treeViewSCLProject.Nodes["root"].Nodes["SCL"]);
                }
                else
                {
                    TreeNode nodeIED = new TreeNode();
                    nodeIED.Name = "tIED[]";
                    nodeIED.Text = "IED";
                    nodeIED.Tag  = scl.IED;
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.Add(nodeIED);

                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tIED[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tIED[]"], sCLObject);
                }
            }
            if (scl.Communication != null)
            {
                sCLObject = treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"];
                if (sCLObject != null)
                {
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.RemoveByKey("tCommunication");
                    treeViewSCL.GetNodes((treeViewSCLProject.Nodes["root"].Nodes["SCL"].Tag as SCL).Communication, treeViewSCLProject.Nodes["root"].Nodes["SCL"]);
                }
                else
                {
                    TreeNode nodeCommunication = new TreeNode();
                    nodeCommunication.Name = "tCommunication";
                    nodeCommunication.Text = "Communication";
                    nodeCommunication.Tag  = scl.Communication;
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.Add(nodeCommunication);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tCommunication"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"], sCLObject);
                }
            }
            if (scl.DataTypeTemplates != null)
            {
                sCLObject = treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"];
                if (sCLObject != null)
                {
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tLNodeType[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tLNodeType[]"], sCLObject);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tDOType[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tDOType[]"], sCLObject);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tDAType[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tDAType[]"], sCLObject);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tEnumType[]"], treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"].Nodes["tEnumType[]"], sCLObject);
                }
                else
                {
                    TreeNode nodeDataTypeTemplates = new TreeNode();
                    nodeDataTypeTemplates.Name = "tDataTypeTemplates";
                    nodeDataTypeTemplates.Text = "DataTypeTemplates";
                    nodeDataTypeTemplates.Tag  = scl.DataTypeTemplates;
                    treeViewSCLProject.Nodes["root"].Nodes["SCL"].Nodes.Add(nodeDataTypeTemplates);
                    this.CopyNodes(treeViewToImport.Nodes["SCL"].Nodes["tDataTypeTemplates"], treeViewProject.Nodes["root"].Nodes["SCL"].Nodes["tDataTypeTemplates"], sCLObject);
                }
            }
        }
Ejemplo n.º 23
0
        public void UpdateBook(int id, SCL.Book newBook)
        {
            if (FindBookById(id)!=null)
            {
                if (newBook.Photo!=null)
                {
                    string query = "update BooksTable set BookTitle = @BookTitle, BookAuthor = @BookAuthor, BookImage = @BookImage, BookCategory = @BookCategory, BookPrice = @BookPrice, BookDescription = @BookDescription where BookId = @BookId";
                    SqlCommand cmd = new SqlCommand();
                    sqlConnection.Open();
                    cmd.Connection = sqlConnection;
                    cmd.CommandText = query;

                    cmd.Parameters.Add("@BookTitle", System.Data.SqlDbType.VarChar, 50).Value = newBook.Title;
                    cmd.Parameters.Add("@BookAuthor", System.Data.SqlDbType.VarChar, 50).Value = newBook.Author;
                    cmd.Parameters.Add("@BookImage", System.Data.SqlDbType.VarBinary, newBook.Photo.Length).Value = newBook.Photo;
                    cmd.Parameters.Add("@BookCategory", System.Data.SqlDbType.VarChar, 50).Value = newBook.Category;
                    cmd.Parameters.Add("@BookId", System.Data.SqlDbType.Int).Value = id;
                    cmd.Parameters.Add("@BookPrice", System.Data.SqlDbType.Decimal).Value = newBook.Price;
                    cmd.Parameters.Add("@BookDescription", System.Data.SqlDbType.Text).Value = newBook.Description;
                    cmd.ExecuteNonQuery();

                    cmd.Dispose();
                    sqlConnection.Close();

                }
                else
                {
                    string query = "update BooksTable set BookTitle = @BookTitle, BookAuthor = @BookAuthor, BookImage = NULL, BookCategory = @BookCategory, BookPrice = @BookPrice, BookDescription = @BookDescription where BookId = @BookId";
                    SqlCommand cmd = new SqlCommand();
                    sqlConnection.Open();
                    cmd.Connection = sqlConnection;
                    cmd.CommandText = query;

                    cmd.Parameters.Add("@BookTitle", System.Data.SqlDbType.VarChar, 50).Value = newBook.Title;
                    cmd.Parameters.Add("@BookAuthor", System.Data.SqlDbType.VarChar, 50).Value = newBook.Author;
                    cmd.Parameters.Add("@BookCategory", System.Data.SqlDbType.VarChar, 50).Value = newBook.Category;
                    cmd.Parameters.Add("@BookId", System.Data.SqlDbType.Int).Value = id;
                    cmd.Parameters.Add("@BookPrice", System.Data.SqlDbType.Decimal, 50).Value = newBook.Price;
                    cmd.Parameters.Add("@BookDescription", System.Data.SqlDbType.Text).Value = newBook.Description;

                    cmd.ExecuteNonQuery();

                    cmd.Dispose();
                    sqlConnection.Close();
                }
            }
        }
Ejemplo n.º 24
0
        public void InsertReview(SCL.Review review)
        {
            string query = "insert into ReviewsTable (ReviewAuthor, BookId, ReviewText, ReviewMark) values (@ReviewAuthor, @BookId, @ReviewText, @ReviewMark); "
                + "update BooksTable set BookMark = (BookMark + @ReviewMark)/2 where BookId = @BookId";
            sqlConnection.Open();
            SqlCommand cmd = new SqlCommand(query, sqlConnection);

            cmd.Parameters.Add("@ReviewAuthor", System.Data.SqlDbType.Int).Value = review.AuthorId;
            cmd.Parameters.Add("@BookId", System.Data.SqlDbType.Int).Value = review.BookId;
            cmd.Parameters.Add("@ReviewText", System.Data.SqlDbType.Text).Value = review.Text;
            cmd.Parameters.Add("@ReviewMark", System.Data.SqlDbType.Decimal).Value = review.Mark;

            cmd.ExecuteNonQuery();

            sqlConnection.Close();
        }
Ejemplo n.º 25
0
        public void InsertBook(SCL.Book book)
        {
            if (book.Photo!=null)
            {

                string query = "insert into BooksTable (BookTitle, BookAuthor, BookImage, BookAddDate, BookCategory, BookPrice, BookDescription) values (@BookTitle, @BookAuthor, @BookImage, GETDATE(), @BookCategory, @BookPrice, @BookDescription)";
                SqlCommand cmd = new SqlCommand();
                sqlConnection.Open();
                cmd.Connection = sqlConnection;
                cmd.CommandText = query;

                cmd.Parameters.Add("@BookTitle", System.Data.SqlDbType.VarChar, 50).Value = book.Title;
                cmd.Parameters.Add("@BookAuthor", System.Data.SqlDbType.VarChar, 50).Value = book.Author;
                cmd.Parameters.Add("@BookImage", System.Data.SqlDbType.VarBinary, book.Photo.Length).Value = book.Photo;
                cmd.Parameters.Add("@BookCategory", System.Data.SqlDbType.VarChar, 50).Value = book.Category;
                cmd.Parameters.Add("@BookPrice", System.Data.SqlDbType.Decimal).Value = book.Price;
                cmd.Parameters.Add("@BookDescription", System.Data.SqlDbType.Text).Value = book.Description;
                cmd.ExecuteNonQuery();

                cmd.Dispose();
                sqlConnection.Close();
                return;
            }

            if (book.Photo == null || book.PhotoPath =="")
            {

                string query = "insert into BooksTable (BookTitle, BookAuthor, BookImage, BookAddDate, BookCategory, BookPrice, BookDescription) values (@BookTitle, @BookAuthor, NULL, GETDATE(), @BookCategory, @BookPrice, @BookDescription)";
                SqlCommand cmd = new SqlCommand();
                sqlConnection.Open();
                cmd.Connection = sqlConnection;
                cmd.CommandText = query;

                cmd.Parameters.Add("@BookTitle", System.Data.SqlDbType.VarChar, 50).Value = book.Title;
                cmd.Parameters.Add("@BookAuthor", System.Data.SqlDbType.VarChar, 50).Value = book.Author;
                cmd.Parameters.Add("@BookCategory", System.Data.SqlDbType.VarChar, 50).Value = book.Category;
                cmd.Parameters.Add("@BookPrice", System.Data.SqlDbType.Decimal).Value = book.Price;
                cmd.Parameters.Add("@BookDescription", System.Data.SqlDbType.Text).Value = book.Description;
                cmd.ExecuteNonQuery();

                cmd.Dispose();
                sqlConnection.Close();
                return;

            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// This method shows the information to edit all values pre-configured for SMV,
        /// SMVControl and SMVoptions classes.
        /// </summary>
        /// <param name="sMVControl">
        /// Sampled Value Controls class.
        /// </param>
        /// <param name="sMVOptions">
        /// Sampled Value Options class.
        /// </param>
        /// <param name="smv">
        /// Sampled Value class.
        /// </param>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        public void SMVHandler(object sMVControl, object sMVOptions, string[] smv, TreeNode treeSCL)
        {
            tSampledValueControl sMVCtrl = (tSampledValueControl)sMVControl;

            sMVCtrl.datSet = this.datSet.SelectedItem.ToString();
            SCL sCL = (SCL)treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;
            tSampledValueControlSmvOpts sMVOpts = (tSampledValueControlSmvOpts)sMVOptions;
            TreeNode nodeSMVControl             = new TreeNode();
            TreeNode nodeSMV;

            nodeSMVControl.Name = sMVCtrl.name;
            nodeSMVControl.Text = sMVCtrl.name;
            nodeSMVControl.Tag  = sMVCtrl;
            TreeNode nodetSMV;
            tSMV     tsmv = new tSMV();

            if (this.objectManagement.AddObjectToArrayObjectOfParentObject(sMVCtrl, treeSCL.Tag))
            {
                if (treeSCL.TreeView.SelectedNode.Tag is tLN0)
                {
                    tLN0     ln0       = (tLN0)treeSCL.Tag;
                    TreeNode parentSMV = new TreeNode();
                    parentSMV.Name = "tSampledValueControl[]";
                    parentSMV.Text = "SampledValueControl";
                    parentSMV.Tag  = ln0.SampledValueControl;
                    treeSCL.Nodes.Add(parentSMV);
                    treeSCL = parentSMV;
                }
                else
                {
                    treeSCL = treeSCL.TreeView.SelectedNode;
                }
                treeSCL.Nodes.Add(nodeSMVControl);
                this.objectManagement.AddObjectToSCLObject(sMVOpts, sMVCtrl);
                TreeNode nodeOP = new TreeNode();
                nodeOP.Name = "SMVOpts";
                nodeOP.Text = "SMVOpts";
                nodeOP.Tag  = sMVOpts;
                nodeSMVControl.Nodes.Add(nodeOP);
            }
            treeViewSCL.CreateCommNode(sCL, treeSCL);
            TreeNode connAPRef = new TreeNode();

            for (int i = 0; i < sCL.Communication.SubNetwork.Length; i++)
            {
                connAPRef = treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, apParentName, iedParentName, "apName", "iedName");
                if (connAPRef == null && sCL.Communication.SubNetwork[i].ConnectedAP == null)
                {
                    treeViewSCL.CreateConnectedNode(sCL, treeSCL, apParentName, iedParentName, i);
                    connAPRef = treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, apParentName, iedParentName, "apName", "iedName");
                }
                if (connAPRef != null)
                {
                    tsmv.cbName = sMVCtrl.name;
                    tsmv.ldInst = smv[0];
                    tsmv.desc   = smv[5];
                    nodeSMV     = new TreeNode();
                    this.objectManagement.AddObjectToArrayObjectOfParentObject(tsmv, connAPRef.Tag);
                    if (connAPRef.Nodes["tSMV[]"] == null)
                    {
                        tConnectedAP tconn = (tConnectedAP)connAPRef.Tag;
                        nodeSMV.Text = "SMV";
                        nodeSMV.Name = "tSMV[]";
                        nodeSMV.Tag  = tconn.SMV;
                        connAPRef.Nodes.Add(nodeSMV);
                    }
                    else
                    {
                        nodeSMV = connAPRef.Nodes["tSMV[]"];
                    }
                    nodetSMV      = new TreeNode();
                    nodetSMV.Text = sMVCtrl.name;
                    nodetSMV.Name = smv[0] + "." + sMVCtrl.name;
                    nodetSMV.Tag  = tsmv;
                    nodeSMV.Nodes.Add(nodetSMV);
                    AttributeReferences aReferences = new AttributeReferences();
                    aReferences.Insert(tsmv, nodeSMVControl);
                    tAddress taddr = new tAddress();
                    this.objectManagement.AddObjectToSCLObject(taddr, tsmv);
                    TreeNode nodeAddress = new TreeNode();
                    nodeAddress.Text = "Address";
                    nodeAddress.Name = "Address";
                    nodeAddress.Tag  = taddr;
                    nodetSMV.Nodes.Add(nodeAddress);
                    TreeNode nodetP = new TreeNode();
                    nodetP.Name = "tP[]";
                    nodetP.Text = "P";
                    nodeAddress.Nodes.Add(nodetP);
                    Utils utilsOM = new Utils();

                    tP            t_mac  = new tP();
                    tP_MACAddress t_mac_ = new tP_MACAddress();
                    this.objectManagement.EmptySourcetoDestinyObject(t_mac_, t_mac);
                    t_mac.Value = this.mac.Text;
                    utilsOM.AddTPTreeNode(t_mac, "tP_mac", "tP", taddr, nodetP);

                    tP       t_app  = new tP();
                    tP_APPID t_app_ = new tP_APPID();
                    this.objectManagement.EmptySourcetoDestinyObject(t_app_, t_app);
                    t_app.Value = this.appID.Text;
                    utilsOM.AddTPTreeNode(t_app, "tP_app", "tP", taddr, nodetP);

                    tP t_vlap = new tP();
                    tP_VLANPRIORITY t_vlap_ = new tP_VLANPRIORITY();
                    this.objectManagement.EmptySourcetoDestinyObject(t_vlap_, t_vlap);
                    t_vlap.Value = this.vLANP.Text;
                    utilsOM.AddTPTreeNode(t_vlap, "tP_vlanp", "tP", taddr, nodetP);

                    tP        t_vlani  = new tP();
                    tP_VLANID t_vlani_ = new tP_VLANID();
                    this.objectManagement.EmptySourcetoDestinyObject(t_vlani_, t_vlani);
                    t_vlani.Value = this.vLANI.Text;
                    utilsOM.AddTPTreeNode(t_vlani, "tP_vlani", "tP", taddr, nodetP);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// This method shows the information to edit all values pre-configured for SMV,
        /// SMVControl and SMVoptions classes.
        /// </summary>
        /// <param name="treeSCL">
        /// TreeNode reference
        /// </param>
        /// <param name="smvc">
        /// Sampled Value Controls class.
        /// </param>
        /// <param name="smvopt">
        /// Sampled Value Options class.
        /// </param>
        /// <param name="smv">
        /// Sampled Value class.
        /// </param>
        /// <param name="oldSMVName">
        /// Control block Name of the SMV.
        /// </param>
        public void SMVHandler(TreeNode treeSCL, object smvc, object smvopt, string[] smv, string oldSMVName)
        {
            SCL sCL = (SCL)treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Tag;
            tSampledValueControl tsmvc = (tSampledValueControl)smvc;

            tsmvc = (tSampledValueControl)smvc;
            tSampledValueControlSmvOpts tsmvco = (tSampledValueControlSmvOpts)smvopt;

            tsmvco = (tSampledValueControlSmvOpts)smvopt;
            this.objectManagement.ModifyObjectOfArrayObjectOfParentObject(tsmvc, treeSCL.TreeView.SelectedNode.Index, treeSCL.TreeView.SelectedNode.Parent.Parent.Tag);
            treeSCL.TreeView.SelectedNode.Tag  = tsmvc;
            treeSCL.TreeView.SelectedNode.Text = tsmvc.name;
            String[] names = new String[4];
            names[0] = "MAC_Address";
            names[1] = "APPID";
            names[2] = "VLAN_PRIORITY";
            names[3] = "VLAN_ID";
            if (sCL.Communication != null)
            {
                TreeNode Conn = this.treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes,
                                                                 this.objectManagement.FindVariable(
                                                                     this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(treeSCL.TreeView.SelectedNode, typeof(tAccessPoint)).Tag, "name").ToString(),
                                                                 this.objectManagement.FindVariable(
                                                                     this.treeViewSCL.SearchUPForTypeAndGetSCLTreeNode(treeSCL.TreeView.SelectedNode, typeof(tIED)).Tag, "name").ToString());
                if (sCL.Communication.SubNetwork != null && Conn != null)
                {
                    for (int i = 0; i < sCL.Communication.SubNetwork.Length; i++)
                    {
                        TreeNode smvN   = treeViewSCL.SeekAssociation(treeSCL.TreeView.Nodes["root"].Nodes["SCL"].Nodes["tCommunication"].Nodes["tSubNetwork[]"].Nodes[i].Nodes, oldSMVName, "cbName", "tSMV");
                        TreeNode newSMV = smvN;
                        if (smvN != null)
                        {
                            tSMV tsmv = (tSMV)smvN.Tag;
                            tsmv.ldInst  = smv[0];
                            tsmv.cbName  = tsmvc.name;
                            tsmv.desc    = smv[5];
                            tsmvc.datSet = this.datSet.SelectedItem.ToString();                            //victor
                            if (this.objectManagement.ModifyObjectOfArrayObjectOfParentObject(tsmv, smvN.Index, smvN.Parent.Parent.Tag))
                            {
                                if (smvN.FirstNode != null)
                                {
                                    object   arrayOf = smvN.FirstNode.Tag;
                                    tP[]     arr     = (tP[])this.objectManagement.FindVariable(arrayOf, "P");
                                    tAddress tad     = new tAddress();
                                    tsmv.Address = tad;
                                    if (arr != null)
                                    {
                                        for (int x = 0; x < arr.Length; x++)
                                        {
                                            for (int y = 0; y < names.Length; y++)
                                            {
                                                if (arr[x].type.ToString() == names[y])
                                                {
                                                    arr[x].Value = smv[y + 1].ToString();
                                                }
                                            }
                                        }
                                    }
                                    tsmv.Address.P = (tP[])arr;
                                    smvN.Tag       = tsmv;
                                    smvN.Text      = tsmv.cbName;
                                    if (this.objectManagement.ModifyObjectOfArrayObjectOfParentObject((tP[])arr, 0, tsmv.Address.P))
                                    {
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    SMVHandler(tsmvc, tsmvco, smv, treeSCL);
                }
            }
            else
            {
                SMVHandler(tsmvc, tsmvco, smv, treeSCL);
            }
        }
Ejemplo n.º 28
0
        /// <inheritdoc />
        protected override async Task <Result <Unit, IError> > Run(
            IStateMonad stateMonad,
            CancellationToken cancellationToken)
        {
            var sclResult = await SCL.Run(stateMonad, cancellationToken).Map(x => x.GetStringAsync());

            if (sclResult.IsFailure)
            {
                return(sclResult.ConvertFailure <Unit>());
            }

            List <VariableName> variablesToExport;

            if (Export is null)
            {
                variablesToExport = new List <VariableName>();
            }
            else
            {
                var exportResult = await Export.Run(stateMonad, cancellationToken)
                                   .Bind(x => x.GetElementsAsync(cancellationToken));

                if (exportResult.IsFailure)
                {
                    return(exportResult.ConvertFailure <Unit>());
                }

                variablesToExport = exportResult.Value.Select(x => x.GetString())
                                    .Select(x => new VariableName(x))
                                    .ToList();
            }

            var stepResult = SCLParsing.TryParseStep(sclResult.Value)
                             .Bind(x => x.TryFreeze(TypeReference.Unit.Instance, stateMonad.StepFactoryStore));

            if (stepResult.IsFailure)
            {
                return(stepResult.ConvertFailure <Unit>());
            }

            await using var monad2 = new ScopedStateMonad(
                            stateMonad,
                            ImmutableDictionary <VariableName, object> .Empty
                            );

            await stepResult.Value.Run <Unit>(monad2, cancellationToken);

            foreach (var variable in variablesToExport)
            {
                var value = monad2.GetVariable <object>(variable);

                var valueV = value.IsSuccess ? value.Value : null;

                await monad2.RemoveVariableAsync(
                    variable,
                    false,
                    this
                    ); //Remove the variable to prevent it being disposed

                await stateMonad.SetVariableAsync(variable, valueV, true, this);
            }

            return(Unit.Default);
        }