예제 #1
0
        public void User_should_be_able_to_delete_an_widget_from_page()
        {
            var facade = default(Facade);
            var profile = default(UserProfile);
            var wiId = default(int);
            var userSetup = default(UserSetup);
            
            "Given a new user".Context(() =>
            {
                profile = MembershipHelper.CreateNewAnonUser();
                facade = new Facade(new AppContext(string.Empty, profile.UserName));

                userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
            });

            "When user adds a new page".Do(() =>
            {
                var widgets = facade.GetWidgetInstancesInZoneWithWidget(
                    facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);

                wiId = widgets.First().Id;
                facade.DeleteWidgetInstance(wiId);
            });

            "It should add a new blank page as current page".Assert(() =>
            {
                var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);

                var widgets = facade.GetWidgetInstancesInZoneWithWidget(
                    facade.GetColumnsInTab(userSetup.CurrentTab.ID).First().WidgetZone.ID);

                Assert.Equal(0, widgets.Where(wi => wi.Id == wiId).Count());
            });
        }
예제 #2
0
        static void Main()
        {
            Facade facade = new Facade();

            facade.MethodA();
            facade.MethodB();
        }
예제 #3
0
        public void User_should_be_able_change_page_title()
        {
            var facade = default(Facade);
            var profile = default(UserProfile);
            var userSetup = default(UserSetup);
            var newName = Guid.NewGuid().ToString();
            "Given a new user".Context(() =>
            {
                profile = MembershipHelper.CreateNewAnonUser();
                facade = new Facade(new AppContext(string.Empty, profile.UserName));

                userSetup = facade.FirstVisitHomeTab(profile.UserName, string.Empty, true, false);
            });

            "When user changes title of current page".Do(() =>
            {
                facade.ChangeTabName(newName);
            });

            "It should persist and on next visit the new page title should reflect".Assert(() =>
            {
                var userTabSetup = facade.RepeatVisitHomeTab(profile.UserName, string.Empty, true, false);
                Assert.Equal(newName, userTabSetup.CurrentTab.Title);
            });
        }
예제 #4
0
        public void Admin_user_can_add_new_widget_and_assign_roles_to_widget()
        {
            var facade = default(Facade);
            var newWidget = default(Widget);

            "Given an admin user".Context(() =>
                {
                    facade = new Facade(new AppContext(string.Empty, ADMIN_USER));
                });

            "When user adds a new widget and assigns roles to it".Do(() =>
                {
                    newWidget = facade.AddWidget("Test Widget", 
                        "omaralzabir.com", string.Empty, "Test widget", 
                        string.Empty, false, false, 0, "guest", 
                        (int)Enumerations.WidgetType.PersonalTab);
                    facade.AssignWidgetRoles(newWidget.ID, new string[] { GUEST_ROLE });
                });

            "It should be available to the users of that role".Assert(() =>
                {
                    var newUserProfile = MembershipHelper.CreateNewAnonUser();
                    facade.SetUserRoles(newUserProfile.UserName, new string[] { GUEST_ROLE });
                    var widgetsAvailable = facade.GetWidgetList(newUserProfile.UserName, Enumerations.WidgetType.PersonalTab);
                    Assert.Equal(1, widgetsAvailable.Where(w => w.ID == newWidget.ID).Count());
                });
        }
        public ActionResult AddToShoppingCart(int movieId, int amount)
        {
            MakeShoppingCart();
            HttpCookie myCookie = Request.Cookies.Get(CART_NAME);

            ShoppingCart cart = JsonConvert.DeserializeObject<ShoppingCart>(myCookie.Value);

            if (lookInCart(cart,movieId))
            {
                var orderline = cart.Orderline.First(c => c.Movie.Id == movieId);
                orderline.Amount += amount;
            }
            else
            {
                var mov = new Facade().GetMovieGateway().Get(movieId);
                cart.Orderline.Add(new Orderline() { Amount = amount, Movie = mov });
            }

            myCookie.Value = JsonConvert.SerializeObject(cart);

            myCookie.Expires = DateTime.Now.AddDays(PERSISTANCE_TIME); // this will make the cart persist longer.

            this.HttpContext.Response.Cookies.Set(myCookie);
            return RedirectToAction("Index","Home");
            //this should allow you to return nothing, I imagine that this could be useful
            //for JavaScript
            // return null
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Employee uIEmployee = new Employee();

            uIEmployee.EmployeeFirstName = this.FirstNameTextBox.Text;
            uIEmployee.EmployeeLastName = this.LastNameTextBox.Text;
            uIEmployee.Employeetype = this.EmployeeTypeTextBox.Text;
            uIEmployee.EmployeePhone = this.PhoneTextBox.Text;

            object Class = uIEmployee;
            int ActionType = 1;

            //Facade newFacade = new Facade(uIEmployee, ActionType);
            Facade newFacade = new Facade(Class, ActionType);
            newFacade.ProcessRequest();

            if (Page.IsValid)
            {
                SuccessLabel.Text = "You have successfully registered on the FFR's website";
            }
            else
            {
                SuccessLabel.Text = "Failed to registers on FFR's website, please verify you have entered all necessary information.";
            }
            //deploy project
            //CustomerManager cm = new CustomerManager();
            //cm.Insert(uICustomer);
            /*XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.Indent = true;

            string xmlFileName = "CustomerTest.xml";
            //XmlWriter xmlWriter = XmlWriter.Create("@C:, xmlSetting);

            XmlWriter xmlWriter = XmlWriter..Create(xmlFileName, xmlSetting);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteComment("This Xml is generated when a customer registers on FFR's site");
            xmlWriter.WriteStartElement("Customer");
            xmlWriter.WriteElementString("ObjectType", "Customer");
            xmlWriter.WriteElementString("ActionType", "1");
            xmlWriter.WriteElementString("FirstName", this.FirstNameTextBox.Text);
            xmlWriter.WriteElementString("LastName", this.LastNameTextBox.Text);
            xmlWriter.WriteElementString("City", this.CityTextBox.Text);
            xmlWriter.WriteElementString("State", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Street", this.StreetTextBox.Text);
            xmlWriter.WriteElementString("Zip", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Phone", this.PhoneTextBox.Text);
            xmlWriter.WriteElementString("Email", this.EmailTextBox.Text);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();

            xmlWriter.Flush();
            xmlWriter.Close();

            Facade newFacade = new Facade(xmlWriter, xmlFileName);
            newFacade.ProcessRequest();
            xmlWriter.Dispose();
            xmlFileName = "";*/
        }
예제 #7
0
        public void Movie_add_will_create_new_genre_test()
        {
            Facade facade = new Facade();
            Movie temp = new Movie() { Genres = new List<Genre>() { new Genre() {Name = "test" } }, Name = "test", Price = 120d, TrailerURL = "test" };
            temp = facade.GetMovieRepo().Add(temp);

            Assert.AreEqual(facade.GetMovieRepo().Get(temp.Id).Genres.FirstOrDefault().Name, "test");
        }
예제 #8
0
 private void LoadWidgets()
 {
     using (Facade facade = new Facade(AppContext.GetContext(Context)))
     {
         Widgets.DataSource = facade.GetAllWidgets();
         Widgets.DataBind();
     }
 }
예제 #9
0
 public HttpResponseMessage Update(Identity id, Facade.GroupPut group)
 {
     return ProcessPut(() =>
                        {
                            var instance = group.ToModel();
                            updateGroupCommand.Execute(instance);
                        });
 }
예제 #10
0
 static Facade()
 {
     Singleton = new Facade ();
     Singleton.Lies = new Dictionary<Facet, HashSet<Lie>> ();
     foreach (Facet f in Enum.GetValues(typeof(Facet)).Cast<Facet>()) {
         Singleton.Lies[f] = new HashSet<Lie> ();
     }
 }
예제 #11
0
        public void GetPdfFailsIdInvoiceIdIsNotValidInteger()
        {
            //Arrange
            var sut = new Facade{Session = SessionMock.Object};

            //Act
            sut.GetPdf("not an integer");
        }
예제 #12
0
    protected void SaveWidget_Clicked(object sender, EventArgs e)
    {
        try
        {
            var control = LoadControl(Field_Url.Value);
        }
        catch (Exception x)
        {
            Debug.WriteLine(x.ToString());
            Services.Get<ILogger>().LogException(x);
            Error.Text = x.Message;
            Error.Visible = true;
            return;
        }

        using (Facade facade = new Facade(AppContext.GetContext(Context)))
        {
            var widgetId = int.Parse(Field_ID.Value.Trim());
            if (widgetId == 0)
            {
                var newlyAddedWidget = facade.AddWidget(
                    Field_Name.Value,
                    Field_Url.Value,
                    Field_Icon.Value,
                    Field_Description.Value,
                    Field_DefaultState.Value,
                    Field_IsDefault.Checked,
                    Field_IsLocked.Checked,
                    int.Parse(Field_OrderNo.Value),
                    Field_RoleName.Value,
                    int.Parse(Field_WidgetType.Value));
                
                widgetId = newlyAddedWidget.ID;
                SetWidgetRoles(widgetId);   
                this.EditWidget(newlyAddedWidget);
            }
            else
            {
                facade.UpdateWidget(widgetId,
                    Field_Name.Value,
                    Field_Url.Value,
                    Field_Icon.Value,
                    Field_Description.Value,
                    Field_DefaultState.Value,
                    Field_IsDefault.Checked,
                    Field_IsLocked.Checked,
                    int.Parse(Field_OrderNo.Value),
                    Field_RoleName.Value,
                    int.Parse(Field_WidgetType.Value));

                SetWidgetRoles(widgetId);   
            }

            this.LoadWidgets();
            EditForm.Visible = false;
        }        
    }
예제 #13
0
 public Bookings Get(int id)
 {
     Bookings bookings = new Facade().GetBookingsRepository().Find(id);
     if (bookings == null)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     return bookings;
 }
예제 #14
0
 public HttpResponseMessage Create(Facade.GroupPost topic)
 {
     return  ProcessPost(() =>
                        {
                            var instance = topic.ToModel();
                            createGroupCommand.Execute(instance);
                            return ResourceLocation.OfGroup(instance.Id.Value);
                        });
 }
예제 #15
0
 public Facilities Get(int id)
 {
     Facilities facility = new Facade().GetFacilitiesRepository().Find(id);
     if (facility == null)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     return facility;
 }
예제 #16
0
 public HttpResponseMessage Create(Facade.SubscriptionPost subscription)
 {
     return ProcessPost(()  =>
                        {
                            var instance = subscription.ToModel();
                            createCommand.Execute(instance);
                            return ResourceLocation.OfSubscription(instance.Id.Value);
                        });
 }
예제 #17
0
  public static void Main(string[] args)
  {
    Facade f = new Facade();

    f.MethodA();
    f.MethodB();

    Console.Read();
  }
예제 #18
0
 public Apartment Get(int id)
 {
     Apartment apartment = new Facade().GetApartmentRepository().Find(id);
     if (apartment == null)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     return apartment;
 }
예제 #19
0
        public void Movie_get_by_genre_return_empty_on_no_movies_test()
        {
            Facade facade = new Facade();
            Genre genre = new Genre() { Name = "test" };
            genre = facade.GetGenreRepo().Add(genre);

            facade = new Facade();
            Assert.AreEqual(facade.GetMovieRepo().GetMovieByGenre(genre).ToList().Count, 0);
        }
예제 #20
0
 public User Get(int id)
 {
     User user = new Facade().GetUserReporitory().Find(id);
     if (user == null)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     return user;
 }
예제 #21
0
 public Prices Get(int id)
 {
     Prices prices = new Facade().GetPricesRepository().Find(id);
     if (prices == null)
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     return prices;
 }
예제 #22
0
        public void Genre_added_on_call_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);
            Context context = new Context();

            Assert.IsNotNull(context.Genres.FirstOrDefault(x=> x.Id == temp.Id));
            Assert.AreNotEqual(temp.Id, 0);
        }
        public void OrderMovie_get_works_test()
        {
            Facade facade = new Facade();
            OrderMovie om = new OrderMovie() { Movie = SetMovie(), Order = SetOrder() };

            om = facade.GetOrderMovieRepo().Add(om);

            facade = new Facade();
            Assert.AreEqual(facade.GetOrderMovieRepo().Get(om.Id).Movie.Name, "The Martian");
        }
예제 #24
0
        public void Movie_added_on_call_test()
        {
            Movie temp = new Movie() { Name = "test", Price = 120d, TrailerURL = "test" };
            Facade facade = new Facade();
            temp = facade.GetMovieRepo().Add(temp);
            Context context = new Context();

            Assert.IsNotNull(context.Movies.FirstOrDefault(x=>x.Id == temp.Id));
            Assert.AreNotEqual(temp.Id, 0);
        }
예제 #25
0
        public HttpResponseMessage Update(Facade.SubscriptionPut subscriptionPut)
        {
            return ProcessPut(() =>
            {
                var current = entityById.Get<Subscription>(subscriptionPut.Id.ToModel());

                current.Callback = subscriptionPut.Callback.ToModel();
                updateCommand.Execute(current);
            });
        }
예제 #26
0
        public void Genre_get_all_return_all_test()
        {
            Genre temp = new Genre() { Name = "test" };
            Facade facade = new Facade();
            temp = facade.GetGenreRepo().Add(temp);

            facade = new Facade();
            Assert.IsNotNull(facade.GetGenreRepo().GetAll());
            Assert.AreNotEqual(0, facade.GetGenreRepo().GetAll().ToList().Count);
        }
예제 #27
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Demo()
        {
            Facade facade = new Facade();

            facade.MethodA();
            facade.MethodB();

            // Wait for user
            Console.ReadKey();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            Customer uICustomer = new Customer();

            uICustomer.FirstName = this.FirstNameTextBox.Text;
            uICustomer.LastName = this.LastNameTextBox.Text;
            uICustomer.City = this.CityTextBox.Text;
            uICustomer.State = this.StateTextBox.Text;
            uICustomer.Street = this.StreetTextBox.Text;
            uICustomer.Zip = this.ZipTextBox.Text;
            uICustomer.Address = this.AddressTextBox.Text;
            uICustomer.Phone = this.PhoneTextBox.Text;
            uICustomer.Email = this.EmailTextBox.Text;

            //object Class = uICustomer;
            int ActionType = 1;

            Facade newFacade = new Facade(uICustomer, ActionType);
            //            Facade newFacade = new Facade(uICustomer, ActionType);
            newFacade.ProcessRequest();
            //deploy project
            //CustomerManager cm = new CustomerManager();
            //cm.Insert(uICustomer);
            /*XmlWriterSettings xmlSetting = new XmlWriterSettings();
            xmlSetting.Indent = true;

            string xmlFileName = "CustomerTest.xml";
            //XmlWriter xmlWriter = XmlWriter.Create("@C:, xmlSetting);

            XmlWriter xmlWriter = XmlWriter..Create(xmlFileName, xmlSetting);

            xmlWriter.WriteStartDocument();
            xmlWriter.WriteComment("This Xml is generated when a customer registers on FFR's site");
            xmlWriter.WriteStartElement("Customer");
            xmlWriter.WriteElementString("ObjectType", "Customer");
            xmlWriter.WriteElementString("ActionType", "1");
            xmlWriter.WriteElementString("FirstName", this.FirstNameTextBox.Text);
            xmlWriter.WriteElementString("LastName", this.LastNameTextBox.Text);
            xmlWriter.WriteElementString("City", this.CityTextBox.Text);
            xmlWriter.WriteElementString("State", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Street", this.StreetTextBox.Text);
            xmlWriter.WriteElementString("Zip", this.StateTextBox.Text);
            xmlWriter.WriteElementString("Phone", this.PhoneTextBox.Text);
            xmlWriter.WriteElementString("Email", this.EmailTextBox.Text);
            xmlWriter.WriteEndElement();
            xmlWriter.WriteEndDocument();

            xmlWriter.Flush();
            xmlWriter.Close();

            Facade newFacade = new Facade(xmlWriter, xmlFileName);
            newFacade.ProcessRequest();
            xmlWriter.Dispose();
            xmlFileName = "";*/
        }
예제 #29
0
 public Facade.Notes.IMetainfo CreateMetainfo(Facade.Notes.IAttachment attachment)
 {
     using (SheetContext ctx = new SheetContext())
     {
         Attachment dbAttachment = ctx.Attachments.Find(attachment.ID);
         Metainfo metainfo = new Metainfo();
         dbAttachment.Metadata.Add(metainfo);
         ctx.SaveChanges();
         return metainfo;
     }
 }
예제 #30
0
        public HttpResponseMessage<Facade.Topic[]> GetByGroup(Facade.Identity groupId, int skip, int limit)
        {
            // set valid values of opional parameters
            var validatedSkip = skip > 0 ? skip : new int?();
            var validatedLimit = limit > 0 ? limit : new int?();

            return ProcessGet(() =>
                    topicsByGroup.GetTopics(groupId.ToModel(), validatedSkip, validatedLimit)
                        .Select(item => item.ToFacade())
                        .ToArray());
        }
예제 #31
0
        /// <summary>
        /// Method for load messages.
        /// </summary>
        /// <param name="mailMessage">The mail messages.</param>
        /// <param name="type">The mail sender type.</param>
        public void LoadMessage(MailMessage mailMessage, MailSenderType type)
        {
            // the current mailbox.
            string mailbox = MainForm.GetInstance().GetSelectedMailbox();

            // retrieve the message body.
            string body = Facade.GetInstance().GetMessageBodyString(mailMessage, mailbox);

            // load message to.

            if (type == MailSenderType.Reply)
            {
                this.tbTo.Text = mailMessage.From;
            }
            else if (type == MailSenderType.ReplyToAll)
            {
                string to = mailMessage.From;

                if (to.Length > 0)
                {
                    to = string.Concat(to, ", ", mailMessage.To);
                }

                this.tbTo.Text = to;
            }

            // load message subject.

            if (type == MailSenderType.Reply || type == MailSenderType.ReplyToAll)
            {
                this.tbSubject.Text = string.Concat("Re: ", mailMessage.Subject);
            }
            else if (type == MailSenderType.Forward)
            {
                this.tbSubject.Text = string.Concat("Fwd: ", mailMessage.Subject);
            }

            // TODO: load message attachments.

            // load message body.

            if (type == MailSenderType.Reply || type == MailSenderType.ReplyToAll)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);
                sb.Append("On ");
                sb.Append(mailMessage.SentDate);
                sb.Append(", ");
                sb.Append(mailMessage.From);
                sb.Append(" wrote:");
                sb.Append(Environment.NewLine);

                sb.Append(body);

                this.htmlEditorControl.InnerText = sb.ToString();
            }
            else if (type == MailSenderType.Forward)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);
                sb.Append("---------- Forwarded message ----------");
                sb.Append(Environment.NewLine);
                sb.Append("From: ");
                sb.Append(mailMessage.From);
                sb.Append(Environment.NewLine);
                sb.Append("Date: ");
                sb.Append(mailMessage.SentDate);
                sb.Append(Environment.NewLine);
                sb.Append("Subject: ");
                sb.Append(mailMessage.Subject);
                sb.Append(Environment.NewLine);
                sb.Append("To: ");
                sb.Append(mailMessage.To);
                sb.Append(Environment.NewLine);
                sb.Append(Environment.NewLine);
                sb.Append(body);
                sb.Append(Environment.NewLine);

                this.htmlEditorControl.InnerText = sb.ToString();
            }
        }
예제 #32
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.DescricaoPrato);

            toolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar);
            TextView mTitle = (TextView)toolbar.FindViewById(Resource.Id.toolbar_title);

            mTitle.SetText("Resultado " + pratosel.Designacao, TextView.BufferType.Normal);

            ImageView foto          = FindViewById <ImageView>(Resource.Id.foto);
            RatingBar classificacao = FindViewById <RatingBar>(Resource.Id.classificacao);
            TextView  prato         = FindViewById <TextView>(Resource.Id.prato);
            TextView  restaurante   = FindViewById <TextView>(Resource.Id.restaurante);
            TextView  morada        = FindViewById <TextView>(Resource.Id.morada);
            TextView  telefone      = FindViewById <TextView>(Resource.Id.telefone);
            TextView  preco         = FindViewById <TextView>(Resource.Id.preco);

            byte[] a = Convert.FromBase64String(pratosel.Fotografia);
            Bitmap b = BitmapFactory.DecodeByteArray(a, 0, a.Length);

            foto.SetImageBitmap(b);

            classificacao.Rating = (float)pratosel.Classificacao;
            prato.Text           = pratosel.Designacao;
            restaurante.Text     = pratosel.Restaurante.Nome;
            morada.Text          = pratosel.Restaurante.Localizacao;
            telefone.Text        = "Contacto: " + pratosel.Restaurante.Telefone;
            preco.Text           = "Preço: " + pratosel.Preco.ToString() + " €";

            List <Classificacao> classificacoes = pratosel.Classificacoes;

            ListView listview = FindViewById <ListView>(Resource.Id.listview);

            listview.Adapter = new ComentariosAdapter(this, classificacoes);

            ImageView addComment = FindViewById <ImageView>(Resource.Id.addBo);

            addComment.Click += (sender, e) => {
                Console.WriteLine("\n\n\nBOTAOCOMENTARIOS");
                var dialog = new AdicionarComentario();
                Console.WriteLine("\n\n\nAdicionaComentario");
                dialog.Show(FragmentManager, "dialog");
            };

            Button guardarbuttom = FindViewById <Button>(Resource.Id.guardar);

            guardarbuttom.Click += (sender, e) => {
                Facade.GuardarPrato(pratosel);
                new AlertDialog.Builder(this).
                SetPositiveButton("OK", (senderAlert, args) => { }).
                SetMessage("Prato guardado nas seleções!").
                SetTitle("Sucesso").
                Show();
            };

            Button mapabuttom = FindViewById <Button>(Resource.Id.mapa);

            mapabuttom.Click += (sender, e) => {
                var geoUri    = Android.Net.Uri.Parse("geo:0,0?q=" + pratosel.Restaurante.Localizacao);
                var mapIntent = new Intent(Intent.ActionView, geoUri);
                StartActivity(mapIntent);
            };
        }
예제 #33
0
 protected override void OnAwake()
 {
     Facade.Instance <TwManger>().SendAction("saleInfo", new Dictionary <string, object>(), UpdateView);
 }
예제 #34
0
 public override void OnRegister()
 {
     base.OnRegister();
     pvpProxy = Facade.RetrieveProxy("PVPProxy") as PVPProxy;
 }
        public async Task <IActionResult> GetPDF([FromRoute] int Id)
        {
            try
            {
                var indexAcceptPdf = Request.Headers["Accept"].ToList().IndexOf("application/pdf");
                int timeoffsset    = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                FinishingPrintingSalesContractModel model = await Facade.ReadByIdAsync(Id);

                if (model == null)
                {
                    Dictionary <string, object> Result =
                        new ResultFormatter(ApiVersion, Common.NOT_FOUND_STATUS_CODE, Common.NOT_FOUND_MESSAGE)
                        .Fail();
                    return(NotFound(Result));
                }
                else
                {
                    string BuyerUri = "master/buyers";
                    string BankUri  = "master/account-banks";
                    //string CurrenciesUri = "master/currencies";
                    string Token = Request.Headers["Authorization"].First().Replace("Bearer ", "");


                    FinishingPrintingSalesContractViewModel viewModel = Mapper.Map <FinishingPrintingSalesContractViewModel>(model);

                    /* Get Buyer */
                    var response = HttpClientService.GetAsync($@"{APIEndpoint.Core}{BuyerUri}/" + viewModel.Buyer.Id).Result.Content.ReadAsStringAsync();
                    Dictionary <string, object> result = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Result);
                    object json;
                    if (result.TryGetValue("data", out json))
                    {
                        Dictionary <string, object> buyer = JsonConvert.DeserializeObject <Dictionary <string, object> >(json.ToString());
                        viewModel.Buyer.City    = buyer.TryGetValue("City", out json) ? (json != null ? json.ToString() : "") : "";
                        viewModel.Buyer.Address = buyer.TryGetValue("Address", out json) ? (json != null ? json.ToString() : "") : "";
                        viewModel.Buyer.Contact = buyer.TryGetValue("Contact", out json) ? (json != null ? json.ToString() : "") : "";
                        viewModel.Buyer.Country = buyer.TryGetValue("Country", out json) ? (json != null ? json.ToString() : "") : "";
                    }

                    /* Get Agent */
                    var responseAgent = HttpClientService.GetAsync($@"{APIEndpoint.Core}{BuyerUri}/" + viewModel.Agent.Id).Result.Content.ReadAsStringAsync();
                    Dictionary <string, object> resultAgent = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseAgent.Result);
                    object jsonAgent;
                    if (resultAgent.TryGetValue("data", out jsonAgent))
                    {
                        Dictionary <string, object> agent = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonAgent.ToString());
                        viewModel.Agent.City    = agent.TryGetValue("City", out jsonAgent) ? (jsonAgent != null ? jsonAgent.ToString() : "") : "";
                        viewModel.Agent.Address = agent.TryGetValue("Address", out jsonAgent) ? (jsonAgent != null ? jsonAgent.ToString() : "") : "";
                        viewModel.Agent.Contact = agent.TryGetValue("Contact", out jsonAgent) ? (jsonAgent != null ? jsonAgent.ToString() : "") : "";
                        viewModel.Agent.Country = agent.TryGetValue("Country", out jsonAgent) ? (jsonAgent != null ? jsonAgent.ToString() : "") : "";
                    }

                    /* Get AccountBank */
                    var responseBank = HttpClientService.GetAsync($@"{APIEndpoint.Core}{BankUri}/" + viewModel.AccountBank.Id).Result.Content.ReadAsStringAsync();
                    Dictionary <string, object> resultBank = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseBank.Result);
                    object jsonBank;
                    if (resultBank.TryGetValue("data", out jsonBank))
                    {
                        Dictionary <string, object> bank = JsonConvert.DeserializeObject <Dictionary <string, object> >(jsonBank.ToString());
                        var    currencyBankObj           = new CurrencyViewModel();
                        object objResult = new object();
                        if (bank.TryGetValue("Currency", out objResult))
                        {
                            currencyBankObj = JsonConvert.DeserializeObject <CurrencyViewModel>(objResult.ToString());
                        }
                        viewModel.AccountBank.BankAddress = bank.TryGetValue("BankAddress", out objResult) ? (objResult != null ? objResult.ToString() : "") : "";
                        viewModel.AccountBank.SwiftCode   = bank.TryGetValue("SwiftCode", out objResult) ? (objResult != null ? objResult.ToString() : "") : "";

                        viewModel.AccountBank.Currency             = new CurrencyViewModel();
                        viewModel.AccountBank.Currency.Description = currencyBankObj.Description;
                        viewModel.AccountBank.Currency.Symbol      = currencyBankObj.Symbol;
                        viewModel.AccountBank.Currency.Rate        = currencyBankObj.Rate;
                        viewModel.AccountBank.Currency.Code        = currencyBankObj.Code;
                    }

                    if (viewModel.Buyer.Type != "Ekspor")
                    {
                        FinishingPrintingSalesContractPDFTemplate PdfTemplate = new FinishingPrintingSalesContractPDFTemplate();
                        MemoryStream stream = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset);
                        return(new FileStreamResult(stream, "application/pdf")
                        {
                            FileDownloadName = "finishing printing sales contract (id)" + viewModel.SalesContractNo + ".pdf"
                        });
                    }
                    else
                    {
                        FinishingPrintingSalesContractExportPDFTemplate PdfTemplate = new FinishingPrintingSalesContractExportPDFTemplate();
                        MemoryStream stream = PdfTemplate.GeneratePdfTemplate(viewModel, timeoffsset);
                        return(new FileStreamResult(stream, "application/pdf")
                        {
                            FileDownloadName = "finishing printing sales contract (en) " + viewModel.SalesContractNo + ".pdf"
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, Common.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(Common.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }
예제 #36
0
 public void OnManagenCtrl()
 {
     Facade.Instance <TwManager>().SendAction("mahjongwm.manageCtrl", new Dictionary <string, object>(), FreshCtrl);
 }
예제 #37
0
        public async Task <IActionResult> DeleteScript(User.DeleteScriptCommand command)
        {
            var result = await Facade.ExecuteCommandAsync(command);

            return(NoContent());
        }
예제 #38
0
 public void PlayCommonEffect(EnCommonSound index)
 {
     Facade.Instance <MusicManager>().Play(CommenName[(int)index]);
 }
예제 #39
0
 public StudentController()
 {
     facade = new Facade();
 }
예제 #40
0
 public override void Execute(PureMVC.Interfaces.INotification notification)
 {
     Facade.RegisterProxy(new PanelSummaryProxy(PanelSummaryProxy.NAME));
 }
예제 #41
0
    /// <summary>
    /// Event for confirms the settings displayed in the page
    /// </summary>
    /// <param name="sender">The sender object</param>
    /// <param name="e">The event arguments</param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        string emailAddress;
        string password;
        string displayName;
        string incomingMailServer;
        string outgoingServer;
        string loginId;
        string incomingNameMailServer;
        int    portIncomingServer = 0;
        int    portOutgoingServer = 0;
        bool   isIncomeSecureConnection;
        bool   isOutgoingSecureConnection;
        bool   isOutgoingWithAuthentication;

        emailAddress           = TextBoxEmailAddress.Text;
        password               = TextBoxPassword.Text;
        displayName            = TextBoxDisplayName.Text;
        incomingNameMailServer = TextBoxIncomingServer.Text;
        incomingMailServer     = DropDownListIncomingServer.SelectedValue;

        try
        {
            if (CheckBoxPortIncoming.Checked)
            {
                if (!TextBoxPortIncoming.Text.Equals(string.Empty))
                {
                    portIncomingServer = Convert.ToInt32(TextBoxPortIncoming.Text);

                    if (this.ImcomingWasChanged(portIncomingServer))
                    {
                        Facade.GetInstance().ChangeImcoming = true;
                    }
                }
            }
            if (CheckBoxPortOutgoing.Checked)
            {
                if (!TextBoxPortOutgoing.Text.Equals(string.Empty))
                {
                    portOutgoingServer = Convert.ToInt32(TextBoxPortOutgoing.Text);
                }
            }
        }
        catch (Exception)
        {
            Session["ErrorMessage"] = "The port must be an integer";
            Response.Redirect("~/ErrorPage.aspx");
        }

        isIncomeSecureConnection     = CheckBoxSecureConnection.Checked;
        isOutgoingSecureConnection   = CheckBoxOutgoingSecure.Checked;
        isOutgoingWithAuthentication = CheckBoxOutgoingAuthentication.Checked;

        loginId        = TextBoxLoginID.Text;
        outgoingServer = TextBoxOutgoingServer.Text;

        //These informations are going to save

        AccountSettings.AccountInfo acc_info = new AccountSettings.AccountInfo();
        acc_info.EmailAddress                 = EncryptDescript.CriptDescript(emailAddress);
        acc_info.Password                     = EncryptDescript.CriptDescript(password);
        acc_info.DisplayName                  = displayName;
        acc_info.IncomingMailServer           = incomingMailServer;
        acc_info.OutgoingServer               = outgoingServer;
        acc_info.LoginId                      = loginId;
        acc_info.PortIncomingServer           = portIncomingServer;
        acc_info.PortOutgoingServer           = portOutgoingServer;
        acc_info.IncomingNameMailServer       = incomingNameMailServer;
        acc_info.IsIncomeSecureConnection     = isIncomeSecureConnection;
        acc_info.IsOutgoingSecureConnection   = isOutgoingSecureConnection;
        acc_info.IsOutgoingWithAuthentication = isOutgoingWithAuthentication;
        acc_info.PortIncomingChecked          = CheckBoxPortIncoming.Checked;
        acc_info.PortOutgoingChecked          = CheckBoxPortOutgoing.Checked;

        Facade f = Facade.GetInstance();

        f.setAccountInfo(acc_info);
        f.SaveAccountSettings();

        try
        {
            f.Disconnect();
        }
        catch (Exception)
        {
            Facade.GetInstance().deleteAccountSettings();
            Session["ErrorMessage"] = "Could not be disconnected with imcoming server";
            Response.Redirect("~/ErrorPage.aspx");
        }
        try
        {
            f.Connect();
        }
        catch (Exception)
        {
            Facade.GetInstance().deleteAccountSettings();
            Session["ErrorMessage"] = "Could not be connected with imcoming server, review the account settings";
            //how the settings is not valid set null
            Facade.GetInstance().AccSettings = null;
            Response.Redirect("~/ErrorPage.aspx");
        }

        Session["SucessMessage"] = "Account Settings updated with success!";
        Response.Redirect("~/SucessPage.aspx");
    }
예제 #42
0
    /// <summary>
    /// 返回拥有英雄列表
    /// </summary>
    private void OnGetHeroInfoList(object obj)
    {
        HeroInfoListMsg heroInfoListMsg = (HeroInfoListMsg)obj;

        Facade.SendNotification(NotificationID.SelectRoleOpen, heroInfoListMsg);
    }
 public override void Execute(INotification notification)
 {
     base.Execute(notification);
     Facade.SendNotification(VideoMediator.Notifications.StopVideo);
 }
예제 #44
0
 protected void DispatchUIEvent(string eventKey, object sender, GameEventArgs arg)
 {
     Facade.DispatchEvent(eventKey, sender, arg);
 }
예제 #45
0
        public async Task <IActionResult> UpdateUserScript(User.UpdateScriptCommand command)
        {
            var result = await Facade.ExecuteCommandAsync(command);

            return(Ok(result));
        }
예제 #46
0
 protected void DeregisterUIEvent(string eventKey)
 {
     Facade.DeregisterEvent(eventKey);
 }
예제 #47
0
        public async Task <IActionResult> ExecuteScript(Guid scriptId, [FromBody] string[] inputs)
        {
            var result = await Facade.ExecuteScriptAsync(scriptId, new DefaultExecutionParameters(), inputs);

            return(Ok(result));
        }
예제 #48
0
 protected void RemoveUIEventListener(string eventKey, Action <object, GameEventArgs> handler)
 {
     Facade.RemoveEventListener(eventKey, handler);
 }
예제 #49
0
    private void LoadOptions()
    {
        Debug.Log(Facade <Option> .ToStringAll());

        Option sound   = OptionFacade.Find(OptionName.Sound);
        bool   soundOn = (OnOffOption)sound.Value == OnOffOption.On ? true : false;

        Option        control   = OptionFacade.Find(OptionName.Controls);
        ControlOption controlId = (ControlOption)control.Value;

        audio.enabled = soundOn;

        Toggle[] optionToggles = Options_screen.GetComponentsInChildren <Toggle>();
        foreach (Toggle t in optionToggles)
        {
            switch (t.name)
            {
            case OptionToggle.Sound:
                t.isOn = soundOn;
                break;

            case OptionToggle.Arrow:
                t.isOn = controlId == ControlOption.Arrows;
                break;

            case OptionToggle.Paddle:
                t.isOn = controlId == ControlOption.Paddle;
                break;

            case OptionToggle.Gyroscope:
                t.isOn = controlId == ControlOption.Gyroscope;
                break;

            default:
                Debug.Log(String.Format("Not set: {0}", t.name));
                break;
            }
        }

        Option unlockedLevel = OptionFacade.Find(OptionName.UnlockedLevel);

        switch ((UnlockedLevelOption)unlockedLevel.Value)
        {
        case UnlockedLevelOption.Level_16:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_16.ToString()));
            goto case UnlockedLevelOption.Level_15;

        case UnlockedLevelOption.Level_15:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_15.ToString()));
            goto case UnlockedLevelOption.Level_14;

        case UnlockedLevelOption.Level_14:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_14.ToString()));
            goto case UnlockedLevelOption.Level_13;

        case UnlockedLevelOption.Level_13:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_13.ToString()));
            goto case UnlockedLevelOption.Level_12;

        case UnlockedLevelOption.Level_12:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_12.ToString()));
            goto case UnlockedLevelOption.Level_11;

        case UnlockedLevelOption.Level_11:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_11.ToString()));
            goto case UnlockedLevelOption.Level_10;

        case UnlockedLevelOption.Level_10:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_10.ToString()));
            goto case UnlockedLevelOption.Level_9;

        case UnlockedLevelOption.Level_9:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_9.ToString()));
            goto case UnlockedLevelOption.Level_8;

        case UnlockedLevelOption.Level_8:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_8.ToString()));
            goto case UnlockedLevelOption.Level_7;

        case UnlockedLevelOption.Level_7:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_7.ToString()));
            goto case UnlockedLevelOption.Level_6;

        case UnlockedLevelOption.Level_6:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_6.ToString()));
            goto case UnlockedLevelOption.Level_5;

        case UnlockedLevelOption.Level_5:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_5.ToString()));
            goto case UnlockedLevelOption.Level_4;

        case UnlockedLevelOption.Level_4:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_4.ToString()));
            goto case UnlockedLevelOption.Level_3;

        case UnlockedLevelOption.Level_3:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_3.ToString()));
            goto case UnlockedLevelOption.Level_2;

        case UnlockedLevelOption.Level_2:
            UnlockLevel(Level_selection_screen.transform.FindChild(UnlockedLevelOption.Level_2.ToString()));
            break;

        default:
            break;
        }
    }
예제 #50
0
 /// <summary>
 /// 发送签到
 /// </summary>
 public void OnSignBtn()
 {
     Facade.Instance <TwManager>().SendAction("signIn", new Dictionary <string, object>(), OnSignSuccess);
 }
예제 #51
0
 public override void OnRegister()
 {
     base.OnRegister();
     _beardProxy = Facade.RetrieveProxy(BeardProxy.NAME) as BeardProxy;
 }
 private static async void UpdateChipList()
 {
     chipList = await Facade.GetListAsync(new Chip());
 }
예제 #53
0
        public override void Execute(INotification notification)
        {
            LeadersMediator mediator = Facade.RetrieveMediator(LeadersMediator.NAME) as LeadersMediator;

            mediator.Show();
        }
 public static async Task <bool> AddChipToAccountAsync(string chipId, int accountId)
 {
     return(await Facade.PostAsync(new Chip(chipId, accountId)));
 }
예제 #55
0
        private IEnumerable <T> getWarnResult(WarnSettings warnSettings, TDetail detail, double warnCoefficientMin)
        {
            List <T> result = new List <T>();
            var      d      = Datas.FirstOrDefault();

            if (d == null)
            {
                return(result);
            }

            var totalHourRange = warnSettings.BuildingSubsidence_Day * 24;
            var endTime        = detail.IssueDateTime;
            var details        = Facade.GetDetailsByTimeRange(detail.IssueType, endTime.AddHours(-totalHourRange), endTime);
            var orderedDetails = details.OrderByDescending(c => c.IssueDateTime).ToList();
            var currentDetail  = detail;
            //需预警的节点
            //监测 warnSettings.BuildingSubsidence_SumMillimeter;
            var sumMillimeter = warnSettings.SurfaceSubsidence_SumMillimeter;

            foreach (var data in Datas)
            {
                if (data.SumChanges_Float >= sumMillimeter * warnCoefficientMin)
                {
                    result.Add(data);
                }

                //if (double.IsNaN(overCoefficientMax))
                //{
                //    if (data.SumChanges_Float >= sumMillimeter * warnCoefficientMin)
                //        result.Add(data);
                //}
                //else
                //{
                //    if (data.SumChanges_Float >= sumMillimeter * warnCoefficientMin)
                //        && data.SumChanges_Float < sumMillimeter * overCoefficientMax)
                //        result.Add(data);
                //}
            }
            //监测 warnSettings.BuildingSubsidence_DailyMillimeter;
            //数据天数达标监测
            if (totalHourRange != 0)
            {
                var    dailyMillimeter        = warnSettings.SurfaceSubsidence_DailyMillimeter;
                double warnDailyMillimeterMin = dailyMillimeter * warnCoefficientMin;
                //double warnDailyMillimeterMax = 0;
                //if (!double.IsNaN(overCoefficientMax))
                //{
                //    warnDailyMillimeterMax = dailyMillimeter * overCoefficientMax;
                //}
                var tempTotalTimeRange = totalHourRange;
                int detailIndex        = 0;
                while (tempTotalTimeRange > 0)
                {
                    if (detailIndex == orderedDetails.Count())
                    {
                        throw new NotImplementedException("未满足监测报警要求的天数");
                    }
                    var nextDetail       = orderedDetails[detailIndex];
                    var currentTimeRange = (int)(currentDetail.IssueDateTime.AddMinutes(currentDetail.IssueTimeRange) - nextDetail.IssueDateTime.AddMinutes(nextDetail.IssueTimeRange)).TotalHours;
                    if (currentTimeRange <= tempTotalTimeRange)
                    {
                        tempTotalTimeRange -= currentTimeRange;
                    }
                    else
                    {
                        tempTotalTimeRange -= currentTimeRange;
                    }
                    currentDetail = nextDetail;
                    detailIndex++;
                }
                foreach (var data in Datas)
                {
                    if (result.Contains(data))
                    {
                        continue;
                    }

                    detailIndex   = 0;
                    currentDetail = detail;
                    int    days       = warnSettings.BuildingSubsidence_Day;
                    double overHours  = 0;
                    double overValues = 0;
                    while (days > 0)
                    {
                        double dailyValue  = 0;
                        double hoursToDeal = 0;
                        if (overHours >= 24)
                        {
                            dailyValue  = overValues * 24 / overHours;
                            overValues -= dailyValue;
                            overHours  -= 24;
                        }
                        else
                        {
                            dailyValue  = overValues;
                            hoursToDeal = 24 - overHours;
                            while (hoursToDeal > 0)
                            {
                                var currentNodeData = currentDetail.NodeDatas.Datas.FirstOrDefault(c => c.NodeCode == data.NodeCode);
                                if (currentNodeData == null) //信息缺失,不作提醒处理  当前所需的节点数据不存在
                                {
                                    days        = -1;        //-1表信息缺失
                                    hoursToDeal = 0;
                                    break;
                                }
                                var    nextDetail       = orderedDetails[detailIndex];
                                double currentTimeRange = (currentDetail.IssueDateTime.AddMinutes(currentDetail.IssueTimeRange) - nextDetail.IssueDateTime.AddMinutes(nextDetail.IssueTimeRange)).TotalHours;
                                if (currentTimeRange <= hoursToDeal)
                                {
                                    dailyValue += (currentNodeData as T).CurrentChanges_Float;
                                }
                                else
                                {
                                    dailyValue += (currentNodeData as T).CurrentChanges_Float * (hoursToDeal / currentTimeRange);
                                    overHours   = currentTimeRange - hoursToDeal;
                                    overValues  = (currentNodeData as T).CurrentChanges_Float * (overHours / currentTimeRange);
                                }
                                hoursToDeal -= currentTimeRange;
                                detailIndex++;
                                currentDetail = nextDetail;
                            }
                        }
                        //时间已尽 检测是否到达预期值
                        if (days == -1)
                        {
                            break;
                        }
                        if (dailyValue >= warnDailyMillimeterMin)
                        {
                            days--;
                        }
                        else
                        {
                            days = -2;//-2表信息未到连续标准
                            break;
                        }
                        //if (!double.IsNaN(overCoefficientMax) && dailyValue > warnDailyMillimeterMax)
                        //{
                        //    days = -3;//-3表信息已过高限
                        //    break;
                        //}
                        //else if (dailyValue >= warnDailyMillimeterMin)
                        //    days--;
                        //else
                        //{
                        //    days = -2;//-2表信息未到连续标准
                        //    break;
                        //}
                    }
                    if (days == 0)//处理结束 认为按照标准的到达了日期0则各天检测通过
                    {
                        result.Add(data);
                    }
                }
            }
            return(result);
        }
예제 #56
0
 /// <summary>
 /// 本类实例在注册时触发
 /// </summary>
 public override void OnRegister()
 {
     //得到“用户代理”引用
     _UserProxy = Facade.RetrieveProxy(UserProxy.NAME) as UserProxy;
 }
예제 #57
0
 /// <summary>
 /// 玩家播放声音(区别性别)
 /// </summary>
 /// <param name="clipName">声音名字</param>
 public override void PlaySound(string clipName)
 {
     Facade.Instance <MusicManager>().Play(clipName, Info.SexI != 1 ? "Woman":"Man");
 }
예제 #58
0
        public async Task <IActionResult> AddUserScript(User.AddScriptCommand command)
        {
            var result = await Facade.ExecuteCommandAsync(command);

            return(CreatedAtRoute(nameof(GetScript), result.Id, result));
        }
예제 #59
0
    /// <summary>
    /// 获取英雄奥义 卡牌信息
    /// </summary>
    /// <param name="obj"></param>
    void OnGetHeroCard(object obj)
    {
        CardInfoListMsg info = (CardInfoListMsg)obj;

        Facade.SendNotification(NotificationID.SetHeroOpen, info);
    }
예제 #60
0
 /// <summary>
 /// 返回拥有的小队列表
 /// </summary>
 private void OnGetTeamListt(object obj)
 {
     Facade.SendNotification(NotificationID.TeamListOpen, obj);
 }