Ejemplo n.º 1
0
        public static List <String> CreateTemplateNoParams(DataTable dg, MapedObject map, String storeName, String customName)
        {
            List <String> result = new List <string>();

            if (String.IsNullOrEmpty(customName))
            {
                customName = String.Format("_{0}", NameSpaceManager.RemoveNameSpace(map.ClassName).ToLower());
            }
            string createObject = String.Format("{0} {1} = new {0}();", NameSpaceManager.RemoveNameSpace(map.ClassName), customName);
            string afterObjects = String.Format("{1} = new {0}();", NameSpaceManager.RemoveNameSpace(map.ClassName), customName);
            string insert       = InputBox.frmInput.InputBox("Adding a Object to a Collection? Enter code:", null, customName, false);

            result.Add(createObject);
            int count = -1;

            foreach (DataRow aRow in dg.Rows)
            {
                count++;

                if (count > 0)
                {
                    if (!String.IsNullOrEmpty(insert))
                    {
                        result.Add(insert);
                    }
                    result.Add(" ");
                    result.Add("//NewObject");
                    result.Add(afterObjects);
                }
                DataMapType storeType = DataMapType.None;
                if (Enum.TryParse <DataMapType>(storeName, out storeType))
                {
                    switch (storeType)
                    {
                    case DataMapType.FieldColumnMap:
                        BuildFieldTemplate(customName, aRow, map.FieldMaps, result);
                        break;

                    case DataMapType.PropertyColumnMap:
                        BuildPropertyTemplate(customName, aRow, map.PropMaps, result);
                        break;
                    }
                }
            }
            if (!String.IsNullOrEmpty(insert))
            {
                result.Add(insert);
            }
            return(result);
        }
        public static String BuildTemplate(string customName, DataRow aRow, ColumnMap aMap)
        {
            string output = String.Empty;

            if (aMap.IsNullable)
            {
                if (aMap.DataType.Contains("DateTime?") || aMap.DataType.Contains("String?"))
                {
                    output = string.Format(@"{0}.{1} = {2};", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), ExtractStoreData.SetNullableDateValue(aRow, aMap));
                }
                else
                {
                    output = string.Format("{0}.{1} = {2};", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), ExtractStoreData.SetNullableValue(aRow, aMap));
                }
            }
            else if (aMap.DataType.Contains("String"))
            {
                string value = aRow.Field <string>(aMap.ColumnName);
                if (value != null)
                {
                    value = value.Trim();
                }
                output = string.Format(@"{0}.{1} = ""{2}"";", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), value);
            }
            else if (aMap.DataType.Contains("DateTime"))
            {
                output = string.Format(@"{0}.{1} = DateTime.Parse(""{2}"");", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), aRow.Field <object>(aMap.ColumnName));
            }
            else if (aMap.DataType.Contains("Guid"))
            {
                output = string.Format(@"{0}.{1} = Guid.ParseExact(""{2}"");", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), aRow.Field <object>(aMap.ColumnName));
            }
            else if (aMap.DataType.Contains("Boolean"))
            {
                object value = aRow.Field <object>(aMap.ColumnName);
                if (value != null)
                {
                    value = value.ToString().ToLower();
                }
                output = string.Format("{0}.{1} = {2};", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), value);
            }
            else
            {
                output = string.Format("{0}.{1} = {2};", customName, NameSpaceManager.RemoveNameSpace(ExtractStoreData.GetMapFieldPropName(aMap)), aRow.Field <object>(aMap.ColumnName));
            }

            return(output);
        }
Ejemplo n.º 3
0
        public static List <String> CreateTemplateParams(DataTable dg, MapedObject map, String storeName, String customName)
        {
            List <String> results = new List <string>();

            if (String.IsNullOrEmpty(customName))
            {
                customName = String.Format("_{0}", NameSpaceManager.RemoveNameSpace(map.ClassName).ToLower());
            }

            string insert       = InputBox.frmInput.InputBox("Adding a Object to a Collection? Enter code:", null, customName, false);
            var    aMap         = map.MethodParameters.Where(x => x.MethodName == storeName).FirstOrDefault();
            int    count        = -1;
            bool   delcareClass = true;

            foreach (DataRow aRow in dg.Rows)
            {
                count++;

                if (count > 0)
                {
                    if (!String.IsNullOrEmpty(insert))
                    {
                        results.Add(insert);
                    }
                    results.Add(" ");
                    results.Add("//NewObject");
                    delcareClass = false;
                }

                BuildParamTemplate(aMap, aRow, results, customName, map.ClassName, delcareClass);
            }
            if (!String.IsNullOrEmpty(insert))
            {
                results.Add(insert);
            }
            return(results);
        }