Exemple #1
0
        public void Test_Delete_Insert_GetHistDPGrp()
        {
            string histDPGrpName = "unitTest_histDPGrp";

            histDataPointDAO.DeleteAllHistDPInGrp(histDPGrpName);

            List <EtyHistDataPoint> histDPList = new List <EtyHistDataPoint>();
            EtyHistDataPoint        dp1        = new EtyHistDataPoint();
            EtyHistDataPoint        dp2        = new EtyHistDataPoint();

            dp1.DPName    = "histDP1";
            dp2.DPName    = "histDP2";
            dp1.EntityKey = 1;
            dp2.DPColor   = Color.Red.ToArgb().ToString();
            dp2.DPLblName = "lbl1";
            dp2.DPServer  = TestDBInit.OPCSERVER_NAME;
            dp2.DPHost    = TestDBInit.HOST_NAME;
            histDPList.Add(dp1);
            histDPList.Add(dp2);

            // histDataPointDAO.InsertHistDPListToGrp(histDPList, histDPGrpName);
            histDataPointDAO.SaveHistDPListToGrp(histDPList, histDPGrpName);

            histDataPointDAO.GetHistDPByCfgName(histDPGrpName);
        }
        public void SaveHistDPListToGroup(List <EtyHistDataPoint> dpList, string grpName)
        {
            //This dpList contains EtyHistDataPoint with EntityKey already

//             EntityDAO entityDAO = new EntityDAO();
//
//             foreach (EtyHistDataPoint dp in dpList)
//             {
//                 string dpNameWithoutSuffix = "";
//                 if (dp.DPName.Contains(".Value"))
//                 {
//                     dpNameWithoutSuffix = dp.DPName.Remove(dp.DPName.Length - 6);
//                 }
//                 //use long, so if there is no entity found, return 0.
//                 //There is no entity which (pkey=0 and type is DataPoint)
//                 ulong entityKey = entityDAO.FindDataPointEtyKeyByName(dpNameWithoutSuffix);
//
//                 dp.PKey = entityKey;  //if not found in entity table, pkey=0
//
//             }

            HistDataPointDAO dpDAO = new HistDataPointDAO();

            //make it as a transaction
            dpDAO.SaveHistDPListToGrp(dpList, grpName);

            //dpDAO.DeleteAllHistDPInGrp(grpName);
            //dpDAO.InsertHistDPListToGrp(dpList, grpName); //if dp.pkey=0, insert null into this column,
        }