Commit b276ad7c by Kim Jinsung

Task #44587【And】カテゴリ選択時の一括更新アイコン機能追加

parent 23854c17
......@@ -1439,5 +1439,14 @@
<string name="title_all_operation">全作業</string>
<string name="category_list">カテゴリ一覧</string>
<string name="title_quick_report_output">帳票確認</string>
<!-- 一括同期機能 -->
<string name="batch_sync">一括同期</string>
<string name="batch_syncing">一括同期中...</string>
<string name="msg_confirm_batch_sync">表示中の全作業を一括同期しますか?</string>
<string name="msg_batch_sync_disconnect_network">インターネットに接続されていない為、同期処理を中止します。</string>
<string name="msg_batch_sync_content_download_fail">作業ベース資料のダウンロードに失敗しました。</string>
<string name="msg_batch_sync_new_content_updating">新着更新処理中の為、一括同期できません。</string>
<string name="msg_batch_sync_error">「%1$s」の同期に失敗しました。同期処理を中止します。\n</string>
<string name="msg_batch_sync_move_operation_view">一括同期中には点検作業報告画面へ遷移できません。</string>
<string name="msg_batch_sync_fail_meeting_room_connected">会議室入室中の為、このボタンは利用できません。</string>
</resources>
......@@ -1447,5 +1447,14 @@
<string name="title_all_operation">전체 작업</string>
<string name="category_list">분류 목록</string>
<string name="title_quick_report_output">장표 확인</string>
<!-- 一括同期機能 -->
<string name="batch_sync">일괄 동기</string>
<string name="batch_syncing">일괄 동기중...</string>
<string name="msg_confirm_batch_sync">표시 중인 모든 작업을 일괄 동기 하시겠습니까?</string>
<string name="msg_batch_sync_disconnect_network">인터넷에 접속 중이 아니므로, 동기처리를 중지합니다.</string>
<string name="msg_batch_sync_content_download_fail">작업 베이스 자료 파일 다운로드에 실패 하였습니다.</string>
<string name="msg_batch_sync_new_content_updating">새로운 정보갱신 중에는 일괄 동기을 하실 수 없습니다.</string>
<string name="msg_batch_sync_error">「%1$s」정보갱신에 실패하였습니다. 동기처리을 중지합니다.\n</string>
<string name="msg_batch_sync_move_operation_view">일괄 동기 처리 중에는 점검작업 보고화면으로 이동하실 수 없습니다.</string>
<string name="msg_batch_sync_fail_meeting_room_connected">회의실 접속 중에는 이 버튼을 이용하실 수 없습니다.</string>
</resources>
\ No newline at end of file
......@@ -1445,5 +1445,14 @@
<string name="title_all_operation">All</string>
<string name="category_list">Select Category</string>
<string name="title_quick_report_output">Report confirmation</string>
<!-- 一括同期機能 -->
<string name="batch_sync">batch sync</string>
<string name="batch_syncing">batch syncing...</string>
<string name="msg_confirm_batch_sync">Do you want to synchronize all the displayed operation?</string>
<string name="msg_batch_sync_disconnect_network">There are not connected to the internet, we will stop the synchronization process.</string>
<string name="msg_batch_sync_content_download_fail">Failed to download operation base content.</string>
<string name="msg_batch_sync_new_content_updating">Batch synchronization can not be performed because new data is being updated.</string>
<string name="msg_batch_sync_error">「%1$s」 failed. Cancel synchronization processing.\n</string>
<string name="msg_batch_sync_move_operation_view">You can not transition to the inspection work report screen because you are in a batch synchronization.</string>
<string name="msg_batch_sync_fail_meeting_room_connected">This button is not available because the meeting is connected.</string>
</resources>
\ No newline at end of file
......@@ -51,7 +51,12 @@
android:textColor="@color/text_dialog"
android:textSize="15dp"
android:textStyle="bold" />
<ImageButton
android:id="@+id/btn_batch_sync"
style="@style/ToolBarIcon"
android:layout_toLeftOf="@+id/btn_search"
android:src="@drawable/btn_operation_batch_sync"
android:visibility="gone" />
<ImageButton
android:id="@+id/btn_search"
android:layout_width="wrap_content"
......
......@@ -59,6 +59,13 @@
android:textStyle="bold" />
</LinearLayout>
<ImageButton
android:id="@+id/btn_batch_sync"
style="@style/ToolBarIcon"
android:layout_marginRight="10dp"
android:layout_toLeftOf="@+id/btn_search"
android:src="@drawable/btn_operation_batch_sync"
android:visibility="gone" />
<ImageButton
android:id="@+id/btn_search"
......
......@@ -800,7 +800,7 @@ public abstract class ABVActivity extends Activity {
showSimpleAlertDialog(getString(titleResId), getString(bodyResId));
}
protected void showSimpleAlertDialog(final String title, final String body) {
public void showSimpleAlertDialog(final String title, final String body) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
......
......@@ -98,6 +98,7 @@ import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.DisplayUtil;
import jp.agentec.abook.abv.ui.common.util.Initializer;
import jp.agentec.abook.abv.ui.common.view.ABVBatchSyncView;
import jp.agentec.abook.abv.ui.common.vo.Size;
import jp.agentec.abook.abv.ui.home.activity.HelpActivity;
import jp.agentec.abook.abv.ui.home.activity.LoginActivity;
......@@ -125,7 +126,8 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
protected ImageButton btnDownload;
protected ActivityHandlingHelper activityHandlingHelper;
protected Size mDisplaySize;
// 一括同期ビュー(コントロール)
protected ABVBatchSyncView batchSyncView;
/**
* メッセージ表示タイプ
*/
......@@ -590,6 +592,17 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
}
protected boolean contentDownload(final long contentId, boolean needCheckWifiFlag) {
return contentDownload(contentId, true, true);
}
/**
* ダウンロード処理
* @param contentId
* @param needCheckWifiFlag
* @param isShowToast
* @return
*/
protected boolean contentDownload(final long contentId, boolean needCheckWifiFlag, final boolean isShowToast) {
boolean result = true;
try {
if (needCheckWifiFlag) {
......@@ -597,7 +610,7 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
showWifiDisconnectAlert(R.string.C_E_SYSTEM_0005, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
contentDownload(contentId, false);
contentDownload(contentId, false, isShowToast);
}
}, new DialogInterface.OnClickListener() {
@Override
......@@ -611,42 +624,29 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
} else {
// 空き容量が少ない場合警告を表示
if (!StorageUtil.isFreeSpaceEnough(this)) {
Logger.w(TAG, "[storage free space enough]");
if (isShowToast) {
handleErrorMessageToast(ErrorCode.STORAGE_WARNING);
}
}
contentDownloader.download(contentId);
}
} catch (NetworkDisconnectedException e) {
Logger.e(TAG, "NetworkDisconnectedException" + e);
if (isShowToast) {
handleErrorMessageToast(ErrorCode.NETWORK);
}
result = false;
} catch (ABVException e) {
if (btnDownload != null) {
btnDownload.setVisibility(View.INVISIBLE);
}
Logger.e("ABVException", e.toString());
result = false;
} catch (Exception e) {
Logger.e(TAG, "Exception " + e);
if (isShowToast) {
handleErrorMessageToast(ErrorCode.E107);
result = false;
} finally {
try {
List<ContentDto> contentList = contentDao.getUnfinishedDownloadAll();
if (contentList != null && contentList.size() > 0) {
if (btnDownload != null) {
btnDownload.setVisibility(View.VISIBLE);
}
} else {
if (btnDownload != null) {
btnDownload.setVisibility(View.INVISIBLE);
}
}
} catch (Exception e) {
Logger.e(TAG, "Exception " + e);
handleErrorMessageToast(ErrorCode.E107);
result = false;
}
}
return result;
}
......@@ -749,4 +749,11 @@ public abstract class ABVAuthenticatedActivity extends ABVActivity implements Co
startActivity(intent);
}
/**
* 一括同期処理中であるか確認
* @return
*/
public boolean isShowingBatchSync() {
return batchSyncView != null && batchSyncView.isShowing();
}
}
package jp.agentec.abook.abv.ui.common.view;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.PixelFormat;
import java.util.Stack;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.data.dao.AbstractDao;
import jp.agentec.abook.abv.bl.data.dao.ContentDao;
import jp.agentec.abook.abv.bl.dto.ContentDto;
import jp.agentec.abook.abv.bl.dto.OperationDto;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.home.activity.OperationListActivity;
/**
* Created by leej on 2019/08/26.
*/
public class ABVBatchSyncView extends ProgressDialog {
private static final String TAG = "ABVBatchSyncView";
private Stack<OperationDto> mBatchSyncOperationStack = new Stack<>();
private ContentDao contentDao = AbstractDao.getDao(ContentDao.class);
private OperationListActivity mOperationListActivity;
// Activityが破棄された場合、処理を中止するフラグ
private boolean isDestroy = false;
public ABVBatchSyncView(Context context) {
super(context);
mOperationListActivity = (OperationListActivity)context;
init();
isDestroy = false;
}
// 初期化
private void init() {
if (getWindow() != null) {
setIndeterminate(false);
// キャンセルできないように設定・ナビゲーションバーのバックボタンも無効してくれる
setCancelable(false);
setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); //プログレスバー表示
getWindow().setFormat(PixelFormat.TRANSPARENT);
setMessage(getContext().getResources().getString(R.string.batch_syncing));
}
}
/**
* スタックをセット(同期対象情報)
* @param operationDtoStack
*/
public void setStack(Stack<OperationDto> operationDtoStack) {
setMax(operationDtoStack.size());
mBatchSyncOperationStack = operationDtoStack;
}
/**
* 閉じる処理
*/
public void closeProgressDialog() {
// プログレス値を0に初期化
setProgress(0);
dismiss();
}
/**
* スタック中の空チェック
* @return
*/
public boolean isStackEmpty() {
return mBatchSyncOperationStack.empty();
}
/**
* 一括同期処理(stackの中を全て同期する)
* ベース資料ダウンロードチェックして、未ダウンロードであればダウンロードして同期
*/
public void batchOperationSyncForCheckDonwload() {
if (isDestroy || isStackEmpty()) {
// Activity破棄フラグがtrue、またはスタックが存在しなければ、全て完了と見做す
closeProgressDialog();
Logger.d(TAG, "---batchSync is end");
return;
}
// ベース資料のダウンロードチェック
OperationDto peekOperationDto = mBatchSyncOperationStack.peek();
ContentDto contentDto = contentDao.getContent(peekOperationDto.contentId);
if (contentDto == null) {
Logger.e(TAG, "contentDto is null !");
closeProgressDialog();
return;
}
if (!contentDto.downloadedFlg || contentDto.updatedFlg) {
if (!mOperationListActivity.operationContentDownload(contentDto)) {
// error
showBatchSyncErrorAlert(peekOperationDto, mOperationListActivity.getString(R.string.msg_batch_sync_content_download_fail));
}
return;
}
// 同期処理
batchOperationSync();
}
/**
* 一括同期処理(ベース資料はダウンロード済み)
*/
public void batchOperationSync() {
final OperationDto operationDto = mBatchSyncOperationStack.pop();
String errorMessage = mOperationListActivity.syncOperation(operationDto.operationId, operationDto.reportType, false);
if (errorMessage != null) {
showBatchSyncErrorAlert(operationDto, errorMessage);
} else {
// 正常
// 次のスタックがなければ、カウントしない
if (!isStackEmpty()) {
setProgress(getProgress() + 1);
}
// 次の作業を同期処理
batchOperationSyncForCheckDonwload();
}
}
// Activityが破棄された場合呼ばれる
public void setActivityDestroy() {
isDestroy = true;
}
/**
* 一括同期処理時、エラーアラート表示
* 一括同期中のプログレスバーは非表示にする
* @param operationDto
* @param errorMessage
*/
public void showBatchSyncErrorAlert(OperationDto operationDto, String errorMessage) {
// 異常
closeProgressDialog();
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
String convertErrorMsg = String.format(mOperationListActivity.getString(R.string.msg_batch_sync_error), operationDto.operationName) + errorMessage;
mOperationListActivity.showSimpleAlertDialog(mOperationListActivity.getString(R.string.app_name), convertErrorMsg);
} else {
// ネットワーク通信エラー
mOperationListActivity.showSimpleAlertDialog(mOperationListActivity.getString(R.string.app_name), mOperationListActivity.getString(R.string.msg_batch_sync_disconnect_network));
}
}
}
......@@ -54,6 +54,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
......@@ -107,6 +108,7 @@ import jp.agentec.abook.abv.ui.common.util.KeyboardUtils;
import jp.agentec.abook.abv.ui.common.util.PatternStringUtil;
import jp.agentec.abook.abv.ui.common.view.ABVListDialog;
import jp.agentec.abook.abv.ui.common.view.ABVPopupListWindow;
import jp.agentec.abook.abv.ui.common.view.ABVBatchSyncView;
import jp.agentec.abook.abv.ui.home.adapter.FixPushMessageAdapter;
import jp.agentec.abook.abv.ui.home.adapter.OperationSelectAdapter;
import jp.agentec.abook.abv.ui.home.adapter.PushMessageListAdapter;
......@@ -132,6 +134,7 @@ public class OperationListActivity extends OperationActivity {
private ImageButton mViewModeButton; // 左上
private ImageButton mSearchButton; // 検索ボタン
private ImageButton mCategoryLocationButton; // カテゴリ選択ボタン
private ImageButton mOperationBatchSyncButton; // カテゴリの一括同期ボタン
private List<OperationDto> mOperationList;
......@@ -230,6 +233,7 @@ public class OperationListActivity extends OperationActivity {
mTitleView = (TextView) findViewById(R.id.title);
// カテゴリボタン
mCategoryLocationButton = (ImageButton) findViewById(R.id.btn_category_location);
mOperationBatchSyncButton = (ImageButton) findViewById(R.id.btn_batch_sync);
mViewModeButton.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -259,6 +263,30 @@ public class OperationListActivity extends OperationActivity {
mSelectedFixPuchMessagePosition = 0;
mSendType = 0;
// 一括同期ボタン
mOperationBatchSyncButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// ネットワーク通信チェック
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
showSimpleAlertDialog(getString(R.string.app_name), getString(R.string.request_network_connection));
return;
}
// 新着更新チェック
if (contentRefresher.isRefreshing()) {
showSimpleAlertDialog(getString(R.string.app_name), getString(R.string.msg_batch_sync_new_content_updating));
return;
}
// 会議室接続中
if (ActivityHandlingHelper.getInstance().isMeetingConnected()) {
ABVToastUtil.showMakeText(OperationListActivity.this, R.string.msg_batch_sync_fail_meeting_room_connected, Toast.LENGTH_SHORT);
return;
}
showBatchSyncDialog();
}
});
if (!StringUtil.isNullOrEmpty(getIntent().getStringExtra(AppDefType.PushMessageKey.operationId))) {
final long operationId = Long.parseLong(getIntent().getStringExtra(AppDefType.PushMessageKey.operationId));
String message = getIntent().getStringExtra(AppDefType.PushMessageKey.message);
......@@ -347,6 +375,7 @@ public class OperationListActivity extends OperationActivity {
clearSearch();
// 検索ボタンを無効にする
mSearchButton.setEnabled(false);
mOperationBatchSyncButton.setVisibility(View.VISIBLE);
} else {
// 全て
// 検索ボタン、カテゴリボタンを活性化
......@@ -354,6 +383,7 @@ public class OperationListActivity extends OperationActivity {
mCategoryLocationButton.setEnabled(true);
setCategoryImage(false);
mTitleView.setText(R.string.title_all_operation);
mOperationBatchSyncButton.setVisibility(View.GONE);
}
} else {
// サービスオプションOFF
......@@ -361,6 +391,7 @@ public class OperationListActivity extends OperationActivity {
// アイコン非表示
setCategoryImage(false);
mCategoryLocationButton.setVisibility(View.GONE);
mOperationBatchSyncButton.setVisibility(View.GONE);
// 検索ボタンを活性化
mSearchButton.setEnabled(true);
}
......@@ -437,6 +468,7 @@ public class OperationListActivity extends OperationActivity {
super.onResume();
refreshOperationList();
// 作業指示・報告からプロジェクト一覧へ戻った時の同期処理
if (ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
final long operationId = getUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
if (operationId != -1) {
final OperationDto operationDto = mOperationLogic.getOperation(operationId);
......@@ -450,7 +482,7 @@ public class OperationListActivity extends OperationActivity {
Logger.d(TAG, "onResume Sync operationId : " + operationId);
if (operationDto != null && operationDto.needSyncFlg) {
// 同期処理後、直列処理で新着更新を行う。
syncOperation(operationId, operationDto.reportType);
singleSyncOperation(operationId, operationDto.reportType);
} else {
closeProgressPopup();
}
......@@ -458,10 +490,11 @@ public class OperationListActivity extends OperationActivity {
}
});
}
if (!activityResultFlg && operationId == -1) {
dataRefresh(true);
}
}
putUserPref(AppDefType.UserPrefKey.SYNC_TARGET_OPERATION_ID, -1L);
activityResultFlg = false;
......@@ -684,14 +717,36 @@ public class OperationListActivity extends OperationActivity {
@Override
public void onDownloadingContentZip(final ContentZipDownloadNotification notification) {
String errorCodeStr = "";
if (isShowingBatchSync()) {
if (notification.getError() != null) {
Exception e = notification.getError();
Logger.e(TAG, e);
if (e instanceof AcmsException && ((AcmsException)e).getCode() != null) {
errorCodeStr = Integer.toString(((AcmsException)e).getHttpStatus());
}
}
} else {
super.onDownloadingContentZip(notification);
}
OperationContentDto operationContentDto = mOperationContentDao.getOperationContentForContentId(notification.getContentId());
if (operationContentDto != null) {
if (notification.downloadStatus == DownloadStatusType.Succeeded) {
if (isShowingBatchSync()) {
// 一括同期からの同期処理
Logger.d(TAG, "[onDownloadingContentZip] batchOperationSync start");
batchSyncView.batchOperationSync();
} else {
OperationDto operationDto = mOperationLogic.getOperation(operationContentDto.operationId);
syncOperation(operationContentDto.operationId, operationDto.reportType, true);
singleSyncOperation(operationContentDto.operationId, operationDto.reportType, true);
}
} else if (notification.downloadStatus == DownloadStatusType.Failed || notification.downloadStatus == DownloadStatusType.Canceled || notification.downloadStatus == DownloadStatusType.Paused) {
Logger.i(TAG, "syncOperation update is failed downloadStatus : " + notification.downloadStatus);
Logger.d(TAG, "syncOperation update is failed downloadStatus : " + notification.downloadStatus);
if (isShowingBatchSync()) {
// 一括同期からのダウンロード失敗時、エラーメッセージ表示
OperationDto operationDto = mOperationLogic.getOperation(operationContentDto.operationId);
batchSyncView.showBatchSyncErrorAlert(operationDto, getString(R.string.msg_batch_sync_content_download_fail) + (StringUtil.isNullOrEmpty(errorCodeStr) ? "" : "(" + errorCodeStr + ")"));
}
closeProgressPopup();
}
}
......@@ -700,32 +755,13 @@ public class OperationListActivity extends OperationActivity {
/**
* プロジェクト同期処理
* @param operationId
* @param operationReportType
*/
public void syncOperation(final long operationId, int operationReportType) {
syncOperation(operationId, operationReportType, false);
}
/**
* プロジェクト同期処理
* @param operationId
* @param reportType
* @param buttonEventFlag
* @return errorメッセージ文字列
*/
public void syncOperation(final long operationId, int reportType, boolean buttonEventFlag) {
public String syncOperation(final long operationId, int reportType, boolean buttonEventFlag) {
final StringBuilder errorMsg = new StringBuilder();
Logger.i(TAG, "---sync start");
// ネットワーク通信チェック
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
ABVToastUtil.showMakeText(OperationListActivity.this, R.string.request_network_connection, Toast.LENGTH_SHORT);
closeProgressPopup();
return;
}
// 新着更新チェック
if (contentRefresher.isRefreshing()) {
// ignore
closeProgressPopup();
return;
}
try {
//コンテンツダウンロード関連プログレスバー値設定
progressDialogHorizontal.setProgress(20);
......@@ -748,7 +784,7 @@ public class OperationListActivity extends OperationActivity {
progressDialogHorizontal.setProgress(60);
// 報告受信
mOperationLastEditDate = receptionTaskData(operationId, progressCallback, buttonEventFlag);
mOperationLastEditDate = receptionTaskData(operationId, progressCallback, buttonEventFlag, errorMsg);
if (reportType == ReportType.RoutineTask) {
if (buttonEventFlag) {
......@@ -768,7 +804,7 @@ public class OperationListActivity extends OperationActivity {
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
if (!StringUtil.isNullOrEmpty(dialogMsg)) {
showSimpleAlertDialog(getString(R.string.app_name), dialogMsg);
errorMsg.append(dialogMsg);
}
}
}
......@@ -778,35 +814,25 @@ public class OperationListActivity extends OperationActivity {
switch (e.getCode()) {
case P_E_ACMS_P003:
// リソースパターンを適用
showSimpleAlertDialog(R.string.app_name, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P003,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.P003, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
break;
case P_E_ACMS_P004:
showSimpleAlertDialog(R.string.app_name, PatternStringUtil.patternToInt(getApplicationContext(),
R.string.P004,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)));
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.P004, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
break;
case P_E_ACMS_P005:
showSimpleAlertDialog(R.string.app_name, R.string.P005);
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.P005, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
break;
case P_E_ACMS_P006:
showSimpleAlertDialog(R.string.app_name, R.string.P006);
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.P006, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
break;
default:
Logger.e(TAG, "syncOperation", e);
handleErrorMessageToast(ErrorMessage.getErrorCode(e));
errorMsg.append(ErrorMessage.getErrorMessage(this, ErrorMessage.getErrorCode(e)));
break;
}
} catch (Exception e) {
Logger.e(TAG, e);
handler.post(new Runnable() {
@Override
public void run() {
handleErrorMessageToast(ABVExceptionCode.S_E_ACMS_0001);
closeProgressPopup();
}
});
errorMsg.append(ErrorMessage.getErrorMessage(this, ABVExceptionCode.C_E_SYSTEM_0001));
} finally {
handler.post(new Runnable() {
@Override
......@@ -824,6 +850,7 @@ public class OperationListActivity extends OperationActivity {
});
Logger.i(TAG, "---sync end");
}
return errorMsg.length() > 0 ? errorMsg.toString() : null;
}
public void onClickShowHelpView(View v) {
......@@ -858,8 +885,10 @@ public class OperationListActivity extends OperationActivity {
/**
* 作業データ受信
* @param operationId
* @param progressCallback
* @param operationId 作業ID
* @param progressCallback プログレスコールバック
* @param buttonEventFlag ボタンタッチフラグ
* @param errorMsg エラーメッセージ
* @return
* @throws NetworkDisconnectedException
* @throws ABVException
......@@ -868,7 +897,7 @@ public class OperationListActivity extends OperationActivity {
* @throws NoSuchAlgorithmException
* @throws ZipException
*/
public Date receptionTaskData(long operationId, Callback progressCallback, boolean buttonEventFlag) throws NetworkDisconnectedException, ABVException, IOException, InterruptedException, NoSuchAlgorithmException, ZipException {
public Date receptionTaskData(long operationId, Callback progressCallback, boolean buttonEventFlag, StringBuilder errorMsg) throws NetworkDisconnectedException, ABVException, IOException, InterruptedException, NoSuchAlgorithmException, ZipException {
GetOperationDataParameters param = new GetOperationDataParameters(ABVDataCache.getInstance().getMemberInfo().sid, operationId);
OperationDto operationDto = mOperationLogic.getOperation(operationId);
OperationContentDto operationContentDto = mOperationContentDao.getOperationMainContent(operationId);
......@@ -938,24 +967,32 @@ public class OperationListActivity extends OperationActivity {
if (operationDto.reportType == ReportType.RoutineTask) {
serverTaskReportDto.taskKey = serverTaskDto.taskKey;
try {
// 添付ファイルが存在する場合、取得して解凍する。
refreshRoutineTaskFile(operationId, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, serverTaskReportDto.taskReportId, serverTaskReportDto.taskReportInfoId, serverTaskReportDto.reportStartDate, attachedFileName);
if (isSyncGetTaskFileError) {
} catch (Exception e) {
Logger.e(TAG, e);
// リソースパターンの適用
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.msg_error_task_report_receiving_failed, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
return null;
}
if (localTaskReportDto != null) {
// 報告データが存在すると作業報告を更新する
mOperationLogic.updateRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false, localTaskReportDto.localSavedFlg);
} else {
mOperationLogic.insertRoutineTaskReport(serverTaskDto.operationId, operationContentDto.contentId, serverTaskReportDto, false, false);
}
} else {
JSONObject taskReportJson = null;
// 添付ファイルが存在する場合、取得して解凍する。
try {
refreshTaskFile(operationId, serverTaskReportDto.taskReportLevel, operationContentDto.contentId, serverTaskDto.taskId, serverTaskDto.taskKey, serverTaskReportDto.attachedFileName);
} catch (Exception e) {
Logger.e(TAG, e);
// リソースパターンの適用
errorMsg.append(getString(PatternStringUtil.patternToInt(getApplicationContext(), R.string.msg_error_task_report_receiving_failed, getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0))));
return null;
}
if (!serverTaskReportDto.jsonData.isEmpty()) {
......@@ -1012,21 +1049,12 @@ public class OperationListActivity extends OperationActivity {
String reportLocalAttachedFileName = mTaskReportDao.getTaskReportAttachedFileName(taskKey, taskReportLevel);
if (attachedFileName != null && !attachedFileName.equals(reportLocalAttachedFileName)) {
try {
Logger.i(TAG, "[Get Task Report Files] operationId=%s, taskKey=%s, taskId=%s, attachedFileName=%s", operationId, taskKey, taskId, attachedFileName);
// #32926 start
FileUtil.delete(ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel));
// #32926 end
String outputFilePath = mOperationLogic.getTaskFile(operationId, taskKey, taskId, attachedFileName, taskReportLevel);
ContentFileExtractor.getInstance().extractZipFile(contentId, outputFilePath, ABVEnvironment.getInstance().getOperationTaskReportLevelDirPath(operationId, taskKey, taskReportLevel),null, true);
} catch (Exception e) {
Logger.e(TAG, e);
// リソースパターンの適用
ABVToastUtil.showMakeText(getApplicationContext(), PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_error_task_report_receiving_failed,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_LONG);
throw e;
}
}
}
......@@ -1055,7 +1083,6 @@ public class OperationListActivity extends OperationActivity {
boolean getReportFileFlg = !StringUtil.isNullOrEmpty(reportAttachedFileName) && !reportAttachedFileName.equals(reportLocalAttachedFileName);
if (getReportFileFlg) {
try {
Logger.i(TAG, "[Get Task Report Files] operationId=%s, taskKey=%s, taskId=%s, attachedFileName=%s", operationId, taskKey, taskId, reportAttachedFileName);
// #32926 start
int taskReportLevel = 0;
......@@ -1066,14 +1093,6 @@ public class OperationListActivity extends OperationActivity {
ContentFileExtractor.getInstance().extractZipFile(contentId, outputFilePath,
ABVEnvironment.getInstance().getRoutineTaskReportDirFilePath(operationId, taskKey, taskReportId, reportStartDateNone), null, true);
// #32926 end
} catch (Exception e) {
Logger.e(TAG, e);
// リソースパターンの適用
ABVToastUtil.showMakeText(getApplicationContext(), PatternStringUtil.patternToInt(getApplicationContext(),
R.string.msg_error_task_report_receiving_failed,
getUserPref(AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0)), Toast.LENGTH_LONG);
isSyncGetTaskFileError = true;
}
}
}
......@@ -1655,7 +1674,7 @@ public class OperationListActivity extends OperationActivity {
if (contentDto == null || !contentDto.downloadedFlg || contentDto.updatedFlg) {
contentDownload(operationDto.contentId, false);
} else {
syncOperation(operationDto.operationId, operationDto.reportType, true);
singleSyncOperation(operationDto.operationId, operationDto.reportType, true);
}
}
});
......@@ -2087,4 +2106,115 @@ public class OperationListActivity extends OperationActivity {
popup.showAsDropDown(anchor);
}
}
/**
* カテゴリの一括同期ダイアログ表示
*/
private void showBatchSyncDialog() {
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(this);
dialog.setTitle(getString(R.string.batch_sync));
dialog.setMessage(getString(R.string.msg_confirm_batch_sync));
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
// 一括同期開始
categoryBatchSync();
}
});
dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
if (mAlertDialog != null && this.mAlertDialog.isShowing()) {
mAlertDialog.dismiss();
}
this.mAlertDialog = dialog;
mAlertDialog.show();
}
/**
* カテゴリの一括同期ボタン
*/
public void categoryBatchSync() {
Logger.i(TAG, "---batch sync start");
// ネットワーク通信チェック
if (!ABVEnvironment.getInstance().networkAdapter.isNetworkConnected()) {
showSimpleAlertDialog(getString(R.string.app_name), getString(R.string.request_network_connection));
return;
}
// 作業種別に関連する作業リストを取得
List<OperationDto> operationList = mOperationDao.getNeedSyncOperationByGroupMasterId(getABVUIDataCache().getOperationGroupMasterId());
// 作業リストをスタックにセット
Stack<OperationDto> operationDtoStack = new Stack<OperationDto>();
operationDtoStack.addAll(operationList);
// 一括同期を設定
batchSyncView = new ABVBatchSyncView(this);
// batchSyncViewにスタックをセットして表示
batchSyncView.setStack(operationDtoStack);
batchSyncView.show();
// 一括同期処理
CommonExecutor.execute(new Runnable() {
@Override
public void run() {
batchSyncView.batchOperationSyncForCheckDonwload();
}
});
}
/**
* 一括同期の活性化・非活性化チェック
*/
public void checkBatchNeedSyncButton(Integer operationGroupMasterId) {
if (mOperationDao.hasNeedSyncOperationByGroupMasterId(operationGroupMasterId)) {
// 選択したカテゴリ一覧でneedSyncFlgがtrueの作業が存在すれば、活性化する
mOperationBatchSyncButton.setEnabled(true);
} else {
// 一括同期ボタンを非活性化する
mOperationBatchSyncButton.setEnabled(false);
}
}
// 作業の自動同期処理(onresumeで呼ばれる同期処理)
public void singleSyncOperation(final long operationId, int operationReportType) {
singleSyncOperation(operationId, operationReportType, false);
}
/**
* 作業同期処理(単一)
* @param operationId
* @param operationReportType
*/
public void singleSyncOperation(final long operationId, int operationReportType, boolean buttonEventFlg) {
String errorMessage = syncOperation(operationId, operationReportType, buttonEventFlg);
if (errorMessage != null) {
closeProgressPopup();
// エラーメッセージ表示
showSimpleAlertDialog(getString(R.string.app_name), errorMessage);
}
}
/**
* 作業用コンテンツダウンロード時、ダウンロードかダウンロード再開か判定して行う。
* @param contentDto
* @return
*/
public boolean operationContentDownload(final ContentDto contentDto) {
if (contentDto.isDownloadPaused()) {
// ダウンロード途中で通信が切れた場合、一時停止のステータスに変更になるため、再開させる
try {
contentDownloader.resume(contentDto.contentId);
} catch (Exception e) {
Logger.e(TAG, "downloadContent failed. contentId=" + contentDto.contentId, e);
return false;
}
} else {
// ダウンロード
return contentDownload(contentDto.contentId, false, false);
}
return true;
}
}
......@@ -75,6 +75,7 @@ public class OperationGroupMasterListHelper extends CategoryOperationListHelper<
}
OperationGroupMasterDto peekOperationGroupMasterDto = stack.peek();
mAppActivity.checkBatchNeedSyncButton(peekOperationGroupMasterDto.operationGroupMasterId);
// ソート方向
int operationSortType = mAppActivity.getSortCondition();
OperationSortingType operationSortingType = OperationSortingType.parse(operationSortType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment