예제 #1
0
        /// <summary>
        /// Saves the selected Datapoint of the specified Sample Grp and Server name in database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void okCmd_Click(object sender, EventArgs e)
        {
            string Function_Name = "okCmd_Click";

            try
            {
                if (m_localIntervalGrpID == "")
                {
                    return;
                }
                if (m_view.CheckSelectionListModified())
                {
                    EtyDataLogDPTrend SampleGrpEty = new EtyDataLogDPTrend();
                    SampleGrpEty.OPCSampleGrpId = Convert.ToDouble(m_localIntervalGrpID);
                    SampleGrpEty.Disabled       = true;
                    List <string>            selectedItems      = m_view.GetSelectedDataPoints();
                    List <EtyDataLogDPTrend> selectedDataPoints = new List <EtyDataLogDPTrend>();
                    for (int i = 0; i < selectedItems.Count; i++)
                    {
                        EtyDataLogDPTrend etyDataPoint = new EtyDataLogDPTrend();
                        etyDataPoint.Disabled         = false;
                        etyDataPoint.OPCSampleGrpId   = Convert.ToDouble(m_localIntervalGrpID);
                        etyDataPoint.OPCDataPointName = selectedItems[i];
                        selectedDataPoints.Add(etyDataPoint);
                    }
                    m_model.UpdateDataPoints(SampleGrpEty, selectedDataPoints);
                }
                MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCDATASELECTOR_SAVE_MSG, EnglishString.SAVE_SUSSCCESSFUL_MSG));
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }
            m_view.Close();
        }
        public void UpdateDataPoints(EtyDataLogDPTrend sampleGrpEty, List <EtyDataLogDPTrend> selectedDataPoints)
        {
            SimpleDatabase.GetInstance().BeginTransaction();
            bool bResult = UpdateOPCDataPointByGrpId(sampleGrpEty.Disabled, sampleGrpEty.OPCSampleGrpId);

            if (bResult)
            {
                for (int i = 0; i < selectedDataPoints.Count; i++)
                {
                    bResult = UpdateOPCDataPointByName(selectedDataPoints[i]);
                }
            }
            if (bResult)
            {
                bResult = DatalogConfigSettingsDAO.GetInstance().UpdateTrendVersionNum();
            }
            if (bResult)
            {
                SimpleDatabase.GetInstance().CommitTransaction();
            }
            else
            {
                SimpleDatabase.GetInstance().RollbackTransaction();
            }
            return;
        }
        public bool InsertOPCDataPoint(EtyDataLogDPTrend etyDPTrend)
        {
            const string Function_Name = "InsertOPCDataPoint";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string sEnabled = DAOHelper.GetEnabledStr(DAOHelper.ChangeBoolToStr(etyDPTrend.Disabled));
            string dpName   = etyDPTrend.OPCDataPointName.Trim();

            if (dpName.Contains(".Value"))
            {
                dpName = dpName.Remove(dpName.Length - 6);
            }
            List <string> sqlStrings = new List <string>();

            for (int i = 0; i < 2; i++)
            {
                string sql = "INSERT INTO DATALOG_DP_TREND (PKEY, ENTITY_KEY, DP_NAME, DP_GRP_ID,ENABLED)"
                             + " (SELECT PKEY,PKEY,CONCAT(NAME,'.Value'),"
                             + etyDPTrend.OPCSampleGrpId.ToString()
                             + ",'" + sEnabled + "'"
                             + " FROM ENTITY  WHERE TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint' )"
                             + " AND NAME = '" + dpName + "')";
                sqlStrings.Add(sql);
            }
            List <SqlParameter> parameters = DAOHelper.CreateEnqueneParameters(sqlStrings);

            return(SimpleDatabase.GetInstance().ExecuteEnqueneProcedure(parameters));
        }
        /// <summary>
        /// Updates the datapoints of specified name
        /// </summary>
        /// <param name="EtyDataLogDPTrend"></param>
        public bool UpdateOPCDataPointByName(EtyDataLogDPTrend etyDPTrend)
        {
            const string Function_Name = "UpdateOPCDataPointByName";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string sEnabled = DAOHelper.GetEnabledStr(DAOHelper.ChangeBoolToStr(etyDPTrend.Disabled));

            if (GetOPCDataPointByName(etyDPTrend.OPCDataPointName))
            {
                List <string> sqlStrings = new List <string>();
                for (int i = 0; i < 2; i++)
                {
                    string sql = " UPDATE DATALOG_DP_TREND "
                                 + " SET DP_GRP_ID = " + etyDPTrend.OPCSampleGrpId.ToString()
                                 + ",ENABLED =  '" + sEnabled + "'"
                                 + " WHERE DP_NAME = '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(etyDPTrend.OPCDataPointName.Trim()) + "'";
                    sqlStrings.Add(sql);
                }
                List <SqlParameter> parameters = DAOHelper.CreateEnqueneParameters(sqlStrings);
                return(SimpleDatabase.GetInstance().ExecuteEnqueneProcedure(parameters));
            }
            else
            {
                return(InsertOPCDataPoint(etyDPTrend));
            }
        }
예제 #5
0
        public void TestUpdateDataPointDB01()
        {
            OPCSampleGrpConfigStartModel oPCSampleGrpConfigStartModel = OPCSampleGrpConfigStartModelFactory.CreateOPCSampleGrpConfigStartModel01();
            double sampleGrpID = double.MinValue;

            oPCSampleGrpConfigStartModel.UpdateDataPointDB(sampleGrpID);

            //Test2---Valid input
            #region TestSetup
            //insert testing group
            EtyDataLogDPGroupTrend etySampleGrp = new EtyDataLogDPGroupTrend();
            etySampleGrp.NewData       = true;
            etySampleGrp.SampleGrpName = "DOTTestParasoftTesting123";
            etySampleGrp.Interval      = 1;
            etySampleGrp.IntervalType  = "M";
            etySampleGrp.Disabled      = false;
            oPCSampleGrpConfigStartModel.InsertOPCSampleGrp(etySampleGrp);
            //getSampleId from DB
            List <EtyDataLogDPGroupTrend> list = oPCSampleGrpConfigStartModel.GetAllOPCSampelGrp(OPCSampleGrpConfigStart.OPCSAMPLEGRPDESC_COL_NAME, OPCSampleGrpConfigStart.OPCSAMPLEGRP_SORT_ASC);
            foreach (var item in list)
            {
                if (item.SampleGrpName.Equals("DOTTestParasoftTesting123"))
                {
                    etySampleGrp = item;
                    break;
                }
            }

            //insert testing Datapoint
            EtyDataLogDPTrend etyOPCDP = new EtyDataLogDPTrend();
            etyOPCDP.OPCDataPointName = "DOTTestParasoftDP1.Value";
            etyOPCDP.EntityKey        = 20099999;
            etyOPCDP.OPCSampleGrpId   = etySampleGrp.SampleGrpID;
            etyOPCDP.Disabled         = false;
            DatalogDPTrendDAO.GetInstance().InsertOPCDataPoint(etyOPCDP);
            #endregion

            //Test Procedure Call
            oPCSampleGrpConfigStartModel.UpdateDataPointDB(etySampleGrp.SampleGrpID);
            //Post Condition Check
            #region PostConditionCheck
            bool   bDisable       = false;
            string sampleGrpIDstr = etySampleGrp.SampleGrpID.ToString();
            //Get DataPoint from DB
            double sampleid = DatalogDPTrendDAO.GetInstance().GetGrpIDByDPName("DOTTestParasoftDP1.Value");
            //Assert.IsTrue(bDisable);
            Assert.AreEqual(sampleid, -1);
            #endregion

            #region CleanUp
            //Clean up inserted test data in DB
            //Delete testing DP
            string localSQL = "Delete from OPC_DT_PT where DATA_PT_NAME = 'DOTTestParasoftDP1.Value'";
            SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL);

            //Delete Testing sampleGrp
            DatalogDPGroupTrendDAO.GetInstance().DeleteOPCSampleGroupById(etySampleGrp.SampleGrpID.ToString());
            #endregion
        }
        /// <summary>
        /// Returns the DataPoints based specified datapoint name substring.
        /// </summary>
        /// <param name="opcServerName">Datapoint server name</param>
        /// <param name="DataPointNameSubstr"> Datapoint name substring to be queried</param>
        /// <returns>Datapoints</returns>
        public List <EtyDataLogDPTrend> GetDataPointByName(string opcServerName, string DataPointNameSubstr)
        {
            const string Function_Name = "GetDataPointByName";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");


            List <EtyDataLogDPTrend> etyDPTrendList = new List <EtyDataLogDPTrend>();

            string localSQL = "SELECT et.PKEY AS ENTITY_KEY,CONCAT(et.NAME,'.Value')as DP_NAME ,DP.DP_GRP_ID AS DP_GRP_ID FROM ENTITY et LEFT JOIN DATALOG_DP_TREND DP" +
                              " ON et.PKEY = DP.ENTITY_KEY WHERE TYPEKEY = (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint')" +
                              " AND UPPER(et.NAME) LIKE '%" + DAOHelper.convertEscapeStringAndGB2312To8859P1(DataPointNameSubstr) + "%'";

            string LocationClauseStr = DAOHelper.CheckLocationAndAddSQL(COLUMN_ENTITY_LOCATIONKEY);

            if (LocationClauseStr.Length != 0)
            {
                localSQL += " AND" + LocationClauseStr;
            }

            localSQL += " ORDER BY DP_NAME ";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        EtyDataLogDPTrend etyDPTrend = new EtyDataLogDPTrend();
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_ENTITY_KEY)))
                        {
                            etyDPTrend.EntityKey = Convert.ToDouble(drReader[COLUMN_ENTITY_KEY]);
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_NAME)))
                        {
                            etyDPTrend.OPCDataPointName = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_NAME].ToString());
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_SAMPLE_GRP_ID)))
                        {
                            etyDPTrend.OPCSampleGrpId = Convert.ToDouble(drReader[COLUMN_SAMPLE_GRP_ID]);
                        }
                        etyDPTrendList.Add(etyDPTrend);
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(etyDPTrendList);
        }
예제 #7
0
        public void TestInsertOPCDataPoint_UpdateOPCDataPointByName()
        {
            EtyDataLogDPTrend etyDataLogDPTrend = new EtyDataLogDPTrend();

            etyDataLogDPTrend.OPCDataPointName = "DT18.LV.MSB.LF211.diiPWRC-MSBCBNotcloseClose.Value";
            etyDataLogDPTrend.OPCSampleGrpId   = 6;
            etyDataLogDPTrend.Disabled         = false;
            DatalogDPTrendDAO.GetInstance().InsertOPCDataPoint(etyDataLogDPTrend);
            DatalogDPTrendDAO.GetInstance().UpdateOPCDataPointByName(etyDataLogDPTrend);
        }
        /// <summary>
        /// Returns the DataPoints based on the filterstring for specified server name.
        /// e.g. for filterstring can include substring datapoint name to search.
        /// </summary>
        /// <param name="opcServerName">datapoint server name</param>
        /// <param name="filterString">Where clause query string</param>
        /// <returns>Datapoints</returns>
        public List <EtyDataLogDPTrend> GetOPCDataPoint(string opcServerName, string filterString)
        {
            const string Function_Name = "GetOPCDataPoint";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");


            List <EtyDataLogDPTrend> etyDPTrendList = new List <EtyDataLogDPTrend>();

            string localSQL = "SELECT et.PKEY AS ENTITY_KEY,CONCAT(et.NAME,'.Value') as DP_NAME ,DP.DP_GRP_ID as DP_GRP_ID FROM ENTITY et LEFT JOIN DATALOG_DP_TREND DP"
                              + " ON et.PKEY = DP.ENTITY_KEY WHERE et.TYPEKEY = (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint')";

            if (filterString.Trim() != "")
            {
                localSQL += filterString;
            }
            localSQL += " ORDER BY DP_NAME ";


            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        EtyDataLogDPTrend etyDPTrend = new EtyDataLogDPTrend();
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_ENTITY_KEY)))
                        {
                            etyDPTrend.EntityKey = Convert.ToDouble(drReader[COLUMN_ENTITY_KEY]);
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_NAME)))
                        {
                            etyDPTrend.OPCDataPointName = DAOHelper.convert8859P1ToGB2312(drReader[COLUMN_NAME].ToString());
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_SAMPLE_GRP_ID)))
                        {
                            etyDPTrend.OPCSampleGrpId = Convert.ToDouble(drReader[COLUMN_SAMPLE_GRP_ID]);
                        }
                        etyDPTrendList.Add(etyDPTrend);
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }

                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(etyDPTrendList);
        }
예제 #9
0
        public void TestUpdateDataPointDB01()
        {
            OPCDataSelectorModel oPCDataSelectorModel = new OPCDataSelectorModel();
            EtyDataLogDPTrend    etyDP = new EtyDataLogDPTrend();

            //etyDP.OPCDataPointServer = "localserver";
            etyDP.EntityKey = 1;
            oPCDataSelectorModel.UpdateDataPointDB(etyDP);

            //test2
            etyDP.OPCDataPointName = "testing";
            oPCDataSelectorModel.UpdateDataPointDB(etyDP);
        }
        /// <summary>
        /// Updates DataPoint values in database based on either name or sample group id.
        /// </summary>
        /// <param name="etyDataPoint">DataPoint entity with updated values</param>
        public bool UpdateDataPointDB(EtyDataLogDPTrend etyDataPoint)
        {
            bool bResult = true;

            if (etyDataPoint.OPCDataPointName == null)
            {
                //clears the sample group and datapoint link for specified sample group
                bResult = DatalogDPTrendDAO.GetInstance().UpdateOPCDataPointByGrpId(etyDataPoint.Disabled, etyDataPoint.OPCSampleGrpId);
            }
            else
            {
                bResult = DatalogDPTrendDAO.GetInstance().UpdateOPCDataPointByName(etyDataPoint);
            }
            return(bResult);
        }
예제 #11
0
        public void TestEtyDataLogDPTrendConstructor01()
        {
            EtyDataLogDPTrend etyDataLogDPTrend = new EtyDataLogDPTrend();

            etyDataLogDPTrend.Disabled         = false;
            etyDataLogDPTrend.EntityKey        = 1;
            etyDataLogDPTrend.OPCDataPointDesc = "des";
            etyDataLogDPTrend.OPCDataPointName = "name";
            etyDataLogDPTrend.OPCSampleGrpId   = 1;
            etyDataLogDPTrend.Pkey             = 2;
            etyDataLogDPTrend.Disabled         = etyDataLogDPTrend.Disabled;
            etyDataLogDPTrend.EntityKey        = etyDataLogDPTrend.EntityKey;
            etyDataLogDPTrend.OPCDataPointDesc = etyDataLogDPTrend.OPCDataPointDesc;
            etyDataLogDPTrend.OPCDataPointName = etyDataLogDPTrend.OPCDataPointName;
            etyDataLogDPTrend.OPCSampleGrpId   = etyDataLogDPTrend.OPCSampleGrpId;
            etyDataLogDPTrend.Pkey             = etyDataLogDPTrend.Pkey;
        }
 public void UpdateDataPoints(EtyDataLogDPTrend sampleGrpEty, List <EtyDataLogDPTrend> selectedDataPoints)
 {
     DatalogDPTrendDAO.GetInstance().UpdateDataPoints(sampleGrpEty, selectedDataPoints);
 }