示例#1
0
        public void SingleDocRapidFire(string docid, int repeat, BackgroundWorker bw)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return;
            }

            decimal count = 0;

            for (int i = 0; i < repeat; i++)
            {
                string responseContent1 = rest.PostDocPage(docid, null, "placeholder.tif");
                if (!responseContent1.Equals("success"))
                {
                    MessageBox.Show($"Failed to add page to document.\r\n{responseContent1}");
                    return;
                }
                count++;
                bw.ReportProgress((int)((count / repeat) * 100));
            }
            string responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default the sessions will clear in one hour.\r\n{responseContent2}");
            }
            MessageBox.Show($"Fake pages added to document: {docid}.");
        }
示例#2
0
        public void SingleDocSingleFile(string docid, int repeat, BackgroundWorker bw)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return;
            }

            string filename = Path.GetFileName(conf.filePath);

            byte[]  fileBytes = File.ReadAllBytes(conf.filePath);
            decimal count     = 0;

            for (int i = 0; i < repeat; i++)
            {
                string responseContent1 = rest.PostDocPage(docid, fileBytes, filename);
                if (!responseContent1.Equals("success"))
                {
                    MessageBox.Show($"Failed to add page to document.\r\n{responseContent1}");
                    return;
                }
                count++;
                bw.ReportProgress((int)((count / repeat) * 100));
            }
            string responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default the sessions will clear in one hour.\r\n{responseContent2}");
            }
            MessageBox.Show($"Pages added to document: {docid}.");
        }
示例#3
0
        public void MultiDocRapidFire(string n, string l, string d, string f1, string f2, string f3, string f4, string f5, string dt, int repeat, string queueid, BackgroundWorker bw)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return;
            }

            decimal count = 0;

            for (int i = 0; i < repeat; i++)
            {
                ImageNowDoc doc;
                if (d.Contains("Folder"))
                {
                    doc = new ImageNowDoc(Guid.NewGuid().ToString(), l, d, f1, f2, f3, f4, Guid.NewGuid().ToString(), dt);
                }
                else
                {
                    doc = new ImageNowDoc(n, l, d, f1, f2, f3, f4, Guid.NewGuid().ToString(), dt);
                }

                string docid = rest.PostDoc(doc);
                if (docid.Length != 23)
                {
                    MessageBox.Show($"Failed to create document.\r\n{docid}");
                    return;
                }

                string queueResponse = "";
                if (!string.IsNullOrEmpty(queueid))
                {
                    queueResponse = rest.RouteDoc(docid, queueid);
                }

                if (!queueResponse.Equals("success"))
                {
                    MessageBox.Show($"Failed to route document.\r\n{queueResponse}");
                }

                count++;
                bw.ReportProgress((int)((count / repeat) * 100));
            }
            string responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default the sessions will clear in one hour.\r\n{responseContent2}");
            }
            MessageBox.Show("Documents created.");
        }
示例#4
0
        public CustPropRoot GetCustProps(string docTypeID)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return(null);
            }
            CustPropRoot temp = rest.GetCustProps(docTypeID);

            return(temp);
        }
示例#5
0
        public DocTypeRoot GetDocTypes()
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return(null);
            }
            DocTypeRoot docTypes = rest.GetDocType();

            return(docTypes);
        }
示例#6
0
        public void SingleDocMultiFile(string docid, int repeat, bool recursive, BackgroundWorker bw)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return;
            }

            string[] files;
            if (recursive)
            {
                files = Directory.GetFiles(conf.folderPath, "*", SearchOption.AllDirectories);
            }
            else
            {
                files = Directory.GetFiles(conf.folderPath);
            }

            decimal total = files.Length * repeat;
            decimal count = 0;

            for (int i = 0; i < repeat; i++)
            {
                foreach (string s in files)
                {
                    string filename         = Path.GetFileName(s);
                    byte[] fileBytes        = File.ReadAllBytes(s);
                    string responseContent1 = rest.PostDocPage(docid, fileBytes, filename);
                    if (!responseContent1.Equals("success"))
                    {
                        MessageBox.Show($"Failed to add page to document.\r\n{responseContent1}");
                        return;
                    }
                    count++;
                    bw.ReportProgress((int)((count / total) * 100));
                }
            }

            string responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default the sessions will clear in one hour.\r\n{responseContent2}");
            }
            MessageBox.Show($"Pages added to document: {docid}.");
        }
示例#7
0
        public DrawerRoot GetDrawers()
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return(null);
            }
            DrawerRoot drawers          = rest.GetDrawers();
            string     responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default the sessions will clear in one hour.\r\n{responseContent2}");
            }
            return(drawers);
        }
示例#8
0
        public void MultiDocMultiFile(string n, string l, string d, string f1, string f2, string f3, string f4, string f5, string dt, int repeat, bool recursive, string queueid, BackgroundWorker bw)
        {
            RestCall rest = new RestCall(conf);

            conf.intServer.sessionHash = rest.GetConnection();
            if (conf.intServer.sessionHash.Length != 41)
            {
                MessageBox.Show($"Failed to get connection.\r\n{conf.intServer.sessionHash}");
                return;
            }

            string[] files;
            if (recursive)
            {
                files = Directory.GetFiles(conf.folderPath, "*", SearchOption.AllDirectories);
            }
            else
            {
                files = Directory.GetFiles(conf.folderPath);
            }

            decimal total = files.Length * repeat;
            decimal count = 0;

            for (int i = 0; i < repeat; i++)
            {
                foreach (string s in files)
                {
                    string      shortFilename = GetShortFileName(s);
                    string      longFilename  = Path.GetFileName(s);
                    ImageNowDoc doc;
                    if (d.Contains("Folder"))
                    {
                        doc = new ImageNowDoc(Guid.NewGuid().ToString(), l, d, f1, f2, f3, shortFilename, Guid.NewGuid().ToString(), dt);
                    }
                    else
                    {
                        doc = new ImageNowDoc(n, l, d, f1, f2, f3, shortFilename, Guid.NewGuid().ToString(), dt);
                    }

                    string docid = rest.PostDoc(doc);
                    if (docid.Length != 23)
                    {
                        MessageBox.Show($"Failed to create document.\r\n{docid}");
                        return;
                    }
                    else
                    {
                        byte[] fileBytes        = File.ReadAllBytes(s);
                        string responseContent1 = rest.PostDocPage(docid, fileBytes, longFilename);
                        if (!responseContent1.Equals("success"))
                        {
                            MessageBox.Show($"Failed to add page to document.\r\n{responseContent1}");
                            return;
                        }
                    }

                    string queueResponse = "";
                    if (!string.IsNullOrEmpty(queueid))
                    {
                        queueResponse = rest.RouteDoc(docid, queueid);
                    }

                    if (!queueResponse.Equals("success"))
                    {
                        MessageBox.Show($"Failed to route document.\r\n{queueResponse}");
                    }

                    count++;
                    bw.ReportProgress((int)((count / total) * 100));
                }
            }
            string responseContent2 = rest.DeleteConnection();

            if (!responseContent2.Equals("success"))
            {
                MessageBox.Show($"Failed to clear sessions.\r\nNo reason to be alarmed, by default they will clear themselves in one hour.\r\n{responseContent2}");
            }
            MessageBox.Show("Documents created and pages added.");
        }