public int AddOrder(ExOrder objOrder) { int order_id = RemoteCall.GetNextID(_reqSession, "Order_Id"); string url = "/caxa/add_order_item"; JObject newOrder = new JObject { new JProperty("order_id", order_id), new JProperty("order_no", objOrder.OrderNo), new JProperty("customer", objOrder.CustomerName), new JProperty("phone", objOrder.CustomerPhone), new JProperty("person", objOrder.CustomerName), new JProperty("address", objOrder.CustomerAddress), new JProperty("order_date", objOrder.OrderDate), new JProperty("delivery_date", objOrder.DeliveryDate), new JProperty("order_memo", objOrder.Remarks), new JProperty("order_status", "scheduling"), new JProperty("projectid", 0) }; string response = RemoteCall.PostJObject(_reqSession, url, newOrder); JObject jResult = JObject.Parse(response); if ((int)jResult["result_code"] > 0) { return(order_id); } else { return(0); } }
public Addic7edSubtitleProvider(IHttpClient httpClient, IFileSystem fileSystem, IApplicationPaths appPaths, IJsonSerializer json, ILogger logger) { _json = json; _remote = new RemoteCall(httpClient); _cache = new CacheStorage(json, appPaths, fileSystem); _logger = logger; }
private void buttonOrder_Click(object sender, EventArgs e) { OpenFileDialog openXLsFileDialog = new OpenFileDialog(); openXLsFileDialog.Filter = "Excel Files (.xml)|*.xml|All Files (*.*)|*.*"; openXLsFileDialog.FilterIndex = 1; openXLsFileDialog.Multiselect = false; if (DialogResult.OK == openXLsFileDialog.ShowDialog()) { StringBuilder taskID = new StringBuilder(2048); Boolean result = RemoteCall.OrderPartition(_reqSession, openXLsFileDialog.FileName, "ProcessByOrderList", null, taskID);//processor:"ProcessByOrderList" if (result) { _TaskType = "OrderDirect"; _TaskID = taskID.ToString(); _LastTaskID = ""; AppendLog(String.Format("Success: upload orders: {0}, task:{1}", openXLsFileDialog.FileNames.ToString(), _TaskID)); } else { _TaskID = ""; _TaskType = ""; this.listBoxLog.Items.Add(String.Format("Failed to upload orders")); } } }
private List <ProductType> GetProductTypes() { List <ProductType> types = new List <ProductType>(); try { string sql = "select * from productTypes"; DataTable dt = RemoteCall.RESTQuery(_reqSession, sql); for (int i = 0; i < dt.Rows.Count; i++) { ProductType type = new ProductType() { TypeId = Convert.ToInt32(dt.Rows[i]["type_id"]), TypeName = dt.Rows[i]["type_name"].ToString().Trim(), }; types.Add(type); } } catch (Exception e) { throw new Exception(e.Message); } return(types); }
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); }
private void buttonProjectData_Click(object sender, EventArgs e) { OpenFileDialog openXLsFileDialog = new OpenFileDialog(); openXLsFileDialog.Filter = "Excel Files (.xml)|*.xml|All Files (*.*)|*.*"; openXLsFileDialog.FilterIndex = 1; openXLsFileDialog.Multiselect = false; if (DialogResult.OK == openXLsFileDialog.ShowDialog()) { StringBuilder taskID = new StringBuilder(2048); Dictionary <String, String> other = new Dictionary <string, string>(); other["task_param"] = "ProcessByOrderList"; Boolean result = RemoteCall.OrderPartition(_reqSession, openXLsFileDialog.FileName, "CreateProjectData", other, taskID);//processor:"ProcessByOrderList" if (result) { _TaskType = "CreateProjectData"; _TaskID = taskID.ToString(); int idx = _TaskID.IndexOf("#"); if (idx >= 0) { _TaskID = _TaskID.Substring(idx + 1); } _LastTaskID = _TaskID; AppendLog(String.Format("Success: upload orders: {0}, task:{1}", openXLsFileDialog.FileNames.ToString(), _TaskID)); } else { _TaskID = ""; _TaskType = ""; _LastTaskID = ""; this.listBoxLog.Items.Add(String.Format("Failed to upload orders")); } } }
public static int TaskProgress(WebRequestSession session, String taskID, StringBuilder taskError) { string url = "/caxa/task_progress"; try { Boolean bSSL = session.ssl; String host = session.host; int port = session.port; String urlReq = String.Format("{0}?taskid={1}", url, taskID); int nProgress = -1; String taskStatus = ""; StringBuilder errMessage = new StringBuilder(); String txtResult = RemoteCall.RESTGetAsString(bSSL, host, port, urlReq, errMessage); if (txtResult != null) { JObject jResult = JObject.Parse(txtResult); if ((int)jResult["result_code"] > 0) { if (!String.IsNullOrEmpty("" + jResult["task_id"])) { if (!String.IsNullOrEmpty("" + jResult["task_progress"])) { nProgress = Convert.ToInt32(jResult["task_progress"]); } if (!String.IsNullOrEmpty("" + jResult["task_status"])) { taskStatus = Convert.ToString(jResult["task_status"]); if (taskError != null) { taskError.Append(taskStatus); } } } } else { if (errMessage.Length > 0) { if (taskError != null) { taskError.Append(errMessage); } } } } return(nProgress); } catch (Exception e) { Debug.WriteLine(e.Message); } return(-1); }
public async Task <IActionResult> Index(RegisterViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (await _activationInformant.IsRegistered()) { return(RedirectToLocal(returnUrl)); } if (ModelState.IsValid) { var company = new Company { Name = model.CompanyName, NbEmployees = model.NumberOfEmployee, Mail = model.Email, Address = model.AddressNumber + " " + model.AddressStreet + ", " + model.AddressBox + ", " + model.AddressPostalCode + ", " + model.AddressCity + ", " + model.AddressCountry, Status = false }; var manager = new Employee { UserName = model.UserName, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, Wallet = (decimal)0.00, Company = company }; RemoteCall remoteCaller = RemoteCall.GetInstance(); CommWrap <Company> responseCompany = await remoteCaller.RegisterCompany(company); if (responseCompany.RequestStatus == 1) { company.Id = responseCompany.Content.Id; company.ChkCode = responseCompany.Content.ChkCode; var result = await _userManager.CreateAsync(manager, model.Password); if (result.Succeeded) { IdentityRole role = new IdentityRole { Name = "Responsable", NormalizedName = "RESPONSABLE" }; bool roleExist = await _roleManager.RoleExistsAsync(role.NormalizedName); if (!roleExist) { IdentityResult roleResult = await _roleManager.CreateAsync(role); if (roleResult.Succeeded) { await _userManager.AddToRoleAsync(manager, role.Name); } } else { await _userManager.AddToRoleAsync(manager, role.Name); } return(RedirectToLocal(returnUrl)); } AddErrors(result); } AddErrors("Registration failed on the Snack side"); } // If we got this far, something failed, redisplay form return(View(model)); }
/// <summary> /// Reserves a slot in the call list and prepares timeout timers in case the call wait time expires /// </summary> /// <param name="callback">The function to call when the answer is received</param> /// <param name="nodeID">The node that is getting the call</param> /// <param name="extraInfo">Any extra information to store for later usage</param> /// <param name="timeoutCallback">The function to call if the call timeout expires</param> /// <param name="timeoutSeconds">The amount of seconds to wait until timing out</param> /// <returns>The callID to be notified to the client</returns> public int ExpectRemoteServiceResult(Action <RemoteCall, PyDataType> callback, int nodeID, object extraInfo = null, Action <RemoteCall> timeoutCallback = null, int timeoutSeconds = 0) { RemoteCall entry = new RemoteCall { Callback = callback, ExtraInfo = extraInfo, TimeoutCallback = timeoutCallback, Client = null, NodeID = nodeID }; return(this.ExpectRemoteServiceResult(entry, timeoutSeconds)); }
public void InviteTimeoutCallback(RemoteCall callInfo) { // if the call timed out the character is not connected InviteExtraInfo call = callInfo.ExtraInfo as InviteExtraInfo; call.OriginalCall.Client.SendException( call.OriginalCall, new ChtCharNotReachable(this.CharacterDB.GetCharacterName(call.ToCharacterID)) ); }
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); } }
/// <summary> /// Callback fired by the <seealso cref="TimerManager"/> when a call timeout has been reached /// </summary> /// <param name="callID">The callID that expired</param> public void CallTimeoutExpired(int callID) { Log.Warning($"Timeout for call {callID} expired before getting an answer."); // get call id and call the timeout callback RemoteCall call = this.mCallCallbacks[callID]; // call the callback if available call.TimeoutCallback?.Invoke(call); // finally remove from the list this.mCallCallbacks.Remove(callID); }
public bool Exists(ExOrder objOrder) { string sql = $"select count(*) from orders where order_no='{objOrder.OrderNo}'"; if (Convert.ToInt32(RemoteCall.RESTQuery(_reqSession, sql).Rows[0][0]) > 0) { return(true); } else { return(false); } }
public bool DelOrder(ExOrder objOrder) { try { string sql = $"delete from orders where order_no='{objOrder.OrderNo}'"; RemoteCall.RESTQuery(_reqSession, sql); return(true); } catch (Exception) { return(false); } }
private void buttonNonQuery_Click(object sender, EventArgs e) { try { if (RemoteCall.RESTNonQuery(_reqSession, this.textBoxSQL.Text)) { //SQL 执行成功 listBoxSqlLog.Items.Add("Non Query Success"); } } catch (Exception err) { listBoxSqlLog.Items.Add(err.Message); //失败时,抛出错误信息 } }
private void buttonGetTask_Click(object sender, EventArgs e) { StringBuilder filePath = new StringBuilder(); Boolean result = RemoteCall.StartTask("0Hck3KI5kEmJWh", filePath); if (result) { AppendLog(String.Format("Success: task file: {0}", filePath.ToString())); Process.Start(filePath.ToString()); } else { this.listBoxLog.Items.Add(String.Format("Failed to get task")); } }
public void Call(FunctionId functionId, IMessage argument, CallOptions options = CallOptions.Default) { if ((options & CallOptions.Local) != 0) { functions[functionId]?.Invoke(argument); } if ((options & CallOptions.Remote) != 0) { RemoteCall?.Invoke(functionId, argument); } if ((options & CallOptions.Queue) != 0) { queuedRemoteCalls.Add((functionId, argument)); } }
private void buttonNextID_Click(object sender, EventArgs e) { try { int nextID = RemoteCall.GetNextID(_reqSession, "Product_Id"); if (nextID > 0) { listBoxSqlLog.Items.Add("NextID: Product_Id=" + nextID.ToString()); } } catch (Exception err) { listBoxSqlLog.Items.Add(err.Message); //失败时,抛出错误信息 } }
public void DownloadJobData(WebRequestSession req) { StringBuilder errMessage = new StringBuilder(); String file = RemoteCall.RESTGetAsFile(req.ssl, req.host, req.port, req.url, errMessage, req.cts); if (!String.IsNullOrEmpty(file) && File.Exists(file)) { File.Delete(file); try { Thread.Sleep(req.delay); } catch (Exception e) { } Interlocked.Increment(ref FinishedFiles); } }
private void buttonGetPicture_Click(object sender, EventArgs e) { StringBuilder filePath = new StringBuilder(); Boolean result = RemoteCall.GetTaskPic("BAT00170309000125000000", filePath); if (result) { AppendLog(String.Format("Success: taskList file: {0}", filePath.ToString())); Process.Start(filePath.ToString()); } else { this.listBoxLog.Items.Add(String.Format("Failed to get taskList")); } }
private static void ResolveStringAnsi(RemoteCall data, Stream pipe) { try { // Read Ansi string from memory of current process string stringAnsi = Marshal.PtrToStringAnsi((IntPtr)data.Parameters[0]); RemoteCallResult callResult = new RemoteCallResult { Result = stringAnsi }; // Write result back to the client formatter.Serialize(pipe, callResult); } catch (Exception e) { WriteExceptionToClient(pipe, e); } }
private static void ProcedureExists(RemoteCall data, Stream pipe, NativeLibrary library) { try { // Check if procedure with given name exists in target library bool exists = library.ProcedureExists(data.Name); RemoteCallResult callResult = new RemoteCallResult { Result = exists }; // Write result back to the client formatter.Serialize(pipe, callResult); } catch (Exception e) { WriteExceptionToClient(pipe, e); } }
//GeneratePartList private void buttonLines_Click(object sender, EventArgs e) { try { DataTable dt = RemoteCall.GetAssemblyLines(_reqSession); if ((dt != null) && (dt.Rows.Count >= 0)) { //SQL 执行成功 this.dataGridViewSql.DataSource = dt; listBoxSqlLog.Items.Add("Lines: " + dt.Rows.Count); } } catch (Exception err) { listBoxSqlLog.Items.Add(err.Message); //失败时,抛出错误信息 } }
private void buttonOrderFile_Click(object sender, EventArgs e) { try { StringBuilder resultFile = new StringBuilder(1024); Boolean result = RemoteCall.GetOrderFile(_reqSession, 1000, 1012, resultFile); if (result) { listBoxSqlLog.Items.Add("OrderFile: " + resultFile.ToString()); } } catch (Exception er) { listBoxSqlLog.Items.Add(er.Message); //失败时,抛出错误信息 } }
private void buttonQuery_Click(object sender, EventArgs e) { try { DataTable dt = RemoteCall.RESTQuery(_reqSession, this.textBoxSQL.Text); if ((dt != null) && (dt.Rows.Count >= 0)) { //SQL 执行成功 this.dataGridViewSql.DataSource = dt; listBoxSqlLog.Items.Add("Rows: " + dt.Rows.Count); } } catch (Exception err) { listBoxSqlLog.Items.Add(err.Message); //失败时,抛出错误信息 } }
public static int TaskCancel(WebRequestSession session, String taskID, StringBuilder taskError) { string url = "/caxa/task_cancel"; try { Boolean bSSL = session.ssl; String host = session.host; int port = session.port; JObject obj2Post = new JObject(); obj2Post["taskid"] = taskID; StringBuilder errMessage = new StringBuilder(); string txtResult = RemoteCall.PostJObject(session, url, obj2Post); if (txtResult != null) { JObject jResult = JObject.Parse(txtResult); if ((int)jResult["result_code"] > 0) { if (jResult["message"] != null) { if (taskError != null) { taskError.Append(txtResult); } } return(1); } } } catch (Exception e) { Debug.WriteLine(e.Message); if (taskError != null) { taskError.Append(e.Message); } } return(-1); }
/// <summary> /// Tells the ServiceManager that a call was completed successfully and invokes the success callback /// so the server can continue processing further /// </summary> /// <param name="callID">The callID that completed</param> /// <param name="result">The result of the call</param> public void ReceivedRemoteCallAnswer(int callID, PyDataType result) { if (this.mCallCallbacks.ContainsKey(callID) == false) { Log.Warning($"Received an answer for call {callID} after the timeout expired, ignoring answer..."); return; } // remove the timer from the list this.TimerManager.DequeueCallTimer(callID); // get the callback information RemoteCall call = this.mCallCallbacks[callID]; // invoke the handler call.Callback?.Invoke(call, result); // remove the call from the list this.mCallCallbacks.Remove(callID); }
/// <summary> /// Reserves a slot in the call list and prepares timeout timers in case the call wait time expires /// </summary> /// <param name="entry">The RemoteCall entry to associate with this call</param> /// <param name="timeoutSeconds">The amount of seconds to wait until timing out</param> /// <returns>The callID to be notified to the client</returns> private int ExpectRemoteServiceResult(RemoteCall entry, int timeoutSeconds = 0) { // get the new callID int callID = ++this.mNextCallID; // add the callback to the list this.mCallCallbacks[callID] = entry; // create the timer (if needed) if (timeoutSeconds > 0) { this.TimerManager.EnqueueCallTimer( DateTime.UtcNow.AddSeconds(timeoutSeconds).ToFileTimeUtc(), CallTimeoutExpired, callID ); } return(callID); }
public void InviteAnswerCallback(RemoteCall callInfo, PyDataType result) { InviteExtraInfo call = callInfo.ExtraInfo as InviteExtraInfo; if (result is PyString answer) { // this user's character might not be in the service // so fetch the name from the database call.OriginalCall.Client.SendException( call.OriginalCall, new UserError( answer, new PyDictionary { ["channel"] = this.DB.GetChannelName(call.ChannelID), ["char"] = this.CharacterDB.GetCharacterName(call.ToCharacterID) } ) ); } // return an empty response to the original calling client, this should get mechanism going for the JoinChannel notification call.OriginalCall.Client.SendCallResponse(call.OriginalCall, null); // character has accepted, notify all users of the channel string channelType = this.DB.GetChannelType(call.ChannelID); PyDataType notification = GenerateLSCNotification("JoinChannel", call.ChannelID, new PyTuple(0), callInfo.Client); // you should only be able to invite to global channels as of now // TODO: CORP CHANNELS SHOULD BE SUPPORTED TOO if (channelType == ChatDB.CHANNEL_TYPE_NORMAL) { // get users in the channel that are online now PyList characters = this.DB.GetOnlineCharsOnChannel(call.ChannelID); // notify them all call.OriginalCall.Client.ClusterConnection.SendNotification("OnLSC", "charid", characters, notification); } }
private void buttonGetObject_Click(object sender, EventArgs e) { StringBuilder filePath = new StringBuilder(); //Boolean result = RemoteCall.GetObjectData("4CE089D6-9FB9-40AF-A27A-33948FC5FC3C", "02ck3KICwBQyvF", filePath, "front"); //02ck3KICw6x5Tb //Boolean result = RemoteCall.GetObjectData("E09E68C9-EEDA-4966-AA4D-DCCCE465074B", "BAT00161212000818000003-BAT001612120008", filePath, ""); //Boolean result = RemoteCall.GetObjectData("E09E68C9-EEDA-4966-AA4D-DCCCE465074B", "BAT00161225000118000000-BAT001612250001", filePath, ""); Boolean result = RemoteCall.GetObjectData("SheetPicture", "BAT00170309000125000000-BAT001703090001", filePath, ""); //Boolean result = RemoteCall.GetObjectData("SheetPicture", "BAT00170309000118010001-BAT001703090001", filePath, ""); //req.url = "/caxa/get_object_data?proc_id=4CE089D6-9FB9-40AF-A27A-33948FC5FC3C&object_id=02ck3KICw6x5Tb&flag=front";//E09E68C9-EEDA-4966-AA4D-DCCCE465074B&object_id=0Hck3KI5kEmJWh&flag="; if (result) { AppendLog(String.Format("Success: object file: {0}", filePath.ToString())); Process.Start(filePath.ToString()); } else { this.listBoxLog.Items.Add(String.Format("Failed to get object")); } }