コード例 #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            this.btnStart.Enabled = false;

            List <Web_ItemLibrary> allData = new List <Web_ItemLibrary>();

            SimpleLoading       loadingfrm = new SimpleLoading(this);
            SplashScreenManager loading    = new SplashScreenManager(loadingfrm);

            loading.ShowLoading();

            //临时数据
            //  8a8632fe-fcb0-4e56-b4b9-7bc965885994  =  https://www.pic.jzbl.com/ItemFiles/0d54bf62-e42b-460b-aab4-7e6bd1990221/8a8632fe-fcb0-4e56-b4b9-7bc965885994/6367115379197304639880898.jpg  直接得到原图
            //  91fbcff0-304c-4fa6-b3d7-3f6662cd609a  =  https://www.pic.jzbl.com/ItemFiles/8b166b7c-d1cf-47b2-806a-3a81ee78b6e3/91fbcff0-304c-4fa6-b3d7-3f6662cd609a/6368089569974537847086484_small.jpg  去_small得到原图

            //  3a966d22-56ba-4d23-9ab5-0355523d1604  =  https://www.pic.jzbl.com/itemFiles/6760efac-e98b-4539-adf3-a842280803dd/2019-09-21/3a966d22-56ba-4d23-9ab5-0355523d1604/i/s/ca4e0b991569072379.jpg  去/s/ 得到原图

            //  9a599ffe-039c-4886-a28c-1936b5e4e5eb  =  https://www.pic.jzbl.com/itemFiles/8e5dc0f7-ed86-4d3c-89db-3a8593f6a2d7/2020-03-02/9a599ffe-039c-4886-a28c-1936b5e4e5eb/i/s/950b1f8a1583157228.jpg  去/s/ 加ori_ 得到原图
            //string[] tdata = { "8a8632fe-fcb0-4e56-b4b9-7bc965885994", "91fbcff0-304c-4fa6-b3d7-3f6662cd609a", "3a966d22-56ba-4d23-9ab5-0355523d1604"}; //"9a599ffe-039c-4886-a28c-1936b5e4e5eb"
            string[] tdata = { "8a8632fe-fcb0-4e56-b4b9-7bc965885994", "3a966d22-56ba-4d23-9ab5-0355523d1604" }; //"9a599ffe-039c-4886-a28c-1936b5e4e5eb"



            using (var context = new DataModelEntities())
            {
                //排除
                //allData = context.Web_ItemLibrary
                //    .Where(o => o.IsDelete == 0 && !string.IsNullOrEmpty(o.ItemContentBefore))
                //    // .Take(50)
                //    .OrderByDescending(o => o.CreateDate)
                //    .ToList();
                allData = context.Web_ItemLibrary
                          .Where(o => tdata.Contains(o.ItemId))
                          .OrderByDescending(o => o.CreateDate)
                          .ToList();

                if (allData.Any())
                {
                    loading.CloseWaitForm();
                }
            }
            gjxm = allData.Count;

            this.tsslgyxm.Text = $"共计项目:{gjxm},有效项目{0}";
            this.tsslgj.Text   = 0.ToString();

            this.ContentImgUploadToOSS(allData, watch);

            //Task task = Task.Run(() =>
            //{
            //    this.ContentImgUploadToOSS(allData, watch);
            //    //this.ContentImgDataCopy(allData, watch);
            //});

            // this.btnStart.Enabled = task.IsCompleted;
        }
コード例 #2
0
        //private void btnGetData_Click(object sender, EventArgs e)
        //{

        //    using (var context = new DataModelEntities())
        //    {
        //        var data = context.Web_ItemLibrary
        //            .Where(o => o.IsDelete.ToString().Equals("0"))
        //            .OrderByDescending(o => o.CreateDate)
        //            .ToList();

        //        MessageBox.Show($"DataCount:{data.Count()}");
        //        Debug.WriteLine("DataCount:" + data.Count());

        //    }

        //}

        private void btnStart_Click(object sender, EventArgs e)
        {
            SimpleLoading loadingfrm = new SimpleLoading(this);
            //将Loaing窗口,注入到 SplashScreenManager 来管理
            SplashScreenManager loading = new SplashScreenManager(loadingfrm);

            loading.ShowLoading();
            using (var context = new DataModelEntities())
            {
                var data = context.Web_ItemLibrary
                           .Where(o => o.IsDelete.ToString().Equals("0"))
                           .OrderByDescending(o => o.CreateDate)
                           .ToList();

                if (data.Any())
                {
                    loading.CloseWaitForm();
                }
            }


            return;


            Task task = Task.Run(() =>
            {
                TitleImgCopy();
            });

            btnStart.Enabled = task.IsCompleted;
        }
コード例 #3
0
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            RegisterFrm   registerFrm = null;
            SimpleLoading loadingfrm  = new SimpleLoading(registerFrm);
            //将Loaing窗口,注入到 SplashScreenManager 来管理
            SplashScreenManager loading = new SplashScreenManager(loadingfrm);

            //判断是否已经有实例在运行
            Process instance = RunningInstance();

            if (instance == null) //没有实例在运行
            {
                loading.ShowLoading();
                //try catch 包起来,防止出错
                try
                {
                    CheckoutModel checkoutModel = new CheckoutModel();
                    string        a = string.Empty, b = string.Empty;
                    checkoutModel.res = RegeditTime.InitRegedit(ref a, ref b, checkoutModel.path, checkoutModel.registerCodeName);

                    checkoutModel.sericalNumber = a;
                    checkoutModel.registerCode  = b;

                    LogHelper.WriteLine("程序主入口: 注册结果:" + checkoutModel.res + ",激活码:" + checkoutModel.sericalNumber + ",注册码:" +
                                        "" + checkoutModel.registerCode + "");

                    loading.CloseWaitForm();

                    registerFrm = new RegisterFrm(checkoutModel);
                    registerFrm.ShowDialog();//显示注册激活窗体

                    if (registerFrm.DialogResult == DialogResult.OK)
                    {
                        Application.Run(new HomeForm(checkoutModel, registerFrm.json));
                    }
                }
                catch (Exception e)
                {
                    loading.CloseWaitForm();
                    /*可选处理异常*/
                    LogHelper.WriteLine("程序主入口:" + e.Message.ToString());
                }
            }
            else //已经有一个实例在运行
            {
                //显示窗口
                ShowWindowAsync(instance.MainWindowHandle, 1);
                //窗口显示在最前端
                SetForegroundWindow(instance.MainWindowHandle);
            }
        }
コード例 #4
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            this.btnStart.Enabled = false;
            this.cb01.Enabled     = false;
            this.cb02.Enabled     = false;
            this.cb03.Enabled     = false;
            txtTarget.Enabled     = false;
            btnTarget.Enabled     = false;

            List <Web_ItemLibrary> allData = new List <Web_ItemLibrary>();

            SimpleLoading       loadingfrm = new SimpleLoading(this);
            SplashScreenManager loading    = new SplashScreenManager(loadingfrm);

            loading.ShowLoading();
            using (var context = new DataModelEntities())
            {
                //排除
                allData = context.Web_ItemLibrary
                          .Where(o => o.IsDelete == 0 && !string.IsNullOrEmpty(o.ItemContentBefore))
                          // .Take(50)
                          .OrderByDescending(o => o.CreateDate)
                          .ToList();

                if (allData.Any())
                {
                    loading.CloseWaitForm();
                }
            }
            gjxm = allData.Count;

            this.tsslgyxm.Text = $"共计项目:{gjxm},有效项目{0}";
            this.tsslgj.Text   = 0.ToString();

            Task task = Task.Run(() =>
            {
                this.ContentImgDataCopy(allData, watch);
            });

            this.btnStart.Enabled = task.IsCompleted;
            this.cb01.Enabled     = task.IsCompleted;
            this.cb02.Enabled     = task.IsCompleted;
            this.cb03.Enabled     = task.IsCompleted;
            btnTarget.Enabled     = task.IsCompleted;
            txtTarget.Enabled     = task.IsCompleted;
        }
コード例 #5
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            btnStart.Enabled  = false;
            txtTarget.Enabled = false;
            btnTarget.Enabled = false;

            List <Web_ItemLibrary> allData = new List <Web_ItemLibrary>();

            SimpleLoading       loadingfrm = new SimpleLoading(this);
            SplashScreenManager loading    = new SplashScreenManager(loadingfrm);

            loading.ShowLoading();
            using (var context = new DataModelEntities())
            {
                allData = context.Web_ItemLibrary
                          .Where(o => !string.IsNullOrEmpty(o.ItemFilePath.ToString()) && o.IsDelete == 0)
                          .OrderBy(o => o.CreateDate)
                          .ToList();

                if (allData.Any())
                {
                    loading.CloseWaitForm();
                }
            }


            this.tsslgj.Text = $"共计:{allData.Count}";

            Task task = Task.Run(() =>
            {
                this.FileDataCopy(allData, watch);
            });

            btnStart.Enabled  = task.IsCompleted;
            btnTarget.Enabled = task.IsCompleted;
            txtTarget.Enabled = task.IsCompleted;
        }
コード例 #6
0
        /// <summary>
        ///  显示 load 返回数据
        /// </summary>
        /// <param name="form"></param>

        private void LoadData()
        {
            // List<Web_ItemLibrary> allData = new List<Web_ItemLibrary>();

            SimpleLoading loadingfrm = new SimpleLoading(this);
            //将Loaing窗口,注入到 SplashScreenManager 来管理
            SplashScreenManager loading = new SplashScreenManager(loadingfrm);

            loading.ShowLoading();
            using (var context = new DataModelEntities())
            {
                _allData = context.Web_ItemLibrary
                           .Where(o => o.IsDelete.ToString().Equals("0"))
                           .OrderByDescending(o => o.CreateDate)
                           .ToList();

                if (_allData.Any())
                {
                    loading.CloseWaitForm();
                }
            }

            //   return allData;
        }
コード例 #7
0
        /// <summary>
        /// 移动图片
        /// </summary>
        private void TitleImgCopy()
        {
            using (var context = new DataModelEntities())
            {
                string message = "开始获取数据,请等待…";

                if (this.InvokeRequired)
                {
                    this.Invoke(new DelegateWriteMessage(WriteMessage), new object[] { message });
                }
                else
                {
                    this.WriteMessage(message);
                }

                SimpleLoading loadingfrm = new SimpleLoading(this);
                //将Loaing窗口,注入到 SplashScreenManager 来管理
                SplashScreenManager loading = new SplashScreenManager(loadingfrm);
                loading.ShowLoading();

                var data = context.Web_ItemLibrary
                           .Where(o => o.IsDelete.ToString().Equals("0"))
                           .OrderByDescending(o => o.CreateDate)
                           .ToList();



                int iExists = 1, iUnExists = 1;


                for (int i = 0; i < data.Count; i++)
                {
                    string filePath = data[i].ItemTitleImg.Replace(_domain, _G).Replace('/', '\\');

                    if (!File.Exists(filePath))
                    {
                        iUnExists++;
                        message = $"路径:{filePath} 状态:< > 文件不存在";
                    }
                    else
                    {
                        iExists++;
                        message = $"路径:{filePath} 状态:< > 待复制";
                        //没有就创建一个基本文件夹

                        string filePathCopy = filePath.Replace(_itemfiles, _itemfilescopy);
                        try
                        {
                            //没有文件夹还需要创建
                            //拷贝原始文件
                            string fileName = filePathCopy.Split('\\').LastOrDefault();
                            string basePath = filePathCopy.Replace(fileName, "");
                            if (!Directory.Exists(basePath))
                            {
                                Directory.CreateDirectory(basePath);
                            }

                            //判断文件是否存在
                            if (File.Exists(filePathCopy))
                            {
                                message = $"拷贝(新路径原图)文件:{filePath} 到 {filePathCopy} 状态:》文件以存在《";
                            }
                            else
                            {
                                File.Copy(filePath, filePathCopy);
                                message = $"拷贝(压缩图片)文件:{filePath} 到 {filePathCopy} 状态:》成功《";
                            }

                            if (filePath.Contains(_samll))
                            {
                                if (filePath.Contains(_nS))
                                {
                                    string nSPath     = filePath.Replace(_nS, @"\").Replace(_samll, "");
                                    string nSfilePath = filePathCopy.Replace(_nS, @"\").Replace(_samll, "");

                                    //判断文件是否存在
                                    if (File.Exists(nSfilePath))
                                    {
                                        message = $"拷贝(新路径原图)文件:{nSPath} 到 {nSfilePath} 状态:》文件以存在《";
                                    }
                                    else
                                    {
                                        File.Copy(nSPath, nSfilePath);
                                        message = $"拷贝(新路径原图)文件:{nSPath} 到 {nSfilePath} 状态:》成功《";
                                    }
                                }
                                else
                                {
                                    string nSPath     = filePath.Replace(_samll, "");
                                    string nSfilePath = filePathCopy.Replace(_samll, "");
                                    //判断文件是否存在
                                    if (File.Exists(nSfilePath))
                                    {
                                        message = $"拷贝(老路径原图)文件:{nSPath} 到 {nSfilePath} 状态:》文件以存在《";
                                    }
                                    else
                                    {
                                        File.Copy(nSPath, nSfilePath);
                                        message = $"拷贝(老路径原图)文件:{nSPath} 到 {nSfilePath} 状态:》成功《";
                                    }
                                }
                            }
                            else
                            {
                                message = $"封面路径:{filePath} 不包含_small 状态:》未知《";
                            }
                        }
                        catch (Exception ex)
                        {
                            message = $"拷贝文件:{filePath} 状态:》失败{ex}";
                        }
                    }
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new DelegateWriteMessage(WriteMessage), new object[] { message });
                    }
                    else
                    {
                        this.WriteMessage(message);
                    }
                }


                message = $"共计{data.Count}条,本地存在{iExists}条,不存在{iUnExists}条";


                if (this.InvokeRequired)
                {
                    this.Invoke(new DelegateWriteMessage(WriteMessage), new object[] { message });
                }
                else
                {
                    this.WriteMessage(message);
                }
            }
        }