Пример #1
0
 /* public static OrderTypeEnum CastEnumType(StOrder_Type type)
  * {
  *  if (type == StOrder_Type.StOrder_Type_Limit) return OrderTypeEnum.LIMIT;
  *  else if (type == StOrder_Type.StOrder_Type_Stop) return OrderTypeEnum.STOP;
  *  else throw new SmartException(ExceptionImportanceLevel.MEDIUM, "OrderTypeEnum", "Server", "No other choice type: " + type);
  * }
  * public static ActionEnum CastEnumAction(StOrder_Action action)
  * {
  *  if (action == StOrder_Action.StOrder_Action_Buy) return ActionEnum.BUY;
  *  else if (action == StOrder_Action.StOrder_Action_Sell) return ActionEnum.SELL;
  *  else throw new SmartException(ExceptionImportanceLevel.MEDIUM, "CastEnumAction", "Server", "No other choice: " + action);
  * } */
 private void ConnectStockServer()
 {
     if (!IsConnected)
     {
         try
         {
             WriteToLog("Trying to connect");
             Form.WriteToStatus("Trying to connect");
             if (WasConnected)
             {
                 EmailSender.SendEmail("Stocks Stopped", "Robot Stopped because the connection was lost. Will be reconnected by Monitor");
                 Environment.Exit(0);
             }
             else
             {
                 WasConnected = true;
             }
             SmartComServer.connect(ServerIP, ushort.Parse(ServerPort), Login, Password);
         }
         catch (Exception e)
         {
             //EmailSender.SendEmail(e);
             WriteToLog(e.Message);
             throw new SmartException(e);
         }
     }
 }
Пример #2
0
 /* public static OrderTypeEnum CastEnumType(StOrder_Type type)
  * {
  *  if (type == StOrder_Type.StOrder_Type_Limit) return OrderTypeEnum.LIMIT;
  *  else if (type == StOrder_Type.StOrder_Type_Stop) return OrderTypeEnum.STOP;
  *  else throw new SmartException(ExceptionImportanceLevel.MEDIUM, "OrderTypeEnum", "Server", "No other choice type: " + type);
  * }
  * public static ActionEnum CastEnumAction(StOrder_Action action)
  * {
  *  if (action == StOrder_Action.StOrder_Action_Buy) return ActionEnum.BUY;
  *  else if (action == StOrder_Action.StOrder_Action_Sell) return ActionEnum.SELL;
  *  else throw new SmartException(ExceptionImportanceLevel.MEDIUM, "CastEnumAction", "Server", "No other choice: " + action);
  * } */
 private void ConnectStockServer()
 {
     if (!IsConnected)
     {
         try
         {
             WriteToLog("Trying to connect");
             Form.WriteToStatus("Trying to connect");
             SmartComServer.connect(ServerIP, ushort.Parse(ServerPort), Login, Password);
         }
         catch (Exception e)
         {
             EmailSender.SendEmail(e);
             WriteToLog(e.Message);
             throw e;
         }
     }
 }