コード例 #1
0
ファイル: Program.cs プロジェクト: nilmarpublio/jawiweb
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            int x = 0;//pending count
            int y = 0;//success generated count

            List<nisanOrder> orders = new List<nisanOrder>();
            NisanReader reader = new NisanReader("nisan.xml");
            reader.Read(out orders);
            //System.Diagnostics.Debug.WriteLine("Total order: " + orders.Count);
            //System.Diagnostics.Debug.WriteLine("Total purchase: " + purchases.Count);

            //get undelivered order
            int length = ConfigurationManager.AppSettings.Keys.Count;
            for (int i = 0; i < length; i++)
            {
                //hack: refactor by get all item values and query with linq
                string item = ConfigurationManager.AppSettings.Keys[i].ToString();
                string[] lookupFiles = ConfigurationManager.AppSettings.GetValues(i);
                if (lookupFiles.Length < 1) continue;
                List<nisanOrder> undelivered = orders
                    .Where(f => f.name.Length > 0 && f.delivered.Length == 0 && f.item == item)
                    .ToList<nisanOrder>();
                if (undelivered.Count > 0)
                {
                    x += undelivered.Count;
                    Console.WriteLine();
                    Console.WriteLine(string.Format("There are {0}:{1} pending", item, undelivered.Count));
                }

                foreach (nisanOrder order in undelivered)
                {
                    Console.Write("Writing " + order.name.ToLower() + ".svg...");
                    // validation
                    if (order.death.CompareTo(DateTime.Now.ToString("yyyy-MM-dd")) > 0) Console.Write(" Are you cursing people?");
                    if (order.age != null && order.age.Length > 0)
                    {
                        if (Convert.ToInt32(order.age) > 120) Console.Write(" Are you kidding?");
                    }
                    SvgWriter writer = new SvgWriter(order, lookupFiles[0]);
                    if (writer.Write())
                    {
                        Console.WriteLine(" done");
                        y++;
                    }
                    else
                        Console.WriteLine(" exist or fail");
                }
            }
            Console.WriteLine("Complete");
            Console.WriteLine(string.Format("{0} pending. {1} files generated.", x, y));

            //wait for user input
            Console.Read();
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: nilmarpublio/jawiweb
        /// <summary>
        /// Write to temporarily output file then merge into existing raw svg file.
        /// </summary>
        private void Save()
        {
            SvgWriter writer = new SvgWriter("output.svg", this.workSpace);
            writer.Write(this.wordManager);
            this.statusText.Text = "Export svg done";

            SimpleDialog dialog = new SimpleDialog();
            dialog.ShowDialog();

            string fileName = dialog.output.Text.Trim() + ".svg";
            SvgWriter writer2 = new SvgWriter(fileName);
            bool success = writer2.Merge("output.svg");
            string message = success ? "Merge success" : "Merge fail. Please try again";
            this.statusText.Text = message;
            if (success)
            {
                if (MessageBox.Show(message) == MessageBoxResult.OK)
                    clear_Click(clear, new RoutedEventArgs());
            }
            else
                MessageBox.Show(message);
        }
コード例 #3
0
ファイル: nisan.cs プロジェクト: nilmarpublio/jawiweb
        public void GenerateSvg(nisanOrder order)
        {
            // check file exist if not only write
            string file = "Output" + System.IO.Path.DirectorySeparatorChar + order.name + ".svg";
            if (System.IO.File.Exists(file))
            {
                // Inkscape installed path not same at different computer.
                string filePath = @"C:\Program Files\Inkscape\inkscape.exe";
                if (System.IO.File.Exists(filePath))
                    filePath = "\"" + filePath + "\"";
                else
                {
                    filePath = filePath.Replace("Program Files", "Program Files (x86)");
                    if (System.IO.File.Exists(filePath))
                        filePath = "\"" + filePath + "\"";
                    else
                        return;
                }

                Process process = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo();
                //startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo.FileName = filePath;
                startInfo.Arguments = "\"" + file + "\"";
                process.StartInfo = startInfo;
                process.Start();
                System.Diagnostics.Debug.WriteLine(filePath + " " + startInfo.Arguments);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Generating svg for " + order.name);
                string template = GetSvgTemplate(order.item);
                HLGranite.Jawi.nisanOrder jOrder = CloneOrder(order);
                SvgWriter writer = new SvgWriter(jOrder, template);
                writer.Write();
            }
        }