Exemplo n.º 1
0
    protected UploadSettings LogTheUpload(UploadedFileInfo fileInfo, string docTitle, int doctypeID)
    {
        SQL_utils sql = new SQL_utils("backend");
        //Log the upload
        UploadSettings uploadSettings = new UploadSettings(fileInfo.FilePath, fileInfo.OriginalFileName, UploadFiletype.Doc);

        uploadSettings.linked_entitytype = (DbEntityType)Convert.ToInt32(Request.QueryString["entitytypeid"]);
        uploadSettings.linked_entityID   = GetEntityID(sql);
        uploadSettings.doctitle          = fileInfo.OriginalFileName;
        uploadSettings.doctypeID         = doctypeID; // sql.IntScalar_from_SQLstring("select doctypeID from tblDocType_lkup where doctype='Luminex Excel Data'");
        uploadSettings.docstatusID       = sql.IntScalar_from_SQLstring("select docstatusID from tblDocStatus_lkup where docstatus='default'");
        uploadSettings.LogUpload();

        string results = "";

        if (uploadSettings.docversID > 0)
        {
            //Copy to webdocs
            string path        = Server.MapPath(@"~\webdocs\");
            string newpathname = String.Format("{0}{1}", path, uploadSettings.docfilename);

            try
            {
                File.Copy(fileInfo.FilePath, newpathname);
                //int new_datauploadpk = sql.IntScalar_from_SQLstring(String.Format("select datauploadpk from def.DataUpload where docversID={0}", uploadSettings.docversID));

                results = String.Format("docID={0}, docversID={1}", uploadSettings.docID, uploadSettings.docversID);

                //if (new_datauploadpk == max_datauppk)
                //{
                //    results = String.Format("docID={0}, docversID={1}, datauploadpk={2}", uploadSettings.docID, uploadSettings.docversID, new_datauploadpk);
                //} else
                //{
                //    results = String.Format("Error logging data upload ({0} != {1}",
                //}
            }
            catch (Exception ex)
            {
                string err   = ex.Message;
                string unlog = uploadSettings.UnlogUpload();
                results = String.Format("{0} {1}", err, unlog);
            }
        }
        uploadSettings.results = results;
        return(uploadSettings);
    }