public JsonResult GetNavPaneContent(string path = "~/", bool deepDive = false) { DirectoryInfo directory = new DirectoryInfo(KCore.PhysicalPath(path)); if (!directory.Exists) { return(Json(new KResult { status = KStatus.error, message = "directory not found" }, JsonRequestBehavior.AllowGet)); //throw new DirectoryNotFoundException(); } KNavPaneItem item = new KNavPaneItem { name = directory.Name, path = path, list = GetList(KCore.PhysicalPath(path)), }; return(Json(new KResult { status = KStatus.success, message = "", data = item }, JsonRequestBehavior.AllowGet)); }
private void _initEditor(T v, EUC_EditorMode m = EUC_EditorMode.Add) { string s = string.Empty; switch (m) { case EUC_EditorMode.Add: s = "ADD"; break; case EUC_EditorMode.Edit: s = "EDIT"; break; default: s = "UNK"; break; } Window wnd = KCore.GenerateWindow($"Dynamic KEditor [{typeof(T).Name}] {{{s}}}", _editor, Window.GetWindow(this)); _editor.Init(v); wnd.ShowDialog(); if (((T)v).ID != null && m == EUC_EditorMode.Add) { _mainSource.Add(v as T); _filteredSource.Add(v as T); } }
public JsonResult GetViewBoxContent(string path = "~/", string exclude = "") { DirectoryInfo directory = new DirectoryInfo(KCore.PhysicalPath(path)); if (!directory.Exists) { return(Json(new KResult { status = KStatus.error, message = "directory not found" }, JsonRequestBehavior.AllowGet)); //throw new DirectoryNotFoundException(); } KViewBoxContent content = new KViewBoxContent { parentName = directory.Name, parentPath = path, list = new List <KViewBoxItem>() }; foreach (FileSystemInfo fsi in directory.GetFileSystemInfos()) { content.list.Add(GetInfo(fsi)); } return(Json(new KResult { status = KStatus.success, message = content.list.Count.ToString(), data = content }, JsonRequestBehavior.AllowGet)); }
public ActionResult Download(string json, string downloadName) { if (string.IsNullOrWhiteSpace(json)) { return(new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest)); } if (string.IsNullOrWhiteSpace(downloadName)) { downloadName = "download"; } KSelectListItem[] array = JsonConvert.DeserializeObject <KSelectListItem[]>(json); using (var outputStream = new MemoryStream()) { using (ZipFile zip = new ZipFile(System.Text.Encoding.UTF8)) { foreach (KSelectListItem item in array) { string path = KCore.PhysicalPath(item.url); switch (item.type) { case "file": if (System.IO.File.Exists(path)) { zip.AddItem(path, ""); } break; case "folder": if (Directory.Exists(path)) { zip.AddDirectory(path, item.id); } break; } } zip.Save(outputStream); } outputStream.Position = 0; return(File(outputStream, "application/zip", downloadName + ".zip")); } //string path = Server.MapPath(url); //FileInfo file = new FileInfo(path); //string fileName = file.Name; //byte[] fileBytes = System.IO.File.ReadAllBytes(path); //return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName); }
private bool _validateInputs() { if (string.IsNullOrWhiteSpace(tb_Login.Text)) { KCore.ShowKError("Empty Login"); return(false); } if (string.IsNullOrWhiteSpace(pb_Password.Password)) { KCore.ShowKError("Empty Password"); return(false); } return(true); }
public JsonResult Upload(string parent = "~/") { string root = KCore.PhysicalPath(parent); if (!Directory.Exists(root)) { return(Json(new KResult { status = KStatus.error, message = "parent not exist" })); } KResult result = new KResult(); List <KResult> data = new List <KResult>(); foreach (string key in Request.Files.AllKeys) { KResult fileResult = new KResult(); HttpPostedFileBase file = Request.Files.Get(key); if (file != null && file.ContentLength > 0) { string fileName = file.FileName; string fullName = root + "\\" + fileName; fileResult.data = fileName; if (System.IO.File.Exists(fullName)) { fileResult.status = KStatus.warning; fileResult.message = "فایلی با نام و پسوند مشابه وجود دارد."; } else { try { file.SaveAs(fullName); /*fileResult.message = "فایل با موفقیت آپلود شد";*/ } catch (Exception ex) { fileResult.status = KStatus.error; fileResult.message = ex.Message; } } } else { fileResult.status = KStatus.warning; fileResult.message = "فایلی وجود ندارد."; } data.Add(fileResult); } result.data = data; return(Json(result)); }
private void _btn_Add_ItemClick(object sender, ItemClickEventArgs e) { var v = (new T()).New(); if (v != null) { _initEditor(v as T); } else { KCore.ShowKError("Failed to create new entity!"); } }
private void _btn_Edit_ItemClick(object sender, ItemClickEventArgs e) { var v = _lbeMain.SelectedItem; if (v != null) { _initEditor(v as T, EUC_EditorMode.Edit); } else { KCore.ShowKError("Nothing Selected!"); } }
public JsonResult Rename(string newName, string json) { if (string.IsNullOrWhiteSpace(newName)) { return(Json(new KResult { status = KStatus.error, message = "new name is empty" })); } KSelectListItem[] list = JsonConvert.DeserializeObject <KSelectListItem[]>(json); List <KResult> result = new List <KResult>(); foreach (KSelectListItem item in list) { string fullName = KCore.PhysicalPath(item.url); string newFullName; KStatus status = KStatus.success; string message = ""; switch (item.type) { case "file": FileInfo file = new FileInfo(fullName); newFullName = NewFileName(file.DirectoryName + "\\" + newName, file.Extension); try { file.MoveTo(newFullName); } catch (Exception ex) { status = KStatus.error; message = ex.Message; } break; case "folder": DirectoryInfo dir = new DirectoryInfo(fullName); newFullName = NewFolderName(dir.Parent.FullName + "\\" + newName); try { dir.MoveTo(newFullName); } catch (Exception ex) { status = KStatus.error; message = ex.Message; } break; default: status = KStatus.error; message = "incorrect type"; break; } result.Add(new KResult { status = status, message = message, data = item.id }); } return(Json(result)); }
public JsonResult AddNewItem(string type, string name, string parent) { KResult result = new KResult(); if (!KCore.IsValidFileName(name)) { result.status = KStatus.warning; result.message = "file/folder name is invalid: it either contains invalid characters or starts with a reserved name"; return(Json(result)); } string fullName = KCore.PhysicalPath(parent + "/" + name); switch (type) { case "file": if (!System.IO.File.Exists(fullName)) { FileStream fs = null; try { fs = System.IO.File.Create(fullName); } catch (Exception ex) { result.status = KStatus.error; result.message = ex.Message; } finally { if (fs != null) { fs.Close(); fs.Dispose(); } } } else { result.status = KStatus.error; result.message = "file " + name + " already exists."; } break; case "folder": try { Directory.CreateDirectory(fullName); } catch (Exception ex) { result.status = KStatus.error; result.message = ex.Message; } break; default: result.status = KStatus.error; result.message = "incorrect type"; break; } return(Json(result)); }
private void _btn_Delete_ItemClick(object sender, ItemClickEventArgs e) { var v = _lbeMain.SelectedItem; if (v != null) { if (((T)v).Delete()) { _mainSource.Remove(v as T); _filteredSource.Remove(v as T); } } else { KCore.ShowKError("Nothing Selected!"); } }
private void btn_Register_Click(object sender, RoutedEventArgs e) { if (_validateInputs()) { if (!DB_Bridge.Instance.CheckIfAdminExist(tb_Login.Text)) { if (DB_Bridge.Instance.CreateAdmin(tb_Login.Text, pb_Password.Password)) { KCore.ShowKError("Admin created!"); } } else { KCore.ShowKError("Such Admin already exist"); } } }
public static void Main() { k.StartInit.Starting(new k.Init()); // KCore KCore.Dynamic1(); KCore.Security(); KCore.Credential(); KCore.List(); KCore.Shell(); KCore.KExceptionTest(); // SAPDI KCore.SAPDI(); KCore.SAPDIServer(); return; }
protected async override void OnStart() { IKCore core = KCore.New() .ConfigureServices(services => { services.Singleton <IHotUpdateService, HotUpdateService>(); //ViewModels services.Bind <MainPageViewModel>(); }); await core.RunAsync(); var hotupdate = core.Services.Get <IHotUpdateService>(); await hotupdate.StartAsync(); Console.WriteLine("ILRuntime 准备完毕"); NavigationPage = new NavigationPage(new MainPage()); MainPage = NavigationPage; }
public JsonResult Remove(string json) { KSelectListItem[] list = JsonConvert.DeserializeObject <KSelectListItem[]>(json); List <KResult> result = new List <KResult>(); foreach (KSelectListItem item in list) { string fullName = KCore.PhysicalPath(item.url); KStatus status = KStatus.success; string message = ""; switch (item.type) { case "file": FileInfo file = new FileInfo(fullName); try { file.Delete(); } catch (Exception ex) { status = KStatus.error; message = ex.Message; } break; case "folder": DirectoryInfo dir = new DirectoryInfo(fullName); try { dir.Delete(true); } catch (Exception ex) { status = KStatus.error; message = ex.Message; } break; default: status = KStatus.error; message = "incorrect type"; break; } result.Add(new KResult { status = status, message = message, data = item.id }); } return(Json(result)); }
private void btn_Auth_Click(object sender, RoutedEventArgs e) { try { if (_validateInputs()) { if (DB_Bridge.Instance.CheckIfAdminExist(tb_Login.Text, pb_Password.Password)) { ((MainWindow)this.Parent).InitTools(); } else { KCore.ShowKError("Admin Not Found!"); } } } catch (Exception ex) { KCore.ShowKError(ex.ToString()); } }
public MainWindow() { InitializeComponent(); this.Title += " " + KCore.GetAssemblyVersion(); TitleMask = this.Title + " [{0}]"; }