Пример #1
0
        public IndicatorEditForm(IndicatorInfo indicator)
        {
            InitializeComponent();


            CurrentIndicator = indicator;

            foreach (var item in Globals.GetTechnicalIndicatorList())
            {
                comboIndicator.Properties.Items.Add(item);
            }

            if (indicator != null)
            {
                // means we are editing the indicator
                comboIndicator.Text  = indicator.Name;
                comboInputValue.Text = indicator.InputValue;
                chkVisible.Checked   = indicator.Visible;

                comboIndicator.Enabled = false;
            }
            else
            {
                comboIndicator.Text  = Globals.GetTechnicalIndicatorList()[0];
                comboInputValue.Text = "Close";
                chkVisible.Checked   = true;
            }
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,ShortName,Unit")] IndicatorInfo indicatorInfo)
        {
            if (id != indicatorInfo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(indicatorInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IndicatorInfoExists(indicatorInfo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(indicatorInfo));
        }
Пример #3
0
        /// <summary>
        /// 得到绑定汽机或锅炉(TargetType:耗差类型:0可控耗差,1不可控耗差。ConsumeType:指标类型:0锅炉指标,1汽机指标)
        /// </summary>
        /// <returns></returns>
        public List <IndicatorInfo> GetInfo(string beginTime, string endTime, string unitId, string paraId, out string errMsg)
        {
            List <IndicatorInfo> list = new List <IndicatorInfo>();

            List <VerticalInfo> infos = new List <VerticalInfo>();

            IndicatorInfo sb = new IndicatorInfo();

            DataTable dt      = new DataTable();
            DataTable dtTable = new DataTable();

            dtTable = GetTableName(unitId, paraId, out errMsg);
            string tableName = dtTable.Rows.Count == 0 ? string.Empty : dtTable.Rows[0]["T_OUTTABLE"].ToString();
            string unit      = dtTable.Rows.Count == 0 ? string.Empty : dtTable.Rows[0]["T_UNIT"].ToString();

            //得到实际值
            if (!string.IsNullOrEmpty(tableName))
            {
                dt = be.GetBase(tableName, beginTime, endTime, unitId, paraId, out errMsg);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.Name      = String.IsNullOrEmpty(dr["T_DESC"].ToString()) ? String.Empty : dr["T_DESC"].ToString();
                        sb.RealValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                        sb.Unit      = unit;
                        list.Add(sb);
                    }
                }
            }

            return(list);
        }
Пример #4
0
        protected override void OnInit()
        {
            // Create instance of required indicator
            IndicatorInfo emaIndicatorInfo = Core.Instance.Indicators.All.FirstOrDefault(info => info.Name == "SuperTrend");

            superTrendInd = Core.Instance.Indicators.CreateIndicator(emaIndicatorInfo);

            // Use previous stored settings
            if (superTrendIndSettings != null)
            {
                superTrendInd.Settings = superTrendIndSettings;
            }
            // Set default settings
            else
            {
                superTrendInd.Settings = new List <SettingItem>
                {
                    new SettingItemInteger("ATR period", 11),
                    new SettingItemDouble("Digit", 4),
                };
            }

            // Add indicator
            AddIndicator(superTrendInd);
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            CurrentIndicator = GetCurrentIndicator();

            this.Close();
        }
Пример #6
0
        /// <summary>
        /// 得到绑定汽机或锅炉(TargetType:指标类型:0锅炉指标,1汽机指标。ConsumeType:耗差类型:0可控耗差,1不可控耗差)
        /// </summary>
        /// <returns></returns>
        public List <IndicatorInfo> GetInfo(string beginTime, string endTime, string companyId, string plantId, string unitId, int TargetType, int ConsumeType, out string errMsg)
        {
            List <IndicatorInfo> list = new List <IndicatorInfo>();

            List <FirstInfo> infos = new List <FirstInfo>();

            infos = GetFirstInfo(companyId, plantId, unitId, TargetType, ConsumeType, out errMsg);

            foreach (var i in infos)
            {
                IndicatorInfo sb = new IndicatorInfo();

                DataTable dt = new DataTable();
                //dt = be.GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId + "_el_B", TargetType, ConsumeType, out errMsg);

                ////得到基准值和指标类型和耗差类型
                //if (dt != null)
                //{
                //    foreach (DataRow dr in dt.Rows)
                //    {
                //        sb.Name = String.IsNullOrEmpty(dr["T_DESC"].ToString()) ? String.Empty : dr["T_DESC"].ToString();
                //        sb.TargetType = String.IsNullOrEmpty(dr["I_TARGETTYPE"].ToString()) ? String.Empty : dr["I_TARGETTYPE"].ToString();
                //        sb.ConsumeType = String.IsNullOrEmpty(dr["I_CONSUMETYPE"].ToString()) ? String.Empty : dr["I_CONSUMETYPE"].ToString();
                //        sb.StandardValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                //    }
                //}

                //得到实际值
                dt = be.GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId, out errMsg);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.Name        = String.IsNullOrEmpty(dr["T_DESC"].ToString()) ? String.Empty : dr["T_DESC"].ToString();
                        sb.TargetType  = String.IsNullOrEmpty(dr["I_TARGETTYPE"].ToString()) ? String.Empty : dr["I_TARGETTYPE"].ToString();
                        sb.ConsumeType = String.IsNullOrEmpty(dr["I_CONSUMETYPE"].ToString()) ? String.Empty : dr["I_CONSUMETYPE"].ToString();
                        sb.RealValue   = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                    }
                }

                ////得到耗差值
                //dt =be.GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId + "_el", TargetType, ConsumeType, out errMsg);
                //if (dt != null)
                //{
                //    foreach (DataRow dr in dt.Rows)
                //    {
                //        sb.ConsumeValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                //    }
                //}


                //参数单位
                sb.Unit = i.Unit;
                list.Add(sb);
            }

            return(list);
        }
Пример #7
0
        public async Task <IActionResult> Create([Bind("Id,FullName,ShortName,Unit")] IndicatorInfo indicatorInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(indicatorInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(indicatorInfo));
        }
Пример #8
0
        public void ProcessRequest(HttpContext context)
        {
            string param = context.Request["param"];

            if (param != "")
            {
                if (param == "seachList")
                {
                    string companId = String.IsNullOrEmpty(context.Request["companId"].ToString()) ? string.Empty : context.Request["companId"].ToString();
                    string plantId  = String.IsNullOrEmpty(context.Request["plantId"].ToString()) ? string.Empty : context.Request["plantId"].ToString();
                    string unit     = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
                    //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
                    string beginTime = String.IsNullOrEmpty(context.Request["beginTime"].ToString()) ? string.Empty : context.Request["beginTime"].ToString();
                    string endTime   = String.IsNullOrEmpty(context.Request["endTime"].ToString()) ? string.Empty : context.Request["endTime"].ToString();

                    List <IndicatorInfo> infoList = new List <IndicatorInfo>();
                    List <IndicatorInfo> saveList = new List <IndicatorInfo>();

                    //获取汽机和锅炉的所有耗差类型。
                    infoList = bi.GetInfo(beginTime, endTime, companId, plantId, unit, -1, 1, out errMsg);
                    //上线启用
                    //foreach (var info in infoList)
                    for (int i = 0; i < infoList.Count; i++)
                    {
                        IndicatorInfo infos = new IndicatorInfo();
                        //info.Name = "主汽温度(°C)";
                        //info.StandardValue = 333.22;
                        //info.RealValue = 54.32;
                        //info.ConsumeValue = 87.09;
                        if (!string.IsNullOrEmpty(infoList[i].Name))
                        {
                            infos.Name          = infoList[i].Name;
                            infos.StandardValue = Math.Round(infoList[i].StandardValue, 2);
                            infos.RealValue     = Math.Round(infoList[i].RealValue, 2);
                            infos.ConsumeValue  = Math.Round(infoList[i].ConsumeValue, 2);
                            saveList.Add(infos);
                        }
                    }

                    int    count = 0;
                    object obj   = new
                    {
                        total = count,
                        rows  = saveList
                    };

                    string result = JsonConvert.SerializeObject(obj);
                    context.Response.ContentType = "text/json;charset=gb2312;";
                    context.Response.Write(result);
                }
            }
        }
Пример #9
0
        //private int ImportIndicator(DataRow row)
        //{
        //    int RetVal = -1;

        //    IndicatorInfo IndicatorRecord;
        //    IndicatorBuilder IndicatorBuilderObj;

        //    IndicatorRecord = this.GetIndicatorInfo(row);
        //    IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = IndicatorBuilderObj.ImportIndicator(IndicatorRecord, IndicatorRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportUnit(DataRow row)
        //{
        //    int RetVal = -1;

        //    UnitInfo UnitRecord;
        //    UnitBuilder UnitBuilderObj;

        //    UnitRecord = this.GetUnitInfo(row);

        //    UnitBuilderObj = new UnitBuilder(this._TargetDBConnection, this._TargetDBQueries);
        //    RetVal = UnitBuilderObj.ImportUnit(UnitRecord, UnitRecord.Nid, this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private int ImportSubgroupVal(DataRow row)
        //{
        //    int RetVal = -1;

        //    DI6SubgroupValBuilder SubgroupValBuilderObj = new DI6SubgroupValBuilder(this._TargetDBConnection, this._TargetDBQueries);

        //    //import into target database
        //    RetVal = SubgroupValBuilderObj.ImportSubgroupVal(Convert.ToInt32(row[SubgroupVals.SubgroupValNId]), this.SourceDBQueries, this.SourceDBConnection);

        //    return RetVal;
        //}

        //private void ImportIUS(List<string> selectedNids, bool allSelected)
        //{
        //    int ProgressBarValue = 1;
        //    int IndicatorNId = -1;
        //    int UnitNId = -1;
        //    int SGValNId = -1;
        //    int MinValue=0;
        //    int MaxValue=0;

        //    DataRow[] Rows;
        //    DataTable TempTable;

        //    List<string> ImportedIndicatorNIDs = new List<string>();
        //    List<string> ImportedUnitNIDs = new List<string>();
        //    List<string> ImportedSGNIDs = new List<string>();

        //    IUSBuilder IusBuilderObj ;

        //    if (this.ShowIUS)
        //    {
        //        // Get selected rows
        //        if (allSelected)
        //        {
        //            Rows = this.SourceTable.Select("1=1");
        //        }
        //        else
        //        {
        //            Rows = this.SourceTable.Select(this.TagValueColumnName + " IN ( " + string.Join(",", selectedNids.ToArray()) + ")");
        //        }

        //        foreach (DataRow Row in Rows)
        //        {
        //            try
        //            {
        //                //import Indicator
        //                IndicatorNId = Convert.ToInt32(Row[Indicator.IndicatorNId]);
        //                if (!ImportedIndicatorNIDs.Contains(IndicatorNId.ToString()))
        //                {
        //                    ImportedIndicatorNIDs.Add(IndicatorNId.ToString());
        //                    IndicatorNId = this.ImportIndicator(Row);
        //                }


        //                    // import unit
        //                UnitNId = Convert.ToInt32(Row[Unit.UnitNId]);
        //                if (!ImportedIndicatorNIDs.Contains(UnitNId.ToString()))
        //                {
        //                   ImportedUnitNIDs.Add(UnitNId.ToString());
        //                    UnitNId =  this.ImportUnit(Row);
        //                }

        //                // import subgroupval
        //                SGValNId=Convert.ToInt32(Row[SubgroupVals.SubgroupValNId]);
        //                if (!ImportedSGNIDs.Contains(SGValNId.ToString()))
        //                {
        //                    ImportedSGNIDs.Add(SGValNId.ToString());
        //                    SGValNId = this.ImportSubgroupVal(Row);
        //                }

        //                //import IUS
        //                if (IndicatorNId > 0 && UnitNId > 0 && SGValNId > 0)
        //                {
        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MaxValue]).Length>0)
        //                    //{
        //                    //MaxValue=   Convert.ToInt32(Row[Indicator_Unit_Subgroup.MaxValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MaxValue=0;
        //                    //}

        //                    //if(Convert.ToString(Row[Indicator_Unit_Subgroup.MinValue]).Length>0)
        //                    //{
        //                    //    MinValue= Convert.ToInt32(Row[Indicator_Unit_Subgroup.MinValue]);
        //                    //}
        //                    //else
        //                    //{
        //                    //    MinValue=0;
        //                    //}


        //                    IusBuilderObj = new IUSBuilder( this._TargetDBConnection, this._TargetDBQueries);

        //                    IusBuilderObj.ImportIUS(IndicatorNId, UnitNId, SGValNId,                                                    MinValue, MaxValue , this.SourceDBQueries, this.SourceDBConnection);

        //                }

        //                if (this.ShowSector)
        //                {
        //                    this.ImportSector(Row);
        //                }
        //            }
        //            catch (Exception)
        //            {

        //                throw;
        //            }
        //            this.RaiseIncrementProgessBarEvent(ProgressBarValue);
        //            ProgressBarValue++;
        //        }
        //    }
        //}

        /// <summary>
        /// Imports records from source database to target database/template
        /// </summary>
        /// <param name="selectedNids"></param>
        /// <param name="allSelected">Set true to import all records</param>
        public override void ImportValues(List <string> selectedNids, bool allSelected)
        {
            DataRow                    Row;
            IndicatorInfo              IndicatorRecord            = null;
            IndicatorBuilder           IndicatorBuilderObj        = null;
            DI7MetadataCategoryBuilder MetadataCategoryBuilderObj = null;
            int ProgressBarValue = 1;

            // import indicator metadata categories
            MetadataCategoryBuilderObj = new DI7MetadataCategoryBuilder(this._TargetDBConnection, this._TargetDBQueries);
            MetadataCategoryBuilderObj.ImportAllMetadataCategories(this.SourceDBConnection, this.SourceDBQueries, MetadataElementType.Indicator);

            // import IUS or indicator
            foreach (string Nid in selectedNids)
            {
                try
                {
                    Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0];

                    if (this._ShowIUS)
                    {
                        this.ImportForIUS(Row);
                    }
                    else
                    {
                        //import indicator
                        IndicatorRecord     = this.GetIndicatorInfo(Row);
                        IndicatorBuilderObj = new IndicatorBuilder(this._TargetDBConnection, this._TargetDBQueries);
                        IndicatorBuilderObj.ImportIndicator(IndicatorRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection);

                        if (this._ShowSector)
                        {
                            this.ImportSector(Row);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                this.RaiseIncrementProgessBarEvent(ProgressBarValue);
                ProgressBarValue++;
            }


            if (this._ShowIUS && this._ShowSector)
            {
                this.ImportSectors(selectedNids, allSelected);
            }
        }
Пример #10
0
        private void BtnAddIndicator_Click(object sender, EventArgs e)
        {
            var f = new IndicatorEditForm(null);

            f.ShowDialog();

            if (f.DialogResult == DialogResult.OK)
            {
                IndicatorInfo indicator = f.CurrentIndicator;

                var n = treeIndicators.Nodes.Add(new object[] { indicator.Name + " (" + indicator.Period + ")" });
                n.Tag = indicator;
            }
        }
Пример #11
0
        private void CurrentIndicator_Disposed(object sender, EventArgs e)
        {
            lock (_lock)
            {
                if (_currentIndicator != null)
                {
                    _currentIndicator.Disposed -= CurrentIndicator_Disposed;
                    _currentIndicator           = null;
                }

                this.Title     = null;
                this.IsWorking = false;
                ProcessQueue();
            }
        }
Пример #12
0
        private IndicatorInfo GetCurrentIndicator()
        {
            var ind = new IndicatorInfo();

            ind.Name       = comboIndicator.Text;
            ind.Visible    = chkVisible.Checked;
            ind.InputValue = comboInputValue.Text;


            foreach (TreeListNode n in treeProperties.Nodes)
            {
                var vValue = n.GetValue(treeListColumn2);
                var vName  = n.GetDisplayText(treeListColumn1);
                if (vName == X_PERIOD)
                {
                    ind.Period = Convert.ToInt32(vValue);
                }
                else if (vName == X_STDEV)
                {
                    ind.StdDev = (float)Convert.ToDouble(vValue);
                }
                else if (vName == X_LINE_COLOR)
                {
                    ind.LineColor = (Color)vValue;
                }
                else if (vName == X_FAST_PERIOD)
                {
                    ind.FastPeriod = Convert.ToInt32(vValue);
                }
                else if (vName == X_SLOW_PERIOD)
                {
                    ind.SlowPeriod = Convert.ToInt32(vValue);
                }
                else if (vName == X_FAST_COLOR)
                {
                    ind.FastColor = (Color)vValue;
                }
                else if (vName == X_SLOW_COLOR)
                {
                    ind.SlowColor = (Color)vValue;
                }
                else
                {
                }
            }

            return(ind);
        }
Пример #13
0
        protected override void OnInit()
        {
            // Create instance of required indicator
            IndicatorInfo emaIndicatorInfo = Core.Instance.Indicators.All.FirstOrDefault(info => info.Name == "Exponential Moving Average");

            emaInd = Core.Instance.Indicators.CreateIndicator(emaIndicatorInfo);

            // Set indicator parameters
            emaInd.Settings = new List <SettingItem>
            {
                new SettingItemInteger("MaPeriod", 10)
            };

            // Add
            AddIndicator(emaInd);
        }
Пример #14
0
        //根据不同类型的机组获取信息
        public void GetInfo()
        {
            string companyId = String.IsNullOrEmpty(Request["companyId"]) ? string.Empty : Request["companyId"].ToString();
            string plantId   = String.IsNullOrEmpty(Request["plantId"]) ? string.Empty : Request["plantId"].ToString();
            string unit      = String.IsNullOrEmpty(Request["unit"]) ? string.Empty : Request["unit"].ToString();
            string beginTime = String.IsNullOrEmpty(Request["BeginTime"]) ? string.Empty : Request["BeginTime"].ToString();
            string endTime   = String.IsNullOrEmpty(Request["EndTime"]) ? string.Empty : Request["EndTime"].ToString();
            List <IndicatorInfo> infoList = new List <IndicatorInfo>();
            List <IndicatorInfo> saveList = new List <IndicatorInfo>();

            //获取汽机和锅炉的所有耗差类型。
            infoList = bi.GetInfo(beginTime, endTime, companyId, plantId, unit, 1, -1, out errMsg);
            //上线启用
            IndicatorInfo infos;

            for (int i = 0; i < infoList.Count; i++)
            {
                infos = new IndicatorInfo();
                if (!string.IsNullOrEmpty(infoList[i].Name))
                {
                    infos.Name          = infoList[i].Name;
                    infos.StandardValue = Math.Round(infoList[i].StandardValue, 2);
                    infos.RealValue     = Math.Round(infoList[i].RealValue, 2);
                    infos.ConsumeValue  = Math.Round(infoList[i].ConsumeValue, 2);
                    infos.Unit          = infoList[i].Unit;
                    saveList.Add(infos);
                }
            }

            int    count = saveList.Count;
            object obj   = new
            {
                total = count,
                rows  = saveList
            };

            string result = JsonConvert.SerializeObject(obj);

            //Response.ContentType = "text/json;charset=utf-8;";
            Response.Write(result);
            Response.End();
        }
Пример #15
0
        IDisposable IShowIndicatorViewService.ShowIndicator(string title, TimeSpan timeout)
        {
            var _indicatorInfo = new IndicatorInfo(title, timeout);

            lock (_lock)
            {
                // lazy load, also note we only keep a weak reference to the indicator info
                if (_indicators == null)
                {
                    _indicators = new Queue <WeakReference>();
                }
                _indicators.Enqueue(new WeakReference(_indicatorInfo));

                ProcessQueue();
            }

            // we initialize and return - note unlike status viewer, the timers are run together and not one-by-one
            _indicatorInfo.Initialize();
            return(_indicatorInfo);
        }
Пример #16
0
        private IndicatorInfo GetIndicatorInfo(DataRow row)
        {
            IndicatorInfo RetVal;

            try
            {
                //get unit from source table
                RetVal        = new IndicatorInfo();
                RetVal.Name   = DICommon.RemoveQuotes(row[Indicator.IndicatorName].ToString());
                RetVal.GID    = row[Indicator.IndicatorGId].ToString();
                RetVal.Global = Convert.ToBoolean(row[Indicator.IndicatorGlobal]);
                RetVal.Info   = DICommon.RemoveQuotes(Convert.ToString(row[Indicator.IndicatorInfo]));
                RetVal.Nid    = Convert.ToInt32(row[Indicator.IndicatorNId]);
            }
            catch (Exception ex)
            {
                RetVal = null;
                ExceptionFacade.ThrowException(ex);
            }
            return(RetVal);
        }
Пример #17
0
        private void ProcessQueue()
        {
            lock (_lock)
            {
                if (_currentIndicator != null || _indicators == null || _indicators.Count == 0)
                {
                    return;
                }

                var _indicatorReference = _indicators.Dequeue();
                if (_indicatorReference != null && _indicatorReference.IsAlive)
                {
                    _currentIndicator = (IndicatorInfo)_indicatorReference.Target;
                    if (_currentIndicator != null)
                    {
                        if (_currentIndicator.IsDisposed)
                        {
                            this.Title        = null;
                            _currentIndicator = null;
                        }
                        else
                        {
                            this.Title = _currentIndicator.Title;
                            _currentIndicator.Disposed += CurrentIndicator_Disposed;
                            _currentIndicator.Initialize();
                        }
                    }

                    _indicatorReference.Target = null;
                    _indicatorReference        = null;
                }

                // if no current active indicator, the process queue
                this.IsWorking = (_currentIndicator != null);
                if (!this.IsWorking)
                {
                    ProcessQueue();
                }
            }
        }
Пример #18
0
        private void TreeIndicators_DoubleClick(object sender, EventArgs e)
        {
            TreeListHitInfo hi = treeIndicators.CalcHitInfo(treeIndicators.PointToClient(Control.MousePosition));

            if (hi.Node != null)
            {
                IndicatorInfo indicator = (IndicatorInfo)hi.Node.Tag;

                var f = new IndicatorEditForm(indicator);
                f.ShowDialog();

                if (f.DialogResult == DialogResult.OK)
                {
                    indicator = f.CurrentIndicator;

                    hi.Node.SetValue(treeListColumn1, indicator.Name + " (" + indicator.Period + ")");
                    hi.Node.Tag = indicator;

                    treeIndicators.Refresh();
                }
            }
        }
Пример #19
0
        public static IIndicator CreateIndicator(Bars bars, IndicatorInfo info)
        {
            Log.Instance.Trace("CreateIndicator {0}", info);
            IIndicator indicator;
            BarsSingleValues baseIndicator;
            switch (info.Base)
            {
                case IndicatorBase.Open:
                    baseIndicator = new BarsOpen(bars);
                    break;
                case IndicatorBase.Close:
                    baseIndicator = new BarsClose(bars);
                    break;
                case IndicatorBase.High:
                    baseIndicator = new BarsHigh(bars);
                    break;
                case IndicatorBase.Low:
                    baseIndicator = new BarsLow(bars);
                    break;
                default:
                    return null;
            }

            switch (info.Type)
            {
                case IndicatorType.EMA:
                    indicator = new Ema(baseIndicator, info.Period);
                    break;
                case IndicatorType.Simple:
                    indicator = new Simple(baseIndicator, info.Period);
                    break;
                default:
                    return null;
            }

            return indicator;
        }
 public ChildExampleViewController(IndicatorInfo itemInfo) : base(null, null)
 {
     this.ItemInfo = itemInfo;
 }
Пример #21
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime   = String.IsNullOrEmpty(context.Request["beginTime"].ToString()) ? string.Empty : context.Request["beginTime"].ToString();
            string endTime     = String.IsNullOrEmpty(context.Request["endTime"].ToString()) ? string.Empty : context.Request["endTime"].ToString();
            string timeType    = String.IsNullOrEmpty(context.Request["timeType"].ToString()) ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = String.IsNullOrEmpty(context.Request["quarterType"].ToString()) ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (quarterType)
            {
            case "0":     //指定时间段

                break;

            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString();
                endTime   = dh.GetLastDayOfMonth(dt1).ToString();
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "01-01";
                endTime   = tim + "-12-31";
                break;
            }

            List <IndicatorInfo> infoList = new List <IndicatorInfo>();

            //获取锅炉的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, 0, out errMsg);
            //foreach (var info in infoList)
            //{
            for (int i = 0; i < 10; i++)
            {
                IndicatorInfo infos = new IndicatorInfo();
                infos.Name          = "主汽温度(°C)";
                infos.StandardValue = 333.22;
                infos.RealValue     = 54.32;
                infos.ConsumeValue  = 87.09;
                //上线启用
                //infos.Name = info.Name;
                //infos.StandardValue = info.StandardValue;
                //infos.RealValue = info.RealValue;
                //infos.ConsumeValue = info.ConsumeValue;
                infoList.Add(infos);
            }
            //}

            string content = infoList.ToJsonItem();
            int    count   = 0;
            object obj     = new
            {
                total = count,
                rows  = infoList
            };

            string result = JsonConvert.SerializeObject(obj);

            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(result);
        }
Пример #22
0
        public void GetBCList()
        {
            //string companyId = Request["company"].ToString();
            //string plantId = Request["plant"].ToString();
            //string unitId = Request["unit"].ToString();
            //string beginTime = Request["beginTime"].ToString();
            //string endTime = Request["endTime"].ToString();
            //int page = Convert.ToInt32(Request["page"].ToString());
            //int rows = Convert.ToInt32(Request["rows"].ToString());
            //int sCount = (page - 1) * rows + 1;
            //int eCount = page * rows;
            ////总的行数。
            //int count = 0;
            //DataTable dt = bl.GetInitByCondition(companyId, plantId, unitId, beginTime, endTime, sCount, eCount, out count, out errMsg);
            ////int count =dt.Rows.Count;
            //IList<Hashtable> list = new List<Hashtable>();

            //foreach (DataRow item in dt.Rows)
            //{
            //    Hashtable ht = new Hashtable();
            //    ht.Add("T_CODE", item["T_CODE"]);
            //    ht.Add("T_UNITDESC", item["T_UNITDESC"].ToString());
            //    ht.Add("D_CAPABILITY", item["D_CAPABILITY"].ToString());
            //    ht.Add("I_GAAG", item["I_GAAG"].ToString());
            //    ht.Add("I_PH", item["I_PH"].ToString());
            //    ht.Add("I_AH", item["I_AH"].ToString());
            //    ht.Add("I_SH", item["I_SH"].ToString());
            //    ht.Add("I_UOH", item["I_UOH"].ToString());
            //    ht.Add("I_FOH", item["I_FOH"].ToString());
            //    ht.Add("I_EUNDH", item["I_EUNDH"].ToString());
            //    list.Add(ht);
            //}
            //object obj = new
            //{
            //    total = count,
            //    rows = list
            //};

            //string result = JsonConvert.SerializeObject(obj);
            //Response.Write(result);
            //Response.End();
            string unit        = String.IsNullOrEmpty(Request["unit"].ToString()) ? string.Empty : Request["unit"].ToString();
            string time        = String.IsNullOrEmpty(Request["time"].ToString()) ? string.Empty : Request["time"].ToString();
            string beginTime   = String.IsNullOrEmpty(Request["beginTime"].ToString()) ? string.Empty : Request["beginTime"].ToString();
            string endTime     = String.IsNullOrEmpty(Request["endTime"].ToString()) ? string.Empty : Request["endTime"].ToString();
            string timeType    = String.IsNullOrEmpty(Request["timeType"].ToString()) ? string.Empty : Request["timeType"].ToString();
            string quarterType = String.IsNullOrEmpty(Request["quarterType"].ToString()) ? string.Empty : Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (quarterType)
            {
            case "0":     //指定时间段

                break;

            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString();
                endTime   = dh.GetLastDayOfMonth(dt1).ToString();
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "01-01";
                endTime   = tim + "-12-31";
                break;
            }

            List <IndicatorInfo> infoList = new List <IndicatorInfo>();

            //获取汽机的所有耗差类型。
            //infoList = bl.GetInfo(beginTime, endTime, unit, -1, 1, out errMsg);
            for (int i = 0; i < 10; i++)
            {
                IndicatorInfo info = new IndicatorInfo();
                info.Name          = "主汽温度(°C)";
                info.StandardValue = 333.22;
                info.RealValue     = 54.32;
                info.ConsumeValue  = 87.09;
            }
            //string content = infoList.ToJsonItem();
            //int count = 0;
            //object obj = new
            //{
            //    total = count,
            //    rows = infoList
            //};

            string result = JsonConvert.SerializeObject(infoList);

            //Response.ContentType = "text/json;charset=gb2312;";
            Response.Write(result);
        }
Пример #23
0
        private void InitPropertyList(IndicatorInfo indicator)
        {
            var hasPeriod    = false;
            var hasStDev     = false;
            var hasLineColor = false;

            var hasFastPeriod = false;
            var hasSlowPeriod = false;

            var hasFastColor = false;
            var hasSlowColor = false;

            var indName = (indicator != null) ? indicator.Name : comboIndicator.Text;

            if (indName == Globals.IND_ParabolicSAR ||
                indName == Globals.IND_CCI ||
                indName == Globals.IND_ATR ||
                indName == Globals.IND_ADX ||
                indName == Globals.IND_WilliamsR)
            {
                comboInputValue.Visible = false;
                lblInputValue.Visible   = false;
            }
            else
            {
                comboInputValue.Visible = true;
                lblInputValue.Visible   = true;
            }

            if (indName == Globals.IND_SimpleMovingAverage)
            {
                hasPeriod    = true;
                hasLineColor = true;
            }
            else if (indName == Globals.IND_ExponentialMovingAverage)
            {
                hasPeriod    = true;
                hasLineColor = true;
            }
            else if (indName == Globals.IND_ParabolicSAR)
            {
                hasLineColor = true;
            }
            else if (indName == Globals.IND_BollingerBands)
            {
                hasPeriod    = true;
                hasStDev     = true;
                hasLineColor = true;
            }
            else if (indName == Globals.IND_MACD)
            {
                hasFastPeriod = true;
                hasSlowPeriod = true;

                hasFastColor = true;
                hasSlowColor = true;
            }
            else if (indName == Globals.IND_RSI)
            {
                hasLineColor = true;
                hasPeriod    = true;
            }
            else if (indName == Globals.IND_CCI || indName == Globals.IND_ATR || indName == Globals.IND_ADX || indName == Globals.IND_WilliamsR)
            {
                hasPeriod    = true;
                hasLineColor = true;
            }
            else if (indName == Globals.IND_SD)
            {
                hasPeriod    = true;
                hasStDev     = true;
                hasLineColor = true;
            }

            treeProperties.ClearNodes();

            if (indicator == null)
            {
                indicator = new IndicatorInfo();
            }

            if (hasPeriod)
            {
                var pValue = (indicator != null) ? indicator.Period : 14;

                var n = treeProperties.Nodes.Add(new object[] { X_PERIOD, pValue });
            }

            if (hasStDev)
            {
                var pValue = (indicator != null) ? indicator.StdDev : 2.0f;

                var n = treeProperties.Nodes.Add(new object[] { X_STDEV, pValue });
            }

            if (hasLineColor)
            {
                var pValue = (indicator != null) ? indicator.LineColor : Color.LawnGreen;

                var n = treeProperties.Nodes.Add(new object[] { X_LINE_COLOR, pValue });
            }

            if (hasFastPeriod)
            {
                var pValue = (indicator != null) ? indicator.FastPeriod : 12;

                var n = treeProperties.Nodes.Add(new object[] { X_FAST_PERIOD, pValue });
            }

            if (hasSlowPeriod)
            {
                var pValue = (indicator != null) ? indicator.SlowPeriod : 24;

                var n = treeProperties.Nodes.Add(new object[] { X_SLOW_PERIOD, pValue });
            }

            if (hasFastColor)
            {
                var pValue = (indicator != null) ? indicator.FastColor : Color.LawnGreen;

                var n = treeProperties.Nodes.Add(new object[] { X_FAST_COLOR, pValue });
            }

            if (hasSlowColor)
            {
                var pValue = (indicator != null) ? indicator.SlowColor : Color.LawnGreen;

                var n = treeProperties.Nodes.Add(new object[] { X_SLOW_COLOR, pValue });
            }
        }
Пример #24
0
        /// <summary>
        /// 得到绑定汽机或锅炉(TargetType:耗差类型:0可控耗差,1不可控耗差。ConsumeType:指标类型:0锅炉指标,1汽机指标)
        /// </summary>
        /// <returns></returns>
        public List <IndicatorInfo> GetInfo(string beginTime, string endTime, string unitId, int TargetType, int ConsumeType, out string errMsg)
        {
            List <IndicatorInfo> list = new List <IndicatorInfo>();

            List <TmpInfoE> infos = new List <TmpInfoE>();

            infos = GetFirstInfo(unitId, out errMsg);
            if (TargetType == 0 || TargetType == 1)
            {
                infos = infos.Where(info => info.TargetType == TargetType).ToList();
            }
            if (ConsumeType == 0 || ConsumeType == 1)
            {
                infos = infos.Where(info => info.ConsumeType == ConsumeType).ToList();
            }

            foreach (var i in infos)
            {
                IndicatorInfo sb = new IndicatorInfo();
                sb.Name        = i.Desc;
                sb.TargetType  = i.TargetType.ToString();
                sb.ConsumeType = i.ConsumeType.ToString();

                DataTable dt = new DataTable();
                dt = GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", out errMsg);

                //得到基准值和指标类型和耗差类型
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.StandardValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                    }
                }

                //得到实际值
                dt = GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId.Remove(i.ParaId.Length - 3, 3), out errMsg);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.RealValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                    }
                }

                //得到耗差值
                dt = GetBase(i.TableName, beginTime, endTime, unitId, i.ParaId, out errMsg);
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.ConsumeValue = String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString());
                    }
                }



                list.Add(sb);
            }

            return(list);
        }
Пример #25
0
 public TableChildExampleViewController(UITableViewStyle style, IndicatorInfo itemInfo) : base(style)
 {
     this.ItemInfo = itemInfo;
 }
Пример #26
0
        public override void Import(string selectedGIds)
        {
            int       ProgressCounter = 0;
            DataTable Table           = null;
            string    selectedNids    = string.Empty;

            selectedNids = selectedGIds;

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedGIds.Split(',').GetUpperBound(0) + 1);

            IndicatorBuilder             TrgIndicatorBuilderObj = null;
            IndicatorBuilder             SourceIndicatorBuilder = null;
            IndicatorInfo                IndicatorInfoObj       = null;
            Dictionary <string, DataRow> FileWithNids           = new Dictionary <string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries    SourceDBQueries    = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportIndicator(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            TrgIndicatorBuilderObj = new IndicatorBuilder(this.TargetDBConnection, this.TargetDBQueries);

            //-- Step 3: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    string SourceFileWPath = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SourceFileWPath, String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries    = DataExchange.GetDBQueries(SourceDBConnection);

                    // Get Source Indicator Info
                    SourceIndicatorBuilder = new IndicatorBuilder(SourceDBConnection, SourceDBQueries);
                    IndicatorInfoObj       = SourceIndicatorBuilder.GetIndicatorInfo(FilterFieldType.NId, Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), FieldSelection.Light);

                    // Import INdicator By Nid
                    TrgIndicatorBuilderObj.ImportIndicator(IndicatorInfoObj, Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);
                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                    {
                        SourceDBConnection.Dispose();
                    }
                    if (SourceDBQueries != null)
                    {
                        SourceDBQueries.Dispose();
                    }
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
Пример #27
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = context.Request["unit"] == null ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime   = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString();
            string endTime     = context.Request["endTime"] == null? string.Empty : context.Request["endTime"].ToString();
            string timeType    = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (timeType)
            {
            case "0":     //指定时间段

                break;

            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-");
                endTime   = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-");
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31 23:59:59";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30 23:59:59";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30 23:59:59";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31 23:59:59";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "-01-01 00:00:00";
                endTime   = tim + "-12-31 23:59:59";
                break;
            }

            List <IndicatorInfo> infoList = new List <IndicatorInfo>();
            List <IndicatorInfo> saveList = new List <IndicatorInfo>();

            //获取汽机和锅炉的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, -1, out errMsg);
            List <IndicatorInfo> tmpList = infoList.Where(info => info.ConsumeType == "0" || info.ConsumeType == "1").ToList();

            //上线启用
            //foreach (var info in infoList)
            for (int i = 0; i < tmpList.Count; i++)
            {
                IndicatorInfo infos = new IndicatorInfo();
                //info.Name = "主汽温度(°C)";
                //info.StandardValue = 333.22;
                //info.RealValue = 54.32;
                //info.ConsumeValue = 87.09;
                if (!string.IsNullOrEmpty(tmpList[i].Name))
                {
                    infos.Name          = tmpList[i].Name;
                    infos.StandardValue = Math.Round(tmpList[i].StandardValue, 2);
                    infos.RealValue     = Math.Round(tmpList[i].RealValue, 2);
                    infos.ConsumeValue  = Math.Round(tmpList[i].ConsumeValue, 2);
                    saveList.Add(infos);
                }
            }
            //IndicatorInfo infos = new IndicatorInfo();

            //infos.Name = "主汽温度(°C)";
            //infos.StandardValue = 538.22;
            //infos.RealValue = 533.32;
            //infos.ConsumeValue = 0.64;
            //infoList.Add(infos);
            //infos = new IndicatorInfo();
            //infos.Name = "主汽压力(Mpa)";
            //infos.StandardValue = 16.70;
            //infos.RealValue = 16.43;
            //infos.ConsumeValue = 0.21;
            //infoList.Add(infos);

            int    count = 0;
            object obj   = new
            {
                total = count,
                rows  = saveList
            };

            string result = JsonConvert.SerializeObject(obj);

            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(result);
        }