Beispiel #1
0
 public static List<Image> GetImagesFromPdf()
 {
     ContainerAccess container = new ContainerAccess();
     AuScGen.PDFOperation.PDFReader pdfReader = container.GetPlugin<AuScGen.PDFOperation.PDFReader>();
     List<Image> images = pdfReader.GetImages(Directory.GetCurrentDirectory() + @"\TestPDF\Test3.pdf");
     return images;
 }
Beispiel #2
0
        public bool HasAccess(CorporationRole memberRole, ContainerAccess access)
        {
            //not defined for this container
            if (HangarAccess == CorporationRole.NotDefined)
            {
                return(true);
            }

            //corp lord?
            if (memberRole.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO))
            {
                return(true);
            }

            //return a single bit: the highest
            var hangarAccess = HangarAccess.GetHighestContainerAccess();

            // let's check the action
            var expectedAccess = (int)memberRole.CleanUpHangarAccess() & (int)hangarAccess;

            if (expectedAccess == 0)
            {
                return(false);
            }

            if (access != ContainerAccess.Delete && access != ContainerAccess.Remove && access != ContainerAccess.List)
            {
                return(true);
            }

            return(memberRole.IsAnyRole(hangarAccess.GetRelatedRemoveAccess()));
        }
Beispiel #3
0
 static string FormatContainerAccessUri(ContainerAccess accessTest, string blob, string uriSuffix)
 {
     return(String.Format("http://localhost/{0}/{1}/{2}?{3}",
                          String.IsNullOrEmpty(blob) ? "container" : "blob",
                          accessTest == ContainerAccess.Private ? "test" : (accessTest == ContainerAccess.Container ? "anonymouscontainertest" : "anonymousblobtest"),
                          blob,
                          uriSuffix));
 }
        protected void AddLogEntry(Character character, ContainerAccess access, int definition = 0, int quantity = 0)
        {
            if (!IsLogging())
            {
                return;
            }

            ContainerLogger.AddLogEntry(character, access, definition, quantity);
        }
Beispiel #5
0
        public static List<string> PDFRead()
        {
            ContainerAccess container = new ContainerAccess();
            AuScGen.PDFOperation.PDFReader pdfReader = container.GetPlugin<AuScGen.PDFOperation.PDFReader>();
            string pdfContent = pdfReader.ExtractTextFromPdf(Directory.GetCurrentDirectory() + @"\TestPDF\Test3.pdf");
            List<string> values = pdfContent.Split(new string[] { "\n" }, StringSplitOptions.None).ToList();

            return values;
        }
Beispiel #6
0
        public Testbase()
        {
            Container = new ContainerAccess();
            //White = Container.GetPlugin<WhitePlugin>();
            //white.ProcessName = "calc";
            //white.AppWindowName = "Calculator";


        }
        public static Container GetWithItems(long containerEid, Character character, ContainerAccess access)
        {
            var container = GetOrThrow(containerEid);

            container.Quantity.ThrowIfNotEqual(1, ErrorCodes.ItemHasToBeSingle);
            container.IsRepackaged.ThrowIfTrue(ErrorCodes.ContainerHasToBeUnPacked);
            container.CheckAccessAndThrowIfFailed(character, access);
            container.ReloadItems(character);

            return(container);
        }
Beispiel #8
0
        public void UpdateExistAccess(ContainerAccess containerExist, ContainerAccess containerAdd)
        {
            if (containerExist == null)
            {
                this.ContainerAccessList.Add(containerAdd);
                return;
            }
            if (this.FindContainerAccessByName(containerExist.ContainerName) == null)
            {
                this.ContainerAccessList.Add(containerAdd);
            }
            else
            {
                if (containerExist.ContainerName == containerAdd.ContainerName)
                {
                    List <ControlAccess> controlAccessList = new List <ControlAccess>();
                    ControlAccess        accessTmp         = null;
                    foreach (ControlAccess item in containerAdd.ControlAccessList)
                    {
                        accessTmp = containerExist.ControlAccessList.Find(p => { return(p.AccessDesrciption == item.AccessDesrciption); });
                        //如果ControlAccess 已经存在
                        if (accessTmp != null)
                        {
                            //默认中有的权限项,accessTmp中可能不存在
                            List <AccessMap> maps = new List <AccessMap>();

                            AccessMap mapTemp = null;
                            //遍历默认的权限AccessMap
                            foreach (AccessMap map in item.Controls)
                            {
                                mapTemp = accessTmp.Controls.Find(p => p.ControlName == map.ControlName);
                                //accessTmp 存在AccessMap
                                if (mapTemp != null)
                                {
                                    maps.Add(mapTemp);
                                }
                                else
                                {
                                    maps.Add(map);
                                }
                            }
                            accessTmp.Controls = maps;
                            controlAccessList.Add(accessTmp);
                        }
                        else//如果不存在
                        {
                            controlAccessList.Add(item);
                        }
                    }
                    containerExist.ControlAccessList = controlAccessList;
                }
            }
        }
Beispiel #9
0
        public CorporateHangar GetHangar(long hangarEid, Character character, ContainerAccess containerAccess = ContainerAccess.Delete)
        {
            var role = GetMemberRole(character);

            var hangar = (CorporateHangar)Container.GetOrThrow(hangarEid);

            if (!role.IsAnyRole(CorporationRole.CEO, CorporationRole.DeputyCEO))
            {
                role.IsAnyRole(CorporationRole.HangarOperator).ThrowIfFalse(ErrorCodes.InsufficientPrivileges);
                hangar.CheckAccessAndThrowIfFailed(character, containerAccess);
            }

            hangar.Owner.ThrowIfNotEqual(Eid, ErrorCodes.AccessDenied);
            return(hangar);
        }
Beispiel #10
0
        public void AddContainerAccess(ContainerAccess containerAccess)
        {
            ContainerAccess accessExist = null;

            accessExist = this.ContainerAccessList.Find(p => p.ContainerName == containerAccess.ContainerName);

            if (accessExist == null)
            {
                this.ContainerAccessList.Add(containerAccess);
            }
            else
            {
                this.UpdateExistAccess(accessExist, containerAccess);
            }
        }
Beispiel #11
0
        public void AddLogEntry(Character character, ContainerAccess access, int definition = 0, int quantity = 0)
        {
            if (character == Character.None)
            {
                return;
            }

            var logEntry = new ContainerLogEntry
            {
                character  = character,
                definition = definition,
                quantity   = quantity,
                access     = access
            };

            _logs.Enqueue(logEntry);
        }
Beispiel #12
0
 static string FormatContainerAccessUri(ContainerAccess accessTest, string blob, string uriSuffix)
 {
     return String.Format("http://localhost/{0}/{1}/{2}?{3}",
         String.IsNullOrEmpty(blob) ? "container" : "blob",
         accessTest == ContainerAccess.Private ? "test" : (accessTest == ContainerAccess.Container ? "anonymouscontainertest" : "anonymousblobtest"),
         blob,
         uriSuffix);
 }
Beispiel #13
0
 public void CheckAccessAndThrowIfFailed(CorporationRole memberRole, ContainerAccess access)
 {
     HasAccess(memberRole, access).ThrowIfFalse(ErrorCodes.InsufficientPrivileges);
 }
Beispiel #14
0
 public static void ExtractPages(string sourcePath, string targetPath, int startPageNumber, int endPageNumber)
 {
     ContainerAccess container = new ContainerAccess();
     AuScGen.PDFOperation.PDFReader pdfReader = container.GetPlugin<AuScGen.PDFOperation.PDFReader>();
     pdfReader.ExtractPages(sourcePath, targetPath, startPageNumber, endPageNumber);
 }
Beispiel #15
0
 static void EvaluateAnonymousContainerAccess(ContainerAccess expectedAccess, string method, string blob, string uriSuffix, IEnumerable <Tuple <string, string> > headers = null)
 {
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Private), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Private, blob, uriSuffix), headers));
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Container), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Container, blob, uriSuffix), headers));
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Blob), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Blob, blob, uriSuffix), headers));
 }
Beispiel #16
0
 static void EvaluateAnonymousContainerAccess(ContainerAccess expectedAccess, string method, string blob, string uriSuffix, IEnumerable<Tuple<string, string>> headers = null)
 {
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Private), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Private, blob, uriSuffix), headers));
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Container), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Container, blob, uriSuffix), headers));
     Assert.AreEqual(expectedAccess.HasFlag(ContainerAccess.Blob), IsRequestAuthorized(method, FormatContainerAccessUri(ContainerAccess.Blob, blob, uriSuffix), headers));
 }
 public static IContainerAccessChecker Create(Character character, ContainerAccess access)
 {
     return(new ContainerAccessChecker(character, access));
 }
 private ContainerAccessChecker(Character character, ContainerAccess access)
 {
     _character = character;
     _access    = access;
 }
 public void CheckAccessAndThrowIfFailed(Character character, ContainerAccess containerAccess)
 {
     CheckAccess(character, containerAccess).ThrowIfError();
 }
Beispiel #20
0
        private void AddContainerAccess(ContainerAccess containerAccess)
        {
            DataGridViewRow dr = new DataGridViewRow();

            dr.HeaderCell.Value           = containerAccess.ContainerAccessDescription;
            dr.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            ControlAccess           container = containerAccess.GetContainerAccess();
            DataGridViewTextBoxCell txtCell   = new DataGridViewTextBoxCell();

            dr.Cells.Add(txtCell);
            if (container == null)
            {
                MessageBox.Show("缺少窗体控件权限");
                return;
            }
            dr.Tag = container;
            for (int i = 0; i < 3; i++)
            {
                DataGridViewCheckBoxCell ckbCell = new DataGridViewCheckBoxCell();
                dr.Cells.Add(ckbCell);
            }

            if (container == null)
            {
                dr.Cells[1].Value = true;
                dr.Cells[2].Value = true;
                dr.Cells[3].Value = true;
            }
            else
            {
                dr.Cells[1].Value = (RoleEnums.Operator - container.RoleLevel) >= 0 ? true : false;
                dr.Cells[2].Value = (RoleEnums.Technician - container.RoleLevel) >= 0 ? true : false;
                dr.Cells[3].Value = (RoleEnums.Supervisor - container.RoleLevel) >= 0 ? true : false;
            }

            this.dgvAccess.Rows.Add(dr);

            foreach (ControlAccess item in containerAccess.ControlAccessList)
            {
                if (item.AccessDesrciption == containerAccess.ContainerAccessDescription)
                {
                    continue;
                }
                dr = new DataGridViewRow();
                dr.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                dr.Tag = item;
                DataGridViewTextBoxCell txtCellChild = new DataGridViewTextBoxCell();
                txtCellChild.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
                dr.Cells.Add(txtCellChild);
                for (int i = 0; i < 3; i++)
                {
                    DataGridViewCheckBoxCell ckbCell = new DataGridViewCheckBoxCell();
                    dr.Cells.Add(ckbCell);
                }
                dr.Cells[0].Value = item.AccessDesrciption;
                dr.Cells[1].Value = (RoleEnums.Operator - item.RoleLevel) >= 0 ? true : false;
                dr.Cells[2].Value = (RoleEnums.Technician - item.RoleLevel) >= 0 ? true : false;
                dr.Cells[3].Value = (RoleEnums.Supervisor - item.RoleLevel) >= 0 ? true : false;
                this.dgvAccess.Rows.Add(dr);
            }
        }
        public ErrorCodes CheckAccess(Character character, ContainerAccess access)
        {
            var checker = ContainerAccessChecker.Create(character, access);

            return(checker.CheckAccess(this));
        }