Beispiel #1
0
        /// <summary>
        /// 选择目录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowers_Click(object sender, EventArgs e)
        {
            if (fdlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                txtFileDir.Text = fdlg.SelectedPath;

                lstFile.Items.Clear();
                var fis = Directory.GetFiles(txtFileDir.Text.Trim(), "*.*", SearchOption.TopDirectoryOnly);
                if (null == fis || fis.Length < 1)
                {
                    return;
                }
                var lst = new List <RemoteFile>(fis.Length);
                foreach (var fi in fis)
                {
                    if (checkBox1.Checked && Path.GetFileName(fi).StartsWith("DevExpress", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    if (Path.GetFileName(fi).EndsWith("pdb", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    if (string.Compare(Path.GetFileName(fi), "SvcUpdate.exe", true) == 0)
                    {
                        continue;
                    }
                    lst.Add(new RemoteFile {
                        FileName = Path.GetFileName(fi),
                        FullName = fi,
                        MD5      = ByteStringUtil.ByteArrayToHexStr(HashDigest.FileDigest(fi)),
                        Url      = "http://localhost/UpdateApp/ttt/" + Path.GetFileName(fi),
                        Size     = new FileInfo(fi).Length,
                        Status   = string.Empty
                    });
                }
                lst = lst.OrderBy(j => j.FileName).ToList();
                lst.ForEach(j => {
                    var li   = lstFile.Items.Add(j.FileName);
                    var sub  = li.SubItems.Add(j.MD5);
                    sub      = li.SubItems.Add(j.Status);
                    sub.Name = "Status";
                });
                XmlSerializer xs = new XmlSerializer(typeof(List <RemoteFile>));
                StringWriter  sw = new StringWriter();
                xs.Serialize(sw, lst);
                sw.Close();
                richTextBox1.Text = sw.ToString();  //Common.SerializeJson(lst);
                UpdFiles          = lst;
            }
        }
Beispiel #2
0
        private void Refc(string cls, string mod, TreeListNode mnu)
        {
            try {
                var pth = Path.Combine(Lanucher.AppDir, mod);
                var md5 = string.Empty;
                if (File.Exists(pth))
                {
                    md5 = ByteStringUtil.ByteArrayToHexStr(HashDigest.FileDigest(pth));
                }
                var m  = Lanucher.Start(cls, mod);
                var ip = m as ISurfacePermission;
                if (null == ip)
                {
                    return;
                }
                var toolbar = ip.ToolBarItems;
                var grids   = ip.Grids;
                var btns    = ip.ButtonItems;
                if (null != toolbar && toolbar.Count > 0)
                {
                    var td = mnu.Nodes.Add(new object[] { "主按钮" });
                    foreach (var ti in toolbar)
                    {
                        var tds = td.Nodes.Add(new object[] { ti.Caption });
                        tds.Tag = new t_rolepermit {
                            ControlName = ti.Name,
                            TextName    = ti.Caption,
                            CtlType     = (int)EnCtlType.ToolBarItems,
                            IsEnabled   = false,
                            ClsName     = cls,
                            AsmName     = mod,
                            AsmMD5      = md5
                        };
                    }
                }
                if (null != grids && grids.Count > 0)
                {
                    foreach (var ti in grids)
                    {
                        var td = mnu.Nodes.Add(new object[] { ti.Name });
                        td.Tag = new t_rolepermit {
                            ControlName = ti.Gv.Name,
                            TextName    = ti.Name,
                            CtlType     = (int)EnCtlType.Grids,
                            IsEnabled   = false,
                            ClsName     = cls,
                            AsmName     = mod,
                            AsmMD5      = md5
                        };
                        foreach (DevExpress.XtraGrid.Columns.GridColumn col in ti.Gv.Columns)
                        {
                            var tdc = td.Nodes.Add(new object[] { col.Caption });

                            tdc.Tag = new t_rolepermit {
                                ControlName   = col.Name,
                                ParentCtlName = ti.Gv.Name,
                                TextName      = col.Caption,
                                CtlType       = (int)EnCtlType.GridCol,
                                IsEnabled     = false,
                                ClsName       = cls,
                                AsmName       = mod,
                                AsmMD5        = md5
                            };
                        }
                    }
                }
                if (null != btns && btns.Count > 0)
                {
                    var td = mnu.Nodes.Add(new object[] { "自定义按钮" });
                    foreach (var ti in btns)
                    {
                        var tds = td.Nodes.Add(new object[] { string.IsNullOrEmpty(ti.Text) ? ti.Name : ti.Text /*ti.Name*/ });
                        tds.Tag = new t_rolepermit {
                            ControlName = ti.Name,
                            TextName    = ti.Text,
                            CtlType     = (int)EnCtlType.ButtonItems,
                            IsEnabled   = false,
                            ClsName     = cls,
                            AsmName     = mod,
                            AsmMD5      = md5
                        };
                    }
                }
            } catch //(Exception)
            {
                //throw;
            }
        }