private void button_Add_Click(object sender, EventArgs e) { string name = textBox1_Ime.Text; string lastname = textBox2_Familia.Text; string pass = textBox_Password.Text; User newUser = new User(); newUser.First_Name = name; newUser.Last_Name = lastname; newUser.Password = pass; using (var context = new Entities()) { var user1 = new User() { First_Name = name, Last_Name = lastname, Password = pass, UserID=Guid.NewGuid() }; context.AddToUsers(user1); context.SaveChanges(); dataGridView1.DataSource = context.Users; } }
public ActionResult Login(BL.User _User, string returnUrl) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, // Ticket Version _User.UserName, // username associated with ticket DateTime.Now, // Date/Time issued DateTime.Now.AddMinutes(30), // Date/Time to expire false, // Cookie is persistant or not _User.Documenttyp, // we can also store user role FormsAuthentication.FormsCookiePath); // Path cookie valid for if (_User.UserName != null) { if (_User.Password != null) { Service = BL.OrganizationUtility.GetCRMService(); BL.User _verifiedUser = PortalRepository.AuthenticateUser(_User.UserName, _User.Password, _User.Documenttyp, Service); if (_verifiedUser != null) { if (_verifiedUser.UserId != Guid.Empty) { string hashTicket = FormsAuthentication.Encrypt(ticket); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashTicket); Response.Cookies.Add(authCookie); BL.CurrentUser _cuser = new BL.CurrentUser(_verifiedUser); BL.CurrentUser.Instance.VerifiedUser = _verifiedUser; string name = BL.CurrentUser.Instance.VerifiedUser.UserName; if (Url.IsLocalUrl(returnUrl) && !string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("DocumentNotes", "Document")); } } else { _User.lstDocumentType = GetDocumentType(); } ModelState.AddModelError("", "Invalid Username or Password"); } else { _User.lstDocumentType = GetDocumentType(); ModelState.AddModelError("", "Please Enter Password"); } } else { _User.lstDocumentType = GetDocumentType(); ModelState.AddModelError("", "Please Enter Username"); } return(View(_User)); }
public ActionResult Login(string returnUrl) { #region Image To Text Test //var testImagePath = "~/App_Data/IMG-20171220-WA0005.jpg"; //var dataPath = "\\App_Data\\test.txt"; //try //{ // using (var tEngine = new TesseractEngine(dataPath, "eng", EngineMode.Default)) //creating the tesseract OCR engine with English as the language // { // using (var img = Pix.LoadFromFile(testImagePath)) // Load of the image file from the Pix object which is a wrapper for Leptonica PIX structure // { // using (var page = tEngine.Process(img)) //process the specified image // { // var text = page.GetText(); //Gets the image's content as plain text. // Console.WriteLine(text); //display the text // Console.WriteLine(page.GetMeanConfidence()); //Get's the mean confidence that as a percentage of the recognized text. // Console.ReadKey(); // } // } // } //} //catch (Exception e) //{ // Console.WriteLine("Unexpected Error: " + e.Message); //} #endregion //return Redirect("~/theme/ErrorPage.html"); BL.User Data = new BL.User(); Data.lstDocumentType = null; Data.Documenttyp = null; //string Filapath = @"C:\Users\Sai\Desktop\nuance\1.png"; //AL.Class1 obj = new AL.Class1(); //var result = obj.GetResult(Filapath); ViewBag.ReturnUrl = returnUrl; if (!HttpContext.User.Identity.IsAuthenticated || BL.CurrentUser.Instance == null) { return(View(Data)); } return(View(Data)); }
public static BL.User AuthenticateUser(string pUserName, string pPassword, string DocumentType, IOrganizationService CrmService) { Entity PortalUser = GetAuthenticateUser(pUserName, pPassword, CrmService); if (PortalUser != null) { string TimeZoneCode = ""; if (PortalUser.Attributes.Contains("mhl_timezone")) { TimeZoneCode = Convert.ToString(PortalUser.Attributes["mhl_timezone"]); } EntityCollection TimeZoneDef = null; if (TimeZoneCode != string.Empty) { var qe = new QueryExpression("timezonedefinition"); qe.ColumnSet = new ColumnSet("standardname"); qe.Criteria.AddCondition("timezonecode", ConditionOperator.Equal, TimeZoneCode); TimeZoneDef = CrmService.RetrieveMultiple(qe); } BL.User _User = new BL.User() { Password = pPassword, UserId = PortalUser.Id, FullName = PortalUser.Attributes.Contains("new_fullname") ? Convert.ToString(PortalUser.Attributes["new_fullname"]) : "", UserName = PortalUser.Attributes.Contains("new_name") ? Convert.ToString(PortalUser.Attributes["new_name"]) : "", CompanyName = PortalUser.Attributes.Contains("parentcustomerid") ? Convert.ToString(((EntityReference)PortalUser.Attributes["parentcustomerid"]).Id) : "", timezone = TimeZoneDef != null ? TimeZoneDef.Entities[0].Attributes["standardname"].ToString() : "", FirstName = PortalUser.Attributes.Contains("new_name") ? Convert.ToString(PortalUser.Attributes["new_name"]) : "", LastName = PortalUser.Attributes.Contains("mhl_usertype") ? Convert.ToString(((OptionSetValue)PortalUser["mhl_usertype"]).Value) : "", Documenttyp = string.Empty //DocumentType //Email = PortalUser.Contains("new_email") ? Convert.ToString(PortalUser["new_email"]) : "" }; //int value = ((OptionSetValue)PortalUser["mhl_usertype"]).Value; //var optionList = (from o in BL.CurrentUser.Instance.VerifiedUser.LastName.OptionSet.Options select new { Value = o.Value, Text = o.Label.UserLocalizedLabel.Label }).ToList(); //Guid timezoneid = new Guid(_User.timezone); //EntityReference TimezoneId = new EntityReference("subject", timezoneid); //TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); //DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone); return(_User); } return(null); }
public ActionResult SaveCases(BL.TicketData Model) { try { if (Service == null) { Service = BL.OrganizationUtility.GetCRMService(); } if (BL.CurrentUser.Instance != null && BL.CurrentUser.Instance.VerifiedUser.UserId != Guid.Empty) { BL.User us = new BL.User(); //QueryExpression query = new QueryExpression("contact"); //query.ColumnSet = new ColumnSet("contactid", "parentcustomerid"); ////query.Criteria.AddCondition(new ConditionExpression("new_account", ConditionOperator.Equal, CustId)); //EntityCollection Col = Service.RetrieveMultiple(query); // Entity entity = context.InputParameters["account"] as Entity; if (Model.incidentid == null || Model.incidentid == new Guid("00000000-0000-0000-0000-000000000000")) { Entity entity = new Entity("incident"); //entity.Id = ""; entity.LogicalName = "incident"; //entity.Attributes["incidentid"] = ; entity.Attributes["title"] = Model.title; Guid subjectid = new Guid(Model.subjectid); EntityReference SubjectId = new EntityReference("subject", subjectid); entity.Attributes["subjectid"] = SubjectId; entity.Attributes["description"] = Model.description; Guid customerid = new Guid(BL.CurrentUser.Instance.VerifiedUser.CompanyName); EntityReference CustomerId = new EntityReference("account", customerid); entity.Attributes["customerid"] = CustomerId; Guid sitename = new Guid(Model.new_name); EntityReference SiteName = new EntityReference("new_projectsite", sitename); entity.Attributes["new_sitename"] = SiteName; Guid contactid = new Guid(BL.CurrentUser.Instance.VerifiedUser.UserId.ToString()); EntityReference ContactId = new EntityReference("contact", contactid); entity.Attributes["primarycontactid"] = ContactId; //new_sitename entity.Attributes["createdby"] = ContactId; //new_sitename var incId = Service.Create(entity); #region SaveNotes Entity entity_notes = new Entity("annotation"); entity_notes["subject"] = " by " + BL.CurrentUser.Instance.VerifiedUser.UserName; entity_notes["notetext"] = "*WEB*" + Model.description; if (Model.Attachment != null) { if (Model.Attachment.ContentLength > 0) { var fname = Path.GetFileNameWithoutExtension(Model.Attachment.FileName) + (DateTime.Now).ToString("ddMMyyhhmmss"); var FExtension = Path.GetExtension(Model.Attachment.FileName); var fileName = fname + FExtension;// //var fileName = Path.GetFileName(ModelNotes.Attachment.FileName);// + (DateTime.Now).ToString("dd-MM-yyyy")); var path = Path.Combine(Server.MapPath("~/App_Data/"), fileName); Model.Attachment.SaveAs(path); FileStream stream = new FileStream(path, FileMode.Open); byte[] byteData = new byte[stream.Length]; stream.Read(byteData, 0, byteData.Length); stream.Close(); entity_notes["filename"] = fileName; entity_notes["mimetype"] = Model.Attachment.ContentType; entity_notes["documentbody"] = System.Convert.ToBase64String(byteData); } } EntityReference IncidentIdNew = new EntityReference("incident", incId); entity_notes["objectid"] = IncidentIdNew; EntityReference User = new EntityReference("contact", BL.CurrentUser.Instance.VerifiedUser.UserId); //entity["createdby"] = User.Id; Service.Create(entity_notes); #endregion Model.PageMessage = "Case Successfully Created"; } else { Entity entity = new Entity("incident"); //entity.Id = ""; entity.LogicalName = "incident"; entity.Attributes["incidentid"] = Model.incidentid; entity.Attributes["title"] = Model.title; Guid subjectid = new Guid(Model.subjectid); EntityReference SubjectId = new EntityReference("subject", subjectid); entity.Attributes["subjectid"] = SubjectId; entity.Attributes["description"] = Model.description; Guid customerid = new Guid(BL.CurrentUser.Instance.VerifiedUser.CompanyName); EntityReference CustomerId = new EntityReference("account", customerid); entity.Attributes["customerid"] = CustomerId; Guid sitename = new Guid(Model.new_name); EntityReference SiteName = new EntityReference("new_projectsite", sitename); entity.Attributes["new_sitename"] = SiteName; Guid contactid = new Guid(BL.CurrentUser.Instance.VerifiedUser.UserId.ToString()); EntityReference ContactId = new EntityReference("contact", contactid); entity.Attributes["primarycontactid"] = ContactId;//new_sitename Service.Update(entity); Model.PageMessage = "Case Successfully Updated"; } } //EditCases(Model.incidentid); return(RedirectToAction("GetAllCasesForIncident")); } catch (Exception ex) { return(RedirectToAction("../Activity/Login")); } }
protected void Button1_Click(object sender, EventArgs e) { ClassLibrary1.User user = new ClassLibrary1.User(); ClassLibrary1.Class1 c = new ClassLibrary1.Class1(); user = ClassLibrary1.Class1. }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> public static User CreateUser(global::System.Guid userID) { User user = new User(); user.UserID = userID; return user; }