jxycms
11/29/2017 - 10:34 PM

Get meta description

Get meta description

[MacroMethod(typeof(string), "Get Meta Description", 1)]
[MacroMethodParam(0, "DocumentID", typeof(Int32), "DocumentID")]
public static object GetMetaDescription(EvaluationContext context, params object[] parameters)
{                    
    int DocumentID = ValidationHelper.GetInteger(parameters[0], 0);
    string pageDescription = "";
    string spotLightwhereCondition = "";
    spotLightwhereCondition = "DocumentID = @DocumentID";
    QueryDataParameters dataParams = new QueryDataParameters();
    dataParams.Add("DocumentID", DocumentID, typeof(int));
    DataSet starterSpotLight = ConnectionHelper.ExecuteQuery("SELECT * FROM CMS_Document WHERE " + spotLightwhereCondition, dataParams, QueryTypeEnum.SQLQuery);
    DataRow[] spotLightRows = starterSpotLight.Tables[0].Select();
    if (spotLightRows.Length != 0)
    {
        for (int i = 0; i < spotLightRows.Length; i++)
        {
            pageDescription = ValidationHelper.GetString(spotLightRows[i]["DocumentPageDescription"], "");
        }
    }
    return pageDescription;
}