예제 #1
0
        private TaskDTO[] GetTasksFromT(int teamId, BDT businessDayT)
        {
            // return cn
            //     .Tasks
            //     .Where(t=>t.TeamId==teamId)
            //     .Where(t=>t.BusinessDT==businessDayT.TPlus)
            //     .Where(t=>t.BusinessDT==businessDayT.TMinus)
            //     .ToArray(); wrong, we can write multiple where but not on same property why?

            // return cn
            //     .Tasks
            //     .Where(t=>t.TeamId==teamId)
            //     .Where(t=>t.BusinessDT==businessDayT.TPlus || t.BusinessDT==businessDayT.TMinus)
            //     .ToArray();//this woen iswerite:

            // return cn
            //     .Tasks
            //     .Where(t=>t.TeamId==teamId)
            //     .Where(t=>t.BusinessDT==businessDayT.TPlus || t.BusinessDT==businessDayT.TMinus)
            //     .ToArray().Select(tsk=>new
            //     {
            //         tsk.Priority,
            //         tsk.Title,
            //         tsk.Description,
            //         tsk.BusinessDT,
            //         tsk.PrimaryOwner,
            //         tsk.SecondaryOwner
            //     }).Cast<TaskDTO>().ToArray();not working
            //  return cn
            //                 .Tasks
            //                 .Where(t=>t.TeamId==teamId)
            //                 .Where(t=>t.BusinessDT==businessDayT.TPlus || t.BusinessDT==businessDayT.TMinus)
            //                 .ToArray().Select(tsk=>new TaskDTO
            //                 {
            //                     Priority = tsk.Priority.ToString(),
            //                     Title=tsk.Title,
            //                     Description=tsk.Description,
            //                     BusinessDT=tsk.BusinessDT,
            //                     PrimaryOwner=tsk.PrimaryOwner.UserId,
            //                     SecondaryOwner=tsk.SecondaryOwner.UserId
            //                 }).Cast<TaskDTO>().ToArray();working
            return(cn
                   .Tasks
                   .Where(t => t.TeamId == teamId)
                   .Where(t => t.BusinessDT == businessDayT.TPlus || t.BusinessDT == businessDayT.TMinus)
                   .Select(tsk => new TaskDTO
            {
                Priority = Enum.GetName(typeof(Priorities), tsk.Priority),
                Title = tsk.Title,
                Description = tsk.Description,
                BusinessDT = tsk.BusinessDT,
                PrimaryOwner = tsk.PrimaryOwner.UserId,
                SecondaryOwner = tsk.SecondaryOwner.UserId
            }).ToArray());
        }
예제 #2
0
        private BDT?GetBusinessDayT(int?businessdayId)
        {
            //BDT? bdt = new BDT();
            BDT bdt = new BDT {
                TPlus = 0, TMinus = 0, TotalTs = 0
            };

            DateTime startDate = cn.BusinessDays
                                 .Where(b => b.Id == businessdayId)
                                 .Select(b => b.StartDate)
                                 .SingleOrDefault();

            DateTime endDate = cn.BusinessDays
                               .Where(b => b.Id == businessdayId)
                               .Select(b => b.EndDate)
                               .SingleOrDefault();

            DateTime dateForIteration = startDate;
            DateTime nowDate          = DateTime.Now;

            while (dateForIteration < endDate)//last date is T and henc e <
            {
                bool isHollyday = IsHollydayinHollydayList(dateForIteration);
                if (isHollyday)
                {
                    dateForIteration = dateForIteration.AddDays(1d);//dateForIteration.AddDays(1);
                }
                else
                {
                    dateForIteration = dateForIteration.AddDays(1d);//dateForIteration.AddDays(1); this is bad, i got stuck
                    bdt.TotalTs     += 1;
                    if (dateForIteration <= nowDate)
                    {
                        bdt.TPlus += 1;
                    }
                }
            }

            bdt.TMinus = -(bdt.TotalTs - bdt.TPlus);

            return(bdt);
        }
예제 #3
0
        private bool processBDT(BDT bdt, string baseDir, string subPath)
        {
            bool edited = false;

            foreach (BDT.File bdtEntry in bdt.Files)
            {
                if (stop)
                {
                    return(false);
                }

                bool   dcx               = false;
                byte[] bdtEntryBytes     = bdtEntry.Bytes;
                string bdtEntryExtension = Path.GetExtension(bdtEntry.Name);
                if (bdtEntryExtension == ".dcx")
                {
                    dcx               = true;
                    bdtEntryBytes     = DCX.Decompress(bdtEntryBytes);
                    bdtEntryExtension = Path.GetExtension(bdtEntry.Name.Substring(0, bdtEntry.Name.Length - 4));
                }

                if (bdtEntryExtension == ".tpf")
                {
                    TPF tpf = TPF.Read(bdtEntryBytes);
                    if (processTPF(tpf, baseDir, subPath))
                    {
                        bdtEntry.Bytes = tpf.Write();
                        if (dcx)
                        {
                            bdtEntry.Bytes = DCX.Compress(bdtEntry.Bytes);
                        }
                        edited = true;
                    }
                }
                // This whouldn't really be a problem, but I would like to know about it
                else
                {
                    appendError("Error: {0}\r\n\u2514\u2500 Non-tpf found in tpfbdt: {1}", subPath, bdtEntry.Name);
                }
            }
            return(edited);
        }
예제 #4
0
        /// <summary>
        /// Adds a new document encapsulation (BDT/EDT tags) to the end of the print file. Will automatically handle nesting if print file tags exist
        /// </summary>
        /// <param name="docName">The optional 8 character name of the document</param>
        /// <returns>The resulting document's container</returns>
        public Container AddDocument(string docName = "")
        {
            Container newContainer  = null;
            int       indexToInsert = Fields.Count;

            // If BPF/EPF tags exist, make sure the document goes inside them
            if (Fields.Last() is EPF)
            {
                indexToInsert--;
            }

            // Add the only two required fields for a document - BDT and EDT
            BDT newBDT = new BDT(docName);
            EDT newEDT = new EDT(docName);

            AddFields(new List <StructuredField>()
            {
                newBDT, newEDT
            }, indexToInsert);

            // Set and return the new container
            newContainer = newBDT.LowestLevelContainer;
            return(newContainer);
        }
예제 #5
0
 public ButtonDelegateT(BDT bd)
 {
     bd = bdt;
 }
예제 #6
0
        private void iterateFiles(ConcurrentQueue <string> filepaths)
        {
            while (!stop && filepaths.TryDequeue(out string filepath))
            {
                // These are already full paths, but trust no one, not even yourself
                string absolute = Path.GetFullPath(filepath);
                string relative = absolute.Substring(gameDir.Length + 1);

                if (repack)
                {
                    appendLog("Checking: " + relative);
                }
                else
                {
                    appendLog("Unpacking: " + relative);
                }

                bool   dcx       = false;
                byte[] bytes     = File.ReadAllBytes(absolute);
                string extension = Path.GetExtension(absolute);
                string subpath   = Path.GetDirectoryName(relative) + "\\" + Path.GetFileNameWithoutExtension(absolute);
                if (extension == ".dcx")
                {
                    dcx       = true;
                    bytes     = DCX.Decompress(bytes);
                    extension = Path.GetExtension(Path.GetFileNameWithoutExtension(absolute));
                    subpath   = subpath.Substring(0, subpath.Length - extension.Length);
                }

                bool edited = false;
                switch (extension)
                {
                case ".tpf":
                    TPF tpf = TPF.Read(bytes);
                    if (processTPF(tpf, looseDir, subpath))
                    {
                        edited = true;
                        byte[] tpfBytes = tpf.Write();
                        if (dcx)
                        {
                            tpfBytes = DCX.Compress(tpfBytes);
                        }
                        writeRepack(absolute, tpfBytes);
                        lock (countLock)
                            fileCount++;
                    }
                    break;

                case ".tpfbhd":
                    string dir     = Path.GetDirectoryName(absolute);
                    string name    = Path.GetFileNameWithoutExtension(absolute);
                    string bdtPath = dir + "\\" + name + ".tpfbdt";
                    if (File.Exists(bdtPath))
                    {
                        byte[] bdtBytes = File.ReadAllBytes(bdtPath);
                        BDT    bdt      = BDT.Read(bytes, bdtBytes);
                        if (processBDT(bdt, looseDir, subpath))
                        {
                            edited = true;
                            (byte[], byte[])repacked = bdt.Write();
                            if (dcx)
                            {
                                repacked.Item1 = DCX.Compress(repacked.Item1);
                            }
                            writeRepack(absolute, repacked.Item1);
                            writeRepack(bdtPath, repacked.Item2);
                            lock (countLock)
                                fileCount++;
                        }
                    }
                    else
                    {
                        throw new FileNotFoundException("Data file not found for header: " + relative);
                    }
                    break;

                case ".chrbnd":
                case ".ffxbnd":
                case ".fgbnd":
                case ".objbnd":
                case ".partsbnd":
                    BND bnd = BND.Read(bytes);
                    foreach (BND.File entry in bnd.Files)
                    {
                        if (stop)
                        {
                            break;
                        }

                        string entryExtension = Path.GetExtension(entry.Name);
                        if (entryExtension == ".tpf")
                        {
                            TPF bndTPF = TPF.Read(entry.Bytes);
                            if (processTPF(bndTPF, looseDir, subpath))
                            {
                                entry.Bytes = bndTPF.Write();
                                edited      = true;
                            }
                        }
                        else if (entryExtension == ".chrtpfbhd")
                        {
                            string bndDir  = Path.GetDirectoryName(absolute);
                            string bndName = Path.GetFileNameWithoutExtension(absolute);
                            if (dcx)
                            {
                                bndName = Path.GetFileNameWithoutExtension(bndName);
                            }
                            string bndBDTPath = bndDir + "\\" + bndName + ".chrtpfbdt";
                            if (File.Exists(bndBDTPath))
                            {
                                byte[] bdtBytes = File.ReadAllBytes(bndBDTPath);
                                BDT    bndBDT   = BDT.Read(entry.Bytes, bdtBytes);
                                if (processBDT(bndBDT, looseDir, subpath))
                                {
                                    (byte[], byte[])repacked = bndBDT.Write();
                                    entry.Bytes = repacked.Item1;
                                    writeRepack(bndBDTPath, repacked.Item2);
                                    edited = true;
                                }
                            }
                            else
                            {
                                throw new FileNotFoundException("Data file not found for header: " + relative);
                            }
                        }
                    }

                    if (edited && !stop)
                    {
                        byte[] bndBytes = bnd.Write();
                        if (dcx)
                        {
                            bndBytes = DCX.Compress(bndBytes);
                        }
                        writeRepack(absolute, bndBytes);
                        lock (countLock)
                            fileCount++;
                    }
                    break;
                }

                if (repack && !edited && !stop)
                {
                    appendError("Notice: {0}\r\n\u2514\u2500 No overrides found.", relative);
                }

                lock (progressLock)
                    progress++;
            }
        }