public void Add(AttachFileModel model)
 {
     items.Add( model );
 }
 public void Add(AttachFileModel model)
 {
     items.Add(model);
 }
Esempio n. 3
0
        private static void InsertAttachFile(SqlCommand cmd, AttachFileModel model)
        {
            cmd.Parameters.Clear();

            cmd.CommandText = "UAA_InsertAttachFile";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@ArticleNo", SqlDbType.Int);
            cmd.Parameters.Add("@FilePath", SqlDbType.VarChar,255);
            cmd.Parameters.Add("@FileSize", SqlDbType.Int);

            cmd.Parameters["@ArticleNo"].Value	= model.ArticleNo;
            cmd.Parameters["@FilePath"].Value	= model.FilePath;
            cmd.Parameters["@FileSize"].Value	= model.FileSize;

            cmd.ExecuteNonQuery();
        }
Esempio n. 4
0
        private static void FillAttachFile(SqlDataReader reader, ArticleModel model)
        {
            if( !reader.NextResult() ) return;

            while (reader.Read())
            {
                AttachFileModel fileModel = new AttachFileModel((int)reader["FileNo"]);
                fileModel.ArticleNo		= (int)reader["ArticleNo"];
                fileModel.FilePath		= (string)reader["FilePath"];
                fileModel.FileSize		= (int)reader["FileSize"];
                fileModel.DownCount		= (int)reader["DownCount"];
                fileModel.InsertDate	= (DateTime)reader["InsertDate"];

                model.AttachFile.Add( fileModel );

                fileModel				= null;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// ��ƼŬ�� �����Ѵ�.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="fileCollection"></param>
        /// <returns></returns>
        public static bool UpdateArticle(ArticleModel model, HttpFileCollection fileCollection)
        {
            object trackbackUrl = model.TrackbackUrl.Length > 0 ? (object)model.TrackbackUrl : DBNull.Value;

            SqlParameter[] param =
                {
                    CreateInParam("@ArticleNo",					SqlDbType.Int,4,				model.ArticleNo),
                    CreateInParam("@CategoryID",				SqlDbType.Int, 4,				model.CategoryID),
                    CreateInParam("@Title",						SqlDbType.VarChar,255,			model.Title),
                    CreateInParam("@Content",					SqlDbType.Text,Int32.MaxValue,	model.Content),
                    CreateInParam("@TrackbackUrl",				SqlDbType.VarChar,255,			trackbackUrl),
                    CreateInParam("@PublicFlag",				SqlDbType.Bit,1,				model.PublicFlag),
                    CreateInParam("@PublicRss",					SqlDbType.Bit,1,				model.PublicRss),
                    CreateInParam("@AllowComment",				SqlDbType.Bit,1,				model.AllowComment),
                    CreateInParam("@AllowTrackback",			SqlDbType.Bit,1,				model.AllowTrackback)
                };

            SqlCommand cmd = GetSpCommand("UBA_UpdateArticle", param, IsolationLevel.ReadCommitted);

            try
            {
                cmd.ExecuteNonQuery();

                // ÷������ ����
                for (int i = 0; i < fileCollection.Count; i++)
                {
                    if (fileCollection[i].ContentLength <= 0) continue;
                    string path = string.Format("{0}/{1}", REPOSITORY_ARTICLE, model.ArticleNo.ToString());
                    RepositoryManager.GetInstance().SaveAs(path, fileCollection[i]);

                    AttachFileModel fileModel = new AttachFileModel();
                    fileModel.ArticleNo = model.ArticleNo;
                    fileModel.FilePath = path + "/" + Path.GetFileName(fileCollection[i].FileName);
                    fileModel.FileSize = fileCollection[i].ContentLength;

                    InsertAttachFile(cmd, fileModel);

                    fileModel = null;
                }

                // �±׸� ����� ������ �±׸� �����Ѵ�.
                RemoveTagAll( cmd, model.ArticleNo );
                if (!InsertTag(cmd, model.ArticleNo, model.Tag))
                {
                    throw new UmcDataException("Tag ������ ����");
                }

                ReleaseCommandWithCommit(cmd);

                return true;
            }
            catch (Exception ex)
            {
                ReleaseCommandWithRollback(cmd);
                //return false;
                throw new UmcDataException("UBA_UpdateArticle ���ν��� ȣ���� ����", ex);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// ���Ϲ�ȣ�� ÷�������� �����´�.
        /// </summary>
        /// <param name="fileNo"></param>
        /// <returns></returns>
        public static AttachFileModel GetAttachFileByFileNo(int fileNo)
        {
            SqlParameter[] param = {
                CreateInParam("@FileNo", SqlDbType.Int, 4, fileNo)
            };

            SqlCommand cmd		= GetRawCommand("SELECT * FROM AttachFile WHERE FileNo=@FileNo", param);
            SqlDataReader reader= cmd.ExecuteReader(CommandBehavior.CloseConnection);

            if( !reader.Read()) return new AttachFileModel();

            AttachFileModel fileModel = new AttachFileModel((int)reader["FileNo"]);
            fileModel.ArticleNo = (int)reader["ArticleNo"];
            fileModel.FilePath = (string)reader["FilePath"];
            fileModel.FileSize = (int)reader["FileSize"];
            fileModel.DownCount = (int)reader["DownCount"];
            fileModel.InsertDate = (DateTime)reader["InsertDate"];

            return fileModel;
        }