Esempio n. 1
0
        /// <summary>
        /// insert a new formula configuration to table TRENDVIEWER_FORMULA_CONFIG
        /// </summary>
        /// <param name="formulaList">the formula list included in the configuration</param>
        /// <param name="grpName">the configuration name</param>
        public bool InsertFormulaListToGrp(List <EtyFormula> formulaList, string grpName)
        {
            string Function_Name = "InsertFormulaListToGrp";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            bool executeOK = false;

            string localSQL = " INSERT INTO TRENDVIEWER_FORMULA_CONFIG(CONFIG_NAME,DATA_PT_EQUATION,DATA_PT_TYPE, " +
                              " DATA_PT_COLOR,DATA_PT_ENABLED,DATA_PT_LBL_ENABLED,DATA_PT_LBL_NAME) " +
                              " VALUES( '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(grpName) + "'";

            foreach (EtyFormula formula in formulaList)
            {
                executeOK = SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL
                                                                         + ",'" + formula.DPEquation.Replace("'", "''") + "'"
                                                                         + ",'" + DAOHelper.ConvertLineTypeToDBString(formula.DPType) + "'"
                                                                         + ",'" + formula.DPColor + "'"
                                                                         + ",'" + DAOHelper.ChangeBoolToStr(formula.DPEnabled) + "'"
                                                                         + ",'" + DAOHelper.ChangeBoolToStr(formula.DPLblEnabled) + "'"
                                                                         + ",'" + DAOHelper.convertEscapeStringAndGB2312To8859P1(formula.DPLblName) + "'"
                                                                         + " ) ");
                if (executeOK == false)
                {
                    break;
                }
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(executeOK);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the value of the specified variable name
        /// </summary>
        /// <param name="varName">Variable name</param>
        /// <returns>variable value</returns>
        public string GetVarValue(string varName)
        {
            string Function_Name = "GetVarValue";

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

            string varValue = "null";
            string localSQL = "SELECT VAR_VALUE FROM CONFIG_VARS WHERE VAR_NAME = '" + varName + "'";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        if (!drReader.IsDBNull(0))
                        {
                            varValue = drReader.GetString(0).ToString();
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }

                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(varValue);
        }
Esempio n. 3
0
        public void TestCreateCommand()
        {
            SimpleDatabase.GetInstance().BeginTransaction();

            SimpleDatabase.GetInstance().ExecuteNonQuery("select * from entity");
            SimpleDatabase.GetInstance().RollbackTransaction();
        }
        /// <summary>
        /// Returns the total sample group records count in table
        /// </summary>
        /// <returns>No of Sample group configured</returns>
        public int GetRowCount()
        {
            string Function_Name = "GetRowCount";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string localSQL;
            int    nRowCount = 0;

            localSQL = "SELECT COUNT(SAMPLE_GRP_NAME) AS MAXROWS FROM OPC_DT_SAMPLE_GRP";
            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(0))
                    {
                        LogHelper.Debug(CLASS_NAME, Function_Name, "Function_Exited");
                        nRowCount = Convert.ToInt32(drReader["MAXROWS"]);
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(nRowCount);
        }
        /// <summary>
        /// Updates the datapoints of specified name
        /// </summary>
        /// <param name="disabled">true-disabled , false - enabled</param>
        /// <param name="opcServerName">datapoint server name</param>
        /// <param name="sampleGrpId">sample group key</param>
        /// <param name="DataPointName">datapoint name to be updated</param>
        public void UpdateOPCDataPointByName(EtyOPCDataPoint etyDataPoint)  //bool disabled, string opcServerName, double sampleGrpId,string DataPointName)
        {
            const string Function_Name = "UpdateOPCDataPointByName";

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

            string localSQL = " UPDATE OPC_DT_PT "
                              + " SET SAMPLE_GRP_ID = " + etyDataPoint.OPCSampleGrpId.ToString()
                              + ",DISABLE =  '" + DAOHelper.ChangeBoolToStr(etyDataPoint.Disabled) + "'"
                              + " WHERE DATA_PT_NAME = '" + DAOHelper.convertGB2312To8859P1(etyDataPoint.OPCDataPointName.Trim()) + "'"
                              + " AND DATA_PT_SERVER = '" + DAOHelper.convertGB2312To8859P1(etyDataPoint.OPCDataPointServer.Trim()) + "'";

            //DBConnection.getInstance().ExecuteOracleNonQuery(localSQL, dbConn);
            if (!SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL))
            {
                string dpName = etyDataPoint.OPCDataPointName.Trim();
                if (dpName.Contains(".Value"))
                {
                    dpName = dpName.Remove(dpName.Length - 6);
                }
                //insert the datapoint into the OPC_dt_pt table.
                localSQL = "INSERT INTO OPC_DT_PT (DATA_PT_HOST, DATA_PT_SERVER, KEYID, DATA_PT_NAME, DATA_PT_DESC, PKEYID,SAMPLE_GRP_ID,DISABLE)"
                           + " (SELECT '127.0.0.1', 'TransActiveDataSource', PKEY,CONCAT(NAME,'.Value'),DESCRIPTION , PARENTKEY,"
                           + etyDataPoint.OPCSampleGrpId.ToString()
                           + ",'" + DAOHelper.ChangeBoolToStr(etyDataPoint.Disabled) + "'"
                           + " FROM ENTITY  WHERE TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataPoint' )"
                           + " AND NAME = '" + dpName + "')";

                SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL);
            }


            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }
Esempio n. 6
0
        /// <summary>
        /// retrieve all the configuration name for real-time charting.
        /// </summary>
        /// <returns></returns>
        public List <string> GetAllDPGrpNames()
        {
            string Function_Name = "GetAllDPGrpNames";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            List <string> dpGrpNames = new List <string>();
            string        localSQL   = " SELECT DISTINCT CONFIG_NAME FROM TRENDVIEWER_CONFIG order by config_name ";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        if (!drReader.IsDBNull(0))
                        {
                            dpGrpNames.Add(DAOHelper.convert8859P1ToGB2312(drReader["CONFIG_NAME"].ToString()));
                        }
                    }
                }
                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(dpGrpNames);
        }
        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;
        }
Esempio n. 8
0
        public string GetLocationNameFromKey(double locationKey)
        {
            string Function_Name = "GetLocationNameFromKey";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string locationName = "";
            string localSQL     = "SELECT NAME FROM LOCATION WHERE PKEY = " + locationKey.ToString();

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal("NAME")))
                    {
                        locationName = DAOHelper.convert8859P1ToGB2312(drReader["NAME"].ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
                //SimpleDatabase.GetInstance().CloseCurrentSession();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(locationName);
        }
        /// <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));
            }
        }
        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));
        }
Esempio n. 11
0
        public static void DatabaseToXML()
        {
            SimpleDatabase student = new SimpleDatabase {
            };

            student.Generate(10);
            string db = "";

            for (int k = 0; k < 10; k++)
            {
                db += student.students[k].name;
                db += ",";
                db += student.students[k].age.ToString();
                db += " ";
            }

            Console.WriteLine(db[10]);
            db = db.TrimEnd(); //Удаляем пробел в концк строки


            var flow = db.Split(' ').
                       Select(student => new XElement("student", new XElement("name", student.Split(',')[0]), new XElement("age", student.Split(',')[1])));
            XElement dbxml = new XElement("dbxml", flow);

            Console.WriteLine(dbxml.ToString());
        }
        public bool GetOPCDataPointByName(string dataPoint)
        {
            string Function_Name = "GetOPCDataPointByName";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string localSQL = "SELECT PKEY FROM DATALOG_DP_TREND WHERE DP_NAME = '" + dataPoint + "'";

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            bool bFound = false;

            try
            {
                if (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal(COLUMN_PKEY)))
                    {
                        bFound = true;
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(bFound);
        }
Esempio n. 13
0
        /// <summary>
        /// insert marker list to a marker group
        /// </summary>
        /// <param name="markerList">marker list</param>
        /// <param name="grpName">marker group name</param>
        public bool InsertMarkerListToGrp(List <EtyMarker> markerList, string grpName)
        {
            const string Function_Name = "InsertMarkerListToGrp";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            bool executeOK = false;

            string localSQL = " INSERT INTO TRENDVIEWER_MARKER(CONFIG_NAME,MARKER_NAME,MARKER_WIDTH,MARKER_BCOLOR,MARKER_VALUE,MARKER_ENABLED,MARKER_FCOLOR) " +
                              " VALUES( '" + DAOHelper.convertEscapeStringAndGB2312To8859P1(grpName) + "'";

            foreach (EtyMarker marker in markerList)
            {
                string markerEnabledStr = "Y";
                if (!marker.MarkerEnabled)
                {
                    markerEnabledStr = "N";
                }

                executeOK = SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL
                                                                         + ",'" + DAOHelper.convertEscapeStringAndGB2312To8859P1(marker.MarkerName) + "'"
                                                                         + ", " + marker.MarkerWidth.ToString()
                                                                         + ",'" + marker.MarkerBColor + "'"
                                                                         + ", " + marker.MarkerValue.ToString()
                                                                         + ",'" + markerEnabledStr + "'"
                                                                         + ",'" + marker.MarkerFColor + "'"
                                                                         + " ) ");
                if (executeOK == false)
                {
                    break;
                }
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(executeOK);
        }
        /// <summary>
        /// Returns Sample Group details of the specified Sample group Key.
        /// </summary>
        /// <param name="opcGrpID">Sample group key</param>
        /// <returns>Sample Group entity</returns>
        public EtyOPCSampleGroup GetOPCGrpByID(string opcGrpID)
        {
            string Function_Name = "GetOPCGrpByID";

            LogHelper.Trace(CLASS_NAME, Function_Name, string.Format("Function_Entered with params - {0}", opcGrpID));
            EtyOPCSampleGroup etyOPCSampleGrp = new EtyOPCSampleGroup();

            string localSQL = " SELECT SAMPLE_GRP_NAME,SAMPLE_GRP_DESC,SAMPLE_INTERVAL,INTERVAL_TYPE,START_TIME,DELTA_VALUE,DISABLE "
                              + " FROM OPC_DT_SAMPLE_GRP WHERE SAMPLE_GRP_ID = " + opcGrpID;

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);
            try
            {
                while (drReader != null && drReader.Read())
                {
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_GRP_NAME")))
                    {
                        etyOPCSampleGrp.SampleGrpName = DAOHelper.convert8859P1ToGB2312(drReader["SAMPLE_GRP_NAME"].ToString());
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_GRP_DESC")))
                    {
                        etyOPCSampleGrp.SampleGrpDescription = DAOHelper.convert8859P1ToGB2312(drReader["SAMPLE_GRP_DESC"].ToString());
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("SAMPLE_INTERVAL")))
                    {
                        etyOPCSampleGrp.Interval = Convert.ToInt32(drReader["SAMPLE_INTERVAL"]);
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("INTERVAL_TYPE")))
                    {
                        etyOPCSampleGrp.IntervalType = drReader["INTERVAL_TYPE"].ToString();
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("START_TIME")))
                    {
                        etyOPCSampleGrp.StartTime = drReader["START_TIME"].ToString();
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("DELTA_VALUE")))
                    {
                        etyOPCSampleGrp.DeltaValue = Convert.ToDouble(drReader["DELTA_VALUE"]);
                    }
                    if (!drReader.IsDBNull(drReader.GetOrdinal("DISABLE")))
                    {
                        etyOPCSampleGrp.Disabled = DAOHelper.ChangeStrToBool(drReader["DISABLE"].ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
            }

            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(etyOPCSampleGrp);
        }
Esempio n. 15
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
        }
        private SimpleDatabase CreateDatabase()
        {
            var db = new SimpleDatabase("TEST_" + Guid.NewGuid(), useTwoPhaseCommit: true);

            db.CreateTable(Constants.ReservationTableName, 96, 36);
            db.CreateTable(Constants.ResourcesTableName, 96, 36);
            return(db);
        }
Esempio n. 17
0
        public async void LiteralWhereTest()
        {
            var query  = "Select number from integers where literal = '2'";
            var result = await SimpleDatabase.Query(query);

            Assert.Single(result[1]);
            Assert.Equal("2", result[1][0]);
        }
Esempio n. 18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseRouting();

            SimpleDatabase student = new SimpleDatabase {
            };

            student.Generate(10);

            XElement html = new XElement("html",
                                         new XElement("head"),
                                         new XElement("body",
                                                      new XElement("table",
                                                                   new XAttribute("border", 1),
                                                                   new XElement("tr", student.Elements()
                                                                                .Select(x => new XElement("td",
                                                                                                          new XElement("a", x.name, new XAttribute("href", x.name + ".html")))),
                                                                                new XElement("tr", student.Elements()
                                                                                             .Select(x => new XElement("td", $"{x.age}"))))))); //пробел с помощью div

            var files = Enumerable.Range(0, 10)
                        .Select(x => new XDocument(new XElement("html", new XElement("head", new XElement("body", x))))
                                );

            int i = 0;

            foreach (var elem in files)
            {
                elem.Save($"Student{i}.ml");
                i++;
            }



            XDocument doc = new XDocument(new XElement("html",
                                                       new XElement("head",
                                                                    new XElement("body",
                                                                                 new XElement("age", "sljgsljg")))));

            XElement el = new XElement("html",
                                       new XElement("head",
                                                    new XElement("body",
                                                                 doc.Element("age"))));

            app.UseStaticFiles();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    string path = context.Request.Path; //запрос котoрый посылается
                    await context.Response.WriteAsync(html.ToString());
                });
            });
        }
Esempio n. 19
0
        protected void InitStorage()
        {
            var database = new SimpleDatabase("MYRM_" + _name, true);

            //TODO: BUGBUG: add validation to check the data and key length
            database.CreateTable(Constants.ReservationTableName, 96, 36);
            database.CreateTable(Constants.ResourcesTableName, 96, 36);
            _transactionStorage = new TransactionStorage(database);
        }
        /// <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);
        }
        /// <summary>
        /// Returns all the Root Data Nodes.
        /// </summary>
        /// <returns>Root Data Nodes</returns>
        public List <EtyOPCDataNode> GetAllOPCDataNode(string serverRootName, string opcServerName)
        {
            const string Function_Name = "GetAllOPCDataNode";

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


            List <EtyOPCDataNode> OPCDataNodeList = new List <EtyOPCDataNode>();

            string localSQL = " SELECT KEYID,DT_NODE_NAME,DT_NODE_DESC " +
                              " FROM OPC_DT_NODE WHERE PKEYID  IN (SELECT DISTINCT PKEY FROM ENTITY WHERE NAME = '" + serverRootName + "') AND DISABLE = 'N' AND DATA_PT_SERVER = '" + opcServerName
                              + "' ORDER BY DT_NODE_NAME";

            //sql for getting from entity table

            /*string localSQL = " SELECT PKEY,NAME,DESCRIPTION" +
             *                      " FROM ENTITY WHERE TYPEKEY = (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'DataNode')"+
             *                      " AND PARENTKEY  IN (SELECT DISTINCT PKEY FROM ENTITY WHERE TYPEKEY IN (SELECT PKEY FROM ENTITYTYPE WHERE NAME = 'SCADAROOT'))"+
             *                      " ORDER BY NAME";*/

            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQuery(localSQL);

            if (drReader != null)
            {
                try
                {
                    while (drReader.Read())
                    {
                        EtyOPCDataNode etyOPCDataNode = new EtyOPCDataNode();
                        if (!drReader.IsDBNull(drReader.GetOrdinal("KEYID")))
                        {
                            etyOPCDataNode.OPCDataNodeId = Convert.ToDouble(drReader["KEYID"]);
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal("DT_NODE_NAME")))
                        {
                            etyOPCDataNode.OPCDataNodeName = DAOHelper.convert8859P1ToGB2312(drReader["DT_NODE_NAME"].ToString());
                        }
                        if (!drReader.IsDBNull(drReader.GetOrdinal("DT_NODE_DESC")))
                        {
                            etyOPCDataNode.OPCDataNodeDesc = DAOHelper.convert8859P1ToGB2312(drReader["DT_NODE_DESC"].ToString());
                        }
                        OPCDataNodeList.Add(etyOPCDataNode);
                    }
                }
                catch (System.Exception ex)
                {
                    LogHelper.Error(CLASS_NAME, Function_Name, ex.ToString());
                }
                drReader.Close();
                drReader.Dispose();
            }


            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(OPCDataNodeList);
        }
Esempio n. 22
0
        public void TestSessionStoreConstructor01()
        {
            SessionStore    sessionStore = new SessionStore();
            DatabaseSession session      = new DatabaseSession(TestDBInit.localConnectionString2);

            sessionStore.Store(TestDBInit.localConnectionString2, session);
            sessionStore.Dispose("");
            DBConnectionStrings.ReleaseInstance();
            SimpleDatabase.ReleaseInstance();
        }
Esempio n. 23
0
        public void FixtureSetUp()
        {
            DBConnectionStrings.GetInstance().AddConnectionString(TestConst.CONNECTION_STR);
            SimpleDatabase.GetInstance().OpenConnection();
            ViewManager.GetInstance().RegisterViewFactory(new TrendingViewFactory());
            IView view = ViewManager.GetInstance().GetView(TrendViewConst.OPCDataSelector, TestConst.TEST_VIEW_ID);

            oPCDataSelectorController = (OPCDataSelectorController)(view.getController());
            //oPCDataSelectorController.InitDataNodeList();
        }
Esempio n. 24
0
        /// <summary>
        /// Updates the value of the variable name.
        /// </summary>
        /// <param name="VarName">varaible name </param>
        /// <param name="VarValue">varaible value</param>
        public void UpdateValue(string VarName, string VarValue)
        {
            string Function_Name = "UpdateValue";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            string localSQL = "UPDATE CONFIG_VARS SET VAR_VALUE = '" + VarValue + "' WHERE VAR_NAME = '" + VarName + "'";

            SimpleDatabase.GetInstance().ExecuteNonQuery(localSQL);
            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }
        /// <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);
        }
Esempio n. 26
0
        public void FixtureSetUp()
        {
            DBConnectionStrings.GetInstance().AddConnectionString(TestConst.CONNECTION_STR);
            SimpleDatabase.GetInstance().OpenConnection();
            ViewManager.GetInstance().RegisterViewFactory(new TrendingViewFactory());
            IView view = ViewManager.GetInstance().GetView(TrendViewConst.TrendView, TestConst.TEST_VIEW_ID);  //viewID is ""

            trendView = (TrendView)view;
            ConfigureFileHelper.GetInstance().init();
            viewAccessor = ReflectionAccessor.Wrap(trendView);
        }
Esempio n. 27
0
        public async void WhereTest()
        {
            var query  = "Select number from integers where number > 2";
            var result = await SimpleDatabase.Query(query);

            for (var i = 0; i < 8; i++)
            {
                Assert.Equal(i + 3 + "", result[i + 1][0]);
                Assert.Single(result[i + 1]);
            }
        }
Esempio n. 28
0
        public async void SingleColumnTest()
        {
            var query  = "Select number from integers";
            var result = await SimpleDatabase.Query(query);

            for (var i = 0; i < 10; i++)
            {
                Assert.Equal(i + "", result[i + 1][0]);
                Assert.Single(result[i + 1]);
            }
        }
Esempio n. 29
0
        public void FixtureSetUp()
        {
            ViewManager.GetInstance().RegisterViewFactory(new TrendingViewFactory());
            IView view = ViewManager.GetInstance().GetView(TrendViewConst.TrendView, TestConst.TEST_VIEW_ID);

            trendViewController = (TrendViewController)view.getController();
            if (DBConnectionStrings.GetInstance().GetConnectionStrings().Count < 1)
            {
                DBConnectionStrings.GetInstance().AddConnectionString(TestConst.CONNECTION_STR);
                SimpleDatabase.GetInstance().OpenConnection();
            }
        }
Esempio n. 30
0
        public async Task SimpleTest()
        {
            var query  = "Select * from integers";
            var result = await SimpleDatabase.Query(query);

            Assert.Equal("Number", result[0][0]);
            Assert.Equal("Literal", result[0][1]);
            for (var i = 0; i < 10; i++)
            {
                Assert.Equal(i + "", result[i + 1][0]);
                Assert.Equal(i + "", result[i + 1][1]);
            }
        }
Esempio n. 31
0
        private static void Generate()
        {
            lock (_migrationLock)
            {
                var groups = new List<BubbleGroup>();
                var serviceNames = new Dictionary<string, string>();

                // Load all normal groups

                var bubbleGroupsLocations = Directory.GetFiles(BubbleGroupDatabase.GetBaseLocation(), "*.*", SearchOption.AllDirectories);
                var bubbleGroupsLocationsSorted =
                    bubbleGroupsLocations.OrderByDescending(x => Time.GetUnixTimestamp(File.GetLastWriteTime(x))).ToList();

                foreach (var bubbleGroupLocation in bubbleGroupsLocationsSorted)
                {
                    String groupId = null;
                    try
                    {
                        var groupHeader = Path.GetFileNameWithoutExtension(bubbleGroupLocation);

                        var groupDelimeter = groupHeader.IndexOf("^", StringComparison.Ordinal);
                        var serviceName = groupHeader.Substring(0, groupDelimeter);
                        groupId = groupHeader.Substring(groupDelimeter + 1);

                        serviceNames.Add(groupId, serviceName);
                        Service service = null;

                        var deserializedBubbleGroup = LoadPartiallyIfPossible(bubbleGroupLocation, 
                                                      service, groupId, 100);
                        if (deserializedBubbleGroup == null)
                        {
                            throw new Exception("DeserializedBubbleGroup is nothing.");
                        }

                        groups.Add(deserializedBubbleGroup);
                    }
                    catch (Exception ex)
                    {
                        Utils.DebugPrint("[Migration] Group " + bubbleGroupLocation + " is corrupt (deleting): " + ex);
                        if (File.Exists(bubbleGroupLocation))
                        {
                            File.Delete(bubbleGroupLocation);
                        }
                    }
                }

                // Load all unified groups

                var unifiedBubbleGroupsDatabase =
                    new SimpleDatabase<UnifiedBubbleGroup, DisaUnifiedBubbleGroupEntry>("UnifiedBubbleGroups");
                foreach (var group in unifiedBubbleGroupsDatabase)
                {
                    var innerGroups = new List<BubbleGroup>();
                    foreach (var innerGroupId in @group.Serializable.GroupIds)
                    {
                        var innerGroup = groups.FirstOrDefault(x => x.ID == innerGroupId);
                        if (innerGroup == null)
                        {
                            Utils.DebugPrint("[Migration] Unified group, inner group " + innerGroupId + " could not be related.");
                        }
                        else
                        {
                            innerGroups.Add(innerGroup);
                        }
                    }
                    if (!innerGroups.Any())
                    {
                        Utils.DebugPrint("[Migration] This unified group has no inner groups. Skipping this unified group.");
                        continue;
                    }

                    var primaryGroup = innerGroups.FirstOrDefault(x => x.ID == @group.Serializable.PrimaryGroupId);
                    if (primaryGroup == null)
                    {
                        Utils.DebugPrint("[Migration] Unified group, primary group " + @group.Serializable.PrimaryGroupId +
                        " could not be related. Skipping this unified group.");
                        continue;
                    }

                    var id = @group.Serializable.Id;

                    var unifiedGroup = BubbleGroupFactory.CreateUnifiedInternal(innerGroups, primaryGroup, id);

                    var sendingGroup = innerGroups.FirstOrDefault(x => x.ID == @group.Serializable.SendingGroupId);
                    if (sendingGroup != null)
                    {
                        unifiedGroup.SendingGroup = sendingGroup;
                    }
                        
                    groups.Add(unifiedGroup);
                }

                // save it to the new index

                var entries = new List<Entry>();
                foreach (var group in groups)
                {
                    var unified = group as UnifiedBubbleGroup;
                    if (unified == null)
                    {
                        var lastBubble = group.LastBubbleSafe();
                        var serviceName = serviceNames[group.ID];
                        if (serviceName != null)
                        {
                            entries.Add(new Entry
                            {
                                Guid = group.ID,
                                Service = serviceName,
                                LastBubble = SerializeBubble(lastBubble),
                                LastBubbleGuid = lastBubble.ID
                            });
                        }
                        else
                        {
                            Utils.DebugPrint("[Migration] Weird... there's no associated service name!");
                        }
                    }
                    else
                    {
                        entries.Add(new Entry
                        {
                            Guid = group.ID,
                            Unified = true,
                            UnifiedBubbleGroupsGuids = unified.Groups.Select(x => x.ID).
                            Aggregate((current, next) => current + "," + next),
                            UnifiedPrimaryBubbleGroupGuid = unified.PrimaryGroup.ID,
                            UnifiedSendingBubbleGroupGuid = unified.SendingGroup.ID,
                        });
                    }
                }
                Save(entries.ToArray());
            }
        }
Esempio n. 32
0
 internal static void Initialize()
 {
     UnifiedBubbleGroupsDatabase =
         new SimpleDatabase<UnifiedBubbleGroup, DisaUnifiedBubbleGroupEntry>("UnifiedBubbleGroups");
 }