Beispiel #1
0
        /// <summary>
        /// Method through which Form commuicates with its controller.
        /// </summary>
        /// <param name="ctl">Form controller</param>
        public override void  AttachListener(IController ctl)
        {
            string Function_Name = "AttachListener";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            OPCSampleGrpConfigStartController controller = (OPCSampleGrpConfigStartController)ctl;
            //check the Database Connection
            bool bConnectionOpened = controller.GetDatabaseConnection();

            if (!bConnectionOpened)
            {
                LogHelper.Error("No Connection to Database. Closing the Form.");
                MessageBoxDialog.Show(StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLECONFIG_NODATABASECONN_MSG, EnglishString.OPC_MSG_NODB));
                this.Close();
            }

            //set Current location
            LocationKeyHelper.GetInstance().init();
            this.LocationKeyTextBox.Text = LocationKeyHelper.GetInstance().LocationKey.ToString();
            this.saveMsgCmd.Click       += controller.SaveCommand;
            this.intervalConfigDataGridView.CellDoubleClick += controller.IntervalConfigDataGridView_CellDoubleClick;
            this.RefreshGridData   += controller.RetriveAllOPCGrp;
            this.RefreshPageNumber += controller.RetriveTotalCount;
            this.Paint             += controller.AddLoggerInterval_Paint_1;
            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }
Beispiel #2
0
        public void FixtureSetUp()
        {
            //Test all the normal flow of all the functions:

            locationKeyHelper = LocationKeyHelper.GetInstance();
            TestDBInit.openConn();
        }
Beispiel #3
0
        /// <summary>
        /// Resets value of all edit related controls.
        /// </summary>
        public void ResetEditFields()
        {
            string Function_Name = "ResetEditFields";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            intervalNameTextBox.Text      = "";
            intervalDescTextBox.Text      = "";
            intervalUnitBox.Value         = 1;
            intervalTypeBox.SelectedIndex = INTERVALETYPE_MINUTE_INDEX;
            deltaValueBox.Value           = 1;
            dateTimePicker.Checked        = false;
            disableCheckBox.Checked       = true; // false;
            intervalNameTextBox.Enabled   = false;
            LocationKeyTextBox.Text       = LocationKeyHelper.GetInstance().LocationKey.ToString();
            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }
        /// <summary>
        ///  Inserts new sample group into database
        /// </summary>
        /// <param name="etyOPCGrp">new sample group entity</param>
        public bool InsertOPCGrpData(EtyDataLogDPGroupTrend etyDPGroupTrend)
        {
            string Function_Name = "InsertOPCGrpData";

            LogHelper.Trace(CLASS_NAME, Function_Name, string.Format("Function_Entered with params -  SampleGroup Name  = {0}", etyDPGroupTrend.SampleGrpName));

            SimpleDatabase.GetInstance().BeginTransaction();

            // Get The max pkey from the database first and then insert the group with pkey value.
            // To avoid having incorrect pkey value between stations , hence avoid concurrency problem
            SqlStatements sqlQueries = new SqlStatements();

            sqlQueries.OracleSql = DAOHelper.ORACLE_SEQ_FUNC_SQL;
            sqlQueries.MySqlStr  = DAOHelper.MYSQL_SEQ_FUNC_SQL;
            System.Data.IDataReader drReader = SimpleDatabase.GetInstance().ExecuteQueryWithSqls(sqlQueries);
            double nextPkey = 1;

            if (drReader != null && drReader.Read())
            {
                if (drReader.FieldCount == 1)
                {
                    nextPkey = Convert.ToDouble(drReader[0]);
                }
            }
            if (drReader != null)
            {
                drReader.Close();
                drReader.Dispose();
            }
            //
            //
            string enabled   = DAOHelper.GetEnabledStr(DAOHelper.ChangeBoolToStr(etyDPGroupTrend.Disabled));
            string startTime = "";

            if (etyDPGroupTrend.StartTime.Length != 0)
            {
                startTime = DateTime.Parse(etyDPGroupTrend.StartTime).ToString("dd/MM/yyyy HH:mm:ss");
            }
            string sample_grp_name = DAOHelper.convertEscapeStringAndGB2312To8859P1(etyDPGroupTrend.SampleGrpName);

            List <string> sqlStrings = new List <string>();

            for (int i = 0; i < 2; i++)
            {
                string date_func   = (i == 0) ? DAOHelper.ORACLE_DATE_FUNCTION : DAOHelper.MYSQL_DATE_FUNCTION;
                string date_format = (i == 0) ? DAOHelper.ORACLE_DATE_FORMAT : DAOHelper.MYSQL_DATE_FORMAT;
                if (startTime.Trim().Length != 0)
                {
                    string sql = "INSERT INTO DATALOG_DP_GROUP_TREND "
                                 + " (PKEY,NAME,DESCRIPTION,SAMPLE_INTERVAL,START_TIME,DELTA_VALUE,ENABLED,INTERVAL_TYPE,LOCATION_KEY)"
                                 + " VALUES"
                                 + " (" + nextPkey + ",'" + sample_grp_name + "'"
                                 + ",'" + DAOHelper.convertEscapeStringAndGB2312To8859P1(etyDPGroupTrend.SampleGrpDescription) + "'"
                                 + "," + etyDPGroupTrend.Interval
                                 + "," + date_func + "('" + startTime + "','" + date_format
                                 + "')," + etyDPGroupTrend.DeltaValue
                                 + ",'" + enabled + "'"
                                 + ",'" + etyDPGroupTrend.IntervalType + "',"
                                 + LocationKeyHelper.GetInstance().LocationKey.ToString() + ")";
                    sqlStrings.Add(sql);
                }
                else
                {
                    string sql = "INSERT INTO DATALOG_DP_GROUP_TREND "
                                 + " (PKEY,NAME,DESCRIPTION,SAMPLE_INTERVAL,DELTA_VALUE,ENABLED,INTERVAL_TYPE,LOCATION_KEY)"
                                 + " VALUES"
                                 + " (" + nextPkey + ",'" + sample_grp_name + "'"
                                 + ",'" + DAOHelper.convertEscapeStringAndGB2312To8859P1(etyDPGroupTrend.SampleGrpDescription) + "'"
                                 + "," + etyDPGroupTrend.Interval
                                 + "," + etyDPGroupTrend.DeltaValue
                                 + ",'" + enabled + "'"
                                 + ",'" + etyDPGroupTrend.IntervalType + "',"
                                 + LocationKeyHelper.GetInstance().LocationKey.ToString() + ")";
                    sqlStrings.Add(sql);
                }
            }

            List <SqlParameter> parameters = DAOHelper.CreateEnqueneParameters(sqlStrings);
            bool rRes = true;

            rRes = SimpleDatabase.GetInstance().ExecuteEnqueneProcedure(parameters);

            if (rRes)
            {
                rRes = DatalogConfigSettingsDAO.GetInstance().UpdateTrendVersionNum();
            }
            if (!rRes)
            {
                SimpleDatabase.GetInstance().RollbackTransaction();
            }
            else
            {
                SimpleDatabase.GetInstance().CommitTransaction();
            }

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
            return(rRes);
        }
 public bool IsOccLocation()
 {
     return(LocationKeyHelper.GetInstance().IsOCC);
 }
Beispiel #6
0
        /// <summary>
        /// Intializes the Sample Group Grid control columns.
        /// </summary>
        private void InitializeIntervalConfigDataGridView()
        {
            string Function_Name = "InitializeIntervalConfigDataGridView";

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

            intervalConfigDataGridView.Columns.Add(OPCSAMPLEGRPID_COL_NAME, OPCSAMPLEGRPID_COL_TEXT);
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_IDCOL_INDEX].Width = 50;
            intervalConfigDataGridView.Columns.Add(OPCSAMPLEGRPNAME_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRPNAME_COL_TEXT, EnglishString.OPCSAMPLEGRPNAME_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_NAMECOL_INDEX].Width = 250;
            intervalConfigDataGridView.Columns.Add(OPCSAMPLEGRPDESC_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRPDESC_COL_TEXT, EnglishString.OPCSAMPLEGRPDESC_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_DESCCOL_INDEX].Width = 300;
            intervalConfigDataGridView.Columns.Add(OPCSAMPLEINTERVAL_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEINTERVAL_COL_TEXT, EnglishString.OPCSAMPLEINTERVAL_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_INTERVALCOL_INDEX].Width = 60;
            intervalConfigDataGridView.Columns.Add(OPCSAMPLEINTERVALTYPE_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEINTERVALTYPE_COL_TEXT, EnglishString.OPCSAMPLEINTERVALTYPE_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_INTERVALTYPECOL_INDEX].Width = 95;
            intervalConfigDataGridView.Columns.Add(OPCSAMPLESTARTTIME_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLESTARTTIME_COL_TEXT, EnglishString.OPCSAMPLESTARTTIME_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_STARTTIMECOL_INDEX].Width = 80;
            this.intervalConfigDataGridView.Columns.Add(OPCSAMPLEDELTAVAL_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEDELTAVAL_COL_TEXT, EnglishString.OPCSAMPLEDELTAVAL_COL_TEXT));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_DELTAVALCOL_INDEX].Width = 92;



            this.intervalConfigDataGridView.Columns.Add(OPCSAMPLELOCATION_COL_NAME, StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRP_LOCATIONCOL_TEXT, EnglishString.OPCSAMPLEGRP_LOCATIONCOL_NAME));
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_LOCATIONNAME_INDEX].Width   = 80;
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_LOCATIONNAME_INDEX].Visible = false;
            if (LocationKeyHelper.GetInstance().IsOCC)
            {
                this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_LOCATIONNAME_INDEX].Visible = true;
                this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_DESCCOL_INDEX].Width        = 220;
            }


            DataGridViewImageColumn column4 = new DataGridViewImageColumn();

            column4.Image      = Properties.Resources.blank;
            column4.HeaderText = StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEDISABLE_COL_TEXT, OPCSAMPLEDISABLE_COL_NAME);
            this.intervalConfigDataGridView.Columns.Add(column4);
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_DISABLECOL_INDEX].Width = 70;


            DataGridViewImageColumn iconColumn1 = new DataGridViewImageColumn();

            iconColumn1.Image      = Properties.Resources.Notes_16_;
            iconColumn1.Name       = EnglishString.OPCSAMPLEGRP_EDITCOLUMN_NAME;
            iconColumn1.HeaderText = StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRP_EDITCOLUMN_TEXT, EnglishString.OPCSAMPLEGRP_EDITCOLUMN_NAME);
            intervalConfigDataGridView.Columns.Add(iconColumn1);
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_EDITCOLUMN_INDEX].Width = 50;

            DataGridViewImageColumn iconColumn2 = new DataGridViewImageColumn();

            iconColumn2.Image      = Properties.Resources.Erase_16_;
            iconColumn2.Name       = EnglishString.OPCSAMPLEGRP_DELETECOL_NAME;
            iconColumn2.HeaderText = StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRP_DELETECOL_TEXT, EnglishString.OPCSAMPLEGRP_DELETECOL_NAME);
            intervalConfigDataGridView.Columns.Add(iconColumn2);
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_DELETECOLUMN_INDEX].Width = 50;

            DataGridViewImageColumn iconColumn3 = new DataGridViewImageColumn();

            iconColumn3.Image      = Properties.Resources.nav_icon_insertkey;
            iconColumn3.Name       = EnglishString.OPCSAMPLEGRP_CONFIGCOL_NAME;
            iconColumn3.HeaderText = StringHelper.GetInstance().getStringValue(FormCaptionHelper.OPCSAMPLEGRP_CONFIGCOL_TEXT, EnglishString.OPCSAMPLEGRP_CONFIGCOL_NAME);
            intervalConfigDataGridView.Columns.Add(iconColumn3);
            this.intervalConfigDataGridView.Columns[OPCSAMPLEGRP_CONFIGCOLUMN_INDEX].Width = 50;

            intervalConfigDataGridView.Columns[OPCSAMPLEGRPID_COL_NAME].Visible = false;

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }