Esempio n. 1
0
        public static string Link(string IdTaxonomyCategory, string IdCategory, string IdVariable, string IdTaxonomyVariable)
        {
            VariableLink variableLink = new VariableLink(Global.Core.VariableLinks);

            List <object[]> variableLinks = Global.Core.VariableLinks.GetValues(
                new string[] { "Id" },
                new string[] { "IdVariable", "IdTaxonomyVariable" },
                new object[] { IdVariable, IdTaxonomyVariable });

            variableLink.IdVariable         = new Guid(IdVariable);
            variableLink.IdTaxonomyVariable = new Guid(IdTaxonomyVariable);
            variableLink.CreationDate       = DateTime.Now;

            if (variableLinks.Count() == 0)
            {
                variableLink.Insert();
            }

            CategoryLink categoryLink = new CategoryLink(Global.Core.CategoryLinks);

            categoryLink.IdCategory         = new Guid(IdCategory);
            categoryLink.IdTaxonomyCategory = new Guid(IdTaxonomyCategory);
            categoryLink.IdVariable         = new Guid(IdVariable);
            categoryLink.IdTaxonomyVariable = new Guid(IdTaxonomyVariable);
            categoryLink.CreationDate       = DateTime.Now;

            List <object[]> categoryLinks = Global.Core.CategoryLinks.GetValues(
                new string[] { "Id" },
                new string[] {
                "IdCategory",
                "IdTaxonomyCategory",
                "IdVariable",
                "IdTaxonomyVariable"
            },
                new object[] {
                IdCategory,
                IdTaxonomyCategory,
                IdVariable,
                IdTaxonomyVariable
            });

            if (categoryLinks.Count() == 0)
            {
                categoryLink.Insert();
            }

            return("sucess");
        }
        /// <summary>
        /// segregated only link funtionality of variables
        /// </summary>
        /// <param name="IdsStudyVariables">comma seperated values of variable ids to be un linked</param>
        /// <param name="IdsTaxonomyVariables">comma seperated values of  taxonomy variable ids to be un linked</param>
        /// <returns></returns>
        private static void LinkVariables(string[] ArrIdsStudyVariables, string[] ArrIdsTaxonomyVariables)
        {
            for (int i = 0; i < ArrIdsStudyVariables.Count(); i++)
            {
                List <object[]> variableLinks = Global.Core.VariableLinks.GetValues(new string[] { "Id" }, new string[] { "IdVariable", "IdTaxonomyVariable" }, new object[] { ArrIdsStudyVariables[i], ArrIdsTaxonomyVariables[0] });

                if (variableLinks.Count() == 0)
                {
                    VariableLink newVariableLink = new VariableLink(Global.Core.VariableLinks);

                    newVariableLink.IdVariable         = new Guid(ArrIdsStudyVariables[i]);
                    newVariableLink.IdTaxonomyVariable = new Guid(ArrIdsTaxonomyVariables[0]);
                    newVariableLink.CreationDate       = DateTime.Now;

                    newVariableLink.Insert();
                }
            }
        }
        /// <summary>
        /// For Linking Multi and Numeric Variables
        /// </summary>
        /// <param name="context"></param>
        public void LinkNumericOrMulti(HttpContext context)
        {
            Guid IdVariable         = Guid.Parse(context.Request.Params["IdVariable"]);
            Guid IdTaxonomyVariable = Guid.Parse(context.Request.Params["IdTaxonomyVariable"]);

            VariableLink variableLink = new VariableLink(Global.Core.VariableLinks);

            List <object[]> variableLinks = Global.Core.VariableLinks.GetValues(
                new string[] { "Id" },
                new string[] { "IdVariable", "IdTaxonomyVariable" },
                new object[] { IdVariable, IdTaxonomyVariable });

            variableLink.IdVariable         = IdVariable;
            variableLink.IdTaxonomyVariable = IdTaxonomyVariable;
            variableLink.CreationDate       = DateTime.Now;

            if (variableLinks.Count() == 0)
            {
                variableLink.Insert();
            }

            context.Response.Write("success");
        }
        /// <summary>
        /// For Linking Variables and Categories
        /// </summary>
        /// <param name="context"></param>
        public void Link(HttpContext context)
        {
            Guid IdTaxonomyCategory = Guid.Parse(context.Request.Params["IdTaxonomyCategory"]);
            Guid IdCategory         = Guid.Parse(context.Request.Params["IdCategory"]);
            Guid IdVariable         = Guid.Parse(context.Request.Params["IdVariable"]);
            Guid IdTaxonomyVariable = Guid.Parse(context.Request.Params["IdTaxonomyVariable"]);

            VariableLink variableLink = new VariableLink(Global.Core.VariableLinks);

            List <object[]> variableLinks = Global.Core.VariableLinks.GetValues(
                new string[] { "Id" },
                new string[] { "IdVariable", "IdTaxonomyVariable" },
                new object[] { IdVariable, IdTaxonomyVariable });

            ArrayList categoriesLinkList = new ArrayList();

            variableLink.IdVariable         = IdVariable;
            variableLink.IdTaxonomyVariable = IdTaxonomyVariable;
            variableLink.CreationDate       = DateTime.Now;

            if (variableLinks.Count() == 0)
            {
                variableLink.Insert();
            }

            CategoryLink categoryLink = new CategoryLink(Global.Core.CategoryLinks);

            categoryLink.IdVariable         = IdVariable;
            categoryLink.IdCategory         = IdCategory;
            categoryLink.IdTaxonomyCategory = IdTaxonomyCategory;
            categoryLink.IdTaxonomyVariable = IdTaxonomyVariable;
            categoryLink.CreationDate       = DateTime.Now;

            List <object[]> categoryLinks = Global.Core.CategoryLinks.GetValues(
                new string[] { "Id" },
                new string[] {
                "IdCategory",
                "IdTaxonomyCategory",
                "IdVariable",
                "IdTaxonomyVariable"
            },
                new object[] {
                IdCategory,
                IdTaxonomyCategory,
                IdVariable,
                IdTaxonomyVariable
            });

            if (categoryLinks.Count() == 0)
            {
                categoryLink.Insert();
            }


            foreach (var item in categoryLinks)
            {
                dynamic variable = new { IdVariable = IdVariable, IdCategory = IdCategory, IdTaxonomyCategory = IdTaxonomyCategory, IdTaxonomyVariable = IdTaxonomyVariable };
                categoriesLinkList.Add(variable);
            }

            string jSon = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(categoriesLinkList);

            context.Response.Write(jSon);

            //context.Response.Write("success");
        }