예제 #1
0
        public ActionResult DropDownList(string lang)
        {
            Session["Culture"] = new CultureInfo(lang);
            string        customType   = Request.Form["customType"];
            string        valuetype    = Request.Form["selectvalue"];
            string        type         = Request.Form["selecttype"];
            string        timeInterval = Request.Form["timeInterval"];//报表时间类型
            StringBuilder sb           = new StringBuilder();

            //单位
            if (type.Trim().Equals("ValueType"))
            {
                if (!string.IsNullOrEmpty(valuetype) && !valuetype.Trim().ToLower().Equals("null"))
                {
                    try
                    {
                        int imi = int.Parse(valuetype.Trim());

                        MonitorType mm = MonitorType.getMonitorTypeByCode(imi);
                        if (mm != null && !string.IsNullOrEmpty(mm.unit))
                        {
                            string[] sunit = mm.units();
                            foreach (string ss in sunit)
                            {
                                sb.Append("<option value=\"" + ss + "\">" + ss + "</option>");
                            }
                        }
                    }
                    catch
                    { }
                }
            }
            else if (type.Trim().Equals("TimeSlot"))//时间大类
            {
                sb.Append("  <select id=\"timeInterval\" name=\"timeInterval\" class = \"subselect02\">");

                if (valuetype.ToLower().Trim().Equals(ComConst.Time_YEAR.ToLower().Trim()))
                {
                    sb.Append(" <option title=\"YEAR\" value=\"YEAR\">YEAR</option>");

                    sb.Append(" <option title=\"MONTH\" value=\"MONTH\">MONTH</option>");
                }
                else if (valuetype.ToLower().Trim().Equals(ComConst.Time_MONTH.ToLower().Trim()))
                {
                    sb.Append(" <option title=\"MONTH\" value=\"MONTH\">MONTH</option>");

                    sb.Append("  <option title=\"DAY\" value=\"DAY\">DAY</option>");
                }
                else if (valuetype.ToLower().Trim().Equals(ComConst.Time_DAY.ToLower().Trim()))
                {
                    sb.Append("  <option title=\"DAY\" value=\"DAY\">DAY</option>");

                    sb.Append("  <option title=\"HOUR\" value=\"HOUR\">HOUR</option>");
                }
                sb.Append("  </select>");
            }
            else if (type.Trim().Equals("IdType"))
            {
                string[] strvalue = valuetype.Split('&');
                if (strvalue != null && strvalue.Length == 2)
                {
                    int deviceTypeCode      = int.Parse(strvalue[1].Trim());
                    IList <MonitorType> mts = MonitorType.getFilterMonitorTypesByTypeCode(deviceTypeCode);

                    IList <MonitorType> temp = new List <MonitorType>();

                    string[]      items  = new string[] { };
                    MonitorConfig config = MonitorConfigService.GetInstance().Get(deviceTypeCode);
                    if (config != null)
                    {
                        items = config.items.Split(',');
                    }

                    foreach (MonitorType monitor in mts)
                    {
                        foreach (string s in items)
                        {
                            if (s.Equals(monitor.code.ToString()))
                            {
                                temp.Add(monitor);
                                break;
                            }
                        }
                    }



                    if (temp != null)
                    {
                        if (deviceTypeCode == DeviceData.INVERTER_CODE && !timeInterval.Equals("Hour"))
                        {
                            MonitorType mt = MonitorType.getMonitorTypeByCode(MonitorType.PLANT_MONITORITEM_ENERGY_CODE);
                            sb.Append(" <option value=\"" + mt.code + "\">" + mt.name + "</option>");
                        }
                        else
                        {
                            foreach (MonitorType item in temp)
                            {
                                //if (item.code == MonitorType.MIC_DETECTOR_ADR || item.code == MonitorType.MIC_DETECTOR_SOI || item.code == MonitorType.MIC_DETECTOR_WINDDIRECTION || item.code == MonitorType.MIC_BUSBAR_MAXLINE || item.code == MonitorType.MIC_BUSBAR_COMMUNICATION || item.code == MonitorType.MIC_BUSBAR_DIGITALINPUT || item.code == MonitorType.MIC_BUSBAR_JDQOUT || item.code == MonitorType.MIC_BUSBAR_MAXLINE || item.code == MonitorType.MIC_INVERTER_STATUSTIME || item.code == MonitorType.MIC_INVERTER_DEVICESTATUS || item.code == MonitorType.MIC_INVERTER_OUTTYPE || item.code == MonitorType.MIC_INVERTER_POWER || item.code == MonitorType.MIC_INVERTER_RUNTIME || item.code == MonitorType.MIC_INVERTER_STATUSDATA1 || item.code == MonitorType.MIC_INVERTER_STATUSDATA2 || item.code == MonitorType.MIC_INVERTER_STATUSDATA3 || item.code == MonitorType.MIC_INVERTER_TODAYENERGY)
                                //    continue;
                                sb.Append(" <option value=\"" + item.code + "\">" + item.name + "</option>");
                            }
                        }
                    }
                }
            }

            return(Content(sb.ToString()));
        }