Example #1
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in DeleteReportDAO!"));
                }

                string orderGuid = "", assignSite = "";

                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "ORDERGUID")
                    {
                        orderGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "ASSIGNSITE")
                    {
                        assignSite = inMap[key] as string;
                    }
                }

                if (orderGuid == null || orderGuid.Length < 1 ||
                    assignSite == null || assignSite.Length < 1)
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DeleteReportDAO!"));
                }
                string sql = string.Format("update tRegOrder set Assign2Siet ={0} where orderGuid={1}",
                                           orderGuid, assignSite);


                ServerPubFun.RISLog_Info(0, "AssingReportDAO_MSSQL, SQL=" + sql,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                using (RisDAL dal = new RisDAL())
                {
                    dal.ExecuteNonQuery(sql);
                }

                return(1);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "AssingReportDAO_MSSQL=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("-1");
        }
Example #2
0
        /// <summary>
        /// OnReportDelete
        /// </summary>
        /// <param name="rptInfo"></param>
        /// <param name="nextStatus"></param>
        public static void OnReportDelete(tagReportInfo rptInfo, ReportCommon.RP_Status nextStatus)
        {
            try
            {
                // Need to send gateway
                if (!ServerPubFun.GetSystemProfile_Bool("SendToGateServer", ReportCommon.ModuleID.Integration))
                {
                    return;
                }

                //
                // Gateway
                using (RisDAL dal = new RisDAL())
                {
                    string guid = Guid.NewGuid().ToString();

                    if (dal.DriverClassName.ToUpper() == "ORACLE")
                    #region Oracle
                    {
                        string sql = " insert into GW_DataIndex(data_id, data_dt, event_type, RECORD_INDEX_1, Data_Source)"
                                     + " values('" + guid + "', SYSDATE, '" + (nextStatus == ReportCommon.RP_Status.Repeatshot ? "32" : "33") + "', 'ReportGuid', 'Local'); "
                                     + " insert into GW_Patient(DATA_ID,DATA_DT,PATIENTID,PATIENT_NAME,PATIENT_LOCAL_NAME,BIRTHDATE,SEX)"
                                     + "    values('" + guid + "', SYSDATE, '" + rptInfo.patientID + "','" + rptInfo.patientName + "',N'" + rptInfo.patientLocalName + "','" + rptInfo.birthday.ToString("yyyy-MM-dd") + "','" + rptInfo.gender + "'); "
                                     + " insert into GW_Order(DATA_ID,DATA_DT,ORDER_NO,FILLER_NO,PATIENT_ID,EXAM_STATUS) "
                                     + "    values('" + guid + "', SYSDATE, '" + rptInfo.orderGuid + "', '" + rptInfo.AccNO + "', '" + rptInfo.patientID
                                     + "', '" + (nextStatus == ReportCommon.RP_Status.Repeatshot ? "17" : "16") + "'); "
                                     + " insert into GW_Report(data_id, data_dt, report_no, ACCESSION_NUMBER, PATIENT_ID, REPORT_STATUS, MODALITY, "
                                     + " REPORT_TYPE, REPORT_FILE, REPORT_WRITER, REPORT_APPROVER, REPORTDT, OBSERVATIONMETHOD)"
                                     + " values('" + guid + "', SYSDATE, '"
                                     + ((rptInfo.reportGuid == null || rptInfo.reportGuid == "") ? " " : rptInfo.reportGuid) + "', '"
                                     + rptInfo.AccNO + "'," + " '" + rptInfo.patientID + "', '204', '"
                                     + rptInfo.modality + "', '0', '', '" + rptInfo.reportCreater_LocalName + "',"
                                     + " '" + rptInfo.reportApprover_LocalName + "', '" + rptInfo.reportApproveDt.ToString("yyyy-MM-dd HH:mm:ss") + "',"
                                     + " '" + ReportCommon.ReportCommon.StringLeft(rptInfo.operationStep, ServerPubFun.GetColumnWidth("GW_Report", "OBSERVATIONMETHOD") / 2) + "'); ";

                        sql = "begin " + sql + " commit; end;";

                        dal.ExecuteNonQuery(sql);

                        if (rptInfo.wysText != null && rptInfo.wysText.Length > 0)
                        {
                            dal.WriteLargeObj("GW_Report", "data_id", guid, "DIAGNOSE", rptInfo.wysText, rptInfo.wysText.Length, RisDAL.ConnectionState.KeepOpen);
                        }

                        if (rptInfo.wygText != null && rptInfo.wygText.Length > 0)
                        {
                            dal.WriteLargeObj("GW_Report", "data_id", guid, "COMMENTS", rptInfo.wygText, rptInfo.wygText.Length, RisDAL.ConnectionState.KeepOpen);
                        }
                    }
                    #endregion
                    else if (dal.DriverClassName.ToUpper() == "MSSQL")
                    #region MSSQL
                    {
                        string sql = SaveReportDAO_MSSQL.MakeSQL4GateWay(rptInfo, guid, nextStatus == ReportCommon.RP_Status.Repeatshot ? 32 : 33, 16, 204);

                        using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(dal.ConnectionString))
                        {
                            conn.Open();

                            System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                            cmd.Connection = conn;

                            try
                            {
                                //
                                // begin transaction
                                //cmd.Transaction = conn.BeginTransaction();

                                ServerPubFun.RISLog_Info(0, "OnReportDelete=" + sql,
                                                         (new System.Diagnostics.StackFrame(true)).GetFileName(),
                                                         (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());

                                cmd.CommandText = sql;
                                cmd.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {
                                //cmd.Transaction.Rollback();

                                System.Diagnostics.Debug.Assert(false, ex.Message);

                                RISLog_Error(0, "OnReportDelete, MSG=" + ex.Message + ", SQL=" + sql,
                                             (new System.Diagnostics.StackFrame(true)).GetFileName(),
                                             (new System.Diagnostics.StackFrame(true)).GetFileLineNumber());
                            }
                        }
                    }
                    #endregion
                    else
                    {
                        System.Diagnostics.Debug.Assert(false, "Invalid DB setting!");
                    }

                    // Hippa
                    Server.Utilities.HippaLogTool.HippaLogTool.AuditPatientCareAssignMsg(
                        CommonGlobalSettings.HippaName.ActionCode.Delete,

                        rptInfo.AccNO, rptInfo.reportGuid, rptInfo.reportName, rptInfo.patientID, rptInfo.patientName, "", true);
                }
            }
            catch
            {
                Server.Utilities.HippaLogTool.HippaLogTool.AuditPatientCareAssignMsg(
                    CommonGlobalSettings.HippaName.ActionCode.Delete,
                    rptInfo.AccNO, rptInfo.reportGuid, rptInfo.reportName, rptInfo.patientID, rptInfo.patientName, "", false);
            }
        }
Example #3
0
        /// <summary>
        /// Get Report Info by rp guid
        /// </summary>
        /// <param name="rpGuid"></param>
        /// <returns></returns>
        public static tagReportInfo GetReportInfo2(string rpGuid)
        {
            int    idx = rpGuid.IndexOf(',');
            string rp  = rpGuid;

            if (idx > 0 && idx < rpGuid.Length)
            {
                rp = rpGuid.Substring(0, idx);
            }
            rp = rp.Trim("' ".ToCharArray());


            string sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                         " select "
                         + "  tRegPatient.patientID, tRegPatient.localName, tRegPatient.EnglishName, tRegPatient.address, tRegPatient.telephone,"
                         + "  tRegPatient.isVip, tRegPatient.Comments tRegPatient__Comments, tRegPatient.remotePID tRegPatient__remotePID,"
                         + "  tRegPatient.Gender as tRegPatient__Gender, tRegPatient.Birthday as tRegPatient__Birthday,"
                         + "  tRegOrder.inhospitalNo, tRegOrder.clinicNo, tRegOrder.PatientType, tRegOrder.Observation, "
                         + "  tRegOrder.inHospitalRegion, tRegOrder.BedNo, tRegOrder.comments tRegOrder__orderComment,"
                         + "  tRegOrder.OrderGuid as tRegOrder__OrderGuid, tRegOrder.AccNo, tRegOrder.applyDept as tRegOrder__applyDept,"
                         + "  tRegOrder.applyDoctor as tRegOrder__applyDoctor, tRegOrder.VisitComment tRegOrder__VisitComment,"
                         + "  tRegOrder.remoteAccNo,"
                         + "  tRegProcedure.ProcedureGuid as tRegProcedure__ProcedureGuid, tRegProcedure.status as tRegProcedure__status, "
                         + "  tRegProcedure.charge, tRegProcedure.ModalityType, tRegProcedure.Modality, "
                         + "  tRegProcedure.Registrar, tRegProcedure.RegisterDt, tRegProcedure.Technician, "
                         + "  tRegProcedure.OperationStep, tRegProcedure.ExamineDt, tRegProcedure.comments tRegProcedure__comments, "
                         + "  tRegProcedure.isCharge, tRegProcedure.ProcedureCode tRegProcedure__ProcedureCode, "
                         + "  tRegProcedure.RPDesc tProcedureCode__Description, tRegProcedure.bodypart tProcedureCode__bodypart, "
                         + "  tReport.reportGuid, "
                         + "  tReport.ReportName, tReport.techInfo, tReport.wysText, tReport.wygText, "
                         + "  tReport.WYS, tReport.WYG, "
                         + "  tReport.creater as tReport__creater, tReport.createDt as tReport__createDt,"
                         + "  tReport.submitter as tReport__submitter, tReport.submitDt as tReport__submitDt,"
                         + "  tReport.firstApprover as tReport__firstApprover, tReport.firstApproveDt as tReport__firstApproveDt,"
                         + "  tReport.rejectDt as tReport__rejectDt"
                         + "  from tRegPatient with (nolock), "
                         + "  tRegOrder with (nolock), tRegProcedure with (nolock) "
                         + "  left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid "
                         + "  where tRegPatient.PatientGuid = tRegOrder.PatientGuid "
                         + "  and tRegOrder.OrderGuid = tRegProcedure.OrderGuid "
                         + " and tRegProcedure.procedureGuid = '" + rp + "'";

            DataTable dt = new DataTable("ReportInfo");



            tagReportInfo ri = new tagReportInfo();

            if (0 == iWrittenCount++ % 100)
            {
                ServerPubFun.RISLog_Info(0, "GetReportInfo2, SQL=" + sql,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }
            else
            {
                ServerPubFun.RISLog_Info(0, "GetReportInfo2, rpGuid=" + rpGuid,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }
            using (RisDAL dal = new RisDAL())
            {
                dal.ExecuteQuery(sql, dt);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];

                    ri.status           = ReportCommon.Converter.toInt(dr["tRegProcedure__status"]);
                    ri.dept             = dr["tRegOrder__applyDept"] as string;
                    ri.orderGuid        = dr["tRegOrder__OrderGuid"] as string;
                    ri.reportGuid       = dr["reportGuid"] as string;
                    ri.reportName       = dr["reportName"] as string;
                    ri.AccNO            = dr["AccNO"] as string;
                    ri.patientID        = dr["PatientID"] as string;
                    ri.patientName      = dr["EnglishName"] as string;
                    ri.patientLocalName = dr["LocalName"] as string;
                    // ri.patientAlias = dr["Alias"] as string;
                    ri.patientAddress = dr["Address"] as string;
                    ri.patientPhone   = dr["TelePhone"] as string;
                    // ri.patientMarriage = dr["Marriage"] as string;
                    ri.gender           = dr["tRegPatient__Gender"] as string;
                    ri.patientType      = dr["PatientType"] as string;
                    ri.remotePID        = dr["tRegPatient__remotePID"] as string;
                    ri.modality         = dr["Modality"] as string;
                    ri.modalityType     = dr["modalityType"] as string;
                    ri.operationStep    = dr["operationStep"] as string;
                    ri.reportCreater    = dr["tReport__creater"] as string;
                    ri.reportSubmitter  = dr["tReport__submitter"] as string;
                    ri.reportApprover   = dr["tReport__firstApprover"] as string;
                    ri.reportCreateDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__createDt"]);
                    ri.reportSubmitDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__submitDt"]);
                    ri.reportApproveDt  = ReportCommon.ReportCommon.GetDateTime(dr["tReport__firstApproveDt"]);
                    ri.reportRejectDt   = ReportCommon.ReportCommon.GetDateTime(dr["tReport__rejectDt"]);
                    ri.birthday         = ReportCommon.ReportCommon.GetDateTime(dr["tRegPatient__birthday"]);
                    ri.registerDt       = ReportCommon.ReportCommon.GetDateTime(dr["registerDt"]);
                    ri.examineDt        = ReportCommon.ReportCommon.GetDateTime(dr["examineDt"]);
                    ri.inHospitalRegion = dr["inHospitalRegion"] as string;
                    ri.visitNo          = dr["clinicNo"] as string;
                    ri.bedNo            = dr["bedNo"] as string;
                    ri.isVIP            = ReportCommon.Converter.toInt(dr["isVip"]).ToString();
                    ri.inHospitalNo     = dr["inhospitalNo"] as string;
                    ri.patientComment   = dr["tRegPatient__Comments"] as string;
                    ri.remoteAccNo      = dr["remoteAccNo"] as string;

                    ri.applyDoctor       = dr["tRegOrder__applyDoctor"] as string;
                    ri.visitComments     = dr["tRegOrder__visitComment"] as string;
                    ri.observation       = dr["Observation"] as string;
                    ri.orderComments     = dr["tRegOrder__orderComment"] as string;
                    ri.technician        = dr["technician"] as string;
                    ri.procedureComments = dr["remoteAccNo"] as string;
                    ri.isCharge          = ReportCommon.Converter.toInt(dr["isCharge"]).ToString();

                    string tmp     = "";
                    double dChange = 0;
                    foreach (DataRow tmpDr in dt.Rows)
                    {
                        tmp = tmpDr["tProcedureCode__bodypart"] as string;
                        if (tmp != null)
                        {
                            ri.bodypart += tmp + ", ";
                        }

                        tmp = tmpDr["tRegProcedure__ProcedureCode"] as string;
                        if (tmp != null)
                        {
                            ri.procedureCode += tmp + ", ";
                        }

                        tmp = tmpDr["tProcedureCode__Description"] as string;
                        if (tmp != null)
                        {
                            ri.procedureDesc += tmp + ", ";
                        }

                        double dTmp = System.Convert.ToDouble(tmpDr["charge"]);
                        dChange += dTmp;
                    }
                    ri.bodypart      = ri.bodypart.Trim(", ".ToCharArray());
                    ri.procedureCode = ri.procedureCode.Trim(", ".ToCharArray());
                    ri.procedureDesc = ri.procedureDesc.Trim(", ".ToCharArray());
                    ri.charge        = dChange.ToString();

                    ri.reportCreater_LocalName   = ServerPubFun.GetLocalName(ri.reportCreater);
                    ri.reportSubmitter_LocalName = ServerPubFun.GetLocalName(ri.reportSubmitter);
                    ri.reportApprover_LocalName  = ServerPubFun.GetLocalName(ri.reportApprover);
                    ri.technician__LocalName     = ServerPubFun.GetLocalName(ri.technician);

                    ri.duration = System.Convert.ToString(ri.examineDt - ri.registerDt);

                    Byte[] buff = dr["wys"] as Byte[];
                    if (buff == null)
                    {
                        ri.wys = "";
                    }
                    else
                    {
                        ri.wys = ReportCommon.Converter.GetStringFromBytes(buff);
                    }

                    buff = dr["wyg"] as Byte[];
                    if (buff == null)
                    {
                        ri.wyg = "";
                    }
                    else
                    {
                        ri.wyg = ReportCommon.Converter.GetStringFromBytes(buff);
                    }

                    //buff = dr["wysText"] as Byte[];
                    //if (buff == null)
                    ri.wysText = dr["wysText"] as string;
                    //else
                    //  ri.wysText = ReportCommon.Converter.GetStringFromBytes(buff);

                    // buff = dr["wygText"] as Byte[];
                    //if (buff == null)
                    ri.wygText = dr["wygText"] as string;
                    //else
                    //  ri.wygText = ReportCommon.Converter.GetStringFromBytes(buff);

                    ri.techinfo = System.Convert.ToString(dr["techinfo"]);
                }
            }

            return(ri);
        }
Example #4
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in SaveReportDAO!"));
                }

                string[] reportGuids = null;
                string   curUserGuid = "", comments = "", snapShotSrvPath = "", modalityType = "", modality = "";
                int      logType = 0, cnt = 1, costTime = 0;
                string   strType = "", strMultiCostTime = null;
                string   strPrintTemplateGuid = "";

                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "LOGTYPE")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            logType = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "REPORTGUIDS" || key.ToUpper() == "REPORTGUID")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && (tmp = tmp.Trim(", ".ToCharArray())).Length > 0)
                        {
                            reportGuids = tmp.Split(',');
                        }
                    }
                    else if (key.ToUpper() == "COUNT")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            cnt = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "USERID" || key.ToUpper() == "USERGUID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "COMMENTS")
                    {
                        comments = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "SNAPSHOTSRVPATH")
                    {
                        snapShotSrvPath = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MODALITYTYPE")
                    {
                        modalityType = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MODALITY")
                    {
                        modality = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "COSTTIME")
                    {
                        string tmp = inMap[key] as string;

                        if (tmp != null && tmp.Length > 0)
                        {
                            costTime = System.Convert.ToInt32(tmp);
                        }
                    }
                    else if (key.ToUpper() == "TYPE")
                    {
                        strType = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "MULTICOSTTIME")
                    {
                        strMultiCostTime = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "PRINTTEMPLATEGUID")
                    {
                        strPrintTemplateGuid = inMap[key] as string;
                    }
                }

                string sql = "";

                string strDomain = CommonGlobalSettings.Utilities.GetCurDomain();

                if (strMultiCostTime != null && strMultiCostTime.Trim().Length > 0)
                {
                    string[] arrCostTime = strMultiCostTime.Split('|');

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Exam2Draft + ", '" + modalityType + "', "
                           + arrCostTime[0].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "') \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Draft2Submit + ", '" + modalityType + "', "
                           + arrCostTime[1].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_Submit2Approve + ", '" + modalityType + "', "
                           + arrCostTime[2].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";

                    sql += " insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                           + " values('" + Guid.NewGuid().ToString() + "', " + (int)ReportCommon.ReportLog_Type.EventLog_ApproveStart2End + ", '" + modalityType + "', "
                           + arrCostTime[3].ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')  \r\n";
                }
                else
                {
                    if (logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Exam2Draft) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Draft2Submit) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Submit2Approve) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_ApproveStart2End) ||
                        logType == System.Convert.ToInt32(ReportCommon.ReportLog_Type.EventLog_Exam2Print))
                    {
                        if (reportGuids.Length > 0)
                        {
                            sql = "insert into tEventLog(guid, eventCode, ModalityType, costtime, createdt, operator,Domain)"
                                  + " values('" + Guid.NewGuid().ToString() + "', " + logType.ToString() + ", '" + modalityType + "', "
                                  + costTime.ToString() + ", getdate(), '" + curUserGuid + "','" + strDomain + "')";
                        }
                    }
                    // 2015-06-08, Oscar added (US25173)
                    else if (logType == (int)ReportCommon.ReportLog_Type.EventLog_SubmitCostTime ||
                             logType == (int)ReportCommon.ReportLog_Type.EventLog_ApproveCostTime)
                    {
                        if (reportGuids.Length > 0)
                        {
                            sql += UpsertEventLog(logType, modalityType, costTime, curUserGuid, strDomain, reportGuids[0]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < reportGuids.Length; i++)
                        {
                            string tmp = reportGuids.GetValue(i) as string;
                            if (tmp != null && tmp.Length > 0)
                            {
                                if (cnt < 1)
                                {
                                    sql += " insert into tReportPrintLog(fileGuid, ReportGuid,Printer,PrintDt,Counts,Comments,snapShotSrvPath,Type,Domain) "
                                           + " values(newid(), '" + tmp + "', '" + curUserGuid + "', getdate(), "
                                           + cnt.ToString() + ", '" + comments + "', '" + snapShotSrvPath + "','" + strType + "','" + strDomain + "') \r\n";
                                }
                                else
                                {
                                    sql += " update tReport set isPrint=1,Optional1='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', PrintTemplateGuid ='" + strPrintTemplateGuid + "' where reportGuid='" + tmp + "' \r\n"
                                           + " insert into tReportPrintLog(fileGuid, ReportGuid,Printer,PrintDt,Counts,Comments,snapShotSrvPath,Type,PrintTemplateGuid,Domain)"
                                           + " values(newid(), '" + tmp + "', '" + curUserGuid + "', getdate(), "
                                           + cnt.ToString() + ", '" + comments + "', '" + snapShotSrvPath + "','" + strType + "','" + strPrintTemplateGuid + "','" + strDomain + "') \r\n";
                                }
                            }
                        }
                    }
                }
                if (0 == iWrittenLog++ % 100)
                {
                    ServerPubFun.RISLog_Info(0, "RecordLogDAO, UserGuid=" + curUserGuid + ", SQL=" + sql,
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                }
                else
                {
                    ServerPubFun.RISLog_Info(0, "RecordLogDAO, UserGuid=" + curUserGuid + ", reportGuids=" + reportGuids.ToString(),
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                }

                if (sql.Length > 0)
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        dal.ExecuteNonQuery(sql);

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "RecordLogDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(false);
        }
Example #5
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetReportNameDAO!"));
                }

                string reportGuid = "";
                string rpGuids    = "";
                string accNO      = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = paramMap[key] as string;

                        if (rpGuids == null)
                        {
                            rpGuids = "";
                        }
                    }
                    else if (key.ToUpper() == "ACCNO")
                    {
                        accNO = paramMap[key] as string;

                        if (accNO == null)
                        {
                            accNO = "";
                        }
                    }
                }

                string sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                             "select " + GetAllReportColumn() + " \r\n"
                             + " from tRegPatient with (nolock), tRegOrder with (nolock), tProcedureCode with (nolock), tRegProcedure with (nolock) \r\n"
                             + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                             + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                             + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                             + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n";

                string sqlFile = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                 " select distinct tReportFile.* from tReportFile, tReport "
                                 + " where tReportFile.reportGuid = tReport.reportGuid";


                #region Added by Kevin For SR

                string sqlreportcontent = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                          " select * from tReportContent"
                                          + " where tReportContent.ReportId ='" + reportGuid + "' ";

                #endregion


                if (!string.IsNullOrWhiteSpace(reportGuid))
                {
                    sql += " and tReport.reportGuid = '" + reportGuid + "'";

                    sqlFile += " and tReport.reportGuid = '" + reportGuid + "'";
                }
                else if (!string.IsNullOrWhiteSpace(rpGuids))
                {
                    rpGuids = rpGuids.Trim(", ".ToCharArray());

                    string[] arr = rpGuids.Split(',');
                    if (arr.Length > 1)
                    {
                        if (!rpGuids.Contains("','"))
                        {
                            rpGuids = rpGuids.Replace(",", "','");
                            rpGuids = "'" + rpGuids + "'";
                        }
                        sql += " and tRegProcedure.ProcedureGuid in (" + rpGuids + ")";
                    }
                    else
                    {
                        rpGuids = "'" + rpGuids + "'";
                        sql    += " and tRegProcedure.ProcedureGuid =" + rpGuids;
                    }

                    sqlFile += " and 1=2 ";
                }
                else if (!string.IsNullOrWhiteSpace(accNO))
                {
                    sql += " AND tRegOrder.ACCNO = '" + accNO.Trim() + "'";

                    sqlFile += " AND 1=2 ";
                }

                if (0 == iWrittenCount++ % 100)
                {
                    ServerPubFun.RISLog_Info(0, "GetReportInfoDAO=" + sql + ", reportFile=" + sqlFile, "", 0);
                }
                else
                {
                    ServerPubFun.RISLog_Info(0, "GetReportInfoDAO, rpGuid=" + rpGuids + ", reportGuid=" + reportGuid + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                }

                DataSet ds = new DataSet();

                using (RisDAL dal = new RisDAL())
                {
                    //
                    // report info
                    DataTable dt0 = new DataTable("ReportInfo");

                    dal.ExecuteQuery(sql, dt0);

                    ds.Tables.Add(dt0);

                    //
                    // report file
                    DataTable dt1 = new DataTable("ReportFile");

                    dal.ExecuteQuery(sqlFile, dt1);

                    ds.Tables.Add(dt1);

                    string    sqlPrintTemplate = "select * from tPrintTemplate where Type=3 and TemplateName='QualityControlReportTemplate'";
                    DataTable dt2 = new DataTable("PrintTemplate");
                    dal.ExecuteQuery(sqlPrintTemplate, dt2);
                    ds.Tables.Add(dt2);
                    #region Added by Kevin For SR

                    // reportcontent
                    DataTable dt3 = new DataTable("ReportContent");

                    dal.ExecuteQuery(sqlreportcontent, dt3);

                    ds.Tables.Add(dt3);

                    #endregion
                }


                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportInfoDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Example #6
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in DisqualifyImageDAO!"));
                }

                string rpGuids = "", reportGuid = "", curUserGuid = "", reason = "";
                string strDomain = CommonGlobalSettings.Utilities.GetCurDomain();
                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "USERID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "PROCEDUREGUID")
                    {
                        rpGuids = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "REASON")
                    {
                        reason = inMap[key] as string;
                    }
                }

                if ((reportGuid == null || reportGuid.Length < 1) &&
                    (rpGuids == null || rpGuids.Length < 1))
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (curUserGuid == null || curUserGuid.Length < 1)
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DisqualifyImageDAO!"));
                }

                if (reportGuid == null)
                {
                    reportGuid = "";
                }

                reportGuid = reportGuid.Trim(" ,".ToCharArray());

                if (rpGuids == null)
                {
                    rpGuids = "";
                }

                rpGuids = rpGuids.Trim(" ,".ToCharArray());

                reason = reason == null ? "" : reason.Length >= 512 ? reason.Substring(0, 512) : reason;

                string sql = " begin tran \r\n";

                using (RisDAL dal = new RisDAL())
                {
                    if (reportGuid != null && reportGuid.Length > 0)
                    {
                        string sqlGetRPs = "select procedureGuid from tRegProcedure where ReportGuid='" + reportGuid + "'";

                        DataTable dtTmp = dal.ExecuteQuery(sqlGetRPs);
                        if (dtTmp != null)
                        {
                            foreach (DataRow dr in dtTmp.Rows)
                            {
                                string tmpRP = System.Convert.ToString(dr[0]);
                                if (string.IsNullOrEmpty(tmpRP))
                                {
                                    continue;
                                }

                                sql += " if exists(select 1 from tReShot where procedureGuid ='" + tmpRP + "') \r\n"
                                       + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "',"
                                       + " rejectDt = getdate(),domain='" + strDomain + "' "
                                       + " where procedureGuid = '" + tmpRP + "' \r\n"
                                       + " else "
                                       + " insert tReShot(ProcedureGuid, reason, rejectDoctor, rejectDt, domain) "
                                       + " values ('" + tmpRP + "', '" + reason + "', '" + curUserGuid + "', getdate(), '" + strDomain + "') \r\n"
                                ;
                            }
                        }

                        //sql += " delete from tReShot where procedureGuid in (select procedureGuid from tRegProcedure where ReportGuid='" + reportGuid + "') \r\n"
                        //    + " insert tReShot(ProcedureGuid) select procedureGuid from tRegProcedure "
                        //    + " where reportGuid = '" + reportGuid + "' \r\n"
                        //    + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = getdate(),domain='" + strDomain + "' "
                        //    + " where (rejectDoctor is null or rejectDoctor = '')"
                        //    + " and procedureGuid in (select procedureGuid from tRegProcedure"
                        //    + "  where reportGuid = '" + reportGuid + "') \r\n";

                        sql += ""
                               + " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString() + ",reportguid=null where  "
                               + "  reportGuid = '" + reportGuid + "' \r\n"
                               + " delete from tReportlist where reportGuid = '" + reportGuid + "' \r\n"
                               + " delete from tReport where reportGuid = '" + reportGuid + "' \r\n";
                    }
                    else if (rpGuids != null && rpGuids.Length > 0)
                    {
                        string[] arrRPs = rpGuids.Split(",;".ToCharArray());

                        foreach (string tmpRP in arrRPs)
                        {
                            if (string.IsNullOrEmpty(tmpRP))
                            {
                                continue;
                            }

                            sql += " if exists(select 1 from tReShot where procedureGuid ='" + tmpRP + "') \r\n"
                                   + " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "',"
                                   + " rejectDt = getdate(),domain='" + strDomain + "' "
                                   + " where procedureGuid = '" + tmpRP + "' \r\n"
                                   + " else "
                                   + " insert tReShot(ProcedureGuid, reason, rejectDoctor, rejectDt, domain) "
                                   + " values ('" + tmpRP + "', '" + reason + "', '" + curUserGuid + "', getdate(), '" + strDomain + "') \r\n"
                            ;
                        }

                        if (!rpGuids.Contains("'"))
                        {
                            rpGuids = rpGuids.Replace(",", "','");
                            rpGuids = rpGuids.Replace(";", "','");
                            rpGuids = "'" + rpGuids + "'";
                        }

                        //sql += " delete from tReShot where procedureGuid in (" + rpGuids + ") \r\n"
                        //+ " insert tReShot(ProcedureGuid) select procedureGuid from tRegProcedure"
                        //+ " where procedureGuid in (" + rpGuids + ") \r\n"
                        //+ " update tReShot set reason='" + reason + "', rejectDoctor='" + curUserGuid + "', rejectDt = getdate(),domain='" + strDomain + "' "
                        //+ " where (rejectDoctor is null or rejectDoctor = '') and procedureGuid in (" + rpGuids + ") \r\n";

                        sql += " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Repeatshot).ToString()
                               + " where procedureGuid in (" + rpGuids + ") \r\n";
                    }

                    sql += " commit";

                    ServerPubFun.RISLog_Info(0, "DisqualifyImageDAO_MSSQL, SQL=" + sql,
                                             (new System.Diagnostics.StackFrame()).GetFileName(),
                                             (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                    // Delete
                    tagReportInfo rptInfo = ServerPubFun.GetReportInfo2(rpGuids); //ServerPubFun.GetReportInfo(reportGuid);

                    ServerPubFun.OnReportDelete(rptInfo, ReportCommon.RP_Status.Repeatshot);



                    dal.ExecuteNonQuery(sql);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "DisqualifyImageDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("-1");
        }
Example #7
0
        public object Execute(object param)
        {
            try
            {
                #region get parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    throw (new Exception("No parameter in GetLockDAO!"));
                }

                string action     = "";
                string lockType   = "";
                string lockGuid   = "";
                string owner      = "";
                string ownerIP    = "";
                string rpguids    = "";
                string patientid  = "";
                string localname  = "";
                string accno      = "";
                string reportGuid = "";

                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "LOCKTYPE")
                    {
                        lockType = paramMap[key] as string;

                        if (lockType == null)
                        {
                            lockType = "";
                        }
                    }
                    else if (key.ToUpper() == "LOCKGUID")
                    {
                        lockGuid = paramMap[key] as string;

                        if (lockGuid == null)
                        {
                            lockGuid = "";
                        }
                    }
                    else if (key.ToUpper() == "ACTION")
                    {
                        action = paramMap[key] as string;

                        if (action == null)
                        {
                            action = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNER")
                    {
                        owner = paramMap[key] as string;

                        if (owner == null)
                        {
                            owner = "";
                        }
                    }
                    else if (key.ToUpper() == "OWNERIP")
                    {
                        ownerIP = paramMap[key] as string;

                        if (ownerIP == null)
                        {
                            ownerIP = "";
                        }
                    }
                    else if (key.ToUpper() == "RPGUIDS")
                    {
                        rpguids = paramMap[key] as string;

                        if (rpguids == null)
                        {
                            rpguids = "";
                        }
                    }
                    else if (key.ToUpper() == "PATIENTID")
                    {
                        patientid = paramMap[key] as string;

                        if (patientid == null)
                        {
                            patientid = "";
                        }
                    }
                    else if (key.ToUpper() == "LOCALNAME")
                    {
                        localname = paramMap[key] as string;

                        if (localname == null)
                        {
                            localname = "";
                        }
                    }
                    else if (key.ToUpper() == "ACCNO")
                    {
                        accno = paramMap[key] as string;

                        if (accno == null)
                        {
                            accno = "";
                        }
                    }
                    else if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = paramMap[key] as string;

                        if (reportGuid == null)
                        {
                            reportGuid = "";
                        }
                    }
                }

                #endregion



                DataSet ds = new DataSet();

                //dal.BeginTransaction();

                try
                {
                    using (RisDAL dal = new RisDAL())
                    {
                        DataTable dtLock = null;
                        string    strSQL = "";
                        if (!string.IsNullOrEmpty(lockGuid))
                        {
                            strSQL = string.Format("select Owner,OwnerIP,RPGuids,ModuleID from tSync where guid='{0}'", lockGuid);
                            dtLock = dal.ExecuteQuery(strSQL);
                        }

                        if (action.ToUpper() == "ADD")
                        #region ADD
                        {
                            #region only ReportGuid is arrived so should get some info of patient,order and rp
                            if (!string.IsNullOrEmpty(reportGuid))
                            {
                                string strFromRp      = string.Format("select procedureguid, orderguid from tregprocedure with(nolock) where reportguid ='{0}'", reportGuid);
                                string strFromOrder   = "select accno,patientguid from tregorder with(nolock) where orderguid ='{0}'";
                                string strFromPatient = "select patientid, localname from tregpatient with(nolock) where patientguid='{0}'";
                                //get rp info
                                DataTable dtRp = dal.ExecuteQuery(strFromRp);
                                rpguids = "";
                                foreach (DataRow dr in dtRp.Rows)
                                {
                                    rpguids += Convert.ToString(dr["ProcedureGuid"]) + "&" + owner + "&" + ownerIP + "|";
                                }
                                rpguids  = rpguids.TrimEnd(new char[] { '|' });
                                lockGuid = Convert.ToString(dtRp.Rows[0]["OrderGuid"]);
                                //get accno
                                DataTable dtOrder = dal.ExecuteQuery(string.Format(strFromOrder, lockGuid));
                                accno = Convert.ToString(dtOrder.Rows[0]["AccNo"]);
                                //get patient info
                                DataTable dtPatient = dal.ExecuteQuery(string.Format(strFromPatient, dtOrder.Rows[0]["PatientGuid"]));
                                patientid = Convert.ToString(dtPatient.Rows[0]["PatientID"]);
                                localname = Convert.ToString(dtPatient.Rows[0]["LocalName"]);
                                //lockGuid has value now~
                                strSQL = string.Format("select Owner,OwnerIP,RPGuids,ModuleID from tSync where guid='{0}'", lockGuid);
                                dtLock = dal.ExecuteQuery(strSQL);
                            }
                            #endregion

                            //#region RWF

                            //if (_rwfMode == -1)
                            //    _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");

                            //if (_rwfMode == 1)
                            //{
                            //    int rpStatus = CS.GCRIS.RWF.SCU.RwfScu.getRpStatus(lockGuid);

                            //    if (CS.GCRIS.RWF.SCU.RwfScu.needClaim(lockGuid))
                            //    {
                            //        if (!CS.GCRIS.RWF.SCU.RwfScu.claim(lockGuid, owner))
                            //        {
                            //            // failed to check.
                            //            strSQL = "select top 1 '2' syncType, '" + lockGuid + "' guid, 'CSBROKER' owner,"
                            //                + " 'CSBROKER' ownerIP, '0400' moduleID, p.patientID, p.localName, o.AccNo, '' RPGuids"
                            //                + " from tRegPatient p, tRegOrder o "
                            //                + " where p.patientguid=o.patientguid AND o.orderguid='" + lockGuid + "' ";

                            //            dal.ExecuteQuery(strSQL, ds, "tSync");

                            //            return ds;
                            //        }
                            //    }
                            //    else if (100 == rpStatus)
                            //    {
                            //        CS.GCRIS.RWF.SCU.RwfScu.nSetCompleted(lockGuid, owner);
                            //    }
                            //}

                            //#endregion

                            #region add lock in ris

                            if (dtLock == null || dtLock.Rows.Count == 0)
                            {
                                string domain = CommonGlobalSettings.Utilities.GetCurDomain();

                                //Not be locked
                                strSQL = string.Format("insert tSync(syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids,domain) " +
                                                       "values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')",
                                                       lockType, lockGuid, owner, ownerIP, "0400", patientid, localname, accno, rpguids, domain);
                            }
                            else
                            {
                                if (dtLock.Rows[0]["RPGuids"] == null || dtLock.Rows[0]["RPGuids"].ToString().Trim().Length == 0)
                                {
                                    //Lock by other panel
                                    strSQL = string.Format("select syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids from tSync where guid='{0}'", lockGuid);
                                }
                                else
                                {
                                    string   strOrgRpGuids = Convert.ToString(dtLock.Rows[0]["RPGuids"]);
                                    string   strOrgOwner   = Convert.ToString(dtLock.Rows[0]["owner"]);
                                    string   strOrgOwnerIP = Convert.ToString(dtLock.Rows[0]["ownerIP"]);
                                    string   strModuleID   = Convert.ToString(dtLock.Rows[0]["moduleID"]);
                                    char[]   sep1          = { '|' };
                                    char[]   sep2          = { '&' };
                                    string[] arrItems1     = rpguids.Split(sep1);
                                    bool     bLocked       = false;
                                    string   strLockInfo   = "";
                                    foreach (string strSegment in arrItems1)
                                    {
                                        string[] arritems2 = strSegment.Split(sep2);
                                        if (arritems2[0] == null)
                                        {
                                            continue;
                                        }

                                        string[] strOrgItems = strOrgRpGuids.Split(sep1);
                                        foreach (string str in strOrgItems)
                                        {
                                            if (str.Contains(arritems2[0]))
                                            {
                                                bLocked      = true;
                                                strLockInfo += str;
                                                strLockInfo += "|";
                                            }
                                        }
                                    }

                                    if (bLocked)
                                    {
                                        strLockInfo = strLockInfo.TrimEnd('|');
                                        //Lock by other by report panel
                                        string[] arrItem3 = strLockInfo.Split(sep1);
                                        if (arrItem3.Length > 0)
                                        {
                                            DataTable dt = new DataTable("tSync");
                                            dt.Columns.Add("Description", typeof(string));
                                            dt.Columns.Add("Owner", typeof(string));
                                            dt.Columns.Add("OwnerIP", typeof(string));
                                            dt.Columns.Add("ModuleID", typeof(string));
                                            foreach (string strSegment in arrItem3)
                                            {
                                                string[] arrItem4        = strSegment.Split(sep2);
                                                string   strRPGuid       = arrItem4[0];
                                                string   strLockUserGuid = arrItem4[1];
                                                string   strLockIP       = arrItem4[2];
                                                string   str             = string.Format("select RPDesc AS Description from tRegProcedure where ProcedureGuid='{0}'", strRPGuid);
                                                object   obj             = dal.ExecuteScalar(str);
                                                if (obj == null)
                                                {
                                                    obj = "";
                                                }
                                                DataRow dr = dt.NewRow();
                                                dr["Description"] = obj.ToString();
                                                dr["Owner"]       = strLockUserGuid;
                                                dr["OwnerIP"]     = strLockIP;
                                                dr["ModuleID"]    = strModuleID;
                                                dt.Rows.Add(dr);
                                            }
                                            ds.Tables.Add(dt);
                                            strSQL = "";
                                        }
                                        else
                                        {
                                            strSQL = string.Format("select syncType, guid, owner, ownerIP, moduleID, patientID, patientName, AccNo,RPGuids from tSync where guid='{0}'", lockGuid);
                                        }
                                    }
                                    else
                                    {
                                        if (strOrgOwner.Contains(owner))
                                        {
                                            strSQL = string.Format("Update tSync set RPGuids='{0}' where guid='{1}'", strOrgRpGuids + "|" + rpguids, lockGuid);
                                        }
                                        else
                                        {
                                            strSQL = string.Format("Update tSync set RPGuids='{0}',owner='{1}',ownerip='{2}' where guid='{3}'", strOrgRpGuids + "|" + rpguids, strOrgOwner + "|" + owner, strOrgOwnerIP + "|" + ownerIP, lockGuid);
                                        }
                                    }
                                }
                            }

                            ServerPubFun.RISLog_Info(0, "GetLockDAO_MSSQL, ADD, owner=" + owner + ", ownerIP=" + ownerIP,
                                                     (new System.Diagnostics.StackFrame()).GetFileName(),
                                                     (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                            if (strSQL.Trim().Length > 0)
                            {
                                dal.ExecuteQuery(strSQL, ds, "tSync");
                            }

                            #endregion
                        }
                        #endregion
                        else if (action.ToUpper() == "DELETE" || action.ToUpper() == "DEL")
                        #region Delete
                        {
                            #region RWF

                            if (_rwfMode == -1)
                            {
                                _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");
                            }

                            /*
                             * if (_rwfMode == 1)
                             * {
                             *  int rpStatus = CS.GCRIS.RWF.SCU.RwfScu.getRpStatus(lockGuid);
                             *  if (RWF_COMPLETED_VS_RIS_STATUS == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.spsComplete(lockGuid, owner);
                             *  }
                             *  else if (100 == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.nCreate(lockGuid, owner);
                             *  }
                             *  else if (50 == rpStatus)
                             *  {
                             *      CS.GCRIS.RWF.SCU.RwfScu.spsDefer(lockGuid, owner);
                             *  }
                             *  else
                             *  {
                             *      // do nothing
                             *  }
                             * }
                             */
                            #endregion

                            #region delete lock in ris

                            if (dtLock != null && dtLock.Rows.Count > 0)
                            {
                                string strOrgRpGuids = Convert.ToString(dtLock.Rows[0]["RPGuids"]);


                                string   strOrgOwner   = Convert.ToString(dtLock.Rows[0]["owner"]);
                                string   strOrgOwnerIP = Convert.ToString(dtLock.Rows[0]["ownerIP"]);
                                char[]   sep           = { '|' };
                                string[] arrItems      = rpguids.Split(sep);
                                bool     bLocked       = false;
                                foreach (string strRpGuid in arrItems)
                                {
                                    if (strOrgRpGuids.Contains(strRpGuid + "|"))
                                    {
                                        strOrgRpGuids = strOrgRpGuids.Replace(strRpGuid + "|", "");
                                    }
                                    else if (strOrgRpGuids.Contains(strRpGuid))
                                    {
                                        strOrgRpGuids = strOrgRpGuids.Replace(strRpGuid, "");
                                    }
                                }
                                strOrgRpGuids = strOrgRpGuids.TrimEnd('|');
                                if (strOrgRpGuids.Trim().Length == 0)
                                {
                                    strSQL = string.Format("delete from tSync where guid='{0}'", lockGuid);
                                }
                                else
                                {
                                    string[] arrItems1 = strOrgOwner.Split(sep);
                                    if (arrItems1.Length > 1)
                                    {
                                        foreach (string strOwner in arrItems1)
                                        {
                                            bool     bRPGuidContainOwner = false;
                                            string[] arr10 = strOrgRpGuids.Split('|');
                                            foreach (string strRPGuid10 in arr10)
                                            {
                                                string[] arr11 = strRPGuid10.Split('&');
                                                if (owner.ToUpper() == arr11[1].ToUpper())
                                                {
                                                    bRPGuidContainOwner = true;
                                                    break;
                                                }
                                            }

                                            bool     bOwnerContain = false;
                                            string[] arr12         = strOrgOwner.Split('|');
                                            foreach (string strOwner10 in arr12)
                                            {
                                                if (owner.ToUpper() == strOwner10.ToUpper())
                                                {
                                                    bOwnerContain = true;
                                                    break;
                                                }
                                            }

                                            if (bOwnerContain && !bRPGuidContainOwner)
                                            {
                                                if (strOrgOwner.Contains(owner + "|"))
                                                {
                                                    strOrgOwner = strOrgOwner.Replace(owner + "|", "");
                                                }
                                                else
                                                {
                                                    //strOrgOwner = strOrgOwner.Replace(owner, "");
                                                    strOrgOwner = "";
                                                    foreach (string strOwner10 in arr12)
                                                    {
                                                        if (owner.ToUpper() != strOwner10.ToUpper())
                                                        {
                                                            strOrgOwner += strOwner10;
                                                            strOrgOwner += "|";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        strOrgOwner = strOrgOwner.TrimEnd('|');

                                        string[] arrItems2 = strOrgOwnerIP.Split(sep);
                                        foreach (string strOwnerIP in arrItems2)
                                        {
                                            if (strOrgOwnerIP.Contains(ownerIP + "|") && !strOrgRpGuids.Contains(ownerIP))
                                            {
                                                strOrgOwnerIP = strOrgOwnerIP.Replace(ownerIP + "|", "");
                                            }
                                            else if (strOrgOwnerIP.Contains(ownerIP) && !strOrgRpGuids.Contains(ownerIP))
                                            {
                                                strOrgOwnerIP = strOrgOwnerIP.Replace(ownerIP, "");
                                            }
                                        }
                                        strOrgOwnerIP = strOrgOwnerIP.TrimEnd('|');
                                        strSQL        = string.Format("update tSync set owner='{0}',ownerip='{1}',rpguids='{2}' where guid='{3}'", strOrgOwner, strOrgOwnerIP, strOrgRpGuids, lockGuid);
                                    }
                                    else
                                    {
                                        strSQL = string.Format("update tSync set rpguids='{0}' where guid='{1}'", strOrgRpGuids, lockGuid);
                                    }
                                }



                                dal.ExecuteQuery(strSQL, ds, "tSync");
                            }
                            #endregion
                        }
                        #endregion
                        else
                        #region Query
                        {
                            string sql = "select * from tSync, tUser where tSync.Owner=tUser.UserGuid and tSync.SyncType="
                                         + lockType + " and tSync.Guid='" + lockGuid + "'";

                            dal.ExecuteQuery(sql, ds, "tSync");
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    //dal.RollbackTransaction();

                    System.Diagnostics.Debug.Assert(false, ex.Message);

                    ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                              (new System.Diagnostics.StackFrame()).GetFileName(),
                                              (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                    throw (ex);
                }



                return(ds);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetLockDAO=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Example #8
0
        public object Execute(object param)
        {
            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListDAO!", "", 0);
                }

                using (RisDAL dal = new RisDAL())
                {
                    string condition = "", userGuid = "", panelName = GRIDNAME_DEFAULT;
                    int    nPagesize = 0, nCurpage = 0;
                    string strOrderBy   = "";
                    bool   bOfflineData = false;

                    foreach (string key in paramMap.Keys)
                    {
                        switch (key.ToUpper())
                        {
                        case "CONDITION":
                        {
                            condition = paramMap[key] as string;

                            if (condition == null)
                            {
                                condition = "";
                            }
                        }
                        break;

                        case "PAGESIZE":
                        {
                            nPagesize = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        break;

                        case "CURPAGE":
                        {
                            nCurpage = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        break;

                        case "USERID":
                        {
                            userGuid = paramMap[key] as string;
                        }
                        break;

                        case "PANELNAME":
                        {
                            panelName = paramMap[key] as string;
                        }
                        break;

                        case "SORTING":
                        {
                            strOrderBy = paramMap[key] as string;
                        }
                        break;

                        case "OFFLINEDATA":
                        {
                            bOfflineData = (System.Convert.ToString(paramMap[key]) == "1");
                        }
                        break;
                        }
                    }

                    condition = condition == null ? "" : condition;
                    userGuid  = userGuid == null ? "" : userGuid;
                    panelName = panelName == null ? "" : panelName;
                    nPagesize = nPagesize < 1 ? ReportCommon.ReportCommon.DEFAULT_PAGESIZE : nPagesize;
                    nCurpage  = nCurpage < 1 ? 0 : nCurpage;

                    #endregion

                    //#region RWF

                    //if (_rwfMode == -1)
                    //    _rwfMode = ServerPubFun.GetSystemProfile_Int("RWFmode");

                    //if (_rwfMode == 1)
                    //{
                    //    CS.GCRIS.RWF.SCU.RwfScu.queryWorklist(condition);

                    //    // ONLY for RWF test
                    //    condition = CS.GCRIS.RWF.SCU.RwfScu.composeSQLfromConditionMap(CS.GCRIS.RWF.SCU.RwfScu.parserCondition(condition));
                    //}

                    //#endregion

                    #region Compose SQL sentense

                    string sqlcol = GetSqlCol(panelName, userGuid).Trim();
                    if (!sqlcol.Contains("tRegProcedure.Status as RPStatus"))
                    {
                        sqlcol += ",tRegProcedure.Status as RPStatus";
                    }
                    if (!sqlcol.Contains("tRegProcedure.Optional3 as IsLocked"))
                    {
                        sqlcol += ",tRegProcedure.Optional3 as IsLocked";
                    }
                    if (!sqlcol.Contains("tRegProcedure.ExamSystem as tRegProcedure__ExamSystem"))
                    {
                        sqlcol += ",tRegProcedure.ExamSystem as tRegProcedure__ExamSystem";
                    }
                    if (!sqlcol.Contains("convert(varchar(max),tRegOrder.OrderMessage) as OrderMessageXml "))
                    {
                        sqlcol += ",convert(varchar(max),tRegOrder.OrderMessage) as OrderMessageXml ";
                    }
                    if (!sqlcol.Contains("tReport.CreaterName as tReport__CreaterName"))
                    {
                        sqlcol += ",tReport.CreaterName as tReport__CreaterName";
                    }
                    if (!sqlcol.Contains("tReport.SubmitterName as tReport__SubmitterName"))
                    {
                        sqlcol += ",tReport.SubmitterName as tReport__SubmitterName";
                    }
                    if (!sqlcol.Contains("tReport.FirstapproverName as tReport__FirstapproverName"))
                    {
                        sqlcol += ",tReport.FirstapproverName as tReport__FirstapproverName";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawDept as tRegOrder__FilmDrawDept"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawDept as tRegOrder__FilmDrawDept";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawRegion as tRegOrder__FilmDrawRegion"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawRegion as tRegOrder__FilmDrawRegion";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawComment as tRegOrder__FilmDrawComment"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawComment as tRegOrder__FilmDrawComment";
                    }
                    if (!sqlcol.Contains("tRegOrder.FilmDrawerSign as tRegOrder__FilmDrawerSign"))
                    {
                        sqlcol += ",tRegOrder.FilmDrawerSign as tRegOrder__FilmDrawerSign";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmDept as tReport__TakeFilmDept"))
                    {
                        sqlcol += ",tReport.TakeFilmDept as tReport__TakeFilmDept";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmRegion as tReport__TakeFilmRegion"))
                    {
                        sqlcol += ",tReport.TakeFilmRegion as tReport__TakeFilmRegion";
                    }
                    if (!sqlcol.Contains("tReport.TakeFilmComment as tReport__TakeFilmComment"))
                    {
                        sqlcol += ",tReport.TakeFilmComment as tReport__TakeFilmComment ";
                    }

                    sqlcol = sqlcol.Length > 0 ? sqlcol : "No Grid Column Setting!";

                    // 2015-11-06, Oscar removed (US28272)
                    //string plainColumns = sqlcol;

                    //plainColumns = removeBrackets(plainColumns);
                    //plainColumns = plainColumns.Replace(" AS ", " as ");
                    //int asTmp0 = 0;
                    //while ((asTmp0 = plainColumns.IndexOf(" as ")) > 0)
                    //{
                    //    int comma0 = plainColumns.LastIndexOf(',', asTmp0);

                    //    if (comma0 < 0)
                    //        plainColumns = " " + plainColumns.Substring(asTmp0 + 4);
                    //    else
                    //        plainColumns = plainColumns.Substring(0, comma0 + 1) + " " + plainColumns.Substring(asTmp0 + 4);
                    //}

                    //while ((asTmp0 = plainColumns.IndexOf(".")) > 0)
                    //{
                    //    int comma0 = plainColumns.LastIndexOf(',', asTmp0);

                    //    if (comma0 < 0)
                    //        plainColumns = " " + plainColumns.Substring(asTmp0 + 1);
                    //    else
                    //        plainColumns = plainColumns.Substring(0, comma0 + 1) + " " + plainColumns.Substring(asTmp0 + 1);
                    //}

                    string sql = "";

                    string strWhere = " from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock) \r\n"
                                      + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                                      + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                                      + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                                      + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                    string strWhereforArchive = " from RISArchive..tRegPatient tRegPatient with (nolock), RISArchive..tRegOrder tRegOrder with (nolock), RISArchive..tRegProcedure tRegProcedure with (nolock) \r\n"
                                                + " left join RISArchive..tReport tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                                                + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                                                + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                                                + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                    if (condition.Length > 0)
                    {
                        while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                        {
                            condition = condition.Substring(0, condition.Length - 3);
                        }

                        strWhere           += " and " + condition;
                        strWhereforArchive += " and " + condition;
                    }
                    if (strWhere.Length > 4096)
                    {
                        throw new Exception("The query conditions is too long!");
                    }

                    #endregion

                    #region Execute Query

                    DataSet ds = new DataSet();

                    //DataSet tmp = new DataSet();

                    if (0 == iWrittenCount++ % 100)
                    {
                        ServerPubFun.RISLog_Info(0, "GetReportsListDAO_MSSQL, curPage=" + nCurpage.ToString() + ", SQL=" + sql, "", 0);
                    }
                    else
                    {
                        ServerPubFun.RISLog_Info(0, "GetReportsListDAO_MSSQL, curPage=" + nCurpage.ToString() + ", condition=" + condition + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                    }

                    //{Bruce Deng 20071128
                    //dal.ExecuteQuery(sql, tmp, "ReportsList");
                    dal.Parameters.Clear();
                    dal.Parameters.AddInt("@PageIndex", nCurpage);
                    dal.Parameters.AddInt("@PageSize", nPagesize);
                    dal.Parameters.AddVarChar("@Columns", sqlcol, 8000);
                    dal.Parameters.AddVarChar("@Where", strWhere, 8000);
                    dal.Parameters.AddVarChar("@WhereArchive", bOfflineData ? strWhereforArchive : "", 8000);
                    //dal.Parameters.AddVarChar("@plainColumns", plainColumns, 8000);
                    dal.Parameters.AddVarChar("@OrderBy", bOfflineData ? strOrderBy.Replace(".", "__") : strOrderBy, 8000);
                    int nTotalCount = 0;
                    dal.Parameters.AddInt("@TotalCount", nTotalCount, ParameterDirection.Output);
                    DataTable dt1 = new DataTable();
                    dal.ExecuteQuerySP("SP_REPORT_PAGE", dt1);
                    dt1.TableName = "ReportList";

                    if (dal.Parameters["@TotalCount"].Value != null)
                    {
                        nTotalCount = Convert.ToInt32(dal.Parameters["@TotalCount"].Value);
                    }
                    //}

                    if (-1 == nTotalCount)
                    {
                        nTotalCount = dt1.Rows.Count;
                    }

                    if (dt1 != null)
                    {
                        ////DataTable dt = tmp.Tables[0].Clone();
                        //DataTable dt = new DataTable();
                        //dt.TableName = "ReportPage";
                        //foreach (DataColumn dc in dt1.Columns)
                        //{
                        //    dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                        //}

                        //if (dt1.Rows.Count > 0)
                        //{
                        //    if (dt1.Rows.Count <= (Int64)nCurpage * nPagesize)
                        //    {
                        //        int ipage = (dt1.Rows.Count - 1) / nPagesize;
                        //        for (int i = ipage * nPagesize; i < dt1.Rows.Count; i++)
                        //        {
                        //            DataRow dr = dt.NewRow();

                        //            foreach (DataColumn col in dt.Columns)
                        //            {
                        //                dr[col.ColumnName] = dt1.Rows[i][col.ColumnName];
                        //            }

                        //            dt.Rows.Add(dr);
                        //        }

                        //        nCurpage = ipage;
                        //    }
                        //    else
                        //    {
                        //        for (int i = nCurpage * nPagesize; i < (nCurpage + 1) * nPagesize && i < dt1.Rows.Count; i++)
                        //        {
                        //            DataRow dr = dt.NewRow();

                        //            foreach (DataColumn col in dt.Columns)
                        //            {
                        //                dr[col.ColumnName] = dt1.Rows[i][col.ColumnName];
                        //            }

                        //            dt.Rows.Add(dr);
                        //        }
                        //    }
                        //}
                        //else
                        //{
                        //    nCurpage = 0;
                        //}

                        //ds.Tables.Add(dt);
                        //ds.Tables.Add(dt1);

                        //if (dt1.Rows.Count > 0)
                        //{
                        //    if (dt1.Rows.Count <= (Int64)nCurpage * nPagesize)
                        //    {
                        //        int ipage = (dt1.Rows.Count - 1) / nPagesize;

                        //        nCurpage = ipage;
                        //    }
                        //}
                        //else
                        //{
                        //    nCurpage = 0;
                        //}

                        //StringBuilder sb = new StringBuilder();
                        //sb.AppendFormat("rownum > {0} AND rownum <= {1}", nCurpage * nPagesize, (nCurpage + 1) * nPagesize);

                        //dt1.DefaultView.RowFilter = sb.ToString();
                        //DataTable dt = dt1.DefaultView.ToTable("ReportPage");
                        DataTable dt = dt1.Copy();//.DefaultView.ToTable("ReportPage");
                        dt.TableName = "ReportPage";

                        ds.Tables.Add(dt);
                        ds.Tables.Add(dt1);
                    }


                    #endregion


                    Dictionary <string, object> outMap = new Dictionary <string, object>();

                    outMap.Add("DataSet", ds);
                    outMap.Add("CurPage", nCurpage);
                    outMap.Add("TotalCount", nTotalCount);

                    return(outMap);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListDAO_MSSQL, MSG=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                throw new Exception(ex.Message);
            }

            return(null);
        }
Example #9
0
        public object Execute(object param)
        {
            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListDAO!", "", 0);
                }

                using (RisDAL dal = new RisDAL())
                {
                    string condition = "", userGuid = "", panelName = GRIDNAME_DEFAULT;
                    int    nPagesize = 0, nCurpage = 0;

                    foreach (string key in paramMap.Keys)
                    {
                        if (key.ToUpper() == "CONDITION")
                        {
                            condition = paramMap[key] as string;

                            if (condition == null)
                            {
                                condition = "";
                            }
                        }
                        else if (key.ToUpper() == "PAGESIZE")
                        {
                            nPagesize = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        else if (key.ToUpper() == "CURPAGE")
                        {
                            nCurpage = System.Convert.ToInt32(paramMap[key] as string);
                        }
                        else if (key.ToUpper() == "USERID")
                        {
                            userGuid = paramMap[key] as string;
                        }
                        else if (key.ToUpper() == "PANELNAME")
                        {
                            panelName = paramMap[key] as string;
                        }
                    }

                    condition = condition == null ? "" : condition;
                    userGuid  = userGuid == null ? "" : userGuid;
                    panelName = panelName == null ? "" : panelName;
                    nPagesize = nPagesize < 1 ? ReportCommon.ReportCommon.DEFAULT_PAGESIZE : nPagesize;
                    nCurpage  = nCurpage < 1 ? 0 : nCurpage;

                    #endregion

                    #region Compose SQL sentense

                    string sqlcol = GetSqlCol(panelName, userGuid).Trim();
                    sqlcol = sqlcol.Length > 0 ? sqlcol : "No Grid Column Setting!";

                    string sql = "";

                    if (nPagesize * (nCurpage + 1) >= 5000 || nPagesize * (nCurpage + 1) < 0)
                    {
                        sql += "select " + sqlcol + ",tRegProcedure.Status as RPStatus,tRegProcedure.Optional3 as IsLocked  \r\n"
                               + " from tRegPatient, tRegOrder, tRegProcedure \r\n"
                               + " left join tReport on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                               + " , tProcedureCode"
                               + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                               + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                               + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n"
                               + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);
                    }
                    else
                    {
                        sql += "select " + sqlcol + ",tRegProcedure.Status as RPStatus,tRegProcedure.Optional3 as IsLocked  \r\n"
                               + " from tRegPatient, tRegOrder, tRegProcedure \r\n"
                               + " left join tReport on tRegProcedure.reportGuid = tReport.reportGuid \r\n"
                               + " , tProcedureCode"
                               + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid \r\n"
                               + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid \r\n"
                               + " and tRegProcedure.ProcedureCode = tProcedureCode.ProcedureCode \r\n"
                               + " and rownum < " + (nPagesize * (nCurpage + 1)).ToString()
                               + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);
                    }

                    if (condition.Length > 0)
                    {
                        while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                        {
                            condition = condition.Substring(0, condition.Length - 3);
                        }

                        sql += " and " + getOracleDateString(condition);
                    }

                    #endregion

                    #region Execute Query

                    DataSet ds = new DataSet();

                    //if (nCurpage < 10)
                    //{
                    //    sql = " select * from (" + sql + ") _ReportA where _rowindex between " + (nCurpage * nPagesize + 1).ToString() + " and " + ((nCurpage + 1) * nPagesize).ToString();

                    //    ReportCommon.ReportCommon.WriteDebugLog("CurPage=" + nCurpage.ToString() + "\r\n" + sql);

                    //    dal.ExecuteQuery(sql, ds, "ReportsList");
                    //}
                    //else
                    {
                        DataSet tmp = new DataSet();



                        dal.ExecuteQuery(sql, tmp, "ReportsList");

                        if (tmp != null && tmp.Tables.Count > 0)
                        {
                            //DataTable dt = tmp.Tables[0].Clone();
                            DataTable dt = new DataTable();

                            foreach (DataColumn dc in tmp.Tables[0].Columns)
                            {
                                dt.Columns.Add(dc.ColumnName, dc.DataType, dc.Expression);
                            }

                            if (tmp.Tables[0].Rows.Count > 0)
                            {
                                if (tmp.Tables[0].Rows.Count <= (Int64)nCurpage * nPagesize)
                                {
                                    int ipage = (tmp.Tables[0].Rows.Count - 1) / nPagesize;
                                    for (int i = ipage * nPagesize; i < tmp.Tables[0].Rows.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();

                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            dr[col.ColumnName] = tmp.Tables[0].Rows[i][col.ColumnName];
                                        }

                                        dt.Rows.Add(dr);
                                    }

                                    nCurpage = ipage;
                                }
                                else
                                {
                                    for (int i = nCurpage * nPagesize; i < (nCurpage + 1) * nPagesize && i < tmp.Tables[0].Rows.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();

                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            dr[col.ColumnName] = tmp.Tables[0].Rows[i][col.ColumnName];
                                        }

                                        dt.Rows.Add(dr);
                                    }
                                }
                            }
                            else
                            {
                                nCurpage = 0;
                            }

                            ds.Tables.Add(dt);
                        }
                    }

                    #endregion



                    Dictionary <string, object> outMap = new Dictionary <string, object>();

                    outMap.Add("DataSet", ds);
                    outMap.Add("CurPage", nCurpage);

                    return(outMap);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListDAO_ORACLE=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Example #10
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public object Execute(object param)
        {
            int    iRet = -1;
            string sql  = "";

            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    //throw (new Exception("No parameter in GetReportsListCountDAO!"));

                    ServerPubFun.RISLog_Info(0, "No parameter in GetReportsListCountDAO!", "", 0);
                }

                string condition    = "";
                bool   bOfflineData = false;

                foreach (string key in paramMap.Keys)
                {
                    switch (key.ToUpper())
                    {
                    case "CONDITION":
                    {
                        condition = paramMap[key] as string;

                        if (condition == null)
                        {
                            condition = "";
                        }
                    }
                    break;

                    case "OFFLINEDATA":
                    {
                        bOfflineData = (System.Convert.ToString(paramMap[key]) == "1");
                    }
                    break;
                    }
                }

                condition = condition == null ? "" : condition;

                #endregion

                #region Compose SQL sentense

                //sql = "select count(1) "
                //     + " from tRegPatient, tRegOrder, tRegProcedure "
                //     + " left join tReport with (nolock) on tRegProcedure.reportGuid = tReport.reportGuid "
                //     + " , tProcedureCode"
                //     + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid "
                //     + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid "
                //     + " and tProcedureCode.ProcedureCode = tRegProcedure.ProcedureCode "
                //     + " and tRegProcedure.status >= " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination);

                //if (condition != null && condition.Length > 0)
                //{
                //    while ((condition = condition.Trim()).Length > 0 && condition.ToUpper().EndsWith("AND"))
                //    {
                //        condition = condition.Substring(0, condition.Length - 3);
                //    }

                //    sql += " and " + condition;
                //}

                #endregion

                #region Execute Query

                using (RisDAL dal = new RisDAL())
                {
                    DataTable dt = new DataTable();

                    //if (0 == iWrittenCount++ % 100)
                    //{
                    //    ServerPubFun.RISLog_Info(0, "GetReportsListCountDAO_MSSQL, SQL=" + sql, "", 0);
                    //}
                    //else
                    //{
                    //    ServerPubFun.RISLog_Info(0, "GetReportsListCountDAO_MSSQL, condition=" + condition + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                    //}

                    //dal.ExecuteQuery(sql, dt);

                    //if (dt != null && dt.Rows.Count > 0)
                    //{
                    //    iRet = System.Convert.ToInt32(dt.Rows[0][0]);
                    //}

                    dal.Parameters.Clear();
                    dal.Parameters.AddVarChar("@condition", condition, 8000);
                    dal.Parameters.AddVarChar("@offlineCondition", bOfflineData ? "1" : "", 8000);
                    dal.Parameters.AddInt("@TotalCount", iRet, ParameterDirection.Output);

                    DataTable dt1 = new DataTable();
                    dal.ExecuteQuerySP("SP_REPORT_PAGE_COUNT", dt1);
                    dt1.TableName = "ReportList";

                    if (dal.Parameters["@TotalCount"].Value != null)
                    {
                        iRet = Convert.ToInt32(dal.Parameters["@TotalCount"].Value);
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportsListCountDAO_MSSQL, MSG=" + ex.Message + ", SQL=" + sql,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(iRet);
        }
Example #11
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public object Execute(object param)
        {
            int    iRet = 0;
            string sql  = "";

            try
            {
                #region Parse the parameters

                Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                if (paramMap == null || paramMap.Count < 1)
                {
                    ServerPubFun.RISLog_Info(0, "No parameter in GeExamNumberDAODAO!", "", 0);
                }

                string patientid = "";
                string orderguid = "";
                foreach (string key in paramMap.Keys)
                {
                    if (key.ToUpper() == "PATIENTID")
                    {
                        patientid = paramMap[key] as string;
                    }
                    if (key.ToUpper() == "ORDERGUID")
                    {
                        orderguid = paramMap[key] as string;
                    }
                }
                patientid = patientid == null ? "" : patientid;
                orderguid = orderguid == null ? "" : orderguid;
                #endregion


                #region Execute Query
                using (RisDAL dal = new RisDAL())
                {
                    DataTable dt = new DataTable();
                    string    sp = @"SP_GetPatientExamNo";
                    dal.Parameters.AddVarChar("@PatientID", patientid, patientid.Length * 2);
                    dal.Parameters.AddVarChar("@OrderGuid", orderguid, orderguid.Length * 2);
                    object obj = dal.ExecuteScalarSP(sp);
                    if (obj != null || obj != DBNull.Value)
                    {
                        return(Convert.ToInt32(obj));
                    }
                }


                #endregion
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GeExamNumberDAO_MSSQL, MSG=" + ex.Message + ", SQL=" + sql,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
                return(1);//default is 1
            }

            return(1);//default is 1
        }
Example #12
0
        public object Execute(object param)
        {
            Dictionary <string, object> outMap = new Dictionary <string, object>();

            try
            {
                using (RisDAL dal = new RisDAL())
                {
                    #region Parse the parameters

                    Dictionary <string, object> paramMap = param as Dictionary <string, object>;

                    if (paramMap == null || paramMap.Count < 1)
                    {
                        throw (new Exception("No parameter in GetReportHistoryDAO!"));
                    }

                    string patientID = "", reportGuid = "", strGlobalID = "", strDBCenter = "0", strisSR = "";
                    string strHasReportHistory = null;
                    string szStartReportStatus = string.Empty;
                    bool   bOfflineData        = false;

                    foreach (string key in paramMap.Keys)
                    {
                        switch (key.ToUpper())
                        {
                        case "PATIENTGUID":
                        case "PATIENTID":
                        {
                            patientID = paramMap[key] as string;

                            if (patientID == null)
                            {
                                patientID = "";
                            }
                        }
                        break;

                        case "REPORTGUID":
                        case "REPORTID":
                        {
                            reportGuid = paramMap[key] as string;

                            if (reportGuid == null)
                            {
                                reportGuid = "";
                            }
                        }
                        break;

                        case "HASREPORTHISTORY":
                        {
                            strHasReportHistory = paramMap[key] as string;
                        }
                        break;

                        case "GLOBALID":
                        {
                            strGlobalID = paramMap[key] as string;
                        }
                        break;

                        case "DBCENTER":
                        {
                            strDBCenter = paramMap[key] as string;
                        }
                        break;

                        case "STARTREPORTSTATUS":
                        {
                            szStartReportStatus = paramMap[key] as string;
                        }
                        break;

                        case "OFFLINEDATA":
                        {
                            bOfflineData = (System.Convert.ToString(paramMap[key]) == "1");
                        }
                        break;

                        case "ISSR":
                        {
                            strisSR = paramMap[key] as string;
                        }
                        break;
                        }
                    }

                    if (string.IsNullOrEmpty(szStartReportStatus))
                    {
                        szStartReportStatus = System.Convert.ToInt32(ReportCommon.RP_Status.FirstApprove).ToString();
                    }

                    bool bRelatedPatient = ServerPubFun.GetSystemProfile_Bool("RelatePatient", ReportCommon.ModuleID.Global);

                    #endregion

                    if (strHasReportHistory != null)
                    #region Check whether history reports exist
                    {
                        // We check it using the procedure guid.
                        // Actually clients use the reportGuid to transmit the rpGuids
                        string[] rpGuids       = reportGuid.Split(",".ToCharArray());
                        string   strExpression = "";
                        foreach (string rpguid in rpGuids)
                        {
                            if (string.IsNullOrEmpty(rpguid))
                            {
                                continue;
                            }

                            string tmpRP = rpguid.Trim(",;|. ".ToCharArray());

                            if (string.IsNullOrEmpty(tmpRP))
                            {
                                continue;
                            }

                            strExpression += "'" + tmpRP + "',";
                        }

                        if (!string.IsNullOrEmpty(strExpression))
                        {
                            strExpression = strExpression.TrimEnd(new char[] { ',' });
                            strExpression = string.Format(" AND tRegProcedure.ProcedureGuid not in ({0})", strExpression);
                        }

                        string sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n"
                                     + " select tRegProcedure.reportGuid, tRegProcedure.ProcedureGuid "
                                     + " from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock) "
                                     + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                     + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                     + " and tRegProcedure.status >= " + szStartReportStatus + strExpression
                                     + " and tRegPatient.PatientID = '" + patientID + "'";

                        if (bRelatedPatient)
                        {
                            sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n"
                                  + " declare @pguid nvarchar(64) select @pguid=RelatedID from tRegPatient where PatientID = '" + patientID + "' "
                                  + " select tRegProcedure.reportGuid, tRegProcedure.ProcedureGuid "
                                  + " from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock) "
                                  + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                  + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                  + " and tRegProcedure.status >= " + szStartReportStatus + strExpression
                                  + " and ( tRegPatient.PatientID = '" + patientID + "' or (tRegPatient.RelatedID = @pguid AND tRegPatient.RelatedID <> '') )";
                        }

                        DataTable dtReport = dal.ExecuteQuery(sql);
                        if (dtReport == null || dtReport.Rows.Count == 0)
                        {
                            outMap.Add("HasReportHistory", "0");
                            return(outMap);
                        }

                        bool bHasReportHistory = false;
                        bHasReportHistory = dtReport.Rows.Count > 0;

                        outMap.Add("HasReportHistory", bHasReportHistory ? "1" : "0");
                        return(outMap);
                    }
                    #endregion
                    else
                    {
                        DataSet ds = new DataSet();


                        if (patientID != null && patientID.Length > 0)
                        #region History reports
                        {
                            // We check it using the procedure guid.
                            // Actually clients use the reportGuid to transmit the rpGuids
                            string[] rpGuids       = reportGuid.Split(",".ToCharArray());
                            string   strExpression = "";
                            foreach (string rpguid in rpGuids)
                            {
                                if (string.IsNullOrEmpty(rpguid))
                                {
                                    continue;
                                }

                                string tmpRP = rpguid.Trim(",;|. ".ToCharArray());

                                if (string.IsNullOrEmpty(tmpRP))
                                {
                                    continue;
                                }

                                strExpression += "'" + tmpRP + "',";
                            }

                            if (!string.IsNullOrEmpty(strExpression))
                            {
                                strExpression = strExpression.TrimEnd(new char[] { ',' });
                                strExpression = string.Format(" AND tRegProcedure.ProcedureGuid not in ({0})", strExpression);
                            }

                            GetReportInfoDAO_MSSQL rptInfo = new GetReportInfoDAO_MSSQL();
                            string allCol = rptInfo.GetAllReportColumn();

                            allCol = allCol.Replace("tRegPatient.Birthday as tRegPatient__Birthday,", "convert(nvarchar(10), tRegPatient.Birthday, 120) as tRegPatient__Birthday,");
                            allCol = allCol.Replace("tRegProcedure.Status as tRegProcedure__Status", "isnull(cast(tRegProcedure.status as varchar(8)), '50') as tRegProcedure__Status");
                            //allCol = allCol.Replace(", TREGORDER.ORDERMESSAGE as TREGORDER__ORDERMESSAGE", ""); reportlist wys/wyg comparing need show ordermessage
                            allCol = allCol.Replace("tProcedureCode.ProcedureCode as tProcedureCode__ProcedureCode,", "");
                            allCol = allCol.Replace("tProcedureCode.Description as tProcedureCode__Description,", "");
                            allCol = allCol.Replace("tProcedureCode.EnglishDescription as tProcedureCode__EnglishDescription,", "");
                            allCol = allCol.Replace("tProcedureCode.ModalityType as tProcedureCode__ModalityType,", "");
                            allCol = allCol.Replace("tProcedureCode.BodyPart as tProcedureCode__BodyPart,", "");
                            allCol = allCol.Replace("tProcedureCode.CheckingItem as tProcedureCode__CheckingItem,", "");
                            allCol = allCol.Replace("tProcedureCode.BodyCategory as tProcedureCode__BodyCategory,", "");
                            allCol = allCol.Replace("tReport.ScoringVersion as tReport__ScoringVersion,", "");
                            allCol = allCol.Replace("tReport.AccordRate as tReport__AccordRate,", "");
                            string sql = string.Empty;

                            if (bRelatedPatient)
                            {
                                sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n"
                                      + " declare @pguid nvarchar(64) select @pguid=RelatedID from tRegPatient where PatientID = '" + patientID + "' "
                                      + " select " + allCol.Trim(',')
                                      + " ,'1' as localreport, (select ContentHtml from tReportContent where ReportId = tReport.ReportGuid) as ContentHtml, (select NaturalContentHtml from tReportContent where ReportId = tReport.ReportGuid) as NaturalContentHtml from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock)  "
                                      + " left join tReport with (nolock) on tRegProcedure.ReportGuid = tReport.ReportGuid "
                                      + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                      + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                      + " and tRegProcedure.status >= " + szStartReportStatus + strExpression;

                                // Here, the latter sentence is obviously faster than "IN" subquery.
                                //sql += " and ( tRegPatient.PatientID = '" + patientID + "'"
                                //    + " or tRegPatient.PatientGuid in (select RelatedID from tRegPatient where PatientID = '" + patientID + "') )";
                                sql += " and ( tRegPatient.PatientID = '" + patientID + "' or (tRegPatient.RelatedID = @pguid AND tRegPatient.RelatedID <> '') )";

                                // Offline Data
                                if (bOfflineData)
                                {
                                    sql += " UNION select " + allCol.Trim(',')
                                           + " ,'1' as localreport from RISArchive..tRegPatient tRegPatient with (nolock), RISArchive..tRegOrder tRegOrder with (nolock), RISArchive..tRegProcedure tRegProcedure with (nolock)"
                                           + "  left join RISArchive..tReport tReport with (nolock) on tRegProcedure.ReportGuid = tReport.ReportGuid "
                                           + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                           + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                           + " and tRegProcedure.status >= " + szStartReportStatus + strExpression;

                                    sql += " and ( tRegPatient.PatientID = '" + patientID + "' or (tRegPatient.RelatedID = @pguid AND tRegPatient.RelatedID <> '') )";
                                }
                            }
                            else
                            {
                                sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n"
                                      + " select " + allCol.Trim(',')
                                      + " ,'1' as localreport, (select ContentHtml from tReportContent where ReportId = tReport.ReportGuid) as ContentHtml, (select NaturalContentHtml from tReportContent where ReportId = tReport.ReportGuid) as NaturalContentHtml from tRegPatient with (nolock), tRegOrder with (nolock), tRegProcedure with (nolock)"
                                      + "  left join tReport with (nolock) on tRegProcedure.ReportGuid = tReport.ReportGuid "
                                      + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                      + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                      + " and tRegProcedure.status >= " + szStartReportStatus + strExpression;

                                sql += " and tRegPatient.PatientID = '" + patientID + "'";

                                // Offline Data
                                if (bOfflineData)
                                {
                                    sql += " UNION select " + allCol.Trim(',')
                                           + " ,'1' as localreport from RISArchive..tRegPatient tRegPatient with (nolock), RISArchive..tRegOrder tRegOrder with (nolock), RISArchive..tRegProcedure tRegProcedure with (nolock) "
                                           + "  left join RISArchive..tReport tReport with (nolock) on tRegProcedure.ReportGuid = tReport.ReportGuid "
                                           + " where tRegPatient.PatientGuid = tRegOrder.PatientGuid"
                                           + " and tRegOrder.OrderGuid = tRegProcedure.OrderGuid"
                                           + " and tRegProcedure.status >= " + szStartReportStatus + strExpression;

                                    sql += " and tRegPatient.PatientID = '" + patientID + "'";
                                }
                            }

                            sql += " order by tReport__CreateDt desc";

                            DataTable dt = new DataTable("Reports");

                            if (0 == iWrittenCount++ % 100)
                            {
                                ServerPubFun.RISLog_Info(0, "GetReportHistoryDAO_MSSQL=" + sql, "", 0);
                            }
                            else
                            {
                                ServerPubFun.RISLog_Info(0, "GetReportHistoryDAO_MSSQL, patientID=" + patientID + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                            }

                            dal.ExecuteQuery(sql, dt);

                            ds.Tables.Add(dt);
                        }
                        #endregion

                        if (reportGuid != null && reportGuid.Length > 0)
                        #region modify list
                        {
                            string sql = "";
                            if (strisSR == "true")
                            {
                                sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                      "select tReportList.*,tReportContentList.ContentHtml,tReportContentList.NaturalContentHtml from tReportList,tReportContentList  "
                                      + " where tReportList.reportGuid = '" + reportGuid + "' and tReportList.ReportListGuid = tReportContentList.ReportListId order by operationTime desc";
                            }
                            else
                            {
                                sql = "SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED \r\n" +
                                      "select * from tReportList  "
                                      + " where tReportList.reportGuid = '" + reportGuid + "' order by operationTime desc";
                            }


                            DataTable dt = new DataTable("History");

                            if (0 == iWrittenCount++ % 100)
                            {
                                ServerPubFun.RISLog_Info(0, "GetReportHistoryDAO_MSSQL=" + sql, "", 0);
                            }
                            else
                            {
                                ServerPubFun.RISLog_Info(0, "GetReportHistoryDAO_MSSQL, reportGuid=" + reportGuid + ", iWrittenCount=" + iWrittenCount.ToString(), "", 0);
                            }

                            //if (strDBCenter == "1")
                            //{
                            //    KodakDAL okodak = new KodakDAL(2);
                            //    okodak.ExecuteQuery(sql, dt);
                            //}
                            //else
                            //{
                            dal.ExecuteQuery(sql, dt);
                            //}

                            ds.Tables.Add(dt);
                        }
                        #endregion


                        outMap.Add("DataSet", ds);

                        return(outMap);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "GetReportHistoryDAO_MSSQL, MSG=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return(null);
        }
Example #13
0
        public object Execute(object param)
        {
            try
            {
                Dictionary <string, object> inMap = param as Dictionary <string, object>;

                if (inMap == null || inMap.Count < 1)
                {
                    throw (new Exception("No parameter in DeleteReportDAO!"));
                }

                string reportGuid = "", curUserGuid = "";

                foreach (string key in inMap.Keys)
                {
                    if (key.ToUpper() == "REPORTGUID")
                    {
                        reportGuid = inMap[key] as string;
                    }
                    else if (key.ToUpper() == "USERID")
                    {
                        curUserGuid = inMap[key] as string;
                    }
                }

                if (reportGuid == null || reportGuid.Length < 1 ||
                    curUserGuid == null || curUserGuid.Length < 1)
                {
                    System.Diagnostics.Debug.Assert(false, "Missing Parameter");
                    throw (new Exception("Miss Parameter in DeleteReportDAO!"));
                }
                string sql = " begin tran \r\n"
                             + " update tRegProcedure set status = " + System.Convert.ToInt32(ReportCommon.RP_Status.Examination).ToString()
                             + " ,ReportGuid=null  where reportGuid = '" + reportGuid + "'  \r\n"
                             + " insert into treportdelpool select * from treport where reportguid='" + reportGuid + "' \r\n"
                             + " update treportdelpool set deleter='" + curUserGuid + "',deletedt='" + DateTime.Now.ToString() + "' where reportguid='" + reportGuid + "' \r\n"
                             + " delete from tReportlist where reportGuid = '" + reportGuid + "' \r\n"
                             + " delete from tReport where reportGuid = '" + reportGuid + "' \r\n"
                             #region Kevin For SR
                             + " delete from tReportContent where ReportId = '" + reportGuid + "'\r\n"
                             #endregion
                             + " commit";


                ServerPubFun.RISLog_Info(0, "DeleteReportDAO_MSSQL, SQL=" + sql,
                                         (new System.Diagnostics.StackFrame()).GetFileName(),
                                         (new System.Diagnostics.StackFrame()).GetFileLineNumber());

                // Delete
                tagReportInfo rptInfo = ServerPubFun.GetReportInfo(reportGuid);



                using (RisDAL dal = new RisDAL())
                {
                    DataTable dt = new DataTable();

                    dal.ExecuteQuery(sql, dt);
                }
                ServerPubFun.OnReportDelete(rptInfo, ReportCommon.RP_Status.Examination);

                //return (dt != null && dt.Rows.Count > 0);
                return(true);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.Message);

                ServerPubFun.RISLog_Error(0, "DeleteReportDAO_MSSQL=" + ex.Message,
                                          (new System.Diagnostics.StackFrame()).GetFileName(),
                                          (new System.Diagnostics.StackFrame()).GetFileLineNumber());
            }

            return("-1");
        }