예제 #1
0
        void ProcessExcel(string path)
        {
            AssertThat.IsNotNullOrEmpty(path);
            var excelApp  = new Application();
            var workbooks = excelApp.Workbooks.Open(path);

            try
            {
                int pageCount = workbooks.Sheets.Count;
                AssertThat.IsTrue(pageCount > 1, "Excel's page count MUST > 1");
                var sheet = workbooks.Sheets[2];
                AssertThat.IsNotNull(sheet, "Excel's sheet is null");
                Worksheet worksheet = sheet as Worksheet;
                AssertThat.IsNotNull(sheet, "Excel's worksheet is null");

                var usedRange = worksheet.UsedRange;
                var name      = Path.GetFileNameWithoutExtension(path);
                new ProtoGenerator(name, usedRange).Process();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                workbooks.Close();
                excelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            }
        }
예제 #2
0
        /// <summary>
        /// Connect to server
        /// </summary>
        /// <param name="ip">ipv4/ipv6</param>
        /// <param name="port"></param>
        public void Connect(string ip, int port)
        {
            AssertThat.IsNotNullOrEmpty(ip);
            var iep = new IPEndPoint(IPAddress.Parse(ip), port);

            Connect(iep);
        }
예제 #3
0
 /// <summary>
 /// Connect to server
 /// </summary>
 /// <param name="ip">ipv4/ipv6</param>
 /// <param name="port"></param>
 public void Connect(string ip, int port)
 {
     lock (_locker)
     {
         AssertThat.IsNotNullOrEmpty(ip, "ip is null or empty");
         var iep = new IPEndPoint(IPAddress.Parse(ip), port);
         Connect(iep);
     }
 }
예제 #4
0
        void ProcessExcel(string path)
        {
            AssertThat.IsNotNullOrEmpty(path);
            var fileInfo = new FileInfo(path);

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            using (ExcelPackage excelPackage = new ExcelPackage(fileInfo))
            {
                var count     = excelPackage.Workbook.Worksheets.Count;
                var worksheet = excelPackage.Workbook.Worksheets[0];
                AssertThat.IsNotNull(worksheet, "Excel's sheet is null");
                var rowCount    = worksheet.Dimension.Rows;
                var columnCount = worksheet.Dimension.Columns;
                var name        = Path.GetFileNameWithoutExtension(path);
                new ProtoGenerater(name, rowCount, columnCount, worksheet).Process();
            }
        }
예제 #5
0
        void ProcessExcel(string excelFilePath)
        {
            AssertThat.IsNotNullOrEmpty(excelFilePath);
            var excelApp  = new Application();
            var workbooks = excelApp.Workbooks.Open(excelFilePath);

            try
            {
                var sheet = workbooks.Sheets[1];
                AssertThat.IsNotNull(sheet, "Excel's sheet is null");
                Worksheet worksheet = sheet as Worksheet;
                AssertThat.IsNotNull(sheet, "Excel's worksheet is null");
                var usedRange = worksheet.UsedRange;
                //int rowCount = usedRange.Rows.Count;
                //int colCount = usedRange.Columns.Count;
                //for (int i = 1; i <= rowCount; i++)
                //{
                //    for (int j = 1; j <= colCount; j++)
                //    {
                //        var value = ((Range)usedRange.Cells[i, j]).Value2;
                //        var str = value.ToString();
                //    }
                //}
                var protoName = Path.GetFileNameWithoutExtension(excelFilePath);
                new ProtoGenerator(protoName, usedRange).Generate();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                workbooks.Close();
                excelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
            }
        }
예제 #6
0
 public void RemovePlugin(string name)
 {
     AssertThat.IsNotNullOrEmpty(name);
     plugins.Remove(name);
 }
예제 #7
0
 public IPlugin GetPlugin(string name)
 {
     AssertThat.IsNotNullOrEmpty(name);
     return(plugins[name]);
 }
예제 #8
0
 /// <summary>
 /// Remove plugin
 /// </summary>
 /// <param name="name">plugin's name</param>
 public void RemovePlugin(string name)
 {
     AssertThat.IsNotNullOrEmpty(name, "Name is null or empty");
     _plugins.Remove(name);
 }
예제 #9
0
 public bool IsPluginExist(string name)
 {
     AssertThat.IsNotNullOrEmpty(name, "Name is null or empty");
     return(_plugins.ContainsKey(name));
 }
예제 #10
0
 /// <summary>
 /// Get plugin by name
 /// </summary>
 /// <param name="name">plugin's name</param>
 /// <returns>plugin</returns>
 public IPlugin GetPlugin(string name)
 {
     AssertThat.IsNotNullOrEmpty(name, "Name is null or empty");
     return(_plugins[name]);
 }
예제 #11
0
 /// <summary>
 /// Dispatch message from socket
 /// </summary>
 /// <param name="key"></param>
 /// <param name="bytes"></param>
 public static void Dispatch(string key, byte[] bytes)
 {
     AssertThat.IsNotNullOrEmpty(key);
     AssertThat.IsTrue(_msgs.ContainsKey(key));
     _msgs[key].OnBytes(bytes);
 }