예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        public Item FindItemById(Innovator inn, string itemtype, string id)
        {
            Item itm = inn.getItemById(itemtype, id);

            itm = itm.apply();
            return(itm);
        }
예제 #4
0
        public static void TransferToSAP()
        {
            Innovator inn = IomFactory.CreateInnovator(connection);

            Item pendingQueryItem = inn.newItem("GAG_SAPTransferLog", "get");

            pendingQueryItem.setProperty("gag_sap_status", "Pending");
            Item results = pendingQueryItem.apply();

            Item failedQueryItem = inn.newItem("GAG_SAPTransferLog", "get");

            failedQueryItem.setProperty("gag_sap_status", "Failed");
            Item failedresult = failedQueryItem.apply();

            if (results.isEmpty())
            {
                results = failedresult;
            }
            else if (!failedresult.isEmpty())
            {
                results.appendItem(failedresult);
            }

            if (!results.isError())
            {
                foreach (Item logItem in results.Enumerate())
                {
                    DateTime thisDayStart = DateTime.Now;
                    string   nowStart     = thisDayStart.ToString("yyyy-MM-ddTHH:mm:ss");
                    logItem.setAction("edit");
                    logItem.setProperty("gag_start_date", nowStart);

                    string result = CheckSAPConnection();
                    if (result.Equals("Connection Successful"))
                    {
                        string materialID     = logItem.getProperty("gag_material_number");
                        Item   materialPart   = inn.getItemById("Part", materialID);
                        string materialStatus = CheckMaterial(materialPart);
                        if (materialStatus == "Failure")
                        {
                            CreateMaterial(materialPart, logItem);
                        }
                        else
                        {
                            string bomStatus = CheckBOM(materialPart);
                            if (!string.IsNullOrEmpty(bomStatus))
                            {
                                CreateBOM(materialPart, logItem);
                            }
                        }
                    }
                    else
                    {
                        FillLogItem(logItem, $"ERROR!. {result}", "Failed");
                    }
                }
            }
        }
예제 #5
0
        private void StartExecAD()
        {
            btnClear.Enabled = false;
            lblError.Text    = "0";
            RB.Clear();

            //获取数据库名称
            string dbName = cmbDB.Text;
            string dbPath = txtPath.Text + "\\" + dbName;

            if (!Directory.Exists(dbPath))
            {
                MessageBox.Show("没有需要处理得数据"); return;
            }
            DirectoryInfo TheFolder = new DirectoryInfo(dbPath);

            Thread.Sleep(100);
            System.Windows.Forms.Application.DoEvents();
            RB.AppendText("【" + DateTime.Now.ToString() + "】扫描中..." + "\n");
            foreach (var item in TheFolder.GetDirectories())
            {
                Thread.Sleep(100);
                System.Windows.Forms.Application.DoEvents();
                string fileid = item.Name;
                getFileID(item);
            }
            lblFileCount.Text = fileList.Count.ToString();
            RB.AppendText("【" + DateTime.Now.ToString() + "】扫描完毕,开始整理垃圾数据...,这可能需要几分钟,请耐心等待..." + "\n");
            foreach (var item in fileList)
            {
                Thread.Sleep(100);
                System.Windows.Forms.Application.DoEvents();
                string path     = Path.GetDirectoryName(item);
                string id       = path.Substring(path.LastIndexOf(cmbDB.Text) + cmbDB.Text.Length).Replace("\\", "");
                Item   fileItem = inn.getItemById("File", id);
                if (fileItem.getItemCount() != 1)
                {
                    ErrorfileIdList.Add(item);
                    lblError.Text = ErrorfileIdList.Count.ToString();
                    RB.AppendText("【" + DateTime.Now.ToString() + "】无效文件" + item + "\n");
                }
                fileIdList.Add(id);
            }
            RB.AppendText("【" + DateTime.Now.ToString() + "】整理完毕" + "\n");
            btnClear.Enabled = true;
        }
예제 #6
0
        private void UpdateActivityRibbonName(string source_id, RibbonLabel ActivityRibbonLabel, RibbonButton CompleteTaskButton)
        {
            Item Workflow = inn.applyAML(AddtoItem(Settings.Default.getWorkFlowAML, "source_id", source_id));

            if (Workflow.node != null)
            {
                string Workflowprocessid = Workflow.getProperty("related_id");
                Item   WorkFlowProcess   = inn.applyAML(AddtoItem(Settings.Default.getWorkFlowProcessAML, "id", Workflowprocessid));
                string WorkflowName      = inn.applyAML(AddtoItem(Settings.Default.getWorkflowMapNameAML, "id", WorkFlowProcess.getProperty("copied_from_string"))).getProperty("name");

                Item   WorkFlowProcessActivities = inn.applyAML(AddtoItem(Settings.Default.getActivitiesAML, "source_id", Workflowprocessid));
                string endactivity = "";
                for (int i = 0; i < WorkFlowProcessActivities.getItemCount(); i++)
                {
                    Item   WorkFlowProcessActivity = WorkFlowProcessActivities.getItemByIndex(i);
                    Item   Activity     = WorkFlowProcessActivity.getPropertyItem("related_id");
                    string currentstate = Activity.getPropertyAttribute("current_state", "keyed_name");
                    endactivity = Activity.getProperty("is_end") == "1" && string.IsNullOrEmpty(endactivity) ? Activity.getID() : endactivity;
                    if (currentstate == "Active")
                    {
                        string currentactivity = Activity.getPropertyAttribute("config_id", "keyed_name");
                        ActivityRibbonLabel.Label = currentactivity;
                        Item myactivities = inn.applyAML(Settings.Default.getMyTasks);
                        for (int j = 0; j < myactivities.getItemCount(); j++)
                        {
                            Item   myInBasketItem = myactivities.getItemByIndex(j);
                            string containerid    = myInBasketItem.getProperty("container");
                            if (containerid == Workflowprocessid)
                            {
                                CompleteTaskButton.Enabled = true;
                            }
                        }
                        return;
                    }
                }
                //if code gets here and didn't break out then end of workflow
                ActivityRibbonLabel.Label  = inn.getItemById("Activity", endactivity).getPropertyAttribute("config_id", "keyed_name");
                CompleteTaskButton.Enabled = false;
            }
            else
            {
                ActivityRibbonLabel.Label  = "";
                CompleteTaskButton.Enabled = false;
            }
        }