Example #1
0
        /// <summary>
        /// Возвращает список параметров, которые могут использоваться в запросах
        /// </summary>
        public static SqlParameter[] GetParameters(AttachedFileDTO item)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("@IsDeleted", DbTypes.DbObject(item.IsDeleted)));
            parameters.Add(new SqlParameter("@ItemID", DbTypes.DbObject(item.ItemId)));
            parameters.Add(new SqlParameter("@FileName", DbTypes.DbObject(item.FileName)));

            object       dbvalue   = DbTypes.DbObject(item.FileData);
            SqlParameter parameter = new SqlParameter();

            if (dbvalue == DBNull.Value)
            {
                parameter.IsNullable    = true;
                parameter.ParameterName = "@FileData";
                parameter.SqlDbType     = SqlDbType.VarBinary;
                parameter.SqlValue      = dbvalue;
            }
            else
            {
                parameter.IsNullable    = false;
                parameter.ParameterName = "@FileData";
                parameter.Value         = dbvalue;
            }
            parameters.Add(parameter);

            return(parameters.ToArray());
        }
        public bool addData(AttachedFileDTO attachedFileDTO)
        {
            if (attachedFileDTO.ProjectID == string.Empty || attachedFileDTO.Stage == string.Empty || attachedFileDTO.Task == string.Empty || attachedFileDTO.Time == string.Empty)
            {
                return(false);
            }

            return(AttachedFileDAO.Instance.addData(attachedFileDTO));
        }
Example #3
0
        /// <summary>
        /// Проверяем есть ли файл в Бд(если есть возвращаем его fileId, если нет то ноль)
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private int FindFileId(AttachedFileDTO file)
        {
            int fileId = 0;
            var ds     = _environment.Execute(AttachedFileQueries.GetSelectQueryByNameAndSize(file.FileName, Convert.ToInt32(file.FileSize)));

            if (ds.Tables[0].Rows.Count > 0)
            {
                fileId = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }

            return(fileId);
        }
        public bool addData(AttachedFileDTO attachedFileDTO)
        {
            if (attachedFileDTO.ProjectID == string.Empty || attachedFileDTO.Stage == string.Empty || attachedFileDTO.Task == string.Empty || attachedFileDTO.Time == string.Empty)
            {
                return(false);
            }

            string str_Query = "INSERT INTO ATTACHEDFILE VALUES ('" + attachedFileDTO.ProjectID + "', '" + attachedFileDTO.Stage + "', '" + attachedFileDTO.Task + "', '" + DateTime.Parse(attachedFileDTO.Time).ToString("MM/dd/yyyy HH:mm:ss") + "', '" + attachedFileDTO.FileName + "', '" + attachedFileDTO.Note + "')";

            int i_Result = DataProvider.Instance.ExecuteNonQuery(str_Query);

            return(i_Result > 0);
        }
Example #5
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            string str_ProjectIDLocal = this.str_ProjectIDGlobal;
            string str_StageLocal     = this.str_StageGlobal;
            string str_TaskLocal      = this.str_TaskGlobal;
            string str_TimeLocal      = DateTime.Now.ToString();
            string str_FileNameLocal  = this.txtEdtFileNameUpload.Text.Trim();
            string str_NoteLocal      = this.txtEdtNoteUpload.Text.Trim();

            ftp ftpClientLocal = new ftp(StaticVarClass.ftp_Server, StaticVarClass.ftp_Username, StaticVarClass.ftp_Password);

            if (ftpClientLocal.upload(StaticVarClass.account_Username, ftpInfo.FileName, ftpInfo.FullName))
            {
                AttachedFileDTO attachFileDTOTemp = new AttachedFileDTO(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_TimeLocal, str_FileNameLocal, str_NoteLocal);

                if (AttachedFileDAO.Instance.addData(attachFileDTOTemp))
                {
                    //this.i_FlagUploadGlobal = 1;  // Báo hiệu đã đăng file.

                    // Kiểm tra xác nhận được chưa.
                    this.checkConfirm();

                    // Load lại attachFile.
                    this.loadDataAttachFile();

                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Successful";

                    HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                    HistoryDAO.Instance.addData(hisDTO);
                    #endregion

                    XtraMessageBox.Show("Successfully uploaded!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Làm sạch control.
                    this.clearUpload();
                    this.disableAttachFileUpload(true);
                }
                else
                {
                    #region Cập nhật lịch sử.
                    string name   = StaticVarClass.account_Username;
                    string time   = DateTime.Now.ToString();
                    string action = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                    string status = "Failed";

                    HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                    HistoryDAO.Instance.addData(hisDTO);
                    #endregion

                    XtraMessageBox.Show("Upload failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                #region Cập nhật lịch sử.
                string name   = StaticVarClass.account_Username;
                string time   = DateTime.Now.ToString();
                string action = "Upload a file named " + str_FileNameLocal + " in project - stage - task: " + str_ProjectIDLocal + " - " + str_StageLocal + " - " + str_TaskLocal;
                string status = "Failed";

                HistoryDTO hisDTO = new HistoryDTO(name, time, action, status);
                HistoryDAO.Instance.addData(hisDTO);
                #endregion

                XtraMessageBox.Show("Upload failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }