Example #1
0
        private void getTitlePage()
        {
            try
            {
                JsonReader        reader     = new JsonTextReader(new StringReader(WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetModuleInfo?moduleID=" + data.ModuleName, data.Token)));
                string            text       = WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetModuleInfo?moduleID=" + data.ModuleName, data.Token);
                ModuleInformation moduleInfo = JsonConvert.DeserializeObject <ModuleInformation>(text);
                XFont             titleFont  = new XFont("Verdana", 15, XFontStyle.Bold);

                using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new Bitmap(1, 1)))
                {
                    SizeF  size      = graphics.MeasureString(moduleInfo.ModuleName, new Font("Verdana", 15, FontStyle.Bold, GraphicsUnit.Point));
                    Double textWidth = (double)size.Width / 2;
                    XRect  titleRect = new XRect((pdfPage.Width / 2) - textWidth / 1.4, 100, someWidth, 200);
                    tf.DrawString(moduleInfo.ModuleName, titleFont, XBrushes.Black, titleRect, XStringFormats.TopLeft);
                    size      = graphics.MeasureString(data.ModuleName, new Font("Verdana", 15, FontStyle.Bold, GraphicsUnit.Point));
                    textWidth = (double)size.Width / 2;
                    titleRect = new XRect(pdfPage.Width / 2 - textWidth / 1.4, 120, someWidth, 200);
                    tf.DrawString(data.ModuleName, titleFont, XBrushes.Black, titleRect, XStringFormats.TopLeft);
                }



                XFont infoText = new XFont("Verdana", 10, XFontStyle.Regular);
                XRect infoRect = new XRect(myX, pdfPage.Height - 200, someWidth, 200);
                tf.DrawString(moduleInfo.LocationName, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 190, someWidth, 200);
                tf.DrawString(moduleInfo.Sector, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 180, someWidth, 200);
                tf.DrawString(moduleInfo.POBox, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 170, someWidth, 200);
                tf.DrawString(moduleInfo.PostalCode, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 160, someWidth, 200);
                tf.DrawString(moduleInfo.Phone, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                infoRect = new XRect(myX, pdfPage.Height - 150, someWidth, 200);
                tf.DrawString(moduleInfo.Website, infoText, XBrushes.Black, infoRect, XStringFormats.TopLeft);

                pdfPage = pdf.AddPage();
                graph   = XGraphics.FromPdfPage(pdfPage);
                tf      = new XTextFormatter(graph);
            }
            catch
            {
                getTitlePage();
            }
        }
Example #2
0
        public static Dictionary <string, string> getModuleData(string token, string lang, string moduleId)
        {
            Console.WriteLine(lang);
            Dictionary <string, string> moduleDetails = new Dictionary <string, string>();
            List <Subsecties>           sub           = new List <Subsecties>();
            string text = null;
            Task   t    = Task.Factory.StartNew(() => {
                text = WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetSubsectionNames?languageID=" + lang, token);
                sub  = JsonConvert.DeserializeObject <List <Subsecties> >(text);
            });

            Task.WaitAll(t);

            foreach (Subsecties subsec in sub)
            {
                string         moduleResond  = WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/GetData?moduleID=+" + moduleId + "&subsectionID=" + subsec.SubsectionID + "&languageID=" + lang, token);
                SubsectionData respondString = JsonConvert.DeserializeObject <SubsectionData>(moduleResond);
                moduleDetails.Add(subsec.SubsectionName, respondString.Content);
            }

            return(moduleDetails);
        }
Example #3
0
        private List <Module> getModuleData()
        {
            string text = WebRequestHelper.getData("http://mbbsweb.azurewebsites.net/api/Module/DocentModules", this.data.Token);

            return(JsonConvert.DeserializeObject <List <Module> >(text));
        }