Esempio n. 1
0
        private void SaveChecked()
        {
            if (_FormType == FormType.ftPKF)
            {
                _PKFields.Clear();
                for (int i = 0; i < this.listView1.Items.Count; i++)
                {
                    ListViewItem  lvi = this.listView1.Items[i];
                    GWDataDBField dbf = (GWDataDBField)lvi.Tag;

                    if (lvi.Checked)
                    {
                        _PKFields.Add(new PKField(GWDataDB.GetTableName(dbf.Table), dbf.FieldName, "AND"));
                    }
                    //_PKFields.Add(new PKField(dbf.Table.ToString(),dbf.FieldName,"AND"));
                }
            }

            if (_FormType == FormType.ftMgF)
            {
                _MergeFields.Clear();
                for (int i = 0; i < this.listView1.Items.Count; i++)
                {
                    ListViewItem  lvi = this.listView1.Items[i];
                    GWDataDBField dbf = (GWDataDBField)lvi.Tag;

                    if (lvi.Checked)
                    {
                        _MergeFields.Add(new MergeField(GWDataDB.GetTableName(dbf.Table), dbf.FieldName));
                    }
                    //_MergeFields.Add(new MergeField(dbf.Table.ToString(), dbf.FieldName));
                }
            }
        }
Esempio n. 2
0
        public void CreatPassiveSPScript(XCollection <SQLOutboundChanel> channelSet)
        {
            string interfaceName  = Program.DeviceMgt.DeviceDirInfor.Header.Name;
            string fnameInstall   = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName;
            string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName;

            //Install
            //using (StreamWriter sw = File.CreateText(fnameInstall))   // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (SQLOutboundChanel channel in channelSet)
                {
                    sb.AppendLine(channel.SPStatement);
                }
                //sw.Write(sb.ToString());
                File.WriteAllText(fnameInstall, sb.ToString(), Encoding.Unicode);
            }

            //UnInstall
            using (StreamWriter sw = File.CreateText(fnameUninstall))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (SQLOutboundChanel channel in channelSet)
                {
                    string strSql = RuleControl.GetOutboundSPUninstall(interfaceName, channel.Rule);
                    sb.AppendLine(strSql);
                }
                sw.Write(sb.ToString());
            }
        }
Esempio n. 3
0
        public static string GetUpdateString(DataGridViewColumnCollection columns, DataGridViewRow row, GWDataDBTable table)
        {
            string tableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]";

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))");
            sb.AppendLine("UPDATE " + tableName);
            sb.AppendLine("SET ");

            #region Set expression part of update script
            StringBuilder sbExp = new StringBuilder();
            int           i     = 0;
            foreach (DataGridViewColumn column in columns)
            {
                sbExp.AppendLine("[" + column.HeaderText + "] = " + "N\'" + row.Cells[i].Value.ToString().Replace("'", "''") + "\',");
                i++;
            }
            sbExp.Remove(sbExp.Length - 3, 3).ToString();
            string strExp = sbExp.ToString();
            #endregion
            sb.AppendLine(strExp);

            sb.AppendLine("WHERE");
            sb.AppendLine("[" + columns[0].HeaderText + "] = " + "\'" + row.Cells[0].Value.ToString().Replace("'", "''") + "\'");

            return(sb.ToString());
        }
Esempio n. 4
0
        public static string GetDeleteString(string guid)
        {
            string indexTablename   = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Index) + "]";
            string patientTableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]";
            string orderTableName   = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Order) + "]";
            string reportTableName  = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Report) + "]";

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Report) + "]') AND type in (N'U'))");
            sb.AppendLine("DELETE" + " FROM " + reportTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.r_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Order) + "]') AND type in (N'U'))");
            sb.AppendLine("DELETE" + " FROM " + orderTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.o_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]') AND type in (N'U'))");
            sb.AppendLine("DELETE" + " FROM " + patientTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.p_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Index) + "]') AND type in (N'U'))");
            sb.AppendLine("DELETE" + " FROM " + indexTablename);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.i_IndexGuid) + " = " + "\'" + guid + "\'");

            return(sb.ToString());
        }
Esempio n. 5
0
        //All matched tables
        public static string GetTablesString(string guid)
        {
            string patientTableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]";
            string orderTableName   = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Order) + "]";
            string reportTableName  = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Report) + "]";

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);
            //sb.AppendLine("");

            //sb.AppendLine("SET ANSI_NULLS ON");
            //sb.AppendLine("SET QUOTED_IDENTIFIER ON");
            //sb.AppendLine("");

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]') AND type in (N'U'))");
            sb.AppendLine("SELECT " + patientTableName + ".* FROM " + patientTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.p_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]') AND type in (N'U'))");
            sb.AppendLine("SELECT " + orderTableName + ".* FROM " + orderTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.o_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]') AND type in (N'U'))");
            sb.AppendLine("SELECT " + reportTableName + ".* FROM " + reportTableName);
            sb.AppendLine("WHERE " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.r_DATA_ID) + " = " + "\'" + guid + "\'");
            sb.AppendLine("");

            return(sb.ToString());
        }
Esempio n. 6
0
        private bool DispatchMessage_Custom(DataRow dataRow, ref string strResponse)
        {
            string strFieldName      = GWDataDB.GetTableName(GWDataDB.GetTable(_entity.Context.ConfigMgr.Config.MessageDispatchConfig.TableName)) + "_" + _entity.Context.ConfigMgr.Config.MessageDispatchConfig.FieldName;
            string strConditionValue = dataRow[strFieldName].ToString();

            string[] valueSubscribers = _entity.Context.ConfigMgr.Config.MessageDispatchConfig.ValueSubscriber.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in valueSubscribers)
            {
                if (str.Equals(strConditionValue))
                {
                    return(DispatchMessage_Publish(dataRow));
                }
            }

            string[] valueResponsers = _entity.Context.ConfigMgr.Config.MessageDispatchConfig.ValueResponser.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string str in valueResponsers)
            {
                if (str.Equals(strConditionValue))
                {
                    return(DispatchMessage_Request(dataRow, ref strResponse));
                }
            }

            _entity.Context.Log.Write(LogType.Error, "Can not determine how to dispath the following dataset according to current configuration.");
            _entity.Context.Log.Write(LogType.Error, SerializeDataRowToXml(dataRow));

            strResponse = _entity.Context.ConfigMgr.Config.GetBrokerErrorMessageContent();
            return(false);
        }
Esempio n. 7
0
        /*
         * private static void UpdateGUID(DataTable dt, DataColumn dc, string columnName, GWDataDBField field)
         * {
         *  if (dc.ColumnName == columnName)
         *  {
         *      Dictionary<string, string> rpIDs = new Dictionary<string, string>();
         *      foreach (DataRow dr in dt.Rows)
         *      {
         *          object o = dr[dc];
         *          string rpID = (o == null) ? "" : o.ToString();
         *          if (rpID.Length < 1)
         *          {
         *              string guid = DicomMappingHelper.GetGUID(dr);
         *              rpID = DHelper.GetDicomGUID();
         *              rpIDs.Add(guid, rpID);
         *              dr[dc] = rpID;
         *          }
         *      }
         *      if (rpIDs.Count > 0)
         *      {
         *          StringBuilder sb = new StringBuilder();
         *          foreach (KeyValuePair<string, string> pair in rpIDs)
         *          {
         *              string tableName = GWDataDB.GetTableName(Program.InterfaceName, GWDataDBTable.Order);
         *              string pkName = GWDataDBField.o_DATA_ID.FieldName;
         *              string fieldName = field.FieldName;
         *              sb.Append("UPDATE ").Append(tableName)
         *                  .Append(" SET ").Append(fieldName).Append(" = '").Append(pair.Value).Append("'")
         *                  .Append(" WHERE ").Append(pkName).Append(" = '").Append(pair.Key).Append("';\r\n");
         *          }
         *          if (Program.Database.DoQuery(sb.ToString()) == null)
         *          {
         *              Program.Log.Write(LogType.Error, "Update " + columnName + " into database failed.");
         *          }
         *          else
         *          {
         *              Program.Log.Write("Update " + columnName + " into database succeeded.");
         *          }
         *      }
         *  }
         * }*/

        private bool UpdateStudyInstanceUID(string sData_ID, string sStudyInstanceUID, GWDataDBField field)
        {
            try
            {
                if (field == null)
                {
                    Program.Log.Write(LogType.Error, "No StudyInstanceUID map!");
                    return(false);
                }

                string sTableName = GWDataDB.GetTableName(Program.InterfaceName, field.Table);
                string sSql       = " update " + sTableName + " set " + field.FieldName + " ='" + sStudyInstanceUID + "'" +
                                    " where data_id='" + sData_ID + "'";

                if (Program.Database.DoQuery(sSql) == null)
                {
                    Program.Log.Write(LogType.Error, "Update StudyINstanceUID into" + field.ToString() + "  failed.");
                }
                else
                {
                    Program.Log.Write(LogType.Debug, "Update StudyINstanceUID into" + field.ToString() + "  succeeded.");
                }
                return(true);
            }
            catch (Exception ex)
            {
                Program.Log.Write(LogType.Error, "Write StudyInstanceUID to GWDataDB Error:" + ex.Message);
                return(false);
            }
        }
Esempio n. 8
0
        private void RefreshTableName()
        {
            string interfaceName = this.textBoxTP.Text;

            this.textBoxTName.Text = GWDataDB.GetTableName(interfaceName, GWDataDBTable.Index)
                                     + "," + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient)
                                     + "," + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Order)
                                     + "," + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Report);
        }
Esempio n. 9
0
        private void CreateInboundSPScript(IInboundRule[] ruleList)
        {
            string interfaceName  = Program.DeviceMgt.DeviceDirInfor.Header.Name;
            string fnameInstall   = Application.StartupPath + "\\" + RuleScript.InstallSP.FileName;
            string fnameUninstall = Application.StartupPath + "\\" + RuleScript.UninstallSP.FileName;

            Program.Log.Write("Creating install storage procedure script...");
            //using (StreamWriter sw = File.CreateText(fnameInstall))     // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (IInboundRule rule in ruleList)
                {
                    string strSql = RuleControl.GetInboundSP(interfaceName, rule);
                    sb.AppendLine(strSql);

                    IRuleSupplier supplier = rule as IRuleSupplier;
                    if (supplier != null)
                    {
                        string strSqlSupplied = supplier.GetInstallDBScript();
                        if (strSqlSupplied != null)
                        {
                            sb.AppendLine(strSqlSupplied);
                        }
                    }
                }
                //sw.Write(sb.ToString());
                File.WriteAllText(fnameInstall, sb.ToString(), Encoding.Unicode);
            }
            Program.Log.Write("Create install storage procedure script succeeded. " + fnameInstall);

            Program.Log.Write("Creating uninstall storage procedure script...");
            using (StreamWriter sw = File.CreateText(fnameUninstall))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (IInboundRule rule in ruleList)
                {
                    string strSql = RuleControl.GetInboundSPUninstall(interfaceName, rule);
                    sb.AppendLine(strSql);

                    IRuleSupplier supplier = rule as IRuleSupplier;
                    if (supplier != null)
                    {
                        string strSqlSupplied = supplier.GetUninstallDBScript();
                        if (strSqlSupplied != null)
                        {
                            sb.AppendLine(strSqlSupplied);
                        }
                    }
                }
                sw.Write(sb.ToString());
            }
            Program.Log.Write("Create uninstall storage procedure script succeeded. " + fnameUninstall);
        }
Esempio n. 10
0
        private static void UpdateGUID(DataTable dt, DataColumn dc, string columnName, GWDataDBField field)
        {
            if (dc.ColumnName == columnName)
            {
                Dictionary <string, string> rpIDs = new Dictionary <string, string>();
                foreach (DataRow dr in dt.Rows)
                {
                    object o    = dr[dc];
                    string rpID = (o == null) ? "" : o.ToString();
                    if (rpID.Length < 1)    // need to generate GUID
                    {
                        string guid = DicomMappingHelper.GetGUID(dr);
                        if (rpIDs.ContainsKey(guid))
                        {
                            // 20100222
                            // has already generated GUID in this loop,
                            // for example there are two records with same guid and splitted according to multiple procedure codes

                            // 20100227
                            // as we move the auto generating STDUID before the procedure code spliting in the class Kodak.GCGateway.DicomAdapter.MWLServer.Dicom.WorklistSCP,
                            // this (different records with the same guid/data_id) will not happen any more.

                            rpID = rpIDs[guid];
                        }
                        else
                        {
                            rpID = DHelper.GetDicomGUID(Program.DeviceMgt.DeviceDirInfor.Header.ID, Program.ConfigMgt.Config.MaxAutoGeneratedLengthOfSTDUID);
                            rpIDs.Add(guid, rpID);
                        }
                        dr[dc] = rpID;
                    }
                }
                if (rpIDs.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (KeyValuePair <string, string> pair in rpIDs)
                    {
                        string tableName = GWDataDB.GetTableName(Program.InterfaceName, GWDataDBTable.Order);
                        string pkName    = GWDataDBField.o_DATA_ID.FieldName;
                        string fieldName = field.FieldName;
                        sb.Append("UPDATE ").Append(tableName)
                        .Append(" SET ").Append(fieldName).Append(" = '").Append(pair.Value).Append("'")
                        .Append(" WHERE ").Append(pkName).Append(" = '").Append(pair.Key).Append("';\r\n");
                    }
                    if (Program.Database.DoQuery(sb.ToString()) == null)
                    {
                        Program.Log.Write(LogType.Error, "Update " + columnName + " into database failed.");
                    }
                    else
                    {
                        Program.Log.Write("Update " + columnName + " into database succeeded.");
                    }
                }
            }
        }
Esempio n. 11
0
        public static string GetHeadersQueryString(GWDataDBTable table)
        {
            string tableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]";

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))");
            sb.AppendLine("SELECT TOP 0" + " * FROM " + tableName);

            return(sb.ToString());
        }
Esempio n. 12
0
        private static void UpdateID(DataTable dt, DataColumn dc, string columnName, GWDataDBField field)
        {
            if (dc.ColumnName == columnName)
            {
                Dictionary <string, string> rpIDs = new Dictionary <string, string>();
                foreach (DataRow dr in dt.Rows)
                {
                    object o    = dr[dc];
                    string rpID = (o == null) ? "" : o.ToString();
                    if (rpID.Length < 1)
                    {
                        string guid = DicomMappingHelper.GetGUID(dr);
                        if (rpIDs.ContainsKey(guid))
                        {
                            // 20100222
                            // please see the function UpdateGUID() for details

                            rpID = rpIDs[guid];
                        }
                        else
                        {
                            rpID = GetRandomNumber(Program.ConfigMgt.Config.MaxAutoGeneratedLengthOfRPIDAndSPSID).ToString();
                            rpIDs.Add(guid, rpID);
                        }
                        dr[dc] = rpID;
                    }
                }
                if (rpIDs.Count > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (KeyValuePair <string, string> pair in rpIDs)
                    {
                        string tableName = GWDataDB.GetTableName(Program.InterfaceName, GWDataDBTable.Order);
                        string pkName    = GWDataDBField.o_DATA_ID.FieldName;
                        string fieldName = field.FieldName;
                        sb.Append("UPDATE ").Append(tableName)
                        .Append(" SET ").Append(fieldName).Append(" = '").Append(pair.Value).Append("'")
                        .Append(" WHERE ").Append(pkName).Append(" = '").Append(pair.Key).Append("';\r\n");
                    }
                    //Program.Log.Write(sb.ToString());
                    if (Program.Database.DoQuery(sb.ToString()) == null)
                    {
                        Program.Log.Write(LogType.Error, "Update " + columnName + " into database failed.");
                    }
                    else
                    {
                        Program.Log.Write("Update " + columnName + " into database succeeded.");
                    }
                }
            }
        }
Esempio n. 13
0
        public void Initialize(string dataDBConnectionString, Logging log)
        {
            _dbConnection = new DataBase(dataDBConnectionString);
            LoggingHelper.EnableDatabaseLogging(_dbConnection, log);

            string[] tableList = GWDataDB.GetTableNames();
            foreach (string table in tableList)
            {
                _comboTable.Items.Add(table);
            }
            if (_comboTable.Items.Count > 0)
            {
                _comboTable.SelectedIndex = 0;
            }
        }
Esempio n. 14
0
 private void CheckFields(MergeFields mgfs)
 {
     for (int i = 0; i < listView1.Items.Count; i++)
     {
         GWDataDBField dbf = (GWDataDBField)listView1.Items[i].Tag;
         //if (mgfs.FindField(dbf.Table.ToString(), dbf.FieldName) != null)
         if (mgfs.FindField(GWDataDB.GetTableName(dbf.Table), dbf.FieldName) != null)
         {
             this.listView1.Items[i].Checked = true;
         }
         else
         {
             this.listView1.Items[i].Checked = false;
         }
     }
 }
Esempio n. 15
0
        //Just one table form patient, order or report
        public static string GetSelectRecordString(string guid, GWDataDBTable table)
        {
            string tableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]";

            StringBuilder sb = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))");
            sb.AppendLine("SELECT " + " * FROM " + tableName);
            sb.AppendLine("WHERE");

            #region Get Field Name
            string fieldname = "";
            switch (table)
            {
            case GWDataDBTable.Index:
            {
                fieldname = GWDataDBField.i_IndexGuid.FieldName;
                break;
            }

            case GWDataDBTable.Patient:
            {
                fieldname = GWDataDBField.p_DATA_ID.FieldName;
                break;
            }

            case GWDataDBTable.Order:
            {
                fieldname = GWDataDBField.o_DATA_ID.FieldName;
                break;
            }

            case GWDataDBTable.Report:
            {
                fieldname = GWDataDBField.r_DATA_ID.FieldName;
                break;
            }
            }
            #endregion

            sb.AppendLine("[" + fieldname + "] = " + "\'" + guid + "\'");

            return(sb.ToString());
        }
Esempio n. 16
0
        public static string GetAddString(DataGridViewColumnCollection columns, DataGridViewRow row, GWDataDBTable table)
        {
            if (table == GWDataDBTable.None)
            {
                return(null);
            }

            string        tablename = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]";
            StringBuilder sb        = new StringBuilder();

            //sb.AppendLine("USE " + GWDataDB.DataBaseName);

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))");
            sb.AppendLine("INSERT INTO " + tablename);

            #region Fields
            StringBuilder sbField = new StringBuilder();
            foreach (DataGridViewColumn column in columns)
            {
                sbField.Append("[" + column.HeaderText + "]" + ",");
            }

            string strField = sbField.ToString();
            if (strField.Length > 0)
            {
                strField = strField.TrimEnd(',');
            }
            sb.AppendLine("			( "+ strField + " )");
            #endregion
            sb.AppendLine("			VALUES");
            #region Values
            StringBuilder sbValue = new StringBuilder();
            foreach (DataGridViewCell cell in row.Cells)
            {
                sbValue.Append("N\'" + cell.Value.ToString().Replace("'", "''") + "\'" + ",");
            }
            string strValue = sbValue.ToString();
            if (strValue.Length > 0)
            {
                strValue = strValue.TrimEnd(',');
            }
            sb.AppendLine("			( "+ strValue + " )");
            #endregion

            return(sb.ToString());
        }
Esempio n. 17
0
        private void CreateLookupTableScript(LookupTable[] tableList)
        {
            if (tableList == null)
            {
                Program.Log.Write(LogType.Warning, "LookupTable array is NULL, do not create any private look up table.");
                return;
            }

            string installTable   = Application.StartupPath + "\\" + RuleScript.InstallLUT.FileName;
            string uninstallTable = Application.StartupPath + "\\" + RuleScript.UninstallLUT.FileName;

            Program.Log.Write("Creating install private look up table script...");
            //using (StreamWriter sw = File.CreateText(installTable))   // 20110706 OSQL & SQLMgmtStudio only support ASCII and UNICODE
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (LookupTable table in tableList)
                {
                    string strSql = RuleControl.GetCreateLUTSQL(table);
                    sb.AppendLine(strSql);
                }
                //sw.Write(sb.ToString());
                File.WriteAllText(installTable, sb.ToString(), Encoding.Unicode);
            }
            Program.Log.Write("Create install private look up table script succeeded. " + installTable);

            Program.Log.Write("Creating uninstall private look up table script...");
            using (StreamWriter sw = File.CreateText(uninstallTable))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(GWDataDB.GetUseDataBaseSql());
                foreach (LookupTable table in tableList)
                {
                    string strSql = RuleControl.GetDropLUTSQL(table);
                    sb.AppendLine(strSql);
                }
                sw.Write(sb.ToString());
            }
            Program.Log.Write("Create uninstall private look up table script succeeded. " + uninstallTable);
        }
Esempio n. 18
0
 protected virtual string[] GetTableList()
 {
     return(GWDataDB.GetTableNames());
 }
Esempio n. 19
0
        //private static Mutex _mutex = new Mutex();

        //protected static bool LockDatabase()
        //{
        //    if (_mutex.WaitOne(Program.ConfigMgt.Config.MutexTimeOut, true)) return true;
        //    Program.Log.Write(LogType.Error, "Mutex time out! (" + Program.ConfigMgt.Config.MutexTimeOut.ToString() + "ms)");
        //    return false;
        //}

        //protected static void ReleaseDatabase()
        //{
        //    _mutex.ReleaseMutex();
        //}

        public static string GetSPName(IRule rule)
        {
            return(GWDataDB.GetSPName(Program.DeviceMgt.DeviceDirInfor.Header.Name, rule));
        }
Esempio n. 20
0
        public static string GetFilterString(SimpleQuery queryInfo, XCollection <QueryCriteriaItem> filterItemList)
        {
            //Get interface name from configuration file
            string indexTablename   = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Index) + "]";
            string patientTableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Patient) + "]";
            string orderTableName   = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Order) + "]";
            string reportTableName  = "[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Report) + "]";

            #region Query Head
            StringBuilder sb = new StringBuilder();
            //sb.AppendLine("USE " + GWDataDB.DataBaseName);
            //sb.AppendLine("");

            //sb.AppendLine("SET ANSI_NULLS ON");
            //sb.AppendLine("SET QUOTED_IDENTIFIER ON");
            //sb.AppendLine("");

            //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, GWDataDBTable.Index) + "]') AND type in (N'U'))");

            sb.AppendLine("SELECT");
            sb.AppendLine("\t" + indexTablename + ".* FROM " + indexTablename);
            sb.AppendLine("\tLEFT JOIN " + patientTableName + " ON " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.p_DATA_ID) + " = " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.i_IndexGuid));
            sb.AppendLine("\tLEFT JOIN " + orderTableName + " ON " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.o_DATA_ID) + " = " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.i_IndexGuid));
            sb.AppendLine("\tLEFT JOIN " + reportTableName + " ON " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.r_DATA_ID) + " = " + GWDBControl.GetFullFieldName(interfaceName, GWDataDBField.i_IndexGuid));
            #endregion

            #region Query Condition
            if (queryInfo != null || filterItemList != null)
            {
                StringBuilder sbWhere = new StringBuilder();

                if (queryInfo != null)
                {
                    #region Simple Query
                    if (queryInfo.EventType.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.EventType.Fieldname) + " like " + "\'%" + queryInfo.EventType.FieldValue.Replace("'", "''") + "%\'");
                    }
                    if (queryInfo.StartTime.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.StartTime.Fieldname) + " >= " + "\'" + queryInfo.StartTime.FieldValue.Replace("'", "''") + "\'");
                    }
                    if (queryInfo.EndTime.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.EndTime.Fieldname) + " <= " + "\'" + queryInfo.EndTime.FieldValue.Replace("'", "''") + "\'");
                    }
                    if (queryInfo.PatientID.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.PatientID.Fieldname) + " like " + "\'%" + queryInfo.PatientID.FieldValue.Replace("'", "''") + "%\'");
                    }
                    if (queryInfo.PatientName.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.PatientName.Fieldname) + " like " + "\'%" + queryInfo.PatientName.FieldValue.Replace("'", "''") + "%\'");
                    }
                    if (queryInfo.OrderNo.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.OrderNo.Fieldname) + " like " + "\'%" + queryInfo.OrderNo.FieldValue.Replace("'", "''") + "%\'");
                    }
                    if (queryInfo.AccessionNo.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.AccessionNo.Fieldname) + " like " + "\'%" + queryInfo.AccessionNo.FieldValue.Replace("'", "''") + "%\'");
                    }
                    if (queryInfo.StudyInstanceUID.Enable)
                    {
                        sbWhere.AppendLine("\tAND " + GWDBControl.GetFullFieldName(interfaceName, queryInfo.StudyInstanceUID.Fieldname) + " like " + "\'%" + queryInfo.StudyInstanceUID.FieldValue.Replace("'", "''") + "%\'");
                    }
                    #endregion
                }
                else
                {
                    #region Advanced Query
                    foreach (QueryCriteriaItem filterItem in filterItemList)
                    {
                        if (filterItem.Type == QueryCriteriaType.Or)
                        {
                            sbWhere.Append("\t OR ");
                        }
                        else
                        {
                            sbWhere.Append("\tAND ");
                        }

                        string fname = GWDBControl.GetFullFieldName(interfaceName, filterItem.GWDataDBField);
                        switch (filterItem.Operator)
                        {
                        case QueryCriteriaOperator.Like:
                        {
                            sbWhere.AppendLine(fname + " LIKE " + "\'%" + filterItem.Translating.ConstValue + "%\'");
                            break;
                        }

                        case QueryCriteriaOperator.Equal:
                        {
                            sbWhere.AppendLine(fname + " = " + "\'" + filterItem.Translating.ConstValue + "\'");
                            break;
                        }

                        case QueryCriteriaOperator.NotEqual:
                        {
                            sbWhere.AppendLine("(" + fname + " <> " + "\'" + filterItem.Translating.ConstValue + "\'" + " OR " + fname + " IS NULL)");
                            break;
                        }

                        case QueryCriteriaOperator.LargerThan:
                        {
                            sbWhere.AppendLine(fname + " > " + "\'" + filterItem.Translating.ConstValue + "\'");
                            break;
                        }

                        case QueryCriteriaOperator.SmallerThan:
                        {
                            sbWhere.AppendLine(fname + " < " + "\'" + filterItem.Translating.ConstValue + "\'");
                            break;
                        }

                        case QueryCriteriaOperator.EqualLargerThan:
                        {
                            sbWhere.AppendLine(fname + " >= " + "\'" + filterItem.Translating.ConstValue + "\'");
                            break;
                        }

                        case QueryCriteriaOperator.EqualSmallerThan:
                        {
                            sbWhere.AppendLine(fname + " <= " + "\'" + filterItem.Translating.ConstValue + "\'");
                            break;
                        }
                        }
                    }
                    #endregion
                }

                if (sbWhere.Length > 4)
                {
                    sbWhere.Remove(1, 4);
                    sb.AppendLine("WHERE");
                    sb.AppendLine(sbWhere.ToString());
                }
            }
            #endregion

            sb.AppendLine(" ORDER BY " + GWDataDBField.i_DataDateTime.GetFullFieldName(interfaceName));

            return(sb.ToString());
        }
Esempio n. 21
0
        private GWDataDBTable GetTable()
        {
            string str = _comboTable.SelectedItem as string;

            return(GWDataDB.GetTable(str));
        }
Esempio n. 22
0
        public GWDataDBTable GetTable()
        {
            string str = this.comboBoxTable.SelectedItem as string;

            return(GWDataDB.GetTable(str));
        }