public static Stream GetResourceStream(string resourceName, string itemName)
        {
            string name   = string.Format("PreciousUI.Resources.{0}.{1}", resourceName, itemName);
            Stream stream = ResourceStreamHelper.GetStream(name, Assembly.GetExecutingAssembly());

            return(stream);
        }
        private bool InitializeDataBase(string dataDirectory, string userName, string password)
        {
            bool tmpCreateResult = false;

            var tmpSQLiteDataBase = new HuiruiSoft.Data.SQLite.GeneralSQLiteDataBase();

            tmpSQLiteDataBase.DataSource = string.Format(@"{0}\SafePassData.dat", dataDirectory);
            tmpSQLiteDataBase.Password   = Md5DigestHelper.Md5Salt(password, userName);
            tmpSQLiteDataBase.CreateDataBase();

            var tmpResourceStream = ResourceStreamHelper.GetStream("resources.database.SafePass.sql", typeof(ResourceFinder));

            if (tmpResourceStream != null)
            {
                byte[] bytes = new byte[tmpResourceStream.Length];
                tmpResourceStream.Read(bytes, 0, bytes.Length);
                string tmpCommandString = System.Text.Encoding.UTF8.GetString(bytes);

                tmpSQLiteDataBase.ExecuteNonQuery(tmpCommandString);

                var tmpRootCatalog = new AccountCatalog();
                tmpRootCatalog.Depth    = 1;
                tmpRootCatalog.ParentId = -1;
                tmpRootCatalog.Name     = this.textSafePassName.Text;

                tmpCreateResult = tmpSQLiteDataBase.CreateRootCatalog(tmpRootCatalog);
                if (tmpCreateResult)
                {
                    //
                }
            }

            return(tmpCreateResult);
        }
        public void TestMethod1()
        {
            try
            {
                string           fileName           = ResourceStreamHelper.WriteEmbeddedResourceToTempFile(m_Assembly, MNameSpaceName, ResourceName);
                IList <ExcelRow> list               = GenerateUtil.ReadSheet(fileName, "GSP", m_ColumnNames, SpreadsheetRowResolver);
                const string     PaymentDossierId   = "PaymentDossierId: ";
                const string     AffiliateSynergyID = "AffiliateSynergyID: ";
                foreach (ExcelRow excelRow in list)
                {
                    Console.WriteLine(PaymentDossierId + excelRow.PaymentDossierID);
                    Console.WriteLine(AffiliateSynergyID + excelRow.AffiliateSynergyId);
                }

                Assert.IsNotNull(list);
            }
            catch (Exception exc)
            {
                if (exc.Message.Contains(@"The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine."))
                {
                    Console.WriteLine(@"SpreadSheetTest not correctly run because there is no Microsoft.ACE.OLEDB.12.0 provider registered!");
                }
                else
                {
                    throw;
                }
            }
        }
        private bool CreateLog4NetConfig( )
        {
            bool tmpCreateResult = false;
            var  tmpConfigStream = ResourceStreamHelper.GetStream("resources.config.log4net.config", typeof(ResourceFinder));

            if (tmpConfigStream != null)
            {
                var tmpConfigDirectory = Path.Combine(Application.StartupPath, "config");
                if (!Directory.Exists(tmpConfigDirectory))
                {
                    try
                    {
                        Directory.CreateDirectory(tmpConfigDirectory);
                    }
                    catch (System.SystemException exception)
                    {
                        loger.Error(exception);
                        System.Diagnostics.Debug.WriteLine(exception.Message);
                    }
                }

                using (var tmpFileStream = new FileStream(Path.Combine(tmpConfigDirectory, "log4net.config"), FileMode.OpenOrCreate, FileAccess.Write))
                {
                    byte[] buffer = new byte[tmpConfigStream.Length];
                    tmpConfigStream.Read(buffer, 0, buffer.Length);
                    tmpFileStream.Write(buffer, 0, buffer.Length);
                    tmpFileStream.Flush();
                    tmpFileStream.Close();
                    tmpCreateResult = true;
                }
            }

            return(tmpCreateResult);
        }