public IEnumerable <DataItem> GetDataItem(string organizationId, params string[] variableIds)
        {
            IList <DataItem>            results      = new List <DataItem>();
            SingletonForDataBase        singleton    = SingletonForDataBase.GetInstance();
            Dictionary <string, string> myDictionary = (Dictionary <string, string>)singleton.AddFactoryDB(organizationId);

            string               queryString = @"select OrganizationID,VariableID,CoalDustConsumption from [{0}].[dbo].[RealtimeFormulaValue] 
                                   where OrganizationID=@organizationId";
            StringBuilder        baseString  = new StringBuilder(queryString);
            IList <SqlParameter> parameters  = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@organizationId", organizationId));
            //SqlParameter[] parameters = { new SqlParameter("@organizationId", organizationId + "%") };

            ParametersHelper.AddParamsCondition(baseString, parameters, variableIds);

            DataTable dt = _companyFactory.Query(string.Format(queryString, myDictionary[organizationId].Trim()), parameters.ToArray());

            foreach (DataRow dr in dt.Rows)
            {
                DataItem itemCoalDustConsumption = new DataItem
                {
                    ID    = dr["OrganizationID"].ToString().Trim() + ">" + dr["VariableID"].ToString().Trim() + ">PulverizedCoalInput",
                    Value = dr["CoalDustConsumption"] is DBNull ? "0" : Convert.ToDecimal(dr["CoalDustConsumption"]).ToString("#.00").Trim()
                };
                results.Add(itemCoalDustConsumption);
            }

            return(results);
        }
Ejemplo n.º 2
0
        public IEnumerable <DataItem> GetDataItem(string organizationId, params string[] variableIds)
        {
            IList <DataItem>            results      = new List <DataItem>();
            SingletonForDataBase        singleton    = SingletonForDataBase.GetInstance();
            Dictionary <string, string> myDictionary = (Dictionary <string, string>)singleton.AddFactoryDB(organizationId);

            string    queryString = @"select * from [{0}].[dbo].[Realtime_RealtimeFlow] order by vDate desc";
            DataTable dt          = _companyFactory.Query(string.Format(queryString, myDictionary[organizationId]));

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < variableIds.Length; i++)
                {
                    string m_VariableIdTemp = variableIds[i].Trim();
                    if (dt.Columns.Contains(m_VariableIdTemp))
                    {
                        DataItem itemPower = new DataItem();
                        itemPower.ID    = organizationId.Trim() + ">" + m_VariableIdTemp + ">WaterFlowRate";
                        itemPower.Value = dt.Rows[0][m_VariableIdTemp] is DBNull ? "0" : Convert.ToDecimal(dt.Rows[0][m_VariableIdTemp]).ToString("#.00").Trim();
                        results.Add(itemPower);
                    }
                }
            }
            return(results);
        }
Ejemplo n.º 3
0
        public IEnumerable <DataItem> GetDataItem(string organizationId, params string[] variableIds)
        {
            IList <DataItem>            results      = new List <DataItem>();
            SingletonForDataBase        singleton    = SingletonForDataBase.GetInstance();
            Dictionary <string, string> myDictionary = (Dictionary <string, string>)singleton.AddFactoryDB(organizationId);

            string               queryString = @"select OrganizationID,VariableID,CoalDustConsumption,DenominatorValue from [{0}].[dbo].[RealtimeFormulaValue] 
                                where OrganizationID=@organizationId";
            StringBuilder        baseString  = new StringBuilder(queryString);
            IList <SqlParameter> parameters  = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@organizationId", organizationId));

            ParametersHelper.AddParamsCondition(baseString, parameters, variableIds);

            DataTable dt = _companyFactory.Query(string.Format(baseString.ToString(), myDictionary[organizationId].Trim()), parameters.ToArray());

            foreach (DataRow item in dt.Rows)
            {
                if (!Convert.IsDBNull(item["DenominatorValue"]))
                {
                    decimal denominatorValue = 0;
                    decimal.TryParse(item["DenominatorValue"].ToString().Trim(), out denominatorValue);
                    //if (denominatorValue != 0)
                    //{
                    decimal coalDustConsumption = 0;
                    decimal.TryParse(item["CoalDustConsumption"].ToString().Trim(), out coalDustConsumption);
                    coalDustConsumption = coalDustConsumption * 1000;

                    DataItem itemCoalConsumption = new DataItem
                    {
                        ID    = item["OrganizationID"].ToString().Trim() + ">" + item["VariableID"].ToString().Trim() + ">" + "CoalConsumption",
                        Value = denominatorValue == 0 ? "0" : Convert.ToDecimal((coalDustConsumption / denominatorValue)).ToString("#.00").Trim()    //产量为0时将煤耗致为0
                    };
                    results.Add(itemCoalConsumption);
                    //}
                }
            }

            return(results);
        }
        public IEnumerable <DataItem> GetDataItem(string organizationId, params string[] variableIds)
        {
            IList <DataItem> results = new List <DataItem>();

            string               materialDetailString = @"select A.OrganizationID,B.VariableId,B.TagTableName,B.Formula 
                                         from [dbo].[tz_Material] as A,[dbo].[material_MaterialDetail] as B
                                         where A.KeyID=B.KeyID and A.OrganizationID=@organizationId";
            StringBuilder        materialStringBase   = new StringBuilder(materialDetailString);
            IList <SqlParameter> parameters           = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@organizationId", organizationId));
            ParametersHelper.AddParamsCondition(materialStringBase, parameters, variableIds);
            DataTable materialDetailTable = _companyFactory.Query(materialStringBase.ToString(), parameters.ToArray());

            StringBuilder  baseString    = new StringBuilder("select top 1");
            string         baseTableName = "";
            IList <string> variables     = new List <string>();

            if (materialDetailTable.Rows.Count > 0)
            {
                foreach (DataRow dr in materialDetailTable.Rows)
                {
                    baseString.Append(string.Format(" {0} as {1},", dr["Formula"].ToString().Trim(), dr["VariableId"].ToString().Trim()));
                    variables.Add(dr["VariableId"].ToString().Trim());
                    if (baseTableName == "")
                    {
                        baseTableName = dr["TagTableName"].ToString().Trim();
                    }
                }
                baseString.Remove(baseString.Length - 1, 1);
                SingletonForDataBase        singleton    = SingletonForDataBase.GetInstance();
                Dictionary <string, string> myDictionary = (Dictionary <string, string>)singleton.AddFactoryDB(organizationId);

                baseString.Append(" from ").Append(string.Format("[{0}].[dbo].", myDictionary[organizationId].Trim()) + baseTableName).Append(" order by vDate desc");
                DataTable resultDt = _companyFactory.Query(baseString.ToString());

                foreach (var item in variables)
                {
                    DataItem dataItem = new DataItem
                    {
                        ID = organizationId + ">" + item + ">Material"//resultDt.Rows[0][item] is DBNull?"0": Convert.ToDecimal(resultDt.Rows[0][item]).ToString("#.00").Trim()
                    };
                    decimal defaultValue = 0;
                    if (resultDt.Rows[0][item] is DBNull)
                    {
                        defaultValue = 0;
                    }
                    else
                    {
                        defaultValue = Convert.ToDecimal(resultDt.Rows[0][item]);
                    }
                    if (defaultValue < CorrectionValue.OutputCorrectionValue)
                    {
                        dataItem.Value = "0";
                    }
                    else
                    {
                        dataItem.Value = defaultValue.ToString("#.00");
                    }
                    results.Add(dataItem);
                }
            }

            return(results);
        }