Exemple #1
0
        public void Insert(FileInfo fileInfo, AudioFileInfo audioFileInfo)
        {
            Database database = (new DbFactory()).CreateDatabase();

            string spName = ((new Resources()).CreateInsertSPList())[TableList.Track].ToString();

            ExecuteStoredProcWithParam executeStoredProcWithParam =
                new ExecuteStoredProcWithParam(database, spName);

            executeStoredProcWithParam.AddInParameter(database,
                                                      InsertValueByTableName(fileInfo.DirectoryName, TableList.Path),
                                                      @"PathID");

            executeStoredProcWithParam.AddInParameter(database,
                                                      InsertValueByTableName(audioFileInfo.Artist, TableList.Artist),
                                                      @"ArtistID");

            executeStoredProcWithParam.AddInParameter(database,
                                                      InsertValueByTableName(audioFileInfo.Album, TableList.Album),
                                                      @"AlbumID");

            executeStoredProcWithParam.AddInParameter(database,
                                                      InsertValueByTableName(audioFileInfo.Genre, TableList.Genre),
                                                      @"GenreID");

            executeStoredProcWithParam.AddInParameter(database,
                                                      InsertValueByTableName(audioFileInfo.Bitrate, TableList.Bitrate),
                                                      @"BitrateID");

            executeStoredProcWithParam.AddInParameter(database,
                                                      audioFileInfo.Title,
                                                      @"TrackTitle");

            executeStoredProcWithParam.AddInParameter(database,
                                                      fileInfo.Name,
                                                      @"FileName");

            executeStoredProcWithParam.AddInParameter(database,
                                                      fileInfo.Length,
                                                      @"FileSize");

            string newName = string.Empty;

            if (string.IsNullOrEmpty(audioFileInfo.Artist) && string.IsNullOrEmpty(audioFileInfo.Title))
            {
                newName = fileInfo.Name;
            }
            else
            {
                newName = audioFileInfo.Artist + "_" + audioFileInfo.Title;
            }

            executeStoredProcWithParam.AddInParameter(database,
                                                      newName,
                                                      @"NewFileName");

            executeStoredProcWithParam.AddOutParameter(database, @"return_value");
            executeStoredProcWithParam.ExecuteSpSetResultValue(database, @"return_value");
        }
        public int Execute(object[] storedProcedureParam, string storedProcedureName)
        {
            const string outParameterName = "result";

            InitSimple(storedProcedureName);

            foreach (ParameterItem parameterItem in storedProcedureParam)
            {
                dataProvider.AddInParameter(
                    parameterItem.ParameterValue,
                    parameterItem.ParameterName
                    );
            }

            dataProvider.AddOutParameter(outParameterName);

            try
            {
                return(dataProvider.ExecuteSpGetResultValue(outParameterName));
            }catch
            {
            }

            return(0);
        }
Exemple #3
0
        public int Execute(StoredProcedure storedProcedure)
        {
            /// The result value must have some name
            const string outParameterName = "result";
            int          result           = 0;

            InitSimple(storedProcedure.Name);

            foreach (ParameterItem parameterItem in storedProcedure.ParameterValueCollection)
            {
                dataProvider.AddInParameter(
                    parameterItem.ParameterValue,
                    parameterItem.ParameterName);
            }

            dataProvider.AddOutParameter(outParameterName);

            try
            {
                result = dataProvider.ExecuteSpGetResultValue(outParameterName);
            }
            catch
            {
                throw new Exception("Execute(StoredProcedure storedProcedure) has failed to execute");
                result = 0;
            }

            return(result);
        }
Exemple #4
0
        private int InsertValueByTableName(string value, TableList tableName)
        {
            Database database = (new DbFactory()).CreateDatabase();

            string spName = ((new Resources()).CreateInsertSPList())[tableName].ToString();

            ExecuteStoredProcWithParam executeStoredProcWithParam = new ExecuteStoredProcWithParam(database, spName);

            executeStoredProcWithParam.AddInParameter(database, value, @"ValueToInsert");
            executeStoredProcWithParam.AddOutParameter(database, @"return_value");

            return(executeStoredProcWithParam.ExecuteSpSetResultValue(database, @"return_value"));
        }