Esempio n. 1
0
        public SigmaResultType AddFileStore(TypeFileStore objFileStore, string targetPath)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            //objFileStore.CompanyId = userinfo.CompanyId.ToString();
            objFileStore.CreatedBy = userinfo.SigmaUserId;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@ProjectId", userinfo.CurrentProjectId));
            paramList.Add(new SqlParameter("@FileTitle", objFileStore.FileTitle));
            paramList.Add(new SqlParameter("@FileDescription", objFileStore.FileDescription));
            paramList.Add(new SqlParameter("@FileCategory", objFileStore.FileCategory));
            paramList.Add(new SqlParameter("@FileTypeCode", objFileStore.FileTypeCode));
            paramList.Add(new SqlParameter("@CreatedBy", objFileStore.CreatedBy));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddFileStore", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;
                //scope.Complete();
                if (objFileStore.UploadedFileInfo.UploadedFileInfoId == 0)
                {
                    //FileInfo fileinfo = new FileInfo(targetPath + objFileStore.UploadedFileInfo.Path);

                    //objFileStore.UploadedFileInfo.Name = Path.GetFileNameWithoutExtension(targetPath + objFileStore.UploadedFileInfo.Path);
                    //objFileStore.UploadedFileInfo.Size = (int)fileinfo.Length;
                    //objFileStore.UploadedFileInfo.FileExtension = fileinfo.Extension;//Path.GetExtension(objFileStore.UploadedFileInfo.Path);
                    //objFileStore.UploadedFileInfo.FileStoreId = (int)outParam.Value;

                    //-----------------------------------------------------------------------------------------------------
                    //--------------- IE - The given path's format is not supported.  error 해결 -------------------------
                    string filename = Path.GetFileNameWithoutExtension(targetPath + objFileStore.UploadedFileInfo.Path);
                    //string filename = System.IO.Path.GetFileName(targetPath + objFileStore.UploadedFileInfo.Path);
                    FileInfo fileinfo = new FileInfo(targetPath + objFileStore.UploadedFileInfo.Path);
                    string fileExtention = Path.GetExtension(targetPath + objFileStore.UploadedFileInfo.Path);
                    //-----------------------------------------------------------------------------------------------------
                    //-----------------------------------------------------------------------------------------------------

                    objFileStore.UploadedFileInfo.Name = filename;
                    objFileStore.UploadedFileInfo.Size = (int)fileinfo.Length;
                    objFileStore.UploadedFileInfo.FileExtension = fileExtention;
                    objFileStore.UploadedFileInfo.FileStoreId = (int)outParam.Value;

                    UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
                    uploadedFileInfoMgr.AddUploadedFileInfo(objFileStore.UploadedFileInfo);
                }
                scope.Complete();
            }

            return result;
        }
Esempio n. 2
0
 public SigmaResultType AddUploadedFileInfo(TypeUploadedFileInfo objUploadedFileInfo)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
         result = uploadedFileInfoMgr.AddUploadedFileInfo(objUploadedFileInfo);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
Esempio n. 3
0
        public SigmaResultType MultiUploadedFileInfo(List<TypeUploadedFileInfo> listObj)
        {
            SigmaResultType result = new SigmaResultType();

            try
            {
                UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
                result = uploadedFileInfoMgr.MultiUploadedFileInfo(listObj);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
Esempio n. 4
0
        public SigmaResultType ListUploadedFileInfo()
        {
            SigmaResultType result = new SigmaResultType();
            try
            {
                var queryStr = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters;
                string max = queryStr["max"];
                string offset = queryStr["offset"];
                string s_option = queryStr["s_option"];
                string s_key = queryStr["s_key"];
                string o_option = queryStr["o_option"];
                string o_desc = queryStr["o_desc"];

                UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
                result = uploadedFileInfoMgr.ListUploadedFileInfo(offset, max, s_option, s_key, o_option, o_desc);
                return result;
            }
            catch (Exception ex)
            {
                // Log Exception
                ExceptionHelper.logException(ex);
                result.IsSuccessful = false;
                result.ErrorMessage = ex.Message;
                return result;
            }
        }
Esempio n. 5
0
 public SigmaResultType GetUploadedFileInfo(string uploadedFileInfoId)
 {
     SigmaResultType result = new SigmaResultType();
     try
     {
         UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
         result = uploadedFileInfoMgr.GetUploadedFileInfo(uploadedFileInfoId);
         return result;
     }
     catch (Exception ex)
     {
         // Log Exception
         ExceptionHelper.logException(ex);
         result.IsSuccessful = false;
         result.ErrorMessage = ex.Message;
         return result;
     }
 }
Esempio n. 6
0
        private bool isExistFile(string importedfilename)
        {
            UploadedFileInfoMgr uploadedfileinfoMgr = new UploadedFileInfoMgr();

            if (uploadedfileinfoMgr.GetUploadedFileInfoCountByName(importedfilename) > 0)
                return false;
            else
                return true;
        }
Esempio n. 7
0
        public SigmaResultType UpdateFileStore(TypeFileStore objFileStore, string targetPath)
        {
            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            objFileStore.UpdatedBy = userinfo.SigmaUserId;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            // Compose parameters
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@FileStroeId", objFileStore.FileStoreId),
                    new SqlParameter("@FileTitle", objFileStore.FileTitle),
                    new SqlParameter("@FileDescription", objFileStore.FileDescription),
                    new SqlParameter("@FileCategory", objFileStore.FileCategory),
                    new SqlParameter("@FileTypeCode", objFileStore.FileTypeCode),
                    new SqlParameter("@UpdatedBy", objFileStore.UpdatedBy),
                };

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, "usp_UpdateFileStore", parameters);
                result.IsSuccessful = true;
                //scope.Complete();
                if (objFileStore.UploadedFileInfo.Path != null)
                {
                    FileInfo fileinfo = new FileInfo(targetPath + objFileStore.UploadedFileInfo.Path);

                    objFileStore.UploadedFileInfo.Name = Path.GetFileNameWithoutExtension(targetPath + objFileStore.UploadedFileInfo.Path);
                    objFileStore.UploadedFileInfo.Size = (int)fileinfo.Length;
                    objFileStore.UploadedFileInfo.FileExtension = Path.GetExtension(objFileStore.UploadedFileInfo.Path);
                    objFileStore.UploadedFileInfo.FileStoreId = objFileStore.FileStoreId;

                    UploadedFileInfoMgr uploadedFileInfoMgr = new UploadedFileInfoMgr();
                    uploadedFileInfoMgr.AddUploadedFileInfo(objFileStore.UploadedFileInfo);
                }
                scope.Complete();
            }

            return result;
        }