Exemple #1
0
        private void fetch_Click(object sender, EventArgs e)
        {
            string LocalLIB = IBMiUtils.GetLocalDir(lib.Text);

            string[] Dirs = Directory.GetDirectories(LocalLIB), MbrPath;
            string   Name, Ext, LocalMember, SPF;
            bool     CheckedUpload = false;

            foreach (string Dir in Dirs)
            {
                SPF = Path.GetFileName(Dir);
                Member[] MemberList = IBMiUtils.GetMemberList(lib.Text, SPF);
                if (MemberList == null)
                {
                    CreateSPFs.Add(SPF, 112);
                }

                foreach (string FilePath in Directory.GetFiles(Dir))
                {
                    Name = SPF + '/' + Path.GetFileNameWithoutExtension(FilePath);
                    Ext  = Path.GetExtension(FilePath).TrimStart('.');

                    if (MemberList == null)
                    {
                        CreateMembers.Add(Name, Ext);
                    }
                    else
                    {
                        if (MemberList.Where(x => (x.GetObject() + '/' + x.GetMember()) == Name).Count() == 0)
                        {
                            CreateMembers.Add(Name, Ext);
                        }
                    }

                    UploadMembers.Add(Name, Ext);
                }

                if (MemberList != null)
                {
                    foreach (Member MemberInfo in MemberList)
                    {
                        LocalMember = IBMiUtils.GetLocalFile(MemberInfo.GetLibrary(), MemberInfo.GetObject(), MemberInfo.GetMember(), MemberInfo.GetExtension());
                        if (!File.Exists(LocalMember))
                        {
                            DeleteMembers.Add(MemberInfo.GetObject() + "/" + MemberInfo.GetMember());
                        }
                    }
                }
            }

            foreach (var SPFInfo in CreateSPFs)
            {
                commandLog.Items.Add(new ListViewItem(SPFInfo.Key + " (" + SPFInfo.Value.ToString() + ")", commandLog.Groups[0]));
            }

            foreach (string MemberName in DeleteMembers)
            {
                commandLog.Items.Add(new ListViewItem(MemberName, commandLog.Groups[1]));
            }

            foreach (var MemberInfo in CreateMembers)
            {
                commandLog.Items.Add(new ListViewItem(MemberInfo.Key + "." + MemberInfo.Value, commandLog.Groups[2]));
            }

            foreach (var MemberName in UploadMembers)
            {
                MbrPath       = MemberName.Key.Trim().Split('/');
                CheckedUpload = MemberCache.EditsContains(lib.Text.ToUpper(), MbrPath[0], MbrPath[1]);
                memberLog.Items.Add(new ListViewItem(MemberName.Key)
                {
                    Checked = CheckedUpload
                });
            }

            pushButton.Enabled  = true;
            fetch.Enabled       = false;
            lib.Enabled         = false;
            runCommands.Enabled = true;
        }