コード例 #1
0
        public async Task <SortedDictionary <ExportTable, long> > Run(WPExportResult wp)
        {
            SortedDictionary <ExportTable, long> result = new SortedDictionary <ExportTable, long>();

            using (var conn = this._dbConnection)
            {
                long categories = await this.SaveCategoriesAsync(conn, wp.Categories);

                long post = await this.SavePostAsync(conn, wp.Posts);

                long contentCategories = await this.SaveContentCategoriesAsync(conn, wp.ContentCategories);

                long contentTags = await this.SaveContentTagsAsync(conn, wp.ContentTags);

                long products = await this.SaveProductsAsync(conn, wp.Products);

                long tags = await this.SaveTagsAsync(conn, wp.Tags);

                long users = await this.SaveUsersAsync(conn, wp.Users);

                long seos = await this.SaveSeoMetaAsync(conn, wp.SeoMeta);

                result.Add(ExportTable.Categories, categories);
                result.Add(ExportTable.Post, post);
                result.Add(ExportTable.ContentCategories, contentCategories);
                result.Add(ExportTable.ContentTags, contentTags);
                result.Add(ExportTable.Products, products);
                result.Add(ExportTable.Tags, tags);
                result.Add(ExportTable.Users, users);
                result.Add(ExportTable.SeoMeta, seos);
            }

            return(result);
        }
コード例 #2
0
        public void DoWork()
        {
            WPExportDTO exportDTO = WPExportEngine.RunAllQueries(
                _wpSource,
                _wpConfigurationPluginExportDTO);

            string json = string.Empty;

            if (string.IsNullOrEmpty(_configurationOUTFile.DirtyExportFile) == false)
            {
                DirtyWPToJson dirtyWPToJson = new DirtyWPToJson(exportDTO);
                json = dirtyWPToJson.CreateJSON(Newtonsoft.Json.Formatting.None);
                FileHelper.WriteToFile(_configurationOUTFile.DirtyExportFile, json);
            }

            WPToJson wPToJson = new WPToJson(exportDTO)
            {
                ExportSeoWithYoast = _wpConfigurationPluginExportDTO.Yoast
            };

            json = wPToJson.CreateJSON(Newtonsoft.Json.Formatting.Indented);

            if (string.IsNullOrEmpty(_configurationOUTFile.ExportFile) == false)
            {
                FileHelper.WriteToFile(_configurationOUTFile.ExportFile, json);
            }

            WPExportResult wp     = Newtonsoft.Json.JsonConvert.DeserializeObject <WPExportResult>(json);
            ISQLEngine     engine = null;

            if (string.IsNullOrEmpty(_configurationOUTFile.SQLServerConnection) == false)
            {
                engine = new SQLServerEngine(_configurationOUTFile.SQLServerConnection);
                ExportToDatabase export = new ExportToDatabase(engine);
                var result = export.Run(wp).Result;
            }


            if (string.IsNullOrEmpty(_configurationOUTFile.MySQLServerConnection) == false)
            {
                engine = new MySQLEngine(_configurationOUTFile.MySQLServerConnection);
                ExportToDatabase export = new ExportToDatabase(engine);
                var result = export.Run(wp).Result;
            }
        }
コード例 #3
0
        public async Task <IActionResult> ConvertJSONToSQL(ImportToMySQLDTO values)
        {
            if (values.contents.Length == 0)
            {
                return(null);
            }

            WPExportResult wp = new WPExportResult();

            using (var ms = new MemoryStream())
            {
                values.contents.CopyTo(ms);
                var    fileBytes = ms.ToArray();
                string json      = Encoding.ASCII.GetString(fileBytes);

                wp = Newtonsoft.Json.JsonConvert.DeserializeObject <WPExportResult>(json);
            }

            if (wp == null)
            {
                return(null);
            }


            ISQLEngine       engine = new MySQLEngine(values.ConnectionString);
            ExportToDatabase export = new ExportToDatabase(engine);
            var result = await export.Run(wp);

            StringBuilder sb = new StringBuilder();

            foreach (var item in result)
            {
                sb.AppendFormat("{0}: {1} {2} | ", item.Key, item.Value, Environment.NewLine);
            }

            string log = sb.ToString();

            return(View("Index"));
        }
コード例 #4
0
        public string CreateJSON(Newtonsoft.Json.Formatting formatting)
        {
            WPExportResult export = new WPExportResult()
            {
                Categories = FillCategories(),
                Tags       = FillTags(),
            };

            export.Posts    = FillPosts();
            export.Users    = FillUsers();
            export.Products = FillProducts();

            export.ContentCategories = FillContentCategories();
            export.ContentTags       = FillContentTags();

            if (ExportSeoWithYoast)
            {
                export.SeoMeta = FillSeoMetaWithYoast();
            }

            string result = Newtonsoft.Json.JsonConvert.SerializeObject(export, formatting);

            return(result);
        }