示例#1
0
 private void btnTest_Click(object sender, EventArgs e)
 {
     try
     {
         string message = OData4.SendCmd(txtToken.Text, txtMethod.Text.Trim(), txtParams.Text, DataScope.AtlPoc);
         txtResponse.Text = message;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        //http://siemensopds32/sit-svc/Application/AppU4DM/odata/UADMSetWorkOrderForScheduling
        //{"command":{"WorkOrderId":"2cbf2a97-833c-4315-b607-9ad30b881305","WorkOrderNId":"WO-00000004"}}
        public string UADMSetWorkOrderForScheduling(string token, string wo_id, string userId)
        {
            string  json = OData4.SendCmd(token, "UADMSetWorkOrderForScheduling", "{\"command\":{\"WorkOrderId\":\"" + wo_id + "\",\"UserId\":\"" + userId + "\"}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //http://opds31/sit-svc/Application/AppU4DM/odata/UADMReleaseWorkOrder
        //{"command":{"ReleaseWorkOrderDetails":[{"WorkOrderId":"51dc60ee-60ca-47a1-9506-de910625bb2d","WorkOrderNId":"WO-2020-0002"}]}}
        //{"@odata.context":"http://opds31/sit-svc/application/AppU4DM/odata/$metadata#Siemens.SimaticIT.U4DM.AppU4DM.AppU4DM.DMPOMModel.Commands.UADMReleaseWorkOrderResponse","Succeeded":false,"Id":[],"Error":{"ErrorCode":-702597,"ErrorMessage":"The work order(s) WO-2020-0002 has a serialized production type. There are not all produced material items associated: Select serial number to associate."},"SitUafExecutionDetail":null}
        public string ReleaseOrder(string token, string WO_ID, string OrderID)
        {
            string  json = OData4.SendCmd(token, "UADMReleaseWorkOrder", "{\"command\":{\"ReleaseWorkOrderDetails\":[{\"WorkOrderId\":\"" + WO_ID + "\",\"WorkOrderNId\":\"" + OrderID + "\"}]}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        public string CreateSerialNumberCache(string token, string orderId, string serialNumber, string stepId, string stationId, string passId, string eventDatetime, string uniqId, string type)
        {
            string  json = OData4.SendCmd(token, "CreateSerialNumberCache", "{\"command\":{\"OrderId\":\"" + orderId + "\",SerialNumber:\"" + serialNumber + "\",Status:1,\"StepId\":\"" + stepId + "\",\"StationId\":\"" + stationId + "\",\"EventDatetime\":\"" + eventDatetime + "\",\"PassId\":\"" + passId + "\",\"UniqId\":\"" + uniqId + "\",\"Type\":\"" + type + "\"}}", DataScope.OpeApp);
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //http://siemensopds31/sit-svc/Application/AppU4DM/odata/UADMCreateAndAssignProducedMaterialItems
        //{"command":{"WorkOrderId":"2cbf2a97-833c-4315-b607-9ad30b881305","WorkOrderNId":"WO-00000004"}}
        public string CreateOrderSerialNumbers(string token, string wo_id, string orderId)
        {
            string  json = OData4.SendCmd(token, "UADMCreateAndAssignProducedMaterialItems", "{\"command\":{\"WorkOrderId\":\"" + wo_id + "\",\"WorkOrderNId\":\"" + orderId + "\"}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //	http://siemensopds31/sit-svc/Application/AppU4DM/odata/UADMConsumeMaterialItemList
        //{"command":{"WorkOrderOperationId":"5ec00405-b870-4fce-a3ab-0533f902f20b","WorkOrderOperationNId":"WOO_268bf50e-63b7-4ad4-92b7-41fa74b0da85","Notes":"notes","MaterialItemToConsumeList":[{"TargetMaterialItem":{"NId":"SN2020000001","SerialNumber":"SN2020000001","MaterialDefinitionNId":"A1003860348"},"ToBeConsumedMaterialItemList":[{"ToBeConsumedMaterialName":"B3087658","ToBeConsumedMaterialSequence":1,"MaterialDefinitionNId":"B3087658","SerialNumber":"ABCD-0001","TotalQuantity":1,"ActualQuantity":0,"Quantity":1}]}]}}
        public string UADMConsumeMaterialItemList(string token, string wo_op_id, string wo_op_nid, string tsn, string prd_id, string mat_id, string sub_sn)
        {
            string  json = OData4.SendCmd(token, "UADMConsumeMaterialItemList", "{\"command\":{\"WorkOrderOperationId\":\"" + wo_op_id + "\",\"WorkOrderOperationNId\":\"" + wo_op_nid + "\",\"Notes\":\"notes\",\"MaterialItemToConsumeList\":[{\"TargetMaterialItem\":{\"NId\":\"" + tsn + "\",\"SerialNumber\":\"" + tsn + "\",\"MaterialDefinitionNId\":\"" + prd_id + "\"},\"ToBeConsumedMaterialItemList\":[{\"ToBeConsumedMaterialName\":\"" + mat_id + "\",\"ToBeConsumedMaterialSequence\":1,\"MaterialDefinitionNId\":\"" + mat_id + "\",\"SerialNumber\":\"" + sub_sn + "\",\"TotalQuantity\":1,\"ActualQuantity\":0,\"Quantity\":1}]}]}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //	http://opds31/sit-svc/Application/AppU4DM/odata/UADMCompleteWOOperationSerializedList
        //{"command":{"CompleteSerializedWoOpParameterList":[{"WorkOrderOperationId":"322db10f-cc19-4a80-80b0-e61d19155630","DM_MTUIdList":["7e4cdd14-6aa3-46a3-8875-562a3dc95752"]}]}}
        public string Complete(string token, string sn_id, string op_id)
        {
            string  json = OData4.SendCmd(token, "UADMCompleteWOOperationSerializedList", "{\"command\":{\"CompleteSerializedWoOpParameterList\":[{\"WorkOrderOperationId\":\"" + op_id + "\",\"DM_MTUIdList\":[\"" + sn_id + "\"]}]}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //序列号Start 方法
        //http://opds31/sit-svc/Application/AppU4DM/odata/UADMStartWOOperationSerializedList
        //{"command":{"StartWOOperationSerializedParameterTypeList":[{"EquipmentNId":"SE1L1-NC-MACHINING","DM_MTUIdList":["7e4cdd14-6aa3-46a3-8875-562a3dc95752"],"WorkOrderOperationId":"322db10f-cc19-4a80-80b0-e61d19155630","SetPointItemParameterType":[]}]}}
        public string Start(string token, string EquipmentNId, string sn_id, string op_id)
        {
            string  json = OData4.SendCmd(token, "UADMStartWOOperationSerializedList", "{\"command\":{\"StartWOOperationSerializedParameterTypeList\":[{\"EquipmentNId\":\"" + EquipmentNId + "\",\"DM_MTUIdList\":[\"" + sn_id + "\"],\"WorkOrderOperationId\":\"" + op_id + "\",\"SetPointItemParameterType\":[]}]}}");
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        //http://opds31/sit-svc/Application/AppU4DM/odata/CreateOrderCache
        //{"command":{"ReleaseWorkOrderDetails":[{"WorkOrderId":"51dc60ee-60ca-47a1-9506-de910625bb2d","WorkOrderNId":"WO-2020-0002"}]}}
        //{"@odata.context":"http://opds31/sit-svc/application/AppU4DM/odata/$metadata#Siemens.SimaticIT.U4DM.AppU4DM.AppU4DM.DMPOMModel.Commands.UADMReleaseWorkOrderResponse","Succeeded":false,"Id":[],"Error":{"ErrorCode":-702597,"ErrorMessage":"The work order(s) WO-2020-0002 has a serialized production type. There are not all produced material items associated: Select serial number to associate."},"SitUafExecutionDetail":null}
        public string CreateOrderCache(string token, string orderId, string WO_ID, string lineId)
        {
            string  json = OData4.SendCmd(token, "CreateOrderCache", "{\"command\":{\"OrderID\":\"" + orderId + "\",LineId:\"" + lineId + "\",\"WoId\":\"" + WO_ID + "\",Status:1}}", DataScope.OpeApp);
            JObject jb   = JObject.Parse(json);
            JToken  res_value;

            if (jb.TryGetValue("Error", out res_value))
            {
                return(res_value.ToString());
            }
            return(null);
        }
        /// <summary>
        /// 角色与用户关联
        /// </summary>
        /// <param name="intput">{"command":{"UserIds":["32","28"],"RoleName":"ccc","DomainName":""}}</param>
        /// /// <returns></returns>
        public static ReturnMessage CreateUserRoleAssociation(string intput)
        {
            ReturnMessage msg = new ReturnMessage {
                Succeed = false
            };

            try
            {
                string message1 = OData4.SendCmd(Token, "CreateUserRoleAssociationCommand", intput, DataScope.Engineering);
                if (!string.IsNullOrEmpty(message1))
                {
                    msg.Succeed = true;
                    msg.Message = message1;
                }
            }
            catch (Exception ex)
            {
                msg.Message = ex.Message;
            }
            return(msg);
        }
        /// <summary>
        /// 创建完成角色之后,给角色赋调用权限,默认全部打开,若是关闭某些权限,请在Studio里操作
        /// </summary>
        /// <param name="intput">{"command":{"Securables":[{"SecurableCategoryName":"business_command","Operations":[{"Name":"invoke","SecurableObjectNames":["business_command_root"]}]},{"SecurableCategoryName":"business_entity","Operations":[{"Name":"read","SecurableObjectNames":["business_entity_root"]}]},{"SecurableCategoryName":"business_event","Operations":[{"Name":"fire","SecurableObjectNames":["business_event_root"]},{"Name":"subscribe","SecurableObjectNames":["business_event_root"]},{"Name":"unsubscribe","SecurableObjectNames":["business_event_root"]}]},{"SecurableCategoryName":"screen","Operations":[{"Name":"view","SecurableObjectNames":["screen_root"]}]},{"SecurableCategoryName":"business_signal","Operations":[{"Name":"subscribe","SecurableObjectNames":["business_signal_root"]}]},{"SecurableCategoryName":"business_reading_function","Operations":[{"Name":"execute","SecurableObjectNames":["business_reading_function_root"]}]}],"RoleName":"ccc"}}</param>
        /// <returns></returns>
        public static ReturnMessage AddFunctionRightsToRole_Before(string intput)
        {
            ReturnMessage msg = new ReturnMessage {
                Succeed = false
            };

            try
            {
                string message1 = OData4.SendCmd(Token, "AddFunctionRightsToRoleCommand", intput, DataScope.Engineering);
                if (!string.IsNullOrEmpty(message1))
                {
                    msg.Succeed = true;
                    msg.Message = message1;
                }
            }
            catch (Exception ex)
            {
                msg.Message = ex.Message;
            }
            return(msg);
        }
        //	http://siemensopds31/sit-svc/Application/AppU4DM/odata/UADMCreateWorkOrderFromProcess
        //{"command":{"NId":"WO-00000004","ProcessId":"8d545bf2-aa96-47e9-8a49-5a942269173a","ProductionTypeNId":"Serialized","Quantity":10,"AsPlannedId":"2053cf50-4d08-49e1-b712-99581e5d91f3","FinalMaterialId":"9c557480-cc49-4548-860e-dce4643c2f67","Plant":"SIEMENS-ELEC","DueDate":"2020-03-20T12:30:37.000Z"}}
        //{"@odata.context":"http://siemensopds31/sit-svc/application/AppU4DM/odata/$metadata#Siemens.SimaticIT.U4DM.AppU4DM.AppU4DM.DMPOMModel.Commands.UADMCreateWorkOrderFromProcessResponse","Succeeded":true,"Id":"546da152-8d86-4de9-a3fe-02818cd61eff","Error":{"ErrorCode":0,"ErrorMessage":""},"SitUafExecutionDetail":null}//
        public string CreateOrder(string token, string orderId, string processId, int quantity, string asPlannedId, string finalMaterialId, string plant, string duetime, string color)
        {
            string json = OData4.SendCmd(token, "UADMCreateWorkOrderFromProcess", "{\"command\":{\"NId\":\"" + orderId + "\",\"ProcessId\":\"" + processId + "\",\"ProductionTypeNId\":\"Serialized\",\"Quantity\":" + quantity + ",\"AsPlannedId\":\"" + asPlannedId + "\",\"FinalMaterialId\":\"" + finalMaterialId + "\",\"Plant\":\"" + plant + "\",\"ERPOrder\":\"" + color + "\",\"DueDate\":\"" + duetime + "\"}}");

            return(json);
        }