Ejemplo n.º 1
0
    protected void Step2ImportButton_Click(object sender, EventArgs e)
    {
        // if resource does not exist then "import" operation would not be performed.
        if (!this._isResExist)
        {
            return;
        }
        ICollection <ScholarlyWork> resourcesToBeImported  = null;
        ICollection <Guid>          resourcesToBeCitesOnly = null;

        if (Session.Count > 0)
        {
            // Get resources to be imported in the Zentity
            resourcesToBeImported = (ICollection <ScholarlyWork>)Session[_bibtexImportResource];
            // Get resources for those only citations to be updated
            resourcesToBeCitesOnly = (ICollection <Guid>)Session[_bibtexResourceToBeCitedId];
        }

        if (resourcesToBeImported == null || resourcesToBeCitesOnly == null ||
            (resourcesToBeCitesOnly.Count == 0 && resourcesToBeImported.Count == 0))
        {
            this.DisplayCannotImportMessage(Resources.Resources.BibtexImportNoData);
            return;
        }

        DataSet resourceInfo = null;

        try
        {
            using (ResourceDataAccess resourceDAL = new ResourceDataAccess())
            {
                AuthenticatedToken token = Session[Constants.AuthenticationTokenKey] as AuthenticatedToken;
                resourceInfo = resourceDAL.ImportBibTeX(token, _scholarlyWorkObj.Id, resourcesToBeImported,
                                                        resourcesToBeCitesOnly);
            }
        }
        catch (Exception ex)
        {
            this.DisplayCannotImportMessage(Resources.Resources.BibtexImportError + ex.Message +
                                            _htmlBreakLine + (ex.InnerException != null ? ex.InnerException.Message :
                                                              String.Empty));
            return;
        }
        this.GridView1.DataSource = resourceInfo;
        this.GridView1.DataBind();

        if (resourcesToBeImported.Count == 0)
        {
            this.LabelMessage.Text = Resources.Resources.BibtexImportSuccessful;
            this.Wizard1.Visible   = false;
        }
        else
        {
            this.LabelMessage.Text = Resources.Resources.BibtexImportSuccessful + Resources.Resources.BibtexImportUpdateNew;
        }
        this.LabelMessage.Visible = true;

        //Clean up and move to next step
        Wizard1.ActiveStepIndex = 2;
        Session.Remove(_bibtexImportResource);
        Session.Remove(_bibtexResourceToBeCitedId);
        Session.Remove(_bibtexCitedResource);
        Session.Remove(_bibtexResourceToBeCited);
    }