Ejemplo n.º 1
0
        public void FromBatch(NBatchInfoGroup group)
        {
            if (((group != null) && (group.Batchs != null)) && (group.Batchs.Count > 0))
            {
                NBatchInfo       batchInfo = group.Batchs[0];
                RadTreeNode      batchNode = CreateBatchNode(batchInfo);
                List <NFileInfo> fileInfos = batchInfo.FileInfos;

                //fileInfos.ForEach(x => x.FileName = x.FileNO);
                //HashSet<String> categorys = new HashSet<string>();

                foreach (NFileInfo fileInfo in fileInfos)
                {
                    string category = fileInfo.Category;
                    if (String.IsNullOrEmpty(category)) //没有分类的文件
                    {
                        CreateFileNodeFromServer(batchNode, fileInfo, batchInfo);
                    }
                    else
                    {
                        String      path         = batchNode.Text + "." + category;
                        RadTreeNode categoryNode = navigateTree.GetNodeByPath(path, ".");
                        if (categoryNode == null)
                        {
                            categoryNode = navigateTree.AddNodeByPath(path, ".");
                            UpdateCategoryNode(categoryNode);
                            categoryNode.Parent.Nodes.Move(categoryNode.Index, 0);  //将分类节点移到父节点最前面的位置
                        }
                        CreateFileNodeFromServer(categoryNode, fileInfo, batchInfo);
                    }
                }
                batchNode.ExpandAll();
                UpdateBatchNodeTitle(batchNode);
            }
        }
        private void btn_UploadBatch_Click(object sender, EventArgs e)
        {
            bool            flag            = false;
            NBatchInfoGroup nBatchInfoGroup = new NBatchInfoGroup();

            foreach (ListViewItem listViewItem in this.listView1.Items)
            {
                bool flag2 = listViewItem.Checked && listViewItem.SubItems[1].Text != "成功";
                if (flag2)
                {
                    NBatchInfo nBatchInfo = listViewItem.Tag as NBatchInfo;
                    nBatchInfo.SetupBatchInfo();
                    nBatchInfoGroup.Batchs.Add(nBatchInfo);
                    flag = true;
                }
            }
            bool flag3 = !flag;

            if (flag3)
            {
                MessageBox.Show("请勾选影像批次");
            }
            else
            {
                foreach (NBatchInfo current in nBatchInfoGroup.Batchs)
                {
                    this._transfer           = INetTransferFactory.GetNetTransfer();
                    this._transfer.OnNotify -= new EventHandler <TEventArg <NetTransferNotifyMsg> >(this.OnTransferNotify);
                    this._transfer.OnNotify += new EventHandler <TEventArg <NetTransferNotifyMsg> >(this.OnTransferNotify);
                    this._transfer.UploadBatch(current);
                }
            }
        }
        public NBatchInfoGroup MyClone()
        {
            NBatchInfoGroup nBatchInfoGroup = new NBatchInfoGroup();

            foreach (NBatchInfo current in this.Batchs)
            {
                nBatchInfoGroup.Batchs.Add(current.MyClone());
            }
            return(nBatchInfoGroup);
        }
        /*
         * private RadTreeNode SetBatchNodeDefaultProperty(RadTreeNode node)
         * {
         *  if (node != null)
         *  {
         *      node.AllowDrop = false;
         *      node.Checked = true;
         *      node.Checked = true;
         *      node.ItemHeight = UISetting.GetInstance().BatchNodeHeight;
         *      node.Font = new Font(this.Font.Name, navigateTree.Lev1NodeFontSize);
         *      node.ContextMenu = this._menudefaultbatchnode;
         *      node.PropertyChanged += new PropertyChangedEventHandler(this.BatchNode_PropertyChanged);
         *  }
         *  return node;
         * }
         *
         * private void SetCategoryNodeDefaultProperty(RadTreeNode node)
         * {
         *  node.ContextMenu = this._menuCategoryNode;
         *  node.ShowCheckBox = false;
         * }
         *
         * public RadTreeNode SetFileNodeDefualtProperty(RadTreeNode node)
         * {
         *  if ((node.Tag as NFileInfo).Operation == EOperType.eFROM_SERVER_NOTCHANGE)
         *  {
         *      node.ContextMenu = this._menuFileNode;
         *  }
         *  else
         *  {
         *      node.ContextMenu = this._menuFileNode;
         *  }
         *  node.ItemHeight = UISetting.GetInstance().ThumbImgSize;
         *  node.Checked = true;
         *  node.TextAlignment = ContentAlignment.MiddleCenter;
         *  node.PropertyChanged += new PropertyChangedEventHandler(this.FileNode_PropertyChanged);
         *  return node;
         * }
         *
         *
         *
         * private void SetupNodeDefaultProperty(RadTreeNode node)
         * {
         *  if ((node.Tag != null) && (node.Tag is NCategoryInfo))
         *  {
         *      this.SetCategoryNodeDefaultProperty(node);
         *  }
         *  if ((node.Tag != null) && (node.Tag is NFileInfo))
         *  {
         *      this.SetFileNodeDefualtProperty(node);
         *  }
         *  if ((node.Tag != null) && (node.Tag is NBatchInfo))
         *  {
         *      this.SetBatchNodeDefaultProperty(node);
         *  }
         * }*/

        public void TestFromFileToTree(object param = null)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                NBatchInfo info = NBatchInfo.FromPBFile(dialog.FileName);
                info.ExtractFileData(LibCommon.AppContext.GetInstance().GetVal <AppSetting>(typeof(AppSetting)).TmpFileDir);
                NBatchInfoGroup group = new NBatchInfoGroup
                {
                    Batchs = { info }
                };
                navigateTree.FromBatch(group);
            }
        }
        /*public void DoSelectNode(object info)
         * {
         *  Tuple<string, string> data = info as Tuple<string, string>;
         *  if (data != null)
         *  {
         *      IEnumerable<bool> source = from o in navigateTree.Nodes select (o.Tag as NBatchInfo).BatchNO == data.Item1;
         *      if ((source != null) && (source.Count<bool>() > 0))
         *      {
         *      }
         *  }
         * }*/

        public void DownloadBatch(object param = null)
        {
            UCQueryBatch    ctrl      = new UCQueryBatch();
            FormQBContainer container = new FormQBContainer();

            container.AddControl(ctrl);
            container.AddControl(typeof(UCQueryNBatchHis));
            if (container.ShowDialog() == DialogResult.OK)
            {
                ctrl.DownloadGroup.Update2NoneMode();   //更新所有状态为from server not change
                NBatchInfoGroup group = ctrl.DownloadGroup.MyClone();
                //this.BatchToTreeView(group);
                navigateTree.FromBatch(group);
            }
        }
        /*
         * private void UpdateAllNodeMenu(RadTreeNode node)
         * {
         *  this.SetBatchNodeDefaultProperty(node);
         *  List<RadTreeNode> children = node.GetChildren();
         *  foreach (RadTreeNode node2 in children)
         *  {
         *      this.SetupNodeDefaultProperty(node2);
         *  }
         * }
         */
        /*
         * public void UpdateThumbNail(object param = null)
         * {
         *  RadTreeNode selectedNode = navigateTree.SelectedNode;
         *  if (((selectedNode != null) && (selectedNode.Tag != null)) && (selectedNode.Tag is NFileInfo))
         *  {
         *      NFileInfo tag = selectedNode.Tag as NFileInfo;
         *      selectedNode.SetImageIcon(tag.LocalPath, this._viewfileinfoicon);
         *  }
         * }*/

        public void UploadBatch(object param = null)
        {
            NBatchInfoGroup group = navigateTree.ToBatch();

            if ((group == null) || (group.Batchs.Count == 0))
            {
                LibCommon.AppContext.GetInstance().MS.LogWarning("没有可提交的数据");
            }
            else
            {
                FormUploadBatchs batchs = new FormUploadBatchs
                {
                    Group = group
                };
                if ((batchs.ShowDialog() == DialogResult.OK) && !FunctionSetting.GetInstance().KeepSuccessedUploadNodeInTree)
                // if ((batchs.ShowDialog() == DialogResult.OK) && !FunctionSetting.KeepSuccessedUploadNodeInTree)
                {
                    List <string> uploadSuccessedbatchs = batchs.UploadSuccessedbatchs;
                    //for (int i = navigateTree.Nodes.Count - 1; i >= 0; i--)
                    //{
                    //    if (uploadSuccessedbatchs.Contains((navigateTree.Nodes[i].Tag as NBatchInfo).BatchNO))
                    //    {
                    //        navigateTree.Nodes.Remove(navigateTree.Nodes[i]);
                    //    }
                    //}
                    foreach (RadTreeNode batchNode in navigateTree.GetRadTree().Nodes)
                    {
                        if (uploadSuccessedbatchs.Contains((batchNode.Tag as NBatchInfo).BatchNO))
                        {
                            navigateTree.GetRadTree().Nodes.Remove(batchNode);
                        }
                    }
                }
                if (navigateTree.GetRadTree().Nodes.Count > 0)
                {
                    navigateTree.GetRadTree().Nodes[0].Selected = true;
                    navigateTree.NavigateFirstItem(null);
                }
                else
                {
                    //this.OnItemSelectChanged(this, new TEventArg<RadTreeNode>(null));
                }
                navigateTree.GetRadTree().Focus();
            }
        }
        private void ShowIntoList(NBatchInfoGroup group)
        {
            this.listView1.Items.Clear();
            bool flag = group != null;

            if (flag)
            {
                foreach (NBatchInfo current in group.Batchs)
                {
                    ListViewItem listViewItem = new ListViewItem();
                    listViewItem.Tag     = current;
                    listViewItem.Checked = true;
                    listViewItem.Text    = current.DisplayName;
                    listViewItem.SubItems.Add("");
                    this.listView1.Items.Add(listViewItem);
                }
            }
        }
Ejemplo n.º 8
0
        public NBatchInfoGroup ToBatch()
        {
            NBatchInfoGroup group = new NBatchInfoGroup();

            foreach (RadTreeNode node in navigateTree.Nodes)
            {
                NBatchInfo batchInfo = node.Tag as NBatchInfo;
                batchInfo.FileInfos.Clear();
                //List<String> categoryNames = node.Nodes.Where<RadTreeNode>(x => x.Tag is NCategoryInfo).ToList().Select<RadTreeNode, String>(x => (x.Tag as NCategoryInfo).CategoryName).ToList();
                //batchInfo.Categorys = categoryNames;
                int count = node.Nodes.Count;
                if (batchInfo.Operation == EOperType.eADD)
                {
                    //获取所有文件节点
                    List <RadTreeNode> fileNodes = NavigateTreeHelper.GetAllChildFileNodes(node);
                    foreach (RadTreeNode fileNode in fileNodes)
                    {
                        fileNode.UpdateFileNodeCatInfo();
                        batchInfo.FileInfos.Add(fileNode.Tag as NFileInfo);
                    }
                    group.Batchs.Add(batchInfo);
                }
                else
                {
                    if (batchInfo.Operation == EOperType.eFROM_SERVER_NOTCHANGE || batchInfo.Operation == EOperType.eUPD)
                    {
                        int version;
                        int num3 = 1;
                        batchInfo.FileInfos.Clear();
                        List <RadTreeNode> list2 = NavigateTreeHelper.GetAllChildFileNodes(node);
                        foreach (RadTreeNode node3 in list2)
                        {
                            node3.UpdateNodeNInfo();
                            NFileInfo info3 = node3.Tag as NFileInfo;
                            info3.SetupFileInfo();
                            if (info3.OrigData == null) //本地添加文件
                            {
                                info3.Operation     = EOperType.eADD;
                                batchInfo.Operation = EOperType.eUPD;
                                batchInfo.FileInfos.Add(node3.Tag as NFileInfo);
                            }
                            else if (info3.Operation == EOperType.eDEL)  //要删除的文件, 清空数据,减少数据传输
                            {
                                info3.Data          = null;
                                batchInfo.Operation = EOperType.eUPD;
                                batchInfo.FileInfos.Add(node3.Tag as NFileInfo);
                            }
                            else if (info3.FileMD5 != info3.OrigData.FileMD5)   //判断文件内容是否变化,有问题,操作节点时不操作Info对象
                            {
                                info3.Operation = EOperType.eUPDATEFILE;
                                NFileInfo origData = info3.OrigData;
                                version             = origData.Version;
                                origData.Version    = version + 1;
                                info3.Version       = version;
                                batchInfo.Operation = EOperType.eUPD;
                                batchInfo.FileInfos.Add(node3.Tag as NFileInfo);
                            }
                            else if (!info3.MyEqual(info3.OrigData))    //判断文件属性是否变化
                            {
                                info3.Operation     = EOperType.eUPDATEBASIC;
                                info3.Version       = (info3.OrigData.Version++);
                                info3.Data          = null;
                                batchInfo.Operation = EOperType.eUPD;
                                batchInfo.FileInfos.Add(node3.Tag as NFileInfo);
                            }
                            //没有任何变化不传输
                        }
                    }
                    if (batchInfo.Operation == EOperType.eUPD)
                    {
                        batchInfo.Version++;
                        group.Batchs.Add(batchInfo);
                    }
                }
            }
            return(group);
        }