コード例 #1
0
        private void FriendsConsole_Load(object sender, EventArgs e)
        {
            InitializeFriendsList();

            //lbGroups.Items.Add("All");
            //lbGroups.SelectedIndex = 0;
            cbofgroups.Items.Add("...All friends");
            cbofgroups.SelectedIndex = 0;

            string fconffile = METAbolt.DataFolder.GetDataFolder() + "\\" + client.Self.AgentID.ToString() + "_fr_groups.ini";

// maybe use "Path.Combine(METAbolt.DataFolder.GetDataFolder(),client.Self.AgentID.ToString() + "_fr_groups.ini");" ?

            if (!System.IO.File.Exists(fconffile))
            {
                System.IO.StreamWriter SW;

                SW = System.IO.File.CreateText(fconffile);
                SW.Dispose();
            }

            //lbxFriends.PreSelect  += new EventHandler(lbxFriends_PreSelect);


            fconfig = new FileConfig(fconffile);
            fconfig.Load();

            LoadFriendGroups();
        }
コード例 #2
0
        void WriteToLog(string text)
        {
            lock (Locker)
            {
                try
                {
                    StreamWriter SW;
                    if (LogPath == string.Empty)
                    {
                        LogPath = string.Format("{0}/../logs", System.IO.Directory.GetCurrentDirectory());

                        if (!System.IO.Directory.Exists(LogPath))
                        {
                            System.IO.Directory.CreateDirectory(LogPath);
                        }

                        string FileName = DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss_") + mDummyFileName;
                        LogPath += string.Format("/{0}.log", FileName);
                    }

                    SW = File.AppendText(LogPath);
                    SW.WriteLine(string.Format("{0}, {1}", DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss"), text));
                    SW.Close();
                    SW.Dispose();
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.Print(e.Message);
                    return;
                }
            }
        }
コード例 #3
0
 public void WriteToLog(string message)
 {
     lock (locker)
     {
         StreamWriter SW;
         SW = File.AppendText("Data\\Log.txt");
         SW.WriteLine(message);
         SW.Close();
         SW.Dispose();
     }
 }
コード例 #4
0
ファイル: log.cs プロジェクト: cjccjjj/my_samba
        public void write(string format, params object[] args)
        {
            lock (m_lock_object)
            {
                string       log_message = "";
                StreamWriter SW;
                SW = File.AppendText(m_log_path);

                string timeStamp   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ff");
                string time_string = string.Format("[{0}]", timeStamp);
                //SW.Write(time_string);
                log_message += time_string;
                if (0 == m_main_stack_count)
                {
                    StackFrame callStack = new StackFrame(1, true);
                    string     file_line = string.Format("[{0}:{1}]: ", callStack.GetFileName(), callStack.GetFileLineNumber());
                    //SW.Write(file_line);
                    log_message += file_line;
                }
                else
                {
                    StackTrace st                  = new StackTrace();
                    int        frame_count         = st.FrameCount;
                    int        current_stack_count = frame_count - m_main_stack_count;
                    ++current_stack_count;
                    for (int i = 1; i < current_stack_count; ++i)
                    {
                        StackFrame callStack = new StackFrame(i, true);
                        string     file_line = string.Format("[{0}:{1}]", callStack.GetFileName(), callStack.GetFileLineNumber());
                        //SW.WriteLine(file_line);
                        log_message += file_line;
                    }
                }
                log_message += string.Format(format, args);
                SW.Write(log_message);
                SW.Close();
                SW.Dispose();

                if (m_message_box)
                {
                    MessageBox.Show(log_message);
                }
            }
        }
コード例 #5
0
ファイル: MainConsole.cs プロジェクト: rcoscali/METAbolt
        static void CreateGridFile()
        {
            StreamWriter SW;

            SW = File.CreateText(METAbolt.DataFolder.GetDataFolder() + "\\Grids.txt");
            SW.WriteLine("3rd Rock Grid,http://grid.3rdrockgrid.com:8002");
            SW.WriteLine("Avatar Hangout,http://login.avatarhangout.com:8002");
            SW.WriteLine("Cyberlandia,http://hypergrid.cyberlandia.net:8002");
            SW.WriteLine("Francogrid,http://grid.francogrid.net:8002");
            SW.WriteLine("Legend City Online,http://login.legendcityonline.com");
            SW.WriteLine("InWorldz,http://inworldz.com:8002/");
            SW.WriteLine("OSGrid,http://login.osgrid.org");
            SW.WriteLine("ReactionGrid,http://reactiongrid.com:8008");
            SW.WriteLine("The Gor Grid,http://thegorgrid.com:8002");
            SW.WriteLine("The New World Grid,http://grid.newworldgrid.com:8002");
            SW.WriteLine("WorldSimTerra,http://wsterra.com:8002");
            SW.WriteLine("Your Alternative Life,http://grid.youralternativelife.com");

            SW.Dispose();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            string       pathArchivo = "C:\\Users\\luis.vega\\Desktop";
            var          root        = Path.Combine(pathArchivo, "JSON");
            StreamWriter SW;

            SW   = System.IO.File.CreateText(root + @"\Precio.json");
            root = Path.Combine(root, "Precio.json");
            int count = 0;


            String conexion = "data source=195.192.2.249;initial catalog=Medinet 20170911;user id=sa;password=t0m$0nl@t1n@";

            SqlConnection cnn = new SqlConnection(conexion);

            cnn.Open();
            String     consulta = "select  p.PresentationId,p.DivisionId,p.CategoryId,p.ProductId, p.PharmaFormId,  pt.Brand, p.Presentation, b.BarCode,b.BarCodeId from BarCodes b inner join ProductBarCodes pb on b.BarCodeId = pb.BarCodeId inner join Presentations p on pb.PresentationId = p.PresentationId inner join Products pt on p.ProductId = pt.ProductId";
            SqlCommand cmd      = new SqlCommand(consulta, cnn);


            SqlDataReader read = cmd.ExecuteReader();



            while (read.Read())
            {
                try
                {
                    string   Active       = "false";
                    string   brand        = "";
                    string   presentation = "";
                    string[] getpreciosTotal;
                    string[] getprecios;
                    string   price  = "";
                    string   Distri = "";
                    string   Name   = "";


                    BarCodes BarCodes_reult = new BarCodes();

                    BarCodes_reult.PresentationId = Convert.ToInt32(read.GetValue(0));
                    BarCodes_reult.DivisionId     = Convert.ToInt32(read.GetValue(1));
                    BarCodes_reult.CategoryId     = Convert.ToInt32(read.GetValue(2));
                    BarCodes_reult.ProductId      = Convert.ToInt32(read.GetValue(3));
                    BarCodes_reult.PharmaFormId   = Convert.ToInt32(read.GetValue(4));
                    BarCodes_reult.BarCodeId      = Convert.ToInt32(read.GetValue(8));
                    BarCodes_reult.BarCode        = read.GetValue(7).ToString();
                    BarCodes_reult.Presentation   = read.GetValue(6).ToString();

                    if (BarCodes_reult.BarCodeId == 4470)
                    {
                        int num = 0;
                        num = 2;
                    }

                    if (BarCodes_reult.BarCodeId == 3332)
                    {
                        int num2 = 0;
                        num2 = 2;
                    }

                    Remplazar clean = new Remplazar();

                    //string cadena = "https://api.byprice.com/item/" + BarCodes_reult.BarCode.Trim();
                    string cadena    = "https://byprice.com/producto/" + BarCodes_reult.BarCode.Trim();
                    string GetCadena = "https://gate.byprice.com/public/item/details?uuid=";


                    WebRequest request = WebRequest.Create(cadena);
                    request.Credentials = CredentialCache.DefaultCredentials;
                    HttpWebResponse response           = (HttpWebResponse)request.GetResponse();
                    Stream          dataStream         = response.GetResponseStream();
                    StreamReader    reader             = new StreamReader(dataStream);
                    string          responseFromServer = reader.ReadToEnd();
                    reader.Close();
                    dataStream.Close();
                    response.Close();

                    //////////////////////////////////
                    responseFromServer = clean.GetUrl(responseFromServer);

                    GetCadena = GetCadena + responseFromServer;

                    WebRequest request1 = WebRequest.Create(GetCadena);
                    request1.Credentials = CredentialCache.DefaultCredentials;
                    HttpWebResponse response1           = (HttpWebResponse)request1.GetResponse();
                    Stream          dataStream1         = response1.GetResponseStream();
                    StreamReader    reader1             = new StreamReader(dataStream1);
                    string          responseFromServer1 = reader1.ReadToEnd();



                    Active = clean.Active(responseFromServer1);

                    if (Active == "true")
                    {
                        responseFromServer1 = clean.CleanName(responseFromServer1);
                        brand           = clean.GetBrand(responseFromServer1);
                        presentation    = clean.GetPresentation(responseFromServer1);
                        getpreciosTotal = clean.getprices(responseFromServer1);
                        Name            = clean.GetName(responseFromServer1);
                        //getprecios = clean.GetDistibuitor(getpreciosTotal);

                        for (int j = 0; j < getpreciosTotal.Length; j++)
                        {
                            price  = clean.precio(getpreciosTotal[j]);
                            Distri = clean.retailer(getpreciosTotal[j]);

                            string Precio = "{\"PresentationId\":" + BarCodes_reult.PresentationId + ",\"DivisionId\":" + BarCodes_reult.DivisionId + ",\"CategoryId\":" + BarCodes_reult.CategoryId + ",\"ProductId\":" + BarCodes_reult.ProductId + ",\"PharmaFormId\":" + BarCodes_reult.PharmaFormId + ",\"BarCodeId\":" + BarCodes_reult.BarCodeId + ",\"NombreProducto\":\"" + presentation + "\",\"Nombredistribuidor\":\"" + Distri + "\",\"Precio\":\"" + price + "\",\"Presentation\":\"" + BarCodes_reult.Presentation + "\",} \n";

                            Console.WriteLine("{\"PresentationId\":" + BarCodes_reult.PresentationId + ",\"DivisionId\":" + BarCodes_reult.DivisionId + ",\"CategoryId\":" + BarCodes_reult.CategoryId + ",\"ProductId\":" + BarCodes_reult.ProductId + ",\"PharmaFormId\":" + BarCodes_reult.PharmaFormId + ",\"BarCodeId\":" + BarCodes_reult.BarCodeId + ",\"NombreProducto\":\"" + presentation + "\",\"Nombredistribuidor\":\"" + Distri + "\",\"Precio\":\"" + price + "\"}");


                            SW.Write(Precio);

                            //SqlConnection cnnsp = new SqlConnection(conexion);
                            //cnnsp.Open();
                            //SqlCommand spcmd = new SqlCommand("plm_spUpdatePriceByProductBarCodeByPriceSource", cnnsp);
                            //spcmd.CommandType = System.Data.CommandType.StoredProcedure;
                            //spcmd.Parameters.Clear();

                            //spcmd.Parameters.AddWithValue("@BarCodeId", BarCodes_reult.BarCodeId);
                            //spcmd.Parameters.AddWithValue("@PresentationId", BarCodes_reult.PresentationId);
                            //spcmd.Parameters.AddWithValue("@Price", precio[j]);
                            //spcmd.Parameters.AddWithValue("@SourceName", name[j]);

                            //spcmd.ExecuteNonQuery();
                            //cnnsp.Close();
                        }
                    }



                    //reader1.Close();
                    //dataStream1.Close();
                    //response1.Close();
                    count = count + 1;
                    //if (count > 20)
                    //{
                    //    break;
                    //}
                }
                catch
                {
                }
            }
            count = count;
            SW.Close();
            SW.Dispose();
            Console.ReadKey(true);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: OMARATION/mcforge
        public static void PerformUpdate(bool oldrevision)
        {
            try
            {
                StreamWriter SW;
                if (!Server.mono)
                {
                    if (!File.Exists("Update.bat"))
                    {
                        SW = new StreamWriter(File.Create("Update.bat"));
                    }
                    else
                    {
                        if (File.ReadAllLines("Update.bat")[0] != "::Version 3")
                        {
                            SW = new StreamWriter(File.Create("Update.bat"));
                        }
                        else
                        {
                            SW = new StreamWriter(File.Create("Update_generated.bat"));
                        }
                    }
                    SW.WriteLine("::Version 3");
                    SW.WriteLine("TASKKILL /pid %2 /F");
                    SW.WriteLine("if exist MCForge_.dll.backup (erase MCForge_.dll.backup)");
                    SW.WriteLine("if exist MCForge_.dll (rename MCForge_.dll MCForge_.dll.backup)");
                    SW.WriteLine("if exist MCForge.new (rename MCForge.new MCForge_.dll)");
                    SW.WriteLine("start MCForge.exe");
                }
                else
                {
                    if (!File.Exists("Update.sh"))
                    {
                        SW = new StreamWriter(File.Create("Update.sh"));
                    }
                    else
                    {
                        if (File.ReadAllLines("Update.sh")[0] != "#Version 2")
                        {
                            SW = new StreamWriter(File.Create("Update.sh"));
                        }
                        else
                        {
                            SW = new StreamWriter(File.Create("Update_generated.sh"));
                        }
                    }
                    SW.WriteLine("#Version 2");
                    SW.WriteLine("#!/bin/bash");
                    SW.WriteLine("kill $2");
                    SW.WriteLine("rm MCForge_.dll.backup");
                    SW.WriteLine("mv MCForge_.dll MCForge.dll_.backup");
                    SW.WriteLine("wget " + DLLLocation);
                    SW.WriteLine("mono MCForge.exe");
                }

                SW.Flush(); SW.Close(); SW.Dispose();

                string  filelocation = "";
                string  verscheck    = "";
                Process proc         = Process.GetCurrentProcess();
                string  assemblyname = proc.ProcessName + ".exe";
                if (!oldrevision)
                {
                    WebClient client = new WebClient();
                    Server.selectedrevision = client.DownloadString(ServerSettings.CurrentVersionFile);
                    client.Dispose();
                }
                verscheck = Server.selectedrevision.TrimStart('r');
                int vers = int.Parse(verscheck.Split('.')[0]);
                if (oldrevision)
                {
                    filelocation = (ServerSettings.ArchivePath + Server.selectedrevision + ".exe");
                }
                if (!oldrevision)
                {
                    filelocation = (DLLLocation);
                }
                WebClient Client = new WebClient();
                Client.DownloadFile(filelocation, "MCLawl.new");
                Client.DownloadFile(ServerSettings.ChangelogLocation, "extra/Changelog.txt");

                // Its possible there are no levels or players loaded yet
                // Only save them if they exist, otherwise we fail-whale
                if (Server.levels != null && Server.levels.Any())
                {
                    foreach (Level l in Server.levels)
                    {
                        l.Save();
                    }
                }

                if (Player.players != null && Player.players.Any())
                {
                    foreach (Player pl in Player.players)
                    {
                        pl.save();
                    }
                }

                string fileName;
                if (!Server.mono)
                {
                    fileName = "Update.bat";
                }
                else
                {
                    fileName = "Update.sh";
                }

                try
                {
                    if (MCForge.Gui.Window.thisWindow.notifyIcon1 != null)
                    {
                        MCForge.Gui.Window.thisWindow.notifyIcon1.Icon    = null;
                        MCForge.Gui.Window.thisWindow.notifyIcon1.Visible = false;
                    }
                }
                catch { }

                Process p = Process.Start(fileName, "main " + System.Diagnostics.Process.GetCurrentProcess().Id.ToString());
                p.WaitForExit();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
コード例 #8
0
        public static void PerformUpdate(bool oldrevision)
        {
            try
            {
                StreamWriter SW;
                if (!Server.mono)
                {
                    if (!File.Exists("Update.bat"))
                    {
                        SW = new StreamWriter(File.Create("Update.bat"));
                    }
                    else
                    {
                        if (File.ReadAllLines("Update.bat")[0] != "::Version 3")
                        {
                            SW = new StreamWriter(File.Create("Update.bat"));
                        }
                        else
                        {
                            SW = new StreamWriter(File.Create("Update_generated.bat"));
                        }
                    }
                    SW.WriteLine("::Version 3");
                    SW.WriteLine("TASKKILL /pid %2 /F");
                    SW.WriteLine("if exist MCSong_.dll.backup (erase MCSong_.dll.backup)");
                    SW.WriteLine("if exist MCSong_.dll (rename MCSong_.dll MCSong_.dll.backup)");
                    SW.WriteLine("if exist MCSong.new (rename MCSong.new MCSong_.dll)");
                    SW.WriteLine("start MCSong.exe");
                }
                else
                {
                    if (!File.Exists("Update.sh"))
                    {
                        SW = new StreamWriter(File.Create("Update.sh"));
                    }
                    else
                    {
                        if (File.ReadAllLines("Update.sh")[0] != "#Version 2")
                        {
                            SW = new StreamWriter(File.Create("Update.sh"));
                        }
                        else
                        {
                            SW = new StreamWriter(File.Create("Update_generated.sh"));
                        }
                    }
                    SW.WriteLine("#Version 2");
                    SW.WriteLine("#!/bin/bash");
                    SW.WriteLine("kill $2");
                    SW.WriteLine("rm MCSong_.dll.backup");
                    SW.WriteLine("mv MCSong_.dll MCSong.dll_.backup");
                    SW.WriteLine("wget http://updates.mcsong.x10.mx/MCSong_.dll");
                    SW.WriteLine("mono MCSong.exe");
                }

                SW.Flush(); SW.Close(); SW.Dispose();

                string  filelocation = "";
                string  verscheck    = "";
                Process proc         = Process.GetCurrentProcess();
                string  assemblyname = proc.ProcessName + ".exe";
                if (!oldrevision)
                {
                    WebClient client = new WebClient();
                    Server.selectedrevision = client.DownloadString("http://updates.mcsong.x10.mx/curversion.txt");
                    client.Dispose();
                }
                verscheck = Server.selectedrevision.TrimStart('r');
                int vers = int.Parse(verscheck.Split('.')[0]);
                if (oldrevision)
                {
                    filelocation = ("http://updates.mcsong.x10.mx/archives/exe/" + Server.selectedrevision + ".exe");
                }
                if (!oldrevision)
                {
                    filelocation = ("http://updates.mcsong.x10.mx/MCSong_.dll");
                }
                WebClient Client = new WebClient();
                Client.DownloadFile(filelocation, "MCSong.new");
                Client.DownloadFile("http://updates.mcsong.x10.mx/changelog.txt", "extra/Changelog.txt");
                foreach (Level l in Server.levels)
                {
                    l.Save();
                }
                foreach (Player pl in Player.players)
                {
                    pl.save();
                }

                string fileName;
                if (!Server.mono)
                {
                    fileName = "Update.bat";
                }
                else
                {
                    fileName = "Update.sh";
                }

                try
                {
                    if (MCSong.Gui.Window.thisWindow.notifyIcon1 != null)
                    {
                        MCSong.Gui.Window.thisWindow.notifyIcon1.Icon    = null;
                        MCSong.Gui.Window.thisWindow.notifyIcon1.Visible = false;
                    }
                }
                catch { }

                Process p = Process.Start(fileName, "main " + System.Diagnostics.Process.GetCurrentProcess().Id.ToString());
                p.WaitForExit();
            }
            catch (Exception e) { Server.ErrorLog(e); }
        }
コード例 #9
0
ファイル: CmdBotAI.cs プロジェクト: DireatClassicube/MCLawl
        public void addPoint(Player p, string foundPath, string additional = "", string extra = "10", string more = "2")
        {
            string[] allLines;
            try { allLines = File.ReadAllLines("bots/" + foundPath); }
            catch { allLines = new string[1]; }

            StreamWriter SW;

            try
            {
                if (!File.Exists("bots/" + foundPath))
                {
                    Player.SendMessage(p, "Created new bot AI: &b" + foundPath);
                    SW = new StreamWriter(File.Create("bots/" + foundPath));
                    SW.WriteLine("#Version 2");
                }
                else if (allLines[0] != "#Version 2")
                {
                    Player.SendMessage(p, "File found is out-of-date. Overwriting");
                    SW = new StreamWriter(File.Create("bots/" + foundPath));
                    SW.WriteLine("#Version 2");
                }
                else
                {
                    Player.SendMessage(p, "Appended to bot AI: &b" + foundPath);
                    SW = new StreamWriter("bots/" + foundPath, true);
                }
            }
            catch { Player.SendMessage(p, "An error occurred when accessing the files. You may need to delete it."); return; }

            try
            {
                switch (additional.ToLower())
                {
                case "":
                case "walk":
                    SW.WriteLine("walk " + p.pos[0] + " " + p.pos[1] + " " + p.pos[2] + " " + p.rot[0] + " " + p.rot[1]);
                    break;

                case "teleport":
                case "tp":
                    SW.WriteLine("teleport " + p.pos[0] + " " + p.pos[1] + " " + p.pos[2] + " " + p.rot[0] + " " + p.rot[1]);
                    break;

                case "wait":
                    SW.WriteLine("wait " + int.Parse(extra)); break;

                case "nod":
                    SW.WriteLine("nod " + int.Parse(extra) + " " + int.Parse(more)); break;

                case "speed":
                    SW.WriteLine("speed " + int.Parse(extra)); break;

                case "remove":
                    SW.WriteLine("remove"); break;

                case "reset":
                    SW.WriteLine("reset"); break;

                case "spin":
                    SW.WriteLine("spin " + int.Parse(extra) + " " + int.Parse(more)); break;

                case "reverse":
                    for (int i = allLines.Length - 1; i > 0; i--)
                    {
                        if (allLines[i][0] != '#' && allLines[i] != "")
                        {
                            SW.WriteLine(allLines[i]);
                        }
                    }
                    break;

                case "linkscript":
                    if (extra != "10")
                    {
                        SW.WriteLine("linkscript " + extra);
                    }
                    else
                    {
                        Player.SendMessage(p, "Linkscript requires a script as a parameter");
                    }
                    break;

                case "jump":
                    SW.WriteLine("jump"); break;

                default:
                    Player.SendMessage(p, "Could not find \"" + additional + "\""); break;
                }

                SW.Flush();
                SW.Close();
                SW.Dispose();
            }
            catch { Player.SendMessage(p, "Invalid parameter"); SW.Close(); }
        }
コード例 #10
0
        private void PrintLabels(string OrderNum)
        {
            DataSet dP = GetOrderLabels(OrderNum);

            if (dP.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("No data in Courier Logistics system for this order");
                return;
            }

            RegistryKey registry  = Registry.LocalMachine.CreateSubKey("SOFTWARE\\logidata");
            string      vLablePrn = registry.GetValue("LablePrn").ToString();


            for (int i = 0; i < dP.Tables[0].Rows.Count; i++)
            {
                StreamWriter SW;
                SW = File.CreateText("c:\\logidata\\temp\\PrintJob" + i.ToString() + ".dat");

                SW.WriteLine("L");
                SW.WriteLine("H30");
                SW.WriteLine("PR");
                SW.WriteLine("D11");
                SW.WriteLine("1X1100002200030P0010001008700300087029002200290");
                SW.WriteLine("191100202500030Service");
                SW.WriteLine("121200502300030" + dP.Tables[0].Rows[i]["Service"].ToString());
                SW.WriteLine("191100202500165Route");
                SW.WriteLine("121200502300165" + dP.Tables[0].Rows[i]["Route"].ToString());
                SW.WriteLine("191100202500080Reference No");
                SW.WriteLine("121200502300080" + dP.Tables[0].Rows[i]["CorderNo"].ToString());
                SW.WriteLine("121100600570340CITY");
                SW.WriteLine("121100400450322DELIVERIES");
                SW.WriteLine("121100400330325LOGISTICS");
                SW.WriteLine("111100100230318(031) 580-2800");
                SW.WriteLine("191100601900032Deliver To:");
                SW.WriteLine("191100301700035" + dP.Tables[0].Rows[i]["DName"].ToString());
                SW.WriteLine("191100201500035" + dP.Tables[0].Rows[i]["Adres1"].ToString());
                SW.WriteLine("191100201300035" + dP.Tables[0].Rows[i]["Adres2"].ToString());
                SW.WriteLine("191100301100035" + dP.Tables[0].Rows[i]["Town"].ToString());
                SW.WriteLine("191100300900035" + dP.Tables[0].Rows[i]["PCode"].ToString() + " - Ref:" + dP.Tables[0].Rows[i]["CustRef"].ToString() + "");
                SW.WriteLine("191100400700050From : " + dP.Tables[0].Rows[i]["From"].ToString());

                SW.WriteLine("191100201600300" + DateTime.Now.ToString("dd/M/yy HH:m"));
                SW.WriteLine("191100201450300Dimms: " + dP.Tables[0].Rows[i]["PH"].ToString() + "x" + dP.Tables[0].Rows[i]["PW"].ToString() + "x" + dP.Tables[0].Rows[i]["PL"].ToString());
                SW.WriteLine("191100201300300Weight: " + dP.Tables[0].Rows[i]["Weight"].ToString());
                SW.WriteLine("191100502000300" + (i + 1).ToString() + " of " + dP.Tables[0].Rows.Count.ToString());
                SW.WriteLine("1e1304000200030" + dP.Tables[0].Rows[i]["Barcode"].ToString());
                SW.WriteLine("191100200050030" + dP.Tables[0].Rows[i]["Barcode"].ToString());
                SW.WriteLine("191100100000310Printed by LogiData");
                SW.WriteLine("E");


                SW.Close();

                try
                {
                    System.Diagnostics.ProcessStartInfo sinf = new System.Diagnostics.ProcessStartInfo("cmd", @"/c copy c:\\logidata\\temp\\printjob" + i.ToString() + ".dat " + vLablePrn);
                    sinf.RedirectStandardOutput = true;
                    sinf.UseShellExecute        = false;
                    sinf.CreateNoWindow         = true;
                    System.Diagnostics.Process p = new System.Diagnostics.Process();
                    p.StartInfo = sinf;
                    p.Start();

                    SW.Dispose();
                    System.Threading.Thread.Sleep(1000);
                }
                catch (System.Exception)
                {
                    MessageBox.Show("Printer not available");
                }
            }
        }
コード例 #11
0
        public JsonResult XML(string file)
        {
            int           count    = 0;
            int           final    = 0;
            String        conexion = "data source=195.192.2.249;initial catalog=Medinet 20170721;user id=sa;password=t0m$0nl@t1n@";
            SqlConnection cnn      = new SqlConnection(conexion);

            cnn.Open();
            try
            {
                List <GetXML> GetXML_Result = new List <GetXML>();

                String     consulta = "select * from FXML where XMLContent is not null";
                SqlCommand cmd      = new SqlCommand(consulta, cnn);


                SqlDataReader read  = cmd.ExecuteReader();
                String        PathP = System.Configuration.ConfigurationManager.AppSettings["Path"].ToString();


                if (read.HasRows == true)
                {
                    while (read.Read())
                    {
                        GetXML GetXML = new GetXML();
                        GetXML.NameXML    = read.GetValue(9).ToString();
                        GetXML.XMLContent = read.GetValue(10).ToString();
                        GetXML_Result.Add(GetXML);
                        var root = Path.Combine(PathP, "XML");


                        GetXML.NameXML = ReplaceContent(GetXML.NameXML);

                        if (System.IO.File.Exists(root + @"\" + GetXML.NameXML))
                        {
                            GetXML.NameXML = GetXML.NameXML + "_1";
                        }


                        StreamWriter SW;
                        SW = System.IO.File.CreateText(root + @"\" + GetXML.NameXML);

                        root = Path.Combine(root, GetXML.NameXML);
                        SW.Write(GetXML.XMLContent);
                        SW.Close();
                        SW.Dispose();
                        count = count + 1;
                    }
                }

                else
                {
                    string men = "No hay datos";
                }
                //return View(GetClient_Result);

                final = count;
                return(Json(true, JsonRequestBehavior.AllowGet));
            }

            catch (Exception e)
            {
                string message = e.Message;
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #12
0
        public ActionResult Index(HttpPostedFileBase file, int?value)
        {
            if (file != null)
            {
                int tamaño = 0;
                int final  = 0;
                //String PathP = System.Configuration.ConfigurationManager.AppSettings["Path"].ToString();
                String PathP      = Request.MapPath("~/ReportesXLS");
                string CodeString = "";

                String FileName  = file.FileName;
                String Extention = Path.GetExtension(file.FileName);
                var    root      = Path.Combine(PathP, "Analytics");

                try
                {
                    if (System.IO.Directory.Exists(root))
                    {
                        root = Path.Combine(root, FileName);

                        file.SaveAs(root);
                    }
                    else
                    {
                        Directory.CreateDirectory(root);

                        root = Path.Combine(root, FileName);

                        file.SaveAs(root);
                    }
                }
                catch (Exception e)
                {
                    String msg = e.Message;

                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }

                string        path      = root;
                DirectoryInfo directory = new DirectoryInfo(path);

                FileInfo item = new FileInfo(path);

                string allcontent = getContent(item.FullName);
                allcontent = ReplaceContent(allcontent);


                if (value == 1)
                {
                    allcontent = CreateCad(allcontent);

                    //String conexion = "data source=195.192.2.249;initial catalog=PLMClients 20160913;user id=sa;password=t0m$0nl@t1n@";
                    String        conexion = System.Configuration.ConfigurationManager.AppSettings["Conexion"].ToString();
                    SqlConnection cnn      = new SqlConnection(conexion);
                    cnn.Open();
                    try
                    {
                        String     consulta = "select distinct ClientId from plm_vwClientsByApplication where CodeString in (" + allcontent + ")" + " ";
                        SqlCommand cmd      = new SqlCommand(consulta, cnn);


                        SqlDataReader read = cmd.ExecuteReader();


                        if (read.HasRows == true)
                        {
                            while (read.Read())
                            {
                                CodeString = CodeString + read.GetValue(0).ToString() + ",";
                            }
                        }


                        allcontent = CodeString.Trim();
                    }

                    catch (Exception e)
                    {
                    }
                }
                tamaño     = allcontent.Length;
                final      = tamaño - 1;
                allcontent = allcontent.Substring(0, final);

                StreamWriter SW;
                SW = System.IO.File.CreateText(PathP + @"\Content.txt");

                root = Path.Combine(root, "Content.txt");
                SW.Write(allcontent);
                SW.Close();
                SW.Dispose();
                return(View());
            }

            return(View());
        }
コード例 #13
0
ファイル: RecordDataFile.cs プロジェクト: ywwjzsf/CANStream
        /// <summary>
        /// Converts the decoded PCAN trace file into a text file
        /// </summary>
        /// <param name="OutputFolder">Output file folder</param>
        /// <returns>Converion result (True: OK / False: Error)</returns>
        private bool WriteTextRecordData(string OutputFolder)
        {
            if (Channels.Count == 0)
            {
                return(false);
            }

            string OutFilePath = BuildOutputFilePtah(OutputFolder, RecordConversionFormat.Text);

            bool FileSplited = false;

            StreamWriter SW          = new StreamWriter(OutFilePath);
            FileInfo     OutFileInfo = new FileInfo(OutFilePath);

            string Line = "";

            //Channels name
            WriteTextRecordDataHeader(SW);

            //Data
            double SampleTime = GetOverallMinSampleTime();

            if (SampleTime <= 0)
            {
                return(false);
            }

            double Time = Records[0].TimeOffset;

            while (Time <= Records[Records.Count - 1].TimeOffset)
            {
                Line = ((Time - Records[0].TimeOffset) / 1000).ToString();

                for (int iChan = 0; iChan < Channels.Count; iChan++)
                {
                    Line = Line + ";" + Channels[iChan].FastGetValueAtTime(Time).ToString();
                }

                SW.WriteLine(Line);

                OutFileInfo.Refresh();

                if (OutFileInfo.Length > CANStreamConstants.TextRecordDataFileSizeMax)                 //Out file larger than 50 MBytes => close the file, eventually rename it and create a new one.
                {
                    FileSplited = true;

                    SW.Close();
                    SW.Dispose();
                    SW          = null;
                    OutFileInfo = null;

                    RenameTextRecordDataFile(OutFilePath);

                    SW          = new StreamWriter(OutFilePath);
                    OutFileInfo = new FileInfo(OutFilePath);

                    WriteTextRecordDataHeader(SW);
                }

                Time = Time + SampleTime;
            }

            SW.Close();
            SW.Dispose();
            SW          = null;
            OutFileInfo = null;

            if (FileSplited)
            {
                RenameTextRecordDataFile(OutFilePath);
            }

            return(true);
        }
コード例 #14
0
        public void addPoint(Player p, string foundPath, string additional = "", string extra = "10", string more = "2")
        {
            string[] allLines;
            try { allLines = File.ReadAllLines("bots/" + foundPath); }
            catch { allLines = new string[1]; }

            StreamWriter SW;

            try
            {
                if (!File.Exists("bots/" + foundPath))
                {
                    Player.SendMessage(p, "Cree une nouvelle IA de bot: &b" + foundPath);
                    SW = new StreamWriter(File.Create("bots/" + foundPath));
                    SW.WriteLine("#Version 2");
                }
                else if (allLines[0] != "#Version 2")
                {
                    Player.SendMessage(p, "Le fichier trouver est depacer. Reecriture");
                    SW = new StreamWriter(File.Create("bots/" + foundPath));
                    SW.WriteLine("#Version 2");
                }
                else
                {
                    Player.SendMessage(p, "Apprentissage a l'IA: &b" + foundPath);
                    SW = new StreamWriter("bots/" + foundPath, true);
                }
            }
            catch { Player.SendMessage(p, "Une erreur s'est produite lors de l'acces aux fichiers. Vous devez le supprimer."); return; }

            try
            {
                switch (additional.ToLower())
                {
                case "":
                case "walk":
                    SW.WriteLine("walk " + p.pos[0] + " " + p.pos[1] + " " + p.pos[2] + " " + p.rot[0] + " " + p.rot[1]);
                    break;

                case "teleport":
                case "tp":
                    SW.WriteLine("teleport " + p.pos[0] + " " + p.pos[1] + " " + p.pos[2] + " " + p.rot[0] + " " + p.rot[1]);
                    break;

                case "wait":
                    SW.WriteLine("wait " + int.Parse(extra)); break;

                case "nod":
                    SW.WriteLine("nod " + int.Parse(extra) + " " + int.Parse(more)); break;

                case "speed":
                    SW.WriteLine("speed " + int.Parse(extra)); break;

                case "remove":
                    SW.WriteLine("remove"); break;

                case "reset":
                    SW.WriteLine("reset"); break;

                case "spin":
                    SW.WriteLine("spin " + int.Parse(extra) + " " + int.Parse(more)); break;

                case "reverse":
                    for (int i = allLines.Length - 1; i > 0; i--)
                    {
                        if (allLines[i][0] != '#' && allLines[i] != "")
                        {
                            SW.WriteLine(allLines[i]);
                        }
                    }
                    break;

                case "linkscript":
                    if (extra != "10")
                    {
                        SW.WriteLine("linkscript " + extra);
                    }
                    else
                    {
                        Player.SendMessage(p, "Linkscript necessite un script comme paramètre");
                    }
                    break;

                case "jump":
                    SW.WriteLine("jump"); break;

                default:
                    Player.SendMessage(p, "Could not find \"" + additional + "\""); break;
                }

                SW.Flush();
                SW.Close();
                SW.Dispose();
            }
            catch { Player.SendMessage(p, "parametre invalide"); SW.Close(); }
        }