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()); }
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) { Res.retrunValue = PDAL.DataTableToJson(PDAL.ReadRecords(ref Info.DBCommand, PDAL.SkipParameters(Info, Parameters)), Res.code, ""); } 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)); }
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); }