public static ReturnObject GetShiftSetting(string company_code)
    {
        DBConnection db_connection            = new DBConnection();
        DataTable    shift_setting_data_table = new DataTable();
        ReturnObject return_object            = new ReturnObject();
        string       query = string.Empty;

        try
        {
            query = "select actual as break_type, isaso as is_auto_shift, isramadan as is_ramadan, convert (varchar, ramadanstdt, 103) as ramadan_from_date, convert (varchar, ramadantodt, 103) as ramadan_to_date, convert(varchar(5),breakhrs,108) as break_hours, BreakDeductionRequired as break_deduction_required, Convert(varchar(5),MinWorkHrsforDeduction,108) as min_work_hours_for_deduction, TotalDeductionTime as break_deduction, Convert(varchar(5), MINWORKHRS, 108) as min_work_hours, Convert(varchar(5),MAXWORKHRS,108) as max_work_hours, FromDay as from_day, TOday as to_day, Blokday as block_day, MaxHolidayCount as max_holiday_count , convert(varchar(5),WeeklyOffCutoffTime , 108) as cutoff_time from shiftsetting where companycode = '" + company_code + "' ";
            shift_setting_data_table = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(shift_setting_data_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_SHIFT_SETTINGS");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Shift Settings. Please try again. If the error persists, please contact Support.";
        }

        return(return_object);
    }
Example #2
0
    public static ReturnObject DeleteDevice(string current)
    {
        device_information page_object     = new device_information();
        DBConnection       db_connection   = new DBConnection();
        ReturnObject       return_object   = new ReturnObject();
        string             branch_code     = string.Empty;
        string             device_location = string.Empty;
        string             device_id       = string.Empty;

        try
        {
            JObject current_data = JObject.Parse(current);
            device_location = current_data["device_location"].ToString();
            device_id       = current_data["device_id"].ToString();

            page_object.UpdateDeviceLocation("D", device_location, device_id);

            return_object.status      = "success";
            return_object.return_data = "Device Location deleted successfully!";
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "DELETE_DEVICE_LOCATION");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while deleting the Device Location. Please try again. If the error persists, please contact Support.";
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }
Example #3
0
    public static ReturnObject GetBranchData()
    {
        DBConnection db_connection = new DBConnection();
        ReturnObject return_object = new ReturnObject();
        DataTable    branch_data   = new DataTable();
        string       query         = string.Empty;

        try
        {
            query       = "select BranchCode, BranchName from branchmaster";
            branch_data = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(branch_data, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_BRANCH_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Branch data. Please try again. If the error persists, please contact Support.";
        }

        return(return_object);
    }
Example #4
0
 private void getDebugModeOutput(ReturnObject obj)
 {
     Application.Current.Dispatcher.Invoke(new Action(() => {
         //update Debug Mode Output
         MainWindow.main.DebugModeOutput.Text = "ReturnObject: " + obj.FaceDetected + "\n Emotion: " + obj.Emotion;
     }));
 }
    public static ReturnObject GetRamadanHistoryData(string company_code)
    {
        DBConnection db_connection        = new DBConnection();
        ReturnObject return_object        = new ReturnObject();
        DataSet      return_data          = new DataSet();
        DataTable    ramadan_history_data = new DataTable();
        string       query = string.Empty;

        try
        {
            // get all the RamadanHistory
            query = "select companycode as company_code, Year as 'year', FromDate as from_date, ToDate as 'to_date'  from RamadanHistory where CompanyCode='" + company_code + "'";
            ramadan_history_data = db_connection.ReturnDataTable(query);
            //ramadan_history_data.TableName = "selected_holidays";
            return_data.Tables.Add(ramadan_history_data);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(return_data, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_RAMADAN_HISTORY");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Ramadan History data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }
Example #6
0
    public static ReturnObject UpdateSessionTimeout()
    {
        ReturnObject return_Object = new ReturnObject();

        try
        {
            Configuration       configuration;
            SessionStateSection section;
            configuration = WebConfigurationManager.OpenWebConfiguration("~");
            section       = (SessionStateSection)configuration.GetSection("system.web/sessionState");
            if (section != null)
            {
                section.Timeout = TimeSpan.FromMinutes(40);
                configuration.Save();
                return_Object.status      = "success";
                return_Object.return_data = "Session timeout saved successfully!";
            }
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "UPDATE SESSION TIMEOUT");

            return_Object.status      = "error";
            return_Object.return_data = "An error occurred while loading Company data. Please try again. If the error persists, please contact Support.";

            throw;
        }
        return(return_Object);
    }
Example #7
0
        public ReturnObject Cadastrar(PlanoTelefonia plano)
        {
            ReturnObject retorno = new ReturnObject
            {
                StatusCode = HttpStatusCode.BadRequest,
                Messages   = new List <string>()
            };

            PlanoTelefonia planoDB = _planoTelefoniaRepository.GetPlanoPorCodigo(plano.Codigo);

            if (planoDB == null)
            {
                PlanoTelefoniaTipo planoTipoDb = _planoTelefoniaRepository.GetPlanoTipoPorTipo(plano.Tipo.Tipo);

                if (planoTipoDb != null)
                {
                    plano.Tipo = planoTipoDb;

                    _planoTelefoniaRepository.InsertPlanoTelefonia(plano);

                    retorno.StatusCode = HttpStatusCode.Created;
                    retorno.Messages.Add("Plano de telefonia criado com sucesso!");
                }
                else
                {
                    retorno.Messages.Add("Tipo de plano informado não encontrado");
                }
            }
            else
            {
                retorno.Messages.Add("Plano de telefonia já cadastrado");
            }
            return(retorno);
        }
Example #8
0
        public async Task <IHttpActionResult> SaveUserDetails([FromBody] SaveUserRequestVM request)
        {
            try
            {
                var res = new ReturnObject <dynamic>();

                var userEmail = Request.GetOwinContext().Request.User.Identity.Name;

                using (var context = new ApplicationDbContext())
                {
                    var user = await context.Users.Where(i => i.Email == userEmail).FirstOrDefaultAsync();

                    user.PhoneNumber = request.PhoneNumber;
                    user.FullName    = request.FullName;
                    user.Address     = request.Address;
                    user.DateOfBirth = request.DateOfBirth;
                    user.PhoneNumber = request.PhoneNumber;

                    context.Users.Attach(user);
                    context.Entry(user).State = EntityState.Modified;
                    await context.SaveChangesAsync();

                    res.IsSuccess = true;
                    res.Message   = "Saved Successfully";

                    return(Ok(res));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #9
0
    public static ReturnObject GetSessionTimeout()
    {
        Configuration       configuration;
        SessionStateSection section;
        string       timeout       = string.Empty;
        ReturnObject return_Object = new ReturnObject();

        try
        {
            configuration             = WebConfigurationManager.OpenWebConfiguration("~");
            section                   = (SessionStateSection)configuration.GetSection("system.web/sessionState");
            timeout                   = section.Timeout.ToString();
            return_Object.status      = "success";
            return_Object.return_data = timeout.ToString();
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET SESSION TIMEOUT");

            return_Object.status      = "error";
            return_Object.return_data = "An error occurred while loading Company data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_Object);
    }
Example #10
0
    public static ReturnObject GetLeaveTypeData(string company_code)
    {
        ReturnObject return_object        = new ReturnObject();
        DBConnection db_connection        = new DBConnection();
        DataTable    leavetype_data_table = new DataTable();
        string       leavetype_query      = string.Empty;

        try
        {
            leavetype_query = " select LeaveCode, LeaveName FROM LeaveMaster where LeaveCode not in ('CO','OD','V') and companycode='" + company_code + "'";

            leavetype_data_table = db_connection.ReturnDataTable(leavetype_query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(leavetype_data_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_LEAVE_TYPE");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Leave Type data. Please try again. If the error persists, please contact Support.";
        }
        return(return_object);
    }
Example #11
0
        public async Task <IHttpActionResult> RemoveCurrentEnquiries()
        {
            var userEmail = Request.GetOwinContext().Request.User.Identity.Name;

            try
            {
                var res = new ReturnObject <dynamic>();
                using (var context = new ApplicationDbContext())
                {
                    var list = await context.UserEnquireis.Where(i => i.User.Email == userEmail &&
                                                                 i.ActiveTill > DateTime.Now).ToListAsync();

                    context.UserEnquireis.RemoveRange(list);

                    await context.SaveChangesAsync();

                    res.IsSuccess = true;

                    return(Ok(res));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Example #12
0
    public static ReturnObject getEnrolledCards(int page_number)
    {
        int          start_row        = (page_number - 1) * 30;
        int          number_of_record = (page_number * 30) + 1;
        DBConnection db_connection    = new DBConnection();
        DataTable    enrollment_data  = new DataTable();
        ReturnObject return_object    = new ReturnObject();
        string       query            = "";

        try {
            query = "select Enrollid, cardid, pin, Empid, Name, row from ( select Enrollid, cardid, pin, Empid, Name, ROW_NUMBER() OVER (ORDER BY Cast(enrollid as int)) as row from enrollmaster) a where row > " + start_row + " and row < " + number_of_record;

            enrollment_data = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(enrollment_data, Formatting.Indented);
        }
        catch (Exception ex) {
            Logger.LogException(ex, page, "GET_ENROLLED_CARDS");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while performing this operation. Please try again. If the error persists, please contact Support.";
        }

        return(return_object);
    }
Example #13
0
    public static ReturnObject GetCompanyData()
    {
        ReturnObject return_object = new ReturnObject();
        DBConnection db_connection = new DBConnection();
        DataTable    company_data  = new DataTable();
        string       employee_id   = HttpContext.Current.Session["employee_id"].ToString();
        string       company_query = string.Empty;

        try
        {
            if (employee_id == "")
            {
                company_query = "select distinct CompanyName, CompanyCode from companymaster";
            }
            else
            {
                company_query = "select CompanyCode, CompanyName from companymaster where companycode = (select emp_company from employeemaster where emp_Code = '" + employee_id + "')";
            }

            company_data = db_connection.ReturnDataTable(company_query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(company_data, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_COMPANY_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Company Data. Please try again. If the error persists, please contact Support.";
        }
        return(return_object);
    }
Example #14
0
 private void OnLoadGameEvent(ReturnObject RO)
 {
     if (LoadGameEvent != null)
     {
         LoadGameEvent(RO);
     }
 }
Example #15
0
        public void FakeDeposite(int numOfTrans)
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);

            _ethBus = new Vakapay.EthereumBusiness.EthereumBusiness(persistenceFactory);
            var trans = new EthereumDepositTransaction()
            {
                UserId      = "8377a95b-79b4-4dfb-8e1e-b4833443c306",
                ToAddress   = "0x12890d2cce102216644c59dae5baed380d84830c",
                FromAddress = "0x3a2e25cfb83d633c184f6e4de1066552c5bf4517",
                Amount      = 10
            };
            ReturnObject outPut = null;

            for (int i = 0; i < numOfTrans; i++)
            {
                outPut = _ethBus.FakeDepositTransaction(trans);
            }
            Console.WriteLine(JsonHelper.SerializeObject(outPut));
            Assert.IsNotNull(outPut);
        }
 /// <summary>
 /// Raises the SaveGameSelectEvent event
 /// </summary>
 /// <param name="RO">ReturnObject</param>
 private void OnSaveGameSelectEvent(ReturnObject RO)
 {
     if (SaveGameSelectEvent != null)
     {
         SaveGameSelectEvent(RO);
     }
 }
Example #17
0
    public void btnSetQuestions_Click(object sender, EventArgs e)
    {
        var questions_answer = repQuestions.Items.OfType <RepeaterItem>().Select
                               (
            ri => new UserQuestion()
        {
            QuestionText = ((DropDownList)ri.FindControl("ddlQuestions")).SelectedItem.Text,
            Answer       = ((TextBox)ri.FindControl("txtQuestionAnswer")).Text
        }
                               ).ToArray();

        new UserServiceClient().Using(client =>
        {
            ReturnObject ro = client.SetUserQuestionsAndAnswers(Username, questions_answer);
            if (ro.ReturnCode != 0)
            {
                lblFailureMessage.Text = ro.DefaultErrorMessage;
            }
            else
            {
                if (QuestionsSuccessfullyChanged != null)
                {
                    QuestionsSuccessfullyChanged(this, EventArgs.Empty);
                }
                ShowNextRegion(Username);
            }
        });

        ShowNextRegion(Username);
    }
Example #18
0
        private ReturnObject AllowUnShelve(UnShelveParams param)
        {
            ReturnObject       reObject = new ReturnObject();
            List <ManageModel> taskList = bllManage.GetWaitRunTaskListByType("8");//下架任务

            if (taskList == null)
            {
                reObject.Status   = false;
                reObject.Describe = "当前系统不允许下达下架任务!只允许执行一个任务";
                return(reObject);
            }
            if (taskList != null && taskList.Count > 0)
            {
                reObject.Status   = false;
                reObject.Describe = "当前系统不允许下达下架任务!只允许执行一个任务";
                return(reObject);
            }
            //View_Plan_StockListModel planStock = bllViewPlanStockList.GetModelByPalletCode(param.PalletCode);
            //if (planStock != null)
            //{
            //    if ( param.WareHouseCode != planStock.Plan_Remark)//不等于计划的上架库房返回false
            //    {
            //        reObject.Status = false;
            //        reObject.Describe = "下架库房与计划的下架架库房不符,请选择计划的下架库房,计划下架的库房为:" + planStock.Plan_Remark;
            //        return reObject;
            //    }
            //}
            reObject.Status   = true;
            reObject.Describe = "";
            return(reObject);
        }
Example #19
0
        public ReturnObject Get(string id)
        {
            ReturnObject  obj           = new ReturnObject();
            DaoPermission daoPermission = new DaoPermission(bookingServicesContext);

            try
            {
                var data = daoPermission.getById(id);
                if (data != null)
                {
                    obj.status = 200;
                    obj.data   = data;
                }
                else
                {
                    obj.status = 404;
                }
            }
            catch (Exception ex)
            {
                obj.status  = 404;
                obj.message = ex.StackTrace;
            }
            return(obj);
        }
Example #20
0
    public void btnLogin_Click(object sender, EventArgs e)
    {
        string username = txtUsername.Text;
        string password = txtPassword.Text;

        new UserServiceClient().Using(client =>
        {
            bool bIsUserValid = (bool)client.ValidateUser(username, password).ReturnValue;
            if (bIsUserValid)
            {
                Session["NCIPL_User"] = username;
                ReturnObject ro       = client.GetRolesForUser(username);
                try
                {
                    Session["NCIPL_Role"] = ((string[])ro.ReturnValue)[0];
                }
                catch (Exception)
                {
                }


                ShowNextRegion(txtUsername.Text);
            }
            else
            {
                //do not give auth ticket
                ReturnObject ro = client.GetValidationFailureReason(username);
                //display failure code on login screen
                lblFailureMessage.Text = ro.DefaultErrorMessage;
            }
        });
    }
    public static ReturnObject GetUnprocessedData(int page_number)
    {
        DBConnection db_connection    = new DBConnection();
        ReturnObject return_object    = new ReturnObject();
        DataTable    unprocessed_data = new DataTable();
        int          start_row        = (page_number - 1) * 30;

        string
            query = string.Empty;

        try
        {
            // JOIN with employee master to get employee code.
            query = "select cardno, empid, Punch_time from unprocessed_punches";
            query = "select up.cardno as card_number, e.Emp_code as employee_code, up.Punch_time as punch_time from Unprocessed_punches up left outer join EmployeeMaster e on up.cardno = e.Emp_Card_No ORDER BY up.Punch_Time DESC OFFSET " + start_row + " ROWS FETCH NEXT 30 ROWS ONLY";

            unprocessed_data = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(unprocessed_data, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_UNPROCESSED_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Unprocessed data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }
Example #22
0
        public ReturnObject GetAll([FromBody] Query query)
        {
            ReturnObject  obj           = new ReturnObject();
            DaoPermission daoPermission = new DaoPermission(bookingServicesContext);

            try
            {
                var data = daoPermission.GetAll(query.PageIndex, query.PageSize, query.Title);
                if (data != null)
                {
                    obj.status = 200;
                    obj.data   = data;
                }
                else
                {
                    obj.status = 404;
                }
            }
            catch (Exception ex)
            {
                obj.status  = 404;
                obj.message = ex.StackTrace;
            }
            return(obj);
        }
Example #23
0
    public static ReturnObject CheckShiftCodeAssigned(string shift_code)
    {
        masters_manage_shift page_object   = new masters_manage_shift();
        DBConnection         db_connection = new DBConnection();
        ReturnObject         return_object = new ReturnObject();
        string query     = string.Empty;
        int    is_active = 0;

        try
        {
            /*check for Employee is anybody has this shift */
            query     = "SELECT count(Emp_Shift_Detail) from EmployeeMaster where Emp_Shift_Detail='" + shift_code + "' and Emp_Status=1 ";
            is_active = db_connection.GetRecordCount(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(is_active, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_COMPANY_CATEGORY");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading data for OT Eligibility. Please try again. If the error persists, please contact Support.";

            throw;
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }
Example #24
0
        public override void Delete()
        {
            this.AssignDataInternal();
            ReturnObject <Boolean> ret = (this.ComponentServer as ICrud).Delete();

            this.DisplayMessageList = ret.GetMessage((this.IsError = ret.HasError()) ? Message.Type.Error : Message.Type.Information);
        }
Example #25
0
    public static ReturnObject EditDepartment(string current, string previous)
    {
        masters_department page_object              = new masters_department();
        ReturnObject       return_object            = new ReturnObject();
        string             original_department_name = string.Empty;
        string             company_code             = string.Empty;
        string             department_code          = string.Empty;
        string             department_name          = string.Empty;
        int count = 0;

        if (HttpContext.Current.Session["username"] == null)  // checking session expired or not
        {
            return_object = page_object.DoLogout();
        }
        else
        {
            try
            {
                JObject current_data = JObject.Parse(current);
                company_code    = current_data["company_code"].ToString();
                department_code = current_data["department_code"].ToString();
                department_name = current_data["department_name"].ToString();

                JObject previous_data = JObject.Parse(previous);
                original_department_name = previous_data["department_name"].ToString();

                if (original_department_name != department_name)
                {
                    count = page_object.CheckDepartmentName(department_name, company_code);
                    if (count > 0)
                    {
                        return_object.status      = "error";
                        return_object.return_data = "Department Name has been taken. Please try again with a different Name";

                        return(return_object);
                    }
                }

                page_object.UpdateDatabase("U", department_code, department_name, company_code);

                return_object.status      = "success";
                return_object.return_data = "Department edited successfully!";
            }
            catch (Exception ex)
            {
                Logger.LogException(ex, page, "EDIT_DEPARTMENT");

                return_object.status      = "error";
                return_object.return_data = "An error occurred while saving the Department. Please try again. If the error persists, please contact Support.";

                throw;
            }
            finally
            {
                page_object.Dispose();
            }
        }

        return(return_object);
    }
Example #26
0
        public ReturnObject Update([FromBody] Permission entity)
        {
            ReturnObject  obj           = new ReturnObject();
            DaoPermission daoPermission = new DaoPermission(bookingServicesContext);

            try
            {
                var data = daoPermission.Update(entity);
                if (data != null)
                {
                    obj.status = 200;
                    obj.data   = data;
                }
                else
                {
                    obj.status = 404;
                }
            }
            catch (Exception ex)
            {
                obj.status  = 404;
                obj.message = ex.StackTrace;
            }
            return(obj);
        }
Example #27
0
    public static ReturnObject GetLeaveTypeData()
    {
        DBConnection db_connection    = new DBConnection();
        DataTable    leave_type_table = new DataTable();
        ReturnObject return_object    = new ReturnObject();
        string       query            = string.Empty;

        try
        {
            query            = "select LeaveTypeName as leave_type from leave_type_table ";
            leave_type_table = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(leave_type_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_LEAVE_TYPE_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Leave type data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }
Example #28
0
    public static ReturnObject GetEmployeeCategoryData(string company_code)
    {
        DBConnection db_connection = new DBConnection();
        DataTable    employeeCategory_data_table = new DataTable();
        ReturnObject return_object = new ReturnObject();
        string       query         = string.Empty;

        try
        {
            query = "select e.EmpCategoryCode as employee_category_code, e.EmpCategoryName as employee_category_name, c.CompanyCode, c.CompanyName, e.Totalhrs, e.includeprocess as process from EmployeeCategoryMaster e, CompanyMaster c where e.companyCode = c.CompanyCode and c.CompanyCode = '" + company_code + "' order by e.EmpCategoryCode";
            employeeCategory_data_table = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(employeeCategory_data_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_EMPLOYEE_CATEGORY_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Employee Category data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }
Example #29
0
    public static ReturnObject GetHolidayGroupData(string company_code)
    {
        DBConnection db_connection       = new DBConnection();
        ReturnObject return_object       = new ReturnObject();
        DataTable    holiday_groups_data = new DataTable();
        string       query = string.Empty;

        try
        {
            query = "select holgrpcode as holiday_group_code, holgrpname as holiday_group_name from HolidayGroup where companycode = '" + company_code + "' order by holgrpname";
            holiday_groups_data = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(holiday_groups_data, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_HOLIDAY_GROUPS");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Holiday Groups data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }
Example #30
0
    public void btnResetPassword_Click(object sender, EventArgs e)
    {
        var questions_answer = repAnswers.Items.OfType <RepeaterItem>().Select
                               (
            ri => new UserQuestion()
        {
            UserQuestionID = Convert.ToInt32(((HiddenField)ri.FindControl("hidUserQuestionID")).Value),
            Answer         = ((TextBox)ri.FindControl("txtQuestionAnswer")).Text
        }
                               ).ToArray();

        new UserServiceClient().Using(client =>
        {
            ReturnObject ro = client.ResetPassword(Username, questions_answer);
            if (ro is ErrorReturnObject)
            {
                lblFailureMessage.Text = ro.DefaultErrorMessage;
            }
            else
            {
                phResetSuccessful.Visible = true;
                phQuestions.Visible       = false;
            }
        });
    }
Example #31
0
 private void OnSaveGameEvent(ReturnObject RO)
 {
     if (SaveGameEvent != null)
     {
         SaveGameEvent(RO);
     }
 }
Example #32
0
    /// <summary>
    /// Saves SDS and GameStateCollection to disk
    /// </summary>
    /// <remarks>
    /// Before we get here, we'll need to have updated the status on PlayerInfo
    /// and GameState with dates, sectors, and positions and such.
    /// </remarks>
    private ReturnObject WriteSDS()
    {
        ReturnObject ro = new ReturnObject();

        try
        {
            // SDS
            using (StreamWriter file = File.CreateText(gameSavePath + gds.Current_Game_ID + ".save"))
            {
                using (JsonTextWriter writer = new JsonTextWriter(file))
                {
                    writer.Formatting = Formatting.Indented;
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(writer, gds.SDS);

                    ro.Return_Status = Enums.Return_Status.OK;
                    ro.Friendly_Message = "SDS has been written to disk";
                }
            }

            //GameState Collection Header File
            using (StreamWriter file = File.CreateText(gameSavePath + gameStateFile))
            {
                using (JsonTextWriter writer = new JsonTextWriter(file))
                {
                    writer.Formatting = Formatting.Indented;
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(writer, gds.GSC);

                    ro.Return_Status = Enums.Return_Status.OK;
                    ro.Friendly_Message += "  GSC has been written to disk";
                }
            }
        }
        catch (Exception ex)
        {
            //Something went wrong with the writing of the save game file and the save game header.
            ro.Return_Status = Enums.Return_Status.Error;
            ro.Friendly_Message="Unable to save the current game.";
            ro.Technical_Message = "Unable to save the current game: " + ex.Message;
            ro.Return_Object = null;
        }

        return ro;
    }
 /// <summary>
 /// Accepts the click event from the instance of the SaveGameListingItem, 
 /// in the form of a ReturnObject instance
 /// </summary>
 /// <param name="RO">ReturnObject</param>
 /// <remarks>
 /// <para>
 /// When a list item is clicked, it passes us a ReturnObject which contains
 /// its GUID (which is also the name of the save game file). We take that RO
 /// and store the Return_Object value (GUID) in a local variable.
 /// </para>
 /// <para>
 /// We don't "cannonize" the GUID until the player clicks the LOAD GAME button,
 /// so this handler can be called multiple times, every time the user clicks
 /// a save game entry.
 /// </para>
 /// </remarks>
 private void SaveGameSelectEventHandler(ReturnObject RO)
 {
     selectedSaveGameGUID = RO.Return_Object.ToString();
 }
Example #34
0
    private ReturnObject ReadSDS()
    {
        ReturnObject ro = new ReturnObject();

        try
        {
            if (File.Exists(gameSavePath + gds.Current_Game_ID + ".save"))
            {
                string stringSDS = File.ReadAllText(gameSavePath + gds.Current_Game_ID + ".save");
                SDS sds = JsonConvert.DeserializeObject<SDS>(stringSDS);
                
                gds.SDS.InventoryItems = sds.InventoryItems;
                gds.SDS.PlayerInfo = sds.PlayerInfo;
                gds.SDS.CurrentGameState = sds.CurrentGameState;

                sds = null;

                ro.Return_Status = Enums.Return_Status.OK;
                ro.Friendly_Message = "SDS has been loaded.";
                ro.Technical_Message = ro.Friendly_Message;
            }
            else
            {
                //Uh...file doesn't exist
            }
        }
        catch (Exception ex)
        {
            //Something went wrong with the reading of the save game file
            ro.Return_Status = Enums.Return_Status.Error;
            ro.Friendly_Message = "Unable to load the selected game.";
            ro.Technical_Message = "Unable to load the selected game: " + ex.Message;
            ro.Return_Object = null;
        }

        return ro;
    }
    /// <summary>
    /// The final step in loading a game; hides the UI and transfers the user to the proper scene.
    /// </summary>
    /// <param name="RO">ReturnObject</param>
    private void LoadGameEventHandler(ReturnObject RO)
    {
        uim.HideUI(UIManager.UIELEMENTS.LoadingUI);

        //Have scene transfer live on SceneController. 
        GameObject sc = GameObject.Find("SceneController");
        SceneManager sm = sc.GetComponent<SceneManager>();

        //SceneTransfer st = sceneController.GetComponent<SceneTransfer>();
        sm.SwitchScene("Alcyone");      //On a load, this would come from SDS
        Debug.Log("A-OK!");
    }
Example #36
0
    /// <summary>
    /// Loads MDS data from disk
    /// </summary>
    /// <returns>ReturnObject: Status bearing object</returns>
    /// <remarks>
    /// <para>Loads the MDS database from disk. If there is no file, we're screwed.</para>
    /// <para>Once MDS has been loaded, it's immediately transferred to the SDS, and
    /// the loading object is nulled.</para>
    /// <para>Raises the LoadMDSDataEevent(RO) on completion.</para>
    /// </remarks>
    ReturnObject LoadMDSData()
    {

        ReturnObject ro;

        if (File.Exists(MDSFilePath + MDSFileName))
        {
            try
            {
                string stringMDS = File.ReadAllText(MDSFilePath + MDSFileName);
                MDS mds = JsonConvert.DeserializeObject<MDS>(stringMDS);

                gds.SDS.TransferFromMDS(mds);
                mds = null;

                ro = new ReturnObject(Enums.Return_Status.OK, "MDS loaded and transferred to SDS.", "MDS loaded and transferred to SDS.", null);
            }
            catch (Exception ex)
            {
                ro = new ReturnObject(Enums.Return_Status.Error, "Error loading MDS.", "Error loading MDS: " + ex.Message, null);
            }
        }
        else
        {
            //Uh...we don't have the file on disk...
            ro = new ReturnObject(Enums.Return_Status.Error, "Master data file was not found. Please reinstall.", "MDS file wasn't found at path " + MDSFilePath + MDSFileName, null);
        }

        OnLoadMDSDataEvent(ro);

        return ro;
    }
Example #37
0
 private void OnLoadGameEvent(ReturnObject RO)
 {
     if (LoadGameEvent != null)
     {
         LoadGameEvent(RO);
     }
 }
Example #38
0
    private void SaveGameEventHandler(ReturnObject RO)
    {
        //At this point, the new game has been generated and saved to disk. 
        //Hide the Loading UI and send the user to wherever they need to be.
        uim.HideUI(UIManager.UIELEMENTS.LoadingUI);

        //Have scene transfer live on SceneController. 
        GameObject sc = GameObject.Find("SceneController");
        SceneManager sm = sc.GetComponent<SceneManager>();

        //SceneTransfer st = sceneController.GetComponent<SceneTransfer>();
        sm.SwitchScene("Alcyone");      //On new, this would be the initial scene
        Debug.Log("A-OK!");
    }
Example #39
0
 /// <summary>
 /// Raises LoadSaveGameListingEvent 
 /// </summary>
 /// <param name="RO">ReturnObject</param>
 void OnLoadSaveGameListingEvent(ReturnObject RO)
 {
     if (LoadSaveGameListingEvent != null)
     {
         LoadSaveGameListingEvent(RO);
     }
 }
 /// <summary>Sets the return code and text into the return object passed.</summary>
 /// <param name="returnObject">Return object to set</param>
 /// <param name="returnCode">Return code to set</param>
 /// <param name="returnText">Return text to set</param>
 private void setReturnCode(ReturnObject returnObject, int returnCode, String returnText)
 {
     returnObject.returnCode = returnCode;
     returnObject.returnText = returnText;
 }
Example #41
0
 public void Init(ReturnObject<PooledObject> returnObject)
 {
     _returnObject = returnObject;
 }
        /// <summary> Method to stop speech recognition</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void stopRecognition(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopRecognition: Entered method.");
            PluginResult result = null;
            ReturnObject returnObject = new ReturnObject();

            if (currentRecognizer != null){
            // stop the recognizer
            currentRecognizer.stopRecording();
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopRecognition: Recognition started.");
            setReturnCode(returnObject, RC_SUCCESS, "Reco Stop Success");
            returnObject.eventName = EVENT_RECO_STOPPED;
            recording = false;
            }
            else{
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopRecognition: Recognizer was null, start not called.");
            setReturnCode(returnObject, RC_RECO_NOT_STARTED, "Reco Stop Failure: Recognizer not started.");
            }

            result = new PluginResult(PluginResult.Status.OK, returnObject);
            result.KeepCallback = true;
            DispatchCommandResult(result);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopRecognition: Leaving method.");
            //return result;
        }
        /// <summary>Stops TTS playback</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void stopTTS(String args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopTTS: Entered method.");
            PluginResult result = null;
            ReturnObject returnObject = new ReturnObject();

            //ttsCallbackId = callbackId;

            if (vocalizerInstance != null){
            vocalizerInstance.cancel();
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopTTS: Vocalizer cancelled.");
            setReturnCode(returnObject, RC_SUCCESS, "Success");
            returnObject.eventName = EVENT_TTS_COMPLETE;

            }
            else{
            setReturnCode(returnObject, RC_TTS_NOT_STARTED, "TTS Stop Failure: TTS not started.");
            }
            result = new PluginResult(PluginResult.Status.OK, returnObject);
            DispatchCommandResult(result);

            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.stopTTS: Leaving method.");
        }
        /// <summary> Method to start speech recognition</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void startRecognition(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startRecognition: Entered method.");
            PluginResult result = null;

            StartRecoParameters startParams = JsonHelper.Deserialize<StartRecoParameters>(args);

            ReturnObject returnObject = new ReturnObject();
            if (speechKit != null){

            if (recording == false)
            {

                // get the recognition type
                String recognitionType = startParams.recognitionType;
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: startReco: Reco Type = [" + recognitionType + "]");
                String recognizerType = RecognizerRecognizerType.Dictation;
                if ("websearch".Equals(recognitionType, StringComparison.CurrentCultureIgnoreCase))
                {
                    recognizerType = RecognizerRecognizerType.Search;
                }
                // get the language
                String language = startParams.language;
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: startReco: Language = [" + language + "]");

                lastResult = null;

                // create and start the recognizer reference
                Thread thread = new Thread(() =>
                {
                    currentRecognizer = speechKit.createRecognizer(recognizerType, RecognizerEndOfSpeechDetection.Long, language, this, null);
                    currentRecognizer.start();
                });
                thread.Start();

                //_currentRecognizer = _speechKit.createRecognizer(recognizerType, RecognizerEndOfSpeechDetection.Long, language, this, new object());
                //_currentRecognizer.start();

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Recognition started.");
                setReturnCode(returnObject, RC_SUCCESS, "Reco Start Success");
                returnObject.eventName = EVENT_RECO_STARTED;
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Recognition already started.");
                setReturnCode(returnObject, RC_SUCCESS, "Reco Already Active");
                returnObject.eventName = EVENT_RECO_ALREADY_STARTED;
            }
            }
            else
            {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Speech kit was null, initialize not called.");
            setReturnCode(returnObject, RC_NOT_INITIALIZED, "Reco Start Failure: Speech Kit not initialized.");
            }

            result = new PluginResult(PluginResult.Status.OK, returnObject);
            result.KeepCallback = true;

            DispatchCommandResult(result);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startRecognition: Leaving method.");
            //return result;
        }
        /// <summary>Starts TTS playback</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void startTTS(String args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Entered method.");

            PluginResult result = null;
            ReturnObject returnObject = new ReturnObject();

            StartTTSParameters startParams = JsonHelper.Deserialize<StartTTSParameters>(args);

            String ttsText = startParams.text;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS Text = ["+ttsText+"]");
            String language = startParams.language;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Language = ["+language+"]");
            String voice = startParams.voice;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Voice = ["+voice+"]");

            if ((ttsText == null) || ("".Equals(ttsText))){
            setReturnCode(returnObject, RC_TTS_TEXT_INVALID, "TTS Text Invalid");
            }
            else
            if ((language == null) && (voice == null)){
            setReturnCode(returnObject, RC_TTS_PARAMS_INVALID, "Invalid language or voice.");
            }
            else
            if (speechKit != null){
            if (vocalizerInstance == null){

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Vocalizer was not null.");

                if (language != null){
                    vocalizerInstance = speechKit.createVocalizerWithLanguage(language, this, null);
                }
                else{
                    vocalizerInstance = speechKit.createVocalizerWithVoice(voice, this, null);
                }

            }
            else{

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Vocalizer was null.");
                if (language != null){
                    vocalizerInstance.setLanguage(language);
                }
                else{
                    vocalizerInstance.setVoice(voice);
                }

            }

            _lastTtsContext = new Object();
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Calling speakString.");
            vocalizerInstance.speakString(ttsText, _lastTtsContext);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Called speakString.");

            setReturnCode(returnObject, RC_SUCCESS, "Success");
            }
            else{
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.execute: Speech kit was null, initialize not called.");
            setReturnCode(returnObject, RC_NOT_INITIALIZED, "TTS Start Failure: Speech Kit not initialized.");
            }

            result = new PluginResult(PluginResult.Status.OK, returnObject);
            result.KeepCallback = true;
            DispatchCommandResult(result);

            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.startTTS: Leaving method.");
        }
        /// <summary>Callback method for TTS starting to speak</summary>
        public void onSpeakingBegin(Vocalizer vocalizer, String text, Object context)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingBegin: Entered method");

                ReturnObject returnObject = new ReturnObject();

                setReturnCode(returnObject, RC_SUCCESS, "TTS Playback Started");
                returnObject.eventName = EVENT_TTS_STARTED;
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingDone: TTS Started...");

                PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                result.KeepCallback = true;
                DispatchCommandResult(result);

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingBegin: Leaving method.");
        }
        /// <summary>Callback method for TTS speaking done</summary>
        public void onSpeakingDone(Vocalizer vocalizer, String text, SpeechError error, Object context)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingDone: Context = [" + context + "], last context = " + _lastTtsContext);
                // Use the context to detemine if this was the final TTS phrase
                if (context != _lastTtsContext)
                {
                    ReturnObject returnObject = new ReturnObject();

                    setReturnCode(returnObject, RC_SUCCESS, "TTS Playing...");
                    returnObject.eventName = EVENT_TTS_PLAYING;

                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingDone: TTS Playing...");

                    PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                    result.KeepCallback = true;
                    DispatchCommandResult(result);

                }
                else
                {

                    ReturnObject returnObject = new ReturnObject();

                    setReturnCode(returnObject, RC_SUCCESS, "TTS Playback Complete");
                    returnObject.eventName = EVENT_TTS_COMPLETE;
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingDone: TTS Complete...");

                    PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                    DispatchCommandResult(result);

                }

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Vocalizer.Listener.onSpeakingDone: Leaving method.");
        }
        /// <summary>Callback method for recording done event</summary>
        public void onRecordingDone(Recognizer recognizer)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingDone: Entered method.");
                recording = false;
                try{
                    ReturnObject returnObject = new ReturnObject();
                    setReturnCode(returnObject, RC_SUCCESS, "Processing");
                    returnObject.eventName = EVENT_RECO_PROCESSING;

                    PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                    result.KeepCallback = true;
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingDone: Reco Done... success:");
                    DispatchCommandResult(result);

                }
                catch(Exception e){
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingDone: Error setting return: "+e);
                }
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingDone: Leaving method.");
        }
        /// <summary>Callback method for recognition complete with results</summary>
        public void onResults(Recognizer recognizer, Recognition results)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Entered method.");
                currentRecognizer = null;
                recording = false;

                lastResult = results;
                string resultString = results.getResult(0).getText();

                ReturnObject returnObject = new ReturnObject();
                try{
                    setReturnCode(returnObject, RC_SUCCESS, "Reco Success");
                    returnObject.eventName = EVENT_RECO_COMPLETE;
                    returnObject.result = resultString;
                    returnObject.results = getResultArray(results);
                    //returnObject.put("results", resultArray);
                }
                catch(Exception je){
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Error storing results: " + je.ToString());
                }
                //success(returnObject, recognitionCallbackId);
                PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                DispatchCommandResult(result);

                // for debugging purpose: printing out the speechkit session id
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onResults: Leaving method.  Results = " + resultString);
        }
        /// <summary>Callback method for recording error event</summary>
        public void onError(Recognizer recognizer, SpeechError error)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onError: Entered method.");
                if (recognizer != currentRecognizer) return;
                currentRecognizer = null;
                recording = false;

                // Display the error + suggestion in the edit box
                String detail = error.getErrorDetail();
                String suggestion = error.getSuggestion();
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onError: Detail = " + detail + "Suggestion = "+suggestion);

                ReturnObject returnObject = new ReturnObject();
                try{
                    setReturnCode(returnObject, RC_RECO_FAILURE, "Reco Failure");
                    returnObject.eventName = EVENT_RECO_ERROR;
                    returnObject.result = detail;
                }
                catch(Exception e){
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onError: Error storing results: " + e);
                }
                PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                DispatchCommandResult( result );

                // for debugging purpose: printing out the speechkit session id
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onError: Leaving method.");
        }
        /// <summary>Callback method for recording started event</summary>
        public void onRecordingBegin(Recognizer recognizer)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingBegin: Entered method.");
                System.Diagnostics.Debug.WriteLine("Recording...");
                recording = true;

                try{
                    ReturnObject returnObject = new ReturnObject();
                    setReturnCode(returnObject, RC_SUCCESS, "Recording Started");
                    returnObject.eventName = EVENT_RECO_STARTED;

                    PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                    result.KeepCallback = true;
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingBegin: Reco Started... ");
                    DispatchCommandResult(result);

                }
                catch(Exception e){
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingBegin: Error setting return: "+e.ToString());
                }

                Thread thread = new Thread(() =>
                {
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Volume level thread starting.");
                    while ((currentRecognizer != null) && (recording == true))
                    {
                        try
                        {
                            ReturnObject returnObject = new ReturnObject();

                            returnObject.eventName = EVENT_RECO_VOLUME_UPDATE;
                            returnObject.volumeLevel =  currentRecognizer.getAudioLevel();

                            PluginResult result = new PluginResult(PluginResult.Status.OK, returnObject);
                            result.KeepCallback = true;

                            DispatchCommandResult(result);

                        }
                        catch (Exception e)
                        {
                            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingDone: Error setting return: " + e.ToString());
                        }
                        //_listeningDialog.setLevel(Float.toString(_currentRecognizer.getAudioLevel()));
                        Thread.Sleep(500);
                    }
                    System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Volume level thread ending.");

                });
                thread.Start();

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin: Recognizer.Listener.onRecordingBegin: Leaving method.");
        }
        /// <summary>Retrieves recognition results from the previous recognition</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void getRecoResult(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.getRecoResult: Entered method.");
            PluginResult result = null;
            ReturnObject returnObject = new ReturnObject();

            if (lastResult != null){
            setReturnCode(returnObject, RC_SUCCESS, "Success");
            String resultString = getResultString(lastResult);
            returnObject.result = resultString;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.getRecoResult: Result string = [" + resultString + "].");
            RecoResult[] resultArray = getResultArray(lastResult);
            returnObject.results = resultArray;

            }
            else{
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.getRecoResult: Last result was null.");
            setReturnCode(returnObject, RC_RECO_NO_RESULT_AVAIL, "No result available.");
            }

            result = new PluginResult(PluginResult.Status.OK, returnObject);
            DispatchCommandResult(result);

            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.getRecoResult: Leaving method.");
        }
        /// <summary> Method to initialize speech kit</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void initSpeechKit(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Entered method.");

            PluginResult result = null;
            InitParameters initParams = JsonHelper.Deserialize<InitParameters>(args);

            // Get parameters to do initialization
            string credentialClassName = initParams.credentialClassName;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Credential Class = [" + credentialClassName + "]");
            string serverName = initParams.serverName;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Server = [" + serverName + "]");
            int port = initParams.port;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: Port = [" + port + "]");
            bool sslEnabled = initParams.sslEnabled;
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: init: SSL = [" + sslEnabled + "]");

            ReturnObject returnObject = new ReturnObject();

            try{
            if (speechKit == null)
            {
                Type t = Type.GetType(credentialClassName);
                ICredentials credentials = (ICredentials)Activator.CreateInstance(t);

                String appId = credentials.getAppId();
                byte[] appKey = credentials.getAppKey();

                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: About to initialize");
                speechKit = SpeechKit.initialize(appId, serverName, port, sslEnabled, appKey);

                //_beep = _speechKit.defineAudioPrompt("beep.wav");
                //_speechKit.setDefaultRecognizerPrompts(_beep, null, null, null);

                speechKit.connect();
                System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Connected.");
                Thread.Sleep(10);

            }

            setReturnCode(returnObject, RC_SUCCESS, "Init Success");
            returnObject.eventName = EVENT_INIT_COMPLETE;
            result = new PluginResult(PluginResult.Status.OK, returnObject);
            result.KeepCallback = false;
            }
            catch(Exception e){
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Error initalizing:" + e.ToString());
            setReturnCode(returnObject, RC_FAILURE, e.ToString());
            result = new PluginResult(PluginResult.Status.OK, returnObject);
            }

            DispatchCommandResult(result);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.initSpeechKit: Leaving method.");
            //return result;
        }
Example #54
0
    /// <summary>
    /// Loads the Save Game Listing from disk
    /// </summary>
    /// <returns>ReturnObject: Status bearing object</returns>
    /// <remarks>
    /// <para>Unlike MDS, if we have no file to load, it's OK.</para>
    /// <para>When we DO load a file, it replaces the default empty GDS.GSC
    /// object that was created when GDS was initialized.</para>
    /// <para>Raises LoadSaveGameListingEvent(RO) on completion.</para>
    /// </remarks>
    ReturnObject LoadSaveGameListingData()
    {
        ReturnObject ro = new ReturnObject();

        if (File.Exists(GSCFilePath + GSDFileName))
        {
            try
            {
                string stringGSC = File.ReadAllText(GSCFilePath + GSDFileName);
                GameStateCollection gsc = JsonConvert.DeserializeObject<GameStateCollection>(stringGSC);

                gds.GSC = gsc;

                ro = new ReturnObject(Enums.Return_Status.OK, "GSC loaded and transferred to GDS.", "GSC loaded and transferred to GDS.", null);

                //Messenger.Broadcast("PopulateSaveGameList");
            }
            catch (Exception ex)
            {
                ro = new ReturnObject(Enums.Return_Status.Error, "Error loading GDS.", "Error loading GDS: " + ex.Message, null);
            }
        }else{
			ro = new ReturnObject(Enums.Return_Status.Notice, "No GDS found on disk. NOT AN ERROR.", "No GDS found on disk. NOT AN ERROR.", null);
		}

        OnLoadSaveGameListingEvent(ro);

        return ro;
    }
        /// <summary> Method to clean up speech kit variables if they have been intialized</summary>
        /// <param name="args">JSON encoded request parameters</param>
        public void cleanupSpeechKit(string args)
        {
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Entered method.");
            PluginResult result = null;

            cleanup();

            ReturnObject returnObject = new ReturnObject();
            setReturnCode(returnObject, RC_SUCCESS, "Cleanup Success");
            returnObject.eventName = EVENT_CLEANUP_COMPLETE;
            result = new PluginResult(PluginResult.Status.OK, returnObject);

            DispatchCommandResult(result);
            System.Diagnostics.Debug.WriteLine("PhoneGapSpeechPlugin.cleanupSpeechKit: Leaving method.");
            //return result;
        }
Example #56
0
 /// <summary>
 /// Raises LoadMDSDataEvent
 /// </summary>
 /// <param name="RO">ReturnObject</param>
 void OnLoadMDSDataEvent(ReturnObject RO)
 {
     if (LoadMDSDataEvent != null)
     {
         LoadMDSDataEvent(RO);
     }
 }
 /// <summary>
 /// Handles the Click event of the entire Game Object
 /// </summary>
 /// <param name="s">Panel</param>
 /// <param name="e">Mouse Events</param>
 /// <remarks>
 /// <para>
 /// Clicking the panel constructs a ReturnObject which is raised to the 
 /// parent (LoadGamePanelManager, in this case) and carries the GameState.GUID
 /// in order to identify which item in the list was clicked.
 /// </para>
 /// </remarks>
 public void LoadGameItemPanel_Click(dfControl s, dfMouseEventArgs e)
 {
     ReturnObject ro = new ReturnObject(Enums.Return_Status.OK, "Selected "+ saveGameGUID, "Selected " + saveGameGUID, saveGameGUID);
     OnSaveGameSelectEvent(ro);
 }