private static Texture2d ParseMaterialTexture(ObjContext objContext, ObjMaterial objMaterial, string[] commandTokens) { string textureFileName = commandTokens[commandTokens.Length - 1]; string textureFilePath = Path.Combine(Path.GetDirectoryName(objContext.Path), textureFileName); try { Image textureImage = ImageCodec.Instance.Load(textureFilePath); Texture2d texture = new Texture2d(); texture.Create(textureImage); texture.GenerateMipmaps(); return(texture); } catch (Exception exception) { throw new InvalidOperationException(String.Format("unable to load texture {0}", textureFileName), exception); } }
/// <summary> /// Load media from stream. /// </summary> /// <param name="stream"> /// A <see cref="Stream"/> where the media data is stored. /// </param> /// <param name="criteria"> /// A <see cref="MediaCodecCriteria"/> that specify parameters for loading an media stream. /// </param> /// <returns> /// An <see cref="SceneObject"/> holding the media data. /// </returns> /// <exception cref="ArgumentNullException"> /// Exception thrown if <paramref name="stream"/> or <paramref name="criteria"/> is null. /// </exception> public SceneObject Load(Stream stream, SceneObjectCodecCriteria criteria) { if (stream == null) { throw new ArgumentNullException("stream"); } if (criteria == null) { throw new ArgumentNullException("criteria"); } // Load OBJ information ObjContext objContext = LoadOBJ(stream, criteria); // Process OBJ information return(ProcessOBJ(objContext)); }
protected void OnlnkEditCapacityClick(object sender, EventArgs e) { try { foreach (GridDataItem item in WeeklyPiecesSummaryRedGrid.Items) { var txtCapacity = (TextBox)item.FindControl("txtCapacity"); var txtHolidays = (TextBox)item.FindControl("txtHolidays"); var txtSalesTarget = (TextBox)item.FindControl("txtSalesTarget"); var linkEditCapacity = (LinkButton)item.FindControl("linkEditCapacity"); var pcid = int.Parse(linkEditCapacity.Attributes["pcid"]); if (pcid <= 0 || txtCapacity == null || txtHolidays == null) { continue; } using (var ts = new TransactionScope()) { var objWeeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext) { ID = pcid }; objWeeklyProductionCapacity.GetObject(); var capacity = txtCapacity.Text.Replace(",", ""); objWeeklyProductionCapacity.Capacity = int.Parse(capacity); objWeeklyProductionCapacity.NoOfHolidays = int.Parse(txtHolidays.Text); objWeeklyProductionCapacity.SalesTarget = decimal.Parse(txtSalesTarget.Text); ObjContext.SaveChanges(); ts.Complete(); } } } catch (Exception ex) { IndicoLogging.log.Error("Error occurred while editing weekly capacity and weekly holidays in ViewWeeklyCpacities.aspx", ex); } PopulateDataGrid(); }
private static void ParseVertex(ObjContext objContext, string[] token) { if (objContext == null) { throw new ArgumentNullException("objContext"); } if (token == null) { throw new ArgumentNullException("token"); } if (token.Length < 3) { throw new ArgumentException("array too short", "token"); } float[] values = Array.ConvertAll(token, delegate(string item) { return(Single.Parse(item, NumberFormatInfo.InvariantInfo)); }); objContext.Vertices.Add(new Vertex4f(values[0], values[1], values[2], values.Length > 3 ? values[3] : 1.0f)); }
private static void ParseTexCoord(ObjContext objContext, string[] token) { if (objContext == null) { throw new ArgumentNullException("objContext"); } if (token == null) { throw new ArgumentNullException("token"); } if (token.Length < 2) { throw new ArgumentException("wrong array length", "token"); } float[] values = Array.ConvertAll(token, delegate(string item) { return(Single.Parse(item, NumberFormatInfo.InvariantInfo)); }); objContext.TextureCoords.Add(new Vertex2f(values[0], values[1])); }
private static void ParseMaterialLib(ObjContext objContext, string[] token) { if (objContext == null) { throw new ArgumentNullException("objContext"); } if (token == null) { throw new ArgumentNullException("token"); } if (token.Length != 1) { throw new ArgumentException("array too short", "token"); } string directoryPath = Path.GetDirectoryName(objContext.Path); string materialLibPath = Path.Combine(directoryPath, token[0]); using (FileStream fs = new FileStream(materialLibPath, FileMode.Open, FileAccess.Read)) { ParseMaterialLibFile(fs, objContext); } }
private static void ParseMaterialLibFile(Stream stream, ObjContext objContext) { using (StreamReader sr = new StreamReader(stream)) { string objLine; while ((objLine = sr.ReadLine()) != null) { // Trim spaces objLine = objLine.Trim(); // Skip empty lines and comments if (objLine.Length == 0 || _CommentLine.IsMatch(objLine)) { continue; } Match commandMatch = _MtlCommandLine.Match(objLine); if (commandMatch.Success == false) { continue; } string command = commandMatch.Groups["Command"].Value; string tokens = commandMatch.Groups["Tokens"].Value.Trim(); string[] token = Regex.Split(tokens, " +"); switch (command) { case "newmtl": ParseMaterial(sr, objContext, token); break; default: throw new InvalidOperationException(String.Format("unknown OBJ/MTL command {0}", command)); } } } }
private void ChangeOrderStatus(int QuoteID) { try { if (QuoteID > 0) { using (TransactionScope ts = new TransactionScope()) { QuoteBO objQuote = new QuoteBO(this.ObjContext); objQuote.ID = QuoteID; objQuote.GetObject(); objQuote.Status = 4; ObjContext.SaveChanges(); ts.Complete(); } } } catch (Exception ex) { IL.log.Error("Error occured while updating quote table in CheckQuote", ex); } }
protected void btnDelete_Click(object sender, EventArgs e) { int invoiceID = int.Parse(hdnSelectedID.Value.Trim()); if (invoiceID > 0) { try { using (TransactionScope ts = new TransactionScope()) { InvoiceBO objInvoice = new InvoiceBO(ObjContext); objInvoice.ID = invoiceID; objInvoice.GetObject(); List <InvoiceOrderBO> lstInvoiceOrder = (new InvoiceOrderBO()).GetAllObject().Where(o => o.Invoice == objInvoice.ID).ToList(); foreach (InvoiceOrderBO objDelInvoiceOrder in lstInvoiceOrder) { InvoiceOrderBO objInvoiceOrder = new InvoiceOrderBO(ObjContext); objInvoiceOrder.ID = objDelInvoiceOrder.ID; objInvoiceOrder.GetObject(); objInvoiceOrder.Delete(); } objInvoice.Delete(); ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { throw ex; } PopulateDataGrid(); } }
private static void ParseMaterial(StreamReader sr, ObjContext objContext, string[] token) { ObjMaterial objMaterial = new ObjMaterial(token[0]); string objLine; while ((objLine = sr.ReadLine()) != null) { // Trim spaces objLine = objLine.Trim(); // Skip comments if (_CommentLine.IsMatch(objLine)) { continue; } // Stop material parsing on empty line // Note: is this robust enought? I don't think so. if (objLine.Length == 0) { break; } Match commandMatch = _MtlParamLine.Match(objLine); if (commandMatch.Success == false) { continue; } string command = commandMatch.Groups["Command"].Value; string commandToken = commandMatch.Groups["Tokens"].Value.Trim(); string[] commandTokens = Regex.Split(commandToken, " +"); switch (command) { case "Ka": // Ambient objMaterial.Ambient = ParseMaterialColor(objMaterial, commandTokens); break; case "Kd": // Diffuse objMaterial.Diffuse = ParseMaterialColor(objMaterial, commandTokens); break; case "Ks": // Specular objMaterial.Specular = ParseMaterialColor(objMaterial, commandTokens); break; case "Tf": // Transmission Filter break; case "illum": // Illumination model break; case "d": // Dissolve factor break; case "Ns": // Specular exponent objMaterial.SpecularExponent = Single.Parse(commandTokens[0]); break; case "sharpness": // Reflection sharpness break; case "Ni": // Index of refrection break; case "map_Ka": objMaterial.AmbientTexture = ParseMaterialTexture(objContext, objMaterial, commandTokens); break; case "map_Kd": objMaterial.DiffuseTexture = ParseMaterialTexture(objContext, objMaterial, commandTokens); break; case "map_Ks": objMaterial.SpecularTexture = ParseMaterialTexture(objContext, objMaterial, commandTokens); break; case "map_d": case "map_Ns": case "map_aat": case "decal": case "disp": case "bump": case "refl": default: // Ignore break; // Custom case "map_n": objMaterial.NormalTexture = ParseMaterialTexture(objContext, objMaterial, commandTokens); break; } } // Collect material objContext.Materials.Add(objMaterial.Name, objMaterial); }
private static void ParseFace(ObjContext objContext, string[] token) { if (objContext == null) { throw new ArgumentNullException("objContext"); } if (token == null) { throw new ArgumentNullException("token"); } if (token.Length < 3) { throw new ArgumentException("wrong array length", "token"); } if (objContext.Groups.Count == 0) { throw new InvalidOperationException("no group"); } ObjGroup objGroup = objContext.Groups[objContext.Groups.Count - 1]; if (objGroup.Geometries.Count == 0) { throw new InvalidOperationException("no geometry"); } ObjGeometry objGeometry = objGroup.Geometries[objGroup.Geometries.Count - 1]; ObjFace objFace = new ObjFace(); foreach (string values in token) { string[] indices = Regex.Split(values, "/"); int[] indicesValues = Array.ConvertAll(indices, delegate(string item) { if (String.IsNullOrEmpty(item) == false) { return(Int32.Parse(item, NumberFormatInfo.InvariantInfo)); } else { return(Int32.MinValue); } }); int indexVertex = indicesValues[0]; int indexNormal = indicesValues[2]; int indexTexCoord = indicesValues[1]; ObjFaceCoord objFaceCoord = new ObjFaceCoord(); // Position if (indexVertex < 0) { indexVertex = objContext.Vertices.Count + indexVertex + 1; } objFaceCoord.VertexIndex = indexVertex - 1; // Normal (optional) if (indexNormal != Int32.MinValue) { if (indexNormal < 0) { indexNormal = objContext.Normals.Count + indexNormal + 1; } objFaceCoord.NormalIndex = indexNormal - 1; } // Tex coord (optional) if (indexTexCoord != Int32.MinValue) { if (indexTexCoord < 0) { indexTexCoord = objContext.TextureCoords.Count + indexTexCoord + 1; } objFaceCoord.TexCoordIndex = indexTexCoord - 1; } objFace.Coords.Add(objFaceCoord); } objGeometry.Faces.Add(objFace); }
protected void btnDelete_Click(object sender, EventArgs e) { int id = int.Parse(hdnSelectedID.Value); string type = this.hdnType.Value; if (type == "distributor") { PriceListDownloadsBO objPriceListDownload = new PriceListDownloadsBO(this.ObjContext); objPriceListDownload.ID = id; objPriceListDownload.GetObject(); string filePath = String.Format("{0}{1}", (IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\PriceLists\"), objPriceListDownload.FileName); if (File.Exists(filePath)) { File.Delete(filePath); try { using (TransactionScope ts = new TransactionScope()) { objPriceListDownload.Delete(); ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting distrinutor price list", ex); } } } if (type == "label") { LabelPriceListDownloadsBO objLabelPriceListDownload = new LabelPriceListDownloadsBO(this.ObjContext); objLabelPriceListDownload.ID = id; objLabelPriceListDownload.GetObject(); string filePath = String.Format("{0}{1}", (IndicoConfiguration.AppConfiguration.PathToDataFolder + @"\PriceLists\"), objLabelPriceListDownload.FileName); if (File.Exists(filePath)) { File.Delete(filePath); try { using (TransactionScope ts = new TransactionScope()) { objLabelPriceListDownload.Delete(); ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while deleting label price list", ex); } } } this.PopulateControls(); }
private void AddNextYear() { using (var scope = new TransactionScope()) { var currentYear = DateTime.Now.Year; var currentWeeks = new WeeklyProductionCapacityBO(ObjContext).GetAllObject(); if (currentWeeks.Any()) { if (currentWeeks.Count > 1) { var lastWeek = currentWeeks.OrderBy(w => w.WeekendDate).Last().WeekendDate; currentYear = lastWeek.Year == currentWeeks[currentWeeks.Count() - 2].WeekendDate.Year ? lastWeek.AddYears(1).Year : lastWeek.Year; } else { currentYear = currentWeeks.Last().WeekendDate.AddYears(1).Year; } } var currentYearStartDate = new DateTime(currentYear, 1, 1); while (currentYearStartDate.DayOfWeek != DayOfWeek.Tuesday) { currentYearStartDate = currentYearStartDate.AddDays(1); } var weekNumber = 1; while (currentYearStartDate.Year == currentYear) { var weeklyProductionCapacity = new WeeklyProductionCapacityBO(ObjContext) { WeekNo = weekNumber, WeekendDate = currentYearStartDate, SalesTarget = 0, HoursPerDay = (decimal)10.0, NoOfHolidays = 6, OrderCutOffDate = currentYearStartDate.AddDays(-18), EstimatedDateOfDespatch = currentYearStartDate, EstimatedDateOfArrival = currentYearStartDate.AddDays(3) }; weeklyProductionCapacity.Add(); var polodetails = new WeeklyProductionCapacityDetailsBO(ObjContext) { ItemType = 1, TotalCapacity = 5850, FivePcsCapacity = 100, SampleCapacity = 200, Workers = 65, Efficiency = (decimal)0.45 }; var outerwaredetails = new WeeklyProductionCapacityDetailsBO(ObjContext) { ItemType = 2, TotalCapacity = 450, FivePcsCapacity = 10, SampleCapacity = 20, Workers = 15, Efficiency = (decimal)0.25 }; weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(polodetails); weeklyProductionCapacity.WeeklyProductionCapacityDetailssWhereThisIsWeeklyProductionCapacity.Add(outerwaredetails); currentYearStartDate = currentYearStartDate.AddDays(7); weekNumber++; } ObjContext.SaveChanges(); scope.Complete(); } PopulateDataGrid(); //try //{ // using (var ts = new TransactionScope()) // { // var currentYear = DateTime.Now.Year.ToString(); // bool isLeap = false; // List<WeeklyProductionCapacityBO> lstWeeklyProdCap = (new WeeklyProductionCapacityBO()).SearchObjects(); // if (lstWeeklyProdCap.Count > 0) // { // currentYear = lstWeeklyProdCap.Last().WeekendDate.AddYears(1).Year.ToString(); // } // DateTime dFirst = DateTime.Parse("01 / 01 /" + currentYear); // DateTime dLast = DateTime.Parse("31 / 12 /" + currentYear); // if ((int.Parse(currentYear) % 4 == 0) && (int.Parse(currentYear) % 100 != 0) || (int.Parse(currentYear) % 400 == 0)) // { // isLeap = true; // } // int weekCount = (isLeap == true) ? this.GetWeeksInYear(int.Parse(currentYear), dLast) : int.Parse((dLast.Subtract(dFirst).Days / 7).ToString()); // //int id = this.GetWeeksInYear(int.Parse(currentYear), dLast); // DateTime firstTuesday = dFirst; // while (firstTuesday.DayOfWeek != DayOfWeek.Tuesday) // { // firstTuesday = firstTuesday.AddDays(1); // } // for (int i = 1; i <= weekCount; i++) // { // WeeklyProductionCapacityBO objProductionCapacity = new WeeklyProductionCapacityBO(this.ObjContext); // objProductionCapacity.WeekNo = i; // objProductionCapacity.WeekendDate = firstTuesday; // objProductionCapacity.Capacity = 0; // objProductionCapacity.Add(); // firstTuesday = firstTuesday.AddDays(7); // } // this.ObjContext.SaveChanges(); // ts.Complete(); // } //} //catch (Exception) //{ // //ignored //} }
private void ProcessForm(int queryId, bool isDelete) { try { using (var ts = new TransactionScope()) { var objProductionCapacity = new WeeklyProductionCapacityBO(ObjContext); if (queryId > 0) { objProductionCapacity.ID = queryId; objProductionCapacity.GetObject(); } if (isDelete) { objProductionCapacity.Delete(); } else { objProductionCapacity.NoOfHolidays = int.Parse(txtWorkingDays.Text); objProductionCapacity.HoursPerDay = decimal.Parse(txtWorkingHours.Text); objProductionCapacity.OrderCutOffDate = DateTime.Parse(txtOrderCutOffDate.Text); objProductionCapacity.EstimatedDateOfDespatch = DateTime.Parse(txtETD.Text); objProductionCapacity.EstimatedDateOfArrival = DateTime.Parse(txtETA.Text); objProductionCapacity.Notes = txtNotes.Text; objProductionCapacity.SalesTarget = decimal.Parse(txtSalesTaget.Text); foreach (RepeaterItem rptItem in rptItemTypes.Items) { var hdnProdCapDetailID = (HiddenField)rptItem.FindControl("hdnProdCapDetailID"); var hdnItemTypeID = (HiddenField)rptItem.FindControl("hdnItemTypeID"); var txtTotalCapacity = (TextBox)rptItem.FindControl("txtTotalCapacity"); var txt5PcsCapacity = (TextBox)rptItem.FindControl("txt5PcsCapacity"); var txtSampleCapacity = (TextBox)rptItem.FindControl("txtSampleCapacity"); var txtWorkers = (TextBox)rptItem.FindControl("txtWorkers"); var txtEfficiency = (TextBox)rptItem.FindControl("txtEfficiency"); var objProdCapDetailBO = new WeeklyProductionCapacityDetailsBO(ObjContext); if (int.Parse(hdnProdCapDetailID.Value) > 0) { objProdCapDetailBO.ID = int.Parse(hdnProdCapDetailID.Value); objProdCapDetailBO.GetObject(); } else { objProdCapDetailBO.WeeklyProductionCapacity = queryId; objProdCapDetailBO.ItemType = int.Parse(hdnItemTypeID.Value); } objProdCapDetailBO.TotalCapacity = int.Parse(txtTotalCapacity.Text) * objProductionCapacity.NoOfHolidays; objProdCapDetailBO.FivePcsCapacity = int.Parse(txt5PcsCapacity.Text) * objProductionCapacity.NoOfHolidays; objProdCapDetailBO.SampleCapacity = int.Parse(txtSampleCapacity.Text) * objProductionCapacity.NoOfHolidays; objProdCapDetailBO.Workers = int.Parse(txtWorkers.Text); objProdCapDetailBO.Efficiency = decimal.Parse(txtEfficiency.Text); } if (queryId == 0) { objProductionCapacity.Add(); } } ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occurred while Adding or Editing or Deleting the details in Production Capacity", ex); } }
public StudentRepository(IOptions <Settings> setting) { _context = new ObjContext(setting); }
private static ObjContext LoadOBJ(Stream stream, SceneObjectCodecCriteria criteria) { FileStream fileStream = stream as FileStream; if (fileStream == null) { throw new InvalidOperationException("only FileStream are supported"); } ObjContext objContext = new ObjContext(fileStream.Name); using (StreamReader sr = new StreamReader(stream)) { string objLine; while ((objLine = sr.ReadLine()) != null) { // Trim spaces objLine = objLine.Trim(); // Skip empty lines and comments if (objLine.Length == 0 || _CommentLine.IsMatch(objLine)) { continue; } Match commandMatch = _ObjCommandLine.Match(objLine); if (commandMatch.Success == false) { continue; } string command = commandMatch.Groups["Command"].Value; string tokens = commandMatch.Groups["Tokens"].Value.Trim(); string[] token = Regex.Split(tokens, " +"); switch (command) { case "mtllib": ParseMaterialLib(objContext, token); break; case "usemtl": if (objContext.Groups.Count == 0) { break; } ObjMaterial objMaterial; if (objContext.Materials.TryGetValue(token[0], out objMaterial) == false) { throw new InvalidOperationException(String.Format("unknown material '{0}'", token[0])); } objContext.Groups[objContext.Groups.Count - 1].Geometries.Add(new ObjGeometry(objMaterial)); break; case "v": ParseVertex(objContext, token); break; case "vn": ParseNormal(objContext, token); break; case "vt": ParseTexCoord(objContext, token); break; case "f": ParseFace(objContext, token); break; case "s": // ? break; case "g": if (token.Length < 1) { throw new InvalidOperationException(); } objContext.Groups.Add(new ObjGroup(token[0])); break; case "vl": case "vp": // Ignored break; default: throw new InvalidOperationException(String.Format("unknown OBJ command {0}", command)); } } } return(objContext); }
public VertexArrays CreateArrays(ObjContext objContext) { if (objContext == null) { throw new ArgumentNullException("objContext"); } VertexArrays vertexArray = new VertexArrays(); List <ObjFaceCoord> coords = new List <ObjFaceCoord>(); bool hasTexCoord = Material.DiffuseTexture != null; bool hasNormals = false; bool hasTanCoord = hasTexCoord && Material.NormalTexture != null; foreach (ObjFace f in Faces) { hasTexCoord |= f.HasTexCoord; hasNormals |= f.HasNormal; coords.AddRange(f.Triangulate()); } uint vertexCount = (uint)coords.Count; Vertex4f[] position = new Vertex4f[vertexCount]; Vertex3f[] normal = hasNormals ? new Vertex3f[vertexCount] : null; Vertex2f[] texcoord = new Vertex2f[vertexCount]; for (int i = 0; i < position.Length; i++) { Debug.Assert(coords[i].VertexIndex < objContext.Vertices.Count); position[i] = objContext.Vertices[coords[i].VertexIndex]; if (hasTexCoord) { Debug.Assert(coords[i].TexCoordIndex < objContext.TextureCoords.Count); texcoord[i] = objContext.TextureCoords[coords[i].TexCoordIndex]; } if (hasNormals) { Debug.Assert(coords[i].NormalIndex < objContext.Normals.Count); normal[i] = objContext.Normals[coords[i].NormalIndex]; } } // Position (mandatory) ArrayBuffer <Vertex4f> positionBuffer = new ArrayBuffer <Vertex4f>(); positionBuffer.Create(position); vertexArray.SetArray(positionBuffer, VertexArraySemantic.Position); // Layout (triangles) vertexArray.SetElementArray(PrimitiveType.Triangles); // Texture if (hasTexCoord) { ArrayBuffer <Vertex2f> texCoordBuffer = new ArrayBuffer <Vertex2f>(); texCoordBuffer.Create(texcoord); vertexArray.SetArray(texCoordBuffer, VertexArraySemantic.TexCoord); } // Normals if (hasNormals) { ArrayBuffer <Vertex3f> normalBuffer = new ArrayBuffer <Vertex3f>(); normalBuffer.Create(normal); vertexArray.SetArray(normalBuffer, VertexArraySemantic.Normal); } else { ArrayBuffer <Vertex3f> normalBuffer = new ArrayBuffer <Vertex3f>(); normalBuffer.Create(vertexCount); vertexArray.SetArray(normalBuffer, VertexArraySemantic.Normal); // XXX vertexArray.GenerateNormals(); } // Tangents if (hasTanCoord) { ArrayBuffer <Vertex3f> tanCoordBuffer = new ArrayBuffer <Vertex3f>(); tanCoordBuffer.Create(vertexCount); vertexArray.SetArray(tanCoordBuffer, VertexArraySemantic.Tangent); ArrayBuffer <Vertex3f> bitanCoordBuffer = new ArrayBuffer <Vertex3f>(); bitanCoordBuffer.Create(vertexCount); vertexArray.SetArray(bitanCoordBuffer, VertexArraySemantic.Bitangent); // XXX vertexArray.GenerateTangents(); } return(vertexArray); }
private int ProcessForm() { int distributor = 0; try { using (TransactionScope ts = new TransactionScope()) { CompanyBO objDistributor = new CompanyBO(this.ObjContext); if (this.QueryID > 0) { objDistributor.ID = this.QueryID; objDistributor.GetObject(); } else { objDistributor.Creator = this.LoggedUser.ID; objDistributor.CreatedDate = DateTime.Now; objDistributor.IsActive = true; objDistributor.IsDelete = false; } objDistributor.Modifier = this.LoggedUser.ID; objDistributor.ModifiedDate = DateTime.Now; objDistributor.Type = 4; //Distributor objDistributor.IsDistributor = true; objDistributor.Name = this.txtName.Text; objDistributor.NickName = this.txtNickName.Text; objDistributor.Number = this.txtCompanyNumber.Text; objDistributor.Address1 = this.txtAddress1.Text; objDistributor.Address2 = this.txtAddress2.Text; objDistributor.City = this.txtCity.Text; objDistributor.State = this.txtState.Text; objDistributor.Postcode = this.txtPostalCode.Text; objDistributor.Country = int.Parse(this.ddlCountry.SelectedValue); objDistributor.Phone1 = this.txtPhoneNo1.Text; objDistributor.Phone2 = this.txtPhoneNo2.Text; objDistributor.Fax = this.txtFaxNo.Text; //objDistributor.Email = this.txtEmailAddress.Text; objDistributor.Coordinator = int.Parse(ddlCoordinator.SelectedValue); //objDistributor.SecondaryCoordinator = int.Parse(this.ddlSecondaryCoordinator.SelectedValue); objDistributor.IsBackOrder = this.chkBackOrder.Checked; objDistributor.IsActive = this.chkIsActive.Checked; ObjContext.SaveChanges(); //distributor = objDistributor.ID; //var objDca = new DistributorClientAddressBO() //{ // CompanyName = "TBA", // Address = "TBA", // Suburb = "TBA", // PostCode = "TBA", // Country = 14, // ContactName = "TBA", // ContactPhone = "TBA", // State = "TBA", // EmailAddress = "TBA", // AddressType = 0, // Distributor = objDistributor.ID, // IsAdelaideWarehouse = false //}; //objDca.Add(); //ObjContext.SaveChanges(); //UserBO objUser = null; //if (this.QueryID == 0) //{ // objUser = new UserBO(this.ObjContext); // objUser.Company = distributor; // objUser.IsDistributor = true; // objUser.Status = 3; //Invited // objUser.Username = this.txtEmailAddress.Text; // objUser.Password = UserBO.GetNewEncryptedRandomPassword(); // objUser.GivenName = this.txtGivenName.Text; // objUser.FamilyName = this.txtFamilyName.Text; // objUser.EmailAddress = this.txtEmailAddress.Text; // objUser.Creator = this.LoggedUser.ID; // objUser.CreatedDate = DateTime.Now; // objUser.HomeTelephoneNumber = this.txtPhoneNo1.Text; // objUser.OfficeTelephoneNumber = this.txtPhoneNo2.Text; // objUser.Modifier = this.LoggedUser.ID; // objUser.ModifiedDate = DateTime.Now; // objUser.Guid = Guid.NewGuid().ToString(); // RoleBO objRole = new RoleBO(this.ObjContext); // objRole.ID = 10; // Distributor Administrator // objRole.GetObject(); // objUser.UserRolesWhereThisIsUser.Add(objRole); // objUser.CompanysWhereThisIsOwner.Add(objDistributor); // this.ObjContext.SaveChanges(); // //Send Invitation Email // string hosturl = IndicoConfiguration.AppConfiguration.SiteHostAddress + "/"; // string emailcontent = String.Format("<p>A new acoount set up for u at <a href =\"http://{0}\">\"http://{0}/</a></p>" + // "<p>To complete your registration simply clik the link below to sign in<br>" + // "<a href=\"http://{0}Welcome.aspx?guid={1}&id={2}\">http://{0}Welcome.aspx?guid={1}&id={2}</a></p>", // hosturl, objUser.Guid, objUser.ID.ToString()); // IndicoEmail.SendMailNotifications(this.LoggedUser, objUser, "Activate Your New Account", emailcontent); //} //else //{ // if (!objDistributor.Name.Contains("BLACKCHROME")) // { // objUser = new UserBO(this.ObjContext); // objUser.ID = (int)objDistributor.Owner; // objUser.GetObject(); // objUser.GivenName = this.txtGivenName.Text; // objUser.FamilyName = this.txtFamilyName.Text; // objUser.EmailAddress = this.txtEmailAddress.Text; // ObjContext.SaveChanges(); // } //} ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while send Distributor email", ex); } return(distributor); }
/// <summary> /// Připojí entitu na sledování /// </summary> /// <param name="entity">Entita která se má začít sledovat</param> public virtual void Attach(T entity) { ObjContext.AttachTo(EntitySetName, entity); }