Example #1
0
 public Image GetImage(string fieldName)
 {
     if (GetString(fieldName) != "")
     {
         return(ArsLibrary.ByteArrayToImage(dataSet.Tables[0].Rows[serviceIndex][fieldName] as byte[]));
     }
     return(null);
 }
Example #2
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 + " ";
                        }
                    }
                }
            }
        }
Example #3
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);
            }
        }
Example #4
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);
        }
Example #5
0
        private void ExecSQL()
        {
            try
            {
                switch (Mode)
                {
                case EnmQryMode.Insert:
                    string insStr = "";
                    bool   firstFieldsCheckIns = false;
                    if (fields.Contains("CREATE_USERNO"))
                    {
                        firstFieldsCheckIns = true;
                        insStr += "INSERT INTO " + TableName + "(CREATE_USERNO, LAST_UPUSERNO, APP_VERSION";
                    }
                    else
                    {
                        insStr += "INSERT INTO " + TableName + "(";
                    }
                    if (fields.Contains("SUBE_KODU"))
                    {
                        if (firstFieldsCheckIns)
                        {
                            insStr += ", SUBE_KODU";
                        }
                        else
                        {
                            insStr += " SUBE_KODU";
                        }
                        firstFieldsCheckIns = true;
                    }

                    bool firstFieldNameCheck = firstFieldsCheckIns;
                    foreach (string fieldName in values.Keys)
                    {
                        if (firstFieldNameCheck)
                        {
                            insStr += ", " + fieldName;
                        }
                        else
                        {
                            insStr += " " + fieldName;
                            firstFieldNameCheck = true;
                        }
                    }
                    if (fields.Contains("CREATE_USERNO"))
                    {
                        insStr += ") OUTPUT INSERTED.REC_ID VALUES (" + ArsLibrary.userNo + ", " + ArsLibrary.userNo + ", '" + ArsLibrary.version + "'";
                    }
                    else
                    {
                        insStr += ") OUTPUT INSERTED.REC_ID VALUES(";
                    }
                    if (fields.Contains("SUBE_KODU"))
                    {
                        insStr += ", '" + ArsLibrary.subeKodu + "'";
                    }
                    foreach (string fieldName in values.Keys)
                    {
                        switch (values[fieldName])
                        {
                        case string _:
                            if (firstFieldsCheckIns)
                            {
                                if ((values[fieldName] as string) != "NULL")
                                {
                                    insStr += ", '" + values[fieldName] + "'";
                                }
                                else
                                {
                                    insStr += ", NULL";
                                }
                            }
                            else
                            {
                                if ((values[fieldName] as string) != "NULL")
                                {
                                    insStr += " '" + values[fieldName] + "'";
                                }
                                else
                                {
                                    insStr += " NULL";
                                }
                                firstFieldsCheckIns = true;
                            }
                            break;

                        case int _:
                            if (firstFieldsCheckIns)
                            {
                                insStr += ", " + values[fieldName];
                            }
                            else
                            {
                                insStr += " " + values[fieldName];
                                firstFieldsCheckIns = true;
                            }
                            break;

                        case double _:
                            if (firstFieldsCheckIns)
                            {
                                insStr += ", " + values[fieldName].ToString().Replace(',', '.');
                            }
                            else
                            {
                                insStr += " " + values[fieldName].ToString().Replace(',', '.');
                                firstFieldsCheckIns = true;
                            }
                            break;

                        case Image _:
                            if (firstFieldsCheckIns)
                            {
                                insStr += ", 0x" + ArsLibrary.ByteArrayToString(ArsLibrary.ImageToByteArray(values[fieldName] as Image));
                            }
                            else
                            {
                                insStr += " 0x" + ArsLibrary.ByteArrayToString(ArsLibrary.ImageToByteArray(values[fieldName] as Image));
                                firstFieldsCheckIns = true;
                            }
                            break;
                        }
                    }
                    insStr += ")";
                    ArsSQLQry qryIns = new ArsSQLQry();
                    qryIns.lisansQry = lisansQry;
                    qryIns.artezQry  = artezQry;
                    qryIns.SQLText   = insStr;
                    qryIns.Open();
                    if (qryIns.Found())
                    {
                        insertRecID = qryIns.GetInt("REC_ID");
                    }

                    execErrorCode   = qryIns.errorCode;
                    execDescription = qryIns.description;

                    break;

                case EnmQryMode.Update:
                    string updStr = "";
                    bool   firstFieldsCheckInsUpd = false;
                    if (fields.Contains("CREATE_USERNO"))
                    {
                        firstFieldsCheckInsUpd = true;
                        updStr = "UPDATE " + TableName + " SET LAST_UPDATE = GETDATE(), LAST_UPUSERNO = " + ArsLibrary.userNo + ", APP_VERSION = '" + ArsLibrary.version + "', IS_CHANGED = 1";
                    }
                    else
                    {
                        updStr = "UPDATE " + TableName + " SET";
                    }
                    if (fields.Contains("SUBE_KODU"))
                    {
                        if (firstFieldsCheckInsUpd)
                        {
                            updStr += ", SUBE_KODU = '" + ArsLibrary.subeKodu + "'";
                        }
                        else
                        {
                            updStr += " SUBE_KODU = '" + ArsLibrary.subeKodu + "'";
                        }
                        firstFieldsCheckInsUpd = true;
                    }
                    foreach (string fieldName in values.Keys)
                    {
                        switch (values[fieldName])
                        {
                        case string _:
                            if (firstFieldsCheckInsUpd)
                            {
                                if ((values[fieldName] as string) != "NULL")
                                {
                                    updStr += ", " + fieldName + " = '" + values[fieldName] + "'";
                                }
                                else
                                {
                                    updStr += ", " + fieldName + " = NULL";
                                }
                            }
                            else
                            {
                                if ((values[fieldName] as string) != "NULL")
                                {
                                    updStr += " " + fieldName + " = '" + values[fieldName] + "'";
                                }
                                else
                                {
                                    updStr += " " + fieldName + " = NULL";
                                }
                                firstFieldsCheckInsUpd = true;
                            }
                            break;

                        case int _:
                            if (firstFieldsCheckInsUpd)
                            {
                                updStr += ", " + fieldName + " = " + values[fieldName];
                            }
                            else
                            {
                                updStr += " " + fieldName + " = " + values[fieldName];
                                firstFieldsCheckInsUpd = true;
                            }
                            break;

                        case double _:
                            if (firstFieldsCheckInsUpd)
                            {
                                updStr += ", " + fieldName + " = " + values[fieldName].ToString().Replace(',', '.');
                            }
                            else
                            {
                                updStr += " " + fieldName + " = " + values[fieldName].ToString().Replace(',', '.');
                                firstFieldsCheckInsUpd = true;
                            }
                            break;

                        case Image _:
                            if (firstFieldsCheckInsUpd)
                            {
                                updStr += ", " + fieldName + " = 0x" + ArsLibrary.ByteArrayToString(ArsLibrary.ImageToByteArray(values[fieldName] as Image));
                            }
                            else
                            {
                                updStr += " " + fieldName + " = 0x" + ArsLibrary.ByteArrayToString(ArsLibrary.ImageToByteArray(values[fieldName] as Image));
                                firstFieldsCheckInsUpd = true;
                            }
                            break;
                        }
                    }
                    updStr += " WHERE " + WhereStr;
                    ArsSQLQry qryUpd = new ArsSQLQry();
                    qryUpd.lisansQry = lisansQry;
                    qryUpd.artezQry  = artezQry;
                    qryUpd.SQLText   = updStr;
                    qryUpd.Open();

                    execErrorCode   = qryUpd.errorCode;
                    execDescription = qryUpd.description;

                    break;

                case EnmQryMode.Delete:
                    string delStr = "DELETE FROM " + TableName + " WHERE " + WhereStr;

                    ArsSQLQry qryDel = new ArsSQLQry();
                    qryDel.lisansQry = lisansQry;
                    qryDel.artezQry  = artezQry;
                    qryDel.SQLText   = delStr;
                    qryDel.Open();

                    execErrorCode   = qryDel.errorCode;
                    execDescription = qryDel.description;

                    break;
                }
            }
            catch (Exception ex)
            {
                ArsMessage.ShowMessage("Hata", "Bilinmeyen Bir Hata Oluştu\n" + ex.Message);
            }
        }
Example #6
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)
                    {
                    }
                }
            }
        }