Esempio n. 1
0
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        string err  = null;
        string info = null;

        // Check modify permission for all actions except for download ZIP
        if (!actionName.EqualsCSafe("downloadzip", true))
        {
            if (!modifyAllowed)
            {
                RedirectToAccessDenied("CMS.TranslationServices", "Modify");
            }
        }

        TranslationSubmissionInfo submissionInfo = TranslationSubmissionInfoProvider.GetTranslationSubmissionInfo(ValidationHelper.GetInteger(actionArgument, 0));

        if (submissionInfo != null)
        {
            switch (actionName.ToLowerCSafe())
            {
            case "downloadzip":
                TranslationServiceHelper.DownloadXLIFFinZIP(submissionInfo, Page.Response);
                break;

            case "resubmit":
                err  = TranslationServiceHelper.ResubmitSubmission(submissionInfo);
                info = GetString("translationservice.translationresubmitted");
                break;

            case "process":
                err  = TranslationServiceHelper.ProcessSubmission(submissionInfo);
                info = GetString("translationservice.translationsimported");
                break;

            case "cancel":
                err  = TranslationServiceHelper.CancelSubmission(submissionInfo);
                info = GetString("translationservice.submissioncanceled");
                break;

            case "delete":
                TranslationServiceHelper.CancelSubmission(submissionInfo);
                submissionInfo.Delete();
                info = GetString("translationservice.submissiondeleted");
                break;
            }
            if (!string.IsNullOrEmpty(err))
            {
                ShowError(err);
            }
            else if (!string.IsNullOrEmpty(info))
            {
                ShowConfirmation(info);
            }
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int submissionId = QueryHelper.GetInteger("submissionid", 0);
        int itemId       = QueryHelper.GetInteger("itemid", 0);

        if (submissionId > 0)
        {
            TranslationSubmissionInfo info = TranslationSubmissionInfoProvider.GetTranslationSubmissionInfo(submissionId);
            if (info != null)
            {
                TranslationServiceHelper.DownloadXLIFFinZIP(info, HttpContext.Current.Response);
            }
        }
        else if (itemId > 0)
        {
            TranslationSubmissionItemInfo info = TranslationSubmissionItemInfoProvider.GetTranslationSubmissionItemInfo(itemId);
            if (info != null)
            {
                TranslationServiceHelper.DownloadXLIFF(info, Response);
            }
        }
    }
    protected void gridElem_OnAction(string actionName, object actionArgument)
    {
        // There is already a running thread
        if (IsRunningThread())
        {
            return;
        }

        string err  = null;
        string info = null;

        // Check modify permission for all actions except for download ZIP
        if (!string.Equals(actionName, "downloadzip", StringComparison.OrdinalIgnoreCase))
        {
            if (!modifyAllowed)
            {
                RedirectToAccessDenied("CMS.TranslationServices", "Modify");
            }
        }

        // Get submission
        var submissionInfo = TranslationSubmissionInfoProvider.GetTranslationSubmissionInfo(ValidationHelper.GetInteger(actionArgument, 0));

        if (submissionInfo == null)
        {
            return;
        }

        switch (actionName.ToLowerInvariant())
        {
        case "downloadzip":
            TranslationServiceHelper.DownloadXLIFFinZIP(submissionInfo, Page.Response);
            break;

        case RESUBMIT_ACTION:
            ProcessActionAsync(actionName, submissionInfo);
            break;

        case PROCESS_ACTION:
            ProcessActionAsync(actionName, submissionInfo);
            break;

        case "cancel":
            err  = TranslationServiceHelper.CancelSubmission(submissionInfo);
            info = GetString("translationservice.submissioncanceled");
            break;

        case "delete":
            var serviceInfo = TranslationServiceInfoProvider.GetTranslationServiceInfo(submissionInfo.SubmissionServiceID);
            if (serviceInfo.TranslationServiceSupportsCancel)
            {
                err = TranslationServiceHelper.CancelSubmission(submissionInfo);
            }

            if (String.IsNullOrEmpty(err))
            {
                submissionInfo.Delete();
            }
            info = GetString("translationservice.submissiondeleted");
            break;
        }

        if (!string.IsNullOrEmpty(err))
        {
            ShowError(err);
        }
        else if (!string.IsNullOrEmpty(info))
        {
            ShowConfirmation(info);
        }
    }