Ejemplo n.º 1
0
        public override void setDataGridViewAdmin(DateTime date)
        {
            int hour = -1
            , offset = -1;
            string strFmtDatetime = string.Empty;
            double PBR_0          = 0F;

            HAdmin.RDGStruct[] arSumCurRDGValues = null;

            (m_admin as AdminTS_Vyvod).SummatorRDGValues();

            if ((m_admin as AdminTS_TG).CompletedGetRDGValues == true)
            {
                //??? не очень изящное решение
                if (IsHandleCreated /*InvokeRequired*/ == true)
                {
                    m_evtAdminTableRowCount.Reset();
                    this.BeginInvoke(new DelegateFunc(normalizedTableHourRows));
                    m_evtAdminTableRowCount.WaitOne(System.Threading.Timeout.Infinite);
                }
                else
                {
                    Logging.Logg().Error(@"PanelTAdminKomDisp::setDataGridViewAdmin () - ... BeginInvoke (normalizedTableHourRows) - ...", Logging.INDEX_MESSAGE.D_001);
                }
                // получить значения из объекта для обращения к данным
                PBR_0 =
                    (this.dgwAdminTable as DataGridViewAdminVyvod).m_PBR_0 =
                        (m_admin as AdminTS_Vyvod).m_SumRDGValues_PBR_0;
                arSumCurRDGValues = new HAdmin.RDGStruct[(m_admin as AdminTS_Vyvod).m_arSumRDGValues.Length];
                (m_admin as AdminTS_Vyvod).m_arSumRDGValues.CopyTo(arSumCurRDGValues, 0);

                for (hour = 0; hour < arSumCurRDGValues.Length; hour++)
                {
                    strFmtDatetime = m_admin.GetFmtDatetime(hour);
                    offset         = m_admin.GetSeasonHourOffset(hour + 1);

                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DATE_HOUR].Value = date.AddHours(hour + 1 - offset).ToString(strFmtDatetime);

                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.PLAN].Value       = arSumCurRDGValues[hour].pmin.ToString("F2");
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.PLAN].ToolTipText = arSumCurRDGValues[hour].pbr_number;

                    // UDGt вычисляется в 'DataGridViewAdminVyvod::onCellValueChanged'

                    (this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.RECOMENDATION] as DataGridViewComboBoxCell).Value = (object)(((int)arSumCurRDGValues[hour].recomendation).ToString());
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.RECOMENDATION].ToolTipText = arSumCurRDGValues[hour].dtRecUpdate.ToString();
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION_TYPE].Value      = arSumCurRDGValues[hour].deviationPercent.ToString();
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION].Value           = arSumCurRDGValues[hour].deviation.ToString("F2");
                }
            }
            else
            {
                ; // рано отображать, не все компоненнты(параметры) опрошены
            }
            m_admin.CopyCurToPrevRDGValues();
        }
Ejemplo n.º 2
0
            public ImportCSV()
            {
                DataTable m_tablePPBRValuesResponse = null;
                string    m_fullPathPPBRCSVValue    = @"D:" //Path.GetDirectoryName(Environment.GetCommandLineArgs()[0])
                                                      + @"\" + @"ГТП(генерация) Сессия(13) от 24.12.2014.csv";

                int    err = -1;
                string strPPBRCSVNameFileTemp = Path.GetFileNameWithoutExtension(m_fullPathPPBRCSVValue)
                , strMes = string.Empty;;

                strPPBRCSVNameFileTemp = strPPBRCSVNameFileTemp.Replace("(", string.Empty);
                strPPBRCSVNameFileTemp = strPPBRCSVNameFileTemp.Replace(")", string.Empty);
                strPPBRCSVNameFileTemp = strPPBRCSVNameFileTemp.Replace(".", string.Empty);
                strPPBRCSVNameFileTemp = strPPBRCSVNameFileTemp.Replace(" ", string.Empty);
                strPPBRCSVNameFileTemp = Path.GetDirectoryName(m_fullPathPPBRCSVValue) + @"\" +
                                         strPPBRCSVNameFileTemp +
                                         Path.GetExtension(m_fullPathPPBRCSVValue);

                ////при аргументе = каталог размещения наборов
                //strPPBRCSVNameFile = m_PPBRCSVDirectory + strPPBRCSVNameFile + strCSVExt;
                //strPPBRCSVNameFileTemp = m_PPBRCSVDirectory + strPPBRCSVNameFileTemp + strCSVExt;

                //File.Copy(strPPBRCSVNameFile, strPPBRCSVNameFileTemp, true);
                File.Copy(m_fullPathPPBRCSVValue, strPPBRCSVNameFileTemp, true);

                StreamReader sr   = new StreamReader(strPPBRCSVNameFileTemp);
                string       cont = sr.ReadToEnd().Replace(',', '.');

                sr.Close(); sr.Dispose();
                StreamWriter sw = new StreamWriter(strPPBRCSVNameFileTemp);

                sw.Write(cont); sw.Flush(); sw.Close(); sw.Dispose();

                if (!(m_tablePPBRValuesResponse == null))
                {
                    m_tablePPBRValuesResponse.Clear();
                }
                else
                {
                    ;
                }

                if (strPPBRCSVNameFileTemp.Length > 0)
                {
                    m_tablePPBRValuesResponse = DbTSQLInterface.Select(@"CSV_DATASOURCE=" + Path.GetDirectoryName(strPPBRCSVNameFileTemp),
                                                                       @"SELECT * FROM ["
                                                                       //+ @"Sheet1$"
                                                                       + Path.GetFileName(strPPBRCSVNameFileTemp)
                                                                       + @"]"
                                                                       //+ @" WHERE GTP_ID='" +
                                                                       //allTECComponents[indxTECComponents].name_future +
                                                                       //@"'"
                                                                       , out err);
                }
                else
                {
                    ;
                }

                File.Delete(strPPBRCSVNameFileTemp);

                int    hour = -1;
                double val  = -1F;

                HAdmin.RDGStruct  [] curRDGValues = new HAdmin.RDGStruct [24];
                string name_future = @"GNOVOS02"
                , pbr_number       = string.Empty;

                //Получить значения для сохранения
                DataRow[] rowsTECComponent = m_tablePPBRValuesResponse.Select(@"GTP_ID='" + name_future + @"'");
                //Проверить наличие записей для ГТП
                if (rowsTECComponent.Length > 0)
                {
                    foreach (DataRow r in rowsTECComponent)
                    {
                        hour = int.Parse(r[@"SESSION_INTERVAL"].ToString());

                        if (double.TryParse(r[@"TotalBR"].ToString(), out val) == false)
                        {
                            if (hour > 0)
                            {
                                curRDGValues[hour].pbr = curRDGValues[hour - 1].pbr;
                            }
                            else
                            {
                                ;
                            }
                        }
                        else
                        {
                            curRDGValues[hour].pbr = val;
                        }

                        curRDGValues[hour].pmin = double.Parse(r[@"PminBR"].ToString());
                        curRDGValues[hour].pmax = double.Parse(r[@"PmaxBR"].ToString());

                        strMes = String.Format(@"Час: {0}\tПБР={1}\tПБРмин={2}\tПБРмакс={3}",
                                               hour.ToString(@"00"), curRDGValues[hour].pbr, curRDGValues[hour].pmin, curRDGValues[hour].pmax);
                        Console.WriteLine(strMes);

                        curRDGValues[hour].pbr_number = pbr_number;
                    }
                }
                else
                {
                    ;
                }
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Заполнить представление значениями
        ///  , при необходимости переносит выполнение в собственный поток
        ///  для регулирования доступа к элементам управления
        /// </summary>
        /// <param name="date">Дата отображаемых значений</param>
        /// <param name="bNewValues">Признак наличия новых значений, иначе требуется изменить оформление представления</param>
        public override void SetDataGridViewAdmin(DateTime date, bool bNewValues)
        {
            int hour = -1
            , offset = -1;
            string strFmtDatetime = string.Empty;
            double PBR_0          = 0F;

            HAdmin.RDGStruct[] arSumCurRDGValues = null;
            IAsyncResult       iar;

            (m_admin as AdminTS_Vyvod).SummatorRDGValues();

            if ((m_admin as AdminTS_TG).CompletedGetRDGValues == true)
            {
                //??? не очень изящное решение
                if (IsHandleCreated == true)
                {
                    if (InvokeRequired == true)
                    {
                        //m_evtAdminTableRowCount.Reset ();
                        iar = this.BeginInvoke(new DelegateBoolFunc(normalizedTableHourRows), InvokeRequired);
                        //m_evtAdminTableRowCount.WaitOne (System.Threading.Timeout.Infinite);
                        WaitHandle.WaitAny(new WaitHandle [] { iar.AsyncWaitHandle }, System.Threading.Timeout.Infinite);
                        this.EndInvoke(iar);
                    }
                    else
                    {
                        normalizedTableHourRows(InvokeRequired);
                    }
                }
                else
                {
                    Logging.Logg().Error(@"PanelAdminVyvod::setDataGridViewAdmin () - ... BeginInvoke (normalizedTableHourRows) - ...", Logging.INDEX_MESSAGE.D_001);
                }

                // получить значения из объекта для обращения к данным
                PBR_0 =
                    (this.dgwAdminTable as DataGridViewAdminVyvod).m_PBR_0 =
                        (m_admin as AdminTS_Vyvod).m_SumRDGValues_PBR_0;
                arSumCurRDGValues = new HAdmin.RDGStruct[(m_admin as AdminTS_Vyvod).m_arSumRDGValues.Length];
                (m_admin as AdminTS_Vyvod).m_arSumRDGValues.CopyTo(arSumCurRDGValues, 0);

                this.dgwAdminTable.DefaultCellStyle.BackColor = this.dgwAdminTable.BackColor;

                for (hour = 0; hour < arSumCurRDGValues.Length; hour++)
                {
                    strFmtDatetime = m_admin.GetFmtDatetime(hour);
                    offset         = m_admin.GetSeasonHourOffset(hour + 1);

                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DATE_HOUR].Value = date.AddHours(hour + 1 - offset).ToString(strFmtDatetime);
                    //this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.DATE_HOUR].Style.BackColor = this.dgwAdminTable.BackColor;

                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.PLAN].Value       = arSumCurRDGValues[hour].pmin.ToString("F2");
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.PLAN].ToolTipText = arSumCurRDGValues[hour].pbr_number;
                    //this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.PLAN].Style.BackColor = this.dgwAdminTable.BackColor;

                    // UDGt вычисляется в 'DataGridViewAdminVyvod::onCellValueChanged'

                    (this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.RECOMENDATION] as DataGridViewComboBoxCell).Value = (object)(((int)arSumCurRDGValues[hour].recomendation).ToString());
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.RECOMENDATION].ToolTipText = arSumCurRDGValues[hour].dtRecUpdate.ToString();
                    //this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.RECOMENDATION].Style.BackColor = this.dgwAdminTable.BackColor;
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION_TYPE].Value = arSumCurRDGValues[hour].deviationPercent.ToString();
                    //this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION_TYPE].Style.BackColor = this.dgwAdminTable.BackColor;
                    this.dgwAdminTable.Rows[hour].Cells[(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION].Value = arSumCurRDGValues[hour].deviation.ToString("F2");
                    //this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.DEVIATION].Style.BackColor = this.dgwAdminTable.BackColor;

                    //if (bNewValues == false) {
                    //// самостоятельно изменяем цвет фона, т.к. в этих столбцах ячейки "обновляются" при проверке/изменении значений
                    //    this.dgwAdminTable.Rows [hour].Cells [(int)DataGridViewAdminVyvod.DESC_INDEX.UDGt].Style.BackColor = this.dgwAdminTable.BackColor;
                    //} else
                    //    ;
                }
            }
            else
            {
                ; // рано отображать, не все компоненнты(параметры) опрошены
            }
            if (bNewValues == true)
            {
                m_admin.CopyCurToPrevRDGValues();
            }
            else
            {
                ;
            }
        }