protected void Button1_Click(object sender, EventArgs e) { int value = int.Parse(DropDownList1.SelectedValue); string name = ""; string cust = ""; if (value == 1) { name = "Dynamite roll"; } else if (value == 2) { name = "Rainbow roll"; } else if (value == 3) { name = "Spicy Tuna roll"; } else if (value == 4) { name = "Mango Tango roll"; } DataInsert myInsert = new DataInsert(); myInsert.InsertOrder(value, name); cust = TextBox1.Text; myInsert.InsertCustomer(cust); Response.Redirect("Checkout?" + "value=" + value + "&" + "name=" + cust); }
// Use this for initialization void Start() { GameObject dbConn = new GameObject("dbConn"); dataInsert = dbConn.AddComponent <DataInsert>(); inputfield0000 = GameObject.Find("InputField (0000)"); inputfield0001 = GameObject.Find("InputField (0001)"); inputfield0010 = GameObject.Find("InputField (0010)"); inputfield0011 = GameObject.Find("InputField (0011)"); inputfield0100 = GameObject.Find("InputField (0100)"); inputfield0101 = GameObject.Find("InputField (0101)"); inputfield0110 = GameObject.Find("InputField (0110)"); inputfield0111 = GameObject.Find("InputField (0111)"); inputfield1000 = GameObject.Find("InputField (1000)"); inputfield1001 = GameObject.Find("InputField (1001)"); inputfield1010 = GameObject.Find("InputField (1010)"); inputfield1011 = GameObject.Find("InputField (1011)"); inputfield1100 = GameObject.Find("InputField (1100)"); inputfield1101 = GameObject.Find("InputField (1101)"); inputfield1110 = GameObject.Find("InputField (1110)"); inputfield1111 = GameObject.Find("InputField (1111)"); GameObject button00 = GameObject.Find("Button"); Button btn = button00.GetComponent <Button>(); btn.onClick.AddListener(TaskOnClick); }
// Use this for initialization void Start() { GameObject dataInsertGO = new GameObject("dbConn"); dataInsertGO.transform.parent = this.gameObject.transform; dataInsert = dataInsertGO.AddComponent <DataInsert>(); }
protected void btnOrder_Click(object sender, EventArgs e) { HttpCookie menucookie = Request.Cookies["MenuItems"]; string name = txtName.Text; string phone = txtPhone.Text; string item = menucookie["Order"]; string[] orders = menucookie["Order"].Replace("%0a", ",").Split(','); DataInsert insert = new DataInsert(); insert.InsertOrder(name, phone); for (int i = 0; i < orders.Length; i++) { if (!orders[i].Equals("", StringComparison.Ordinal)) { int rows = insert.InsertOrder(name, phone, orders[i]); if (rows > 0) { Response.Write("It Worked!!"); } } } HttpCookie infocookie = new HttpCookie("Info"); infocookie["Name"] = txtName.Text; infocookie["Phone"] = txtPhone.Text; Response.Cookies.Add(infocookie); Response.Redirect("Thanks.aspx"); }
public string OrderInsert([FromQuery] InsertOrders Insertdata, [FromBody] InsertOrderDetails IOD) { for (int i = 0; i < IOD.ProductID.Count(); i++) { //required information if (IOD.ProductID[i] == null) { return("Please input ProductId"); } if (IOD.Quantity[i] == null) { return("Please input Quantity"); } if (IOD.Discount[i] == null) { return("Please input Discount"); } } //Insert Orders var Insert = new DataInsert(); var InsertOrder = Insert.InsertOrderData(Insertdata); //Insert OrderDetails var result = Insert.InsertOrderDetailData(IOD, InsertOrder); return(result); }
// Use this for initialization void Start() { createUserButton.onClick.AddListener(CreateUser); GameObject dataInsertGO = new GameObject("dbConn"); dataInsertGO.transform.parent = this.gameObject.transform; dataInsert = dataInsertGO.AddComponent <DataInsert>(); }
// Use this for initialization void Start() { GameObject dataInsertGO = new GameObject("dbConn"); dataInsertGO.transform.parent = this.gameObject.transform; dataInsert = dataInsertGO.AddComponent <DataInsert>(); CSVButton.onClick.AddListener(CSVOutput); }
private void Start() { GameObject dbConn = new GameObject("DataInsert dbConn"); dataInsert = dbConn.AddComponent <DataInsert>(); BtnLogin.onClick.AddListener(OnLoginClick); BtnExit.onClick.AddListener(() => Application.Quit()); BtnResetPassword.onClick.AddListener(() => SceneManager.LoadScene("ResetPswd")); }
public IHttpActionResult Post([FromBody] Osoba person) { if (person == null) { return(BadRequest()); } DataInsert.AddToDb(connection, person); return(Ok()); }
protected void Button1_Click(object sender, EventArgs e) { DataInsert myInsert = new DataInsert(); int value = myInsert.authenticateUser(TextBox1.Text, TextBox2.Text); if (value == 1) { Response.Redirect("orders.aspx"); } }
protected void Button1_Click(object sender, EventArgs e) { string text = TextBox1.Text; DataInsert myInsert = new DataInsert(); myInsert.InsertComment(text); Response.Redirect("Default.aspx"); }
// Use this for initialization void Start() { GameObject dbConn = new GameObject("dbConn"); dataInsert = dbConn.AddComponent <DataInsert>(); GameObject button00 = GameObject.Find("Button"); Button btn = button00.GetComponent <Button>(); btn.onClick.AddListener(TaskOnClick); }
/// <summary> /// Them nhieu /// </summary> /// <param name="listUser"></param> /// <param name="currentUserID"></param> /// <param name="currentUsername"></param> /// <returns></returns> public ServiceResponse AddMulti(List <UserLogin> listUser, int currentUserID, string currentUsername) { ServiceResponse res = new ServiceResponse(); var now = DateTime.Now; if (listUser == null || (listUser != null && listUser.Count == 0)) { res.OnError("Data empty"); return(res); } //check duplicate data req //var duplicates = list.GroupBy(s => s.Id) // .Where(g => g.Count() > 1) // .SelectMany(g => g); // or .SelectMany(g => g) List <UserInfor> listFailed = new List <UserInfor>(); List <UserInfor> listSuccess = new List <UserInfor>(); listUser.ForEach(user => { if (user == null || (user != null && user.User == null) || (user != null && user.User != null && user.User.UserLogin == null)) { listFailed.Add(user.User); } else if (_userLoginRepository.CheckContains(x => x.Username == user.Username)) { listFailed.Add(user.User); } else { user.User.CreatedBy = currentUsername; user.User.CreatedDate = now; user.User.ModifiedBy = currentUsername; user.User.ModifiedDate = now; listSuccess.Add(user.User); } }); if (listSuccess != null && listSuccess.Count > 0) { _userRepository.AddMulti(listSuccess); this.Save(); } DataInsert data = new DataInsert() { DataFailed = listFailed, DataSuccess = listSuccess, }; res.OnSuccess(data); return(res); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebUserControl1.Visible = false; OrderHistoryLink.Visible = false; } xds.XPath = "xsltstylesheet.xsl"; xds.DataFile = "newfeed.xml"; //Repeater1.DataSource = xds; //Repeater1.DataBind(); string user = username.Text; string pass = password.Text; DataInsert insert = new DataInsert(); //userId = insert.LoginUser(user, pass); //string userNum = user["userId"]; HttpCookie userCookie = Context.Request.Cookies["UserId"]; if (userCookie == null)//.Equals("", StringComparison.Ordinal)) { userCookie = Response.Cookies["UserId"]; userCookie.Value = userId.ToString(); Response.Cookies.Add(userCookie); } else { //userCookie = Response.Cookies["UserId"]; if (userId != 0) { userCookie.Value = userId.ToString(); } string userNum = userCookie.Value; //Response.Write(userNum); if (userNum == "0") { OrderHistoryLink.Visible = false; } else { OrderHistoryLink.Visible = true; } } }
public static void Main(string[] args) { using (var scope = CreateHostBuilder(args).Build().Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <DataContext>(); context.Database.Migrate(); DataInsert.Initialize(context); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } CreateHostBuilder(args).Build().Run(); }
// Use this for initialization void Start() { GameObject grader = new GameObject("Grader"); Grader = grader.AddComponent <DataInsert>(); inputfield000 = GameObject.Find("InputField (000)"); inputfield001 = GameObject.Find("InputField (001)"); inputfield010 = GameObject.Find("InputField (010)"); inputfield011 = GameObject.Find("InputField (011)"); inputfield100 = GameObject.Find("InputField (100)"); inputfield101 = GameObject.Find("InputField (101)"); inputfield110 = GameObject.Find("InputField (110)"); inputfield111 = GameObject.Find("InputField (111)"); GameObject button1 = GameObject.Find("Button"); Button btn = button1.GetComponent <Button>(); btn.onClick.AddListener(TaskOnClick); }
protected void btnLogin_Click(object sender, EventArgs e) { string user = username.Text; string pass = password.Text; DataInsert insert = new DataInsert(); userId = insert.LoginUser(user, pass); HttpCookie userCookie = Request.Cookies["UserId"]; userCookie.Value = userId.ToString(); /* * if (userId == 0) * OrderHistoryLink.Visible = false; * else * OrderHistoryLink.Visible = true; */ Page_Load(sender, e); }
public static DataSet CreateDataSet(CodeTypeDeclaration ctd, CodeCompileUnit cu, List <CodeMemberField> lFieldMembers) { DataSet ds = new DataSet(); ds.Name = Format.CamelCaseId(ctd.Name); foreach (CodeMemberField cm in lFieldMembers) { DataInsert d = new DataInsert() { ColumnName = ctd.Name, Position = lFieldMembers.IndexOf(cm), Value = cm.Name }; ds.Entries.Add(d); } return(ds); }
protected void btnSubmitComment_Click(object sender, EventArgs e) { if (commentBox.Text != "") { string userComment = ""; DataInsert dataInsert = new DataInsert(); invalidCommentInfo.Text = ""; userComment = commentBox.Text; //checks for xss attack userComment = Server.HtmlEncode(userComment); dataInsert.InsertComment(userComment); ListView1.DataBind(); commentBox.Text = ""; } else { invalidCommentInfo.Text = "Please enter a comment to submit"; } }
// Use this for initialization void Start() { dataInsert = new DataInsert(); Debug.Log("Username: "******" Password: "******" Lab1: " + DataInsert.inputLab1Grade + " Lab2: " + DataInsert.inputLab2Grade); SandboxMode.onClick.AddListener(EnterSandboxMode); Lab1Button.onClick.AddListener(EnterLab1); Lab2Button.onClick.AddListener(EnterLab2); CameraButton.onClick.AddListener(EnterCamera); LogoutButton.onClick.AddListener(Logout); Lab1Avg = GameObject.Find("Lab1Avg").GetComponent <Text>(); Lab2Avg = GameObject.Find("Lab2Avg").GetComponent <Text>(); currScore1 = GameObject.Find("currScore1").GetComponent <Text>(); currScore2 = GameObject.Find("currScore2").GetComponent <Text>(); username = GameObject.Find("Username").GetComponent <Text>(); currScore1.text = DataInsert.inputLab1Grade + ""; currScore2.text = DataInsert.inputLab2Grade + ""; Lab1Avg.text = DataInsert.lab1avg + ""; Lab2Avg.text = DataInsert.lab2avg + ""; username.text = DataInsert.inputStudent; }
private void SetSpcMsg(byte[] buff) //UTC 이상하게 뿌리고 있음. { try { if (buff.Length > 50) { byte[] tmp01 = new byte[] { buff[10], buff[9], buff[8], buff[7], 0x00, 0x00, 0x00, 0x00 }; //UTC byte[] tmp02 = new byte[] { buff[42], buff[43], buff[44] }; //재난종류 byte[] tmp03 = new byte[] { buff[14], buff[13], buff[12], buff[11] }; //ID byte[] tmp04 = new byte[] { 0, 0, 0, buff[49], buff[48], buff[47], buff[46], buff[45] }; //복합 5byte byte[] tmp05 = new byte[] { buff[18], buff[17] }; //Body 길이 byte[] tmp07 = new byte[] { buff[20], buff[19] }; //Body안의 길이 // string dtTmpstr = this.deviceres.fnByteToBit(tmp04[7]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[6]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[5]); dtTmpstr += this.deviceres.fnByteToBit(tmp04[4]); dtTmpstr = dtTmpstr.Substring(2, 28); // int IntregionC = this.deviceres.DeviceRegionCount((int)tmp04[3]); //지역수 int Intregion = this.deviceres.DeviceRegion((int)tmp04[3], (int)tmp04[4]); //지역형식 (0=전국, 1=정부지정, 2=행정동, 7=수신기개별) if (Intregion == 7 && IntregionC == 0) { IntregionC = 16; } if (Intregion == 2) { IntregionC++; } long longtmp = BitConverter.ToInt64(tmp04, 0); short shorttmp = BitConverter.ToInt16(tmp05, 0); short bodyinLen = BitConverter.ToInt16(tmp07, 0); byte[] tmp06 = new byte[(IntregionC * 10)]; //지역 for (int i = 0; i < (IntregionC * 10); i++) { tmp06[i] = buff[i + 50]; } string TotalRegion = Encoding.Default.GetString(tmp06); //최종 지역(행정동 코드 또는 수신기번호) string TotalMessage = string.Empty; int tmpline = 50 + (IntregionC * 10); if (buff[tmpline] == 3) { int messageLen = (19 + shorttmp) - (51 + (IntregionC * 10)); byte[] tmp08 = new byte[messageLen]; //단문 for (int i = 0; i < messageLen; i++) { tmp08[i] = buff[i + (51 + (IntregionC * 10))]; } TotalMessage = Encoding.Default.GetString(tmp08); //최종 단문 } else { int messageLen = (19 + shorttmp) - (53 + (IntregionC * 10)); byte[] tmp08 = new byte[messageLen]; //단문 for (int i = 0; i < messageLen; i++) { tmp08[i] = buff[i + (53 + (IntregionC * 10))]; } TotalMessage = Encoding.Default.GetString(tmp08); //최종 단문 } long utc = BitConverter.ToInt64(tmp01, 0); //시간 string dis = Encoding.Default.GetString(tmp02); //재난종류 string sts = "수신성공"; //발령상태 int pkid = BitConverter.ToInt32(tmp03, 0); //PKID ListViewItem lvi = this.set_listview.SetNorListView(utc, dis, sts, TotalMessage, pkid); //리스트뷰에 셋팅 this.listView2.Items.Add(lvi); this.set_listview.SetIndex(this.listView2); this.spcmng = new SpcMng(pkid); this.spcmng.ParseSuccessEvt += new SpcMng.ParseSuccessHandle(spcmng_ParseSuccessEvt); this.spcmng.MuxSuccessEvt += new SpcMng.MuxSuccessHandle(spcmng_MuxSuccessEvt); this.spcmng.EndSuccessEvt += new SpcMng.EndSuccessHandle(spcmng_EndSuccessEvt); BaseP bp = ProtoMng.GetPObject("01", pkid.ToString(), dis, TotalRegion) as Proto01; string db_msg = ProtoMng.MakeFrame(bp); if (Intregion == 0) { datainsert = new DataInsert(); datainsert.InsertAllEvt += new DataInsert.InsertAllHandle(datainsert_InsertAllEvt); datainsert.InsertAreaEvt += new DataInsert.InsertAreaHandle(datainsert_InsertAreaEvt); datainsert.setInit(); datainsert.InsertAll(db_msg, pkid, dis); } else { datainsert = new DataInsert(); datainsert.InsertAllEvt += new DataInsert.InsertAllHandle(datainsert_InsertAllEvt); datainsert.InsertAreaEvt += new DataInsert.InsertAreaHandle(datainsert_InsertAreaEvt); datainsert.setInit(); datainsert.InsertArea(Intregion, IntregionC, TotalRegion, "", pkid, dis); } if (buff.Length > (19 + shorttmp)) { byte[] reTmpbuff = new byte[buff.Length - (19 + shorttmp)]; for (int i = 0; i < buff.Length - (19 + shorttmp); i++) { reTmpbuff[i] = buff[i + (19 + shorttmp)]; } this.parse.ParseData(reTmpbuff); } } } catch (Exception ex) { Console.WriteLine("MainForm.SetSpcMsg - " + ex.Message); } }
static void Main(string[] args) { // Concepts Console.WriteLine("Generating OpenIZ Concepts to support GIIS data"); DatasetInstall conceptDataset = new DatasetInstall() { Id = "Concepts to support TIIS data", Action = new List <DataInstallAction>() }; DataInsert healthFacilityTypes = new DataInsert() { Element = new ConceptSet() { Key = Guid.NewGuid(), Mnemonic = "HealthFacilityTypes", Oid = "1.3.6.1.4.1.45219.1.3.5.99.1", Name = "Health Facility Types", Url = "http://ivd.moh.go.tz/valueset/timr/HealthFacilityTypes" }, Association = new List <DataAssociation>() }, placeTypes = new DataInsert() { Element = new ConceptSet() { Key = Guid.NewGuid(), Mnemonic = "PlaceTypes", Oid = "1.3.6.1.4.1.45219.1.3.5.99.2", Name = "Place Sub-Classifications", Url = "http://openiz.org/valueset/timr/PlaceTypes" }, Association = new List <DataAssociation>() { new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = PT_DISTRICT, StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "PlaceType-District", ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "District" } } } }, new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = PT_DISTRICT_COUNCIL, StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "PlaceType-DistrictCouncil", ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "District Council" } } } }, new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = PT_REGION, StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "PlaceType-Region", ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Region" } } } }, new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = PT_TERRITORY, StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "PlaceType-Territory", ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Territory" } } } }, new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = PT_VILLAGE, StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "PlaceType-Village", ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Village" } } } } } }; foreach (var itm in HealthFacilityType.GetHealthFacilityTypeList().OrderBy(o => o.Id)) { facilityTypeId.Add(itm.Id, Guid.NewGuid()); healthFacilityTypes.Association.Add( new DataAssociation() { PropertyName = "Concepts", Element = new Concept() { Key = facilityTypeId[itm.Id], StatusConceptKey = StatusKeys.Active, IsSystemConcept = false, ClassKey = ConceptClassKeys.Other, Mnemonic = "Facility-" + itm.Name.Replace(" ", ""), ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = itm.Name } } } } ); } (healthFacilityTypes.Element as ConceptSet).ConceptsXml = healthFacilityTypes.Association.Select(o => o.Element.Key.Value).ToList(); (placeTypes.Element as ConceptSet).ConceptsXml = placeTypes.Association.Select(o => o.Element.Key.Value).ToList(); conceptDataset.Action.AddRange(healthFacilityTypes.Association.Select(o => new DataInsert() { Element = o.Element })); conceptDataset.Action.AddRange(placeTypes.Association.Select(o => new DataInsert() { Element = o.Element })); conceptDataset.Action.AddRange(new DataInstallAction[] { new DataInsert() { Element = new Concept() { Key = industryManufacturer, Mnemonic = "Industry-Manufacturing", ClassKey = ConceptClassKeys.Other, IsSystemConcept = false, StatusConceptKey = StatusKeys.Active, ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Manufacturing" } }, ConceptSetsXml = new List <Guid>() { Guid.Parse("d1597e50-845a-46e1-b9ae-6f99ff93d9db") } } }, new DataInsert() { Element = new Concept() { Key = industryOther, Mnemonic = "Industry-OtherUnknown", ClassKey = ConceptClassKeys.Other, IsSystemConcept = false, StatusConceptKey = StatusKeys.Active, ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Other/Unknown" } }, ConceptSetsXml = new List <Guid>() { Guid.Parse("d1597e50-845a-46e1-b9ae-6f99ff93d9db") } } }, new DataInsert() { Element = new Concept() { Key = industryHealthDelivery, Mnemonic = "Industry-HealthDelivery", ClassKey = ConceptClassKeys.Other, IsSystemConcept = false, StatusConceptKey = StatusKeys.Active, ConceptNames = new List <ConceptName>() { new ConceptName() { Language = "en", Name = "Healthcare" } }, ConceptSetsXml = new List <Guid>() { Guid.Parse("d1597e50-845a-46e1-b9ae-6f99ff93d9db") } } } }); healthFacilityTypes.Association.Clear(); placeTypes.Association.Clear(); conceptDataset.Action.Add(healthFacilityTypes); conceptDataset.Action.Add(placeTypes); // Facilities Console.WriteLine("Exporting GIIS Facilities to OpenIZ IMS Format"); DatasetInstall facilityDataset = new DatasetInstall() { Action = new List <DataInstallAction>() }; facilityDataset.Id = "Facilities from GIIS"; foreach (var itm in HealthFacility.GetHealthFacilityList().OrderBy(o => o.Id)) { facilityDataset.Action.Add(new DataInsert() { Element = MapFacility(itm) }); } // Places Console.WriteLine("Exporting GIIS Places to OpenIZ IMS Format"); DatasetInstall placeDataset = new DatasetInstall() { Action = new List <DataInstallAction>() }; placeDataset.Id = "Places from GIIS"; foreach (var itm in GIIS.DataLayer.Place.GetPlaceList().OrderBy(o => o.ParentId)) { placeDataset.Action.Add(new DataInsert() { Element = MapPlace(itm) }); } // Users Console.WriteLine("Exporting GIIS Users to OpenIZ IMS Format"); DatasetInstall userDataset = new DatasetInstall() { Action = new List <DataInstallAction>() }; userDataset.Id = "Users from TIIS"; foreach (var itm in User.GetUserList()) { if (userDataset.Action.Any(o => (o.Element as SecurityUser)?.UserName.Trim().ToLower() == itm.Username.Trim().ToLower()) || itm.Username.ToLower() == "administrator") { continue; /// Apparently user names are distinct based on case? } Guid userId = Guid.NewGuid(), entityId = Guid.NewGuid(); userMap.Add(itm.Id, userId); if (!userEntityMap.TryGetValue(itm.Id, out entityId)) { entityId = Guid.NewGuid(); userEntityMap.Add(itm.Id, entityId); } var securityUser = new SecurityUser() { Key = userId, UserName = itm.Username, Email = itm.Email, EmailConfirmed = !String.IsNullOrEmpty(itm.Email), LastLoginTime = itm.Lastlogin, SecurityHash = Guid.Empty.ToString(), Lockout = itm.IsActive ? null : (DateTime?)DateTime.MaxValue, PasswordHash = BitConverter.ToString(Convert.FromBase64String(itm.Password)).Replace("-", ""), UserClass = UserClassKeys.HumanUser, TwoFactorEnabled = false, ObsoletionTime = itm.Deleted ? (DateTime?)DateTime.Now : null, ObsoletedByKey = itm.Deleted ? (Guid?)Guid.Parse(AuthenticationContext.SystemUserSid) : null, }; var userEntity = new UserEntity() { Key = entityId, Names = new List <EntityName>() { new EntityName(NameUseKeys.OfficialRecord, itm.Lastname, itm.Firstname) }, SecurityUserKey = userId, Identifiers = new List <EntityIdentifier>() { new EntityIdentifier(new AssigningAuthority("TIIS_USER_ID", "TIIS User Identifiers", "1.3.6.1.4.1.45219.1.3.5.2"), itm.Id.ToString()) }, Tags = new List <EntityTag>() { new EntityTag("http://openiz.org/tags/contrib/importedData", "true") }, StatusConceptKey = itm.IsActive ? StatusKeys.Active : StatusKeys.Obsolete }; if (!String.IsNullOrEmpty(itm.Email)) { userEntity.Telecoms = new List <EntityTelecomAddress>() { new EntityTelecomAddress(TelecomAddressUseKeys.WorkPlace, itm.Email) } } ; Guid facilityId = Guid.Empty; if (facilityMap.TryGetValue(itm.HealthFacilityId, out facilityId)) { userEntity.Relationships.Add(new EntityRelationship(EntityRelationshipTypeKeys.Employee, new Entity() { Key = facilityId })); } // data element var securityUserData = new DataInsert() { Element = securityUser, Association = new List <DataAssociation>() }; // Role foreach (var r in Role.GetRolesOfUser(itm.Id)) { Guid roleId = Guid.Empty; if (!roleMap.TryGetValue(r.Id, out roleId)) { roleId = Guid.NewGuid(); roleMap.Add(r.Id, roleId); } var role = new SecurityRole() { Key = roleId, Name = r.Name, ObsoletionTime = r.IsActive ? null : (DateTime?)DateTime.Now, ObsoletedByKey = r.IsActive ? null : (Guid?)Guid.Parse(AuthenticationContext.SystemUserSid) }; // Add roles to the user securityUserData.Association.Add(new DataAssociation() { PropertyName = "Roles", Element = new SecurityRole() { Key = role.Key } }); // Add role userDataset.Action.Add(new DataInsert() { Element = role }); // Vaccinator? if (r.Name == "Vaccinator") { // Provider entity var providerEntity = new Provider() { Key = Guid.NewGuid(), Names = userEntity.Names, Telecoms = userEntity.Telecoms, Identifiers = userEntity.Identifiers.Select(o => new EntityIdentifier(new AssigningAuthority("PROVIDER_ID", "TImR Assigned Provider ID", "1.3.6.1.4.1.45219.1.3.5.80"), o.Value)).ToList(), Tags = new List <EntityTag>() { new EntityTag("http://openiz.org/tags/contrib/importedData", "true") }, StatusConceptKey = itm.IsActive ? StatusKeys.Active : StatusKeys.Obsolete }; userDataset.Action.Add(new DataInsert() { Element = providerEntity }); // Create a heath care provider userEntity.Relationships.Add(new EntityRelationship() { RelationshipTypeKey = EntityRelationshipTypeKeys.AssignedEntity, TargetEntityKey = providerEntity.Key }); } } userDataset.Action.Add(securityUserData); userDataset.Action.Add(new DataInsert() { Element = userEntity }); } var materialDataset = new DatasetInstall() { Id = "Manufactured Materials from GIIS" }; foreach (var il in ItemLot.GetItemLotList()) { var itm = MapMaterial(il, materialDataset); materialDataset.Action.Add(new DataUpdate() { InsertIfNotExists = true, Element = itm }); } // Write datasets XmlSerializer xsz = new XmlSerializer(typeof(DatasetInstall)); using (var fs = File.Create("990-tiis.concepts.dataset")) xsz.Serialize(fs, conceptDataset); using (var fs = File.Create("991-tiis.facilities.dataset")) xsz.Serialize(fs, facilityDataset); using (var fs = File.Create("992-tiis.places.dataset")) xsz.Serialize(fs, placeDataset); using (var fs = File.Create("993-tiis.users.dataset")) xsz.Serialize(fs, userDataset); using (var fs = File.Create("994-tiis.materials.dataset")) xsz.Serialize(fs, materialDataset); } }
static void Main(string[] args) { try { Console.WriteLine("Database Initializer."); //IASystem IASystem = new IrrigationAdvisorConsole.IASystem(); #if false Database.SetInitializer <IrrigationAdvisorContext> (new DropCreateDatabaseIfModelChanges <IrrigationAdvisorContext>()); #endif #if false Database.SetInitializer <IrrigationAdvisorContext> (new CreateDatabaseIfNotExists <IrrigationAdvisorContext>()); #endif /* * Changing from DropCreateDatabaseIfModelChanges to DropCreateDatabaseAlways works, * the latter configuration causes the database to be recreated no matter what, * bypassing any sort of database versioning that might be causing an error. */ #if true try { Database.SetInitializer <IrrigationAdvisorContext> (new DropCreateDatabaseAlways <IrrigationAdvisorContext>()); } catch (Exception ex) { logger.Error(ex, "Exception in Program.DropCreateDatabaseAlways " + "\n" + ex.Message + "\n" + ex.StackTrace); logger.Log(LogLevel.Error, "Error in Program: DropCreateDatabaseAlways" + " Message " + ex.ToString()); throw ex; } #endif #region Data DataInsert.InsertStatus(); #endregion #region Lenguage LanguageInsert.InsertLanguages(); #endregion #region Security Console.WriteLine("Add Information of Security."); SecurityInsert.InsertRoles(); SecurityInsert.InsertUsers(); #endregion #region Localization #if true Console.WriteLine("Add Information of Localization."); Console.WriteLine(" - Insert Region-Cities-Countries"); LocalizationInsert.InsertPositions(); LocalizationInsert.InsertRegions(); LocalizationInsert.InsertCapitals(); LocalizationInsert.InsertCountry(); LocalizationInsert.InsertCities(); Console.WriteLine(" - InsertWeatherStations"); WeatherInsert.InsertWeatherStationsINIA(); WeatherInsert.InsertWeatherStationsWeatherLink(); Console.WriteLine(" - InsertFarms"); LocalizationInsert.InsertFarms(); SecurityInsert.InsertUserFarms(); #endif #endregion #region Agriculture #if true Console.WriteLine("Add Information of Agriculture."); AgricultureInsert.InsertSpecieCycles(); if (ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Demo || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2015 || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2016_2017) { AgricultureInsert.InsertSpecies_2016(); } else if (ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Production || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2017_2018) { AgricultureInsert.InsertSpecies_2017(); } else { AgricultureInsert.InsertSpecies_2017(); } AgricultureInsert.UpdateCountryRegionWithSpeciesSpeciesCycles(); Console.WriteLine(" - InsertStages"); AgricultureInsert.InsertStagesCorn(); AgricultureInsert.InsertStagesSoya(); AgricultureInsert.InsertStagesOat(); AgricultureInsert.InsertStagesSorghumForage(); AgricultureInsert.InsertStagesSorghumGrain(); AgricultureInsert.InsertStagesAlfalfa(); AgricultureInsert.InsertStagesSudanGrass(); AgricultureInsert.InsertStagesRedCloverForage(); AgricultureInsert.InsertStagesRedCloverSeed(); AgricultureInsert.InsertStagesFescueForage(); AgricultureInsert.InsertStagesFescueSeed(); Console.WriteLine(" - InsertEffectiveRains"); WaterInsert.InsertEffectiveRainsSouth(); WaterInsert.InsertEffectiveRainsNorth(); WaterInsert.UpdateRegionSetEffectiveRainList(); Console.WriteLine(" - InsertPhenologicalStages"); AgricultureInsert.InsertPhenologicalStagesCornSouthMedium(); //AgricultureInsert.InsertPhenologicalStagesCornSouthShort(); AgricultureInsert.InsertPhenologicalStagesCornSouthShort_2017(); //AgricultureInsert.InsertPhenologicalStagesSoyaSouthShort(); AgricultureInsert.InsertPhenologicalStagesSoyaSouthShort_2017(); AgricultureInsert.InsertPhenologicalStagesSoyaSouthMedium(); AgricultureInsert.InsertPhenologicalStagesCornNorthShort(); //AgricultureInsert.InsertPhenologicalStagesCornNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesCornNorthMedium(); AgricultureInsert.InsertPhenologicalStagesSoyaNorthShort(); //AgricultureInsert.InsertPhenologicalStagesSoyaNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesSoyaNorthMedium(); AgricultureInsert.InsertPhenologicalStagesOatSouthShort_2017(); AgricultureInsert.InsertPhenologicalStagesOatSouthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesOatNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesOatNorthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesAlfalfaSouthShort_2017(); AgricultureInsert.InsertPhenologicalStagesAlfalfaSouthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesAlfalfaNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesAlfalfaNorthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesSudanGrassSouthShort_2017(); AgricultureInsert.InsertPhenologicalStagesSudanGrassSouthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesSudanGrassNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesSudanGrassNorthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesFescueForageSouthShort_2017(); AgricultureInsert.InsertPhenologicalStagesFescueForageSouthMedium_2017(); AgricultureInsert.InsertPhenologicalStagesFescueForageNorthShort_2017(); AgricultureInsert.InsertPhenologicalStagesFescueForageNorthMedium_2017(); Console.WriteLine(" - Insert Horizons - Soils - CropCoefficient"); AgricultureInsert.InsertHorizons(); AgricultureInsert.InsertSoils(); AgricultureInsert.InsertCropCoefficients(); Console.WriteLine("Agriculture - Completed."); #endif #endregion #region Irrigation #if true Console.Write("Add Information of Irrigation."); IrrigationInsert.InsertBombs(); IrrigationInsert.InsertIrrigationUnits(); IrrigationInsert.UpdateSoilsBombsIrrigationUnitsUsersByFarm(); IrrigationInsert.InsertCrops(); IrrigationInsert.InsertCropsInformationByDate(); Console.WriteLine(" - Completed."); #endif #endregion #region Weather #if true Console.WriteLine("Add Information of Weather."); WeatherInsert.InsertTemperatureData(); Console.WriteLine(" - InsertTemperatureData"); WeatherInsert.AddTemperatureDataToRegion(); Console.WriteLine(" - AddTemperatureDataToRegion"); WeatherInsert.WetherStationsAddInformationOfWeather(); Console.WriteLine(" - WetherStationsAddInformationOfWeather"); Console.WriteLine("Weather - Completed."); if (AddWeatherInformation || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Production || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2017_2018) { Console.WriteLine(" ------------------------------------------------ "); Console.WriteLine("Add Information of WeatherLink and press enter."); Console.ReadLine(); } #endif #endregion #region Management #if true Console.WriteLine("Add Information of Management."); if (ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Demo) { Console.WriteLine(" Management - InsertCropIrrigationWeather."); CropIrrigationWeatherInsert2015.InsertCropIrrigationWeather2015(); Console.WriteLine(" "); Console.WriteLine(" Management - InsertCropIrrigationWeather. - Completed."); Console.Write(" Management - Add/Update Rain, Irrigation & Phenology Information."); WaterInsert.UpdateInformationOfRain2015(); WaterInsert.UpdateInformationOfIrrigation2015(); CropIrrigationWeatherInsert2015.AddPhenologicalStageAdjustements2015(); Console.WriteLine(" - Completed."); Console.WriteLine(" Management - Add/Update Information to Irrigation Units."); CropIrrigationWeatherInsert2015.AddInformationToIrrigationUnits2015(); Console.WriteLine(" Management - Add/Update Information to Irrigation Units. - Completed."); } else if (ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2016_2017) { Console.WriteLine(" Management - InsertCropIrrigationWeather."); CropIrrigationWeatherInsert2016.InsertCropIrrigationWeather2016(); Console.WriteLine(" "); Console.WriteLine(" Management - InsertCropIrrigationWeather. - Completed."); Console.Write(" Management - Add/Update Rain, Irrigation & Phenology Information."); WaterInsert.UpdateInformationOfRain2016(); WaterInsert.UpdateInformationOfIrrigation2016(); CropIrrigationWeatherInsert2016.AddPhenologicalStageAdjustements2016(); Console.WriteLine(" - Completed."); Console.WriteLine(" Management - Add/Update Information to Irrigation Units."); CropIrrigationWeatherInsert2016.AddInformationToIrrigationUnits2016(); Console.WriteLine(" Management - Add/Update Information to Irrigation Units. - Completed."); } else if (ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Production || ProcessFarm == Utils.IrrigationAdvisorProcessFarm.Season_2017_2018) { Console.WriteLine(" Management - InsertCropIrrigationWeather."); CropIrrigationWeatherInsert2017.InsertCropIrrigationWeather2017(); Console.WriteLine(" "); Console.WriteLine(" Management - InsertCropIrrigationWeather. - Completed."); Console.Write(" Management - Add/Update Rain, Irrigation & Phenology Information."); WaterInsert.UpdateInformationOfRain2017(); WaterInsert.UpdateInformationOfIrrigation2017(); CropIrrigationWeatherInsert2017.AddPhenologicalStageAdjustements2017(); Console.WriteLine(" - Completed."); Console.WriteLine(" Management - Add/Update Information to Irrigation Units."); CropIrrigationWeatherInsert2017.AddInformationToIrrigationUnits2017(); Console.WriteLine(" Management - Add/Update Information to Irrigation Units. - Completed."); } //When we select only a Farm or group of farm else { Console.WriteLine(" Management - InsertCropIrrigationWeather."); CropIrrigationWeatherInsert2017.InsertCropIrrigationWeather2017(); Console.WriteLine(" "); Console.WriteLine(" Management - InsertCropIrrigationWeather. - Completed."); Console.Write(" Management - Add/Update Rain, Irrigation & Phenology Information."); WaterInsert.UpdateInformationOfRain2017(); WaterInsert.UpdateInformationOfIrrigation2017(); CropIrrigationWeatherInsert2017.AddPhenologicalStageAdjustements2017(); Console.WriteLine(" - Completed."); Console.WriteLine(" Management - Add/Update Information to Irrigation Units."); CropIrrigationWeatherInsert2017.AddInformationToIrrigationUnits2017(); Console.WriteLine(" Management - Add/Update Information to Irrigation Units. - Completed."); } #endif #endregion if (PrintFarm != Utils.IrrigationAdvisorOutputFiles.NONE) { Console.WriteLine("Start Layout process."); } PrintDailyRecord.LayoutDailyRecords(); //Next to do #if false CalculateIrrigation(); #endif Console.WriteLine(" "); Console.WriteLine("Ended with successful!! Great job :)"); Console.WriteLine(" "); Console.WriteLine(" ------------------**********************-------------------- "); Console.ReadLine(); } catch (System.Data.Entity.Infrastructure.DbUpdateException ex) { logger.Error(ex, "Exception in Program.DbUpdateException " + "\n" + ex.Message + "\n" + ex.StackTrace); Console.WriteLine("DB Update Exception "); Console.WriteLine(ex.Message); Console.ReadLine(); } catch (System.Data.SqlClient.SqlException ex) { logger.Info(ex, "Exception in Program.SqlException " + "\n" + ex.Message + "\n" + ex.StackTrace); Console.WriteLine("DB is OPEN, close all connections. OR the model changes (Add or Update Migration) "); Console.WriteLine(ex.Message); Console.ReadLine(); //IF the Model changes: //go to nuget console, select IrrigationAdvisor Project //add-migration Description //ex add-migration AddColumnToWeatherData //PM > Update - Database - TargetMigration AnyMigrationName // It updates database to a migration named "AnyMigrationName" // This will apply migrations if the target hasn't been applied // or roll back migrations if it has } catch (Exception ex) { logger.Error(ex, "Exception in Program " + "\n" + ex.Message + "\n" + ex.StackTrace); Console.WriteLine("Initialization Failed..."); Console.WriteLine(ex.Message); Console.ReadLine(); } }