Exemple #1
0
        /// <summary>
        /// 文件夹权限
        /// </summary>
        /// <param name="path"></param>
        /// <param name="identity"></param>
        /// <param name="right"></param>
        /// <param name="inherit"></param>
        public static void DirectoryInfoAccessControl(string path, string identity, FileSystemRights right, bool inherit)
        {
            DirectoryInfo dir = new DirectoryInfo(path);

            if (!dir.Exists)
            {
                FileAndDirectoryManager.CreateDir(path);
            }
            try
            {
                DirectorySecurity    dirsec = dir.GetAccessControl(AccessControlSections.All);
                FileSystemAccessRule arules = null;
                if (inherit)
                {
                    InheritanceFlags iflag = InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit;
                    arules = new FileSystemAccessRule(identity, right, iflag, PropagationFlags.None, AccessControlType.Allow);
                }
                else
                {
                    arules = new FileSystemAccessRule(identity, right, AccessControlType.Allow);
                }
                dirsec.AddAccessRule(arules);
                dir.SetAccessControl(dirsec);
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// 打开图纸的处理
        /// </summary>
        /// <param name="CreoCommonPath"></param>
        /// <param name="pf"></param>
        private void OpenAssistentDeal(string CreoCommonPath, Platform pf)
        {
            var xtopPath = FileAndDirectoryManager.SearchFile(CreoCommonPath, new string[] { "i486_nt\\obj", "x86e_win64\\obj" }, "pro_comm_msg.exe").FirstOrDefault();

            //添加环境变量
            Environment.SetEnvironmentVariable("PRO_COMM_MSG_EXE", xtopPath, EnvironmentVariableTarget.Machine);

            //将OpenAssistent.exe 拷到system32
            string OpenAssistentName   = "openAssistent.exe";
            string OpenAssistentName64 = "openAssistent64.exe";
            string str = string.Format("{0}\\{1}\\", this.SourceDefaultDir, this.DirName);

            if (pf == Platform.X64)
            {
                CommonBase.CopyFile(str + OpenAssistentName64, "C:\\Windows\\System32\\" + OpenAssistentName);
            }
            else if (pf == Platform.X86)
            {
                CommonBase.CopyFile(str + OpenAssistentName, "C:\\Windows\\System32\\" + OpenAssistentName);
                CommonBase.CopyFile(str + OpenAssistentName, "C:\\Windows\\syswow64\\" + OpenAssistentName);
            }
        }
Exemple #3
0
        private void CopyFile()
        {
            string str        = string.Format("{0}\\{1}\\", this.SourceDefaultDir, this.DirName);
            string text       = string.Format("{0}\\{1}\\", this.UserDefaultDir, this.DirName);
            string str2       = string.Format("{0}\\{1}\\", this.SourceDefaultDir, "Common\\");
            string systemPath = CommonBase.GetSystemPath();

            if (!Directory.Exists(text))
            {
                Directory.CreateDirectory(text);
            }

            var CreoCommonPath = GetProeCommonFilesLocationPath(); //找到 "..\Creo 2.0\\Common Files\\M020" 目录

            if (string.IsNullOrEmpty(CreoCommonPath))
            {
                CreoCommonPath = GetProeCommonFilesLocationPathX64();
            }
            var xtopPath = FileAndDirectoryManager.SearchFile(CreoCommonPath, new string[] { "i486_nt\\obj", "x86e_win64\\obj" }, "xtop.exe").FirstOrDefault();

            if (string.IsNullOrEmpty(xtopPath))
            {
                throw new Exception("未找到 xtop.exe 路径。不支持绿色版,请确认正确安装!");
            }
            var pf = OSHelp.GetExcutePlatform(xtopPath);

            if (pf == Platform.X64)
            {
                CommonBase.CopyFile(str + CREOPACKAGE64, text + CREOPACKAGE);
            }
            else if (pf == Platform.X86)
            {
                CommonBase.CopyFile(str + CREOPACKAGE, text + CREOPACKAGE);
            }
            else
            {
                throw new Exception("未发现当前creo所处平台");
            }

            OpenAssistentDeal(CreoCommonPath, pf);

            if (!File.Exists("c:\\WINDOWS\\IntegrationLogin.exe"))
            {
                CommonBase.CopyFile(str2 + "IntegrationLogin.exe", "c:\\WINDOWS\\IntegrationLogin.exe");
            }
            if (!File.Exists("c:\\WINDOWS\\IntegrationLogin.exe.config"))
            {
                CommonBase.CopyFile(str2 + "IntegrationLogin.exe.config", "c:\\WINDOWS\\IntegrationLogin.exe.config");
            }

            try
            {
                string windowsPath = CommonBase.GetWindowsPath();
                CommonBase.DeleteFile(windowsPath + "\\PlmConfig.dop");//先将之前有的删除掉
            }
            catch { } //忽略错误
            //给文件、文件夹设置权限
            //system32\LoginSetting.ini
            //system32\proegm.txt
            //system32\Login.Html
            //%ALLUSERSPROFILE%\PLM\LoginSetting.ini
            //c:\windows\temp\plmpdf
            foreach (var item in DealFiles())
            {
                AccessControl.FileInfoAccessControl(item);
            }

            this.CopyMenuFile();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var reg_prt = new System.Text.RegularExpressions.Regex(@"(.+)\.prt(?:.\d+)?$");
            var reg_asm = new System.Text.RegularExpressions.Regex(@"(.+)\.asm(?:.\d+)?$");

            Console.WriteLine(GetFileWithoutExt("GB5781"));
            Console.WriteLine(GetFileWithoutExt("GB5781.prt"));
            Console.WriteLine(GetFileWithoutExt("GB5781.prt.23"));
            Console.WriteLine(GetFileWithoutExt("M12X30_GB5781.asm"));
            Console.WriteLine(GetFileWithoutExt("M12X30_GB5781.asm.677"));

            Console.WriteLine(Path.GetFileNameWithoutExtension("GB5781"));
            Console.WriteLine(Path.GetFileNameWithoutExtension("GB5781.prt.1"));
            Console.WriteLine(Path.GetFileNameWithoutExtension("M12X30_GB5781.asm.1"));
            Console.Read();
            return;

            //var t = getTime();
            if (DateTime.Now >= new DateTime(2014, 8, 1))
            {
                Console.WriteLine("dayu");
            }

            //AssociateFieldConllection collent = new AssociateFieldConllection();
            //collent.Add(new Associatefield("MaterialCode", "MODEL_NAME", true, 0, 0, false, "物料编码", true));
            //collent.Add(new Associatefield("MaterialSpec", "SPEC", false, 0, 0, false, "物料规格", false));
            //collent.Add(new Associatefield("MaterialSubstance", "MATERIAL", false, 0, 0, false, "物料材质", false));
            //collent.Add(new Associatefield("MaterialName", "DESCRIPTION", false, 0, 0, false, "物料名称", false));
            //collent.Add(new Associatefield("MaterialDrawNumber", "DRAWNO", false, 0, 0, false, "图号", false));

            //CreoOperate op = new CreoOperate();

            //op.AppTypeName = "PROE";
            //op.IntegType = Proway.PLM.Document.IntegrationType.PROE;
            //op.CategoryId = "affba405-d687-488b-8bb7-05e9a8a986ed";
            //op.WorkId = "";
            //op.CurOperatePosition =  Proway.PLM.Document.OperatePosition.CheckIn;
            //op.FolderId = "60C4C5B7-0107-4F41-9147-F8904FAC6728";
            //op.FileTypeId = "4be5f1a4-db00-4aa4-88cf-a8a5c48a88bf";
            //op.UserId = "FFB0AC2D-C1B5-49E2-89B2-F4058523DF18";
            //op.IsCreateCopy = false;
            //op.IsOperateBOM = true;
            //op.IndexFields = collent;

            ////op.CheckDoc(BOMJSON);

            //Dictionary<string,object> dic = new Dictionary<string,object>();

            //BOMHelp.Write(dic, _.MultiConfiguration, true);

            //var aa = dic.GetValue(_.MultiConfiguration, false);

            //Console.WriteLine(aa);


            //Console.WriteLine(OSHelp.IsVistaAndSubsequentVersion);
            //Console.WriteLine(OSHelp.IsWin7);

            //AccessControl.FileInfoAccessControl(@"c:\111.txt");
            //AccessControl.DirectoryInfoAccessControl(@"c:\111");

            //var regk = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\PTC");
            //Console.WriteLine(regk == null);

            //CreoClient creo = new CreoClient();
            //var aa = creo.GetBom();

            //测试版本
            //Console.WriteLine(OSHelp.GetExcutePlatform(@"D:\github\learn\Creo\CreoTest\Creo.Setup\pubilc\PLM64.dll").ToString());
            //Console.WriteLine(OSHelp.GetExcutePlatform(@"D:\github\learn\Creo\CreoTest\Creo.Setup\pubilc\PLM.dll").ToString());

            //Console.WriteLine(OSHelp.GetExcutePlatform(@"C:\Program Files\Kingdee\K3PLM\Integration\Proe\PLM.dll").ToString());

            foreach (var item in FileAndDirectoryManager.SearchFile(@"D:\MyWork\PTC\Creo 2.0\Common Files\M060\",
                                                                    new string[] { "i486_nt\\obj", "x86e_win64\\obj" }, "xtop.exe"))
            {
                Console.WriteLine(item);
            }

            if (UACHelp.IsRunAsAdmin())
            {
                Console.WriteLine("管理员启动");
            }
            else
            {
                Console.WriteLine("非管理员启动");
            }

            //CreoSetup setup = new CreoSetup();
            //setup.SourceDefaultDir = @"D:\Program Files\kingdee\K3PLM\Integration\Integration Setup\Resources";
            //setup.UserDefaultDir = @"C:\Program Files\Kingdee\K3PLM\Integration";

            //setup.CopyMenuFile();

            //ProcessStartInfo proc = new ProcessStartInfo();
            //proc.UseShellExecute = true;
            //proc.WorkingDirectory = Environment.CurrentDirectory;
            //proc.FileName = Application.ExecutablePath;
            //proc.Verb = "runas"; //使用管理员启动

            //string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ptc\\output.txt";
            //DocumentProperty docprop1 = DocumentProperty.LoadXml(path, Encoding.Default);
            //Console.WriteLine(docprop1.Count);

            //CreoClient cc = new CreoClient();
            //Console.WriteLine(cc.GetCurrentFileName());
            //Console.WriteLine(cc.GetCurrentFilePath());
            //Console.WriteLine(cc.GetCurrentFullPath());

            //var bom = cc.GetBom();

            //var aa = bom.Count;

            Console.Read();

            return;

#if false
            DocumentProperty docprop = new DocumentProperty();

            int index = 1;

            var partprop = getPartData("00" + index, index, "asm");
            docprop.Add(partprop);

            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "3" }, { "count", "1" }
            });
            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "5" }, { "count", "2" }
            });
            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "6" }, { "count", "1" }
            });
            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "7" }, { "count", "1" }
            });

            partprop.ObjectRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "2" }
            });

            index++;
            partprop = getPartData("00" + index, index, "drw");//2
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "prt");//3
            partprop.ObjectRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "4" }
            });
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "drw");//4
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "prt");//5
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "prt");//6
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "asm");//7
            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "8" }, { "count", "1" }
            });
            partprop.ChildRelation.Add(new Dictionary <string, string>()
            {
                { "fileid", "9" }, { "count", "10" }
            });
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "prt");//8
            docprop.Add(partprop);

            index++;
            partprop = getPartData("00" + index, index, "prt");//9
            docprop.Add(partprop);

            docprop.SaveXml(@"c:\123.txt");
#endif
        }