예제 #1
0
    private void UploadFileProc()
    {
        try
        {
            string strFilePath = GetFilePath(uploadDocFile.PostedFile.FileName, Convert.ToByte(txtHFileType.Value));

            if (System.IO.File.Exists(strFilePath))
            {
                System.IO.File.Delete(strFilePath);
            }
            strDocumentName = uploadDocFile.PostedFile.FileName;

            uploadDocFile.PostedFile.SaveAs(strFilePath);
            if (IsMovieFile(System.IO.Path.GetExtension(uploadDocFile.PostedFile.FileName)))     // the type of document is VIDEO
            {
                Convert2FLVfile(strFilePath);
            }
            else
            {
                GetFileSize(strFilePath);
                GetFileBinaryData(strFilePath);
                strDocumentName  = System.IO.Path.GetFileNameWithoutExtension(uploadDocFile.PostedFile.FileName);
                strDocumentName += System.IO.Path.GetExtension(uploadDocFile.PostedFile.FileName);
            }
            SaveVisitDocumentData(strDocumentName, Convert.ToByte(txtHFileType.Value), txtDocLabel.Text.Trim(), txtDescription.Text.Trim());

            gClass.AddDocumentEventLog(intOrganizationCode.ToString(), Convert.ToInt32(txtHDocumentID.Value), 1, intUserPracticeCode, Request.Url.Host, "Upload file");
            listEventName.SelectedIndex = 0;     // Set the eventname to baseline after saving
            txtHUploadResult.Value      = "1";
        }
        catch (Exception err)
        {
            txtTest.Value += err.ToString();
            gClass.AddErrorLogData(Request.Cookies["UserPracticeCode"].Value, Request.Url.Host, Request.Cookies["Logon_UserName"].Value, "Upload Document Form", "Upload document", err.ToString());
            txtHUploadResult.Value = "2";
        }
        Response.Clear();
        return;
    }
 private void AddDocumentEventLog(int intDocumentID, byte intEventCode)
 {
     gClass.AddDocumentEventLog(gClass.OrganizationCode, intDocumentID, intEventCode, Convert.ToInt32(Request.Cookies["UserPracticeCode"].Value), Request.Url.Host, "");
 }
예제 #3
0
    protected void ExportFromSqlServerToMDB(object sender, EventArgs e)
    {
        System.Data.OleDb.OleDbConnection cnnDest = new System.Data.OleDb.OleDbConnection();
        System.Data.OleDb.OleDbCommand    cmdDest;

        Char[]   delimiter = { '\\' };
        String[] SrcFileArr;

        String strSql          = "";
        String SrcFileID       = "";
        String SrcFileName     = "";
        String SrcDocumentName = "";
        String SrcUploadDate   = "";
        String SrcPatientID    = "";
        String SrcEventID      = "0"; //0 for baseline, consultid for visit
        String SrcEventLink    = "B"; //V, B or O
        String SrcFullFilePath = "";
        String SrcFolderPath   = "";

        String DestFileName = "";

        strLapdataPath = "";

        strLapdataPath = txtFolder.Text;

        String strDocID = "";

        //notes
        int    fileNum        = 0;
        int    fileSuccessNum = 0;
        int    fileFailNum    = 0;
        String fileFail       = "";
        String baselineNotes  = "";

        txtErrNotes.InnerHtml = "";

        //need to escape "
        String strMDBPath = strLapdataPath + "\\Lapdata.mdb";

        //String strMDBPath = "C:\\Lapdata\\Lapdata.mdb;";

        try
        {
            if (strLapdataPath == "")
            {
                txtErrNotes.InnerHtml = "Warning: Please enter the Lapdata folder path";
            }

            cnnDest.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + strMDBPath;
            cnnDest.Open();
            cmdDest             = cnnDest.CreateCommand();
            cmdDest.CommandType = CommandType.Text;

            strSql = "Select * from tblDocuments where LinkName is not null and LinkName <> ''";

            cmdDest.CommandText = strSql;
            OleDbDataReader drSource = cmdDest.ExecuteReader(CommandBehavior.Default);

            while (drSource.Read())
            {
                FileSize        = 0;
                strDocumentName = "";
                SrcFileType     = 0;

                //for every data on tblDocuments in mdb file, upload file
                SrcFileID       = drSource["LinikId"].ToString();
                SrcFullFilePath = drSource["LinkName"].ToString();
                SrcDocumentName = drSource["Description"].ToString();
                SrcUploadDate   = drSource["Date"].ToString();
                SrcPatientID    = drSource["PatientId"].ToString();
                SrcEventID      = "0";
                SrcEventLink    = "B";

                //remove # at the end of filename
                if (SrcFullFilePath.Substring((SrcFullFilePath.Length) - 1) == "#")
                {
                    SrcFullFilePath = SrcFullFilePath.Replace("#", "");
                }

                //split file path
                SrcFileArr = SrcFullFilePath.Split(delimiter);

                //get filename and folder path
                SrcFileName   = SrcFileArr[(SrcFileArr.Length) - 1];
                SrcFolderPath = SrcFileArr[(SrcFileArr.Length) - 2];

                //call function to copy file
                DestFileName = copyFile(SrcFileName, SrcFolderPath);

                //save to db
                strDocID = SaveVisitDocumentData(SrcPatientID, SrcEventID, SrcUploadDate, SrcEventLink, SrcUploadDate, SrcFileType, DestFileName, SrcDocumentName);

                if (strDocID != "")
                {
                    gClass.AddDocumentEventLog(gClass.OrganizationCode, Convert.ToInt32(strDocID), 1, Convert.ToInt64(Request.Cookies["UserPracticeCode"].Value), Request.Url.Host, "Upload file");
                }

                //to be diplayed on notes
                fileNum++;

                if (strDocID != "")
                {
                    fileSuccessNum++;
                }
                else
                {
                    fileFailNum++;
                    fileFail += SrcFileID + " - ";
                }
            }
            baselineNotes  = "Finish Uploading baseline file\n";
            baselineNotes += "-------------------------------------\n";
            baselineNotes += "Total file: " + fileNum + "\n";
            baselineNotes += "Success: " + fileSuccessNum + "\n";
            baselineNotes += "Failed: " + fileFailNum + "\n";
            baselineNotes += "Failed File (Link ID): " + fileFail + "\n\n\n";

            //update notes
            txtNotes.Value = txtNotes.Value + baselineNotes;
        }
        catch (Exception err)
        {
            ExportFlag = false;
            gClass.AddErrorLogData(Request.Cookies["UserPracticeCode"].Value, Request.Url.Host,
                                   Request.Cookies["Logon_UserName"].Value, "Import/Export data Form", "ExportFromSqlServerToMDB function",
                                   strSql + " ... " + err.ToString());
        }
        finally { cnnDest.Close(); cnnDest.Dispose(); }
        return;
    }