예제 #1
0
        public static void CreateArtSQL(List <string> pathList, string outFileName)
        {
            var pathArtSQL = Path.GetDirectoryName(Application.ExecutablePath) + "\\" + outFileName;

            File.WriteAllText(pathArtSQL, string.Empty);
            foreach (string path in pathList)
            {
                if (File.Exists(path))
                {
                    string[] lines    = File.ReadAllLines(path);
                    string   sqlStr   = "";
                    bool     lineRead = false;
                    string   lastStr  = "";
                    foreach (string line in lines)
                    {
                        if (line == "")
                        {
                            continue;
                        }
                        if (line.Contains("/*-") && line.Contains("-*/"))
                        {
                            using (var tw = new StreamWriter(pathArtSQL, true))
                            {
                                tw.WriteLine(ArsLibrary.Encryption("--Açıklama:" + line.BetweenStrings("/*-", "-*/")));
                            }
                        }
                        else if (line.Contains("/*_") && line.Contains("_*/"))
                        {
                            using (var tw = new StreamWriter(pathArtSQL, true))
                            {
                                tw.WriteLine(ArsLibrary.Encryption("--Version:" + line.BetweenStrings("/*_", "_*/")));
                            }
                        }
                        else if (line.Contains("/*BEGIN*/"))
                        {
                            lineRead = true;
                        }
                        else if (line.Contains("/*END*/"))
                        {
                            using (var tw = new StreamWriter(pathArtSQL, true))
                            {
                                tw.WriteLine(ArsLibrary.Encryption(sqlStr));
                            }
                            lastStr  = sqlStr;
                            sqlStr   = "";
                            lineRead = false;
                        }
                        else if (lineRead)
                        {
                            string lineStr = line.Replace(((char)9).ToString(), "").Replace("\n", "");
                            sqlStr += lineStr + " ";
                        }
                    }
                }
            }
        }
예제 #2
0
        public static void SaveLineLisansCFG(string key, string value)
        {
            try
            {
                var path = Path.GetDirectoryName(Application.ExecutablePath) + "\\Artez.ls";

                bool writeCheck = false;
                if (File.Exists(path))
                {
                    string[] lines = System.IO.File.ReadAllLines(path);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        lines[i] = Decryption(lines[i]);
                    }
                    System.IO.File.WriteAllText(path, string.Empty);
                    foreach (string line in lines)
                    {
                        using (var tw = new StreamWriter(path, true))
                        {
                            if (line.Split(';').Length == 2 && line.Split(';')[0] == key)
                            {
                                tw.WriteLine(ArsLibrary.Encryption(key + ";" + value));
                                writeCheck = true;
                            }
                            else
                            {
                                tw.WriteLine(ArsLibrary.Encryption(line));
                            }
                        }
                    }
                }
                if (!writeCheck)
                {
                    using (var tw = new StreamWriter(path, true))
                    {
                        tw.WriteLine(ArsLibrary.Encryption(key + ";" + value));
                    }
                }
            }
            catch (Exception ex)
            {
                ArsMessage.ShowMessage("Hata", ex.Message);
            }
        }
예제 #3
0
        public static bool SaveUser()
        {
            bool   canSave         = false;
            int    usersCount      = 0;
            string kullaniciSayisi = GetLineCFG("Kullanıcı Sayısı");

            if (kullaniciSayisi != "")
            {
                usersCount = Convert.ToInt32(kullaniciSayisi);
            }
            int activeUsers = ActiveUsers();

            if (!UserSaved())
            {
                if (activeUsers < usersCount || appId == 0)
                {
                    canSave = true;
                    try
                    {
                        var path = Path.GetDirectoryName(Application.ExecutablePath) + "\\pc_" + activeUsers + ".art";

                        if (!File.Exists(path))
                        {
                            canSave = true;
                            using (var tw = new StreamWriter(path, true))
                            {
                                tw.WriteLine(ArsLibrary.Encryption("PC Name" + ";" + System.Environment.MachineName));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
            }
            else
            {
                canSave = true;
            }

            return(canSave);
        }
예제 #4
0
        public static void SaveLineCFG(string key, string value)
        {
            var saveCheck = true;

            try
            {
                var path    = Path.GetDirectoryName(Application.ExecutablePath) + "\\Artez.cfg";
                var pathNew = Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezNew.cfg";

                bool writeCheck = false;
                if (File.Exists(path))
                {
                    string[] lines = System.IO.File.ReadAllLines(path);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        lines[i] = Decryption(lines[i]);
                    }
                    if (File.Exists(pathNew))
                    {
                        System.IO.File.WriteAllText(pathNew, string.Empty);
                    }
                    foreach (string line in lines)
                    {
                        using (var tw = new StreamWriter(pathNew, true))
                        {
                            if (line.Split(';').Length >= 2 && line.Split(';')[0] == key)
                            {
                                tw.WriteLine(ArsLibrary.Encryption(key + ";" + value));
                                writeCheck = true;
                            }
                            else
                            {
                                tw.WriteLine(ArsLibrary.Encryption(line));
                            }
                        }
                    }
                }
                if (!writeCheck)
                {
                    using (var tw = new StreamWriter(pathNew, true))
                    {
                        tw.WriteLine(ArsLibrary.Encryption(key + ";" + value));
                    }
                }
            }
            catch (Exception ex)
            {
                ArsMessage.ShowMessage("Hata", ex.Message);
                saveCheck = false;
            }finally
            {
                if (saveCheck)
                {
                    try
                    {
                        var path  = Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezNew.cfg";
                        var path2 = Path.GetDirectoryName(Application.ExecutablePath) + "\\Artez.cfg";
                        var path3 = Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezOld.cfg";
                        if (File.Exists(path2))
                        {
                            System.IO.File.Move(path2, Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezOld.cfg");
                        }
                        System.IO.File.Move(path, Path.GetDirectoryName(Application.ExecutablePath) + "\\Artez.cfg");
                        System.IO.File.Delete(Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezNew.cfg");
                        if (File.Exists(path3))
                        {
                            System.IO.File.Delete(Path.GetDirectoryName(Application.ExecutablePath) + "\\ArtezOld.cfg");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }