コード例 #1
0
 private static TextWriter getWriter(int fd)
 {
     if (fd < 0)
     {
         return(null);
     }
     else if (fd == 0)
     {
         return(null);
     }
     else if (fd == 1)
     {
         return(Console.Out);
     }
     else if (fd == 2)
     {
         return(Console.Error);
     }
     else
     {
         myFile file = myFile.get(fd);
         if (file != null)
         {
             return(file.Writer);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #2
0
        public void TestOpenAssembly()
        {
            string filename = @"c:\My Projects\TT Gateway";
            myFile assembly = getTools.openAssemblyInfo(filename);

            Assert.IsNotNull(assembly.getData());
        }
コード例 #3
0
        private void DeleteFileButton_Click(object sender, RoutedEventArgs e)
        {
            myFile selected = filesListView.SelectedItem as myFile;

            fileSource.Remove(selected);
            filesListView.Items.Refresh();
        }
コード例 #4
0
        private void AddFileButton_Click(object sender, RoutedEventArgs e)
        {
            var screen = new System.Windows.Forms.FolderBrowserDialog();

            if (screen.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (var file in Directory.GetFiles(screen.SelectedPath))
                {
                    var file1 = new myFile()
                    {
                        originalFileName = System.IO.Path.GetFileName(file),
                        filePath         = file,
                        newFileName      = getPreview(System.IO.Path.GetFileName(file))
                    };
                    if (!fileSource.Contains(file1))
                    {
                        fileSource.Add(file1);
                        filesListView.Items.Refresh();
                    }
                    else
                    {
                        MessageBox.Show("File already exists in list.", "Error");
                    }
                }
            }
        }
コード例 #5
0
        public void TestOpenJson()
        {
            string filename = @"c:\My Projects\TT Gateway";
            myFile json     = new myFile();

            json = getTools.openJSON(filename);
            Assert.IsNotNull(json.getData());
        }
コード例 #6
0
        public void TestwriteOtherDep()
        {
            myFile json = new myFile();

            json.add("\"version\": \"1.0.0.3\",");
            json.setFilename(@"C:\My Projects\TT Gateway");
            getTools.writeOtherDep(json, @"C:\My Projects\");
        }
コード例 #7
0
 public static myFile get(int fd)
 {
     try {
         myFile file = (myFile)files[fd - 3];
         return(file);
     } catch {
         return(null);
     }
 }
コード例 #8
0
        private void BottomFileButton_Click(object sender, RoutedEventArgs e)
        {
            myFile selected = filesListView.SelectedItem as myFile;

            fileSource.Remove(selected);
            fileSource.Add(selected);
            filesListView.SelectedIndex = filesListView.Items.Count - 1;
            filesListView.Items.Refresh();
        }
コード例 #9
0
        public ActionResult LayerMessage(string Layer, string Chennel, string FilePath, string Time, string Event)
        {
            Response res = new Response();

            try
            {
                if (Directory.Exists(FilePath))
                {
                    var fileList = new DirectoryInfo(FilePath).GetFiles("*.xml", SearchOption.AllDirectories);
                    int count    = 0;
                    foreach (var file in fileList)
                    {
                        if (file.FullName.Contains(Layer))
                        {
                            try
                            {
                                myFile      mf  = new myFile();
                                XmlDocument doc = new XmlDocument();
                                doc.Load(fileList[count].FullName);
                                string  jsonText = JsonConvert.SerializeXmlNode(doc);
                                JObject json     = JObject.Parse(jsonText);
                                //string txt = mf.FileToString(fileList[count].FullName);
                                //JObject json = JObject.Parse(txt);

                                JToken rates = json["Drive"]["message-body"].Children().Where(m => (string)m["channel"] == Chennel && (string)m["event"] == Event && (string)m["time"] == Time).FirstOrDefault();
                                //var rec = rates[Chennel];
                                //foreach (var item in rates)
                                //{
                                //    var t = item;
                                //}
                                var rec     = rates;
                                var message = rec.ToString();

                                res.Status  = "success";
                                res.Message = message;

                                return(Json(res, JsonRequestBehavior.AllowGet));
                            }
                            catch {}
                        }
                        count++;
                    }
                }
                else
                {
                    res.Status  = "error";
                    res.Message = "file path not found.";
                }
            }
            catch (Exception ex)
            {
                res.Status  = "error";
                res.Message = ex.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #10
0
        public static int __gnat_open_new(Byte[] name, int mode)
        {
#if !COMPACT
            myFile file = new myFile(name, FileMode.CreateNew, FileAccess.Write, mode == 0);
            if (file.fd > 0)
            {
                return(file.fd);
            }
#endif
            return(-1);
        }
コード例 #11
0
        public void TestGetJSONVersion()
        {
            string filename = @"c:\My Projects\Task Scheduler";
            myFile json     = getTools.openJSON(filename);

            SpeedBump.Version result   = getTools.getjsonVersion(json);
            string            expected = "1.0.0.0";

            Assert.IsNotNull(expected);
            Assert.AreEqual(expected, result.getVersion());
        }
コード例 #12
0
        public static int __gnat_create_output_file(Byte[] name)
        {
#if !COMPACT
            myFile file = new myFile(name, FileMode.CreateNew, FileAccess.Write, false);
            if (file.fd > 0)
            {
                return(file.fd);
            }
#endif
            return(-1);
        }
コード例 #13
0
        public static int __gnat_open_read(Byte[] name, int mode)
        {
#if !COMPACT
            myFile file = new myFile(name, FileMode.Open, FileAccess.Read, mode == 0);
            if (file.fd > 0)
            {
                return(file.fd);
            }
#endif
            return(-1);
        }
コード例 #14
0
        public void TestParseJson()
        {
            myFile json     = new myFile();
            string expected = "1.0.0.0";

            SpeedBump.Version ver = new SpeedBump.Version();
            json.setFilename(@"c:\My Projects\TT Gateway");
            json.add("version : \"1.0.0.0\"");
            ver = getTools.getjsonVersion(json);

            Assert.AreEqual(expected, ver.getVersion());
        }
コード例 #15
0
        public ActionResult Information(string Layer = "_", string networkMode = "", string FilePath = "", string File = "")
        {
            Response res = new Response();

            try
            {
                List <L3TempModel> Messages = new List <L3TempModel>();
                if (Directory.Exists(FilePath))
                {
                    string fileName = "*.xml";
                    if (File != "All")
                    {
                        fileName = File;
                    }
                    var fileList = new DirectoryInfo(FilePath).GetFiles(fileName, SearchOption.AllDirectories);
                    int count    = 0;
                    foreach (var file in fileList)
                    {
                        myFile      mf  = new myFile();
                        XmlDocument doc = new XmlDocument();
                        doc.Load(fileList[count].FullName);
                        string        jsonText = JsonConvert.SerializeXmlNode(doc);
                        JObject       json     = JObject.Parse(jsonText);
                        DateFunctions df       = new DateFunctions();
                        networkMode = (networkMode == "All") ? "" : networkMode;
                        var rssTitle = json["Drive"]["message-body"];
                        if (rssTitle != null)
                        {
                            var Chennellst = from p in json["Drive"]["message-body"]
                                             select new L3TempModel {
                                rat = (string)p["rat"], RadioBearerID = (string)p["RadioBearerID"], Freq = (string)p["Freq"], PCI = (string)p["PCI"], time = (string)p["time"], channel = (string)p["channel"], Event = (string)p["event"], Ticket = (string)p["time"]
                            };
                            Messages.AddRange(Chennellst);
                        }
                        count++;
                    }
                    return(Json(Messages.Where(a => a.rat.ToLower().Contains(networkMode.ToLower())), JsonRequestBehavior.AllowGet));
                }
                else
                {
                    res.Status  = "error";
                    res.Message = "file path not found.";
                }
            }
            catch (Exception ex)
            {
                res.Status  = "error";
                res.Message = ex.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
コード例 #16
0
        public void TestVerify()
        {
            string filename = @"c:\My Projects\Task Scheduler";
            string selected = @"c:\My Projects\";
            myFile json     = getTools.openJSON(filename);
            bool   worked   = false;

            try { worked = getTools.verify(json, selected); Assert.IsTrue(worked); }
            catch (Exception MismatchedVersion) { Assert.IsFalse(worked); }
            filename = @"fasdfas";
            json.setFilename(filename);
            try { worked = getTools.verify(json, selected); Assert.IsTrue(worked); }
            catch (Exception MismatchedVersion) { Assert.IsFalse(worked); }
        }
コード例 #17
0
        public static int close(int fd)
        {
#if !COMPACT
            myFile file = myFile.get(fd);
            if (file == null)
            {
                return(-1);
            }

            file.Close();
            return(0);
#else
            return(-1);
#endif
        }
コード例 #18
0
        private void button6_Click(object sender, EventArgs e)
        {
            if (textBox4.Text == "")
            {
                MessageBox.Show("파일을 선택해주세요");
            }
            else
            {
                FileInfo fi = new FileInfo(textBox4.Text);

                myFile myfile = new myFile();

                myfile.Type = (int)FileDataType.일;
                myfile.size = (int)fi.Length;
                string[] filenames = path.Split('\\');
                string   filename  = null;

                foreach (string s in filenames)
                {
                    filename = s;
                }

                myfile.filename = filename;
                FileStream filestream = new FileStream(path, FileMode.Open, FileAccess.Read);

                Byte[] byteSendData = new Byte[1024 * 4];

                for (int i = 0; i < (int)fi.Length / (1024 * 4); i++)
                {
                    filestream.Read(byteSendData, 0, byteSendData.Length);//바이트단위로 뜯어서 보냄
                    myfile.data = byteSendData;

                    sendBuffer = FileData.Serialize(myfile);
                    this.Send();
                    Thread.Sleep(2);
                }
                filestream.Read(byteSendData, 0, (int)fi.Length % (1024 * 4));
                myfile.data = byteSendData;
                sendBuffer  = FileData.Serialize(myfile);
                this.Send();

                filestream.Close();
            }
        }
コード例 #19
0
 private static FileStream getStream(int fd)
 {
     if (fd < 3)
     {
         return(null);
     }
     else
     {
         myFile file = myFile.get(fd);
         if (file != null)
         {
             return(file.Stream);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #20
0
        private void Uninitialize(UnityEngine.SceneManagement.Scene arg0)
        {
            mInstance = null;
            //Out put Event History
            string data = "";

            foreach (var item in EventHistory)
            {
                data += item.ToString() + "\n";
            }
            data += "######################################################" + System.DateTime.Now.ToString() + "######################################\n";
            myFile mfile = new myFile();

            mfile.FloaderCheck("./data");
            mfile.WriteToText(data, "./data/EventLogger.log", System.IO.FileMode.Append);
            Debug.Log("[MessageCenter] Event History was saved at './data/EventLogger.log'");
            mfile = null;
            Debug.Log("[MessageCenter] has been uninitiaLized");
        }
コード例 #21
0
        public void MoveFileItem(int direction)
        {
            if (filesListView.SelectedItem == null || filesListView.SelectedIndex < 0)
            {
                return;
            }

            int newIndex = filesListView.SelectedIndex + direction;

            if (newIndex < 0 || newIndex >= fileSource.Count)
            {
                return;
            }

            myFile selected = filesListView.SelectedItem as myFile;

            fileSource.Remove(selected);
            fileSource.Insert(newIndex, selected);
            filesListView.SelectedIndex = newIndex;
            filesListView.Items.Refresh();
        }
コード例 #22
0
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            myFile rawFile;
            string sTmp;

            ListBoxShow("Load!!");

            rawFile = new myFile("\\mcelog.raw");

            while (!rawFile.IsEOF())
            {
                sTmp = rawFile.ReadNextLine();
                ///ListBoxShow(ReadTextLine("\\mcelog.raw"));
                if (0 > sTmp.IndexOf(textBox1.Text.ToString()))
                {
                    ListBoxShow(sTmp);
                }
            }

            rawFile.myDestroy();
        }
コード例 #23
0
        public Response UploadFiles()
        {
            Response r = new Response();

            try
            {
                string sPath = "";
                sPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/AirViewLogs/");
                System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;

                for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
                {
                    System.Web.HttpPostedFile hpf = hfc[iCnt];

                    if (hpf.ContentLength > 0)
                    {
                        DirectoryHandler dh       = new DirectoryHandler();
                        myFile           file     = new myFile();
                        string           FileText = file.StreamToString(hpf.InputStream);


                        XML xml = new XML();

                        string asAscii = Encoding.ASCII.GetString(
                            Encoding.Convert(Encoding.UTF8,
                                             Encoding.GetEncoding(Encoding.ASCII.EncodingName,
                                                                  new EncoderReplacementFallback(string.Empty),
                                                                  new DecoderExceptionFallback()
                                                                  ),
                                             Encoding.UTF8.GetBytes(FileText)
                                             )
                            );

                        string json = xml.ToJson(FileText);



                        string[] FileName = hpf.FileName.Split('_');
                        if (FileName.Length > 6)
                        {
                            AV_SitesBL sitb       = new AV_SitesBL();
                            var        SiteRecord = sitb.ToList("BySiteCodeWithLayer", FileName[3], null, null, null, null, null).FirstOrDefault();
                            if (SiteRecord != null)
                            {
                                //  var fileList = new DirectoryInfo(sPath + SiteRecord.ClientPrefix + "\\" + FileName[2]).GetFiles("*.xml", SearchOption.AllDirectories);


                                string BAlpha   = System.Text.RegularExpressions.Regex.Replace(FileName[5], "[^a-zA-Z]", "");
                                string BNumaric = System.Text.RegularExpressions.Regex.Replace(FileName[5], "[^0-9]", "");
                                string Band     = (!string.IsNullOrEmpty(BAlpha.Trim())) ? BAlpha.Trim() + " " + BNumaric : BNumaric;


                                //string Band = "";

                                //if (FileName[3].Equals("LTE"))
                                //{
                                //    Band = FileName[4].Substring(0, 3) + " " + FileName[4].Substring(3, FileName[4].Length - 3);
                                //}
                                //else if (FileName[3].Equals("WCDMA"))
                                //{
                                //    Band = FileName[4].Substring(0, 4) + " " + FileName[4].Substring(4, FileName[4].Length - 4);
                                //}
                                //else if (FileName[3].Equals("GSM"))
                                //{
                                //    Band = FileName[4].Substring(0, 3) + " " + FileName[4].Substring(3, FileName[4].Length - 3);
                                //}

                                string Alpha   = System.Text.RegularExpressions.Regex.Replace(FileName[6], "[^a-zA-Z]", "");
                                string Numaric = System.Text.RegularExpressions.Regex.Replace(FileName[6], "[^0-9]", "");
                                string Carrier = (!string.IsNullOrEmpty(Alpha.Trim()))? Alpha.Trim() + " " + Numaric:Numaric;

                                sPath = sPath + SiteRecord.ClientPrefix + "\\" + FileName[3] + "\\" + FileName[4] + "_" + Band + "_" + Carrier + "\\";
                                dh.CreateDirectory(sPath);

                                string[] files        = Directory.GetFiles(sPath, "*.xml");
                                string   TempFileName = hpf.FileName.Replace(FileName[6], Carrier);
                                TempFileName = hpf.FileName.Replace(FileName[5], Band);

                                TempFileName = TempFileName.Replace("PSC1900", "PSC 1900");



                                file.Write(sPath, TempFileName, "json", json);

                                file.Write(sPath, TempFileName, "xml", FileText);

                                // hpf.SaveAs(sPath + Path.GetFileName(hpf.FileName));

                                r.Status  = "success";
                                r.Message = "files save successfully.";
                            }
                            else
                            {
                                r.Status  = "error";
                                r.Message = "Site not found.";
                            }
                        }
                        else
                        {
                            r.Status  = "error";
                            r.Message = "File name not correct";
                        }
                    }
                    else
                    {
                        r.Status  = "error";
                        r.Message = "File not found.";
                    }
                }
            }
            catch (Exception ex)
            {
                r.Status  = "error";
                r.Message = ex.Message;
            }
            return(r);
        }
コード例 #24
0
        private void server_run()//서버를 열고 갯수만큼 가지고 있자.
        {
            int count = server_count;

            byte[] sendBuffer = new byte[1024 * 8];
            byte[] readBuffer = new byte[1024 * 8];
            m_Listener[count] = new TcpListener(Convert.ToInt32(port_text_box.Text));
            this.m_Listener[0].Start();//단일 리스너로 하면 되는거 같은데 잘모르겟다.
            m_ClientOn[count] = false;

            Socket Client = m_Listener[0].AcceptSocket();//이것도 연결요청 대기

            server_count++;
            people_count++;
            m_Thread[server_count] = new Thread(new ThreadStart(server_run));
            m_Thread[server_count].Start();

            if (Client.Connected)
            {
                m_ClientOn[count]     = true;
                m_NetStream[count]    = new NetworkStream(Client);
                connect_peopel[count] = true;
                Network_start[count]  = false;
            }

            while (m_ClientOn[count])
            {
                try
                {
                    m_NetStream[count].Read(readBuffer, 0, readBuffer.Length);
                }
                catch
                {
                    m_ClientOn[count]  = false;
                    m_NetStream[count] = null;
                }

                FileData temp = (FileData)FileData.Deserialize(readBuffer);

                switch ((int)temp.Type)
                {
                case (int)FileDataType.로그인:
                {
                    login log = (login)FileData.Deserialize(readBuffer);
                    if (log.logout)
                    {
                        int check = -1;
                        m_ClientOn[count] = false;
                        for (int i = 0; i < 32; i++)
                        {
                            if (client_text_list.Items[i].SubItems[1].Text == log.id)
                            {
                                check = i;
                                break;
                            }
                        }
                        server_text_box.AppendText(client_text_list.Items[check].SubItems[1].Text + "님이 로그아웃 하셧습니다.\n");
                        connect_peopel[Convert.ToInt32(client_text_list.Items[check].SubItems[0].Text)] = false;
                        client_text_list.Items.RemoveAt(check);

                        listItem removeItem = new listItem();
                        removeItem.index = check;
                        removeItem.Type  = (int)FileDataType.접속목록;
                        sendBuffer       = FileData.Serialize(removeItem);
                        for (int i = 0; i < 32; i++)
                        {
                            if (connect_peopel[i])
                            {
                                m_NetStream[i].Write(sendBuffer, 0, sendBuffer.Length);
                                this.m_NetStream[i].Flush();
                            }
                        }
                        people_count--;
                        break;
                    }
                    ListViewItem item;
                    string[]     itemStr = new string[3];
                    itemStr[0] = count.ToString();
                    itemStr[1] = log.id;
                    itemStr[2] = "접속중...";
                    item       = new ListViewItem(itemStr);
                    client_text_list.Items.Add(item);
                    server_text_box.AppendText(log.id + "님이 로그인 하셧습니다.\n");

                    listItem listitem = new listItem();
                    listitem.list  = itemStr;
                    listitem.index = -1;
                    listitem.Type  = (int)FileDataType.접속목록;
                    sendBuffer     = FileData.Serialize(listitem);

                    for (int i = 0; i < 32; i++)
                    {
                        if (connect_peopel[i] && i != count)
                        {
                            m_NetStream[i].Write(sendBuffer, 0, sendBuffer.Length);
                            this.m_NetStream[i].Flush();
                        }
                    }
                    listitem.first = true;
                    for (int i = 0; i < people_count; i++)
                    {
                        itemStr[0]    = client_text_list.Items[i].SubItems[0].Text;
                        itemStr[1]    = client_text_list.Items[i].SubItems[1].Text;
                        itemStr[2]    = client_text_list.Items[i].SubItems[2].Text;
                        listitem.list = itemStr;
                        sendBuffer    = FileData.Serialize(listitem);
                        m_NetStream[count].Write(sendBuffer, 0, sendBuffer.Length);
                        m_NetStream[count].Flush();
                        Thread.Sleep(100);
                    }

                    break;
                }

                case (int)FileDataType.텍스트파일:
                {
                    textFile     tFile   = (textFile)FileData.Deserialize(readBuffer);
                    FileStream   fStream = new FileStream(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\" + tFile.userName + ".txt", FileMode.Create, FileAccess.Write);
                    StreamWriter fWriter = new StreamWriter(fStream);
                    fWriter.Write(tFile.text);
                    mutex[tFile.userIndex] = true;
                    fWriter.Close();
                    fStream.Close();

                    break;
                }

                case (int)FileDataType.일:
                {
                    while (!mutex[count])
                    {
                        ;
                    }
                    mutex[count] = false;

                    bool open = false;

                    myFile file = (myFile)FileData.Deserialize(readBuffer);

                    server_text_box.AppendText(file.filename + " : 업데이트 요청 \n");

                    FileStream fs = new FileStream(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\file\\" + file.filename, FileMode.Create, FileAccess.Write);

                    fs.Close();

                    fs = new FileStream(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\file\\" + file.filename, FileMode.Append, FileAccess.Write);

                    for (int i = 0; i < (int)file.size / (1024 * 4); i++)      //파일크기만큼 반복문
                    {
                        if (open)
                        {
                            m_NetStream[count].Read(readBuffer, 0, readBuffer.Length);
                            file = (myFile)FileData.Deserialize(readBuffer);
                        }
                        fs.Write(file.data, 0, 1024 * 4);
                        open = true;
                    }
                    if (open)
                    {
                        m_NetStream[count].Read(readBuffer, 0, readBuffer.Length);
                    }

                    file = (myFile)FileData.Deserialize(readBuffer);
                    fs.Write(file.data, 0, (int)file.size % (1024 * 4));

                    server_text_box.AppendText(file.filename + " 업데이트\n");

                    fs.Close();
                    mutex[count] = true;
                    break;
                }

                case (int)FileDataType.일리스트:
                {
                    DirectoryInfo di       = new DirectoryInfo(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\file");
                    string        fileList = "";
                    foreach (var item in di.GetFiles())
                    {
                        fileList += item.Name + "%";
                        fileList += item.Length + "%";
                    }
                    filelist fList = new filelist();

                    fList.fileList = fileList;
                    fList.Type     = (int)FileDataType.일리스트;
                    sendBuffer     = FileData.Serialize(fList);

                    m_NetStream[count].Write(sendBuffer, 0, sendBuffer.Length);
                    m_NetStream[count].Flush();

                    break;
                }

                case (int)FileDataType.일체크:
                {
                    string     userName = null;
                    string     data;
                    FileStream fStream;
                    fileCheck  fileCheck = (fileCheck)FileData.Deserialize(readBuffer);
                    for (int i = 0; i < 32; i++)
                    {
                        if (Convert.ToInt32(client_text_list.Items[i].SubItems[0].Text) == fileCheck.fileNumber)
                        {
                            userName = client_text_list.Items[i].SubItems[1].Text;
                            break;
                        }
                    }

                    if (fileCheck.fileNeed == 0)         //파일이 text 라면
                    {
                        while (!mutex[count])
                        {
                            ;
                        }
                        mutex[count] = false;

                        fStream = new FileStream(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\" + userName + ".txt", FileMode.OpenOrCreate, FileAccess.Read);
                        StreamReader streamReader = new StreamReader(fStream);
                        data = streamReader.ReadToEnd();

                        textFile tFIle = new textFile(data);
                        tFIle.text     = data;
                        tFIle.userName = userName;
                        tFIle.Type     = (int)FileDataType.텍스트파일;

                        sendBuffer = FileData.Serialize(tFIle);
                        m_NetStream[count].Write(sendBuffer, 0, sendBuffer.Length);
                        m_NetStream[count].Flush();
                        streamReader.Close();
                        fStream.Close();

                        mutex[count] = true;
                    }
                    else if (fileCheck.fileNeed == 1)
                    {
                        while (!mutex[count])
                        {
                            ;
                        }
                        mutex[count] = false;
                        string filename = fileCheck.filename;

                        server_text_box.AppendText(filename + " : 전송요청 \n");

                        fStream = new FileStream(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\file\\" + filename, FileMode.OpenOrCreate, FileAccess.Read);
                        StreamReader streamReader = new StreamReader(fStream);

                        System.IO.FileInfo fi = new FileInfo(path + "\\" + textBox1.Text + "/" + textBox2.Text + "월 " + textBox3.Text + "일" + "\\file\\" + filename);

                        myFile myfile = new myFile();
                        myfile.Type     = (int)FileDataType.일;
                        myfile.size     = (int)fi.Length;
                        myfile.filename = filename;

                        Byte[] byteSendData = new Byte[1024 * 4];

                        for (int i = 0; i < (int)fi.Length / (1024 * 4); i++)
                        {
                            fStream.Read(byteSendData, 0, byteSendData.Length);        //바이트단위로 뜯어서 보냄
                            myfile.data = byteSendData;
                            sendBuffer  = FileData.Serialize(myfile);
                            m_NetStream[count].Write(sendBuffer, 0, sendBuffer.Length);
                            m_NetStream[count].Flush();
                            Thread.Sleep(2);
                        }
                        fStream.Read(byteSendData, 0, (int)fi.Length % (1024 * 4));
                        myfile.data = byteSendData;
                        sendBuffer  = FileData.Serialize(myfile);
                        m_NetStream[count].Write(sendBuffer, 0, sendBuffer.Length);
                        m_NetStream[count].Flush();

                        server_text_box.AppendText(filename + " : 전송 완료 \n");
                        mutex[count] = true;
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
コード例 #25
0
        private void Receive()//받자 파일을
        {
            while (this.m_blsConnect)
            {
                try
                {
                    this.m_NetStream.Read(this.readBuffer, 0, readBuffer.Length);
                }
                catch
                {
                    this.m_blsConnect = false;
                    this.m_NetStream  = null;
                }
                FileData temp = (FileData)FileData.Deserialize(readBuffer);

                switch ((int)temp.Type)
                {
                case (int)FileDataType.로그인:
                {
                    break;
                }

                case (int)FileDataType.일리스트:
                {
                    filelist fList = (filelist)FileData.Deserialize(readBuffer);
                    string   list  = fList.fileList;

                    string[] strset = list.Split('%');
                    for (int i = 1; i < strset.Length; i = i + 2)
                    {
                        ListViewItem lvi = new ListViewItem(strset[i - 1]);
                        lvi.SubItems.Add(strset[i]);
                        metroListView1.Items.Add(lvi);
                    }

                    break;
                }

                case (int)FileDataType.텍스트파일:
                {
                    textFile tempText = (textFile)FileData.Deserialize(readBuffer);
                    myText.fillText(tempText.text, tempText.userName);
                    break;
                }

                case (int)FileDataType.일:
                {
                    bool open = false;

                    myFile file = (myFile)FileData.Deserialize(readBuffer);

                    FileStream fs = new FileStream(drPath + "\\" + file.filename, FileMode.Create, FileAccess.Write);

                    fs.Close();

                    fs = new FileStream(drPath + "\\" + file.filename, FileMode.Append, FileAccess.Write);

                    for (int i = 0; i < (int)file.size / (1024 * 4); i++)        //파일크기만큼 반복문
                    {
                        if (open)
                        {
                            m_NetStream.Read(readBuffer, 0, readBuffer.Length);
                            file = (myFile)FileData.Deserialize(readBuffer);
                        }
                        fs.Write(file.data, 0, 1024 * 4);
                        open = true;
                    }
                    if (open)
                    {
                        m_NetStream.Read(readBuffer, 0, readBuffer.Length);
                    }

                    file = (myFile)FileData.Deserialize(readBuffer);
                    fs.Write(file.data, 0, (int)file.size % (1024 * 4));
                    break;
                }

                case (int)FileDataType.접속목록:
                {
                    listItem listitem = (listItem)FileData.Deserialize(readBuffer);
                    if (listitem.index != -1)
                    {
                        listView1.Items.RemoveAt(listitem.index);
                        break;
                    }
                    ListViewItem item;
                    item = new ListViewItem(listitem.list);
                    listView1.Items.Add(item);

                    break;
                }

                case (int)FileDataType.일체크:
                {
                    fileCheck fCheck = (fileCheck)FileData.Deserialize(readBuffer);
                    if (fCheck.fileNeed == 0)
                    {
                        textFile tFile = new textFile(backup);
                        tFile.Type      = (int)FileDataType.텍스트파일;
                        tFile.userName  = textBox3.Text;
                        tFile.userIndex = fCheck.fileNumber;        //원래는 파일넘버가 이게 아니지만 유저 인덱스 넘겨줌
                        sendBuffer      = FileData.Serialize(tFile);

                        m_NetStream.Write(sendBuffer, 0, sendBuffer.Length);
                        m_NetStream.Flush();
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
コード例 #26
0
        public ActionResult Information(Int64 Id)
        {
            ViewBag.SiteId = Id;
            List <string> Chennels  = new List <string>();
            List <string> TestTypes = new List <string>();
            List <GetDirctoryinformation> singdir = new List <GetDirctoryinformation>();
            SitesBL sb = new SitesBL();

            try
            {
                List <BandVM> Bands = sb.GetSiteBands("", Id);
                if (Bands.Count > 0)
                {
                    AV_SectorBL secb = new AV_SectorBL();
                    ViewBag.Sectors        = secb.ToList("GetSectors", Id.ToString(), null, null, null, null);
                    ViewBag.Bands          = Bands.Select(m => new { m.BandId, m.NetworkMode, m.BandName, m.Carrier, Text = m.NetworkMode + " " + m.BandName + " " + m.Carrier, Value = m.SiteCode + "_" + m.NetworkMode + "_" + m.BandName + "_" + m.Carrier }).ToList();
                    ViewBag.NetworkModeBag = Bands;
                    var band  = Bands.FirstOrDefault();
                    var sPath = Server.MapPath("~/Content/AirViewLogs/" + band.ClientPrefix + "\\" + band.SiteCode);
                    ViewBag.FilePath = sPath;
                    if (Directory.Exists(sPath))
                    {
                        FileInfo[] allFiles = new DirectoryInfo(sPath).GetFiles("*.xml", SearchOption.AllDirectories);
                        if (allFiles.Length > 0)
                        {
                            foreach (var file in allFiles)
                            {
                                GetDirctoryinformation info = new GetDirctoryinformation();
                                info.createDate    = file.CreationTime.ToString();
                                info.directoryPath = file.FullName;
                                info.fileName      = file.Name;
                                info.fileType      = file.Extension;
                                info.size          = (file.Length / 1024).ToString();
                                singdir.Add(info);
                            }
                        }
                        var    fileList = new DirectoryInfo(sPath).GetFiles("*.xml", SearchOption.AllDirectories);
                        myFile mf       = new myFile();
                        for (int i = 0; i < fileList.Length; i++)
                        {
                            try
                            {
                                XmlDocument doc = new XmlDocument();
                                doc.Load(fileList[i].FullName);
                                string  jsonText = JsonConvert.SerializeXmlNode(doc);
                                JObject json     = JObject.Parse(jsonText);
                                //string txt = mf.FileToString(fileList[i].FullName);
                                //JObject json = JObject.Parse(txt);


                                string rssTitle = (string)json["Drive"]["TestType"];

                                foreach (var x in json)
                                {
                                    // string name = x.Key;
                                    JToken value = x.Value;
                                    if (value != null)
                                    {
                                        var sector = value["TestType"];
                                        TestTypes.Add(sector.ToString());
                                    }
                                }

                                var Chennellst = from p in json["Drive"]["message-body"]
                                                 select new { channel = (string)p["channel"], Event = (string)p["event"] };

                                foreach (var item in Chennellst)
                                {
                                    Chennels.Add(item.channel);
                                }
                            }
                            catch (Exception ex) {
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
            ViewBag.AVXFiles  = singdir.ToList();
            ViewBag.Chennels  = Chennels.Distinct().ToList();
            ViewBag.TestTypes = TestTypes.Distinct().ToList();
            return(View());
        }
コード例 #27
0
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            myFile rawFile;
            string sTmp;
            
            ListBoxShow("Load!!");

            rawFile = new myFile("\\mcelog.raw");

            while (!rawFile.IsEOF())
            {
                sTmp = rawFile.ReadNextLine();
                ///ListBoxShow(ReadTextLine("\\mcelog.raw"));
                if( 0 > sTmp.IndexOf(textBox1.Text.ToString()) )
                    ListBoxShow(sTmp);
            }

            rawFile.myDestroy();
        }