public ActionResult ChangeStudentGrade()
        {
            if ((Request.Form["gridRadios1"] != null) && (Request.Form["Student_id"] != null))
            {
                string       student_id   = Request.Form["Student_id"];
                int          course_id    = Convert.ToInt32(Request.Form["Course_id"]);
                int          grade        = Convert.ToInt32(Request.Form["Grade"]);
                PDAL         DBconnection = new PDAL();
                UsersCourses Student      = DBconnection.UsersCoursess.Find(student_id, course_id);
                string       option       = Request.Form["gridRadios1"].ToString();
                if (Student != null)
                {
                    if (option.Equals("option1"))
                    {
                        Student.moed1 = grade;
                        Student.final = grade;
                    }
                    else if (option.Equals("option2"))
                    {
                        Student.moed2 = grade;
                        Student.final = grade;
                    }
                    else
                    {
                        Student.final = grade;
                    }
                }


                DBconnection.SaveChanges();
            }

            return(Redirect("~/Administration/AdminMain"));
        }
 public ActionResult ChangeMoedDate()
 {
     try
     {
         string   date_time    = Request.Form["Date"] + Request.Form["Time"];
         int      cource_id    = Convert.ToInt32(Request.Form["Course_id"]);
         DateTime dt           = DateTime.ParseExact(date_time, "dd-MM-yyyyHH:mm", CultureInfo.InvariantCulture);
         PDAL     DBconnection = new PDAL();
         Course   a            = DBconnection.Courses.Find(cource_id);
         if (a == null)
         {
             Session["Alert"] = "No such course."; return(Redirect("~/Administration/AdminMain"));
         }
         if (Request.Form["gridRadios1"] == "option1")
         {
             a.moed1 = dt;
         }
         if (Request.Form["gridRadios1"] == "option2")
         {
             a.moed2 = dt;
         }
         DBconnection.SaveChanges();
     }
     catch
     {
         Session["Alert"] = "Bad time or date format.";
     }
     return(Redirect("~/Administration/AdminMain"));
 }
Exemple #3
0
        public JsonResult getDBSelect2DirectValue(string PageName, string PageParameterName, string value)
        {
            Page           P  = PDAL.FindPage(PageName);
            PageParameter  PP = P.DicPageParameters[PageParameterName];
            inputParameter ip = new inputParameter();

            ip.key   = PP.DBSelect2CommandDriectValueParameterName;
            ip.value = value;
            List <inputParameter> px  = new List <inputParameter>();
            inputParameter        res = new inputParameter();

            res.key = "result";

            px.Add(ip);
            try
            {
                if (PP.DBSelect2CommandDriectValue.StartsWith("$") == false)
                {
                    res.value = PDAL.ExecScaller(ref PP.DBSelect2CommandDriectValue, px);
                }
                else
                {
                    res.value = CustomScaler(PP.DBSelect2CommandDriectValue, "!DirectValue", px.ToArray());
                }
            }
            catch (Exception ex)
            {
                res.value = "!" + ex.Message;
            }


            return(Json(res));
        }
Exemple #4
0
        public string  sendFiles(string PageName)
        {
            Page p = PDAL.FindPage(PageName);
            Dictionary <string, string> FileSended = new Dictionary <string, string>();

            for (int k = 0; k < p.PageParameters.Count; k++)
            {
                PageParameter PP = p.PageParameters[k];
                if (PP.type == "FileInput")
                {
                    var C = Request.Files[PP.name];
                    if (C == null)
                    {
                        continue;
                    }
                    if (PP.MaxFileSize != "")
                    {
                        if (long.Parse(PP.MaxFileSize) * 1024 < C.InputStream.Length)
                        {
                            throw new Exception("اندازه غیر مجاز!!!");
                        }
                    }
                    bool   isCommit = false;
                    string ex       = System.IO.Path.GetExtension(C.FileName).ToLower().Substring(1);
                    for (int xx = 0; xx < PP.FileAllows.Count; xx++)
                    {
                        if (ex == PP.FileAllows[xx].ext.ToLower())
                        {
                            isCommit = true;
                        }
                    }
                    if (isCommit == false)
                    {
                        throw new Exception("پسوند غیر مجاز!!!");
                    }
                }
            }
            for (int k = 0; k < p.PageParameters.Count; k++)
            {
                PageParameter PP = p.PageParameters[k];
                if (PP.type == "FileInput")
                {
                    var C = Request.Files[PP.name];
                    if (C == null)
                    {
                        continue;
                    }
                    string ex       = System.IO.Path.GetExtension(C.FileName).ToLower();
                    string FilePath = Convertor.MilToPerDate(DateTime.Now).Replace('/', '.') + (new Random().Next(0, 30000000).ToString()) + "" + ex;
                    C.SaveAs(Server.MapPath(PP.FilePathAtServer + FilePath));

                    FileSended.Add(PP.name, FilePath);
                }
            }


            Session["FileSended"] = FileSended;
            return("");
        }
        public ActionResult GetStudentListByJSON()
        {
            int  id                      = Convert.ToInt32(Session["Course_id"]);
            PDAL DBConnection            = new PDAL();
            List <UsersCourses> Students =
                (from x in DBConnection.UsersCoursess where x.course == id select x).ToList <UsersCourses>();

            return(Json(Students, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ChangeStudentGrade()
        {
            if ((Request.Form["gridRadios1"] != null) && (Request.Form["Student_id"] != null))
            {
                string student_id   = Request.Form["Student_id"];
                int    course_id    = Convert.ToInt32(Request.Form["Course_id"]);
                int    grade        = Convert.ToInt32(Request.Form["Grade"]);
                string Lecturer     = (string)Session["id"];
                PDAL   DBconnection = new PDAL();

                UsersCourses Student         = DBconnection.UsersCoursess.Find(student_id, course_id);
                string       option          = Request.Form["gridRadios1"].ToString();
                string       Course_Lecturer = "-1";
                try
                {
                    Course_Lecturer = (DBconnection.Courses.Find(course_id).lecturer_id).ToString();
                }
                catch (Exception a)
                {
                    if (a != null)
                    {
                        Course_Lecturer = "-1";
                    }
                }
                if (Regex.Replace(Course_Lecturer, " ", "") != Lecturer)
                {
                    Session["Alert"] = "You dont have permission to change that course.";
                    return(Redirect("~/Lecturers/LecturerMain"));
                }
                if (Student == null)
                {
                    Session["Alert"] = "No such student.";
                    return(Redirect("~/Lecturers/LecturerMain"));
                }

                if (option.Equals("option1"))
                {
                    Student.moed1 = grade;
                    Student.final = grade;
                }
                else if (option.Equals("option2"))
                {
                    Student.moed2 = grade;
                    Student.final = grade;
                }
                else
                {
                    Student.final = grade;
                }


                DBconnection.SaveChanges();
            }

            return(Redirect("~/Lecturers/LecturerMain"));
        }
        public ActionResult AdminMain()
        {
            string        id           = (string)Session["id"];
            PDAL          DBConnection = new PDAL();
            List <Course> List_Courses =
                (from x in DBConnection.Courses select x).ToList <Course>();
            ViewModel vm = new ViewModel();

            vm.ListCource = List_Courses;
            return(View("AdminMain", vm));
        }
Exemple #8
0
        public JsonResult Select2AjaxTable(string PageName, string colname, List <inputParameter> Parameters)
        {
            Page Info = PDAL.FindPage(PageName);

            ConvertNullToEmpty(Parameters);

            column Pp = null;

            for (int k = 0; k < Info.tables[0].columns.Count; k++)
            {
                if (Info.tables[0].columns[k].name == colname)
                {
                    Pp = Info.tables[0].columns[k];
                }
            }

            for (int k = 0; k < Pp.DBSelectCommandParameters.Count; k++)
            {
                if (Pp.DBSelectCommandParameters[k].source == "Session")
                {
                    inputParameter i = new inputParameter();
                    i.key   = Pp.DBSelectCommandParameters[k].name;
                    i.value = PDAL.GetSession(Pp.DBSelectCommandParameters[k].Parameter);
                    Parameters.Add(i);
                }
            }


            DataTable   Dt = PDAL.ReadRecords(ref Pp.DBSelect2Command, Parameters);
            List <item> it = new List <item>();

            for (int k = 0; k < Pp.options.Count; k++)
            {
                item i = new item();
                i.id   = Pp.options[k].value;
                i.text = Pp.options[k].text;
                it.Add(i);
            }
            for (int k = 0; k < Dt.Rows.Count; k++)
            {
                item i = new item();
                i.id   = Dt.Rows[k][Pp.codeColumn].ToString();
                i.text = Dt.Rows[k][Pp.textColumn].ToString();
                it.Add(i);
            }

            obj o = new obj();

            o.results = it.ToArray();
            return(Json(o));
        }
Exemple #9
0
        public JsonResult AjaxActionTable(string actionName, List <inputParameter> Parameters)
        {
            if (Parameters == null)
            {
                Parameters = new List <inputParameter>();
            }
            ConvertNullToEmpty(Parameters);
            action Info = PDAL.actionAccess[actionName];

            PDALSect.AccessResult DoAccess = PDALSect.GetCheckPer(Info.PerKey, actionName, Parameters);
            ScallerResult         Res      = new ScallerResult();



            try
            {
                if (DoAccess == PDALSect.AccessResult.AccessDenied)
                {
                    Res.code    = 403;
                    Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
                    return(Json(Res));
                }
                if (DoAccess == PDALSect.AccessResult.ReLogin)
                {
                    Res.code    = 401;
                    Res.Message = "نیاز به ورود مجدد می باشد";
                    return(Json(Res));
                }
                Res.code    = 0;
                Res.Message = "با موفقیت انجام شد";
                if (Info.DBCommand.StartsWith("$") == false)
                {
                    Res.retrunValue = PDAL.DataTableToJson(PDAL.ReadRecords(ref Info.DBCommand, Parameters), 0, "");
                }
                else
                {
                    Res.retrunValue = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(CustomRecords(Info.DBCommand, "!AjaxActions", Parameters.ToArray()));
                }
            }
            catch (SqlException Ex)
            {
                Res.code    = 300;
                Res.Message = "خطایی رخ داد:" + Ex.ErrorCode.ToString() + ":" + Ex.Message;
            }
            catch (Exception Ex)
            {
                Res.code    = 500;
                Res.Message = "خطایی رخ داد:" + Ex.Message;
            }
            return(Json(Res));
        }
Exemple #10
0
        public ActionResult Login(string txtUserId, string txtPassword)
        {
            try
            {
                string R = "CheckLogin";
                List <inputParameter> Lis = new List <inputParameter>();
                inputParameter        p   = new inputParameter();
                p.key   = "UserId";
                p.value = txtUserId;
                Lis.Add(p);
                p       = new inputParameter();
                p.key   = "Password";
                p.value = Convertor.Encrypt(txtPassword, txtPassword);
                Lis.Add(p);


                int r = int.Parse(PDAL.ReadRecords(ref R, Lis).Rows[0][0].ToString());
                if (r == 0)
                {
                    return(Login("نام کاربری یا گذرواژه نادرست است"));
                }
                else
                {
                    Session["UserName"] = txtUserId;
                    Dictionary <string, string> Per = new Dictionary <string, string>();
                    R       = "GetAllPerForUser";
                    Lis     = new List <inputParameter>();
                    p       = new inputParameter();
                    p.key   = "UserId";
                    p.value = txtUserId;
                    Lis.Add(p);



                    DataTable Dt = PDAL.ReadRecords(ref R, Lis);
                    foreach (DataRow Dr in Dt.Rows)
                    {
                        Per.Add(Dr["PerKey"].ToString(), "-");
                    }
                    Session["Per"] = Per;
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch
            {
                return(Login("خطای نامشخص"));
            }
        }
Exemple #11
0
        public JsonResult AjaxAction(string actionName, List <inputParameter> Parameters)
        {
            ConvertNullToEmpty(Parameters);
            action Info = PDAL.actionAccess[actionName];

            PDALSect.AccessResult DoAccess = PDALSect.GetCheckPer(Info.PerKey, actionName, Parameters);
            ScallerResult         Res      = new ScallerResult();



            try
            {
                if (DoAccess == PDALSect.AccessResult.AccessDenied)
                {
                    Res.code    = 403;
                    Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
                    return(Json(Res));
                }
                if (DoAccess == PDALSect.AccessResult.ReLogin)
                {
                    Res.code    = 401;
                    Res.Message = "نیاز به ورود مجدد می باشد";
                    return(Json(Res));
                }
                Res.code    = 0;
                Res.Message = "با موفقیت انجام شد";
                if (Info.DBCommand.StartsWith("$") == false)
                {
                    Res.retrunValue = PDAL.ExecScaller(ref Info.DBCommand, Parameters);
                }
                else
                {
                    Res.retrunValue = CustomScaler(Info.DBCommand, Info.name, Parameters.ToArray());
                }
            }
            catch (SqlException Ex)
            {
                Res.code    = 300;
                Res.Message = "خطایی رخ داد:" + Ex.ErrorCode.ToString() + ":" + Ex.Message;
            }
            catch (Exception Ex)
            {
                Res.code    = 500;
                Res.Message = "خطایی رخ داد:" + Ex.Message;
            }
            return(Json(Res));
        }
        public ActionResult ChangeCourseTime()
        {
            string   day = Request.Form["day"];
            TimeSpan start, end;

            try
            {
                start = TimeSpan.Parse(Request.Form["start"]);
                end   = TimeSpan.Parse(Request.Form["end"]);
                if (start >= end)
                {
                    Session["Alert"] = "Bad time format.";  return(Redirect("~/Administration/AdminMain"));
                }
            }
            catch (Exception a)
            {
                a.GetType();
                Session["Alert"] = "Bad time format.";  return(Redirect("~/Administration/AdminMain"));
            }
            int    Course_id    = Convert.ToInt32(Request.Form["Course_id"]);
            PDAL   DBconnection = new PDAL();
            Course c            = DBconnection.Courses.Find(Course_id);

            if (c == null)
            {
                Session["Alert"] = "No such course.";; return(Redirect("~/Administration/AdminMain"));
            }
            foreach (Course a in DBconnection.Courses)
            {
                if (a.day == c.day)
                {
                    if (a != c)
                    {
                        if (CheckIfTimeOverlaps(a, start, end))
                        {
                            Session["Alert"] = "Time overlaps other course.";
                            return(Redirect("~/Administration/AdminMain"));
                        }
                    }
                }
            }
            c.end_time   = end;
            c.start_time = start;
            DBconnection.SaveChanges();
            return(Redirect("~/Administration/AdminMain"));
        }
        public ActionResult AddStudentToCource()
        {
            int course_id;

            try
            {
                course_id = Convert.ToInt32(Request.Form["Course_id"]);
            }catch (Exception a)
            {
                a.GetType();
                Session["Alert"] = "No such course.";
                return(Redirect("~/Administration/AdminMain"));
            }


            string       Student_id   = (string)Request.Form["Student_id"];
            PDAL         DBconnection = new PDAL();
            UsersCourses Student      = DBconnection.UsersCoursess.Find(Student_id, course_id);

            if (Student == null)
            {
                Session["Alert"] = "Student is alredy tacking the course or no such student.";
                return(Redirect("~/Administration/AdminMain"));
            }
            string role = (DBconnection.Users.Find(Student_id)).role.ToString();

            if (Regex.Replace(role, " ", "") != "1")
            {
                Session["Alert"] = "The user is not student.";
                return(Redirect("~/Administration/AdminMain"));
            }
            if (CheckIfCourseOverlaps(Student_id, course_id))
            {
                Session["Alert"] = "Course overlap with another course.";
                return(Redirect("~/Administration/AdminMain"));
            }
            Student       = new UsersCourses();
            Student.id    = Student_id; Student.course = course_id;
            Student.moed1 = Student.moed2 = Student.final = 0;
            DBconnection.UsersCoursess.Add(Student);
            DBconnection.SaveChanges();

            return(Redirect("~/Administration/AdminMain"));
        }
        public ActionResult connect()
        {
            string      pass         = Request.Form["Password"];
            string      ID           = Request.Form["user_id"];
            PDAL        DBConnection = new PDAL();
            List <User> UserList     =
                (from x in DBConnection.Users where x.id == ID && x.password == pass select x).ToList <User>();

            if (UserList.Count() == 0)
            {
                Session["Alert"] = "Wrong Credantials,Try Again!";
                return(Redirect("~"));
            }
            Session["Alert"] = "";
            try
            {
                Session["id"]        = Regex.Replace(UserList[0].id, " ", "");
                Session["role"]      = Regex.Replace(UserList[0].role, " ", "");
                Session["name"]      = UserList[0].name;
                Session["Course_id"] = "-1";
            }
            catch (Exception) { return(Redirect("~")); }

            if (Session["role"].ToString() == "1")
            {
                return(RedirectToAction("StudentMain", "Students"));
            }
            else if (Session["role"].ToString() == "2")
            {
                return(RedirectToAction("LecturerMain", "Lecturers"));
            }
            else if (Session["role"].ToString() == "3")
            {
                return(RedirectToAction("AdminMain", "Administration"));
            }
            else
            {
                return(Redirect("~"));
            }
        }
        public Boolean CheckIfCourseOverlaps(string Student_id, int course_id)
        {
            PDAL       DBConnection       = new PDAL();
            List <int> StudentsCourses_id = (
                from x in DBConnection.UsersCoursess where x.id == Student_id select x.course).ToList <int>();

            Course toCheck = DBConnection.Courses.Find(course_id);

            foreach (int n in StudentsCourses_id)
            {
                Course a = DBConnection.Courses.Find(n);
                if (a.day == toCheck.day)
                {
                    if (CheckIfTimeOverlaps(a, toCheck.start_time, toCheck.end_time))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #16
0
        public ActionResult StudentMain()
        {
            string id           = (string)Session["id"];
            PDAL   DBConnection = new PDAL();
            List <UsersCourses> List_usersCourses =
                (from x in DBConnection.UsersCoursess where id == x.id select x).ToList <UsersCourses>();

            List <int> UsersCourseString =
                (from x in DBConnection.UsersCoursess where id == x.id select x.course).ToList <int>();
            List <Course> ALL_courses     = (from x in DBConnection.Courses select x).ToList <Course>();
            List <Course> Courses_user_in = new List <Course>();

            foreach (Course c in ALL_courses)
            {
                if (UsersCourseString.Contains(c.course_id))
                {
                    Courses_user_in.Add(c);
                }
            }

            /*
             *          List<Course> List_courses=
             *            (from x in DBConnection.Courses
             *             where x.course_id == (
             *                  from x in DBConnection.UsersCoursess where id == x.id select x.course
             *             )
             *             select x).ToList<Course>();*/



            ViewModel vm = new ViewModel();

            vm.users_courses      = new UsersCourses();
            vm.ListCource         = Courses_user_in;
            vm.List_users_courses = List_usersCourses;
            return(View("StudentMain", vm));
        }
        public ActionResult ShowStudentList()
        {
            string id            = (string)Session["id"];
            string Rq_form       = (string)Request.Form["Course_id"];
            int    req_course_id = -1;

            if (Rq_form != "")
            {
                req_course_id = Convert.ToInt32(Request.Form["Course_id"]);
            }
            PDAL   DBconnaction = new PDAL();
            Course CourseIns    = DBconnaction.Courses.Find(req_course_id);

            if (CourseIns != null)
            {
                if (Regex.Replace(CourseIns.lecturer_id, " ", "") == id)
                {
                    Session["Course_id"] = req_course_id.ToString();
                    return(LecturerMain());
                }
            }
            Session["Course_id"] = "Denied";
            return(LecturerMain());
        }
Exemple #18
0
 public string CreateOnePageMgt(string id)
 {
     return(PDAL.GenPageForSaveOnePageMaster(id));
 }
Exemple #19
0
 public string CreateQuick(string id)
 {
     return(PDAL.GetQuickSerachProc(id));
 }
Exemple #20
0
 public string CreateScallerTableView(string id)
 {
     return(PDAL.mgtAllonce(id));
 }
Exemple #21
0
 public string ShowAllPers()
 {
     return(PDAL.GetAllPer());
 }
Exemple #22
0
 public string CreatePage(string id)
 {
     return(PDAL.CreatePageToTableView(id));
 }
Exemple #23
0
 public string CreateMgt(string id)
 {
     return(PDAL.mgtAllonce(id));
 }
Exemple #24
0
 public string CreateProc(string id)
 {
     return(PDAL.CreateBaseProcForTable(id).Replace("\n", "<br />"));
 }
Exemple #25
0
        public JsonResult ScallerSubmit(string PageName, List <inputParameter> Parameters)
        {
            if (Parameters == null)
            {
                Parameters = new List <inputParameter>();
            }
            ConvertNullToEmpty(Parameters);
            Page Info = PDAL.FindPage(PageName);

            PDAL.ConvertValues(Info, Parameters);
            ScallerResult Res = new ScallerResult();

            PDALSect.AccessResult DoAccess = PDALSect.GetCheckPer(Info.PerKey, PageName, Parameters);
            PDAL.InitServerSideParametersForSubmit(PageName, ref Parameters);
            string error = PDAL.ValidateAndSetDefaultValue(Info, Parameters);

            if (DoAccess == PDALSect.AccessResult.AccessDenied)
            {
                Res.code    = 403;
                Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
                return(Json(Res));
            }
            if (DoAccess == PDALSect.AccessResult.ReLogin)
            {
                Res.code    = 401;
                Res.Message = "نیاز به ورود مجدد می باشد";
                return(Json(Res));
            }
            if (error != "")
            {
                Res.code    = 200;
                Res.Message = error;
                return(Json(Res));
            }


            try
            {
                Res.code    = 0;
                Res.Message = "با موفقیت انجام شد";
                if (Info.DBCommand.StartsWith("$") == false)
                {
                    Res.retrunValue = PDAL.ExecScaller(ref Info.DBCommand, PDAL.SkipParameters(Info, Parameters));
                }
                else
                {
                    Res.retrunValue = CustomScaler(Info.DBCommand, PageName, Parameters.ToArray());
                }
            }
            catch (SqlException Ex)
            {
                Res.code    = 300;
                Res.Message = "خطایی رخ داد:" + Ex.ErrorCode.ToString() + ":" + Ex.Message;
            }
            catch (Exception Ex)
            {
                Res.code    = 500;
                Res.Message = "خطایی رخ داد:" + Ex.Message;
            }
            return(Json(Res));
        }
        public JsonResult getTableViewRecords(string PageName, List <inputParameter> Parameters)
        {
            if (Parameters == null)
            {
                Parameters = new List <inputParameter>();
            }
            ConvertNullToEmpty(Parameters);
            if (PDAL.loaded == false)
            {
                PDAL.load();
            }
            Page Info = PDAL.FindPage(PageName);

            PDALSect.AccessResult DoAccess = PDALSect.GetCheckPer(Info.PerKey, PageName, Parameters);
            ScallerResult         Res      = new ScallerResult();

            PDAL.InitServerSideParametersForSubmit(PageName, ref Parameters);
            if (DoAccess == PDALSect.AccessResult.AccessDenied)
            {
                Res.code    = 403;
                Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
                return(Json(Res));
            }
            if (DoAccess == PDALSect.AccessResult.ReLogin)
            {
                Res.code    = 401;
                Res.Message = "نیاز به ورود مجدد می باشد";
                return(Json(Res));
            }
            PDAL.ConvertValues(Info, Parameters);

            string error = PDAL.ValidateAndSetDefaultValue(Info, Parameters);

            if (error != "")
            {
                Res.code    = 200;
                Res.Message = error;
                return(Json(Res));
            }


            try
            {
                Res.code    = 0;
                Res.Message = "با موفقیت انجام شد";
                if (Info.DBCommand.StartsWith("$") == false)
                {
                    DataTable Dt = PDAL.ReadRecords(ref Info.DBCommand, PDAL.SkipParameters(Info, Parameters));
                    Res.retrunValue = PDAL.DataTableToJson(Dt, Res.code, "");
                    if (Info.PagingCountCommand != "")
                    {
                        Res.RecordTotal = int.Parse(PDAL.ExecScaller(ref Info.PagingCountCommand, PDAL.SkipParameters(Info, Parameters)));
                    }
                    else
                    {
                        Res.RecordTotal = Dt.Rows.Count;
                    }
                }
                else
                {
                    Res.retrunValue = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(CustomRecords(Info.DBCommand, PageName, Parameters.ToArray()));
                }
            }
            catch (SqlException Ex)
            {
                Res.code    = 300;
                Res.Message = "خطایی رخ داد:" + Ex.ErrorCode.ToString() + ":" + Ex.Message;
            }
            catch (Exception Ex)
            {
                Res.code    = 500;
                Res.Message = "خطایی رخ داد:" + Ex.Message;
            }
            return(Json(Res));
        }
Exemple #27
0
        public JsonResult BatchCommand(string PageName, string CommandName, inputParameter[][][][] records)
        {
            Page         Info = PDAL.FindPage(PageName);
            BatchCommand B    = null;

            for (int i = 0; i < Info.BatchCommands.Count; i++)
            {
                if (Info.BatchCommands[i].name == CommandName)
                {
                    B = Info.BatchCommands[i];
                    break;
                }
            }
            ScallerResult Res = new ScallerResult();

            PDALSect.AccessResult DoAccess = PDALSect.GetCheckPer(B.PerKey, PageName, null);
            if (DoAccess == PDALSect.AccessResult.AccessDenied)
            {
                Res.code    = 403;
                Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
                return(Json(Res));
            }
            if (DoAccess == PDALSect.AccessResult.ReLogin)
            {
                Res.code    = 401;
                Res.Message = "نیاز به ورود مجدد می باشد";
                return(Json(Res));
            }
            SqlConnection Con = PDAL.GetConnection();

            if (Con.State != ConnectionState.Open)
            {
                Con.Open();
            }
            string[] scallerValues = new string[records.Length];


            SqlTransaction Tran = Con.BeginTransaction();

            try
            {
                for (int k = 0; k < records.Length; k++)
                {
                    Command Com = B.Commands[k];
                    List <inputParameter> initValues = new List <inputParameter>();

                    for (int q = 0; q < Com.Parameters.Count; q++)
                    {
                        if (Com.Parameters[q].sourceType == "Session")
                        {
                            inputParameter ix = new inputParameter();
                            ix.key   = Com.Parameters[q].name;
                            ix.value = PDAL.GetSession(Com.Parameters[q].sourceTypeParameter);

                            initValues.Add(ix);
                        }
                        if (Com.Parameters[q].sourceType == "SpecValue")
                        {
                            inputParameter ix = new inputParameter();
                            ix.key   = Com.Parameters[q].name;
                            ix.value = PDAL.GetSpecValue(Com.Parameters[q].sourceTypeParameter);

                            initValues.Add(ix);
                        }
                        if (Com.Parameters[q].sourceType == "ScallerValues")
                        {
                            inputParameter ix = new inputParameter();
                            ix.key   = Com.Parameters[q].name;
                            ix.value = scallerValues[int.Parse(Com.Parameters[q].sourceTypeParameter)];

                            initValues.Add(ix);
                        }
                    }


                    for (int k2 = 0; k2 < records[k].Length; k2++)
                    {
                        PDAL.ConvertValuesBatch(Info, Com, records[k][k2]);

                        if (Com.DBCommand.StartsWith("$") == false)
                        {
                            for (int k3 = 1; k3 < records[k][k2].Length; k3++)
                            {
                                List <inputParameter> par = new List <inputParameter>();
                                par.AddRange(initValues);
                                par.AddRange(records[k][k2][k3]);
                                scallerValues[k] = PDAL.ExecScallerWithConnection(ref Com.DBCommand, par, Con, Tran);
                            }
                        }
                        else
                        {
                            for (int k3 = 1; k3 < records[k][k2].Length; k3++)
                            {
                                List <inputParameter> par = new List <inputParameter>();
                                par.AddRange(initValues);
                                par.AddRange(records[k][k2][k3]);
                                scallerValues[k] = CustomScaler(Com.DBCommand, PageName, par.ToArray());
                            }
                        }
                    }
                }
                Tran.Commit();
                Res.code    = 0;
                Res.Message = "با موفقیت انجام شد";
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                Res.code    = 500;
                Res.Message = "خطا در انجام عملیات" + "<br />" + ex.Message;
            }

            if (Con.State != ConnectionState.Closed)
            {
                Con.Close();
            }
            return(Json(Res));
            //ConvertNullToEmpty(Parameters);

            //PDAL.ConvertValues(Info, Parameters);
            //ScallerResult Res = new ScallerResult();
            //bool DoAccess = PDALSect.GetCheckPer(Info.PerKey, PageName, Parameters);
            //PDAL.InitServerSideParametersForSubmit(PageName, ref Parameters);
            //string error = PDAL.ValidateAndSetDefaultValue(Info, Parameters);

            //if (DoAccess == false)
            //{
            //    Res.code = 403;
            //    Res.Message = "شما اجازه دسترسی به این قسمت را ندارید";
            //    return Json(Res);

            //}
            //if (error != "")
            //{
            //    Res.code = 200;
            //    Res.Message = error;
            //    return Json(Res);

            //}


            //try
            //{


            //    Res.code = 0;
            //    Res.Message = "با موفقیت انجام شد";
            //    Res.retrunValue = PDAL.ExecScaller(Info.DBCommand, PDAL.SkipParameters(Info, Parameters));

            //}
            //catch (SqlException Ex)
            //{

            //    Res.code = 300;
            //    Res.Message = "خطایی رخ داد:" + Ex.ErrorCode.ToString() + ":" + Ex.Message;

            //}
            //catch (Exception Ex)
            //{
            //    Res.code = 500;
            //    Res.Message = "خطایی رخ داد:" + Ex.Message;

            //}
            //return Json(Res);
        }
Exemple #28
0
        public ActionResult Index()
        {
            DateTime CreateTime       = new FileInfo(Server.MapPath("~/PDA.Config")).LastWriteTime;
            bool     needToBuildFiles = true;

            if (System.IO.File.Exists(Server.MapPath("~/builded.dat")))
            {
                FileInfo x = new FileInfo(Server.MapPath("~/builded.dat"));
                if (x.LastWriteTime > CreateTime)
                {
                    needToBuildFiles = false;
                }
            }


            if (PDAL.loaded == false)
            {
                PDAL.load();
            }
            else
            {
                if (needToBuildFiles == true)
                {
                    PDAL.load();
                }
            }
            if (needToBuildFiles)
            {
                PDAL.BuildApp();
                System.IO.File.WriteAllText(Server.MapPath("~/builded.dat"), "");
            }

            // nodes = Xml.GetElementsByTagName("xs:element" );
            // for (int k = 0; k < nodes.Count; k++)
            // {
            //
            //     XmlNode att = Xml.CreateElement("xs:annotation"  );
            //     nodes[k].AppendChild(att);
            //     XmlNode doc = Xml.CreateElement("xs:documentation" );
            //     doc.InnerText = "توضیحات";
            //     att.AppendChild(doc);
            //
            // }
            // nodes = Xml.GetElementsByTagName("xs:attribute" );
            // for (int k = 0; k < nodes.Count; k++)
            // {
            //
            //     XmlNode att = Xml.CreateElement("xs:annotation" );
            //     nodes[k].AppendChild(att);
            //     XmlNode doc = Xml.CreateElement("xs:documentation" );
            //     doc.InnerText = "توضیحات";
            //     att.AppendChild(doc);
            //
            // }

            try
            {
                SqlConnection Con = PDALEngine.PDAL.GetConnection();
                Con.Close();
            }
            catch (Exception ex)
            {
                return(RedirectToAction("GetErrorAsText", new { errMsg = "عدم امکان با بانک یا عدم پیکربندی صحیح در فایل PDA.Config : " + ex.Message }));
            }
            if (PDALSect.isLogined() == false)
            {
                return(RedirectToAction("Login"));
            }
            ViewBag.App = PDAL.App;
            return(View());
        }