Пример #1
0
        public static DataSet ExecuteSQLServerAdoQuery(string queryString, SqlParameter[] ParaList, string connectionString)
        {
            DataSet dataset = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand(queryString, conn);

                    using (SqlDataAdapter dadp = new SqlDataAdapter(cmd))
                    {
                        if (ParaList != null)
                        {
                            foreach (SqlParameter para in ParaList)
                            {
                                para.Value = para.Value == null ? DBNull.Value : para.Value;
                                cmd.Parameters.Add(para);
                            }
                        }
                        conn.Open();
                        // dadp.SelectCommand = cmd;
                        dadp.Fill(dataset);
                    }
                }
            }
            catch (Exception ex)
            {
                Log4NetLogger.GetLogger().Error(ex.Message);
                throw;
            }
            return(dataset);
        }
Пример #2
0
        public static DataSet ExecuteQuery(string queryString, SqlParameter[] ParaList, CommandType commandType)
        {
            DataSet dataset = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionStringSettings))
                {
                    SqlDataAdapter dadp = new SqlDataAdapter();
                    SqlCommand     cmd  = new SqlCommand(queryString, conn);
                    cmd.CommandType = commandType;
                    if (ParaList != null)
                    {
                        foreach (SqlParameter para in ParaList)
                        {
                            para.Value = para.Value == null ? DBNull.Value : para.Value;
                            cmd.Parameters.Add(para);
                        }
                    }
                    dadp.SelectCommand = cmd;
                    dadp.Fill(dataset);
                }
            }
            catch (Exception ex)
            {
                Log4NetLogger.GetLogger().Error(ex.Message);
                throw;
            }

            return(dataset);
        }
Пример #3
0
 // Basic Method Here
 public static int ExecuteNonQuery(string strSql, SqlParameter[] ParaList, CommandType commandType)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(ConnectionStringSettings))
         {
             SqlCommand cmd = new SqlCommand();
             cmd.CommandText = strSql;
             cmd.CommandType = commandType;
             cmd.Connection  = conn;
             conn.Open();
             if (ParaList != null)
             {
                 foreach (SqlParameter para in ParaList)
                 {
                     para.Value = para.Value == null ? DBNull.Value : para.Value;
                     cmd.Parameters.Add(para);
                 }
             }
             int iret = cmd.ExecuteNonQuery();
             conn.Close();
             return(iret);
         }
     }
     catch (Exception ex)
     {
         Log4NetLogger.GetLogger().Error(ex.Message);
         throw;
     }
 }
Пример #4
0
        /// <summary>
        /// Remove the old, unnecessary files
        /// </summary>
        private void TempImgLRU()
        {
            int nLURInterval       = 30;  // LUR every ? seconds
            int nMaxFilesCount     = 100; // Only LRU when files count exceed this threshold
            int nMaxExpiredMinutes = 30;  // Only delete the files expired with specified minutes

            string strTempFolder = Yiyou.Util.ImageUtils.GetTempFolderPath();

            while (System.IO.Directory.Exists(strTempFolder))
            {
                try
                {
                    string[] FileList = System.IO.Directory.GetFiles(strTempFolder, "*.*", System.IO.SearchOption.AllDirectories);
                    if (FileList.Length > nMaxFilesCount)
                    {
                        foreach (string filePath in FileList)
                        {
                            System.IO.FileInfo fi = new System.IO.FileInfo(filePath);
                            if (fi.LastAccessTime.AddMinutes(nMaxExpiredMinutes) < DateTime.Now)
                            {
                                fi.Attributes = System.IO.FileAttributes.Normal;
                                fi.Delete();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log4NetLogger.GetLogger().Info("LRU failed: " + ex.StackTrace);
                }

                System.Threading.Thread.Sleep(nLURInterval * 1000);
            }
        }
Пример #5
0
        private bool SaveApplication()
        {
            try
            {
                ApplicationAllInOneMdl totalMdl = this.GetMdlFromGUI();
                Consult_ApplicationMdl mdl      = totalMdl.Consult_ApplicationMdl;
                Consult_ApplicationDAL dal      = new Consult_ApplicationDAL();

                // Save/Update the Patient info first
                #region MyRegion
                string patient_guid = EMR_PatientMdlDAL.GetPatientGUID(totalMdl.EMR_PatientMdl.name, totalMdl.EMR_PatientMdl.user_guid);
                if (string.IsNullOrEmpty(patient_guid))
                {
                    // New
                    totalMdl.EMR_PatientMdl.patient_guid         = Guid.NewGuid().ToString();            // Create new GUID
                    totalMdl.Consult_ApplicationMdl.patient_guid = totalMdl.EMR_PatientMdl.patient_guid; // Copy GUID
                    EMR_PatientMdlDAL.Add(totalMdl.EMR_PatientMdl);
                }
                else
                {
                    // Update
                    totalMdl.EMR_PatientMdl.patient_guid         = patient_guid;                         // Create new GUID
                    totalMdl.Consult_ApplicationMdl.patient_guid = totalMdl.EMR_PatientMdl.patient_guid; // Copy GUID
                    EMR_PatientMdlDAL.Update(totalMdl.EMR_PatientMdl);
                }
                #endregion


                // Continue save the others info
                if (!dal.IsExist(mdl.guid))
                {
                    // Add Consult_ApplicationMdl
                    dal.Add_consult_application(mdl);
                    // Add consult_application_consultant
                    dal.Add_consult_application_consultant(totalMdl.Consult_Application_ConsultantMdlCollection);
                    // Add the Purpose Image
                    dal.Add_consult_application_accessory(totalMdl.consult_application_accessoryMdl);

                    return(true);
                }
                else
                {
                    // Update Consult_ApplicationMdl
                    dal.Update_consult_application(mdl);
                    // Update consult_application_consultant
                    dal.Update_consult_application_consultant(totalMdl.Consult_Application_ConsultantMdlCollection);
                    // Update the Purpose Image
                    dal.Update_consult_application_accessory(totalMdl.consult_application_accessoryMdl);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Log4NetLogger.GetLogger().Error(ex.Message);
                this.lblErrorMsg.Text = ex.Message;
            }
            return(false);
        }
Пример #6
0
        private ILogger CreateGlobalLoggerForService(string instanceName)
        {
            Constraint.MustNotBeNull(Configuration, "Configuration");

            var logFilePath = Configuration.GetStringValue(GlobalSettings.Keys.LogFilePath);

            // ReSharper disable once AssignNullToNotNullAttribute
            logFilePath = string.Format(logFilePath, string.Format(".{0}", instanceName));
            logFilePath = PathHelp.RootPathIfRelative(logFilePath, AppDomain.CurrentDomain.BaseDirectory);
            return(Log4NetLogger.GetLogger(ExeAppSettings.FilePath,
                                           Appenders.Trace(),
                                           Appenders.ColouredConsole(),
                                           Appenders.EventLog(EventLogSource),
                                           Appenders.RollingFile(logFilePath, true)));
        }
Пример #7
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);


            // Code that runs on application startup
            Log4NetLogger.GetLogger().Info("Application_Start....");
            SqlHelper.ConnectionStringSettings = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
            Log4NetLogger.GetLogger().Info("ConnectionStringSettings: " + SqlHelper.ConnectionStringSettings);

            System.Threading.Thread t = new System.Threading.Thread(TempImgLRU);
            t.Start();
        }
Пример #8
0
        // Basic Method Here
        public static int ExecuteNonQuery(List <SqlWrapper> lstSql)
        {
            try
            {
                int iret = 0;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (SqlConnection conn = new SqlConnection(ConnectionStringSettings))
                    {
                        SqlCommand cmd = new SqlCommand();
                        cmd.Connection = conn;
                        conn.Open();
                        foreach (SqlWrapper sql in lstSql)
                        {
                            try
                            {
                                cmd.CommandText = sql.SqlString;
                                cmd.Parameters.Clear();
                                if (sql.Parameter != null)
                                {
                                    foreach (SqlParameter para in sql.Parameter)
                                    {
                                        para.Value = para.Value == null ? DBNull.Value : para.Value;
                                        cmd.Parameters.Add(para);
                                    }
                                }
                                iret += cmd.ExecuteNonQuery();
                            }
                            catch (Exception ex)
                            {
                                Log4NetLogger.GetLogger().Error(ex.Message);
                                throw;
                            }
                        }
                        conn.Close();
                    }
                    scope.Complete();
                    return(iret);
                }
            }
            catch
            {
                throw;
            }
        }
Пример #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             this.InitCtrl();
         }
         else
         {
             this.CreateDropdownListGroup();
         }
     }
     catch (Exception ex)
     {
         Log4NetLogger.GetLogger().Error(ex.Message);
         this.lblErrorMsg.Text = ex.Message;
     }
 }
Пример #10
0
        // Basic Method Here
        public static DataSet ExecuteAdapter(string queryString, string tableName)
        {
            DataSet dataset = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionStringSettings))
                {
                    SqlDataAdapter adapter = new SqlDataAdapter(queryString, conn);
                    adapter.Fill(dataset, tableName);
                }
            }
            catch (Exception ex)
            {
                Log4NetLogger.GetLogger().Error(ex.Message);
                throw;
            }

            return(dataset);
        }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static ILog StaticLogger(System.Type type)
 {
     return(Log4NetLogger.GetLogger(type));
 }
Пример #12
0
 /// <summary>
 /// Logger's constructor using the given type as logger name
 /// </summary>
 /// <param name="type"></param>
 public LoggerBase(System.Type type)
 {
     Logger = Log4NetLogger.GetLogger(type);
 }
Пример #13
0
 /// <summary>
 /// Construct the Logger, using the log4net.config file as configurator
 /// </summary>
 public LoggerBase()
 {
     Logger = Log4NetLogger.GetLogger(GetType());
 }