예제 #1
0
        private void InitInstallConfig()
        {
            string targetPath;

            if (ProjectConst.IsVsIdeEnv && Directory.Exists(InstallTargetDebug))
            {
                targetPath = InstallTargetDebug;
            }
            else
            {
                targetPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86).ToString();
            }

            TargetPath = UtilFile.Combine(targetPath, ProjectConst.APP_FOLDER) + "\\";
        }
예제 #2
0
        public static string INSTALL_WELCOME;           // -- 目标程序快捷方式描述 --
        #endregion
        #region -- init --
        public static void ReadConfigIni()
        {
            if (IsVsIdeEnv && Directory.Exists(InstallSourceDebug))
            {
                SourcePath = InstallSourceDebug;
            }
            else
            {
                SourcePath = Application.StartupPath;
            }

            iniFile = new IniFile(UtilFile.Combine(SourcePath, "config.ini"), 0);

            APP_FOLDER        = iniFile.getValue("app_folder", "config.ini.app_folder error");
            APP_EXE           = iniFile.getValue("app_exe", "config.ini.app_exe error");
            APP_SHORTCUT      = iniFile.getValue("app_shortcut", "config.ini.app_shortcut error");
            APP_SHORTCUT_DESC = iniFile.getValue("app_shortcut_desc", "config.ini.app_shortcut_desc error");

            INSTALL_WELCOME = iniFile.getValue("install_welcome", "欢迎安装使用本程序,祝您工作愉快。");
        }
예제 #3
0
        private void Install()
        {
            if (!CheckBeforeInstall())
            {
                return;
            }

            string package, extTarget, desktopPath, startupPath;

            // -- 1. 拷贝目录 --
            package = UtilFile.Combine(ProjectConst.SourcePath, "package");
            UtilFile.CopyDiretory(package, TargetPath);

            // -- 2. 创建快捷方式到桌面和启动组 --
            extTarget = UtilFile.Combine(TargetPath, ProjectConst.APP_EXE);

            desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            CreateShortcut(TargetPath, extTarget, ProjectConst.APP_SHORTCUT, ProjectConst.APP_SHORTCUT_DESC, desktopPath);

            if (ProjectConst.FLAG_SHORTCUT_ON_STARTUP)
            {
                startupPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);
                CreateShortcut(TargetPath, extTarget, ProjectConst.APP_SHORTCUT, ProjectConst.APP_SHORTCUT_DESC, startupPath);
            }

            // -- 4. 立即运行 --
            if (UtilMessage.ShowConfirm(ProjectConst.APP_SHORTCUT_DESC + " 安装成功,是否立即运行?") == DialogResult.Yes)
            {
                Environment.CurrentDirectory = TargetPath;      // -- 确保exeTarget运行时,当前目录是exeTarget所在目录,否则是SmartInstaller.exe所在目录 --
                Process.Start(extTarget);
            }
            else
            {
                UtilMessage.ShowMessage(ProjectConst.APP_SHORTCUT_DESC + " 安装成功,已创建桌面快捷方式。");
            }

            // -- 9. end --
            this.Close();
        }
예제 #4
0
        private void Sample1()
        {
            string url = "http://127.0.0.1:4195/WebPrint/PrintDLabel";
            string urlImage = "http://www.vinda.com/upload/2019/1203/1606fh6dzt.png";
            string labelFile = UtilFile.Combine(Application.StartupPath, @"\res\vinda.dlb");
            string labelString = UtilFile.ReadFile(labelFile);
            string poststring, response;

            HttpClientHelper client = new HttpClientHelper();
            ArrayList        list = new ArrayList();
            Hashtable        post, data;

            // -- 1. 准备标签数据 --
            for (int i = 1; i <= 5; i++)
            {
                data = new Hashtable();
                data.Add("element_1", "Deluxe棉韧-" + i);
                data.Add("element_2", new Hashtable {
                    { "text", "(01)06901236344033(11)210506(17)240505(10)2119W" },
                    { "value", "01069012363440331121050617240505102119W" }
                });
                data.Add("element_5", urlImage);

                list.Add(data);
            }

            // -- 2. 发送打印数据 --
            post = new Hashtable {
                { "labelString", labelString },
                { "dataString", list },
                { "printerName", "" },
                { "copies", 1 }
            };
            poststring = JsonSerializer.Serialize(post);

            response         = client.Post(url, poststring);
            txtResponse.Text = response;
        }