Ejemplo n.º 1
0
        public void TestBChoosingLineWithFewestItemsLeftForLastPerson()
        {
            var c1 = new CashierTrainee(1);

            c1.EnqueueCustomer(new CustomerA(1, 10));
            c1.EnqueueCustomer(new CustomerB(2, 100));
            c1.EnqueueCustomer(new CustomerA(3, 8));

            var c2 = new Cashier(2);

            c2.EnqueueCustomer(new CustomerB(2, 10));
            c2.EnqueueCustomer(new CustomerB(2, 15));

            var c3 = new Cashier(3);

            c3.EnqueueCustomer(new CustomerA(1, 18));

            var cashiers = new HashSet <ICashier> {
                c1, c2, c3
            };

            var c             = new CustomerB(4, 999);
            var chosenCashier = c.ChooseCashier(cashiers);

            Assert.AreEqual(c1, chosenCashier);
        }
Ejemplo n.º 2
0
        public static Customer CreateCustomer(string customerLine)
        {
            if (string.IsNullOrWhiteSpace(customerLine))
            {
                return(null);
            }
            string[] tokens = customerLine.Split(SplitChars);
            if (tokens.Length < 3)
            {
                return(null);
            }
            int arrivalTime;

            if (!int.TryParse(tokens[1], out arrivalTime))
            {
                return(null);
            }
            int cartCount;

            if (!int.TryParse(tokens[2], out cartCount))
            {
                return(null);
            }

            Customer customer;

            if (tokens[0] == "A")
            {
                customer = new CustomerA(arrivalTime, cartCount);
            }
            else if (tokens[0] == "B")
            {
                customer = new CustomerB(arrivalTime, cartCount);
            }
            else
            {
                return(null);
            }

            return(customer);
        }
Ejemplo n.º 3
0
        public void TestBChoosingEmptyLine()
        {
            var c1 = new Cashier(1);

            c1.EnqueueCustomer(new CustomerA(0, 10));

            var c2 = new Cashier(2);

            c2.EnqueueCustomer(new CustomerB(0, 2));

            var t = new CashierTrainee(3);

            var cashiers = new HashSet <ICashier> {
                c1, c2, t
            };

            var b             = new CustomerB(1, 10);
            var chosenCashier = b.ChooseCashier(cashiers);

            ;
            Assert.AreEqual(t, chosenCashier);
        }
Ejemplo n.º 4
0
        public static Customer CreateCustomer(string customerLine)
        {
            if (string.IsNullOrWhiteSpace(customerLine)) return null;
            string[] tokens = customerLine.Split(SplitChars);
            if (tokens.Length < 3) return null;
            int arrivalTime;
            if (!int.TryParse(tokens[1], out arrivalTime)) return null;
            int cartCount;
            if (!int.TryParse(tokens[2], out cartCount)) return null;

            Customer customer;
            if (tokens[0] == "A")
            {
                customer = new CustomerA(arrivalTime, cartCount);
            }
            else if (tokens[0] == "B")
            {
                customer = new CustomerB(arrivalTime, cartCount);
            }
            else return null;

            return customer;
        }
Ejemplo n.º 5
0
 protected void gridMain_ItemCommand(object sender, GridCommandEventArgs e)
 {
     if (e.CommandName == "invPrint")
     {
         GridDataItem        item          = (GridDataItem)e.Item;
         int                 orderID       = (int)((GridDataItem)e.Item).GetDataKeyValue("ID");
         OrdersController    oCont         = new OrdersController();
         OrderB              curOrder      = oCont.GetOrder(orderID);
         TasksController     lCont         = new TasksController();
         List <TaskB>        tasksForOrder = lCont.GetTasksForOrder(orderID);
         CustomersController cCont         = new CustomersController();
         CustomerB           curCust       = cCont.GetCustomer(curOrder.Customer1.ID);
         try {
             DocumentReplacemetsController cont = new DocumentReplacemetsController();
             List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
             reps = cont.GetDocumentReplacemets(sqlUniqueName);
             DocumentReplacemetB curRep;
             string                imgFolderPath = Server.MapPath(fileUploadFolder);
             RadFlowDocument       curDoc        = LoadTemplateDocument(docTemplate);
             RadFlowDocumentEditor editor        = new RadFlowDocumentEditor(curDoc);
             Run       currRun;
             Paragraph currPar;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             currRun = editor.InsertText("ΑΘΗΝΑ " + DateTime.Now.ToString("dd/MM/yyyy"));
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             string regNo = curOrder.RegNo == null ? "" : curOrder.RegNo;
             currRun = editor.InsertText("ΑΡΙΘ. ΠΡΩΤ. " + regNo);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("ΟΡΓAΝΙΣΜΟΣ ΤΗΛΕΠΙΚΟΙΝΩΝΙΩΝ ΤΗΣ ΕΛΛΑΔΟΣ ΑΕ");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("GENTRANS ATHENS");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table infoTable = editor.InsertTable(3, 2);
             infoTable.Borders            = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = infoTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("Πληροφορίες:");
             currPar                      = infoTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Πληροφορίες").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = infoTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Τηλέφωνο:");
             currPar = infoTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Τηλέφωνο").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = infoTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = infoTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "FAX").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("ΘΕΜΑ:	ΠΡΟΣΩΡΙΝΕΣ ΤΗΛΕΦΩΝΙΚΕΣ ΣΥΝΔΕΣΕΙΣ");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table toTable = editor.InsertTable(3, 2);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = toTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Αιτηθείσα χώρα:");
             currPar = toTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curC = curCust.Country.NameGR == null ? "" : toUpperGR(curCust.Country.NameGR);
             currRun = currPar.Inlines.AddRun(curC);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = toTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Χώρος διεξαγωγής:");
             currPar = toTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curP = curOrder.Event.Place.NameGR == null ? "" : toUpperGR(curOrder.Event.Place.NameGR);
             currRun = currPar.Inlines.AddRun(curP);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = toTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Κάλυψη γεγονότος:");
             currPar = toTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curE = curOrder.Event.NameGR == null ? "" : toUpperGR(curOrder.Event.NameGR);
             currRun = currPar.Inlines.AddRun(curE);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Justified;
             var    distinctTasksLT = tasksForOrder.Select(m => new { m.LineTypeID, m.Internet, m.MSN }).Distinct().ToList();
             string concatString    = "";
             int    distinctItems   = 0;
             foreach (var dItem in distinctTasksLT)
             {
                 if (distinctItems > 0)
                 {
                     concatString += ", ";
                 }
                 TaskB demoTask  = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).FirstOrDefault();
                 int   itemCount = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).Count();
                 concatString += itemCount.ToString() + " " + demoTask.LineType.Name;
                 if (demoTask.Internet == true && demoTask.MSN == true)
                 {
                     concatString += " με ασύρματο ρούτερ και με MSN";
                 }
                 else if (demoTask.Internet == true)
                 {
                     concatString += " με ασύρματο ρούτερ";
                 }
                 else if (demoTask.MSN == true)
                 {
                     concatString += " με MSN";
                 }
                 distinctItems++;
             }
             currRun = editor.InsertText("Παρακαλούμε για την παροχή των εξής Προσωρινών Τηλεφωνικών Συνδέσεων για λογαριασμό του πιο κάτω πελάτη στη αντίστοιχη θέση: " + concatString + ".");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             int tRows = tasksForOrder.Count + 1;
             Telerik.Windows.Documents.Flow.Model.Table contentTable = editor.InsertTable(tRows, 5);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = contentTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currRun         = currPar.Inlines.AddRun("Πελάτης Εξωτερικού:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Από");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[2].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Έως:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[3].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Θέση:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[4].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Σύνδεση:");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             int curRow = 1;
             foreach (TaskB curTask in tasksForOrder)
             {
                 currPar = contentTable.Rows[curRow].Cells[0].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curCust.NameGR);
                 currPar = contentTable.Rows[curRow].Cells[1].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeStartOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[2].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeEndOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[3].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.RequestedPosition.NameGR);
                 currPar = contentTable.Rows[curRow].Cells[4].Blocks.AddParagraph();
                 string LineType2Print = curTask.LineType.Name;
                 if (curTask.Internet == true)
                 {
                     LineType2Print += " + WIFI ROUTER";
                 }
                 currRun = currPar.Inlines.AddRun(LineType2Print);
                 curRow++;
             }
             var distinctTasksC = tasksForOrder.Select(m => new { m.Comments }).Distinct().ToList();
             if (distinctTasksC.Count > 0)
             {
                 currPar = insertParagraph(editor);
                 currPar = insertParagraph(editor);
                 currRun = editor.InsertText("ΣΗΜΕΙΩΣΕΙΣ ΠΕΛΑΤΗ:");
                 currRun.Properties.FontWeight.LocalValue      = FontWeights.Bold;
                 currRun.Properties.ForegroundColor.LocalValue = new ThemableColor(System.Windows.Media.Color.FromRgb(255, 0, 0));
                 foreach (var dItem in distinctTasksC)
                 {
                     if (!string.IsNullOrEmpty(dItem.Comments))
                     {
                         TaskB demoTask = tasksForOrder.Where(k => k.Comments == dItem.Comments).FirstOrDefault();
                         currPar = insertParagraph(editor);
                         currPar.Indentation.LeftIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(1);
                         currRun = editor.InsertText(demoTask.LineType.Name + "  -  " + demoTask.Comments);
                         currRun.Properties.FontWeight.LocalValue      = FontWeights.Bold;
                         currRun.Properties.ForegroundColor.LocalValue = new ThemableColor(System.Windows.Media.Color.FromRgb(255, 0, 0));
                     }
                 }
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Εγκατάσταση στο  OB VAN/TV COMPOUND");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Ανταποκριτής: Mr. Leo Giovanni  +393357415070");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Παρακαλούμε να μας γνωρίσετε τον αριθμό κλήσης που θα διαθέσετε.");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("H χρέωση θα γίνει από το Τμήμα Ρ/Τ Μεταδόσεων.");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.Indentation.LeftIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(3);
             //currPar.TextAlignment = Alignment.Center;
             curRep = reps.Where(o => o.Title == "Προϊστάμενος").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText(curRep.Text);
             }
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.Indentation.LeftIndent      = Telerik.Windows.Documents.Media.Unit.InchToDip(3);
             currPar.Indentation.HangingIndent   = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.Indentation.RightIndent     = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.Indentation.FirstLineIndent = Telerik.Windows.Documents.Media.Unit.InchToDip(0);
             currPar.TextAlignment = Alignment.Left;
             curRep = reps.Where(o => o.Title == "Τίτλος").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText(curRep.Text);
             }
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             curDoc.UpdateFields();
             exportDOCX(curDoc);
         }
         catch (Exception ex) { }
     }
 }
Ejemplo n.º 6
0
 protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e)
 {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     {
         countryID = -1;
         Session.Remove("CountryID");
         customerTypeID = -1;
         Session.Remove("CustomerTypeID");
         languageID = -1;
         Session.Remove("LanguageID");
         userID = -1;
         Session.Remove("UserID");
         GridEditableItem item             = e.Item as GridEditableItem;
         RadDropDownList  ddlCountries     = item.FindControl("ddlCountries") as RadDropDownList;
         RadDropDownList  ddlCustomerTypes = item.FindControl("ddlCustomerTypes") as RadDropDownList;
         RadDropDownList  ddlLanguages     = item.FindControl("ddlLanguages") as RadDropDownList;
         RadDropDownList  ddlUsers         = item.FindControl("ddlUsers") as RadDropDownList;
         try {
             CustomerB           currCustomer  = e.Item.DataItem as CustomerB;
             CountriesController countriesCont = new CountriesController();
             ddlCountries.DataSource     = countriesCont.GetCountries();
             ddlCountries.DataTextField  = "NameGR";
             ddlCountries.DataValueField = "ID";
             ddlCountries.DataBind();
             if (currCustomer != null)
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue(currCustomer.CountryID.ToString()).Index;
                 Session["CountryID"]       = currCustomer.CountryID;
             }
             else
             {
                 ddlCountries.SelectedIndex = ddlCountries.FindItemByValue("1").Index;;
                 Session["CountryID"]       = ddlCountries.SelectedItem.Value;
             }
             CustomerTypesController customerTypesCont = new CustomerTypesController();
             ddlCustomerTypes.DataSource     = customerTypesCont.GetCustomerTypes();
             ddlCustomerTypes.DataTextField  = "NameGR";
             ddlCustomerTypes.DataValueField = "ID";
             ddlCustomerTypes.DataBind();
             if (currCustomer != null)
             {
                 ddlCustomerTypes.SelectedIndex = ddlCustomerTypes.FindItemByValue(currCustomer.CustomerTypeID.ToString()).Index;
                 Session["CustomerTypeID"]      = currCustomer.CustomerTypeID;
             }
             else
             {
                 ddlCustomerTypes.SelectedIndex = 0;
                 Session["CustomerTypeID"]      = ddlCustomerTypes.SelectedItem.Value;
             }
             LanguagesController languagesCont = new LanguagesController();
             ddlLanguages.DataSource     = languagesCont.GetLanguages();
             ddlLanguages.DataTextField  = "Name";
             ddlLanguages.DataValueField = "ID";
             ddlLanguages.DataBind();
             if (currCustomer != null)
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue(currCustomer.LanguageID.ToString()).Index;
                 Session["LanguageID"]      = currCustomer.LanguageID;
             }
             else
             {
                 ddlLanguages.SelectedIndex = ddlLanguages.FindItemByValue("1").Index;
                 Session["LanguageID"]      = ddlLanguages.SelectedItem.Value;
             }
             UsersController usersCont = new UsersController();
             ddlUsers.DataSource     = usersCont.GetUsers();
             ddlUsers.DataTextField  = "NameGR";
             ddlUsers.DataValueField = "ID";
             ddlUsers.DataBind();
             if (currCustomer != null)
             {
                 ddlUsers.SelectedIndex = ddlUsers.FindItemByValue(currCustomer.UserID.ToString()).Index;
                 Session["UserID"]      = currCustomer.UserID;
             }
             else
             {
                 ddlUsers.SelectedIndex = 0;
                 Session["UserID"]      = ddlUsers.SelectedItem.Value;
             }
         }
         catch (Exception) { }
     }
     if (e.Item is GridFilteringItem)
     {
         GridFilteringItem filterItem = (GridFilteringItem)e.Item;
         RadDropDownList   cflist     = (RadDropDownList)filterItem.FindControl("ddlCountryFilter");
         RadDropDownList   ctflist    = (RadDropDownList)filterItem.FindControl("ddlCustomerTypeFilter");
         RadDropDownList   lflist     = (RadDropDownList)filterItem.FindControl("ddlLanguageFilter");
         RadDropDownList   uflist     = (RadDropDownList)filterItem.FindControl("ddlUserFilter");
         try {
             CountriesController ccont = new CountriesController();
             cflist.DataSource     = ccont.GetCountries();
             cflist.DataTextField  = "NameGR";
             cflist.DataValueField = "ID";
             cflist.DataBind();
             cflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             CustomerTypesController ctcont = new CustomerTypesController();
             ctflist.DataSource     = ctcont.GetCustomerTypes();
             ctflist.DataTextField  = "NameGR";
             ctflist.DataValueField = "ID";
             ctflist.DataBind();
             ctflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             LanguagesController lcont = new LanguagesController();
             lflist.DataSource     = lcont.GetLanguages();
             lflist.DataTextField  = "Name";
             lflist.DataValueField = "ID";
             lflist.DataBind();
             lflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
             UsersController ucont = new UsersController();
             uflist.DataSource     = ucont.GetUsers();
             uflist.DataTextField  = "NameGR";
             uflist.DataValueField = "ID";
             uflist.DataBind();
             uflist.Items.Insert(0, new DropDownListItem("Κανένα Φίλτρο", "0"));
         }
         catch (Exception) { }
     }
 }
Ejemplo n.º 7
0
 protected void gridMain_ItemCommand(object sender, GridCommandEventArgs e)
 {
     if (e.CommandName == "invPrint")
     {
         GridDataItem        item          = (GridDataItem)e.Item;
         int                 orderID       = (int)((GridDataItem)e.Item).GetDataKeyValue("ID");
         OrdersController    oCont         = new OrdersController();
         OrderB              curOrder      = oCont.GetOrder(orderID);
         TasksController     lCont         = new TasksController();
         List <TaskB>        tasksForOrder = lCont.GetTasksForOrder(orderID);
         CustomersController cCont         = new CustomersController();
         CustomerB           curCust       = cCont.GetCustomer(curOrder.Customer1.ID);
         try {
             DocumentReplacemetsController cont = new DocumentReplacemetsController();
             List <DocumentReplacemetB>    reps = new List <DocumentReplacemetB>();
             reps = cont.GetDocumentReplacemets(sqlUniqueName);
             DocumentReplacemetB curRep;
             string                imgFolderPath = Server.MapPath(fileUploadFolder);
             RadFlowDocument       curDoc        = LoadTemplateDocument(docTemplate);
             RadFlowDocumentEditor editor        = new RadFlowDocumentEditor(curDoc);
             Run       currRun;
             Paragraph currPar;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             currRun = editor.InsertText("ATHENS " + DateTime.Now.ToString("dd/MM/yyyy"));
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Right;
             string regNo = curOrder.RegNo == null ? "" : curOrder.RegNo;
             currRun = editor.InsertText("REF. " + regNo);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table infoTable = editor.InsertTable(4, 2);
             infoTable.Borders            = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = infoTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("Information:");
             currPar                      = infoTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Πληροφορίες").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Phone:");
             currPar = infoTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Τηλέφωνο").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = infoTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "FAX").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = currPar.Inlines.AddRun(curRep.Text);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = infoTable.Rows[3].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Email:");
             currPar = infoTable.Rows[3].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             curRep = reps.Where(o => o.Title == "Email").FirstOrDefault();
             if (curRep != null)
             {
                 Run currRun2 = currPar.Inlines.AddRun();
                 editor.MoveToInlineEnd(currRun2);
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 editor.MoveToTableEnd(infoTable);
             }
             currPar = insertParagraph(editor);
             editor.MoveToParagraphStart(currPar);
             Telerik.Windows.Documents.Flow.Model.Table toTable = editor.InsertTable(3, 2);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = toTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("ATT.:");
             currPar = toTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.NameEN))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.NameEN);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = toTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("Phone:");
             currPar = toTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.Telephone1))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.Telephone1);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = toTable.Rows[2].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("FAX:");
             currPar = toTable.Rows[2].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             if (!string.IsNullOrEmpty(tasksForOrder[0].Customer.FAX1))
             {
                 currRun = currPar.Inlines.AddRun(tasksForOrder[0].Customer.FAX1);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("SUBJECT:  TEMPORARΥ TELEPHONE LINES");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currPar.TextAlignment = Alignment.Justified;
             currRun = editor.InsertText("You are kindly requested to provide " + tasksForOrder.Count.ToString() + " temporary telephone lines.");
             currPar = insertParagraph(editor);
             Telerik.Windows.Documents.Flow.Model.Table eventTable = editor.InsertTable(2, 2);
             eventTable.Borders           = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar                      = eventTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun                      = currPar.Inlines.AddRun("in:");
             currPar                      = eventTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curP = curOrder.Event.Place.NameEN == null ? "" : curOrder.Event.Place.NameEN;
             currRun = currPar.Inlines.AddRun(curP);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = eventTable.Rows[1].Cells[0].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             currRun = currPar.Inlines.AddRun("event:");
             currPar = eventTable.Rows[1].Cells[1].Blocks.AddParagraph();
             currPar.Spacing.SpacingAfter = 0;
             string curE = curOrder.Event.NameEN == null ? "" : curOrder.Event.NameEN;
             currRun = currPar.Inlines.AddRun(curE);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             int tRows = tasksForOrder.Count + 1;
             Telerik.Windows.Documents.Flow.Model.Table contentTable = editor.InsertTable(tRows, 5);
             toTable.Borders = new TableBorders(new Border(Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None));
             currPar         = contentTable.Rows[0].Cells[0].Blocks.AddParagraph();
             currRun         = currPar.Inlines.AddRun("Customer Name");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[1].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("From");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[2].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("To");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[3].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("Place of Instal.");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = contentTable.Rows[0].Cells[4].Blocks.AddParagraph();
             currRun = currPar.Inlines.AddRun("");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             int curRow = 1;
             foreach (TaskB curTask in tasksForOrder)
             {
                 currPar = contentTable.Rows[curRow].Cells[0].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curCust.NameEN);
                 currPar = contentTable.Rows[curRow].Cells[1].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeStartOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[2].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.DateTimeEndOrder.ToString());
                 currPar = contentTable.Rows[curRow].Cells[3].Blocks.AddParagraph();
                 currRun = currPar.Inlines.AddRun(curTask.RequestedPosition.NameEN);
                 currPar = contentTable.Rows[curRow].Cells[4].Blocks.AddParagraph();
                 string LineType2Print = curTask.LineType.Name;
                 if (curTask.Internet == true)
                 {
                     LineType2Print += " + WIFI ROUTER";
                 }
                 currRun = currPar.Inlines.AddRun(LineType2Print);
                 curRow++;
             }
             var    distinctTasksLT = tasksForOrder.Select(m => new { m.LineTypeID, m.Internet, m.MSN }).Distinct().ToList();
             string concatString    = "";
             int    distinctItems   = 0;
             foreach (var dItem in distinctTasksLT)
             {
                 if (distinctItems > 0 && distinctItems < distinctTasksLT.Count - 1)
                 {
                     concatString += ", ";
                 }
                 else if (distinctItems > 0 && distinctItems == distinctTasksLT.Count - 1)
                 {
                     concatString += " & ";
                 }
                 TaskB demoTask  = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).FirstOrDefault();
                 int   itemCount = tasksForOrder.Where(k => k.LineTypeID == dItem.LineTypeID && k.Internet == dItem.Internet && k.MSN == dItem.MSN).Count();
                 concatString += itemCount.ToString() + " " + demoTask.LineType.Name;
                 if (demoTask.Internet == true && demoTask.MSN == true)
                 {
                     concatString += " with router and MSN";
                 }
                 else if (demoTask.Internet == true)
                 {
                     concatString += " with router";
                 }
                 else if (demoTask.MSN == true)
                 {
                     concatString += " with MSN";
                 }
                 distinctItems++;
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Please provide " + concatString);
             currRun.Properties.FontSize.LocalValue   = Telerik.Windows.Documents.Media.Unit.PointToDip(9);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Contact Person: " + reps.Where(o => o.Title == "Contact Person").FirstOrDefault().Text + "  Mob:" + reps.Where(o => o.Title == "Κινητό C.P.").FirstOrDefault().Text);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Please advise on allocated numbers A.S.A.P. to the e-mail address: ");
             editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("HELLENIC TELECOMMUNICATIONS ORGANIZATION SA (OTE GROUP OF COMPANIES)");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("VAT Number: ");
             currRun = editor.InsertText("EL 094019245");
             currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Responsible for the payments is our company:");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("HELLENIC TELECOMMUNICATIONS ORGANIZATION SA (OTE GROUP OF COMPANIES) via its Billing department bellow");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Delivery invoice address for the original invoice (Post mail):");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("OTE INTERNATIONAL SOLUTION SA (OTEGLOBE)");
             curRep  = reps.Where(o => o.Title == "OTEGlobe Διεύθυνση 1").FirstOrDefault();
             currPar = insertParagraph(editor);
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 //currRun = editor.InsertText(curRep.Text);
                 currRun = editor.InsertLine(curRep.Text);
             }
             curRep = reps.Where(o => o.Title == "OTEGlobe Διεύθυνση 2").FirstOrDefault();
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 //currRun = editor.InsertText(curRep.Text);
                 currRun = editor.InsertLine(curRep.Text);
             }
             curRep = reps.Where(o => o.Title == "OTEGlobe Site").FirstOrDefault();
             if (curRep != null)
             {
                 //currPar = insertParagraph(editor);
                 editor.InsertHyperlink(curRep.Text, "http://" + curRep.Text, false);
             }
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             string rep = "";
             curRep = reps.Where(o => o.Title == "Person In Charge").FirstOrDefault();
             if (curRep != null)
             {
                 rep += curRep.Text;
             }
             curRep = reps.Where(o => o.Title == "Person In Charge (Phone)").FirstOrDefault();
             if (curRep != null)
             {
                 rep += curRep.Text;
             }
             if (!string.IsNullOrEmpty(rep))
             {
                 currRun = editor.InsertText("(Person in charge " + rep + ")");
                 currPar = insertParagraph(editor);
             }
             curRep = reps.Where(o => o.Title == "Person In Charge (Email)").FirstOrDefault();
             if (curRep != null)
             {
                 currRun = editor.InsertText("Email: ");
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 currPar = insertParagraph(editor);
             }
             currRun = editor.InsertText("Email: ");
             editor.InsertHyperlink("*****@*****.**", "mailto:[email protected]", false);
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             curRep  = reps.Where(o => o.Title == "Email").FirstOrDefault();
             if (curRep != null)
             {
                 currPar = insertParagraph(editor);
                 currRun = editor.InsertText("You could notify a copy of the invoice (as a pdf) to this e-mail: ");
                 editor.InsertHyperlink(curRep.Text, "mailto:" + curRep.Text, false);
                 currRun.Properties.FontWeight.LocalValue = FontWeights.Bold;
             }
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("The charges will be settled via Bank transfer.");
             currPar = insertParagraph(editor);
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("Best regards,");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("SAOUSOPOULOU ANNA");
             currPar = insertParagraph(editor);
             currRun = editor.InsertText("MANAGER OF GENTRANS, ATHENS");
             curDoc.UpdateFields();
             exportDOCX(curDoc);
         }
         catch (Exception ex) { }
     }
 }