예제 #1
0
 private void ReadFile(string fileName, WcdListAdapter items, Context context = null)
 {
     try {
         using (var sr = context != null ? new StreamReader(context.Assets.Open(fileName), Encoding.GetEncoding("euc-kr")) : new StreamReader(fileName, Encoding.GetEncoding("euc-kr"))) {
             string swdLine = string.Empty;
             bool   addText = false;
             while ((swdLine = sr.ReadLine()) != null)
             {
                 if (swdLine.StartsWith("#006"))
                 {
                     break;
                 }
                 if (addText && swdLine.Trim().Length > 0)
                 {
                     items.Add(new WeldConditionData(swdLine));
                 }
                 if (swdLine.StartsWith("#005"))
                 {
                     addText = true;
                 }
             }
             sr.Close();
             //LogDebug("불러 오기:" + fileName);
         }
     } catch {
         //LogDebug("읽기 실패:" + fileName);
     }
 }
예제 #2
0
        public override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            dirPath        = Pref.WorkPath;
            robotPath      = System.IO.Path.Combine(dirPath, "ROBOT.SWD");
            wcdListAdapter = new WcdListAdapter(Context);
            ReadFile(robotPath, wcdListAdapter);
        }
예제 #3
0
        async private Task <string> UpdateFileAsync(string fileName, WcdListAdapter items, Context context = null)
        {
            StringBuilder sb = new StringBuilder();

            try {
                using (var sr = context != null ? new StreamReader(context.Assets.Open(fileName), Encoding.GetEncoding("euc-kr")) : new StreamReader(fileName, Encoding.GetEncoding("euc-kr"))) {
                    string swdLine = string.Empty;
                    bool   addText = true;
                    bool   wcdText = true;
                    while ((swdLine = await sr.ReadLineAsync()) != null)
                    {
                        if (addText == false && wcdText)
                        {
                            for (int i = 0; i < items.Count; i++)
                            {
                                sb.AppendLine(items[i].WcdString);
                            }
                            sb.Append("\n");
                            wcdText = false;
                        }
                        if (swdLine.StartsWith("#006"))
                        {
                            addText = true;
                        }
                        if (addText)
                        {
                            sb.AppendLine(swdLine);
                        }
                        if (swdLine.StartsWith("#005"))
                        {
                            addText = false;
                        }
                    }
                    sr.Close();
                }
            } catch {
                //LogDebug("읽기 실패: " + fileName);
            }

            try {
                using (var sw = context != null ? new StreamWriter(context.Assets.Open(fileName), Encoding.GetEncoding("euc-kr")) : new StreamWriter(fileName, false, Encoding.GetEncoding("euc-kr"))) {
                    sw.Write(sb.ToString());
                    sw.Close();
                    //ToastShow("저장 완료: " + fileName.Substring(fileName.LastIndexOf('/')));
                    Show("저장 완료: " + System.IO.Path.GetFileName(fileName));
                }
            } catch {
                Show("저장 실패: " + System.IO.Path.GetFileName(fileName));
            }

            return(sb.ToString());
        }