string strUri_get_stripinfos = strUri + DMCMD_get_stripinfos;


            try

            {

                WebRequest wrGETURL;

                wrGETURL = WebRequest.Create(strUri_get_stripinfos);


                Stream objStream;

                objStream = wrGETURL.GetResponse().GetResponseStream();


                StreamReader objReader = new StreamReader(objStream);


                string sLine = "";

                int i = 0;


                while (sLine != null)

                {

                    i++;

                    sLine = objReader.ReadLine();

                    if (sLine != null)

                    {

                        Console.WriteLine("{0}:{1}", i, sLine);

                        if (sLine.Contains("stripinfos") == true)

                        {

                            string response = sLine.Replace("\\", "");

                            response = sLine.Replace("\"", "");

                            response = response.Replace("{", "");

                            response = response.Replace("}", "");

                            response = response.Replace("stripinfos:", "");

                            response = response.Replace("[", "");

                            response = response.Replace("]", "");

                            string[] valuelist = response.Split(',');

                            if (valuelist.Count() > 0)

                            {

                                int selectedindex = -1;

                                List<string> striplist = new List<string>();

                                stripinfolist.Clear();

                                for (int k = 0; k < valuelist.Count(); k++)

                                {

                                    string[] temp = valuelist[k].Split('/');

                                    int tempvalue = 0;

                                    StripInfo info = new StripInfo();

                                    info.lot_number = temp[0];

                                    striplist.Add(temp[0]);

                                    if (temp.Length > 1 && temp[1] == "true")

                                    {

                                        selectedindex = k;

                                        info.aisdefaultatportable = true;

                                    }


                                    if (temp.Length > 2 && int.TryParse(temp[2], out tempvalue) == true)

                                    {

                                        info.min_cs_A_value = tempvalue;

                                    }


                                    if (temp.Length > 3 && int.TryParse(temp[3], out tempvalue) == true)

                                    {

                                        info.max_cs_A_value = tempvalue;

                                    }


                                    if (temp.Length > 4 && int.TryParse(temp[4], out tempvalue) == true)

                                    {

                                        info.min_cs_B_value = tempvalue;

                                    }


                                    if (temp.Length > 5 && int.TryParse(temp[5], out tempvalue) == true)

                                    {

                                        info.max_cs_B_value = tempvalue;

                                    }


                                    stripinfolist.Add(info);                                    

                                }                               


                                stripinfocombobox.IsEnabled = true;

                                stripinfocombobox.ItemsSource = striplist;

                                stripinfocombobox.SelectedIndex = selectedindex;

                                break;

                            }

                            else

                            {

                                

                            }

                        }

                    }

                }


            }

            catch (Exception err)

            {

                string error_msg = "서버에 접속하지 못했거나 해당 기능이 서버에 반영되지 않았습니다. \r\n접속 주소는 " + strUri_get_stripinfos + " 입니다\r\n메세지 :: " + err.Message;

                LogManager.Log(3, error_msg);

                stripinfocombobox.ItemsSource = null;

                stripinfocombobox.IsEnabled = false;

            }

by 무위자연 2018. 1. 10. 17:12


string '1234' 를 8자로 만들 때 '00001234'로 0으로 채워넣고 싶을 때

(padding 한다고 할 수 있다)

value = value.PadLeft(8, '0'); //참 쉽죠

by 무위자연 2017. 8. 19. 22:06

간단하게 아이템을 변경하고 다시 넣어주는 방식으로 처리해본다.


<ListView...


 lvObservationData.ItemsSource = null;

 lvObservationData.ItemsSource = loadeddatalist;

by 무위자연 2017. 3. 8. 10:40

프로젝트 속성 > 빌드 > 하단의 "고급"을 선택한 다음에


나오는 팝업에서 디버그 정보의 옵션을 "none"으로 설정하면 된다.


보통 debug모드에서 full / release 모드에서는 pdb-only로 설정되어 있다.



by 무위자연 2017. 3. 7. 09:16



파일에 쓸 때


HistoryData data = new HistoryData();

            data.SerialNumber = loadedserial_number;

            data.OperatorID = tbOperatorID.Text;

            data.test_dttm = loadeddatalist[loadeddatalist.Count - 1].test_dttm;

            data.value = loadeddatalist[loadeddatalist.Count - 1].value;


            

            datalist.Historydata.Add(data);


            FileStream fs3 = new FileStream(history_filename, FileMode.Create, FileAccess.Write);

            XmlSerializer xs = new XmlSerializer(datalist.GetType());

            xs.Serialize(fs3, datalist);

            fs3.Close();            


파일에서 읽을 때


  FileStream fs4 = new FileStream(history_filename, FileMode.Open, FileAccess.Read);

            XmlSerializer xs2 = new XmlSerializer(datalist.GetType());

            datalist = (HistoryDataList)xs2.Deserialize(fs4);

            fs4.Close();


이 때 데이터 클래스는 public class 이면서 [serializable]을 붙여줘야 한다.

like this


    [Serializable]

    public class HistoryDataList

    {


by 무위자연 2017. 1. 13. 15:30


 string targfolder = Properties.Settings.Default.Target_Log;

 if(Directory.Exists(targfolder) != true)

 {

     Directory.CreateDirectory(targfolder);

  }

  targfolder += "\\datamanager_log_" + DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".log";

  

ZipFile.CreateFromDirectory(Properties.Settings.Default.DM_Log, targfolder);                    


지정된 폴더 하위에 있는 파일을 지정된 파일명으로 압축한다.


압축율은 zip 상용 프로그램과 비슷하며 


해당 파일은 일반 zip 압축 해제로 열람이 가능하다.



by 무위자연 2016. 6. 30. 11:58

byte[] data = { 1, 2, 4, 8, 16, 32 };


string hex = BitConverter.ToString(data);


해당 string을 출력하면


01-02-04-08-10-20


"-"이 거슬린다면 replace를 쓰자.


string hex = BitConverter.ToString(data).Replace("-", string.Empty);

by 무위자연 2016. 3. 3. 10:17

프로그램에서 간단하게 설정 정보를 저장하고 사용하고 싶을때


1. 프로젝트에서 변수를 추가한다.




2. 해당 프로퍼티 읽기


   isTestMode = Properties.Settings.Default.IsTestMode;


3. 해당 프로퍼티 변경해서 저장하기


Properties.Settings.Default.IsTestMode = isTestMode;

            Properties.Settings.Default.Save(); > 이걸해야 파일에 반영된다.


by 무위자연 2016. 1. 27. 10:35

Visual Studio에서 빌드시에 특정 파일을 debug / release 폴더에 복사하고 싶을때.


해당 파일이 빌드후 결과로만 같이 있기만 할 경우엔 post-build를 / 그전에 필요한 경우라면 pre-build 이벤트에 명령어(command)를 넣어주면 된다.

하기는 다음의 예제이다.


프로젝트의 2개 파일을 빌드 결과 폴더로 복사한다.


copy /Y "$(SolutionDir)\SampleProjectr\ApplicationSetting.xml" "$(TargetDir)ApplicationSetting.xml"

copy /Y "$(SolutionDir)\SampleProject\Resources.xml" "$(TargetDir)Resources.xml"

상위 경로를 사용한다면

copy /Y "..\..\multiRegion.Ini" "$(TargetDir)multiRegion.Ini" - 20.5.15


by 무위자연 2016. 1. 18. 14:04

WPF는 UI 구조에 따라서 bubbling과 tuneling이 발생한다.


그래서 MFC나 QT와 달리 button에서 mouse down/up이 일어나지 않는 것 처럼 보인다.


사용하려면 UI 구조 위에서의 mouse donw을 먹지 못하게 막거나

간단하게 previewMouse...를 사용한다.


해당 이유에 대한 자세한 설명은 하기 링크를 참고 하면 된다.


http://www.sysnet.pe.kr/Default.aspx?mode=2&sub=0&detail=1&pageno=0&wid=1089&rssMode=1&wtype=0

by 무위자연 2015. 12. 18. 16:01
| 1 2 3 4 |