using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using TABS.MailCarrier.StgBase;
using TABS.MailCarrier.WebSDK;
using TABS.MailCarrier.WebSDK.Approval;

/// <summary>
/// 결재 부분에서 사용되는 유틸리티 메서드 제공
/// </summary>
public class ApprovalUtil
{
	public ApprovalUtil()
	{
	}

    public static ApprovalDocuments.EnumDocumentType GetDocumentType(string type)
    {
        ApprovalDocuments.EnumDocumentType documentType = ApprovalDocuments.EnumDocumentType.NONE;
        switch (type)
        {
            case "916501ec-b226-4436-a49d-590b34a1f4a8":
                documentType = ApprovalDocuments.EnumDocumentType.DRAFT;
                break;
            case "070510e7-33e8-4de4-b326-bc787cad7914":
                documentType = ApprovalDocuments.EnumDocumentType.DRAFT_APPROVED;
                break;
            case "17257b51-7f35-4955-9015-ab314ab75d84":
                documentType = ApprovalDocuments.EnumDocumentType.DRAFT_REJECTED;
                break;
            case "f69b5ded-63f9-4114-a9b8-db957a05c39d":
                documentType = ApprovalDocuments.EnumDocumentType.DRAFT_CANCELED;
                break;
            case "bf7750b6-f7ee-4adf-ae26-eb6bec9cc073":
                documentType = ApprovalDocuments.EnumDocumentType.DRAFT_SUSPENDED;
                break;
            case "3d2074a6-c591-40bd-b8d5-f92072936dac":
                documentType = ApprovalDocuments.EnumDocumentType.APPROVAL;
                break;
            case "d1bb9d4e-a1f1-4440-99be-302720d390d9":
                documentType = ApprovalDocuments.EnumDocumentType.APPROVAL_ING;
                break;
            case "b7c32ed6-8dc5-475b-b577-06322adfa4f7":
                documentType = ApprovalDocuments.EnumDocumentType.APPROVAL_APPROVED;
                break;
            case "76a4976d-4f58-4c88-8895-0f5c6a909fdc":
                documentType = ApprovalDocuments.EnumDocumentType.APPROVAL_REJECTED;
                break;
            case "deba262f-79c4-4d12-8b7b-721c5e193a2d":
                documentType = ApprovalDocuments.EnumDocumentType.REFEREE;
                break;
            case "f37ce85a-b2a2-42a0-b6ca-5cc4ed1e18d4":
                documentType = ApprovalDocuments.EnumDocumentType.REFEREE_APPROVED;
                break;
            case "6d93074a-87c1-4bbd-84e6-9ba374a0bcfe":
                documentType = ApprovalDocuments.EnumDocumentType.REFEREE_REJECTED;
                break;
            case "32b1de86-874e-44ca-bfcc-eea35b7b3a03":
                documentType = ApprovalDocuments.EnumDocumentType.REFEREE_CANCELED;
                break;
            case "f496dec4-9fd4-4144-83a9-0c07521c0dba":
                documentType = ApprovalDocuments.EnumDocumentType.CIRCULATION;
                break;
            case "872b792b-0f12-4bb1-8be8-22bc302d6b80":
                documentType = ApprovalDocuments.EnumDocumentType.CIRCULATION_APPROVED;
                break;
            case "ecbb8dcb-dddd-4111-9b61-cabff15c7453":
                documentType = ApprovalDocuments.EnumDocumentType.CIRCULATION_REJECTED;
                break;
            case "97f176e5-efca-4e6f-b799-eee0172578d8":
                documentType = ApprovalDocuments.EnumDocumentType.TEMP;
                break;
        }
        return documentType;
    }

    public static string GetFolderName(ApprovalDocuments.EnumDocumentType docType, Guid id)
    {
        string folderName = "None";
        if (id != Guid.Empty)
        {
            SqlConnection conn = new SqlConnection(GlobalConfig.ConnString);
            DataSet ds = Mcsp.ApvUserFolderSelectById(conn, id);
            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                folderName = (string)row["auf_name"];
            }
        }
        else
        {
            switch (docType)
            {
                case ApprovalDocuments.EnumDocumentType.DRAFT:
                    folderName = Resources.Approval.AppBox_Draft_1;     // 기안한 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.DRAFT_APPROVED:
                    folderName = Resources.Approval.AppBox_Draft_2;     // 승인된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.DRAFT_REJECTED:
                    folderName = Resources.Approval.AppBox_Draft_3;     // 반려된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.DRAFT_CANCELED:
                    folderName = Resources.Approval.AppBox_Draft_4;     // 취소된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.DRAFT_SUSPENDED:
                    folderName = Resources.Approval.AppBox_Draft_5;     // 취소된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.APPROVAL:
                    folderName = Resources.Approval.AppBox_Decision_1;      // 결재할 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.APPROVAL_ING:
                    folderName = Resources.Approval.AppBox_Decision_2;      // 결재중 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.APPROVAL_APPROVED:
                    folderName = Resources.Approval.AppBox_Decision_3;      // 승인한 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.APPROVAL_REJECTED:
                    folderName = Resources.Approval.AppBox_Decision_4;      // 반려한 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.REFEREE:
                    folderName = Resources.Approval.AppBox_Forwarding_1;     // 참조 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.REFEREE_APPROVED:
                    folderName = Resources.Approval.AppBox_Forwarding_2;     // 승인된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.REFEREE_REJECTED:
                    folderName = Resources.Approval.AppBox_Forwarding_3;     // 반려된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.REFEREE_CANCELED:
                    folderName = Resources.Approval.AppBox_Forwarding_4;     // 취소된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.CIRCULATION:
                    folderName = Resources.Approval.AppBox_Routing_1;       // 회람 수신함
                    break;
                case ApprovalDocuments.EnumDocumentType.CIRCULATION_APPROVED:
                    folderName = Resources.Approval.AppBox_Routing_2;       // 승인된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.CIRCULATION_REJECTED:
                    folderName = Resources.Approval.AppBox_Routing_3;       // 반려된 문서함
                    break;
                case ApprovalDocuments.EnumDocumentType.TEMP:
                    folderName = Resources.Approval.AppBox_Temp;        // 임시 보관함;
                    break;
            }
        }
        return folderName;
    }

    public static string GetImageFile(ApprovalDocuments.EnumDocumentType documentType)
    {
        string image = "folder_16.gif";
        switch (documentType)
        {
            case ApprovalDocuments.EnumDocumentType.DRAFT: image = "approval01.png"; break;
            case ApprovalDocuments.EnumDocumentType.DRAFT_APPROVED: image = "approval02.png"; break;
            case ApprovalDocuments.EnumDocumentType.DRAFT_REJECTED: image = "approval03.png"; break;
            case ApprovalDocuments.EnumDocumentType.DRAFT_CANCELED: image = "approval10.png"; break;
            case ApprovalDocuments.EnumDocumentType.APPROVAL: image = "approval04.png"; break;
            case ApprovalDocuments.EnumDocumentType.APPROVAL_ING: image = "approval12.png"; break;
            case ApprovalDocuments.EnumDocumentType.APPROVAL_APPROVED: image = "approval05.png"; break;
            case ApprovalDocuments.EnumDocumentType.APPROVAL_REJECTED: image = "approval06.png"; break;

            case ApprovalDocuments.EnumDocumentType.REFEREE: image = "approval09.png"; break;
            case ApprovalDocuments.EnumDocumentType.REFEREE_APPROVED: image = "approval05.png"; break;
            case ApprovalDocuments.EnumDocumentType.REFEREE_REJECTED: image = "approval06.png"; break;

            case ApprovalDocuments.EnumDocumentType.CIRCULATION: image = "approval11.png"; break;
            case ApprovalDocuments.EnumDocumentType.CIRCULATION_APPROVED: image = "approval05.png"; break;
            case ApprovalDocuments.EnumDocumentType.CIRCULATION_REJECTED: image = "approval06.png"; break;

            case ApprovalDocuments.EnumDocumentType.TEMP: image = "approval07.png"; break;
        }

        return image;
    }
}