コード例 #1
0
ファイル: Config.cs プロジェクト: programs4/CES
 public static bool _RowsBoolean(this DataTable Dt, string ColumnsName, int RowsIndex = 0)
 {
     if (Dt == null || Dt.Rows.Count < 1)
     {
         DALC.ErrorLogs(string.Format("Rows null or count error.  ColumnsName: {0}", ColumnsName));
         throw new Exception("Rows null or count error.  ColumnsName: " + ColumnsName);
     }
     else
     {
         return((bool)Dt.Rows[RowsIndex][ColumnsName]);
     }
 }
コード例 #2
0
ファイル: Config.cs プロジェクト: programs4/CES
 public static object _RowsObject(this System.Data.DataTable Dt, string ColumnsName, int RowsIndex = 0)
 {
     if (Dt.Rows == null || Dt.Rows.Count < 1)
     {
         DALC.ErrorLogs(string.Format("Rows null or count error.  ColumnsName: {0}", ColumnsName));
         throw new Exception("Rows null or count error.  ColumnsName: " + ColumnsName);
     }
     else
     {
         return(Dt.Rows[RowsIndex][ColumnsName]);
     }
 }
コード例 #3
0
ファイル: ImageResize.cs プロジェクト: programs4/CES
    public static bool ImgResize(string Path, int Width, int Height, System.IO.Stream StreamFileupload, long ImgQuality)
    {
        try
        {
            //Thumbnain yaradaq, şəkil təmizliyi maksimum olacaq. ***************************
            string thumbnailFilePath = string.Empty;
            using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(StreamFileupload))
            {
                if (Width == -1)
                {
                    Width = (bmp.Width * (Height * 100) / bmp.Height) / 100;
                }
                else if (Height == -1)
                {
                    Height = (bmp.Height * (Width * 100) / bmp.Width) / 100;
                }

                thumbnailFilePath = HttpContext.Current.Server.MapPath(Path);         //Save File
                System.Drawing.Size newSize = new System.Drawing.Size(Width, Height); // Thumbnail ölçüsü (width = xxx) (height = xxx)

                using (System.Drawing.Bitmap thumb = new System.Drawing.Bitmap((System.Drawing.Image)bmp, newSize))
                {
                    using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumb)) // Original şəkili grafikə çeviririk: Təmizləmək üçün
                    {
                        //Təmizlik paramterləri:
                        g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.High;
                        g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                        //Şəkil Codec yaradırıq. Sondakı 1 index dəyəridir.
                        System.Drawing.Imaging.ImageCodecInfo codec = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1];

                        //Encoding paramter maksimum 100L gedir o zaman şəkilin həcmi çox olur.
                        System.Drawing.Imaging.EncoderParameters eParams = new System.Drawing.Imaging.EncoderParameters(1);

                        eParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, ImgQuality);

                        //Şəkili yaradırıq və dəyərlərini üstəki kimi daxil edirik.
                        g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, thumb.Width, thumb.Height));
                        //Son olaraq Save edirik:
                        thumb.Save(thumbnailFilePath, codec, eParams);
                        return(true);
                    }
                }
            }
        }
        catch (Exception er)
        {
            DALC.ErrorLogs(string.Format("Şəkil ölçüləndirmədə xəta baş verdi catch error: {0} , path: {1}", er.Message, Path));
            return(false);
        }
    }
コード例 #4
0
 /// Decrypts an encrypted text block
 public static string Decrypt(this string textToDecrypt)
 {
     try
     {
         TripleDESImplementation("fblsQBxfNs6nQ10wsRcMFwCN", "25ywte53");
         byte[] buffer = Convert.FromBase64String(textToDecrypt);
         TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
         des.Key = EncryptionKey;
         des.IV  = Global_IV;
         return(UTF8Encoding.UTF8.GetString(des.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length)));
     }
     catch (Exception er)
     {
         DALC.ErrorLogs(string.Format("Cryptography.Decrypt catch error: (Text: {0}) {1}  |  Url: {2}", textToDecrypt, er.Message, HttpContext.Current.Request.Url.ToString()));
         return("");
     }
 }
コード例 #5
0
    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        if (DListDownloadsTypes.SelectedValue == "-1")
        {
            Config.MsgBoxAjax("Sənədin növünü seçin!");
            return;
        }

        if (string.IsNullOrEmpty(TxtName.Text))
        {
            Config.MsgBoxAjax("Sənədin adını qeyd edin!");
            return;
        }

        string FileName = TxtName.Text.ClearTitle();

        if (DALC.CheckDownloadsByName(FileName, _DownloadsID))
        {
            Config.MsgBoxAjax("Bu sənəd adı, artıq istifadə edilib!");
            return;
        }

        if (_DownloadsID == 0)
        {
            if (!FileUp.HasFile)
            {
                Config.MsgBoxAjax("Fayl seçin!");
                return;
            }
        }

        if (DListStatus.SelectedValue == "-1")
        {
            Config.MsgBoxAjax("Sənədin statusunu qeyd edin!");
            return;
        }


        string  FileType          = "";
        decimal FileContentLength = 0;
        string  AllowType         = "-xls-xlsx-doc-docx-pdf-rar-zip-jpg-jpeg-png-txt-rtf-";

        if (FileUp.HasFile)
        {
            FileType = Path.GetExtension(FileUp.PostedFile.FileName);
            //FileName = string.Format("{0}{1}", FileName, FileType);
            FileContentLength = FileUp.PostedFile.ContentLength / 1024;

            if (AllowType.IndexOf(string.Format("-{0}-", FileType.Trim('.'))) < 0)
            {
                Config.MsgBoxAjax("Fayl formatı düzgün deyil!");
                return;
            }

            if (FileUp.PostedFile.CheckIfFileIsExecutable())
            {
                Config.MsgBoxAjax("Fayl formatı düzgün deyil!");
                return;
            }

            if (!FileUp.PostedFile.CheckFileContentLength(20))
            {
                Config.MsgBoxAjax("Faylın həcmi ən cox 20MB ola bilər!");
                return;
            }

            if (string.IsNullOrEmpty(FileName) || string.IsNullOrEmpty(FileName) || FileContentLength == 0)
            {
                Config.MsgBoxAjax("Xətalı fayl!");
                return;
            }

            try
            {
                FileUp.SaveAs(Server.MapPath(string.Format(_filePath, FileName + FileType)));
            }
            catch (Exception er)
            {
                DALC.ErrorLogs(string.Format("Sənədlər bölməsində fayl yüklənərkən xəta: {0}", er.Message));
                Config.MsgBoxAjax("Fayl yüklənərkən xəta baş verdi!");
                return;
            }
        }

        Dictionary <string, object> Dictionary = new Dictionary <string, object>();

        Dictionary.Add("DownloadsTypesID", int.Parse(DListDownloadsTypes.SelectedValue));
        Dictionary.Add("DataID", 0);
        Dictionary.Add("DisplayName", TxtName.Text);

        if (FileUp.HasFile)
        {
            Dictionary.Add("FileName", FileName);
            Dictionary.Add("FileType", FileType);
            Dictionary.Add("ContentLength", FileContentLength);
        }

        Dictionary.Add("Description", TxtDescription.Text);
        Dictionary.Add("IsActive", int.Parse(DListStatus.SelectedValue));


        int Result;

        if (_DownloadsID == 0)
        {
            Dictionary.Add("UsersID", DALC._GetUsersLogin.ID);
            Dictionary.Add("DownloadsQualityTypesID", (int)Tools.DownloadsQualityTypes.Qiymətləndirilməyib);
            Dictionary.Add("Data_Dt", DateTime.Now);
            Dictionary.Add("Add_Dt", DateTime.Now);
            Dictionary.Add("Add_Ip", Request.UserHostAddress.IPToInteger());

            Result = DALC.InsertDatabase(Tools.Table.Downloads, Dictionary);
            if (Result < 1)
            {
                Config.MsgBoxAjax(Config._DefaultErrorMessages);
                return;
            }
        }
        else
        {
            Dictionary.Add("WhereID", _DownloadsID);
            Result = DALC.UpdateDatabase(Tools.Table.Downloads, Dictionary);
            if (Result < 1)
            {
                Config.MsgBoxAjax(Config._DefaultErrorMessages);
                return;
            }
        }

        Config.MsgBoxAjax(Config._DefaultSuccessMessages, "/tools/downloads");
    }