예제 #1
0
        public static Dictionary <string, string> GetDcsTime(string factoryId, string relatedTags)
        {
            Dictionary <string, string> dcsTime;
            string sumStr_new;

            relatedTags = relatedTags.Trim(';');
            string[] relatedTagArray = relatedTags.Split('>');
            if (relatedTagArray.Length > 2)
            {
                string[]      sb     = relatedTagArray[1].Split('_');
                StringBuilder sumStr = new StringBuilder();
                //string[] tagsArray = relatedTags.Split(',',';');
                if (relatedTagArray[0] == "zc_nxjc_qtx_efc")
                {
                    sumStr.Append("Db_02_01");
                    sumStr.Append("_");
                    sumStr.Append(sb[0]);
                }
                else
                {
                    sumStr.Append(relatedTagArray[0]);
                    sumStr.Append("_");
                    sumStr.Append(sb[0]);
                }
                sumStr_new = sumStr.ToString();
                dcsTime    = RealtimeTagValueService.GetDcsTime(factoryId, sumStr_new);
            }
            else
            {
                string[]      sb     = relatedTagArray[0].Split('_');
                StringBuilder sumStr = new StringBuilder();
                if (factoryId == "zc_nxjc_qtx_efc")
                {
                    sumStr.Append("Db_02_01");
                    sumStr.Append("_");
                    sumStr.Append(sb[0]);
                    sumStr_new = sumStr.ToString();
                }
                else
                {
                    sumStr.Append(factoryId);
                    sumStr.Append("_");
                    sumStr.Append(sb[0]);
                    sumStr_new = sumStr.ToString();
                }
                dcsTime = RealtimeTagValueService.GetDcsTime(factoryId, sumStr_new);
            }
            return(dcsTime);
        }
        public Dictionary <string, string> GetRunningTime(string ids)
        {
            string organizationIdDcs = "";
            string organization      = "";
            Dictionary <string, string> EnergyTime = new Dictionary <string, string>();

            string[] iditems = ids.Split(',');
            for (int i = 0; i < iditems.Length - 1; i++)
            {
                string[] itemArry = iditems[i].Split('>');
                organization = itemArry[0];
                string[] organizationArry = organization.Split('_');
                if (organizationArry.Length < 5)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            string connectionString           = ConnectionStringFactory.NXJCConnectionString;
            ISqlServerDataFactory dataFactory = new SqlServerDataFactory(connectionString);
            string       mySql          = @"select A.[MeterDatabase],A.[DCSProcessDatabase] from system_Database AS A, system_Organization AS B
                             where A.[DatabaseID]=B.[DatabaseID] and B.organizationid=@IdInformation
                                      ";
            SqlParameter myParameter    = new SqlParameter("@IdInformation", organization);
            DataTable    table          = dataFactory.Query(mySql, myParameter);
            string       organizationId = table.Rows[0][0].ToString();

            organizationIdDcs = table.Rows[0][0].ToString();
            if (organizationIdDcs == "Db_02_01")
            {
                organizationIdDcs = "zc_nxjc_qtx_efc";
            }
            string dataBaseName = table.Rows[0][1].ToString();

            EnergyTime = RealtimeTagValueService.GetDcsTime(organizationIdDcs, dataBaseName);
            string    mySqlNew     = @"select [vDate] from {0}.[dbo].[RealtimeAmmeter]";
            DataTable tableAmmater = dataFactory.Query(string.Format(mySqlNew, organizationId));

            EnergyTime.Add("Ammatertime", tableAmmater.Rows[0][0].ToString());
            return(EnergyTime);
        }