Ejemplo n.º 1
0
        public static ActionResult Pdf(this Controller controller, params PdfView[] pdfViews)
        {
            var pdfStreams = new List <Stream>();

            // Generate all the pdfs as MemoryStreams
            foreach (var pdfView in pdfViews)
            {
                pdfView.PdfSettings = pdfView.PdfSettings ?? new PdfSettings();
                var    html = Socks.RenderViewToString(controller, pdfView.View, pdfView.Model, pdfView.PdfSettings);
                Stream pdf  = Socks.toPdf(html, pdfView.PdfSettings);
                pdfStreams.Add(pdf);
            }

            // Stitch the files together using pdfSharp (http://www.pdfsharp.net/wiki/CombineDocuments-sample.ashx)
            var outputDocument = new PdfDocument();

            foreach (var pdfStream in pdfStreams)
            {
                var pages = PdfReader.Open(pdfStream, PdfDocumentOpenMode.Import).Pages;
                for (int pageIndex = 0; pageIndex < pages.Count; pageIndex++)
                {
                    outputDocument.AddPage(pages[pageIndex]);
                }
            }

            var finalPdf = new MemoryStream();

            outputDocument.Save(finalPdf, false);

            return(controller.File(finalPdf));
        }
Ejemplo n.º 2
0
        public static ActionResult Pdf(this Controller controller, string view, Object model, PdfSettings settings = null)
        {
            if (settings == null)
            {
                settings = new PdfSettings();
            }

            var html = Socks.RenderViewToString(controller, view, model, settings);

            //var html = controller.RenderViewToString(view, model, settings);

            if (settings.Action == PdfSettings.PdfAction.Html)
            {
                return(Socks.RenderPdfAsHtml(controller, html));
            }

            Stream pdf = Socks.toPdf(html, settings);

            if (settings.Action == PdfSettings.PdfAction.Download)
            {
                var filename = settings.Filename ?? (Guid.NewGuid().ToString("N") + ".pdf");
                controller.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
            }

            return(controller.File(pdf));
        }
Ejemplo n.º 3
0
 public override bool OnConnect(Socks.SocksRequest Request)
 {
     //Compare data.
     if (Request.Address.Contains("74.125.224")) //Google.com IP
     {
         Console.WriteLine("Redirecting traffic from {0} to yahoo.com.", Request.Address);
         Request.Address = "www.yahoo.com";
         Request.Type = Socks.AddressType.Domain;
     }
     //Allow the connection.
     return true;
 }
Ejemplo n.º 4
0
        public static Stream PdfStream(this Controller controller, string view, Object model, PdfSettings settings = null)
        {
            if (settings == null)
            {
                settings = new PdfSettings();
            }

            var html = Socks.RenderViewToString(controller, view, model, settings);

            if (settings.Action == PdfSettings.PdfAction.Html)
            {
                throw new Exception("Html mode is not supported in stream mode");
            }

            return(Socks.toPdf(html, settings));
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            StartDate     = DateTime.Now;
            Console.Title = "Konquer - AuthServer";

            var    cfgFile  = new IniFile("Config.ini");
            int    Port     = cfgFile.ReadInt32("Server", "AuthPort", 0);
            string host     = cfgFile.ReadString("MySql", "Host"),
                   username = cfgFile.ReadString("MySql", "Username"),
                   password = cfgFile.ReadString("MySql", "Password"),
                   database = cfgFile.ReadString("MySql", "Database");

            var stringBuilder = new MySqlConnectionStringBuilder();

            stringBuilder.Server   = host;
            stringBuilder.UserID   = username;
            stringBuilder.Password = password;
            stringBuilder.Database = database;
            connectionString       = stringBuilder.GetConnectionString(true);

            using (var testConn = new MySqlConnection(connectionString))
            {
                try
                {
                    testConn.Open();
                    Console.WriteLine("Valid connection string.");
                }
                catch (Exception e)
                {
                    Console.WriteLine($"[DBError] {e.Message}.");
                    Console.ReadLine();
                    return;
                }
            }

            Servers.LoadInfo();
            AuthCryptography.PrepareAuthCryptography();
            AuthServer = new Socks(Port, 0);

            while (true)
            {
                HandleCommands();
            }
        }
Ejemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     // 마우스 클릭 (터치) 할 경우
     if (Input.GetMouseButtonDown(0))
     {
         // 마우스 클릭(터치) 한 포지션을, 2D 월드 포지션으로 변환
         Vector3 touchPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         // 클릭한 마우스 위치에서 레이캐스트에 걸리는 물체를 hit으로 가져온다
         RaycastHit2D hit = Physics2D.Raycast(touchPosition, Vector2.zero, 0f);
         if (hit)
         {
             Debug.Log("hitObj : " + hit.transform.gameObject.name);
             if (hit.transform.tag == "ColorSocks")
             {
                 Socks socks = hit.transform.GetComponent <Socks>();
                 if (socks.isColorSocks)
                 {
                     socks.ClickSocks();
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 public Account(string name)
 {
     Name = name;
     Socks = new Socks();
 }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            char ch = ' ';

            while (ch != 'e')
            {
                Console.WriteLine("1. Create socks\n" +
                                  "2. Show all socks in wardrobe\n" +
                                  "3. Use socks from wardrobe by index\n" +
                                  "4. Clean socks by index\n" +
                                  "5. Delete socks from list\n" +
                                  "e. Exit\n\n" +
                                  "Your choice: ");
                do
                {
                    string input = Console.ReadLine();
                    if (!char.TryParse(input, out ch))
                    {
                        Console.WriteLine("Incorrect input!\n");
                        continue;
                    }
                    else
                    {
                        break;
                    }
                } while (true);

                switch (ch)
                {
                case '1':
                    Console.WriteLine("Input manufacturer name of new socks \n");
                    string manufactName = Console.ReadLine();
                    Console.WriteLine("Input material of new socks \n");
                    string material = Console.ReadLine();
                    Console.WriteLine("Input model of new socks \n");
                    string model = Console.ReadLine();
                    Console.WriteLine("Input colour of new socks \n");
                    string colour = Console.ReadLine();
                    Console.WriteLine("Input size of new socks \n");
                    int size;

                    do
                    {
                        string input = Console.ReadLine();
                        if (!Int32.TryParse(input, out size))
                        {
                            Console.WriteLine("Incorrect input");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    var newSocks = new Socks(manufactName, colour, material, model, size);
                    Socks.SocksKeeper.Add(newSocks);
                    Socks.SocksKeeper.PrintAllSocks();
                    Console.WriteLine("Choose the next operation if you want\n");

                    break;

                case '2':
                    Socks.SocksKeeper.PrintAllSocks();

                    break;

                case '3':
                    Console.WriteLine("Please input insex of socks you want to use\n");
                    int index;
                    do
                    {
                        string input = Console.ReadLine();
                        if (!Int32.TryParse(input, out index))
                        {
                            Console.WriteLine("Incorrect input");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);
                    var temp = Socks.SocksKeeper.Wardrobe.ElementAt(index);
                    temp.UseSocks(temp);
                    Socks.SocksKeeper.PrintAllSocks();

                    break;

                case '4':
                    Console.WriteLine("Please input insex of socks you want to clean\n");
                    do
                    {
                        string input = Console.ReadLine();
                        if (!Int32.TryParse(input, out index))
                        {
                            Console.WriteLine("Incorrect input");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);
                    temp = Socks.SocksKeeper.Wardrobe.ElementAt(index);
                    temp.CleanSocks(temp);
                    Socks.SocksKeeper.PrintAllSocks();

                    break;

                case '5':
                    Console.WriteLine("Please input insex of socks you want to delete\n");
                    do
                    {
                        string input = Console.ReadLine();
                        if (!Int32.TryParse(input, out index))
                        {
                            Console.WriteLine("Incorrect input");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    Socks.SocksKeeper.Wardrobe.RemoveAt(index);
                    Socks.SocksKeeper.PrintAllSocks();

                    break;

                case 'e':
                    break;
                }
            }
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            int    numbOfProductValid;
            string numbOfProduct;
            string selectKey;
            string selectOption;
            int    countSock = 1;

            do
            {
                Console.Clear();

                Console.WriteLine($"Select the option:\npress \"1\" - Input information about socks\npress \"2\" - Show the list of all products\npress \"3\" - Show information about 1 product" +
                                  $"\npress \"4\" - Delete one product\npress \"5\" - Exit programm");

                selectOption = Console.ReadLine();

                switch (selectOption)
                {
                case "1":
                {
                    Console.WriteLine("Please, input information about socks :)\n");

                    Console.Write("1. Brand of socks:");
                    string brandOfSocks = Console.ReadLine();

                    Console.Write("2. Gender category: 1-man, 2-woman, 3-kids:");
                    string         genderString   = Console.ReadLine();
                    int            gender         = ValidationInputCategory(genderString);
                    GenderCategory genderCategory = (GenderCategory)gender;
                    Console.Write($"You selected category: " + genderCategory.ToString() + "\n");

                    Console.Write("3. Size:");
                    string sizeString          = Console.ReadLine();
                    int    size                = ValidationInput(sizeString);
                    int    sizeAfterValidation = ValidationSizeByGender(size, genderCategory);

                    Console.Write("4. Color:");
                    string color = Console.ReadLine();

                    Console.Write("5. Material:");
                    string material = Console.ReadLine();

                    Socks socks = new Socks(countSock, brandOfSocks, genderCategory, sizeAfterValidation, color, material);

                    ListOfSocks.addSocks(socks);

                    Console.WriteLine(socks.ToString());

                    countSock += 1;
                    break;
                }

                case "2":
                {
                    Console.Clear();

                    Console.WriteLine($"The list of all products:");
                    foreach (var item in ListOfSocks.listOfSocks)
                    {
                        Console.WriteLine(item.ToString());
                    }
                    break;
                }

                case "3":
                {
                    Console.WriteLine($"Enter the product number, for more details:");

                    numbOfProduct      = Console.ReadLine();
                    numbOfProductValid = ValidationInput(numbOfProduct);

                    for (int i = 0; i < ListOfSocks.listOfSocks.Count; i++)
                    {
                        if (ListOfSocks.listOfSocks[i].CountSock.Equals(numbOfProductValid))
                        {
                            Console.WriteLine(ListOfSocks.listOfSocks[i].ToString());
                        }
                    }
                    break;
                }

                case "4":
                {
                    Console.WriteLine($"\nEnter the product number to remove it from this list:");

                    foreach (var item in ListOfSocks.listOfSocks)
                    {
                        Console.WriteLine(item.ToString());
                    }

                    numbOfProduct      = Console.ReadLine();
                    numbOfProductValid = ValidationInput(numbOfProduct);

                    for (int i = 0; i < ListOfSocks.listOfSocks.Count; i++)
                    {
                        if (ListOfSocks.listOfSocks[i].CountSock.Equals(numbOfProductValid))
                        {
                            ListOfSocks.listOfSocks.RemoveAt(i);
                            i--;
                        }
                    }

                    foreach (var item in ListOfSocks.listOfSocks)
                    {
                        Console.WriteLine(item.ToString());
                    }

                    break;
                }

                case "5":
                {
                    return;
                }
                }

                Console.WriteLine("Do you want return to menu? - press \"y\"");
                selectKey = Console.ReadLine();
            }while (selectKey.Equals("y"));



            Console.ReadKey();
        }
Ejemplo n.º 10
0
 public void SetValue(int ST, int SCm, int SCs, int PT, int PCm, int PCs, int KT, int KCm, int KCs)
 {
     Shirt.SetVal(ST, SCm, SCs);
     Pants.SetVal(PT, PCm, PCs);
     Socks.SetVal(KT, KCm, KCs);
 }
Ejemplo n.º 11
0
        public string ToJsString()
        {
            string SendStr = "";

            SendStr = SendStr.AddArrayKV3("Shirt", Shirt.ToJsString(), "Pants", Pants.ToJsString(), "Socks", Socks.ToJsString(), false);
            SendStr = SendStr.AddParen();
            return(SendStr);
        }