Пример #1
0
        private QueryStep PrepQuery(SelectValue selectValue)
        {
            var qs = new QueryStep();

            qs.QueryParameters.Add(new QueryParameter
            {
                ContextValue = new ContextValue
                {
                    SelectValues = new List <SelectValue>
                    {
                        new SelectValue {
                            FieldName = "Id"
                        },
                        new SelectValue {
                            FieldName = "Field1"
                        }
                    },
                    Comparison = Comparisons.Equal
                }
            });

            qs.QueryParameters.First().ContextValue.SelectValues.Add(selectValue);

            return(qs);
        }
Пример #2
0
        void labdel_Click(object sender, EventArgs e)
        {
            List <object> values = SelectValue.ToList();
            object        delval = (sender as Label).Tag;

            values.Remove(delval);
            SelectValue = values.ToArray();
        }
Пример #3
0
        private void add(IEnumerable <case_zds> list, case_zds model, List <SelectValue> rst)
        {
            SelectValue item = new SelectValue(model.zd_id, model.zd_name, model.zd_type);

            rst.Add(item);
            int?id    = int.Parse(model.zd_id);
            var cList = list.Where(t => t.remark == model.zd_type && t.parentid == id);

            foreach (var temp in cList)
            {
                add(list, temp, item.children);
            }
        }
Пример #4
0
        public static List <SelectValue> SearchFriend(string portalId, string portalUserId, string searchKey, SqlDataAccess sda)
        {
            List <SelectValue> selectValues = new List <SelectValue>();

            try
            {
                string str = @"SELECT
	                                *
                                FROM
                                (
	                                SELECT
		                                CASE WHEN f.new_partyoneId!='{1}' THEN f.new_partyoneId ELSE f.new_partytwoId END  AS UserId
		                                ,CASE WHEN f.new_partyoneId!='{1}' THEN f.new_partyoneIdName ELSE f.new_partytwoIdName END AS UserIdName
	                                FROM
		                                new_friendship AS f (NOLOCK)
	                                WHERE
		                                f.new_portalId='{0}'
	                                AND
		                                f.statecode=0
	                                AND
		                                (f.new_partyoneId='{1}' OR f.new_partytwoId='{1}')
                                ) AS A
                                WHERE
	                                A.UserIdName LIKE '%{2}%'"    ;

                DataTable dataTable = sda.getDataTable(string.Format(str, portalId, portalUserId, searchKey));

                if (dataTable.Rows.Count > 0)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        SelectValue selectValue = new SelectValue()
                        {
                            text   = dataTable.Rows[i]["UserIdName"].ToString(),
                            @value = dataTable.Rows[i]["UserId"].ToString()
                        };
                        selectValues.Add(selectValue);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(selectValues);
        }
Пример #5
0
        public static List<SelectValue> SearchFriend(string portalId, string portalUserId, string searchKey, SqlDataAccess sda)
        {
            List<SelectValue> selectValues = new List<SelectValue>();

            try
            {
                string str = @"SELECT
                                    *
                                FROM
                                (
                                    SELECT
                                        CASE WHEN f.new_partyoneId!='{1}' THEN f.new_partyoneId ELSE f.new_partytwoId END  AS UserId
                                        ,CASE WHEN f.new_partyoneId!='{1}' THEN f.new_partyoneIdName ELSE f.new_partytwoIdName END AS UserIdName
                                    FROM
                                        new_friendship AS f (NOLOCK)
                                    WHERE
                                        f.new_portalId='{0}'
                                    AND
                                        f.statecode=0
                                    AND
                                        (f.new_partyoneId='{1}' OR f.new_partytwoId='{1}')
                                ) AS A
                                WHERE
                                    A.UserIdName LIKE '%{2}%'";

                DataTable dataTable = sda.getDataTable(string.Format(str, portalId, portalUserId, searchKey));

                if (dataTable.Rows.Count > 0)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        SelectValue selectValue = new SelectValue()
                        {
                            text = dataTable.Rows[i]["UserIdName"].ToString(),
                            @value = dataTable.Rows[i]["UserId"].ToString()
                        };
                        selectValues.Add(selectValue);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return selectValues;
        }
Пример #6
0
    private void Bind()
    {
        Bll_Region BRegion = new Bll_Region();

        string[] arraySelcetValue = SelectValue.Split(',');
        if (arraySelcetValue != null && arraySelcetValue.Length == 3)
        {
            string ProvinceID = arraySelcetValue[0];
            string CityID     = arraySelcetValue[1];
            string TownID     = arraySelcetValue[2];

            StringBuilder sb = new StringBuilder();
            DataSet       ds = BRegion.GetList(0, " RegionGrade=1 and ParentID=0 and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc ");
            if (ds.Tables.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                if (dt.Rows.Count > 0)
                {
                    //一级地区
                    sb.Append("<select name=\"" + Provinces + "\" id=\"" + Provinces + "\"  class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"ProvinceChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">");
                    sb.Append("<option value=\"0\">请选择</option>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (ProvinceID == dt.Rows[i]["ID"].ToString())
                        {
                            sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                        }
                        else
                        {
                            sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                        }
                    }
                    sb.Append("</select>&nbsp;");

                    //二级地区
                    ds.Clear();
                    dt.Clear();
                    sb.Append("<select name=\"" + Citys + "\" id=\"" + Citys + "\"  class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"CityChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">");
                    sb.Append("<option value=\"0\">请选择</option>");
                    if (ProvinceID != "0")
                    {
                        ds = BRegion.GetList(0, " RegionGrade=2 and ParentID=" + ProvinceID + " and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc ");
                        if (ds.Tables.Count > 0)
                        {
                            dt = ds.Tables[0];
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                if (CityID == dt.Rows[i]["ID"].ToString())
                                {
                                    sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                                }
                                else
                                {
                                    sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                                }
                            }
                        }
                    }
                    sb.Append("</select>&nbsp;");


                    //三级地区
                    ds.Clear();
                    dt.Clear();
                    sb.Append("<select name=\"" + Towns + "\" id=\"" + Towns + "\"  class=\"" + CssClass + "\" datatype=\"no0\" onchange=\"TownsChanged('" + Provinces + "','" + Citys + "','" + Towns + "','" + WebSiteID + "');\">");
                    sb.Append("<option value=\"0\">请选择</option>");
                    if (CityID != "0")
                    {
                        ds = BRegion.GetList(0, " RegionGrade=3 and ParentID=" + CityID + " and WebSiteID=" + WebSiteID + " ", " OrderBy desc,RegionPath asc ");
                        if (ds.Tables.Count > 0)
                        {
                            dt = ds.Tables[0];
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                if (TownID == dt.Rows[i]["ID"].ToString())
                                {
                                    sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" selected=\"selected\">" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                                }
                                else
                                {
                                    sb.Append("<option value=\"" + dt.Rows[i]["ID"].ToString() + "\" >" + dt.Rows[i]["RegionName"].ToString() + "</option>");
                                }
                            }
                        }
                    }
                    sb.Append("</select>");
                }
                AddressHtml = sb.ToString();
            }
        }
    }
Пример #7
0
        public async Task TwoLevelQueryWorks()
        {
            var selectValue = new SelectValue
            {
                FieldName    = "Edge1",
                SelectValues = new List <SelectValue>
                {
                    new SelectValue {
                        FieldName = "Id"
                    },
                    new SelectValue {
                        FieldName = "Field1"
                    }
                }
            };

            var list = PrepData();
            var qs   = PrepQuery(selectValue);

            const string other1Id = "other1";

            var connectionEdges = new List <ConnectionEdge>
            {
                SetupConnectionEdge <ModelWith3ConnectionsEdge, ModelWith3Connections>(
                    new ModelWith3ConnectionsEdge
                {
                    Id     = "other1edge",
                    Field1 = "SHARP"
                }, "model5_a", other1Id)
            };

            SetupConnectionEdgeRepository(new string[] { "model5_a", "model5_b" }, connectionEdges, other1Id,
                                          new List <object> {
                new ModelWith3ConnectionsOther
                {
                    Id = other1Id, Field1 = "testother"
                }
            });

            await _connectionEdgeHandler.QueryAsync(list, qs, null, null,
                                                    new List <ConnectionEdgeDestinationFilter>());

            list.Count.ShouldBe(2);

            var m5_a = GetModel("model5_a", list);

            m5_a.ShouldNotBeNull();
            m5_a.Id.ShouldBe("model5_a");

            m5_a.Edge1.ShouldNotBeNull();
            m5_a.Edge1.Id.ShouldBe("other1edge");
            m5_a.Edge1.Field1.ShouldBe("SHARP");

            m5_a.Edge1.Other.ShouldNotBeNull();
            m5_a.Edge1.Other.Id.ShouldBe("other1");
            m5_a.Edge1.Other.Field1.ShouldBe("testother");

            m5_a.Edge2.ShouldBeNull();
            m5_a.Edge3.ShouldBeNull();

            var m5_b = GetModel("model5_b", list);

            m5_b.ShouldNotBeNull();
            m5_b.Id.ShouldBe("model5_b");

            m5_b.Edge1.ShouldBeNull();
            m5_b.Edge2.ShouldBeNull();
            m5_b.Edge3.ShouldBeNull();
        }
Пример #8
0
        //methods
        public bool CalculateComposites()
        {
            //get configs
            //add columns to datatable and column collection
            //check deadranges
            //compare sensor a aand b acorsss all configs
            //add columns and update data through the dataview that is each config


            SelectValue UseColumn = default(SelectValue);
            double      missing   = Settings.Default.MissingValue;

            IWindSpeedConfig A = new WindSpeedConfig();
            int    AIndex;
            double AVal;


            IWindSpeedConfig B = new WindSpeedConfig();
            int    BIndex;
            double BVal;

            ISessionColumn ACol;
            ISessionColumn BCol;
            int            compositeIndex = 0;


            IConfigCollection configCollection = new HeightConfigCollection(_collection);
            string            datecol          = _data.Columns [_collection.DateIndex].ColumnName;

            string wdcolname = Enum.GetName(typeof(SessionColumnType), SessionColumnType.WDAvg)
                               + Settings.Default.CompColName;
            int WDIndex = _collection[wdcolname].ColIndex;

            double WDVal;


            double workVal;

            //find each config across height changes..
            List <HeightConfig> workConfigs
                = configCollection.GetConfigs().ConvertAll <HeightConfig>(t => (HeightConfig)t).ToList();

            //Console.WriteLine("workconfigs count " + workConfigs.Count);
            //loop through each config
            foreach (HeightConfig htConfig in workConfigs)
            {       //loop each ht in config
                DataView configData = _data.AsDataView();
                configData.Sort = Settings.Default.TimeStampName + " asc ";
                //filter the data based on start and end of the current ht config
                string filter = datecol + ">= '" + htConfig.StartDate.ToString() + "' and " + datecol + " <='"
                                + htConfig.EndDate.ToString() + "'";
                Console.WriteLine(filter);
                configData.RowFilter = filter;

                if (configData.Count > _data.Rows.Count)
                {
                    throw new ApplicationException("Error filtering dataset by configuration dates");
                }

                int RowNum = configData.Count;

                Console.WriteLine("datatable and filtered dataviewcounts: " + _data.Rows.Count + " " + RowNum);

                List <double> resultArray = new List <double>(RowNum);
                Console.WriteLine(" Heights found " + htConfig.Columns.Count);
                //loop each height's columns in config
                //each htconfig stores a collection of collumns with those hts
                foreach (KeyValuePair <double, IList <ISessionColumn> > kv in htConfig.Columns)
                {
                    var a = from f in kv.Value.AsEnumerable()
                            where f.ColumnType == SessionColumnType.WSAvg
                            select f;

                    List <ISessionColumn> thisresult = a.ToList();
                    //get sensor pairs that are ws avg types
                    if (a.Count() == 2)
                    {
                        Console.WriteLine(thisresult[0].ColumnType);
                        Console.WriteLine(thisresult[1].ColumnType);

                        ACol = thisresult[0];
                        BCol = thisresult[1];

                        AIndex = ACol.ColIndex;
                        BIndex = BCol.ColIndex;

                        //get the specific config for the date of the ht config
                        A = (IWindSpeedConfig)ACol.getConfigAtDate(htConfig.StartDate);
                        B = (IWindSpeedConfig)BCol.getConfigAtDate(htConfig.StartDate);
                        //change the config in the sensor config data if there are dead zones

                        CheckDeadRange(A, B);


                        Console.WriteLine("A Good Range: " + A.GoodSector.SectorStart + " to " + A.GoodSector.SectorEnd);
                        Console.WriteLine("A Bad Range: " + A.ShadowSector.SectorStart + " to " + A.ShadowSector.SectorEnd);
                        Console.WriteLine("B Good Range: " + B.GoodSector.SectorStart + " to " + B.GoodSector.SectorEnd);
                        Console.WriteLine("B Bad Range: " + B.ShadowSector.SectorStart + " to " + B.ShadowSector.SectorEnd);
                    }
                    else
                    {
                        continue;
                    }

                    double height = A.Height;

                    IList <ISessionColumn> thisColumnSet = kv.Value;

                    //add column to datatable and column collection if necessary
                    WindSpeedCompColumns wscompcols = new WindSpeedCompColumns(_collection, _data);
                    wscompcols.Add(height, thisColumnSet, htConfig.StartDate, htConfig.EndDate);
                    if (NewCompositeColumnAdded != null)
                    {
                        NewCompositeColumnAdded("Wind Speed Composite Columns Added");
                    }


                    #region decide on value
                    //begin calculating comps for each row
                    if (DeterminingWindSpeedCompositeValues != null)
                    {
                        DeterminingWindSpeedCompositeValues("Assigning Wind Speed Composite Values");
                    }
                    foreach (DataRowView rowview in configData)
                    {
                        if (!Double.TryParse(rowview[AIndex].ToString(), out AVal))
                        {
                            AVal = missing;
                        }
                        else
                        {
                            if (AVal < 0)
                            {
                                AVal = missing;
                            }
                        }
                        if (!Double.TryParse(rowview[BIndex].ToString(), out BVal))
                        {
                            BVal = missing;
                        }
                        else
                        {
                            if (BVal < 0)
                            {
                                BVal = missing;
                            }
                        }
                        if (!double.TryParse(rowview[WDIndex].ToString(), out WDVal) || WDVal < 0)
                        {
                            WDVal     = missing;
                            UseColumn = SelectValue.missing;
                            goto assignvalue;
                        }

                        InSector SensorA = A.BelongsToSector(WDVal);
                        InSector SensorB = B.BelongsToSector(WDVal);

                        //in A not in B
                        if (SensorA.Equals(InSector.Not_Shadowed) &&
                            (SensorB.Equals(InSector.Shadowed) |
                             SensorB.Equals(InSector.Neither)))
                        {
                            workVal = AVal;
                            if (workVal.Equals(missing))
                            {
                                UseColumn = SelectValue.missing;
                            }
                            else
                            {
                                UseColumn = SelectValue.A;
                            }

                            goto assignvalue;
                        }

                        //in B not in A take b
                        if (SensorB.Equals(InSector.Not_Shadowed) &&
                            (SensorA.Equals(InSector.Shadowed) |
                             SensorA.Equals(InSector.Neither)))
                        {
                            workVal = BVal;
                            if (workVal < 0)
                            {
                                UseColumn = SelectValue.missing;
                            }
                            else
                            {
                                UseColumn = SelectValue.B;
                            }

                            goto assignvalue;
                        }

                        //in both A and B avg the two
                        if (SensorB.Equals(InSector.Not_Shadowed) &&
                            SensorA.Equals(InSector.Not_Shadowed))
                        {
                            if (AVal < 0 && BVal >= 0)
                            {
                                UseColumn = SelectValue.B;
                                goto assignvalue;
                            }

                            if (BVal < 0 && AVal >= 0)
                            {
                                UseColumn = SelectValue.A;
                                goto assignvalue;
                            }
                            //if wdval is on a boundary use the other sensor
                            if (WDVal == A.GoodSector.SectorStart | WDVal == A.GoodSector.SectorEnd)
                            {
                                UseColumn = SelectValue.B;
                                goto assignvalue;
                            }

                            if (WDVal == B.GoodSector.SectorStart | WDVal == B.GoodSector.SectorEnd)
                            {
                                UseColumn = SelectValue.A;
                                goto assignvalue;
                            }

                            List <double> avg = new List <double>()
                            {
                                BVal, AVal
                            };
                            UseColumn = SelectValue.both;
                            workVal   = avg.Average();
                            goto assignvalue;
                        }

                        //otherwise set to missing
                        workVal = missing;
                        goto assignvalue;
                        #endregion
                        #region assign value
assignvalue:
                        {
                            double useval        = missing;
                            double usevalB       = missing;
                            string heightstring  = height.ToString().Replace(".", "_");
                            string parentColName = heightstring + Enum.GetName(typeof(SessionColumnType), SessionColumnType.WSAvg) + Settings.Default.CompColName;
                            if (_collection[parentColName] != null)
                            {
                                compositeIndex = _collection[parentColName].ColIndex;
                            }
                            else
                            {
                                throw new ApplicationException(" Parent composite column " + parentColName + " not found");
                            }
                            switch (UseColumn)
                            {
                            case SelectValue.A:
                                rowview[compositeIndex] = AVal;
                                foreach (ISessionColumn child in ACol.ChildColumns)
                                {
                                    string thischildcompname = heightstring
                                                               + Enum.GetName(typeof(SessionColumnType), child.ColumnType)
                                                               + Settings.Default.CompColName;
                                    if (_collection[thischildcompname] != null)
                                    {
                                        if (!double.TryParse(rowview[child.ColIndex].ToString(), out useval))
                                        {
                                            rowview[thischildcompname] = missing;
                                        }
                                        else
                                        {
                                            rowview[thischildcompname] = useval;
                                        }
                                    }
                                    else
                                    {
                                        throw new ApplicationException(" Child composite column " + thischildcompname + " not found");
                                    }
                                }
                                break;

                            case SelectValue.B:
                                rowview[compositeIndex] = BVal;
                                foreach (ISessionColumn child in BCol.ChildColumns)
                                {
                                    string thischildcompname = heightstring
                                                               + child.ColumnType
                                                               + Settings.Default.CompColName;

                                    if (_collection[thischildcompname] != null)
                                    {
                                        if (!double.TryParse(rowview[child.ColIndex].ToString(), out useval))
                                        {
                                            rowview[thischildcompname] = missing;
                                        }
                                        else
                                        {
                                            rowview[thischildcompname] = useval;
                                        }
                                    }
                                    else
                                    {
                                        throw new ApplicationException(" Child composite column " + thischildcompname + " not found");
                                    }
                                }
                                break;

                            case SelectValue.missing:
                                rowview[compositeIndex] = missing;
                                //loop through comp cols for both a and b in case one column has more children than the other
                                foreach (ISessionColumn child in ACol.ChildColumns)
                                {
                                    string thischildcompname = heightstring
                                                               + Enum.GetName(typeof(SessionColumnType), child.ColumnType)
                                                               + Settings.Default.CompColName;
                                    if (_collection[thischildcompname] != null)
                                    {
                                        rowview[thischildcompname] = missing;
                                    }
                                    else
                                    {
                                        throw new ApplicationException(" Child composite column " + thischildcompname + " not found");
                                    }
                                }
                                foreach (ISessionColumn child in BCol.ChildColumns)
                                {
                                    string thischildcompname = heightstring
                                                               + Enum.GetName(typeof(SessionColumnType), child.ColumnType)
                                                               + Settings.Default.CompColName;
                                    if (_collection[thischildcompname] != null)
                                    {
                                        rowview[thischildcompname] = missing;
                                    }
                                    else
                                    {
                                        throw new ApplicationException(" Child composite column " + thischildcompname + " not found");
                                    }
                                }
                                break;

                            case SelectValue.both:
                                double averageWs = new double[2] {
                                    AVal, BVal
                                }.Average();
                                rowview[compositeIndex] = averageWs;
                                //loop through comp cols for both a and b in case one column has more children than the other
                                foreach (ISessionColumn child in ACol.ChildColumns)
                                {
                                    string thischildcompname = heightstring
                                                               + Enum.GetName(typeof(SessionColumnType), child.ColumnType)
                                                               + Settings.Default.CompColName;
                                    if (_collection[thischildcompname] != null)
                                    {
                                        var result = from c in BCol.ChildColumns.AsEnumerable()
                                                     where c.ColumnType == child.ColumnType
                                                     select c;

                                        List <ISessionColumn> columnfound = result.ToList();

                                        if (columnfound.Count == 1)
                                        {
                                            //Console.WriteLine(" ****************** average taken");
                                            if (!double.TryParse(rowview[columnfound[0].ColIndex].ToString(), out useval) &
                                                !double.TryParse(rowview[child.ColIndex].ToString(), out usevalB))
                                            {
                                                rowview[thischildcompname] = missing;
                                            }
                                            else
                                            {
                                                if (child.ColumnType == SessionColumnType.WSStd)
                                                {                //combine ws standard deviations more correctly than straight average
                                                    double pooled_var = (Math.Pow(useval, 2.0) + Math.Pow(usevalB, 2.0)
                                                                         + Math.Pow((AVal - averageWs), 2.0)
                                                                         + Math.Pow((BVal - averageWs), 2.0)) / 2;

                                                    double pooled_std = Math.Sqrt(pooled_var);
                                                    if (pooled_std < 100.0)
                                                    {
                                                        rowview[thischildcompname] = pooled_std;
                                                    }
                                                    else
                                                    {
                                                        rowview[thischildcompname] = missing;
                                                    }
                                                }
                                                else
                                                {
                                                    rowview[thischildcompname] = new double[2] {
                                                        useval, usevalB
                                                    }.Average();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine(" missing taken A value =" + AVal + " B Val " + BVal);
                                            rowview[thischildcompname] = missing;
                                        }
                                    }
                                    else
                                    {
                                        throw new ApplicationException(" Child composite column " + thischildcompname + " not found");
                                    }
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    #endregion
                }
            }
            if (CompletedWindSpeedCompositeValues != null)
            {
                CompletedWindSpeedCompositeValues("Completed Generating Wind Speed Composites");
            }
            return(true);
        }