public static void setAliasName(Item user, CallContext CCO) { string aliasId = CCO.Identity.GetUserAliases(user.getID()); Innovator inn = user.getInnovator(); Item userAlias = inn.getItemById("Identity", aliasId); string aml = "<AML>"; aml += "<Item type='ItemType' action='get'>"; aml += " <name>User</name>"; aml += " <Relationships>"; aml += " <Item type='Property' select='name,keyed_name_order' orderBy='keyed_name_order'>"; aml += " <keyed_name_order condition = 'is not null' />"; aml += " </Item>"; aml += " </Relationships>"; aml += "</Item>"; aml += "</AML>"; Item userType = inn.applyAML(aml); XmlNodeList ndsList = userType.node.SelectNodes("Relationships/Item[@type='Property']/name"); string tagName = ""; for (int i = 0; i < ndsList.Count; i++) { string propName = ndsList[i].InnerText; tagName = tagName + " " + user.getProperty(propName); } tagName = tagName.Trim(); if (tagName != "") { string sql = "UPDATE [innovator].[IDENTITY] set name='{0}' WHERE id='{1}'"; sql = string.Format(sql, tagName, aliasId); Item temp = inn.applySQL(sql); } }
public static void sgmAddIdentityToRoleUseDept(Item user, string role, CallContext CCO) { string identityId = CCO.Identity.GetIdentityIdByUserId(user.getID()); Innovator inn = user.getInnovator(); Item Identity = inn.getItemById("Identity", identityId); string aml = "<AML>"; aml += "<Item type='List' action='get'>"; aml += " <name>{0}</name>"; aml += " <Relationships>"; aml += " <Item type='Value' select='lable,value'>"; aml += " </Item>"; aml += " </Relationships>"; aml += "</Item>"; aml += "</AML>"; aml = string.Format(aml, role); Item list = inn.applyAML(aml); XmlNodeList ndsList = list.node.SelectNodes("Relationships/Item[@type='Value']/value"); List <string> deptList = new List <string>(); for (int i = 0; i < ndsList.Count; i++) { string dept = ndsList[i].InnerText; deptList.Add(dept); } string user_dept = user.getProperty("department"); int index = deptList.FindIndex(s => s == user_dept); Item Role = inn.getItemById("Identity", CCO.Identity.GetIdentityIdByName(role)); if (index >= 0) { if (!isMember(Role, Identity, inn)) { Item member = inn.newItem("Member", "add"); member.setProperty("source_id", Role.getID()); member.setProperty("related_id", identityId); member = member.apply(); } } else { if (isMember(Role, Identity, inn)) { string sql = "DELETE FROM Member WHERE source_id ='{0}' and related_id='{1}'"; sql = string.Format(sql, Role.getID(), identityId); Item temp = inn.applySQL(sql); } } }
public bool SaveMethodXML(Item itmMethod) { try { Item itmPath = inn.applySQL("select value from [innovator].[Variable] where name='TLTC_SaveMethod_Path'"); if (itmPath.isError() == true) { return(false); } string path = itmPath.getProperty("value", ""); string path_class = ""; string path_name = itmMethod.getProperty("name", ""); switch (itmMethod.getProperty("method_type", "")) { case "VB": path_class = "VB"; break; case "C#": path_class = "C#"; break; case "JavaScript": path_class = "JavaScript"; break; } StreamWriter swXML = new StreamWriter(path + path_class + "\\" + path_name + ".xml"); swXML.WriteLine(itmMethod.getProperty("method_code", "")); swXML.Close(); return(true); } catch (Exception ex) { return(false); } }
public Item ApplySql(string sql) { return(TryCall(() => Innovator.applySQL(sql))); }
private void button1_Click(object sender, System.EventArgs e) { button1.Enabled = false; textBox_message.Text = "报表生成中......."; dateTimePicker_report.Focus(); //获取输入的时间 DateTime dt = dateTimePicker_report.Value; //用来限定访问数据的范围 string firstDay = dt.Year + "-" + dt.Month + "-" + 1; string lastDay; if (dt.Month.Equals(12)) { lastDay = (dt.Year + 1) + "-" + 1 + "-" + 1; } else { lastDay = dt.Year + "-" + (dt.Month + 1) + "-" + 1; } try { // 访问Aras string url = Properties.Settings.Default.url; string username = Properties.Settings.Default.username; string pwd = Properties.Settings.Default.pwd; string database = Properties.Settings.Default.database; Item loginItem = IomFactory.CreateHttpServerConnection(url, database, username, pwd).Login(); if (loginItem.isError()) { MessageBox.Show("访问数据库失败,请重试"); button1.Enabled = true; textBox_message.Text = String.Empty; } else { Innovator inn = loginItem.getInnovator(); //EB25E105EFDF478980005105489F6E74表示项目List的cofigId; Item projectSql = inn.applySQL("SELECT value FROM[IPD].[innovator].VALUE where SOURCE_ID = 'EB25E105EFDF478980005105489F6E74' "); //D1593C4073EE49218E67A6B9F28CA943表示用户list的configId Item nameSql = inn.applySQL("SELECT value,label FROM [IPD].[innovator].VALUE a where SOURCE_ID = 'D1593C4073EE49218E67A6B9F28CA943' "); Dictionary <string, string> nameMap = new Dictionary <string, string>(); for (int i = 0; i < nameSql.getItemCount(); i++) { Item item = nameSql.getItemByIndex(i); string nameE = item.getProperty("value"); string nameC = item.getProperty("label"); if (nameE != null) { nameMap[nameE] = nameC; } } Item allDateSql = inn.applySQL("SELECT a.[SOURCE_ID] " + ", a.[PROJECT_NAME] " + ", a.[PROJECT_TIME] " + ", a.[PROJECT_COMMENT] " + ", b.MY_NAME " + " , b.WORKING_DATE " + "FROM[IPD].[innovator].[LAUREL_PROJECT_AND_TIME] a " + "Left Join IPD.innovator.MANHOUR_REGISTER b on b.CONFIG_ID = a.SOURCE_ID " + "and b.WORKING_DATE > ' " + firstDay + " ' and b.WORKING_DATE <'" + lastDay + "' "); if (allDateSql.getItemCount() == -1 || allDateSql.getItemCount() == 0) { MessageBox.Show("未查询到数据,请重试"); button1.Enabled = true; textBox_message.Text = String.Empty; return; } //把所有的数据制作成Map Dictionary <string, List <Item> > dictionary = new Dictionary <string, List <Item> >(); for (int i = 0; i < allDateSql.getItemCount(); i++) { Item item = allDateSql.getItemByIndex(i); string projectName = item.getProperty("project_name"); string myName = item.getProperty("my_name"); if (!string.IsNullOrWhiteSpace(projectName) && !string.IsNullOrWhiteSpace(myName)) { if (dictionary.ContainsKey(projectName)) { List <Item> list = dictionary[projectName]; list.Add(item); } else { List <Item> list = new List <Item>(); list.Add(item); dictionary[projectName] = list; } } } //新建Excel和工作簿 Microsoft.Office.Interop.Excel.Application oXL; Microsoft.Office.Interop.Excel._Workbook oWB; //启动Excel并获取应用程序对象 oXL = new Microsoft.Office.Interop.Excel.Application(); oXL.Visible = false; oWB = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(Missing.Value)); //遍历所有的名字 for (int i = 0; i < projectSql.getItemCount(); i++) { Item item = projectSql.getItemByIndex(i); string name = item.getProperty("value"); //map制作完成, //防止list中的项目在Map中不存在 if (dictionary.ContainsKey(name)) { List <Item> sqlResult = dictionary[name]; if (sqlResult.Count() <= 0) { MessageBox.Show(name + "无查询结果"); button1.Enabled = true; textBox_message.Text = String.Empty; } else { makeSheet(sqlResult, dt, oXL, oWB, name, nameMap); } } } oXL.Visible = true; oXL.UserControl = true; this.Close(); } } catch (Exception theException) { String errorMessage; errorMessage = "Error: "; errorMessage = String.Concat(errorMessage, theException.Message); errorMessage = String.Concat(errorMessage, " Line: "); errorMessage = String.Concat(errorMessage, theException.InnerException); errorMessage = String.Concat(errorMessage, theException.Source); errorMessage = String.Concat(errorMessage, theException.ToString()); errorMessage = String.Concat(errorMessage, theException.TargetSite); MessageBox.Show(errorMessage, "Error"); } }