public JsonResult LoginAuth(string mobile, string password)
        {
            var ModelSender = new ErrorReporterModel();

            if (string.IsNullOrEmpty(mobile))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا شماره موبایل خودرا وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            if (string.IsNullOrEmpty(password))
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX1075463",
                    Errormessage = $"لطفا کلمه عبور را وارد نمایید",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
            EncDec dn = new EncDec();

            password = dn.HMACMD5Generator(password);
            PDBC db = new PDBC();
            List <ExcParameters> pars = new List <ExcParameters>();
            ExcParameters        par  = new ExcParameters()
            {
                _KEY   = "@Mobile",
                _VALUE = mobile
            };

            pars.Add(par);
            par = new ExcParameters()
            {
                _KEY   = "@PASS",
                _VALUE = password
            };
            pars.Add(par);
            db.Connect();
            DataTable dt = db.Select("SELECT [id_Customer] ,[C_Mobile] ,[C_FirstName] ,[C_LastNAme] FROM [tbl_Customer_Main] WHERE [C_Mobile] LIKE @Mobile AND [C_Password] LIKE @PASS AND [C_ISActivate] = 1", pars);

            db.DC();
            if (dt.Rows.Count == 1)
            {
                tbl_Customer_Main tcm = new tbl_Customer_Main()
                {
                    id_Customer = dt.Rows[0]["id_Customer"].ToString(),
                    C_FirstName = dt.Rows[0]["C_FirstName"].ToString(),
                    C_LastNAme  = dt.Rows[0]["C_LastNAme"].ToString(),
                    C_Mobile    = dt.Rows[0]["C_Mobile"].ToString()
                };
                try
                {
                    var userCookieIDV = new HttpCookie(ProjectProperies.AuthCustomerCode());
                    userCookieIDV.Value   = CoockieController.SetCustomerAUTHCookie(tcm);
                    userCookieIDV.Expires = DateTime.Now.AddDays(2);
                    Response.SetCookie(userCookieIDV);
                }
                catch (Exception coockieEXception)
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth)
                    {
                        EXOBJ = coockieEXception
                    };
                    ModelSender = new ErrorReporterModel
                    {
                        ErrorID      = "EX1075463",
                        Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                        Errortype    = "Error"
                    };
                    return(Json(ModelSender));
                }

                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "SX106",
                    Errormessage = $"با موفقیت وارد شدید!",
                    Errortype    = "Success"
                };
                return(Json(ModelSender));
            }
            else
            {
                ModelSender = new ErrorReporterModel
                {
                    ErrorID      = "EX115",
                    Errormessage = $"کاربری با این مشخصات یافت نشد!",
                    Errortype    = "Error"
                };
                return(Json(ModelSender));
            }
        }
Ejemplo n.º 2
0
        public string UploadImages(ImageInGalleryModel senderObj, List <HttpPostedFileBase> AllUploadedimages)
        {
            //File.WriteAllText(System.Web.HttpContext.Current.Server.MapPath($"~/ErrorLogs/{FolderName}/ErrorOn({CodeGenerated}--{FromWhere})-{PersianDateTime.Now.Year}-{PersianDateTime.Now.Month}-{PersianDateTime.Now.Day}-{PersianDateTime.Now.Hour} {PersianDateTime.Now.Minute} {PersianDateTime.Now.Second}.Panda"), excep);
            PDBC db = new PDBC();
            List <ExcParameters> parss = new List <ExcParameters>();

            parss.Add(new ExcParameters()
            {
                _KEY   = "@Name",
                _VALUE = senderObj.ImageName
            });
            db.Connect();
            using (DataTable dt = db.Select("SELECT Count(*)as RN FROM [tbl_ADMIN_UploaderStructure] WHERE [uploadPicName] LIKE @Name", parss))
            {
                db.DC();
                if (Convert.ToInt32(dt.Rows[0]["RN"].ToString()) > 0)
                {
                    return("-1");
                }
            }
            parss = null;
            List <DatabaseImageUploadStructure> DIUS = new List <DatabaseImageUploadStructure>();

            db.Connect();
            using (DataTable dt = db.Select("SELECT [picSizeType] ,[picSizeTypeName] ,[picSizeTypeWidth] ,[picSizeTypeHeight] FROM [tbl_ADMIN_UploaderStructure_ImageSize]"))
            {
                db.DC();
                int ii = dt.Rows.Count;
                for (int i = 0; i < ii; i++)
                {
                    DIUS.Add(new DatabaseImageUploadStructure()
                    {
                        picSizeType       = dt.Rows[i]["picSizeType"].ToString(),
                        picSizeTypeHeight = Convert.ToInt32(dt.Rows[i]["picSizeTypeHeight"].ToString()),
                        picSizeTypeWidth  = Convert.ToInt32(dt.Rows[i]["picSizeTypeWidth"].ToString()),
                        picSizeTypeName   = dt.Rows[i]["picSizeTypeName"].ToString()
                    });
                }
            }
            int ModelCount    = DIUS.Count;
            int UploadesCount = AllUploadedimages.Count;
            ImageSizeConvertor        imgSaver;
            string                    result    = "1";
            List <ReturnedSaveImages> SavedImgs = new List <ReturnedSaveImages>();

            for (int i = 0; i < UploadesCount; i++)
            {
                string CodeSave = DateTime.Now.Ticks.ToString();
                for (int j = 0; j < ModelCount; j++)
                {
                    imgSaver = new ImageSizeConvertor(DIUS[j], AllUploadedimages[i], CodeSave);
                    if (imgSaver.Returned.Status == "0")
                    {
                        result = "0";
                        break;
                    }
                    SavedImgs.Add(imgSaver.Returned);
                }
            }
            if (result == "0")
            {
                return("Error");
            }
            else
            {
                int UploadedAndSavedImagesCount = SavedImgs.Count;
                List <ExcParameters> Allparams  = new List <ExcParameters>();
                ExcParameters        parameters = new ExcParameters();
                db.Connect();
                string Qresult = "";
                string Aresult = "";
                for (int i = 0; i < UploadedAndSavedImagesCount; i++)
                {
                    Allparams  = new List <ExcParameters>();
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@Descriptions",
                        _VALUE = senderObj.ImageDescription
                    };
                    Allparams.Add(parameters);
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@uploadPicName",
                        _VALUE = senderObj.ImageName
                    };
                    Allparams.Add(parameters);
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@alt",
                        _VALUE = senderObj.ImageAlt
                    };
                    Allparams.Add(parameters);
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@PicCategoryType",
                        _VALUE = Convert.ToInt32(SavedImgs[i].UploadedImageTypeID)
                    };
                    Allparams.Add(parameters);
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@UploadAddress",
                        _VALUE = SavedImgs[i].UploadedImageSrc
                    };
                    Allparams.Add(parameters);
                    parameters = new ExcParameters()
                    {
                        _KEY   = "@savedCode",
                        _VALUE = SavedImgs[i].SaveCode
                    };
                    Allparams.Add(parameters);
                    Qresult += db.Script("INSERT INTO [tbl_ADMIN_UploaderStructure]([PicCategoryType],[ISDELETE],[alt],[uploadPicName],[Descriptions],[CreatedDate],[UploadAddress],[savedCode]) VALUES(@PicCategoryType,0,@alt,@uploadPicName,@Descriptions,GETDATE(),@UploadAddress,@savedCode)", Allparams);
                    Aresult += "1";
                }
                db.DC();
                if (Aresult == Qresult)
                {
                    return("1");
                }
                else
                {
                    PPBugReporter rep = new PPBugReporter(BugTypeFrom.ImageFileWriter, Qresult);
                    return("0");
                }
            }
        }
 public ActionResult LoginAuth(LoginAuthForm adObj)
 {
     if (ModelState.IsValid)
     {
         EncDec dn = new EncDec();
         adObj.Password = dn.HMACMD5Generator(adObj.Password);
         PDBC db = new PDBC();
         List <ExcParameters> parasms    = new List <ExcParameters>();
         ExcParameters        parameters = new ExcParameters()
         {
             _KEY   = "@username",
             _VALUE = adObj.Username
         };
         parasms.Add(parameters);
         parameters = new ExcParameters()
         {
             _KEY   = "@password",
             _VALUE = adObj.Password
         };
         parasms.Add(parameters);
         db.Connect();
         using (DataTable dt = db.Select("SELECT * FROM [tbl_ADMIN_main] WHERE ad_username LIKE @username AND ad_password LIKE @password", parasms))
         {
             db.DC();
             int dtrowcount = dt.Rows.Count;
             if (dtrowcount > 0)
             {
                 if (dt.Rows[0]["ad_isActive"].ToString() == "1")
                 {
                     Administrator AdminSession = new Administrator()
                     {
                         id_Admin = dt.Rows[0]["id_Admin"].ToString()
                         ,
                         ad_typeID = dt.Rows[0]["ad_typeID"].ToString()
                         ,
                         ad_firstname = dt.Rows[0]["ad_firstname"].ToString()
                         ,
                         ad_lastname = dt.Rows[0]["ad_lastname"].ToString()
                         ,
                         ad_avatarprofile = dt.Rows[0]["ad_avatarprofile"].ToString()
                         ,
                         ad_email = dt.Rows[0]["ad_email"].ToString()
                         ,
                         ad_phone = dt.Rows[0]["ad_phone"].ToString()
                         ,
                         ad_mobile = dt.Rows[0]["ad_mobile"].ToString()
                         ,
                         ad_has2stepSecurity = dt.Rows[0]["ad_has2stepSecurity"].ToString()
                         ,
                         ad_isActive = dt.Rows[0]["ad_isActive"].ToString()
                         ,
                         ad_isDelete = dt.Rows[0]["ad_isDelete"].ToString()
                         ,
                         ad_lastseen = dt.Rows[0]["ad_lastseen"].ToString()
                         ,
                         ad_lastlogin = dt.Rows[0]["ad_lastlogin"].ToString()
                         ,
                         ad_loginIP = dt.Rows[0]["ad_loginIP"].ToString()
                         ,
                         ad_regdate = dt.Rows[0]["ad_regdate"].ToString()
                         ,
                         ad_personalColorHexa = dt.Rows[0]["ad_personalColorHexa"].ToString()
                         ,
                         AdminModeID = dt.Rows[0]["AdminModeID"].ToString()
                         ,
                         ad_NickName = dt.Rows[0]["ad_NickName"].ToString(),
                         Username    = adObj.Username
                     };
                     try
                     {
                         Session["AdministratorRegistery"] = AdminSession;
                         try
                         {
                             var userCookieIDV = new HttpCookie(ProjectProperies.AuthCoockieCode());
                             userCookieIDV.Value   = CoockieController.SetCoockie(AdminSession);;
                             userCookieIDV.Expires = DateTime.Now.AddYears(5);
                             Response.SetCookie(userCookieIDV);
                         }
                         catch (Exception coockieEXception)
                         {
                             PPBugReporter rep = new PPBugReporter(BugTypeFrom.coockieAuth)
                             {
                                 EXOBJ = coockieEXception
                             };
                             var ModelSender = new ErrorReporterModel
                             {
                                 ErrorID      = "EX103",
                                 Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                                 Errortype    = "Error"
                             };
                             ViewBag.EXLogin = ModelSender;
                             return(View("Index"));
                         }
                         if (string.IsNullOrEmpty(adObj.urlRedirection))
                         {
                             return(RedirectToAction("Index", "AdministratorWorkplace"));
                         }
                         else
                         {
                             string[] GotToPage      = adObj.urlRedirection.Split('-');
                             string   actionname     = "";
                             string   controllername = "";
                             for (int i = 0; i < 2; i++)
                             {
                                 if (GotToPage[i].Contains("A_"))
                                 {
                                     actionname = GotToPage[i].Replace("A_", "");
                                 }
                                 else
                                 {
                                     controllername = GotToPage[i];
                                 }
                             }
                             return(RedirectToAction(actionname, controllername));
                         }
                     }
                     catch (Exception SessionException)
                     {
                         PPBugReporter rep = new PPBugReporter(BugTypeFrom.sessionAuth)
                         {
                             EXOBJ = SessionException
                         };
                         var ModelSender = new ErrorReporterModel
                         {
                             ErrorID      = "EX103",
                             Errormessage = $"عدم توانایی در ایجاد نشست فعال برای شما با پشتیبانی تماس حاصل فرمایید کد ارور شما {rep.CodeGenerated}",
                             Errortype    = "Error"
                         };
                         ViewBag.EXLogin = ModelSender;
                         return(View("Index"));
                     }
                 }
                 else
                 {
                     var ModelSender = new ErrorReporterModel
                     {
                         ErrorID      = "EX101",
                         Errormessage = "کاربر پیدا شده در وضعیت غیر فعال میباشد و اجازه دسترسی به پنل را نخواهد داشت",
                         Errortype    = "Error"
                     };
                     ViewBag.EXLogin = ModelSender;
                     return(View("Index"));
                 }
             }
             else
             {
                 var ModelSender = new ErrorReporterModel
                 {
                     ErrorID      = "EX102",
                     Errormessage = "کاربری با این مشخصات یافت نشد!",
                     Errortype    = "Error"
                 };
                 ViewBag.EXLogin = ModelSender;
                 return(View("Index"));
             }
         }
         db.DC();
         return(View("Index"));
     }
     else
     {
         var ModelSender = new ErrorReporterModel
         {
             ErrorID      = "EX100",
             Errormessage = "درخواست ارسال شده مطابق با ساختار امنیتی نمیباشد",
             Errortype    = "Error"
         };
         ViewBag.EXLogin = ModelSender;
         return(View("Index"));
     }
 }