public ActionResult EditTimeCard(TimeCardVM card)
 {
     try
     {
         TimeSpan span = card.outTime.Subtract(card.inTime);
         if (span.TotalHours > 24 || span.TotalMinutes < 0)
         {
             // this doesn't work -- hah, does now -blake
             ViewBag.status = "Time can't be more than 24 hours or less than zero.";
             return(PartialView("_EditTimeCard", card));
         }
         ReturnStatus rs = Repository.EditTimeCard(card);
         if (rs.errorCode != ReturnStatus.ALL_CLEAR)
         {
             ViewBag.status = "Failed to update time card, please try again later.";
             return(PartialView("_EditTimeCard", card));
         }
         //return RedirectToAction("Timecards");
         //return succes partial view instead of redirect that way the redirect doesn't populate the modal
         //also gives the user some feedback
         return(PartialView("TimeCardPartialViews/_TimeCardSuccess"));
     }
     catch
     {
         return(View("_Error"));
     }
 }
 public ActionResult TimeCards(TimeCardSearchModel tsm)
 {
     try
     {
         ReturnStatus rs = Repository.GetTimeCardPageWithFilter(tsm.Page, tsm.orgId, tsm.projId, tsm.rangeStart, tsm.rangeEnd, tsm.queryString);
         if (rs.errorCode == ReturnStatus.ALL_CLEAR)
         {
             var pageIndex = tsm.Page ?? 1;
             List <TimeCardVM> pagedCards = (List <TimeCardVM>)rs.data;
             tsm.SearchResults = pagedCards.ToPagedList(pageIndex, RecordsPerPage);
             tsm.Page          = tsm.SearchResults.PageNumber;
             return(View(tsm));
         }
         //else if(rs.errorCode == ReturnStatus.ERROR_WHILE_ACCESSING_DATA)
         //{
         //    ViewBag.status = "debug, trouble in data layer -  ";
         //    return View(tsm);
         //}
         ViewBag.status = "No results for that time period";// awwSnapMsg;
         return(View(tsm));
     }
     catch
     {
         return(View("Error"));
     }
 }
Ejemplo n.º 3
0
    public static void handleReturnStatusInternal(string methodName, LogLevel methodLevel, ReturnStatus rs, IntPtr textPtr) {
      string message;
      LogLevel level;
      rs.GetInfo(out message, out level);

      LogLevel maxLevel = (LogLevel)Math.Max((int)level, (int)methodLevel);

      if (maxLevel >= logLevel) {
        string totalMessage = methodName + " returned " + message;

        if (maxLevel == LogLevel.Error) {
          if (textPtr != IntPtr.Zero) {
            totalMessage += "\n";
            totalMessage += Marshal.PtrToStringAnsi(textPtr);
          }

          throw new Exception(totalMessage);
        }

        if (maxLevel == LogLevel.Warning) {
          UnityEngine.Debug.LogWarning(totalMessage);
        } else {
          UnityEngine.Debug.Log(totalMessage);
        }
      }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// 发送请求,返回字符串
        /// </summary>
        /// <param name="data">返回的字符串</param>
        /// <returns></returns>
        public ReturnStatus SendRequest(ref string data)
        {
            ReturnStatus status = new ReturnStatus();

            if (URL == string.Empty)
            {
                status.exception = new ArgumentNullException();
                return(status);
            }

            FileStream fs = new FileStream(SwapFileLocation, FileMode.Create);

            switch (requestType)
            {
            case RequestType.GET: status = HttpGet(false, URL, GetSerializedParams(requestType), ref fs, ref data); break;

            case RequestType.POST: status = HttpPost(false, URL, GetSerializedParams(requestType), ref fs, ref data); break;

            default: break;
            }

            fs.Flush();
            fs.Close();
            fs.Dispose();

            try { File.Delete(SwapFileLocation); } catch { }


            return(status);
        }
Ejemplo n.º 5
0
        public async Task <ReturnStatus> SendVerificationEmailAsync(string emailAddress, string emailView)
        {
            ReturnStatus retVal = new ReturnStatus()
            {
                IsSuccessful  = true,
                ErrorMessages = new List <string>(),
            };

            IdentityUser user = await UserManager.FindByEmailAsync(emailAddress);

            if (user == null)
            {
                retVal.IsSuccessful = false;
                retVal.ErrorMessages.Add(ErrorCodeConstants.ERROR_USER_DOES_NOT_EXIST);
            }
            else
            {
                SendGrid.Response response = await EmailSender.SendEmailAsync(emailAddress, "Hello from ShimMath.com", html : emailView);

                if (response.StatusCode != System.Net.HttpStatusCode.Accepted)
                {
                    retVal.IsSuccessful = false;
                    retVal.ErrorMessages.Add(ErrorCodeConstants.ERROR_VERIFICATION_EMAIL_SEND_FAILED);
                }
            }
            return(retVal);
        }
        /// <summary>
        /// Called by NCalc when attempting to evaluate custom functions.
        /// </summary>
        /// <param name="funcName">Name of the function being evaluated</param>
        /// <param name="args">Arguments for the function specified by funcName</param>
        protected void FunctionHandler(string funcName, FunctionArgs args)
        {
            List <double> evaluatedParams = new List <double>(args.Parameters.Length);

            foreach (Expression curParam in args.Parameters)
            {
                ReturnStatus <double> evaluateStatus = EvaluateExpression(curParam);
                if (evaluateStatus.IsValid)
                {
                    evaluatedParams.Add(evaluateStatus.Value);
                }
                else
                {
                    args.Result = double.NaN;
                    this.functionHandlingErrorEncountered = true;
                    return;
                }
            }

            ReturnStatus <bool> retStatus = HandleCustomFunctions(funcName, args, evaluatedParams);

            if (retStatus.IsValid == false)
            {
                args.Result = double.NaN;
                this.functionHandlingErrorEncountered = true;
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Status")] ReturnStatus returnStatus)
        {
            if (id != returnStatus.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(returnStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReturnStatusExists(returnStatus.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(returnStatus));
        }
Ejemplo n.º 8
0
        public async Task <ReturnStatus> SendEmailVarification(string emailAdress)
        {
            ReturnStatus returnStatus = new ReturnStatus()
            {
                IsSuccessful = false,
            };
            string confirmationToken = await userSvc.GetVerificationCodeAsync(emailAdress);

            ShimMathUser user = await userSvc.GetUserByEmailAsync(emailAdress);

            VerifyEmailModel model = new VerifyEmailModel()
            {
                UserName        = user.Username,
                ConfirmationUrl = Url.ActionLink(
                    "ConfirmEmail/" + user.ID + "/" + confirmationToken,
                    "Account",
                    protocol: HttpContext.Request.Scheme),
            };
            string emailView = await ControllerExtensions.RenderViewAsync <VerifyEmailModel>(this, "/Views/Email/VerifyEmail.cshmtl", model, true);

            if (!string.IsNullOrEmpty(emailView))
            {
                returnStatus = await userSvc.SendVerificationEmailAsync(emailAdress, emailView);
            }

            return(returnStatus);
        }
Ejemplo n.º 9
0
        public ActionResult ListHfhEvents()
        {
            ReturnStatus    rs        = Repository.GetAllHfhEvents();
            List <HfhEvent> hfhEvents = (rs.errorCode == ReturnStatus.ALL_CLEAR) ? (List <HfhEvent>)rs.data : new List <HfhEvent>();

            return(View(hfhEvents));
        }
        //See EvaluationJob.FunctionHandler for documentation
        protected override ReturnStatus <bool> HandleCustomFunctions(string funcName,
                                                                     FunctionArgs args,
                                                                     List <double> evaluatedArgs)
        {
            ReturnStatus <bool> retStatus = new ReturnStatus <bool>();

            switch (funcName)
            {
            case FUNC_NAME_SNAP:
                retStatus.IsValid = HandleSnapFunc(args, evaluatedArgs);
                break;

            case FUNC_NAME_LFO:
                retStatus.IsValid = HandleLfoFunc(args, evaluatedArgs);
                break;

            case FUNC_NAME_WAVEFORM:
                retStatus.IsValid = HandleWaveformFunc(args, evaluatedArgs);
                break;

            default:
                return(HandleBaseFunctions(funcName, args, evaluatedArgs));
            }

            retStatus.Value = true;
            return(retStatus);
        }
        // public ActionResult PunchIn([Bind(Include = "userId,projectId,orgId")] PunchInVM punchInVM)
        public ActionResult PunchIn(PunchInVM punchInVM)

        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (punchInVM.orgId < 1)
                    {
                        punchInVM.orgId = 1; // force the -1 to be org #1, relies on orgId 1 == "Individual"
                    }
                    TimeSheet sheet = new TimeSheet();
                    sheet.user_Id      = punchInVM.userId;
                    sheet.project_Id   = punchInVM.projectId;
                    sheet.clockInTime  = DateTime.Now;
                    sheet.clockOutTime = DateTime.Today.AddDays(1);
                    sheet.org_Id       = punchInVM.orgId;

                    //TODO: check error code?
                    ReturnStatus st = Repository.PunchIn(sheet);
                    if (st.errorCode != ReturnStatus.ALL_CLEAR)
                    {
                        return(RedirectToAction("HandleErrors", "User", new { excMsg = "punchin action" }));
                    }
                    //    return RedirectToAction("VolunteerPortal", "User");
                }


                return(RedirectToAction("VolunteerPortal", "User", new { justPunched = 1 }));
            }
            catch
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 12
0
        private ReturnStatus HttpGet(bool isSave, string Url, string postDataStr, ref FileStream fs, ref string writeTo)
        {
            ReturnStatus status = new ReturnStatus();

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
                request.Method      = "GET";
                request.ContentType = "text/html;charset=UTF-8";

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                response.Cookies = cookie.GetCookies(response.ResponseUri);

                if (isSave)
                {
                    ReadResponseToFileStream(ref fs, response);
                }
                else
                {
                    ReadResponseToString(ref writeTo, response);
                }

                status.statusCode = response.StatusCode;
            }
            catch (Exception e)
            {
                status.exception = e;
#if DEBUG
                Console.WriteLine(e);
#endif
            }

            return(status);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="path">文件下载的路径及文件名</param>
        public ReturnStatus Download(string path)
        {
            ReturnStatus status = new ReturnStatus();

            if (URL == string.Empty || path == string.Empty)
            {
                status.exception = new ArgumentNullException();
                return(status);
            }

            FileStream fs = new FileStream(path, FileMode.Create);

            string str = string.Empty;

            switch (requestType)
            {
            case RequestType.GET: status = HttpGet(true, URL, GetSerializedParams(requestType), ref fs, ref str); break;

            case RequestType.POST: status = HttpPost(true, URL, GetSerializedParams(requestType), ref fs, ref str); break;

            default: break;
            }

            fs.Flush();
            fs.Close();
            fs.Dispose();

            if (!status.IsSuccess())
            {
                try { File.Delete(path); } catch { }
            }

            return(status);
        }
Ejemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public ReturnStatus handshakewithplc()
 {
     Initialization(SiemensType.S1200, "172.16.8.204");
     //SocketBaseKit.SocketBase.
     // Write();
     return(ReturnStatus.CreatSuccessStatus <bool>());
 }
Ejemplo n.º 15
0
        public ActionResult DeleteTimeCard(int?id)
        {
            try
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                //TimeSheet timeSheet = db.timeSheets.Find(id);
                //if (timeSheet == null)
                //{
                //    return HttpNotFound();
                //}
                //return View(timeSheet);

                ReturnStatus rs = Repository.GetTimeCardVM((int)id);
                if (rs.errorCode != ReturnStatus.ALL_CLEAR)
                {
                    ViewBag.status = "Sorry, something went wrong while retrieving information.";
                    //TODO: change this to return some sort of error partial or the modal will blow up
                    return(View());
                }

                return(PartialView("TimeCardPartialViews/_DeleteTimeCard", (TimeCardVM)rs.data));
            }
            catch
            {
                return(View("_Error"));
            }
        }
Ejemplo n.º 16
0
 public ResultBase(ApiResultCodes code, string message = null,
                   object result = null, ReturnStatus returnStatus = ReturnStatus.Success)
 {
     this.Code         = code;
     this.Result       = result;
     this.Message      = code.Description() + " \r\n " + message;
     this.ReturnStatus = returnStatus;
 }
Ejemplo n.º 17
0
 public BaseResultModel(int?Code      = null, string Message = null,
                        object Result = null, ReturnStatus ReturnStatus = ReturnStatus.Success)
 {
     this.Code         = Code;
     this.Result       = Result;
     this.Message      = Message;
     this.ReturnStatus = ReturnStatus;
 }
Ejemplo n.º 18
0
        public static ReturnStatus GetLastError(ref INTERACTION_SCENE scene,
                                                out IntPtr messagePtr)
        {
            ReturnStatus rs = GetLastError(ref scene);

            messagePtr = GetLastErrorString();
            return(rs);
        }
Ejemplo n.º 19
0
 public BaseResultModel(int?code      = null, string message = null,
                        object result = null, ReturnStatus returnStatus = ReturnStatus.Success)
 {
     this.Code         = code;
     this.Result       = result;
     this.Message      = message;
     this.ReturnStatus = returnStatus;
 }
Ejemplo n.º 20
0
 public void Init(bool simulateReceiptPrinting)
 {
     simulate = simulateReceiptPrinting;
     prnStatus += this.Status;
     printerStatus = 3; // Indicates Error status of Printer.
     printerState = 2; // Indicates Printer Offline State.
     printerStatusDesc = "Printer In Offline State.";
     //monitor = this;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Evaluates the equation and stores the output in OutputVal.
        /// </summary>
        /// <returns>
        /// True if the output is valid and false if the equation could not be evaluated.
        /// </returns>
        public virtual bool Execute()
        {
            ReturnStatus <double> outputStatus = EvaluateExpression(this.expression);

            this.OutputIsValid = outputStatus.IsValid;
            this.OutputVal     = outputStatus.Value;

            return(this.OutputIsValid);
        }
        /// <summary>
        /// Will attempt to update the item score for this response.  If there are no more
        /// responses waiting for action, it will also flip the test status to 'handscored'
        /// and submit the file back to the source bin in xmlrepo for TIS to pick up and process.
        /// </summary>
        /// <param name="scoredResponse"></param>
        /// <returns></returns>
        public ScorableTest UpdateItemScore(ScoredResponse scoredResponse)
        {
            ReturnStatus returnStatus = null;
            SqlCommand   cmd          = CreateCommand(CommandType.StoredProcedure, "SD_UpdateItemScore");
            MemoryStream ms           = null;

            int[] itemKey = scoredResponse.GetItemKeyTokens();

            try
            {
                cmd.AddUniqueIdentifier("oppkey", scoredResponse.OppKey);
                cmd.AddInt("itemBank", itemKey[0]);
                cmd.AddInt("itemKey", itemKey[1]);
                //cmd.AddInt("position", scoredResponse.Position);
                cmd.AddInt("sequence", scoredResponse.Sequence); // TODO: this will be reportingversion
                cmd.AddInt("score", scoredResponse.Score);
                cmd.AddVarChar("scorestatus", scoredResponse.ScoreStatus, 150);
                if (!String.IsNullOrEmpty(scoredResponse.ScoreRationale))
                {
                    cmd.AddVarCharMax("scoreRationale", scoredResponse.ScoreRationale);
                }
                //cmd.AddUniqueIdentifier("scoremark", scoredResponse.ScoreMark);
                if (!String.IsNullOrEmpty(scoredResponse.ScoreDimensions))
                {
                    ms = new MemoryStream();
                    scoredResponse.ScoreInfoAsXml().Save(ms);
                    cmd.AddXml("scoreDimensions", new SqlXml(ms));
                }

                ExecuteReader(cmd, delegate(IColumnReader reader)
                {
                    if (reader.Read())
                    {
                        returnStatus = ReturnStatus.Parse(reader);
                    }
                });
            }
            finally
            {
                if (ms != null)
                {
                    ms.Dispose();
                }
            }

            // if the sproc didn't return success, it means that the opp was not in a state that allows
            //  item score updates.  Either the reportingVersion didn't match or the opp was not in handscoring or appeal status
            //  Log the score in this case so that we have a record of it.
            if (!returnStatus.Status.Equals("success"))
            {
                TDSLogger.Application.Info(new TraceLog(String.Format("Item Scoring: Did not accept score: {0}", scoredResponse.AsString())));
            }

            // always returning null for ScorableTest.  Will not support test scoring here.  That will be the responsibility of TIS
            return(null);
        }
Ejemplo n.º 23
0
        public ActionResult DeleteConfirmed(int id)
        {
            ReturnStatus rs = Repository.DeleteHfhEventById(id);

            if (rs.errorCode == ReturnStatus.ALL_CLEAR)
            {
                return(RedirectToAction("ListHfhEvents"));
            }
            return(View("_Error"));
        }
Ejemplo n.º 24
0
        // GET: HfhEvent/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReturnStatus rs = Repository.GetHfhEventById((int)id);

            return((rs.errorCode == ReturnStatus.ALL_CLEAR) ? View((HfhEvent)rs.data) : View("_Error"));
        }
Ejemplo n.º 25
0
        private string GetOperText(ReturnStatus status)
        {
            string result = "处理";

            if (status == ReturnStatus.Refused || status == ReturnStatus.Returned || status == ReturnStatus.MerchantsAgreed)
            {
                result = "详情";
            }
            return(result);
        }
Ejemplo n.º 26
0
        public ActionResult Volunteers(VolunteerSearchModel vsm, string excMsg)
        {
            try
            {
                if (!string.IsNullOrEmpty(excMsg))
                {
                    ViewBag.status = excMsg;
                }
                if (vsm.projects == null)
                {
                    vsm = new VolunteerSearchModel();
                    return(View(vsm));
                }
                ReturnStatus rs = Repository.GetAllVolunteers(vsm.projectId, vsm.orgId);

                if (rs.errorCode != 0)
                {
                    ViewBag.status = awwSnapMsg;
                    return(View(vsm));
                }

                List <UsersVM> allVols      = (List <UsersVM>)rs.data;
                List <UsersVM> filteredVols = new List <UsersVM>();

                if (vsm.queryString == null)
                {
                    vsm.queryString = ""; //no name contains null, turn into empty string instead
                }
                if (!string.IsNullOrEmpty(vsm.queryString) || vsm.Page.HasValue)
                {
                    foreach (UsersVM u in allVols)
                    {
                        if (u != null && vsm.queryString != null)
                        {
                            if (u.email.ToLower().Contains(vsm.queryString.ToLower()) || u.volunteerName.ToLower().Contains(vsm.queryString.ToLower()))
                            {
                                filteredVols.Add(u);
                            }
                        }
                    }
                    var pageIndex = vsm.Page ?? 1;
                    vsm.SearchResults = filteredVols.ToPagedList(pageIndex, RecordsPerPage);
                }
                else
                {
                    var pageIndex = vsm.Page ?? 1;
                    vsm.SearchResults = allVols.ToPagedList(pageIndex, RecordsPerPage);
                }
                return(View(vsm));
            }
            catch
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 27
0
        public static ReturnLogInformation DefineReturn(ReturnStatus ReturnType, String ReturnMessage, List <InformationLogs> ReturnValue)
        {
            ReturnLogInformation ThisReturn = new ReturnLogInformation();

            ThisReturn.ReturnType     = ReturnType;
            ThisReturn.ReturnMessage  = ReturnMessage;
            ThisReturn.ReturnDateTime = DateTime.UtcNow;
            ThisReturn.ReturnValue    = ReturnValue;

            return(ThisReturn);
        }
Ejemplo n.º 28
0
        public async Task <IActionResult> Create([Bind("Id,Status")] ReturnStatus returnStatus)
        {
            if (ModelState.IsValid)
            {
                _context.Add(returnStatus);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(returnStatus));
        }
Ejemplo n.º 29
0
        void SetHandleCommandReturnValue(SbCommandInterpreter mockCommandInterpreter,
                                         string command, ReturnStatus returnStatus,
                                         SbCommandReturnObject returnObject)
        {
            SbCommandReturnObject _;

            mockCommandInterpreter.HandleCommand(command, out _).Returns(x => {
                x[1] = returnObject;
                return(returnStatus);
            });
        }
Ejemplo n.º 30
0
        public static ReturnKnowType DefineReturn(String Message, ReturnStatus Status, Object Value)
        {
            ReturnKnowType ThisReturn = new ReturnKnowType();

            ThisReturn.ReturnMessage  = Message;
            ThisReturn.ReturnType     = Status;
            ThisReturn.ReturnValue    = Value;
            ThisReturn.ReturnDateTime = DateTime.UtcNow;

            return(ThisReturn);
        }
Ejemplo n.º 31
0
        public ActionResult WaiverDetails(int?id)
        {
            ReturnStatus  rs     = Repository.GetAWaiverById((int)id);
            WaiverHistory waiver = new Models.WaiverHistory();

            if (rs.errorCode == ReturnStatus.ALL_CLEAR)
            {
                waiver = (WaiverHistory)rs.data;
            }
            return(View(waiver));
        }
Ejemplo n.º 32
0
        //returns ReturnStatus object with error message explaining why the user object is invalid
        //error message is empty if the object is valid and IsSuccessful is true too.
        private ReturnStatus IsValidUserObject(ShimMathUser user)
        {
            ReturnStatus retVal = new ReturnStatus()
            {
                IsSuccessful  = true,
                ErrorMessages = new List <string>(),
            };

            passwordDoesNotHaveCorrectFormat(user.Password);
            return(retVal);
        }
Ejemplo n.º 33
0
        public short GetStatus(ReturnStatus pStatus)
        {
            short opCode = -1;

            opCode = Reset();
            if (opCode != -1)
            {
                byte[] enq = { 29, 121 }; // Request Combined Printer Status - [GS]y / [29][121] / 1DH 79H
                this.pStatus = pStatus;
                opCode = this.Write(enq, enq.Length, true, 4); // 4 bytes status response is expected from printer.
                //System.Threading.Thread.Sleep(500);
            }
            return opCode;
        }
Ejemplo n.º 34
0
 public void Init(bool simulateReceiptPrinting)
 {
     System.Diagnostics.Trace.WriteLine(string.Format("Printer Init Called with simulate flage set to : {0}", simulateReceiptPrinting));
     using (FileStream stream = new FileStream(@"Printer.log", FileMode.Append, FileAccess.Write))
     {
         StreamWriter writer = new StreamWriter(stream);
         writer.WriteLine(@"Printer Init Called with simulated flag set to : {0}..",simulateReceiptPrinting);
         writer.Flush();
         writer.Close();
     }
     simulate = simulateReceiptPrinting;
     prnStatus += this.Status;
     printerStatus = 3; // Indicates Error status of Printer.
     printerState = 2; // Indicates Printer Offline State.
     printerStatusDesc = "Printer In Offline State.";
     //monitor = this;
 }
Ejemplo n.º 35
0
 /// <remarks/>
 public void DummyAsync(ReturnStatus status, Role role, object userState) {
     if ((this.DummyOperationCompleted == null)) {
         this.DummyOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDummyOperationCompleted);
     }
     this.InvokeAsync("Dummy", new object[] {
                 status,
                 role}, this.DummyOperationCompleted, userState);
 }
Ejemplo n.º 36
0
        public virtual void Close(ReturnStatus status)
        {
            if(GUI.FocusComponent == this)
            {
                GUI.FocusComponent = null;
            }

            isClosed = true;
            IsVisible = false;

            OnClosed.Invoke(status);
            Parent.RemoveChild(this);
        }
        //See EvaluationJob.FunctionHandler for documentation
        protected override ReturnStatus<bool> HandleCustomFunctions(string funcName, 
            FunctionArgs args,
            List<double> evaluatedArgs)
        {
            ReturnStatus<bool> retStatus = new ReturnStatus<bool>();

            switch (funcName)
            {
                case FUNC_NAME_SNAP:
                    retStatus.IsValid = HandleSnapFunc(args, evaluatedArgs);
                    break;
                case FUNC_NAME_LFO:
                    retStatus.IsValid = HandleLfoFunc(args, evaluatedArgs);
                    break;
                case FUNC_NAME_WAVEFORM:
                    retStatus.IsValid = HandleWaveformFunc(args, evaluatedArgs);
                    break;
                default:
                    return HandleBaseFunctions(funcName, args, evaluatedArgs);
            }

            retStatus.Value = true;
            return retStatus;
        }
Ejemplo n.º 38
0
 public ReturnInfo(string msg = "", ReturnStatus status = ReturnStatus.Fail)
 {
     if (string.IsNullOrEmpty(msg))
     {
         Status = true;
         this.ReturnStatus = ReturnStatus.Success;
         Message = string.Empty;
     }
     else
     {
         Status = status == ReturnStatus.Fail ? false : true;
         ReturnStatus = status;
         Message = msg;
     }
 }
Ejemplo n.º 39
0
 public void Dummy(ReturnStatus status, Role role) {
     this.Invoke("Dummy", new object[] {
                 status,
                 role});
 }
Ejemplo n.º 40
0
 public static void HandleReturnStatus(INTERACTION_SCENE scene, string methodName, LogLevel methodLevel, ReturnStatus rs) {
   IntPtr messagePtr;
   InteractionC.GetLastError(ref scene, out messagePtr);
   handleReturnStatusInternal(methodName, methodLevel, rs, messagePtr);
 }
Ejemplo n.º 41
0
        //Return true if the function was handled
        protected ReturnStatus<bool> HandleBaseFunctions(string funcName, 
            FunctionArgs args,
            List<double> evaluatedArgs)
        {
            ReturnStatus<bool> retStatus = new ReturnStatus<bool>();

            switch (funcName)
            {
                case FUNC_NAME_LIMIT:
                    retStatus.IsValid = HandleLimitFunc(args, evaluatedArgs);
                    break;
                default:
                    retStatus.IsValid = true;
                    retStatus.Value = false;
                    return retStatus;
            }

            retStatus.Value = true;
            return retStatus;
        }
Ejemplo n.º 42
0
 public static void HandleReturnStatus(string methodName, LogLevel methodLevel, ReturnStatus rs) {
   IntPtr messagePtr = InteractionC.GetLastErrorString();
   handleReturnStatusInternal(methodName, methodLevel, rs, messagePtr);
 }
Ejemplo n.º 43
0
        private IEnumerator InternalSendRequest(string url, WWWFormParams toAddToUrl, WebServiceStatus returnStatus)
        {
            WWW www;
            try
            {
                WWWForm form = null;
                if(toAddToUrl != null && toAddToUrl.TypeOfRequest != WWWFormParams.RequestType.GET)
                {
                    form = new WWWForm();
                    if(toAddToUrl.PostParams != null)
                    {
                        foreach(var kvp in toAddToUrl.PostParams)
                        {
                            form.AddField(kvp.Key, kvp.Value);
                        }
                    }

                    if(toAddToUrl.BinaryPostParams != null)
                    {
                        foreach(var kvp in toAddToUrl.BinaryPostParams)
                        {
                            form.AddBinaryData(kvp.Key, kvp.Value);
                        }
                    }
                }
                if(toAddToUrl != null && toAddToUrl.headers != null)
                {
                    if(form == null)
                        form = new WWWForm();
                    foreach(var header in toAddToUrl.headers)
                    {
                        if(toAddToUrl.headers.ContainsKey(header.Key))
                            form.headers[header.Key] = header.Value;
                        else
                            form.headers.Add(header.Key, header.Value);
                    }
                }
                string fullUrlWithGetParams;
                if(toAddToUrl != null)
                    fullUrlWithGetParams = GetFullUrl(url, toAddToUrl.GetParams);
                else
                    fullUrlWithGetParams = GetFullUrl(url);
                if(form == null)
                    www = new WWW(fullUrlWithGetParams);
                else
                    www = new WWW(fullUrlWithGetParams, form);
            }
            catch(Exception e)
            {
                Debug.LogError("Error in setting up with www call" + e);
                Log.LogError("Error in setting up with www call" + e);
                returnStatus.ErrorMessage = "Error setting up www call" + e.Message;
                returnStatus.Status = ReturnStatus.INTERNAL_ERROR;
                OnWebserviceFinishedSignal.Dispatch(status);
                yield break;
            }

            yield return www;
            while(!www.isDone)
            {
                yield return null;
            }
            yield return null;

            if(www.error != null)
            {
                //TODO: find the appropriate codes/messages for transport error
                returnStatus.Status = ReturnStatus.TRANSPORT_ERROR;
                returnStatus.Status = ReturnStatus.INTERNAL_ERROR;
                returnStatus.ErrorMessage = www.error;
                www.Dispose();
                OnWebserviceFinishedSignal.Dispatch(status);
                yield break;
            }

            try
            {
                status.Text = www.text;
            }
            catch(Exception e)
            {
                Log.LogError("Error in reading values from www object after yielding on it" + e);
                status.ErrorMessage = "Error in reading values from www object after yielding on it" + e.Message;
                status.Status = ReturnStatus.INTERNAL_ERROR;
                Status = ReturnStatus.INTERNAL_ERROR;

                www.Dispose();
                OnWebserviceFinishedSignal.Dispatch(status);
                yield break;
            }

            www.Dispose();

            status.Status = ReturnStatus.SUCCESS;
            try
            {
                OnWebserviceFinishedSignal.Dispatch(status);
            }
            catch(Exception e)
            {
                Log.LogError("Error returning from web service" + e);
                status.ErrorMessage = "Error returning from web service" + e.Message + " stack: " + e.StackTrace;
                status.Status = ReturnStatus.INTERNAL_ERROR;
            }
        }
Ejemplo n.º 44
0
 public void SendRequest(string url, WWWFormParams toAddToUrl = null)
 {
     var routine = InternalSendRequest(url, toAddToUrl, status);
     CoroutineRunner.StartCoroutine(routine);
     Status = status.Status;
 }
Ejemplo n.º 45
0
 /// <remarks/>
 public void DummyAsync(ReturnStatus status, Role role) {
     this.DummyAsync(status, role, null);
 }