Example #1
0
        private void SaveMoneyReceipts()
        {
            MoneyReceiptsBLL   mrBll        = new MoneyReceiptsBLL();
            MoneyReceiptEntity moneyReceipt = new MoneyReceiptEntity();

            //int returnVal = 0;

            moneyReceipt.InvoiceId    = Convert.ToInt64(_InvoiceId);
            moneyReceipt.LocationId   = Convert.ToInt32(hdnLocationID.Value);
            moneyReceipt.NvoccId      = Convert.ToInt32(hdnNvoccId.Value); // forwarding this field is used as Jobid
            moneyReceipt.ExportImport = Convert.ToChar(ddlExportImport.SelectedValue);
            moneyReceipt.MRDate       = Convert.ToDateTime(txtDate.Text);
            moneyReceipt.ChequeNo     = txtChqNo.Text;
            moneyReceipt.ChequeBank   = txtBankName.Text.ToUpper();
            if (!string.IsNullOrEmpty(txtChqDate.Text))
            {
                moneyReceipt.ChequeDate = Convert.ToDateTime(txtChqDate.Text);
            }

            if (!string.IsNullOrEmpty(txtCashAmt.Text))
            {
                moneyReceipt.CashPayment = Convert.ToDecimal(txtCashAmt.Text);
            }

            if (!string.IsNullOrEmpty(txtChequeAmt.Text))
            {
                moneyReceipt.ChequePayment = Convert.ToDecimal(txtChequeAmt.Text);
            }

            if (!string.IsNullOrEmpty(txtTDS.Text))
            {
                moneyReceipt.TdsDeducted = Convert.ToDecimal(txtTDS.Text);
            }

            moneyReceipt.UserAddedId  = _userId;
            moneyReceipt.UserEditedId = _userId;
            moneyReceipt.UserAddedOn  = DateTime.Now.Date;
            moneyReceipt.UserEditedOn = DateTime.Now.Date;
            moneyReceipt.Status       = true;

            switch (mrBll.SaveMoneyReceipt(moneyReceipt))
            {
            case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                break;

            case 1:
                if (ddlExportImport.Text == "I")
                {
                    Response.Redirect("~/Transaction/BL-Query.aspx?BlNo=" + GeneralFunctions.EncryptQueryString(txtBLNo.Text));
                }
                else if (ddlExportImport.Text == "E")
                {
                    Response.Redirect("~/Export/Export-bl-query.aspx?BLNumber=" + GeneralFunctions.EncryptQueryString(txtBLNo.Text));
                }
                else if (ddlExportImport.Text == "F")
                {
                    Response.Redirect("~/Forwarding/Transaction/Dashboard.aspx?JobId=" + GeneralFunctions.EncryptQueryString(hdnNvoccId.Value));
                }
                break;
            }
        }
Example #2
0
        public static void Parse(string code, string filePath, string prjPath, CodeParts parts, ExceptionsList errors,
                                 bool add = true)
        {
            foreach (Match match in Regex.Matches(code, "\\#include[ \\t]+([^\\s]+)", RegexOptions.Multiline))
            {
                string text     = Convert.ToString(match.Groups[1].Value);
                string fullPath = "";

                var type = text.Substring(0, 1);

                var dirs = Directory.GetDirectories(prjPath + "\\dependencies").ToList();
                if (Directory.Exists(prjPath + "\\pawno\\include"))
                {
                    dirs.Add(prjPath + "\\pawno\\include");
                }

                if (char.Parse(type) == (char)34)
                {
                    //Remove the quotes.
                    try
                    {
                        text = text.Remove(text.IndexOf((char)34), 1);
                        text = text.Remove(text.IndexOf((char)34), 1);
                    }
                    catch (Exception)
                    {
                        continue;
                    }

                    fullPath = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(filePath)), text);
                    AddExtension(ref fullPath);
                }
                else if (type == "<")
                {
                    //Remove the brackets.
                    try
                    {
                        text = text.Remove(text.IndexOf("<"), 1);
                        text = text.Remove(text.IndexOf(">"), 1);
                    }
                    catch (Exception)
                    {
                        continue;
                    }

                    foreach (var dir in dirs)
                    {
                        string pth = Path.Combine(dir, text);
                        AddExtension(ref pth);
                        if (File.Exists(pth))
                        {
                            fullPath = pth;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (var dir in dirs)
                    {
                        string pth = Path.Combine(dir, text);
                        AddExtension(ref pth);
                        if (File.Exists(pth))
                        {
                            fullPath = pth;
                            break;
                        }
                    }
                }

                try
                {
                    //Create a new codeparts object for the includes cause they are needed.
                    if (add)
                    {
                        //Check if was already parsed or not.
                        if (Parser.IsParsed(parts.RootInclude, fullPath))
                        {
                            continue;
                        }

                        //Else:
                        //Check if exists or not:
                        if (File.Exists(fullPath))
                        {
                            CodeParts part = new CodeParts
                            {
                                //Setup and add to list.
                                FilePath = fullPath
                            };
                            parts.AddInclude(part);

                            Parser prs = new Parser(part, File.ReadAllText(fullPath), fullPath, prjPath, true);
                            errors.ExceptionsList_Renamed.AddRange(prs.Errors.ExceptionsList_Renamed);
                        }
                        else
                        {
                            errors.ExceptionsList_Renamed.Add(
                                new IncludeNotFoundException(Path.GetFileNameWithoutExtension(text)));
                        }
                    }
                    else
                    {
                        try
                        {
                            //Here if the include is REMOVED, There is no need to parse it all again cause we already know that we just need to remove the whole include.
                            parts.RemoveIncludeByHash(GeneralFunctions.GetFileHash(fullPath));
                        }
                        catch (Exception)
                        {
                            // ignored
                        }
                    }

                    //Exceptions.
                }
                catch (DirectoryNotFoundException)
                {
                    errors.ExceptionsList_Renamed.Add(new IncludeNotFoundException(Path.GetFileNameWithoutExtension(text)));
                }
                catch (FileNotFoundException)
                {
                    errors.ExceptionsList_Renamed.Add(new IncludeNotFoundException(Path.GetFileNameWithoutExtension(text)));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Save user information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveBT_Click(object sender, RoutedEventArgs e)
        {
            NewUserBT.Focus();

            if (UserNameTX.Text.Length == 0 || UserNameTX.Text.Length < 5)
            {
                MessageBox.Show("El nombre de usuario no puede estar en blanco o ser inferior a 5 caracteres");
                UserNameTX.Focus();
                return;
            }
            else if (UserPassword.Password.Length == 0 || UserPassword.Password.Length < 5)
            {
                MessageBox.Show("la contraseña no puede estar en blanco o ser inferior a 5 caracteres");
                UserPassword.Focus();
                return;
            }

            //Get/Set user parameters
            var Data = new NovaAPI.APIUsers.UsersClass();

            Data.id       = SelectedIndex;
            Data.name     = UserNameTX.Text;
            Data.realname = UserRealTX.Text;

            Data.rolid    = ((NovaAPI.APIRoles.Rols)UserRolCB.SelectedItem).rolid;
            Data.branchid = ((NovaAPI.APIBranch.BranchClass)UserBranchCB.SelectedItem).id;
            Data.status   = UserStatusCB.IsChecked == true ? "1" : "0";

            //Password logic
            if (CheckPassword.Visibility == Visibility.Visible)
            {
                Data.hash = GeneralFunctions.GenerateMD5(UserPassword.Password);
            }

            //rol json data
            string requestData = JsonConvert.SerializeObject(Data);

            bool response;

            //Modify / Create request
            if (Data.id.Length > 0)
            {
                response = await NovaAPI.APIUsers.GetValues("2", DataConfig.LocalAPI, requestData);
            }
            else
            {
                response = await NovaAPI.APIUsers.GetValues("1", DataConfig.LocalAPI, requestData);
            }

            //Request response
            if (response)
            {
                if (Data.id.Length > 0)
                {
                    //On user modified
                    var UserData = NovaAPI.APIUsers.users.Find(x => x.id == Data.id);
                    UserData.name       = Data.name;
                    UserData.realname   = Data.realname;
                    UserData.branchid   = Data.branchid;
                    UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name;
                    UserData.rolid      = Data.rolid;
                    UserData.rolname    = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname;
                    UserData.status     = Data.status;

                    UsersGrid.Items.Refresh();
                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();
                }
                else
                {
                    //On new user created response
                    var UserData = new NovaAPI.APIUsers.UsersClass();
                    UserData.name       = Data.name;
                    UserData.realname   = Data.realname;
                    UserData.branchid   = Data.branchid;
                    UserData.branchname = NovaAPI.APIBranch.branch.Find(x => x.id == Data.branchid).name;
                    UserData.rolid      = Data.rolid;
                    UserData.rolname    = NovaAPI.APIRoles.userrols.Find(x => x.rolid == Data.rolid).rolname;
                    UserData.status     = Data.status;

                    UserData.id = NovaAPI.APIUsers.LastID;

                    FormGrid.BeginStoryboard((Storyboard)Application.Current.TryFindResource("FadeInGrid"));
                    ResetForm();

                    NovaAPI.APIUsers.users.Add(UserData);

                    //Reload rol data
                    LoadData();
                }
            }
            else
            {
                MessageBox.Show($"Error al crear el usuario, INFO: {Environment.NewLine}{NovaAPI.APIUsers.Message}");
            }
        }
Example #4
0
    void UpdateWalls(float dt)
    {
        //.
        currentCounterTime += dt;
        //
        float progression = 0;

        //
        switch (wallStatus)
        {
        case WallStatus.Closing:
            //
            progression = dt / timeClosingWalls;
            //
            DisplaceWalls(progression, 1);
            //
            if (currentCounterTime >= timeClosingWalls)
            {
                wallStatus         = WallStatus.Closed;
                currentCounterTime = 0;
                GeneralFunctions.PlaySoundEffect(audioSource, wallsCompleteCloseSound);
            }

            break;

        case WallStatus.Closed:
            //
            if (currentCounterTime >= timeWallsAreClosed)
            {
                wallStatus         = WallStatus.Opening;
                currentCounterTime = 0;
            }

            break;

        case WallStatus.Opening:
            //
            progression = dt / timeOpeningWalls;
            //
            DisplaceWalls(progression, -1);
            //
            if (currentCounterTime >= timeOpeningWalls)
            {
                // Vamos a ver si el problema es que se va acumulando
                ResetWallPositions();
                //
                wallStatus         = WallStatus.Opened;
                currentCounterTime = 0;
            }
            break;

        case WallStatus.Opened:
            //
            if (currentCounterTime >= timeWallsAreOpened)
            {
                wallStatus         = WallStatus.Closing;
                currentCounterTime = 0;
            }
            break;
        }
    }
Example #5
0
        private void RedirecToAddEditPage(int id)
        {
            string encryptedId = GeneralFunctions.EncryptQueryString(id.ToString());

            Response.Redirect("~/Views/Security/UserEdit.aspx?id=" + encryptedId);
        }
        protected void gvwLoc_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GeneralFunctions.ApplyGridViewAlternateItemStyle(e.Row, 5);

                ScriptManager sManager = ScriptManager.GetCurrent(this);

                e.Row.Cells[0].Text = ((gvwLoc.PageSize * gvwLoc.PageIndex) + e.Row.RowIndex + 1).ToString();
                //e.Row.Cells[1].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Abbreviation"));

                if (Convert.ToChar(DataBinder.Eval(e.Row.DataItem, "IsActive")) == 'Y')
                {
                    ((Label)e.Row.FindControl("lblAbbr")).Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Abbreviation"));
                    ((Label)e.Row.FindControl("lblInActive")).Style["display"] = "none";
                }
                else
                {
                    ((Label)e.Row.FindControl("lblAbbr")).Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Abbreviation"));
                    ((Label)e.Row.FindControl("lblInActive")).Style["display"] = "";
                }

                e.Row.Cells[2].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Name"));

                if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.City")) == string.Empty)
                {
                    if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.Pin")) != string.Empty)
                    {
                        e.Row.Cells[3].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.Pin"));
                    }
                }
                else
                {
                    if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.Pin")) == string.Empty)
                    {
                        e.Row.Cells[3].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.City"));
                    }
                    else
                    {
                        e.Row.Cells[3].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.City")) + "-" + Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocAddress.Pin"));
                    }
                }

                //e.Row.Cells[4].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ManagerName"));

                // Edit link
                ImageButton btnEdit = (ImageButton)e.Row.FindControl("btnEdit");
                btnEdit.ToolTip         = ResourceManager.GetStringWithoutName("ERR00013");
                btnEdit.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Id"));

                ////Delete link
                //ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                //btnRemove.ToolTip = ResourceManager.GetStringWithoutName("ERR00012");
                //btnRemove.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Id"));

                //if (_canDelete)
                //{
                //    btnRemove.OnClientClick = "javascript:return confirm('" + ResourceManager.GetStringWithoutName("ERR00014") + "');";
                //}
                //else
                //{
                //    //btnEdit.OnClientClick = "javascript:alert('" + ResourceManager.GetStringWithoutName("ERR00008") + "');return false;";
                //    btnRemove.OnClientClick = "javascript:alert('" + ResourceManager.GetStringWithoutName("ERR00008") + "');return false;";
                //}
            }
        }
Example #7
0
 protected string BaseYeniKodVer(KartTuru kartTuru, Expression <Func <T, string> > filter, Expression <Func <T, bool> > where = null)
 {
     GeneralFunctions.CreateUnitOfWork <T, TContext>(ref _uow);
     return(_uow.Rep.YeniKodVer(kartTuru, filter, where));
 }
Example #8
0
        private async void StartupForm_Load(object sender, EventArgs e)
        {
            //Download SAMPCTL
            await SampCtl.EnsureLatestInstalled(Application.StartupPath);

            //Add event.
            pathTextBox.PathText.TextChanged += pathTextBox_TextChanged;

            //Check for updates
            AutoUpdater.ParseUpdateInfoEvent += AutoUpdater_ParseUpdateInfoEvent;
            DownloadForm.DownloadFile(translations.StartupForm_StartupForm_Load_Checking_for_updates, "https://api.github.com/repos/Ahmad45123/ExtremeStudio/releases/latest", Application.StartupPath + "/latest.txt");
            AutoUpdater.Start(Application.StartupPath + "/latest.txt");

            //If the interop files don't exist, Extract the files.

            /*if (IsFirst &&
             *  (!File.Exists(
             *       Application.StartupPath + "/x64/SQLite.Interop.dll") ||
             *   !File.Exists(
             *       Application.StartupPath + "/x86/SQLite.Interop.dll")))
             * {
             *  //Remove old.
             *  if (File.Exists(
             *      Application.StartupPath + "/x64/SQLite.Interop.dll"))
             *  {
             *      File.Delete(
             *          Application.StartupPath + "/x64/SQLite.Interop.dll");
             *  }
             *
             *  if (File.Exists(
             *      Application.StartupPath + "/x86/SQLite.Interop.dll"))
             *  {
             *      File.Delete(
             *          Application.StartupPath + "/x86/SQLite.Interop.dll");
             *  }
             *
             *  //Extract New
             *  File.WriteAllBytes(
             *      Application.StartupPath + "/interop.zip", Properties.Resources.SQLite_Interop); //Write the file.
             *  GeneralFunctions.FastZipUnpack(Application.StartupPath + "/interop.zip",
             *      Application.StartupPath); //Extract it.
             *  File.Delete(
             *      Application.StartupPath + "/interop.zip"); //Delete the temp file.
             * }*/

            //Create needed folders and files.
            if (!Directory.Exists(
                    Application.StartupPath + "/cache"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/cache/serverPackages"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache/serverPackages");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/cache/includes"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/cache/includes");
            }

            if (!Directory.Exists(
                    Application.StartupPath + "/configs"))
            {
                Directory.CreateDirectory(
                    Application.StartupPath + "/configs");
                File.WriteAllText(
                    Application.StartupPath + "/configs/recent.json", "");
            }

            //Setting the IsGlobal in Settings will make sure the settings are in place and correct.
            Program.SettingsForm.IsGlobal = true;

            //Load all the recent.
            if (File.Exists(
                    Application.StartupPath + "/configs/recent.json"))
            {
                try
                {
                    Recent = JsonConvert.DeserializeObject <List <string> >(
                        File.ReadAllText(
                            Application.StartupPath + "/configs/recent.json"));
                    if (ReferenceEquals(Recent, null))
                    {
                        Recent = new List <string>();
                    }
                }
                catch (Exception)
                {
                }
            }

            if (ProjectToOpen != "")
            {
                if (GeneralFunctions.IsValidExtremeProject(ProjectToOpen))
                {
                    Program.MainForm.CurrentProject.ProjectPath = ProjectToOpen;
                    Program.MainForm.CurrentProject.ReadInfo();
                    projectName.Text = Program.MainForm.CurrentProject.ProjectName;

                    string projVersion = Convert.ToString(Program.MainForm.CurrentProject.ProjectVersion);
                    string progVersion = Convert.ToString(_versionHandler.CurrentVersion);

                    VersionReader.CompareVersionResult versionCompare =
                        VersionReader.CompareVersions(projVersion, progVersion);
                    if (versionCompare == VersionReader.CompareVersionResult.VersionSame)
                    {
                        loadProjectBtn_Click(null, EventArgs.Empty);
                    }
                    else if (versionCompare == VersionReader.CompareVersionResult.VersionNew)
                    {
                        loadProjectBtn_Click(null, EventArgs.Empty);
                    }
                    else if (versionCompare == VersionReader.CompareVersionResult.VersionOld)
                    {
                        MessageBox.Show(translations.StartupForm_pathTextBox_TextChanged_ProjectVersionNewer);
                        Application.Exit();
                    }
                }
                else
                {
                    MessageBox.Show(Convert.ToString(translations.StartupForm_pathTextBox_TextChanged_InvalidESPrj));
                    Application.Exit();
                }
            }
        }
                public override async Task Call(Card caller, GameHandler gameHandler, ulong curPlayer, ulong enemy, ExtraEffectInfo extraInf)
                {
                    PlayerInteraction chooseOne  = new PlayerInteraction("Choose One", "1) Gain +6 Spikes\n2) Gain +6 Shields", "Write the corresponding number");
                    string            defaultAns = GameHandler.randomGenerator.Next(1, 3).ToString();

                    string ret = await chooseOne.SendInteractionAsync(gameHandler, curPlayer, (x, y, z) => GeneralFunctions.Within(x, 1, 2), defaultAns, extraInf.ctx);

                    if (int.Parse(ret) == 1)
                    {
                        gameHandler.players[curPlayer].creatureData.staticKeywords[StaticKeyword.Spikes] += 6;
                    }
                    else if (int.Parse(ret) == 2)
                    {
                        gameHandler.players[curPlayer].creatureData.staticKeywords[StaticKeyword.Shields] += 6;
                    }
                }
Example #10
0
        private void SaveData(string EqEstId)
        {
            if (chkDamage.Checked || chkpOnHold.Checked)
            { // ClearControls();
            }
            else
            if (!checkContainerStatus(true))
            {
                return;
            }



            if (DisableControls() == 1 && txtAppUser.Text.Trim() == "" && (txtLabourApp.Text != "" || txtMaterialApp.Text != ""))//ddlUser.SelectedIndex == 0)
            {
                lblError.Text = "Approver name cannot be blank";
                return;
            }
            IEqpRepairing iequip = new EquipmentRepairEntity();

            iequip.pk_RepairID       = Convert.ToInt32(EqEstId);
            iequip.locId             = Convert.ToInt32(ddlLoc.SelectedValue);
            iequip.ContainerNo       = txtContainerNo.Text;
            iequip.EstimateReference = txtEstimateRef.Text;
            iequip.RepLabourBilled   = txtLabourBill.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtLabourBill.Text);
            iequip.RepLabourEst      = txtLabourEst.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtLabourEst.Text);
            iequip.RepLabourAppr     = txtLabourApp.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtLabourApp.Text);
            iequip.RepMaterialAppr   = txtMaterialApp.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtMaterialApp.Text);
            iequip.RepMaterialBilled = txtMaterialBill.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtMaterialBill.Text);
            iequip.RepMaterialEst    = txtMaterialEst.Text.Trim() == "" ? 0 : Convert.ToDecimal(txtMaterialEst.Text);
            iequip.Reason            = txtReason.Text;
            iequip.RealeasedOn       = txtReleasedOn.Text.Trim() == "" ? (Nullable <DateTime>)null : Convert.ToDateTime(txtReleasedOn.Text);
            iequip.StockReturnDate   = txtStockRetDate.Text.Trim() == "" ? (Nullable <DateTime>)null : Convert.ToDateTime(txtStockRetDate.Text);
            iequip.TransactionDate   = txtTransactionDate.Text.Trim() == "" ? (Nullable <DateTime>)null : Convert.ToDateTime(txtTransactionDate.Text);
            iequip.ProspectID        = Convert.ToInt32(ddlLine.SelectedValue);
            iequip.locId             = Convert.ToInt32(ddlLoc.SelectedValue);
            iequip.NVOCCId           = Convert.ToInt32(ddlLine.SelectedValue);
            try
            {
                iequip.fk_UserApproved = _userId;// Convert.ToInt32(txtAppUser.Text);// Convert.ToInt32(ddlUser.SelectedValue);
            }
            catch
            {
                iequip.fk_UserApproved = null;
            }

            iequip.onHold  = chkpOnHold.Checked;
            iequip.Damaged = chkDamage.Checked;


            //if (iequip.RepLabourBilled < iequip.RepLabourAppr || iequip.RepMaterialBilled < iequip.RepMaterialAppr)
            //{
            //    // GeneralFunctions.RegisterAlertScript(this, "Approved amount cannot be greater then Billable amount");
            //    lblError.Text = "Approved amount cannot be greater then Billable amount";
            //    return;
            //}

            if (iequip.RepLabourEst < iequip.RepLabourAppr || iequip.RepMaterialEst < iequip.RepMaterialAppr)
            {
                // GeneralFunctions.RegisterAlertScript(this, "Approved amount cannot be greater then Billable amount");
                lblError.Text = "Approved amount cannot be greater then Estimate amount";
                return;
            }

            bool isedit = EqEstId != "-1" ? true : false;
            int  result = EquipmentBLL.AddEditEquipEstimate(_userId, isedit, iequip);

            if (result > 0)
            {
                Response.Redirect("~/Equipment/RepairingEstimate.aspx");
            }
            else
            {
                GeneralFunctions.RegisterAlertScript(this, "Error Occured");
            }
        }
Example #11
0
        private async void CreateProjectBtn_Click(object sender, EventArgs e)
        {
            string newPath = Convert.ToString(locTextBox.PathText.Text);

            if (preExistCheck.Checked)
            {
                if (!Directory.Exists(newPath) ||
                    GeneralFunctions.IsValidExtremeProject(newPath) || !GeneralFunctions.IsValidSAMPFolder(newPath))
                {
                    MessageBox.Show(
                        Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_InvalidSampFolder));
                    return;
                }
                else
                {
                    //Create the default file
                    if (!File.Exists(newPath + "/gamemodes/" + nameTextBox.Text + ".pwn"))
                    {
                        File.WriteAllText(
                            newPath + "/gamemodes/" + nameTextBox.Text + ".pwn",
                            Convert.ToString(Properties.Resources.newfileTemplate));
                    }

                    //Fill pawnctl data
                    Program.MainForm.CurrentProject.SampCtlData = new PawnJson()
                    {
                        entry        = "gamemodes\\" + nameTextBox.Text + ".pwn",
                        output       = "gamemodes\\" + nameTextBox.Text + ".amx",
                        user         = Environment.UserName,
                        repo         = nameTextBox.Text,
                        dependencies = new List <string>()
                        {
                            "sampctl/samp-stdlib"
                        },
                        builds = new List <BuildInfo>()
                        {
                            new BuildInfo()
                            {
                                name = "main",
                                args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList()
                            }
                        },
                        runtime = new RuntimeInfo()
                        {
                            version = verListBox.SelectedItem?.ToString() ?? "latest"
                        },
                    };
                    Program.MainForm.CurrentProject.ProjectName    = nameTextBox.Text;
                    Program.MainForm.CurrentProject.ProjectPath    = newPath;
                    Program.MainForm.CurrentProject.ProjectVersion = _versionHandler.CurrentVersion;
                    Program.MainForm.CurrentProject.CreateTables();    //Create the tables of the db.
                    Program.MainForm.CurrentProject.SaveInfo();        //Write the default extremeStudio config.
                    Program.MainForm.CurrentProject.CopyGlobalConfig();
                    Program.MainForm.CurrentProject.LoadSampCtlData(); //to ensure pawno/includes is there.

                    //Ensure the packages are ready
                    DownloadForm frm = new DownloadForm
                    {
                        progressBar1 = { Style = ProgressBarStyle.Continuous },
                        descLabel    = { Text = translations.StartupForm_CreateProjectBtn_Click_Ensuring_packages }
                    };
                    frm.Show();
                    Enabled = false;
                    await SampCtl.SendCommand(Path.Combine(Application.StartupPath, "sampctl.exe"), newPath, "p ensure");

                    frm.Close();
                    Enabled = true;

                    AddNewRecent(
                        Convert.ToString(Program.MainForm.CurrentProject.ProjectPath)); //Add it to the recent list.
                    Program.MainForm.Show();
                    _isClosedProgram = true;
                    Close();
                }
            }
            else
            {
                //Add to the path folder name.
                if (nameTextBox.Text.IsValidFileName() == false)
                {
                    MessageBox.Show(
                        Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_InvalidName));
                    return;
                }

                newPath = Path.Combine(Convert.ToString(locTextBox.PathText.Text),
                                       Convert.ToString(nameTextBox.Text));
                if (!string.IsNullOrEmpty(newPath) &&
                    Directory.Exists(newPath) == false)
                {
                    Directory.CreateDirectory(newPath);
                }

                //Check if entered path exist.
                if (Directory.Exists(newPath) &&
                    File.Exists(
                        newPath + "/extremeStudio.config") == false)
                {
                    if (verListBox.SelectedIndex != -1)
                    {
                        //Create directories.
                        Directory.CreateDirectory(newPath + "/gamemodes");
                        Directory.CreateDirectory(newPath + "/plugins");
                        Directory.CreateDirectory(newPath + "/scriptfiles");

                        //Create the default file
                        File.WriteAllText(
                            newPath + "/gamemodes/" + nameTextBox.Text + ".pwn",
                            Convert.ToString(Properties.Resources.newfileTemplate));

                        //Fill pawnctl data
                        Program.MainForm.CurrentProject.SampCtlData = new PawnJson()
                        {
                            entry        = "gamemodes\\" + nameTextBox.Text + ".pwn",
                            output       = "gamemodes\\" + nameTextBox.Text + ".amx",
                            user         = Environment.UserName,
                            repo         = nameTextBox.Text,
                            dependencies = new List <string>()
                            {
                                "sampctl/samp-stdlib"
                            },
                            builds = new List <BuildInfo>()
                            {
                                new BuildInfo()
                                {
                                    name = "main", args = Program.SettingsForm.GetCompilerArgs().Split(' ').ToList()
                                }
                            },
                            runtime = new RuntimeInfo()
                            {
                                version = verListBox.SelectedItem.ToString()
                            },
                        };
                        Program.MainForm.CurrentProject.ProjectName    = nameTextBox.Text;
                        Program.MainForm.CurrentProject.ProjectPath    = newPath;
                        Program.MainForm.CurrentProject.ProjectVersion = _versionHandler.CurrentVersion;
                        Program.MainForm.CurrentProject.CreateTables(); //Create the tables of the db.
                        Program.MainForm.CurrentProject.SaveInfo();     //Write the default extremeStudio config.
                        Program.MainForm.CurrentProject.CopyGlobalConfig();

                        //Ensure the packages are ready
                        DownloadForm frm = new DownloadForm
                        {
                            progressBar1 = { Style = ProgressBarStyle.Marquee },
                            descLabel    = { Text = translations.StartupForm_CreateProjectBtn_Click_Ensuring_packages }
                        };
                        frm.Show();
                        Enabled = false;
                        await SampCtl.SendCommand(Path.Combine(Application.StartupPath, "sampctl.exe"), newPath, "p ensure");

                        frm.Close();
                        Enabled = true;

                        AddNewRecent(
                            Convert.ToString(Program.MainForm.CurrentProject.ProjectPath)); //Add it to the recent list.
                        Program.MainForm.Show();
                        _isClosedProgram = true;
                        Close();
                    }
                    else
                    {
                        MessageBox.Show(
                            Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_NoSampSelected));
                        return;
                    }
                }
                else
                {
                    MessageBox.Show(Convert.ToString(translations.StartupForm_CreateProjectBtn_Click_DirError));
                    return;
                }
            }
        }
Example #12
0
        private void SaveMoneyReceipts()
        {
            MoneyReceiptsBLL   mrBll        = new MoneyReceiptsBLL();
            MoneyReceiptEntity moneyReceipt = new MoneyReceiptEntity();

            //int returnVal = 0;

            moneyReceipt.MoneyReceiptId = Convert.ToInt64(_AdvanceId);
            //moneyReceipt.LocationId = Convert.ToInt32(hdnLocationID.Value);
            //moneyReceipt.NvoccId = Convert.ToInt32(hdnNvoccId.Value);
            //moneyReceipt.ExportImport = Convert.ToChar(ddlExportImport.SelectedValue);
            moneyReceipt.MRDate     = Convert.ToDateTime(txtDate.Text);
            moneyReceipt.ChequeNo   = txtChqNo.Text;
            moneyReceipt.ChequeBank = txtBankName.Text.ToUpper();
            moneyReceipt.CHA        = _PaymentType;
            if (!string.IsNullOrEmpty(txtChqDate.Text))
            {
                moneyReceipt.ChequeDate = Convert.ToDateTime(txtChqDate.Text);
            }

            if (!string.IsNullOrEmpty(txtCashAmt.Text))
            {
                moneyReceipt.CashPayment = Convert.ToDecimal(txtCashAmt.Text);
            }

            if (!string.IsNullOrEmpty(txtChequeAmt.Text))
            {
                moneyReceipt.ChequePayment = Convert.ToDecimal(txtChequeAmt.Text);
            }

            if (!string.IsNullOrEmpty(txtTDS.Text))
            {
                moneyReceipt.TdsDeducted = Convert.ToDecimal(txtTDS.Text);
            }

            Int32.TryParse(GeneralFunctions.DecryptQueryString(Request.QueryString["jobid"].ToString()), out _jobid);
            moneyReceipt.BLId         = hdnJobID.Value.ToInt();
            moneyReceipt.CREID        = ddlParty.SelectedValue.ToInt();
            moneyReceipt.NvoccId      = ddlPartyType.SelectedValue.ToInt();
            moneyReceipt.UserAddedId  = _userId;
            moneyReceipt.UserEditedId = _userId;
            moneyReceipt.UserAddedOn  = DateTime.Now.Date;
            moneyReceipt.UserEditedOn = DateTime.Now.Date;
            moneyReceipt.Status       = true;

            switch (mrBll.SaveAdvance(moneyReceipt))
            {
            case 0: lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00011");
                break;

            case 1:
                if (moneyReceipt.MoneyReceiptId == 0)
                {
                    Response.Redirect("~/Forwarding/Transaction/Dashboard.aspx?JobId=" + GeneralFunctions.EncryptQueryString(_jobid.ToString()));
                }
                else
                {
                    Response.Redirect("~/Forwarding/Transaction/ManageAdvanceAdjustment.aspx");
                }
                break;
            }
        }
Example #13
0
        public ActionResult GetTimesheetDetails(string weekendDate, int EmpId)
        {
            NuPortalProjectService.NuPortalProject projectService = new NuPortalProjectService.NuPortalProject();
            projectService.Url = Constants.ProjectService;
            DataTable temp = new DataTable(), dt = new DataTable();

            try
            {
                DateTime endDate = Convert.ToDateTime(weekendDate);
                temp = JsonConvert.DeserializeObject <DataTable>(projectService.selectTaskDetails(EmpId != 0? EmpId: Convert.ToInt32(Session["EmpId"]), endDate));
                if (temp != null && temp.Rows.Count > 0)
                {
                    int Assign = Convert.ToInt32(temp.Rows[0]["AssignedTo"]);
                    dt.Columns.Add("ProjectName", typeof(string));
                    dt.Columns.Add("TaskName", typeof(string));
                    dt.Columns.Add("FK_TaskId", typeof(int));
                    dt.Columns.Add("TaskDetailsId", typeof(int));
                    dt.Columns.Add("Date", typeof(string));
                    dt.Columns.Add("Hour", typeof(float));
                    dt.Columns.Add("Status", typeof(int));
                    dt.Columns.Add("StartDate", typeof(string));
                    foreach (DataRow row in temp.Rows)
                    {
                        dt.Rows.Add(Convert.ToString(row["ProjectName"]), Convert.ToString(row["TaskName"]), Convert.ToInt32(row["FK_TaskId"]), Convert.ToInt32(row["TaskDetailsId"]), Convert.ToDateTime(row["Date"]).ToString("MM/dd/yyyy"), Convert.ToDecimal(row["Hour"]), Convert.ToInt32(row["TicketStatusId"]), Convert.ToDateTime(row["StartDate"]).ToString("MM/dd/yyyy"));
                    }

                    DateTime startDate = Convert.ToDateTime(weekendDate).AddDays(-6);

                    DataTable taskDist = dt.DefaultView.ToTable(true, "FK_TaskId", "TaskName", "ProjectName", "Status", "StartDate");
                    DataTable resultDt = new DataTable();
                    resultDt.Columns.Add("ProjectName", typeof(string));
                    resultDt.Columns.Add("TaskName", typeof(string));
                    resultDt.Columns.Add("FK_TaskId", typeof(int));
                    resultDt.Columns.Add("Date0", typeof(string));
                    resultDt.Columns.Add("Date1", typeof(string));
                    resultDt.Columns.Add("Date2", typeof(string));
                    resultDt.Columns.Add("Date3", typeof(string));
                    resultDt.Columns.Add("Date4", typeof(string));
                    resultDt.Columns.Add("Date5", typeof(string));
                    resultDt.Columns.Add("Date6", typeof(string));
                    resultDt.Columns.Add("TaskDetailsId", typeof(string));
                    resultDt.Columns.Add("AssignedTo", typeof(int));
                    resultDt.Columns.Add("Status", typeof(int));
                    resultDt.Columns.Add("Date0Class", typeof(string));
                    resultDt.Columns.Add("Date1Class", typeof(string));
                    resultDt.Columns.Add("Date2Class", typeof(string));
                    resultDt.Columns.Add("Date3Class", typeof(string));
                    resultDt.Columns.Add("Date4Class", typeof(string));
                    resultDt.Columns.Add("Date5Class", typeof(string));
                    resultDt.Columns.Add("Date6Class", typeof(string));
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow task in taskDist.Rows)
                        {
                            DataRow resultRow = resultDt.NewRow();
                            resultRow["ProjectName"] = task["ProjectName"];
                            resultRow["TaskName"]    = task["TaskName"];
                            resultRow["FK_TaskId"]   = task["FK_TaskId"];
                            resultRow["Status"]      = task["Status"];
                            int    cnt      = 0;
                            string sheetIds = "";
                            for (DateTime dte = startDate; dte < startDate.AddDays(7); dte = dte.AddDays(1))
                            {
                                DataRow[] timesheets = dt.Select("FK_TaskId=" + task["FK_TaskId"] + " And Date='" + dte.ToString("MM/dd/yyyy") + "'");
                                if (timesheets != null && timesheets.Length > 0 && Convert.ToDecimal(timesheets[0]["Hour"]) != 0)
                                {
                                    resultRow["Date" + cnt] = timesheets[0]["Hour"];
                                    sheetIds = sheetIds + Convert.ToString(timesheets[0]["TaskDetailsId"]) + "|";
                                }
                                else
                                {
                                    resultRow["Date" + cnt] = "";
                                }
                                if (dte < Convert.ToDateTime(DateTime.ParseExact(Convert.ToString(task["StartDate"]), "MM/dd/yyyy", null).ToString("yyyy/MM/dd")))
                                {
                                    resultRow["Date" + cnt + "Class"] = "disabled";
                                }
                                else
                                {
                                    resultRow["Date" + cnt + "Class"] = "";
                                }
                                cnt++;
                            }
                            resultRow["TaskDetailsId"] = sheetIds;
                            resultRow["AssignedTo"]    = Assign;
                            resultDt.Rows.Add(resultRow);
                        }
                        return(Json(JsonConvert.SerializeObject(resultDt), JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json("", JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json("", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                GeneralFunctions genFun = new GeneralFunctions();
                genFun.LogError(ControllerContext.HttpContext, ex.Message, ex.TargetSite.Name,
                                Convert.ToString(ControllerContext.RouteData.Values["action"]),
                                Convert.ToString(ControllerContext.RouteData.Values["controller"]));
                genFun = null;
            }
            finally { projectService.Dispose(); dt = null; temp = null; }
            return(Json(Common_Library.Constants.JsonError, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// This webmethod retrieves customer information based on given search criteria
        /// </summary>
        /// <param name="xmlRequest">Input parameters in xml string format</param>
        /// <returns>response string</returns>
        public override string GetCustomerInfo(string xmlRequest)
        {
            // Initialize the DB connection.
            SqlConnection dbConnection = new SqlConnection(connStrCSS);
            SqlCommand    dbCommand    = new SqlCommand("ReadMinimalCustomerInfo", dbConnection);

            dbCommand.CommandType = CommandType.StoredProcedure;
            // Initialize objects.
            responseString = new StringBuilder();
            xmlStream      = new StringWriter(responseString);
            responseWriter = new XmlTextWriter(xmlStream);

            // Initialize the Xml output string.
            responseWriter.Formatting = Formatting.Indented;
            responseWriter.WriteStartElement("Response");

            try
            {
                //Input parameter validation
                if (xmlRequest.Length == 0)
                {
                    return(xmlResponse.ToString());
                }
                XmlDocument dom = new XmlDocument();
                dom.LoadXml(xmlRequest);
                dbConnection.Open();

                string customerId = dom.DocumentElement.SelectSingleNode("CustomerId").InnerText;
                string firstName  = dom.DocumentElement.SelectSingleNode("FirstName").InnerText;
                string lastName   = dom.DocumentElement.SelectSingleNode("LastName").InnerText;
                string phoneNum   = dom.DocumentElement.SelectSingleNode("PhoneNum").InnerText;
                string accountNum = dom.DocumentElement.SelectSingleNode("AccountNum").InnerText;

                SqlParameter param = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.ParameterName = "@CustomerId";
                param.Value         = customerId;
                dbCommand.Parameters.Add(param);

                param               = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.SqlDbType     = SqlDbType.NVarChar;
                param.ParameterName = "@FirstName";
                param.Value         = firstName;
                dbCommand.Parameters.Add(param);

                param               = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.SqlDbType     = SqlDbType.NVarChar;
                param.ParameterName = "@LastName";
                param.Value         = lastName;
                dbCommand.Parameters.Add(param);

                param               = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.SqlDbType     = SqlDbType.NVarChar;
                param.ParameterName = "@PhoneNum";
                param.Value         = phoneNum;
                dbCommand.Parameters.Add(param);

                param               = new SqlParameter();
                param.Direction     = ParameterDirection.Input;
                param.SqlDbType     = SqlDbType.NVarChar;
                param.ParameterName = "@AccountNum";
                param.Value         = accountNum;
                dbCommand.Parameters.Add(param);

                // Use a SQL data reader to process the result set..
                SqlDataReader reader = dbCommand.ExecuteReader();

                // Parse the resulting data set.
                responseWriter.WriteElementString("Status", ERR_SUCCESS);

                string custId         = "";
                string tempCustomerId = "";

                while (reader.Read())
                {
                    custId = GeneralFunctions.GetValueFromReader(reader, 0);
                    if (custId != tempCustomerId)
                    {
                        if (tempCustomerId.Length != 0)
                        {
                            // Close phone number tag
                            responseWriter.WriteEndElement();
                            // Close customer tag
                            responseWriter.WriteEndElement();
                        }
                        responseWriter.WriteStartElement("Customer");

                        responseWriter.WriteElementString("Firstname", GeneralFunctions.GetValueFromReader(reader, 1));
                        responseWriter.WriteElementString("Middlename", GeneralFunctions.GetValueFromReader(reader, 2));
                        responseWriter.WriteElementString("Lastname", GeneralFunctions.GetValueFromReader(reader, 3));
                        responseWriter.WriteElementString("DateofBirth", GeneralFunctions.GetValueFromReader(reader, 4));
                        responseWriter.WriteElementString("StreetAddress1", GeneralFunctions.GetValueFromReader(reader, 5));
                        responseWriter.WriteElementString("StreetAddress2", GeneralFunctions.GetValueFromReader(reader, 6));
                        responseWriter.WriteElementString("City", GeneralFunctions.GetValueFromReader(reader, 7));
                        responseWriter.WriteElementString("State", GeneralFunctions.GetValueFromReader(reader, 8));
                        responseWriter.WriteElementString("ZipCode", GeneralFunctions.GetValueFromReader(reader, 9));
                        responseWriter.WriteElementString("Email", GeneralFunctions.GetValueFromReader(reader, 10));
                        responseWriter.WriteElementString("MothersMaidenname", GeneralFunctions.GetValueFromReader(reader, 11));
                        responseWriter.WriteElementString("SSN", GeneralFunctions.GetValueFromReader(reader, 12));
                        responseWriter.WriteElementString("CustomerId", custId);

                        // Start phone number tag
                        responseWriter.WriteStartElement("PhoneNumbers");

                        responseWriter.WriteElementString("Number", GeneralFunctions.GetValueFromReader(reader, 12));
                        tempCustomerId = custId;
                    }
                    else
                    {
                        responseWriter.WriteElementString("Number", GeneralFunctions.GetValueFromReader(reader, 12));
                    }
                }
                if (custId.Length != 0)
                {
                    // End phone number tag
                    responseWriter.WriteEndElement();
                    // End customer tag
                    responseWriter.WriteEndElement();
                }

                responseWriter.WriteFullEndElement();
                return(responseString.ToString());
                //-------------- End of definition ---------------------------//
            }
            catch (Exception eX)
            {
                Logging.Error("CSR.CustomerInformation.GetCustomerInfo", eX.Message);
                xmlResponse.Append(eX.Message);
                return(xmlResponse.ToString());
            }
            finally
            {
                dbConnection.Close();
            }
        }
Example #15
0
        private void RedirecToAddEditPage(int id)
        {
            string encryptedId = GeneralFunctions.EncryptQueryString(id.ToString());

            Response.Redirect("~/Export/ContainerTranshipmentEntry.aspx?id=" + encryptedId);
        }
Example #16
0
        /// <summary>
        /// Start the desktop tab version.
        /// </summary>
        private static void startDesktop()
        {
            CcfShellBase <Desktop> desktop = null;

            try
            {
                // Even though there is a try-catch across this Main() function
                // exceptions thrown by the message loop of the desktop will not be handled in
                // the catch.  Hence we have a separate exception handler for the Application object.
                Application.ThreadException += new ThreadExceptionEventHandler(ApplicationExceptionHandler);

                bool showSplashScreen;

                if (Boolean.TryParse(System.Configuration.ConfigurationManager.AppSettings["showSplashScreen"], out showSplashScreen) == false)
                {
                    Logging.Error(localize.DESKTOP_MODULE_NAME, String.Format(localize.DESKTOP_ERR_READING_OR_PARSING_APPSETTINGS, "showSplashScreen"));
                    return;
                }

                // If configured to show a splash screen, then do so.
                // Otherwise start the application without a splash screen.
                if (showSplashScreen)
                {
                    // Start splash screen
                    new SplashScreen(new SplashForm());
                }

                bool doExit = ShowLoginDialogue();
                if (doExit)
                {
                    return;
                }

                // NOTE : DO NOT USE Logging, ListenerConfiguration or anything that access a non anonymous web service before this point

                Logging.ShowErrors = false;
                // Ensure there is only one instance of the desktop if one is already running then shut down.
                if (!GeneralFunctions.IsInitialInstance())
                {
                    Logging.Error(Application.ProductName, localize.APPLICATION_NAME + localize.DESKTOP_MSG_ALREADY_RUNNING);
                    return;
                }

                // Log that the application is starting
                Logging.Information(Application.ProductName, localize.DESKTOP_MSG_STARTING);

                // Start the Agent Desktop

                // Start the desktop shell application
                desktop = new CcfShellBase <Desktop>();
                desktop.StartApplication();

                // Log that the application is ending
                Logging.Information(Application.ProductName, localize.DESKTOP_INFO_AGENT_DESKTOP_EXITED);
            }
            catch (Exception exp)
            {
                string message;
                // If something horribly bad happens, it'll get caught here.
                if (exp.Message.IndexOf(localize.DESKTOP_MSG_SQL_EXIST) >= 0)
                {
                    message = localize.DESKTOP_ERR_UNABLE_CONNECT_SQL;
                }
                else if (exp.Message.IndexOf(localize.COMMON_MSG_IIS_ERROR) >= 0)
                {
                    message = localize.DESKTOP_IIS_ERROR;
                }
                else if (Desktop.LoggedIn)
                {
                    message = localize.DESKTOP_ERR_FATAL_ERROR;
                }
                else
                {
                    message = localize.DESKTOP_ERR_FATAL_UNABLE_LOG;
                }
                Logging.Error(Application.ProductName, message, exp);
            }
            finally
            {
                // RTC needs to be explicitly closed to allow its interop to release resources
                // and thus prevent evil crashes later.
                if (desktop != null && desktop.DesktopShell != null && desktop.DesktopShell.Rtc != null)
                {
                    desktop.DesktopShell.Rtc.Close();
                    desktop.DesktopShell.Rtc = null;
                }
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     NVOCCId = GeneralFunctions.DecryptQueryString(Request.QueryString["id"]);
     SaveData(NVOCCId);
 }
    // Fills tile list with tiles
    public LiteRoomTile[,] GetTiles(BoundsInt bounds)
    {
        // create tile array
        LiteRoomTile[,] tile_list = new LiteRoomTile[x_, y_];
        Constants.TileType temp_tiletype;
        Constants.TileType top_tiletype;
        int xMaxMinusOne = bounds.xMax - 1;
        int yMaxMinusOne = bounds.yMax - 1;

        position_offset_ = new Vector3Int(bounds.xMin, bounds.yMin, 0);
        //int yMinPlusOne
        // get all tiles within bounds
        for (int x = 0, rx = bounds.xMin; x < bounds.size.x; x++, rx++)
        {
            for (int y = 0, ry = bounds.yMin; y < bounds.size.y; y++, ry++)
            {
                Vector3Int grid_position = new Vector3Int(rx, ry, 0);
                if (tilemap_.GetTile <Tile>(grid_position) != null)
                {
                    temp_tiletype = Constants.GetTypeFromSprite(GeneralFunctions.GetTileSpriteName(tilemap_, grid_position));
                    if (entity_tilemap.GetTile <Tile>(grid_position) != null)
                    {
                        top_tiletype = Constants.GetTypeFromSprite(GeneralFunctions.GetTileSpriteName(entity_tilemap, grid_position));
                    }
                    else
                    {
                        top_tiletype = Constants.TileType.NONE;
                    }
                    // if tiletype is door and is valid (i.e. at convex edge of room), add to door list
                    if (temp_tiletype == Constants.TileType.CONNECTOR)
                    {
                        // if connector is a corner tile
                        if (rx == bounds.xMin && ry == bounds.yMin)
                        {
                            continue;
                        }
                        else if (rx == bounds.xMin && ry == yMaxMinusOne)
                        {
                            continue;
                        }
                        else if (ry == yMaxMinusOne && rx == xMaxMinusOne)
                        {
                            continue;
                        }
                        else if (rx == xMaxMinusOne && ry == bounds.yMin)
                        {
                            continue;
                        }
                        // if connector is an edge tile
                        else if (rx == bounds.xMin)
                        {
                            sw_doors_.Add(new Door("SW", new Vector3Int(rx, ry, layer_height_)));
                        }
                        else if (rx == xMaxMinusOne)
                        {
                            ne_doors_.Add(new Door("NE", new Vector3Int(rx, ry, layer_height_)));
                        }
                        else if (ry == bounds.yMin)
                        {
                            se_doors_.Add(new Door("SE", new Vector3Int(rx, ry, layer_height_)));
                        }
                        else if (ry == yMaxMinusOne)
                        {
                            nw_doors_.Add(new Door("NW", new Vector3Int(rx, ry, layer_height_)));
                        }
                    }
                    // gets sprite name and checks with dictionary to get enum TileType
                    tile_list[x, y].Init(temp_tiletype, top_tiletype);
                }
                else
                {
                    tile_list[x, y].Init(Constants.TileType.NONE, Constants.TileType.NONE);
                }
            }
        }
        number_nw_doors = nw_doors_.Count;
        number_ne_doors = ne_doors_.Count;
        number_sw_doors = sw_doors_.Count;
        number_se_doors = se_doors_.Count;
        return(tile_list);
    }
Example #19
0
 protected IQueryable <TResult> BaseList <TResult>(Expression <Func <T, bool> > filter, Expression <Func <T, TResult> > selector)
 {
     //Her seferinde UnitofWork un instance ını alacaağız çünkü güncel connection string ile işlem yapacağız.
     GeneralFunctions.CreateUnitOfWork <T, TContext>(ref _uow);
     return(_uow.Rep.Select(filter, selector));
 }
Example #20
0
        public static void Run([TimerTrigger("0 * * * * *")] TimerInfo myTimer, ILogger log)
        {
            try
            {
                //Settings_BLL settings_BLL = new Settings_BLL();
                //Schedules_BLL schedules_BLL = new Schedules_BLL();

                var config = new ConfigurationBuilder()
                             .SetBasePath(Environment.CurrentDirectory)
                             .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                             .AddEnvironmentVariables()
                             .Build();
                string connString       = config["DefaultConnection"];
                int    AddLocalTimeZone = Convert.ToInt32(config["AddLocalTimeZone"]);
                int    totalSent        = 0;
                string createdon        = ""; //req.Query["createdon"];

                DateTime  localNow = (createdon == "" || createdon == null) ? Convert.ToDateTime(DateTime.UtcNow.ToString("hh:mm:ss")) : Convert.ToDateTime(createdon);
                DataTable table    = new DataTable();
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    conn.Open();
                    List <Settings> runningSettings = new List <Settings>();

                    string     query   = "select * from settings where cast(scheduletime as time) = @_selectedTime";
                    SqlCommand command = new SqlCommand(query, conn);
                    command.Parameters.AddWithValue("@_selectedTime", localNow.TimeOfDay);
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        while (reader.Read())
                        {
                            Settings objSettings = new Settings();

                            objSettings.SettingsID      = reader["SettingsID"] == DBNull.Value ? 0 : Convert.ToInt32(reader["SettingsID"]);
                            objSettings.CreatedOn       = reader["CreatedOn"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["CreatedOn"]);
                            objSettings.AppId           = reader["AppId"].ToString() ?? reader["AppId"].ToString();
                            objSettings.AppSecret       = reader["AppSecret"].ToString() ?? reader["AppSecret"].ToString();
                            objSettings.Scheduletime    = reader["Scheduletime"] == DBNull.Value ? TimeSpan.MinValue : TimeSpan.Parse(reader["Scheduletime"].ToString());
                            objSettings.MessageTemplate = reader["MessageTemplate"].ToString() ?? reader["MessageTemplate"].ToString();
                            objSettings.IsActive        = reader["IsActive"] == DBNull.Value ? false : Convert.ToBoolean(reader["IsActive"]);
                            objSettings.LastModified    = reader["LastModified"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["LastModified"].ToString());
                            objSettings.UserId          = reader["UserId"].ToString() ?? reader["AppId"].ToString();

                            runningSettings.Add(objSettings);
                        }
                        foreach (var item in runningSettings)
                        {
                            // get all schedules where isSent = 0
                            List <Schedules> upcomingSchedules = new List <Schedules>();
                            query   = "select * from schedules where isSent = 0 and isvalid = 1 and appid = @_appid";
                            command = new SqlCommand(query, conn);
                            command.Parameters.AddWithValue("@_appid", item.AppId);
                            reader = command.ExecuteReader();
                            try
                            {
                                while (reader.Read())
                                {
                                    Schedules objSchedule = new Schedules();
                                    objSchedule.SchedulesId = reader["SchedulesId"] == DBNull.Value ? 0 : Convert.ToInt32(reader["SchedulesId"]);
                                    objSchedule.AppId       = reader["AppId"].ToString() ?? reader["AppId"].ToString();
                                    objSchedule.CreatedOn   = reader["CreatedOn"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["CreatedOn"]);
                                    objSchedule.MobileNo    = reader["MobileNo"].ToString() ?? reader["MobileNo"].ToString();
                                    objSchedule.IsValid     = reader["IsValid"] == DBNull.Value ? false : Convert.ToBoolean(reader["IsValid"]);
                                    objSchedule.Reason      = reader["Reason"].ToString() ?? reader["Reason"].ToString();
                                    objSchedule.Response    = reader["Response"].ToString() ?? reader["Response"].ToString();
                                    objSchedule.EventDate   = reader["EventDate"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["EventDate"]);
                                    objSchedule.Custom1     = reader["Custom1"].ToString() ?? reader["Custom1"].ToString();
                                    objSchedule.Custom2     = reader["Custom2"].ToString() ?? reader["Custom2"].ToString();
                                    objSchedule.Custom3     = reader["Custom3"].ToString() ?? reader["Custom3"].ToString();
                                    objSchedule.IsSent      = reader["IsSent"] == DBNull.Value ? false : Convert.ToBoolean(reader["IsSent"]);
                                    objSchedule.SentOn      = reader["SentOn"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["SentOn"]);
                                    upcomingSchedules.Add(objSchedule);
                                }
                                //foreach schedules , send SMS and set isSent = 0, SentOn = localNow
                                foreach (var it in upcomingSchedules)
                                {
                                    if (it.EventDate.AddHours(AddLocalTimeZone).Date == DateTime.UtcNow.Date)
                                    {
                                        bool successSent = GeneralFunctions.SendSms(Convert.ToInt32(item.AppId), new Guid(item.AppSecret), it.MobileNo,
                                                                                    item.MessageTemplate.Replace("{custom1}", it.Custom1).Replace("{custom2}", it.Custom2).Replace("{custom3}", it.Custom3));

                                        //update isSent and sentOn
                                        query   = "update schedules set IsSent = @_IsSent, SentOn = @_SentOn where [SchedulesId] = @_SchedulesId";
                                        command = new SqlCommand(query, conn);
                                        command.Parameters.AddWithValue("@_IsSent", successSent);
                                        if (successSent)
                                        {
                                            command.Parameters.AddWithValue("@_SentOn", localNow);
                                            totalSent++;
                                        }
                                        command.Parameters.AddWithValue("@_SchedulesId", it.SchedulesId);
                                        command.ExecuteNonQuery();
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
                log.LogInformation($"Success trigger at " + localNow + ", " + totalSent + " SMS sent");
            }
            catch (Exception ex)
            {
            }
        }
        protected void gvwCust_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GeneralFunctions.ApplyGridViewAlternateItemStyle(e.Row, 7);

                ScriptManager sManager = ScriptManager.GetCurrent(this);

                string corporateOrLocal = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "CorporateOrLocal"));
                string custLocId        = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Location.Id"));
                bool   canEdit          = true;

                if (_roleId == (int)UserRole.Manager || _roleId == (int)UserRole.SalesExecutive)
                {
                    if (corporateOrLocal == "C" && _locId.ToString() != custLocId)
                    {
                        canEdit = false;
                    }
                }

                e.Row.Cells[0].Text = ((gvwCust.PageSize * gvwCust.PageIndex) + e.Row.RowIndex + 1).ToString();
                e.Row.Cells[1].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Location.Name"));
                //e.Row.Cells[2].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Name"));

                //SA Modify -- Souvik
                string strCustName = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Name"));

                if (strCustName.Length > 50)
                {
                    ((Label)e.Row.FindControl("lblName")).ToolTip = strCustName;
                    strCustName = strCustName.Substring(0, 50) + "..";
                }


                if (Convert.ToChar(DataBinder.Eval(e.Row.DataItem, "IsActive")) == 'Y')
                {
                    ((Label)e.Row.FindControl("lblName")).Text = strCustName;
                    ((Label)e.Row.FindControl("lblInActive")).Style["display"] = "none";
                }
                else
                {
                    ((Label)e.Row.FindControl("lblName")).Text = strCustName;
                    ((Label)e.Row.FindControl("lblInActive")).Style["display"] = "";
                }


                if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Group.Id")) != "1")
                {
                    string strGroupCompany = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Group.Name"));
                    if (strGroupCompany.Length > 17)
                    {
                        e.Row.Cells[3].ToolTip = strGroupCompany;
                        strGroupCompany        = strGroupCompany.Substring(0, 17) + "..";
                    }

                    e.Row.Cells[3].Text = strGroupCompany;
                }
                //EA Modify -- Souvik

                string strSalesPerson = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "SalesExecutiveName"));
                if (strSalesPerson.Length > 17)
                {
                    e.Row.Cells[4].ToolTip = strSalesPerson;
                    strSalesPerson         = strSalesPerson.Substring(0, 17) + "..";
                }

                e.Row.Cells[4].Text = strSalesPerson;

                // Edit link
                ImageButton btnEdit = (ImageButton)e.Row.FindControl("btnEdit");
                btnEdit.ToolTip         = ResourceManager.GetStringWithoutName("ERR00008");
                btnEdit.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Id"));

                //Delete link
                ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                btnRemove.ToolTip         = ResourceManager.GetStringWithoutName("ERR00007");
                btnRemove.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Id"));

                if (_hasEditAccess && canEdit)
                {
                    if (_roleId == (int)UserRole.Admin || _roleId == (int)UserRole.Manager)
                    {
                        btnRemove.OnClientClick = "javascript:return confirm('" + ResourceManager.GetStringWithoutName("ERR00010") + "');";
                    }
                    else
                    {
                        btnRemove.OnClientClick = "javascript:alert('" + ResourceManager.GetStringWithoutName("ERR00009") + "');return false;";
                    }
                }
                else
                {
                    btnEdit.OnClientClick   = "javascript:alert('" + ResourceManager.GetStringWithoutName("ERR00009") + "');return false;";
                    btnRemove.OnClientClick = "javascript:alert('" + ResourceManager.GetStringWithoutName("ERR00009") + "');return false;";
                }
            }
        }
Example #22
0
        protected void gvImportBL_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                GeneralFunctions.ApplyGridViewAlternateItemStyle(e.Row, 6);
                ScriptManager sManager = ScriptManager.GetCurrent(this);

                e.Row.Cells[0].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobNo"));
                e.Row.Cells[1].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobDate")).Split(' ')[0];
                e.Row.Cells[2].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobType"));
                e.Row.Cells[3].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "LocName"));
                e.Row.Cells[4].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "POL"));
                e.Row.Cells[5].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "POD"));
                e.Row.Cells[6].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstPayable"));
                e.Row.Cells[7].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstReceivable"));
                e.Row.Cells[8].Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "EstProfit"));

                ImageButton btnDashboard = (ImageButton)e.Row.FindControl("btnDashboard");
                btnDashboard.ToolTip         = "Dashboard";
                btnDashboard.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));

                // display HBL button only Open Job
                if (ddlJobStatus.SelectedValue == "O")
                {
                    ImageButton btnHBLEntry = (ImageButton)e.Row.FindControl("btnHBLEntry");
                    btnHBLEntry.ToolTip = "HBL Entry";
                    if (Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "PrintHBL")))
                    {
                        btnHBLEntry.Visible         = true;
                        btnHBLEntry.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));
                    }
                    else
                    {
                        btnHBLEntry.Visible = false;
                    }
                }
                else
                {
                    ImageButton btnHBLEntry = (ImageButton)e.Row.FindControl("btnHBLEntry");
                    btnHBLEntry.Visible = false;
                }
                //Edit Link
                ImageButton btnEdit = (ImageButton)e.Row.FindControl("btnEdit");
                btnEdit.ToolTip         = ResourceManager.GetStringWithoutName("ERR00070");
                btnEdit.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));

                //Delete link
                if (_canDelete == true)
                {
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible         = true;
                    btnRemove.ToolTip         = ResourceManager.GetStringWithoutName("ERR00007");
                    btnRemove.CommandArgument = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobId"));
                    btnRemove.Attributes.Add("onclick", "javascript:return confirm('Are you sure about delete?');");
                }
                else
                {
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible = false;
                }

                if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "JobActive")) == "C")
                {
                    e.Row.ForeColor = System.Drawing.Color.Red;
                    ImageButton btnRemove = (ImageButton)e.Row.FindControl("btnRemove");
                    btnRemove.Visible = false;
                }
            }
        }
Example #23
0
        private void RedirecToAddEditPage(int id)
        {
            string encryptedId = GeneralFunctions.EncryptQueryString(id.ToString());

            Response.Redirect("~/Forwarding/Master/AddEditFwdAgent.aspx?id=" + encryptedId);
        }
Example #24
0
        private void RedirecToAddEditPage(int id)
        {
            string encryptedId = GeneralFunctions.EncryptQueryString(id.ToString());

            Response.Redirect("~/Forwarding/Transaction/Job.aspx?JobId=" + encryptedId);
        }
Example #25
0
        private void SendResetPwdEmail(int uId)
        {
            IUser user = UserBLL.GetUser(uId);

            if (!ReferenceEquals(user, null))
            {
                string url     = Convert.ToString(ConfigurationManager.AppSettings["ApplicationUrl"]) + "/Security/ChangePassword.aspx?id=" + GeneralFunctions.EncryptQueryString(uId.ToString());
                string msgBody = "Hello " + user.UserFullName + "<br/>We have received new password request for your account " + user.Name + ". Your temporary password is:" + Constants.DEFAULT_PASSWORD + " <br/>If this request was initiated by you, please click on following link and change your password:<br/><a href='" + url + "'>" + url + "</a>";

                try
                {
                    CommonBLL.SendMail(Convert.ToString(ConfigurationManager.AppSettings["Sender"]), Convert.ToString(ConfigurationManager.AppSettings["DisplayName"]), user.EmailId, string.Empty, "Request for change password", msgBody, Convert.ToString(ConfigurationManager.AppSettings["MailServerIP"]), Convert.ToString(ConfigurationManager.AppSettings["MailUserAccount"]), Convert.ToString(ConfigurationManager.AppSettings["MailUserPwd"]));
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('" + ResourceManager.GetStringWithoutName("R00031") + "');</script>", false);
                }
                catch (Exception ex)
                {
                    CommonBLL.HandleException(ex, this.Server.MapPath(this.Request.ApplicationPath).Replace("/", "\\"));
                }
            }
        }
        public DataResultArgs <StudentEntity> Set_Student(StudentEntity entity)
        {
            try
            {
                DataProcess.ControlAdminAuthorization(true);

                if (entity.Id > 0 && entity.DatabaseProcess == DatabaseProcess.Add)
                {
                    entity.DatabaseProcess = DatabaseProcess.Update;
                }

                DataResultArgs <StudentEntity> resultSet = new DataResultArgs <StudentEntity>();
                resultSet.Result = entity;

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@DatabaseProcess", entity.DatabaseProcess);
                cmd.Parameters.AddWithValue("@id", entity.Id);
                cmd.Parameters.AddWithValue("@citizenshipNumber", entity.CitizenshipNumber);
                cmd.Parameters.AddWithValue("@name", entity.Name);
                cmd.Parameters.AddWithValue("@surname", entity.Surname);
                cmd.Parameters.AddWithValue("@middleName", entity.MiddleName);
                cmd.Parameters.AddWithValue("@fatherName", entity.FatherName);
                cmd.Parameters.AddWithValue("@motherName", entity.MotherName);
                cmd.Parameters.AddWithValue("@birthday", entity.Birthday);
                cmd.Parameters.AddWithValue("@fatherPhoneNumber", entity.FatherPhoneNumber);
                cmd.Parameters.AddWithValue("@motherPhoneNumber", entity.MotherPhoneNumber);
                cmd.Parameters.AddWithValue("@isActive", entity.IsActive);
                cmd.Parameters.AddWithValue("@isStudent", entity.IsStudent);
                cmd.Parameters.AddWithValue("@notes", entity.Notes);
                cmd.Parameters.AddWithValue("@dateOfMeeting", entity.DateOfMeeting);
                cmd.Parameters.AddWithValue("@spokenPrice", entity.SpokenPrice);
                cmd.Parameters.AddWithValue("@email", entity.Email);
                using (SqlConnection con = Connection.Conn)
                {
                    con.Open();
                    DataResultArgs <string> currentResultSet = DataProcess.ExecuteProcString(con, cmd, "set_Student");
                    con.Close();

                    resultSet.HasError         = currentResultSet.HasError;
                    resultSet.ErrorDescription = currentResultSet.ErrorDescription;
                    resultSet.MyException      = currentResultSet.MyException;

                    if (entity.DatabaseProcess == DatabaseProcess.Add && !currentResultSet.HasError)
                    {
                        resultSet.Result.Id = GeneralFunctions.GetData <Int32>(currentResultSet.Result);
                        entity.Id           = GeneralFunctions.GetData <Int32>(currentResultSet.Result);
                    }
                }


                if (entity.IsAddAfterPaymentUnPayment)
                {
                    List <PaymentTypeEntity> paymentTypeList = new PaymentTypeBusiness().Get_PaymentType();

                    foreach (PaymentTypeEntity paymentTypeEntity in paymentTypeList)
                    {
                        for (int i = 1; i < DateTime.Today.Month; i++)
                        {
                            PaymentEntity paymentEntity = new PaymentEntity();
                            paymentEntity.Id = 0;
                            paymentEntity.DatabaseProcess = DatabaseProcess.Add;
                            paymentEntity.Year            = (short)DateTime.Today.Year;
                            paymentEntity.StudentId       = entity.Id;
                            paymentEntity.IsNotPayable    = true;
                            paymentEntity.IsActive        = true;
                            paymentEntity.IsDeleted       = false;
                            paymentEntity.Month           = (short)i;
                            paymentEntity.IsPayment       = false;

                            paymentEntity.Amount =
                                ((PaymentTypeEnum)paymentTypeEntity.Id == PaymentTypeEnum.Okul &&
                                 entity.SpokenPrice.HasValue && entity.SpokenPrice.Value > 0)
                                    ? entity.SpokenPrice.Value
                                    : paymentTypeEntity.Amount;
                            paymentEntity.PaymentType = paymentTypeEntity.Id;
                            paymentEntity.AddedOn     = DateTime.Now;

                            new PaymentBusiness().Set_Payment(paymentEntity);
                        }
                    }
                }


                AllStudentWithCache = null;
                Get_AllStudentWithCache();

                return(resultSet);
            }
            catch (Exception e)
            {
                DataResultArgs <StudentEntity> result = new DataResultArgs <StudentEntity>();
                result.HasError         = true;
                result.ErrorDescription = e.Message;
                return(result);
            }
        }
Example #27
0
    protected void UpdateBehaviour(Vector3 playerDirection, float dt)
    {
        //
        switch (currentState)
        {
        // Cuando está vagando por ahí
        case WormStatus.Wandering:

            float playerDistance = (transform.position - player.transform.position).magnitude;

            // Que rote alrededor del player si se aleja demasiado
            // Así no se va a cuenca
            if (playerDistance > 700)
            {
                // Sacar la cruz
                Vector3 playerCross = Vector3.Cross(playerDirection, Vector3.up);
                //transform.rotation = Quaternion.LookRotation(playerCross);
                head.rotation = GeneralFunctions.UpdateRotationInOneAxis(head, playerCross, rotationSpeed, dt);
            }
            else
            {
                head.Rotate(Vector3.up * dt);
            }

            // Velocity no sirve con kinematicos
            //rb.velocity = transform.forward * 100;
            //
            head.Translate(Vector3.forward * currentSpeed * dt);
            //Debug.Log("I'm wandering");

            //
            if (goesUnderground)
            {
                //
                if (head.position.y > underGroundHeight)
                {
                    head.Translate(Vector3.up * heightChangeSpeed * dt * -1);
                }
                //
                currentTimeUnderground += dt;
                if (currentTimeUnderground >= timeUnderground)
                {
                    goesUnderground = false;
                }
            }
            else if (!goesUnderground && head.position.y < overGroundHeight)
            {
                head.Translate(Vector3.up * heightChangeSpeed * dt);
            }
            else if (exteriorWeakPoints == 0)
            {
                // Aquí pasa a la fase de perseguir
                currentState   = WormStatus.Chasing;
                currentSpeed   = chasingMovementSpeed;
                active         = true;
                rotationSpeed *= 3;
                //Debug.Log("Start chasing");
                // Por aqui em principio solo pasa una vez
                carolHelp.TriggerIt(5, "Start chasing");
            }
            else
            {
                // Del targeteable, hacer variable más clara
                active = true;
            }
            break;

        case WormStatus.Chasing:
            // Que persiga al player
            head.rotation = GeneralFunctions.UpdateRotationInOneAxis(transform, player.transform.position, rotationSpeed, dt);
            head.Translate(Vector3.forward * currentSpeed * dt);
            // Que abra la boca cuando lo tenga cerca
            UpdateMaw(playerDirection, dt);
            // Que intente atraparlo de un mordisco (muerte mortísima)
            // (En el script de collision del terreno de momento de momento)
            //      Que pase a estado stun
            break;

        case WormStatus.Stunned:
            // Vamos a hacer que vaya perdiendo velcodidad en un tiempo
            if (currentSpeed > 0)
            {
                //
                currentSpeed -= (chasingMovementSpeed / timeUntilCompleteStun) * dt;
                currentSpeed  = Mathf.Max(currentSpeed, 0);
                //
                head.Rotate(Vector3.forward * completeStunRotation / timeUntilCompleteStun * dt);
                //
                head.Translate(Vector3.forward * currentSpeed * dt);
            }
            break;

        case WormStatus.Recovering:

            // Basicamente invertiremos el stun
            if (currentSpeed < chasingMovementSpeed)
            {
                // Le metemos un multiplicador al
                float recoveryMultiplier = 0.5f;
                //
                currentSpeed += (chasingMovementSpeed / timeUntilCompleteStun) * dt * recoveryMultiplier;
                currentSpeed  = Mathf.Min(currentSpeed, chasingMovementSpeed);
                //
                head.Rotate(-Vector3.forward * completeStunRotation / timeUntilCompleteStun * dt * recoveryMultiplier);
            }

            //
            head.Translate(Vector3.forward * currentSpeed * dt);
            //
            if (currentSpeed == chasingMovementSpeed && gigaWormInsides.PlayerOut)
            {
                currentState = WormStatus.Chasing;
                //
                //Vector3 currentHeadEulers = head.localEulerAngles;
                //currentHeadEulers.z = 0;
                //head.localEulerAngles = currentHeadEulers;
            }

            break;
        }
    }
Example #28
0
        public ActionResult UploadFiles()
        {
            Dictionary <string, string> outFiles = new Dictionary <string, string>();

            // Checking no of files injected in Request object
            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFileBase file = files[i];
                        string             fname, filename;
                        //string[] fnameArray = files.Keys[i].Split('|');
                        //if (fnameArray.Length > 1)
                        //{
                        //    filename = fnameArray[1];
                        //}
                        //else
                        filename = files[i].FileName;
                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = filename.Split(new char[] { '\\' });
                            fname = testfiles[testfiles.Length - 1];
                        }
                        else
                        {
                            fname = filename;
                        }
                        fname = Path.GetFileNameWithoutExtension(fname) + "^_^_^" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + Path.GetExtension(fname);
                        // Get the complete folder path and store the file inside it.
                        string finalPath = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                        file.SaveAs(finalPath);
                        outFiles.Add(filename, "../Uploads/" + fname);
                    }
                    var json = JsonConvert.SerializeObject(outFiles);
                    // Returns message that successfully uploaded
                    return(Json(json));
                }
                catch (Exception ex)
                {
                    GeneralFunctions genFun = new GeneralFunctions();
                    genFun.LogError(ControllerContext.HttpContext, ex.Message, ex.TargetSite.Name,
                                    Convert.ToString(ControllerContext.RouteData.Values["action"]),
                                    Convert.ToString(ControllerContext.RouteData.Values["controller"]));
                    genFun   = null;
                    outFiles = new Dictionary <string, string>();
                    outFiles.Add("Error", ex.ToString());
                    return(Json(JsonConvert.SerializeObject(outFiles)));
                }
            }
            else
            {
                outFiles = new Dictionary <string, string>();
                outFiles.Add("Error", "No Files to upload");
                return(Json(JsonConvert.SerializeObject(outFiles)));
            }
        }
Example #29
0
        private void RedirecToAddEditPage(int id)
        {
            string encryptedId = GeneralFunctions.EncryptQueryString(id.ToString());

            Response.Redirect("~/MasterModule/vendor-add-edit.aspx?id=" + encryptedId);
        }
Example #30
0
 protected IQueryable <TResult> BaseList <TResult>(Expression <Func <TEntity, bool> > filter, Expression <Func <TEntity, TResult> > selector)
 {
     GeneralFunctions.CreateUnitOfWork <TEntity, TContext>(ref _unitOfWork);
     return(_unitOfWork.Rep.Select(filter, selector));
 }