장비관리를 별도의 프로젝트로 분리 -
개별 프로젝트 참조를 위한 뼈대 생성 - 공용은 fcommon 으로 이 관
This commit is contained in:
		
							
								
								
									
										135
									
								
								Project/Util.cs
									
									
									
									
									
								
							
							
						
						
									
										135
									
								
								Project/Util.cs
									
									
									
									
									
								
							| @@ -1,4 +1,9 @@ | ||||
| //180624    chi isLocalApplication 추가 | ||||
| //190806    chi getWorkWeek 추가 | ||||
| //190805    chi MakeCSVString 추가 | ||||
| //180903    chi makefilepath/ ftppath 추가 | ||||
| //180807    chi rad2deg, deg2rad 추가 | ||||
| //180625    chi  ToCharHexString,ToStringFromHexString 추가 | ||||
| //180624    chi isLocalApplication 추가 | ||||
| //180618    chi GetCSVBuffer 추가 | ||||
| //180614    chi map 명령어 추가 | ||||
| using System; | ||||
| @@ -15,6 +20,96 @@ namespace Project | ||||
| { | ||||
|     public static class Util | ||||
|     { | ||||
|  | ||||
|         public static int GetWorkWeek() | ||||
|         { | ||||
|             return GetWorkWeek(DateTime.Now); | ||||
|         } | ||||
|         public static int GetWorkWeek(DateTime date) | ||||
|         { | ||||
|             var dfi = System.Globalization.DateTimeFormatInfo.CurrentInfo; | ||||
|             var date1 = date; | ||||
|             var cal = dfi.Calendar; | ||||
|             var week = cal.GetWeekOfYear(date1, dfi.CalendarWeekRule, dfi.FirstDayOfWeek); | ||||
|             return week; | ||||
|         } | ||||
|  | ||||
|         public static string MakeFilePath(params string[] param) | ||||
|         { | ||||
|             System.Text.StringBuilder sb = new System.Text.StringBuilder(); | ||||
|             foreach (var item in param) | ||||
|             { | ||||
|                 if (sb.Length > 0 && sb.ToString().EndsWith("\\") == false) sb.Append("\\"); | ||||
|                 sb.Append(item.Replace("/", "\\")); | ||||
|             } | ||||
|             var retval = sb.ToString().Replace("/", "\\").Replace("\\\\", "\\"); | ||||
|             return retval.ToString(); | ||||
|         } | ||||
|  | ||||
|         public static string MakeFTPPath(params string[] param) | ||||
|         { | ||||
|             System.Text.StringBuilder sb = new System.Text.StringBuilder(); | ||||
|             foreach (var item in param) | ||||
|             { | ||||
|                 if (sb.Length > 0 && sb.ToString().EndsWith("/") == false) sb.Append("/"); | ||||
|                 sb.Append(item.Replace("\\", "/")); | ||||
|             } | ||||
|             var retval = sb.ToString().Replace("//", "/"); | ||||
|             return retval.ToString(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         public static double rad2Deg(double source) | ||||
|         { | ||||
|             return (source * 1.0) * 180.0 / Math.PI; | ||||
|         } | ||||
|         public static double deg2rad(double source) | ||||
|         { | ||||
|             return (source * 1.0) * Math.PI / 180.0; | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 문자를 HEX 문자로 변경합니다. 각 HEX문자 사이에는 공백이 없습니다. | ||||
|         /// </summary> | ||||
|         /// <param name="input"></param> | ||||
|         /// <returns></returns> | ||||
|         public static string ToCharHexString(string input) | ||||
|         { | ||||
|             System.Text.StringBuilder sb = new System.Text.StringBuilder(); | ||||
|             foreach (char b in input.ToCharArray()) | ||||
|                 sb.Append(((byte)b).ToString("X2")); | ||||
|             return sb.ToString(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 16진수형태의 문자를 일반 문자열로 반환한니다. | ||||
|         /// </summary> | ||||
|         /// <param name="input"></param> | ||||
|         /// <returns></returns> | ||||
|         public static string ToStringFromHexString(string input) | ||||
|         { | ||||
|             int wordCount = (int)(input.Length / 2); | ||||
|             int n = (int)(input.Length % 2); | ||||
|             if (n != 0) return "X:Length Error"; | ||||
|  | ||||
|             System.Text.StringBuilder sb = new StringBuilder(); | ||||
|             for (int i = 0; i < wordCount; i++) | ||||
|             { | ||||
|                 string hexstr = input.Substring(i * 2, 2); | ||||
|                 try | ||||
|                 { | ||||
|                     byte ascvalue = Convert.ToByte(hexstr, 16); | ||||
|                     sb.Append((char)ascvalue); | ||||
|                 } | ||||
|                 catch (Exception ex) | ||||
|                 { | ||||
|                     return ex.Message; | ||||
|                 } | ||||
|             } | ||||
|             //두자리씩 끊어서 16진수로 변환하고 ASC값을 누적한다. | ||||
|             return sb.ToString(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 현재 프로그램이 개인용위치에서 실행중인가(클릭원스의경우) | ||||
|         /// </summary> | ||||
| @@ -25,6 +120,23 @@ namespace Project | ||||
|             return Util.CurrentPath.StartsWith(localpath); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 문자열 배열을 CSV라인으로 변환 | ||||
|         /// </summary> | ||||
|         /// <param name="param"></param> | ||||
|         /// <returns></returns> | ||||
|         public static string MakeCSVString(params string[] param) | ||||
|         { | ||||
|             System.Text.StringBuilder sb = new StringBuilder(); | ||||
|             foreach (var data in param) | ||||
|             { | ||||
|                 if (sb.Length > 0) sb.Append(','); | ||||
|                 sb.Append(ToCSVString(data)); | ||||
|             } | ||||
|             return sb.ToString(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|         /// <summary> | ||||
|         /// CSV데이터포맷으로 버퍼를 반환합니다. 문자열내에 , 가 있는 데이터는 쌍따옴표로 구분합니다. | ||||
|         /// </summary> | ||||
| @@ -39,18 +151,20 @@ namespace Project | ||||
|             bool findsig = false; | ||||
|             var charbuf = line.ToCharArray(); | ||||
|             char pchar = '\0'; | ||||
|             bool findCommaString = false; | ||||
|             foreach (var c in charbuf) | ||||
|             { | ||||
|                 if (c == ',') | ||||
|                 { | ||||
|                     if (findsig) sb.Append(c);  //대상에 콤마가 잇으므로 게소 누적한다. | ||||
|                     else | ||||
|                     else if (findCommaString == false) | ||||
|                     { | ||||
|                         //데이터를 분리해줘야함 | ||||
|                         buffer.Add(sb.ToString()); | ||||
|                         sb.Clear(); | ||||
|                         findsig = false; | ||||
|                     } | ||||
|                     else findCommaString = false; | ||||
|                 } | ||||
|                 else if (c == '\"') | ||||
|                 { | ||||
| @@ -59,7 +173,17 @@ namespace Project | ||||
|                         if (!findsig) findsig = true; | ||||
|                         else findsig = false; //완료된 경우이다. | ||||
|                     } | ||||
|                     else if (!findsig) sb.Append(c); | ||||
|                     else if (!findsig) | ||||
|                     { | ||||
|                         sb.Append(c); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         buffer.Add(sb.ToString()); | ||||
|                         sb.Clear(); | ||||
|                         findsig = false; | ||||
|                         findCommaString = true; | ||||
|                     } | ||||
|                     //if (!findsig) findsig = true; | ||||
|                     //else sb.Append(c); | ||||
|                 } | ||||
| @@ -146,13 +270,12 @@ namespace Project | ||||
|         /// <returns></returns> | ||||
|         public static string ToCSVString(string src) | ||||
|         { | ||||
|             string strdata = src.Replace("\r", "").Replace("\n", ""); | ||||
|             if (src == null) return string.Empty; | ||||
|             string strdata = strdata = src.Replace("\r", "").Replace("\n", ""); | ||||
|             if (strdata.IndexOf(',') != -1) | ||||
|             { | ||||
|                 strdata = "\"" + strdata + "\"";    //180618 콤마가들어가는 csv 처리 | ||||
|             } | ||||
|  | ||||
|  | ||||
|             return strdata; | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 chikyun.kim
					chikyun.kim