public static int TaskSubmit(WebRequestSession session, String taskType, String taskName, Dictionary <String, String> files2Post) { string url = "/caxa/task_submit"; try { NameValueCollection valuePairs = new NameValueCollection(); valuePairs.Add("task_type", taskType); valuePairs.Add("task_name", taskName); NameValueCollection files = new NameValueCollection(); foreach (KeyValuePair <String, String> filePath in files2Post) { files.Add(filePath.Key, filePath.Value); //path, file_id } string response = RemoteCall.PostMultipartRequest(session, url, valuePairs, files); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { if (!String.IsNullOrEmpty("" + jResult["task_id"])) { int taskId = Convert.ToInt32(jResult["task_id"]); return(taskId); } } } catch (Exception e) { Debug.WriteLine(e.Message); } return(-1); }
public int AddOrderItem(ExOrderItem objItem, int order_id, int orderType, int productType) { int item_id = RemoteCall.GetNextID(_reqSession, "Item_Id"); string url = "/caxa/multipart_order_item"; NameValueCollection valuePairs = new NameValueCollection(); valuePairs.Add("item_id", item_id.ToString()); valuePairs.Add("order_id", order_id.ToString()); valuePairs.Add("model_name", objItem.Model); valuePairs.Add("amount", objItem.Count.ToString()); valuePairs.Add("length", objItem.Length.ToString()); valuePairs.Add("width", objItem.Width.ToString()); valuePairs.Add("height", objItem.Height.ToString()); valuePairs.Add("item_memo", objItem.Remarks); valuePairs.Add("productname", objItem.ProductName); valuePairs.Add("ordertype", orderType.ToString()); //订单类型:料单 valuePairs.Add("product_type_id", productType.ToString()); //产品类型ID string response = ""; if (orderType == 1002)//料单需要上传产品描述 { valuePairs.Add("attachment", "File:1"); NameValueCollection files = new NameValueCollection(); string tempFile = Path.GetTempFileName(); XmlDocument doc = new XmlDocument(); XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); doc.AppendChild(dec); XmlNode nodeProduct = doc.ImportNode(objItem.ProductNode, true); doc.AppendChild(nodeProduct); doc.Save(tempFile); files.Add("部件信息", tempFile); response = RemoteCall.PostMultipartRequest(_reqSession, url, valuePairs, files); } else { valuePairs.Add("attachment", "File:0"); response = RemoteCall.PostMultipartRequest(_reqSession, url, valuePairs); } JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { return(item_id); } else { return(0); } }
private void buttonSend_Click(object sender, EventArgs e) { string url = "/dpjia/post_collocation_file"; NameValueCollection valuePairs = new NameValueCollection(); valuePairs.Add("projects", "001/002"); NameValueCollection files = new NameValueCollection(); files = null; string response = RemoteCall.PostMultipartRequest(_reqSession, url, valuePairs, files); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { this.listBoxDpLog.Items.Add(String.Format("成功")); } else { this.listBoxDpLog.Items.Add(String.Format("失败")); } }
private void buttonTest_Click(object sender, EventArgs e) { ///////////////////////////////////////////////////////////////////// if (false) { //获取模型列表 string url = "/caxa/get_cadm_model_list"; String filter = ""; string response = RemoteCall.GetJsonData(_reqSession, url, filter); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { this.listBoxLog.Items.Add(String.Format("成功获取模型树")); } else { this.listBoxLog.Items.Add(String.Format("获取模型树失败")); } } ///////////////////////////////////////////////////////////////////// else if (false) { //获取指定模型的数据包 string url = "/caxa/get_cadm_model_data"; String modelPath = UrlUtility.UrlEncode("\\CADM\\SVG\\喷漆圆角矩形加负刀补(2000x750)#4"); string response = RemoteCall.GetCadmModelData(_reqSession, url, modelPath); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { this.listBoxLog.Items.Add(String.Format("成功获取模型数据")); } else { this.listBoxLog.Items.Add(String.Format("获取模型数据失败")); } } ///////////////////////////////////////////////////////////////////// else if (false) { //测试增加订单 string url = "/caxa/add_order_item"; JObject newOrder = new JObject( new JProperty("order_id", -1), new JProperty("order_no", ""), new JProperty("customer", ""), new JProperty("phone", ""), new JProperty("person", ""), new JProperty("address", ""), new JProperty("order_date", "2017-02-19"), new JProperty("delivery_date", "2017-03-19"), new JProperty("order_memo", ""), new JProperty("order_status", ""), new JProperty("projectid", -1)); string response = RemoteCall.PostJObject(_reqSession, url, newOrder); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { this.listBoxLog.Items.Add(String.Format("增加订单成功")); } else { this.listBoxLog.Items.Add(String.Format("增加订单失败")); } } ///////////////////////////////////////////////////////////////////// else if (false) { //测试增加带附件的订单项 string url = "/caxa/multipart_order_item"; NameValueCollection valuePairs = new NameValueCollection(); valuePairs.Add("order_name", "订单名称"); valuePairs.Add("customer", "客户名称"); NameValueCollection files = new NameValueCollection(); files.Add("压缩文件", "C:\\ACC\\CuttingStockNew.rar"); files.Add("部件名称", "C:\\ACC\\part_form.xml"); string response = RemoteCall.PostMultipartRequest(_reqSession, url, valuePairs, files); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { this.listBoxLog.Items.Add(String.Format("增加订单项成功")); } else { this.listBoxLog.Items.Add(String.Format("增加订单项失败")); } } ///////////////////////////////////////////////////////////////////// else if (false) { //String srcFolder = "C:\\SmartHomeDesign_x64\\2.0\\drawLibs\\files\\banshijiaju\\"; //String zipFile = "C:\\temp\\bsjj.zip"; //RESTClient.GZip.ZipFolder(srcFolder, zipFile); //RESTClient.GZip.UnZip(zipFile, "C:\\temp\\out\\"); //AssemblyLine lines = AssemblyLine.getInstance("C:\\326Demo_V45\\WebServerWithDb\\WebServer\\template\\processTemplate.xml"); DataTable dtLines = RemoteCall.GetAssemblyLines(_reqSession); } ///////////////////////////////////////////////////////////////////// else if (false) { String package_codeid = "0PE77BF72BE832"; //PostgreSQL 9.4,PostgreSQL 9.4 String sheet_codeid = "0Hck6vLDjhqWhu"; String part_codeid = "02ck6vLDf8kXVJ"; StringBuilder resultFile = new StringBuilder(1024); Boolean result = RemoteCall.GetSheetList(_reqSession, package_codeid, resultFile); if (result) { result = RemoteCall.UpdateSheetStatus(_reqSession, sheet_codeid, "cutted"); result = RemoteCall.UpdatePartStatus(_reqSession, part_codeid, "cutted"); } } }