Ejemplo n.º 1
0
        void downloadClass(DatabaseItemNode selectedItem, string url)
        {
            using (System.Windows.Forms.SaveFileDialog fd = new System.Windows.Forms.SaveFileDialog())
            {
                var savepath = this.Cache[$"{url}_{selectedItem.Database.id}"];

                if (!string.IsNullOrEmpty(savepath))
                {
                    try
                    {
                        fd.InitialDirectory = System.IO.Path.GetDirectoryName(savepath);
                        fd.FileName         = System.IO.Path.GetFileName(savepath);
                    }
                    catch
                    {
                        fd.FileName = selectedItem.Database.Name + ".cs";
                    }
                }
                else
                {
                    fd.FileName = selectedItem.Database.Name + ".cs";
                }
                if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        Forms.BuildeCode code = new Forms.BuildeCode(selectedItem.Database.id.Value, fd.FileName, url);
                        code.Owner = this;
                        code.ShowDialog();
                        this.Cache[$"{url}_{selectedItem.Database.id}"] = fd.FileName;
                        this.Cache.Save();
                    }
                    catch (Exception ex)
                    {
                        Helper.ShowError(ex);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void MenuItem_生成简单模型代码_Click_1(object sender, RoutedEventArgs e)
        {
            DatabaseItemNode selectedItem = ((FrameworkElement)e.OriginalSource).DataContext as DatabaseItemNode;

            using (System.Windows.Forms.SaveFileDialog fd = new System.Windows.Forms.SaveFileDialog())
            {
                if (!string.IsNullOrEmpty(selectedItem.Database.dllPath) && selectedItem.Database.dllPath.StartsWith("{"))
                {
                    var json = (Newtonsoft.Json.Linq.JToken)Newtonsoft.Json.JsonConvert.DeserializeObject(selectedItem.Database.dllPath);
                    try
                    {
                        fd.InitialDirectory = System.IO.Path.GetDirectoryName(json.Value <string>("simple"));
                        fd.FileName         = System.IO.Path.GetFileName(json.Value <string>("simple"));
                    }
                    catch
                    {
                        fd.FileName = selectedItem.Database.Name + ".cs";
                    }
                }
                else
                {
                    fd.FileName = selectedItem.Database.Name + ".cs";
                }
                if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        Forms.BuildeCode code = new Forms.BuildeCode(selectedItem.Database.id.Value, fd.FileName, "DownLoadSimpleCodeHandler.aspx");
                        code.Owner = this;
                        code.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        Helper.ShowError(ex);
                    }
                }
            }
        }