private void InitialiseVariables() { paladin = GameObject.FindWithTag("Paladin"); valkyrie = GameObject.FindWithTag("Valkyrie"); sage = GameObject.FindWithTag("Sage"); enemy = GameObject.FindWithTag("Enemy"); paladinController = paladin.GetComponent <Paladin>(); sageController = sage.GetComponent <Sage>(); valkyrieController = valkyrie.GetComponent <Valkyrie>(); enemyController = enemy.GetComponent <Enemy>(); paladinPortraitRenderer = paladinPortrait.GetComponent <SpriteRenderer>(); valkyriePortraitRenderer = valkyriePortrait.GetComponent <SpriteRenderer>(); sagePortraitRenderer = sagePortrait.GetComponent <SpriteRenderer>(); potionButtonImage = potionButton.GetComponent <Image>(); manaButtonImage = manaButton.GetComponent <Image>(); magic1ButtonImage = magic1Button.GetComponent <Image>(); magic2ButtonImage = magic2Button.GetComponent <Image>(); magic3ButtonImage = magic3Button.GetComponent <Image>(); special1ButtonImage = special1Button.GetComponent <Image>(); paladinSelectImage = paladinSelectButton.GetComponent <Image>(); valkyrieSelectImage = valkyrieSelectButton.GetComponent <Image>(); sageSelectImage = sageSelectButton.GetComponent <Image>(); potionButtonText = potionButton.GetComponentInChildren <Text>(); manaButtonText = manaButton.GetComponentInChildren <Text>(); magic1ButtonText = magic1Button.GetComponentInChildren <Text>(); magic2ButtonText = magic2Button.GetComponentInChildren <Text>(); magic3ButtonText = magic3Button.GetComponentInChildren <Text>(); special1ButtonText = special1Button.GetComponentInChildren <Text>(); paladinSelectText = paladinSelectButton.GetComponentInChildren <Text>(); valkyrieSelectText = valkyrieSelectButton.GetComponentInChildren <Text>(); sageSelectText = sageSelectButton.GetComponentInChildren <Text>(); }
private void Insert() { try { if (!string.IsNullOrWhiteSpace(textBoxName.Text) && !string.IsNullOrWhiteSpace(textBoxAge.Text)) { using (MyModel context = new MyModel()) { Sage sage = new Sage() { Name = textBoxName.Text, Age = Convert.ToInt32(textBoxAge.Text) }; context.Sages.Add(sage); context.SaveChanges(); } textBoxName.Clear(); textBoxAge.Clear(); InitializeDataGridViewSages(); } } catch { } }
// Use this for initialization void Start() { animationController = GetComponent <Animator>(); paladinController = paladin.GetComponent <Paladin>(); valkyrieController = valkyrie.GetComponent <Valkyrie>(); sageController = sage.GetComponent <Sage>(); turnController = gameManager.GetComponent <TurnController>(); attackDownTransform = transform.Find("Attack Down"); attackDownImage = attackDownTransform.GetComponentInChildren <SpriteRenderer>(); TR_enraged = transform.Find("Enraged"); enragedImage = TR_enraged.GetComponentInChildren <SpriteRenderer>(); quarterHealth = healthPoints / 4; specialPower = attackPower * 6; poisonPurple = new Color(139, 0, 139); ailmentCount = 0; poisoned = false; damageText.enabled = false; }
public ActionResult Edit([Bind(Include = "IdSage,name,age,photo,city")] Sage sage, List <int> Books) { if (ModelState.IsValid) { Sage changedSage = this.UoW.Sages.Get(sage.IdSage); changedSage.name = sage.name; changedSage.age = sage.age; changedSage.photo = sage.photo; changedSage.city = sage.city; if (Books != null) { foreach (var id in Books) { var book = this.UoW.Books.Get(id); if (!changedSage.Books.Contains(book)) { changedSage.Books.Add(book); } } foreach (var id in changedSage.Books.Select(x => x.IdBook)) { if (!Books.Contains(id)) { changedSage.Books.Remove(this.UoW.Books.Get(id)); } } } this.UoW.Complete(); return(RedirectToAction("Index")); } return(View(sage)); }
public static IWorkItemAction CreateAction(Sage.Entity.Interfaces.IWorkItemAction data) { IWorkItemAction action = null; switch (data.ActionType) { case "Email Notification": action = new EmailAction(); // TODO - this needs to eb dynamic action.DeliverySystem = new SmtpDeliverySystem(new SmtpSettings { EnableSsl = true, SmtpPort = 587, SmtpServer = "smtp.gmail.com", SmtpUser = "******", SmtpUserPassword = "******", EmailAddress = "*****@*****.**", DisplayName = "Saleslogix DTS", IsBodyHtml = false } ); break; default: throw new Exception("Invalid action type " + data.ActionType); } action.LoadConfiguration(data.ActionValue); return action; }
private void AddSage() { try { if (!IsNullOrWhiteSpace(textBox1.Text)) { var work = Form1.Work; IGenericRepository <Sage> repository = work.Repository <Sage>(); var sage = new Sage() { Name = textBox1.Text, Age = Convert.ToInt32(numericUpDown1.Value) }; repository.Add(sage); listBox.Items.Clear(); textBox1.Text = Empty; numericUpDown1.Value = Zero; button1.Enabled = false; LoadData(_load); } else { MessageBox.Show(@"All fields are required", Empty, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public async Task <IActionResult> Edit(int id, [Bind("SageId,Name,Age,Photo,City")] Sage sage) { if (id != sage.SageId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sage); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { // if (!MovieExists(sage.SageId)) // { // return NotFound(); // } // else // { // throw; // } } return(RedirectToAction("Index")); } return(View(sage)); }
public void EditSage(int id, [FromBody] Sage sage) { if (id == sage.Id) { db.Update(sage); } }
private void deleteButton_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Would you like to delete the entry?", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } using (SgDbContext sbc = new SgDbContext()) { if (resultGrid.ItemsSource.GetType() == typeof(ObservableCollection <Sage>)) { Sage s = sbc.Sages.Where(p => p.Id == ((Sage)resultGrid.SelectedItem).Id).FirstOrDefault(); sbc.Sages.Remove(s); Sages.Remove(s); resultGrid.ItemsSource = Sages; } else { Book b = sbc.Books.Where(p => p.Id == ((Book)resultGrid.SelectedItem).Id).FirstOrDefault(); sbc.Books.Remove(b); Books.Remove(b); resultGrid.ItemsSource = Books; } sbc.SaveChanges(); } resultGrid.Items.Refresh(); }
public static void lkpProduct_OnChangeStep( Sage.Form.Interfaces.IAddEditQuotationProduct form, EventArgs args) { // TODO: Complete business rule implementation form.Price.Text = "900"; // form.Price = 100; }
public static void SetSeccode_OnAfterInsertStep( Sage.Entity.Interfaces.IStampMaster stampmaster) { // TODO: Complete business rule implementation Sage.Entity.Interfaces.IOwner objOwner = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IOwner>("SYST00000001"); stampmaster.Owner = objOwner; stampmaster.Save(); }
public ActionResult GetSageBooks(int?Id) { Sage sage = uow.Sages.GetAll().Where(x => x.Id == Id).Single(); IEnumerable <Book> Books = sage.Books; ViewBag.Sage = sage; return(View("SageBooks", Books)); }
public void Setup() { _factory = new MockFactory(MockBehavior.Strict); _parserMock = _factory.Create<IConfigurationParser>(); _proxyMock = _factory.Create<IConfigurationProxyProvider>(); _sage = new Sage(_parserMock.Object, _proxyMock.Object); }
public async Task <int> CreateAsync(Sage sage) { _context.Sages.Add(sage); await _context.SaveChangesAsync(); return(sage.Id); }
public void DeleteSage(int id) { Sage sage = db.GetBook(id); if (sage != null) { db.Delete(id); } }
public override Application.Base.Document GetTransformedDocument(Sage.Common.Syndication.FeedEntry payload) { Application.Base.Document document = _transform.GetTransformedDocument(payload as TradingAccountFeedEntry); if (document.CrmId == null) { document.CrmId = payload.Key; } return document; }
private void btnOk_Click(object sender, RoutedEventArgs e) { try { if (fromSelectedID == -1) { using (DataClasses1DataContext cnt = new DataClasses1DataContext()) { if (fromComboBox == "Book") { Book book = new Book() { Title = textBox2.Text }; cnt.Book.InsertOnSubmit(book); cnt.SubmitChanges(); } if (fromComboBox == "Sage") { Sage sage = new Sage() { Name = textBox2.Text, Age = DateTime.Parse(textBox3.Text) }; cnt.Sage.InsertOnSubmit(sage); cnt.SubmitChanges(); } if (fromComboBox == "SageBook") { Book book = new Book() { Title = textBox2.Text }; cnt.Book.InsertOnSubmit(book); cnt.SubmitChanges(); } } } else { using (DataClasses1DataContext cnt = new DataClasses1DataContext()) { if (fromComboBox == "Book") { var book = cnt.Book.Where(x => x.Id == fromSelectedID).FirstOrDefault(); book.Title = textBox2.Text; cnt.SubmitChanges(); } } } this.Close(); } catch (Exception) { throw; } }
public ActionResult Edit(int id) { Sage s = uow.Sages.SelectByID(id); if (s == null) { return(HttpNotFound()); } return(View(s)); }
public ActionResult Edit(int?Id) { Sage s = uow.Sages.GetAll().Where(x => x.Id == Id).Single(); Book [] books = uow.Books.GetAll().Except(s.Books).ToArray(); ViewBag.Books = books; return(View(s)); }
// GET: Admin/Sages/Create public ActionResult Create() { Sage sage = new Sage(); foreach (var item in this.UoW.Books.GetAll()) { sage.Books.Add(item); } return(View(sage)); }
private void Execute() { GenericUnitOfWork work = new GenericUnitOfWork(new SageBookContext(ConfigurationManager.ConnectionStrings["conStr"]. ConnectionString)); var repo = work.Repository <Sage>(); Sage sage = repo.FindById(SelectedId); repo.Remove(sage); OnPropertyChanged("listToBind"); OnPropertyChanged("listId"); }
public async Task <ActionResult <Sage> > Get(int id) { Sage sage = unitOfWork.Sages.Get(id); if (sage == null) { return(NotFound()); } return(sage); }
public static void SetSeccode_OnAfterInsertStep( Sage.Entity.Interfaces.IBranch branch) { // TODO: Complete business rule implementation //Sage.Entity.Interfaces.IUser currentUser = BusinessRuleHelper.GetCurrentUser(session); Sage.Entity.Interfaces.IOwner objOwner = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IOwner>("SYST00000001"); branch.Owner = objOwner; branch.Save(); }
public ActionResult AddBook(int SageId, List <int> Books) { Sage sage = this.UoW.Sages.Get(SageId); foreach (var id in Books) { sage.Books.Add(this.UoW.Books.Get(id)); } this.UoW.Complete(); return(RedirectToAction("Edit", new { id = SageId })); }
// Use this for initialization void Start() { animationController = GetComponent <Animator>(); spriteImage = GetComponent <SpriteRenderer>(); turnController = gameManager.GetComponent <TurnController>(); paladinController = paladin.GetComponent <Paladin>(); sageController = sage.GetComponent <Sage>(); TR_petrified = transform.Find("V_Petrified"); petrifiedImage = TR_petrified.GetComponentInChildren <SpriteRenderer>(); TR_special = transform.Find("V_Special"); specialImage = TR_special.GetComponentInChildren <SpriteRenderer>(); TR_magic = transform.Find("V_Magic"); magicImage = TR_magic.GetComponentInChildren <SpriteRenderer>(); GO_guardUp = GameObject.FindWithTag("V_GuardUp"); guardUpImage = GO_guardUp.GetComponent <SpriteRenderer>(); TR_win = transform.Find("V_Win"); winImage = TR_win.GetComponentInChildren <SpriteRenderer>(); TR_wounded = transform.Find("V_Wounded"); woundedImage = TR_wounded.GetComponentInChildren <SpriteRenderer>(); TR_dead = transform.Find("V_Dead"); deadImage = TR_dead.GetComponentInChildren <SpriteRenderer>(); b_isDead = false; b_isWounded = false; //Derived Stats attackPower = STRENGTH * 10; // 1000 avg damage magicPower = 0; // No magic offense dodge = AGILITY * 2; // 10% Chance of dodging defencePower = DEFENCE * 2; //10% Defence special = 0; health = MAX_HEALTH; magic = MAX_MAGIC; AudioSource[] audios = GetComponents <AudioSource>(); takeDamageSound = audios[0]; attackSound = audios[1]; magicSound = audios[2]; specialExecute = false; UpdateStats(); enemy = GameObject.FindWithTag("Enemy"); enemyController = enemy.GetComponent <Enemy>(); }
public ActionResult Create(Book b) { ViewBag.sagelist = new MultiSelectList(uow.Sages.GetAll(), "ID", "name", b.SelectedBooks); foreach (var sageID in b.SelectedBooks) { Sage sage = uow.Sages.SelectByID(sageID); b.Sages.Add(sage); } uow.Books.Create(b); uow.Save(); return(RedirectToAction("ViewBook")); }
public ActionResult DeleteSageBook(int?SageId, int?BookId) { Sage sage = uow.Sages.GetAll().Where(x => x.Id == SageId).Single(); sage.Books.Remove(sage.Books.Where(x => x.Id == BookId).SingleOrDefault()); uow.Save(); ViewBag.Sage = sage; IEnumerable <Book> Books = sage.Books; return(View("SageBooks", Books)); }
private void Execute() { GenericUnitOfWork work = new GenericUnitOfWork(new SageBookContext(ConfigurationManager.ConnectionStrings["conStr"]. ConnectionString)); var repo = work.Repository <Sage>(); Sage sage = repo.FindById(SelectedId); sage.FirstName = FirstNameText; sage.LastName = LastNameText; repo.Update(sage); OnPropertyChanged("listToBind"); ClearFields(); }
public async Task <IHttpActionResult> Post(Sage sage) { if (!ModelState.IsValid) { return(this.BadRequest(ModelState.ToValidationMessages())); } await _sageService.UpdateAsync(sage); _logger.Info("Sage " + sage.Name + " [id: " + sage.Id + "] updated by " + _userHelper.UserName); return(Ok()); }
public ActionResult Create(Sage sage) { try { uow.Sages.Create(sage); ViewBag.Message = "Created"; } catch (Exception) { ViewBag.Message = "Error"; } return(View()); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (!sageAge.Text.All(char.IsDigit)) { MessageBox.Show($"Age should be a number. But is: {sageAge.Text}"); } else if (sageName.Text == null || sageCity == null) { MessageBox.Show("All fields shooould be filled!"); } else { Sage _sage = new Sage { Name = sageName.Text, City = sageCity.Text, Age = int.Parse(sageAge.Text) }; using (SgDbContext sbc = new SgDbContext()) { if (sbc.Sages.Where(s => s.Age == _sage.Age && s.Name == _sage.Name && s.City == _sage.City).ToList().Count() != 0) { MessageBox.Show($"Sage {_sage} already exist. Please add new or cancel"); } else { if (IsNewItem) { if (sbc.Sages.Any(s => s.Name == _sage.Name && s.City == _sage.City && s.Age == _sage.Age)) { MessageBox.Show("Sage already exists.Please edit your form!"); } else { sbc.Sages.Add(_sage); } } else { Sage editedSage = sbc.Sages.Where(p => p.Id == SageId).FirstOrDefault(); sbc.Sages.Attach(editedSage); editedSage.Name = SageDefaultName; editedSage.City = SageDefaultCity; editedSage.Age = int.Parse(SageDefaultAge); } sbc.SaveChanges(); } Close(); } } }
public ActionResult EditConfirmed(Sage s, HttpPostedFileBase file) { if (file != null) { using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { file.InputStream.CopyTo(ms); s.photo = ms.GetBuffer(); } } uow.Sages.Update(s); uow.Save(); return(RedirectToAction("ViewSage")); }
// GET: Sages/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sage sage = this.repo.Get((int)id); if (sage == null) { return(HttpNotFound()); } return(View(sage)); }
public static IWorkItemDataSource CreateDataSource(Sage.Entity.Interfaces.IWorkItemDataSource data) { IWorkItemDataSource ds = null; switch (data.DataSourceType) { case "HQL": ds = new HqlDataSource(); break; default: throw new Exception("Invalid datasource type " + data.DataSourceType); } ds.LoadConfiguration(data.DataSourceValue); return ds; }
public async Task <ActionResult <User> > Delete(int id) { Sage sage = unitOfWork.Sages.Get(id); if (sage == null) { return(NotFound()); } unitOfWork.Sages.Delete(sage.SageId); unitOfWork.Save(); return(NoContent()); //return Ok(book); }
public async Task <string> RunAI(int turnState) { string response = ""; sage = new Sage(); SimpleBoard boardToRun = board.GetSimpleBoard(); Move moveToMake = await Task <Move> .Factory.StartNew(() => RunAITurn(boardToRun)); ApplyAIMove(moveToMake); moveToMake.ToString(); // ensure string representation is upto date; moveHistory.Add(moveToMake); requestReDraw = true; responseText = AI_MOVE_COMPLETED; response = JsonConvert.SerializeObject(this); return(response); }
// GET: Sages/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sage sage = await _uow.SageRepository.GetByIdAsync(id.Value); if (sage == null) { return(HttpNotFound()); } return(View(sage)); }
public static IWorkItemTarget CreateTarget(Sage.Entity.Interfaces.IWorkItemTarget data) { IWorkItemTarget target = null; // TODO: this should be dynamic switch (data.TargetType) { case "QueryField": target = new DynamicWorkItemTarget(); break; case "OwnerField": target = new OwnerFieldWorkItemTarget(); break; default: throw new Exception("Invalid target type " + data.TargetType); } target.LoadConfiguration(data.TargetValue); return target; }
public override Application.Base.Document GetTransformedDocument(Sage.Common.Syndication.FeedEntry payload) { return _transform.GetTransformedDocument(payload as UnitOfMeasureFeedEntry); }
protected string GetAccountFilterSQL(Sage.Entity.Interfaces.IUserMIAReport _entity) { //--======================================================= //-- Dynamic Based on Account(s) //--======================================================= string sql = ""; // Return SQL if (_entity.UseAcount != null) { if (_entity.UseAcount == true) { if (_entity.Accountid != null) { sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTID = '" + _entity.Accountid + "'))"; } } else { // Use My Territory Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser Currentuser = usersvc.GetUser(); // Has Access if (RoleSecurityService != null) { if (RoleSecurityService.HasAccess("GWC/Management/MIAReport")) { // UseSelectedUser if (_entity.UseSpecifiedUser != null && _entity.UseSpecifiedUser == true) { if (_entity.SpecifiedUserId != null) { //UseSelected User sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTMANAGERID = '" + _entity.SpecifiedUserId.ToString().Trim() + "'))"; } else { // Use Current User sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTMANAGERID = '" + Currentuser.Id.ToString().Trim() + "'))"; } } else { // Use Current User sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTMANAGERID = '" + Currentuser.Id.ToString().Trim() + "'))"; } } else { // Use Current User sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTMANAGERID = '" + Currentuser.Id.ToString().Trim() + "'))"; } } // User is Valid } } else { // Null so Use Account if (_entity.Accountid != null) { sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTID = '" + _entity.Accountid + "'))"; } else { // Null Accountid so Limit the Results to nothing sql += " AND (vsi.ACCOUNTID IN "; sql += " (SELECT ACCOUNTID "; sql += " FROM sysdba.ACCOUNT AS ACCOUNT_1"; sql += " WHERE (ACCOUNTID = 'Nothing'))"; } } return sql; }
protected void GetProductsForDDL(Sage.Entity.Interfaces.IProduct myProduct) { String SQL = ""; //Intialize ddlAMAnnualMaintenanceProduct.Items.Clear(); // Clear Out the List // Generate In SQL statement Sage.Platform.Data.IDataService datasvc = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>(); //using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString())) //============================================================================= // //============================================================================= //If sType = "Maintenance" Then if (myProduct.Type == "Maintenance") { //'For Annual Maintenance Renewals only //Dim sResults, i, sParentName, sStartIndex, sMatchProducts, rc //Dim sRenewalProduct //rc = False //rc = GetFieldsRows ("Name", "Product", "Family = '" & sFamily & "' AND ProductGroup = '" & sGroup & "' And Type = 'Software' Order by NAME", sMatchProducts) SQL = "SELECT PRODUCT.Name,PRODUCT.PRODUCTID FROM Product WHERE PRODUCT.Family = '" + myProduct.Family + "' AND PRODUCT.ProductGroup = '" + myProduct.ProductGroup + "' And PRODUCT.Type = 'Software' Order by PRODUCT.NAME"; using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString())) { conn.Open(); using (OleDbCommand cmd = new OleDbCommand(SQL, conn)) { OleDbDataReader r = cmd.ExecuteReader(CommandBehavior.CloseConnection); ListItem newItem = new ListItem(); while (r.Read()) { newItem = new ListItem(); newItem.Text = r["Name"].ToString(); newItem.Value = r["PRODUCTID"].ToString(); ddlAMAnnualMaintenanceProduct.Items.Add(newItem); } r.Close(); } } if (ddlAMAnnualMaintenanceProduct.Items.Count == 0) { //if not rc Then // 'Get them all // rc =GetFieldsRows ("Name", "Product", "Name like '%' And Type = 'Software' Order by NAME", sMatchProducts) //end if SQL = "SELECT PRODUCT.Name,PRODUCT.PRODUCTID FROM Product WHERE NAME LIKE '%' AND PRODUCT.Type = 'Software' Order by PRODUCT.NAME"; using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(datasvc.GetConnectionString())) { conn.Open(); using (OleDbCommand cmd = new OleDbCommand(SQL, conn)) { OleDbDataReader r = cmd.ExecuteReader(CommandBehavior.CloseConnection); ListItem newItem = new ListItem(); while (r.Read()) { newItem = new ListItem(); newItem.Text = r["Name"].ToString(); newItem.Value = r["PRODUCTID"].ToString(); ddlAMAnnualMaintenanceProduct.Items.Add(newItem); } r.Close(); } } } //if (ddlAMAnnualMaintenanceProduct.Items.Count > 0) //{ //'fill combo box of potential renewal products //if rc then // For i = 1 to uBound(sMatchProducts, 1) 'Number of rows // cmbRenewalProduct.Items.Add sMatchProducts(i,1) 'Only one field per row // Next // i = 0 // If Instr(lcase(sProductName), "mx") > 0 Then // sRenewalProduct = "MX Net" // elseif Instr(lcase(sProductName), "processsuite") > 0 Then // sRenewalProduct = "ProcessSuite" // end if // if sRenewalProduct <> "" Then // for i = 1 to cmbRenewalProduct.Items.Count // if cmbRenewalProduct.Items(i) = sRenewalProduct Then // exit for // end if // next // end if // cmbRenewalProduct.ItemIndex = i 'Select first item in list by default //end if // } } //end if }
public override Application.Base.Document GetTransformedDocument(Sage.Common.Syndication.FeedEntry payload) { return _transform.GetTransformedDocument(payload as CommodityGroupFeedEntry); }
protected override void OnMyDialogClosing(object from, Sage.Platform.WebPortal.Services.WebDialogClosingEventArgs e) { base.OnMyDialogClosing(from, e); Visible = false; Session["adhocchecked"] = "0"; }
private SalesOrderFeedEntry GetPayload(Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrdersRow row, Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsDataTable detailDataTable, NorthwindConfig config) { #region Declarations SalesOrderFeedEntry payload; string id; CountryCodes countryCodes = new CountryCodes(); #endregion id = row.OrderID.ToString(); payload = new SalesOrderFeedEntry(); payload.UUID = GetUuid(id, "", SupportedResourceKinds.salesOrders); payload.active = true; payload.currency = config.CurrencyCode; payload.pricelist = new PriceListFeedEntry(); payload.pricelist.UUID = GetUuid(id, "", SupportedResourceKinds.priceLists); if (!row.IsCustomerIDNull()) { /*payload.tradingAccount = new TradingAccountFeedEntry(); payload.tradingAccount.Key = Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix + row.CustomerID; payload.tradingAccount.UUID = GetUuid(payload.tradingAccount.Key, "", SupportedResourceKinds.tradingAccounts); payload.tradingAccount.Id = GetSDataId(payload.tradingAccount.Key, SupportedResourceKinds.tradingAccounts); payload.tradingAccount.Uri = payload.tradingAccount.Id;*/ payload.tradingAccount = (TradingAccountFeedEntry)_tradingAccountsFeedEntryWrapper.GetFeedEntry(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix + row.CustomerID); } if (!row.IsOrderDateNull()) { payload.date = row.OrderDate; } //payload.lineCount = detailDataTable.Rows.Count; payload.discountTotal = row.IsDiscountAmountNull() ? new decimal(0) : Convert.ToDecimal(row.DiscountAmount); payload.netTotal = row.IsTotalNetPriceNull() ? new decimal(0) : Convert.ToDecimal(row.TotalNetPrice); payload.carrierTotalPrice = row.IsFreightNull() ? new decimal(0) : row.Freight; payload.grossTotal = payload.netTotal; if (!row.IsRequiredDateNull()) { payload.dueDate = row.RequiredDate; } if (!row.IsShipViaNull()) { payload.deliveryMethod = row.ShipVia.ToString(); ; } PostalAddressFeedEntry address = new PostalAddressFeedEntry(); address.active = true; address.address1 = row.IsShipAddressNull() ? null : row.ShipAddress; address.country = row.IsShipCountryNull() ? null : row.ShipCountry; address.townCity = row.IsShipCityNull() ? null : row.ShipCity; address.zipPostCode = row.IsShipPostalCodeNull() ? null : row.ShipPostalCode; address.type = postalAddressTypeenum.Shipping; payload.postalAddresses = new PostalAddressFeed(); //TODO: check if valid Address? payload.postalAddresses.Entries.Add(address); payload.salesOrderLines = new SalesOrderLineFeed(); foreach (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsRow detailRow in detailDataTable.Rows) { SalesOrderLineFeedEntry soPayload = GetLineItem(detailRow, config); payload.salesOrderLines.Entries.Add(soPayload); } return payload; }
private SalesOrderLineFeedEntry GetLineItem(Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.CalculatedOrderDetailsRow row, NorthwindConfig config) { #region Declarations SalesOrderLineFeedEntry payload; string id; decimal discountPercentage; #endregion id = row.OrderID.ToString() + "-" + row.ProductID.ToString(); payload = new SalesOrderLineFeedEntry(); payload.UUID = GetUuid(id, "", SupportedResourceKinds.salesOrderLines); payload.commodity = (CommodityFeedEntry)_commoditiesFeedEntryWrapper.GetFeedEntry(row.ProductID.ToString()); /* payload.commodity = new CommodityFeedEntry(); payload.commodity.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.commodities);*/ payload.salesOrder = new SalesOrderFeedEntry(); payload.salesOrder.UUID = GetUuid(row.OrderID.ToString(), "", SupportedResourceKinds.salesOrders); payload.unitOfMeasure = (UnitOfMeasureFeedEntry)_unitsOfMeasureFeedEntryWrapper.GetFeedEntry(row.ProductID.ToString()); /*payload.unitOfMeasure = new UnitOfMeasureFeedEntry(); payload.unitOfMeasure.UUID = GetUuid(row.ProductID.ToString(), "", SupportedResourceKinds.unitsOfMeasure);*/ payload.quantity = row.IsQuantityNull() ? Convert.ToInt16(0) : row.Quantity; payload.initialPrice = row.IsUnitPriceNull() ? new decimal(0) : row.UnitPrice; payload.orderLineDiscountPercent = row.IsDiscountNull() ? (decimal)0 : Convert.ToDecimal(row.Discount); payload.discountTotal = payload.initialPrice * (decimal)payload.orderLineDiscountPercent; payload.costTotal = (decimal)payload.initialPrice * (1 - payload.orderLineDiscountPercent); payload.netTotal = Convert.ToDecimal(payload.quantity) * Convert.ToDecimal(payload.costTotal); SetCommonProperties(id, payload, SupportedResourceKinds.salesOrderLines); return payload; }
public static void GetManagerStep( IUser user, out Sage.Entity.Interfaces.IUser result) { result = EntityFactory.GetById<IUser>(user.ManagerId); }
public override SdataTransactionResult Add(Sage.Common.Syndication.FeedEntry payload) { SdataTransactionResult tmpTransactionResult; SalesOrderFeedEntry salesorder = null; if (!(payload is SalesOrderFeedEntry)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder payload missing"); return tmpTransactionResult; } salesorder = (payload as SalesOrderFeedEntry); if (salesorder == null) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder payload missing"); return tmpTransactionResult; } #region check input values if (payload == null) return null; string customerID = ""; if (salesorder.tradingAccount != null) customerID = GetLocalId(salesorder.tradingAccount.UUID, SupportedResourceKinds.tradingAccounts); if (String.IsNullOrEmpty(customerID)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("Trading Acount Id missing"); return tmpTransactionResult; } if (!customerID.StartsWith(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("Salesorder submission is only supported by customers"); return tmpTransactionResult; } #endregion Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.OrdersTableAdapter tableAdapter; Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.Order_DetailsTableAdapter detailsTableAdapter; Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order order = new Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order(); Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.OrdersRow newOrder = order.Orders.NewOrdersRow(); customerID = customerID.Substring(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix.Length); newOrder.CustomerID = customerID; #region get Company Name DataSet dataSet = new DataSet(); OleDbDataAdapter dataAdapter; string sqlQuery = "Select CompanyName from Customers where CustomerID = '" + customerID + "'"; try { using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString)) { dataAdapter = new OleDbDataAdapter(sqlQuery, connection); if (dataAdapter.Fill(dataSet, "Customers") == 0) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("trading account not found"); return tmpTransactionResult; } newOrder.ShipName = dataSet.Tables[0].Rows[0][0].ToString(); } } catch (Exception e) { throw; } #endregion #region fill dataset from document try { if (!salesorder.IsPropertyChanged("date") || salesorder.date==null) newOrder.SetOrderDateNull(); else newOrder.OrderDate = salesorder.date; if (!salesorder.IsPropertyChanged("dueDate") || salesorder.dueDate==null) newOrder.SetRequiredDateNull(); else newOrder.RequiredDate = (DateTime)salesorder.dueDate; //if (orderDoc.shippedvia.IsNull) // newOrder.SetShipViaNull(); //else // newOrder.ShipVia = (int)orderDoc.shippedvia.Value; if (salesorder.postalAddresses == null || salesorder.postalAddresses.Entries.Count == 0) { newOrder.SetShipAddressNull(); newOrder.SetShipCityNull(); newOrder.SetShipCountryNull(); newOrder.SetShipPostalCodeNull(); } else { PostalAddressFeedEntry postadress = salesorder.postalAddresses.Entries[0]; newOrder.ShipAddress = postadress.address1; newOrder.ShipCity = postadress.townCity; newOrder.ShipPostalCode = postadress.zipPostCode; newOrder.ShipCountry = postadress.country; } if (!salesorder.IsPropertyChanged("carrierTotalPrice")) newOrder.Freight = (decimal)0; else newOrder.Freight = (decimal)salesorder.carrierTotalPrice; newOrder.CreateUser = _context.Config.CrmUser; newOrder.ModifyUser = _context.Config.CrmUser; newOrder.CreateID = _context.Config.SequenceNumber; newOrder.ModifyID = _context.Config.SequenceNumber; } catch (Exception e) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.ToString(); return tmpTransactionResult; } #endregion using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString)) { OleDbTransaction transaction = null; try { connection.Open(); transaction = connection.BeginTransaction(); tableAdapter = new Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.OrdersTableAdapter(); tableAdapter.Connection = connection; detailsTableAdapter = new Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.Order_DetailsTableAdapter(); detailsTableAdapter.Connection = connection; tableAdapter.SetTransaction(transaction); detailsTableAdapter.SetTransaction(transaction); order.Orders.AddOrdersRow(newOrder); tableAdapter.Update(order.Orders); OleDbCommand Cmd = new OleDbCommand("SELECT @@IDENTITY", connection); Cmd.Transaction = transaction; object lastid = Cmd.ExecuteScalar(); payload.Key = ((int)lastid).ToString(); // add line Items Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow detailRow; Hashtable addedProductsProducts; addedProductsProducts = new Hashtable(); int productID; int productIndex = 0; if (salesorder.salesOrderLines != null) { foreach (SalesOrderLineFeedEntry salesOrderLine in salesorder.salesOrderLines.Entries) { try { string productIdString = ""; productID = 0; if (salesOrderLine.commodity != null && salesOrderLine.commodity.UUID != null && salesOrderLine.commodity.UUID != Guid.Empty) { productIdString = GetLocalId(salesOrderLine.commodity.UUID, SupportedResourceKinds.commodities); if (!int.TryParse(productIdString, out productID)) productID = 0; } if (addedProductsProducts.Contains(productID)) { transaction.Rollback(); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = "Order contains a product twice"; return tmpTransactionResult; } addedProductsProducts.Add(productID, productID); detailRow = order.Order_Details.NewOrder_DetailsRow(); salesOrderLine.Key = payload.Key + "-" + productID.ToString(); detailRow.OrderID = Convert.ToInt32(payload.Key); detailRow.ProductID = productID; if (salesOrderLine.IsPropertyChanged("quantity")) detailRow.Quantity = Convert.ToInt16(salesOrderLine.quantity); else detailRow.Quantity = 0; if (salesOrderLine.IsPropertyChanged("initialPrice")) detailRow.UnitPrice = (Decimal)salesOrderLine.initialPrice; else detailRow.UnitPrice = 0; if ((!salesOrderLine.IsPropertyChanged("discountTotal")) || (detailRow.Quantity == 0) || (detailRow.UnitPrice == 0)) { detailRow.Discount = (float)0; } else { // discountPC = discountsum / qunatity * listprice //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice)); float discount = Convert.ToSingle((decimal)salesOrderLine.discountTotal / (detailRow.UnitPrice)); if (discount > 1) discount = 0; detailRow.Discount = discount; } detailRow.CreateUser = _context.Config.CrmUser; detailRow.ModifyUser = _context.Config.CrmUser; detailRow.CreateID = _context.Config.SequenceNumber; detailRow.ModifyID = _context.Config.SequenceNumber; } // this error occours in case of invalid data types catch (Exception e) { transaction.Rollback(); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.Message; return tmpTransactionResult; } order.Order_Details.AddOrder_DetailsRow(detailRow); productIndex++; } } // here could an error ouucour in case on broken database connection // or of same invalid constraints which are unhandled before try { detailsTableAdapter.Update(order.Order_Details); } catch (Exception e) { transaction.Rollback(); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.Message; return tmpTransactionResult; } transaction.Commit(); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.Created; tmpTransactionResult.LocalId = payload.Key; return tmpTransactionResult; } catch (Exception transactionException) { if (transaction != null) transaction.Rollback(); throw; } } }
private UnitOfMeasureFamilyDocument GetUOMFamilyDocument(Sage.Integration.Northwind.Application.Entities.Product.DataSets.Product.ProductsRow productRow, Token lastToken, NorthwindConfig config) { #region Declarations UnitOfMeasureFamilyDocument uomDoc; string identity; #endregion identity = productRow.ProductID.ToString(); // create Account Doc uomDoc = new UnitOfMeasureFamilyDocument(); uomDoc.Id = identity; if (lastToken.InitRequest) uomDoc.LogState = LogState.Created; else if (productRow.IsCreateIDNull() || productRow.IsModifyIDNull() || productRow.IsCreateUserNull() || productRow.IsModifyUserNull()) uomDoc.LogState = LogState.Created; else if ((productRow.CreateID > lastToken.SequenceNumber) && (productRow.CreateUser != config.CrmUser)) uomDoc.LogState = LogState.Created; else if ((productRow.CreateID == lastToken.SequenceNumber) && (productRow.CreateUser != config.CrmUser) && (identity.CompareTo(lastToken.Id.Id) > 0)) uomDoc.LogState = LogState.Created; else if ((productRow.ModifyID >= lastToken.SequenceNumber) && (productRow.ModifyUser != config.CrmUser)) uomDoc.LogState = LogState.Updated; uomDoc.active.Value = Constants.DefaultValues.Active; uomDoc.defaultvalue.Value = true; uomDoc.name.Value = productRow.IsQuantityPerUnitNull() ? null : productRow.QuantityPerUnit.ToString(); ; uomDoc.description.Value = uomDoc.name.Value; return uomDoc; }
public override Application.Base.Document GetTransformedDocument(Sage.Common.Syndication.FeedEntry payload) { throw new NotImplementedException(); }
protected override void OnMyDialogClosing(object from, Sage.Platform.WebPortal.Services.WebDialogClosingEventArgs e) { DialogService.DialogParameters.Clear(); IsClosing = true; base.OnMyDialogClosing(from, e); }
private Sage.Entity.Interfaces.IContact GetPrimaryContactFor(Sage.Entity.Interfaces.IAccount account) { Object result; IRepository<Sage.Entity.Interfaces.IContact> rep = Sage.Platform.EntityFactory.GetRepository<Sage.Entity.Interfaces.IContact>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); Sage.Platform.Repository.ICriteria crit = qry.CreateCriteria(); crit.Add(ep.Eq("Account", account)); crit.Add(ep.Eq("IsPrimary", true)); result = crit.UniqueResult<Sage.Entity.Interfaces.IContact>(); return (result != null) ? (Sage.Entity.Interfaces.IContact)result : null; }
private void GetExchageRateData(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType, out string exchangeRateCode, out double exchangeRate) { string _exchangeRateCode = string.Empty; double? _exchangeRate = 0.0; if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate) { IOpportunity opp = BindingSource.Current as IOpportunity; _exchangeRateCode = opp.ExchangeRateCode; _exchangeRate = opp.ExchangeRate; } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.MyRate) { _exchangeRateCode = BusinessRuleHelper.GetMyCurrencyCode(); IExchangeRate myExchangeRate = EntityFactory.GetById<IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); if (myExchangeRate != null) { _exchangeRate = myExchangeRate.Rate.GetValueOrDefault(1); } } if (exchangeRateType == Sage.Platform.Controls.ExchangeRateTypeEnum.BaseRate) { var optionSvc = ApplicationContext.Current.Services.Get<ISystemOptionsService>(true); _exchangeRateCode = optionSvc.BaseCurrency; IExchangeRate er = EntityFactory.GetById<IExchangeRate>(String.IsNullOrEmpty(_exchangeRateCode) ? "USD" : _exchangeRateCode); _exchangeRate = er.Rate.GetValueOrDefault(1); if (_exchangeRate.Equals(0)) { _exchangeRate = 1; } } exchangeRateCode = _exchangeRateCode; exchangeRate = Convert.ToDouble(_exchangeRate); }
private void SetPickListDefault(Sage.SalesLogix.Web.Controls.PickList.PickListControl plc) { if (plc.PickListValue == "") { PickList sv = PickList.GetPickListById(PickList.PickListIdFromName(plc.PickListName)); if (sv.Defaultindex.Value >= 0) { IList<PickList> vals = PickList.GetPickListItemsByName(plc.PickListName); plc.PickListValue = vals[sv.Defaultindex.Value].Text; } } }
private void EditActualAmount(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType) { if (DialogService != null) { IOpportunity entity = BindingSource.Current as IOpportunity; if (GetOpportunityStatusMatch(entity, "ClosedWon")) { DialogService.SetSpecs(200, 200, 400, 600, "OpportunityClosedWon", "", true); } else if (GetOpportunityStatusMatch(entity, "ClosedLost")) { DialogService.SetSpecs(200, 200, 400, 600, "OpportunityClosedLost", "", true); } else { DialogService.SetSpecs(200, 200, 200, 300, "UpdateSalesPotential", "", true); } if (BusinessRuleHelper.IsMultiCurrencyEnabled()) { string exchangeRateCode = string.Empty; double exchangeRate = 0.0; GetExchageRateData(exchangeRateType, out exchangeRateCode, out exchangeRate); DialogService.DialogParameters.Clear(); DialogService.DialogParameters.Add("ExchangeRateType", exchangeRateType); DialogService.DialogParameters.Add("ExchangeRateCode", exchangeRateCode); DialogService.DialogParameters.Add("ExchangeRate", exchangeRate); } DialogService.ShowDialog(); } }
private void EditSalesPotential(Sage.Platform.Controls.ExchangeRateTypeEnum exchangeRateType) { if (DialogService != null) { DialogService.SetSpecs(200, 400, "EditSalesPotential"); if (BusinessRuleHelper.IsMultiCurrencyEnabled()) { string exchangeRateCode = string.Empty; double exchangeRate = 0.0; GetExchageRateData(exchangeRateType, out exchangeRateCode, out exchangeRate); DialogService.DialogParameters.Clear(); DialogService.DialogParameters.Add("ExchangeRateType", exchangeRateType); DialogService.DialogParameters.Add("ExchangeRateCode", exchangeRateCode); DialogService.DialogParameters.Add("ExchangeRate", exchangeRate); } DialogService.ShowDialog(); } }
public override Application.Base.Document GetTransformedDocument(Sage.Common.Syndication.FeedEntry payload) { return _transform.GetTransformedDocument(payload as PostalAddressFeedEntry); }
public SdataTransactionResult Add(Sage.Common.Syndication.FeedEntry payload) { // until there is no reference inside the payload, no add will be possible throw new NotImplementedException(); }
public SdataTransactionResult Update(Sage.Common.Syndication.FeedEntry payload) { //Transform account Document document = GetTransformedDocument(payload); AccountDocument accountDocument = (AccountDocument)_entity.GetDocumentTemplate(); accountDocument.Id = document.Id; accountDocument.CrmId = GetTradingAccountUuid(document.Id); accountDocument.addresses.documents.Add(document); // Update Document List<TransactionResult> transactionResults = new List<TransactionResult>(); _entity.Update(accountDocument, _context.Config, ref transactionResults); SdataTransactionResult sdTrResult = GetSdataTransactionResult(transactionResults, _context.OriginEndPoint, SupportedResourceKinds.tradingAccounts); if (sdTrResult != null) { sdTrResult.ResourceKind = _resourceKind; sdTrResult.HttpMessage = "PUT"; } return sdTrResult; }
/// <summary> /// Sets the user option defaults. /// </summary> /// <param name="activity">The activity.</param> private void SetUserOptionDefaults(Sage.SalesLogix.Activity.Activity activity) { IUserOptionsService userOption = ApplicationContext.Current.Services.Get<IUserOptionsService>(); string alarmLeadUnit = userOption.GetCommonOption("AlarmDefaultLead", "ActivityAlarm"); string alarmLeadValue = userOption.GetCommonOption("AlarmDefaultLeadValue", "ActivityAlarm"); int alarmLeadMinutes = 15; //default if ((alarmLeadUnit != "") && (alarmLeadValue != "")) { try { alarmLeadMinutes = Convert.ToInt32(alarmLeadValue); } catch { alarmLeadMinutes = 15; } switch (alarmLeadUnit) { case "Days": alarmLeadMinutes = alarmLeadMinutes * 24 * 60; break; case "Hours": alarmLeadMinutes = alarmLeadMinutes * 60; break; } } activity.ReminderDuration = alarmLeadMinutes; }
public override SdataTransactionResult Update(Sage.Common.Syndication.FeedEntry payload) { SdataTransactionResult tmpTransactionResult; SalesOrderFeedEntry salesorder = null; #region check input values if (!(payload is SalesOrderFeedEntry)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder payload missing"); return tmpTransactionResult; } salesorder = (payload as SalesOrderFeedEntry); if (salesorder == null) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("salesorder payload missing"); return tmpTransactionResult; } string customerID = ""; if (salesorder.tradingAccount != null) customerID = GetLocalId(salesorder.tradingAccount.UUID, SupportedResourceKinds.tradingAccounts); if (String.IsNullOrEmpty(customerID)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("Trading Acount Id missing"); return tmpTransactionResult; } if (!customerID.StartsWith(Sage.Integration.Northwind.Application.API.Constants.CustomerIdPrefix)) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = ("Salesorder submission is only supported by customers"); return tmpTransactionResult; } #endregion Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.OrdersTableAdapter tableAdapter = new OrdersTableAdapter(); Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.OrderTableAdapters.Order_DetailsTableAdapter detailsTableAdapter = new Order_DetailsTableAdapter(); Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order order = new Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order(); int id; if (!(Int32.TryParse(payload.Key, out id))) id = 0; int recordCount; using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString)) { tableAdapter.Connection = connection; recordCount = tableAdapter.FillBy(order.Orders, id); if (recordCount == 0) return null; detailsTableAdapter.Connection = connection; detailsTableAdapter.FillBy(order.Order_Details, id); } Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.OrdersRow row = (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.OrdersRow)order.Orders[0]; #region fill dataset from document try { if (!salesorder.IsPropertyChanged("date")) row.SetOrderDateNull(); else row.OrderDate = salesorder.date; if (!salesorder.IsPropertyChanged("dueDate")) row.SetRequiredDateNull(); else row.RequiredDate = (DateTime)salesorder.dueDate; //if (orderDoc.shippedvia.IsNull) // newOrder.SetShipViaNull(); //else // newOrder.ShipVia = (int)orderDoc.shippedvia.Value; if (salesorder.postalAddresses == null || salesorder.postalAddresses.Entries.Count == 0) { row.SetShipAddressNull(); row.SetShipCityNull(); row.SetShipCountryNull(); row.SetShipPostalCodeNull(); } else { PostalAddressFeedEntry postadress = salesorder.postalAddresses.Entries[0]; row.ShipAddress = postadress.address1; row.ShipCity = postadress.townCity; row.ShipPostalCode = postadress.zipPostCode; row.ShipCountry = postadress.country; } if (!salesorder.IsPropertyChanged("carrierTotalPrice")) row.Freight = (decimal)0; else row.Freight = (decimal)salesorder.carrierTotalPrice; //row.CreateUser = _context.Config.CrmUser; row.ModifyUser = _context.Config.CrmUser; //row.CreateID = _context.Config.SequenceNumber; row.ModifyID = _context.Config.SequenceNumber; Guid itemUuid; List<Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow> rowsToDelete = new List<Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow>(); List<Guid> itemUuids = new List<Guid>(); if (salesorder.salesOrderLines != null) { foreach (SalesOrderLineFeedEntry soLine in salesorder.salesOrderLines.Entries) { if ((soLine.UUID != null && soLine.UUID != Guid.Empty) && (!itemUuids.Contains(soLine.UUID))) itemUuids.Add(soLine.UUID); } } foreach (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow detailsRow in order.Order_Details) { string itemId = detailsRow.OrderID.ToString() + "-" + detailsRow.ProductID.ToString(); itemUuid = GetUuid(itemId, "", SupportedResourceKinds.salesOrderLines); if (itemUuids.Contains(itemUuid)) { foreach (SalesOrderLineFeedEntry soLine in salesorder.salesOrderLines.Entries) { if (soLine.UUID.Equals(itemUuid)) { if (soLine.IsDeleted) { rowsToDelete.Add(detailsRow); break; } /*if (soLine.IsEmpty) { break; }*/ detailsRow.ModifyUser = _context.Config.CrmUser; detailsRow.ModifyID = _context.Config.SequenceNumber; if (soLine.IsPropertyChanged("quantity")) detailsRow.Quantity = Convert.ToInt16(soLine.quantity); else detailsRow.Quantity = 0; if (soLine.IsPropertyChanged("initialPrice")) detailsRow.UnitPrice = (Decimal)soLine.initialPrice; else detailsRow.UnitPrice = 0; if ((!soLine.IsPropertyChanged("discountTotal")) || (detailsRow.Quantity == 0) || (detailsRow.UnitPrice == 0)) { detailsRow.Discount = (float)0; } else { // discountPC = discountsum / qunatity * listprice //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice)); float discount = Convert.ToSingle((decimal)soLine.discountTotal / (detailsRow.UnitPrice)); if (discount > 1) discount = 0; detailsRow.Discount = discount; } break; } } itemUuids.Remove(itemUuid); } else { //delete item rowsToDelete.Add(detailsRow); } } if (salesorder.salesOrderLines != null) { foreach (SalesOrderLineFeedEntry soLine in salesorder.salesOrderLines.Entries) { Guid soUuid = soLine.UUID; if (itemUuids.Contains(soUuid)) itemUuids.Remove(soUuid); else continue; try { Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow detailRow = order.Order_Details.NewOrder_DetailsRow(); Guid productUuid = soLine.commodity.UUID; string productIdString = GetLocalId(productUuid, SupportedResourceKinds.commodities); int productID; if (!int.TryParse(productIdString, out productID)) continue; string sorderID = payload.Key + "-" + productID.ToString(); detailRow.OrderID = Convert.ToInt32(payload.Key); detailRow.ProductID = productID; if (soLine.IsPropertyChanged("quantity")) detailRow.Quantity = Convert.ToInt16(soLine.quantity); else detailRow.Quantity = 0; if (soLine.IsPropertyChanged("initialPrice")) detailRow.UnitPrice = (Decimal)soLine.initialPrice; else detailRow.UnitPrice = 0; if ((!soLine.IsPropertyChanged("discountTotal")) || (detailRow.Quantity == 0) || (detailRow.UnitPrice == 0)) { detailRow.Discount = (float)0; } else { // discountPC = discountsum / qunatity * listprice //detailRow.Discount = Convert.ToSingle((decimal)lineItemDoc.discountsum.Value / ((decimal)detailRow.Quantity * detailRow.UnitPrice)); float discount = Convert.ToSingle((decimal)soLine.discountTotal / (detailRow.UnitPrice)); if (discount > 1) discount = 0; detailRow.Discount = discount; } detailRow.CreateUser = _context.Config.CrmUser; detailRow.ModifyUser = _context.Config.CrmUser; detailRow.CreateID = _context.Config.SequenceNumber; detailRow.ModifyID = _context.Config.SequenceNumber; order.Order_Details.AddOrder_DetailsRow(detailRow); } // this error occours in case of invalid data types catch (Exception e) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.POST; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.Message; return tmpTransactionResult; } } } using (OleDbConnection connection = new OleDbConnection(_context.Config.ConnectionString)) { OleDbTransaction transaction = null; try { connection.Open(); transaction = connection.BeginTransaction(); tableAdapter.Connection = connection; detailsTableAdapter.Connection = connection; tableAdapter.SetTransaction(transaction); detailsTableAdapter.SetTransaction(transaction); foreach (Sage.Integration.Northwind.Adapter.Data.SalesOrders.DataSets.Order.Order_DetailsRow detailsRow in rowsToDelete) { detailsTableAdapter.Delete(detailsRow.OrderID, detailsRow.ProductID, detailsRow.UnitPrice, detailsRow.Quantity, detailsRow.Discount, detailsRow.CreateID, detailsRow.CreateUser, detailsRow.ModifyID, detailsRow.ModifyUser); } tableAdapter.Update(order.Orders); detailsTableAdapter.Update(order.Order_Details); transaction.Commit(); tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.OK; tmpTransactionResult.LocalId = payload.Key; return tmpTransactionResult; } catch (Exception transactionException) { if (transaction != null) transaction.Rollback(); throw; } } } catch (Exception e) { tmpTransactionResult = new SdataTransactionResult(); tmpTransactionResult.HttpMethod = HttpMethod.PUT; tmpTransactionResult.ResourceKind = _resourceKind; tmpTransactionResult.HttpStatus = System.Net.HttpStatusCode.BadRequest; tmpTransactionResult.HttpMessage = e.ToString(); return tmpTransactionResult; } #endregion }