Example #1
0
        /// <summary>
        /// OnUGUIInit.
        /// </summary>
        public override void OnUGUIInit()
        {
            base.OnUGUIInit();

            GameObject = MyUtilities.FindObjectInFirstLayer(MyUGUIManager.Instance.Canvas.gameObject, PrefabName);
            if (GameObject == null)
            {
                if (IsUseAssetBundle)
                {
                    if (Bundle == null)
                    {
                        Debug.LogError("[" + typeof(MyUGUIScene).Name + "] OnUGUIInit(): Asset bundle null.");
                    }
                    GameObject = GameObject.Instantiate(Bundle.LoadAsset(PrefabName), Vector3.zero, Quaternion.identity) as GameObject;
                }
                else
                {
                    string     path     = MyUGUIManager.SCENE_DIRECTORY + PrefabName;
                    GameObject template = Resources.Load <GameObject>(path);
                    if (template == null)
                    {
                        Debug.LogError("[" + typeof(MyUGUIScene).Name + "] OnUGUIInit(): Could not find file \"" + path + "\".");
                    }
                    GameObject = GameObject.Instantiate(template, Vector3.zero, Quaternion.identity) as GameObject;
                }
                GameObject.name = PrefabName;
                GameObject.transform.SetParent(MyUGUIManager.Instance.Canvas.transform, false);
            }
            GameObject.SetActive(false);
        }
 // Update is called once per frame
 void Update()
 {
     if (gameObject.GetComponent <ParticleSystem>().isStopped)
     {
         MyUtilities.TweenDestroy(gameObject);
     }
 }
        /// <summary>
        /// Init text.
        /// </summary>
        private void _InitText()
        {
            if (mText == null)
            {
                GameObject text = MyUtilities.FindObjectInFirstLayer(gameObject, "Text");
                if (text != null)
                {
                    mText = text.GetComponent <Text>();
                }
                else
                {
                    mText = gameObject.GetComponent <Text>();
                }
            }
#if USE_MY_UI_TMPRO
            if (mText == null && mTextTMPro == null)
            {
                GameObject text = MyUtilities.FindObjectInFirstLayer(gameObject, "Text");
                if (text != null)
                {
                    mTextTMPro = text.GetComponent <TextMeshProUGUI>();
                }
                else
                {
                    mTextTMPro = gameObject.GetComponent <TextMeshProUGUI>();
                }
            }
#endif
        }
        private void UpdateGraph()
        {
            var positions = GetPositionsInGraph().ToList();

            if (hasConnectors)
            {
                connections = MyUtilities.EnsureAllObjectsCreated(
                    positions.Count - 1,
                    connections,
                    () => CreateUnpositionedDotConnection(),
                    connection => GameObject.Destroy(connection));
                foreach (var connection in positions.RollingWindow(2).Zip(connections, (pair, line) => new { pair, line }))
                {
                    UpdateDotConnection(connection.pair[0], connection.pair[1], connection.line);
                }
            }

            if (hasDots)
            {
                dots = MyUtilities.EnsureAllObjectsCreated(
                    positions.Count,
                    dots,
                    () => CreateUnpositionedDot(),
                    dot => GameObject.Destroy(dot));
                foreach (var dot in positions.Zip(dots, (pos, dot) => new { pos, dot }))
                {
                    UpdateDot(dot.pos, dot.dot);
                }
            }
        }
Example #5
0
        public List <HorseBet> ListOfHistoricHorseBetsWithCourseID()
        {
            var result = new List <HorseBet>();

            try
            {
                using (FileStream fs = File.OpenRead(@"C:\Users\carra\Documents\HotTipster\RevisedData.txt"))
                    using (TextReader myreader = new StreamReader(fs, Encoding.UTF8))
                    {
                        while (myreader.Peek() > -1)
                        {
                            string   line = myreader.ReadLine();
                            string[] bet  = line.Split(stringSplitCommaSeparator, StringSplitOptions.RemoveEmptyEntries);
                            bet    = MyUtilities.TrimArrayStrings(bet);
                            bet[1] = bet[1].Substring(1, 4);
                            bet[3] = bet[3].Substring(0, 2);
                            bet[4] = bet[4].Substring(0, bet[4].Length - 1);


                            result.Add(new HorseBet(bet[0], new DateTime(int.Parse(bet[1]), int.Parse(bet[2]), int.Parse(bet[3])), decimal.Parse(bet[4]), bool.Parse(bet[5]), int.Parse(bet[6])));
                        }
                    }
            }
            catch
            {
                throw new Exception("File input does not match expected datatypes");
            }

            return(result);
        }
Example #6
0
 //I've found that rigidbody eats performance so much, so adopted this distance-deleting system
 void DeletePassedNotes()
 {
     if (gameObject.GetComponent <DuplicateNotes>().isDataAvailable)
     {
         GameObject[] targetNote = new GameObject[4];
         for (int i = 0; i < 4; i++)
         {
             float nextNoteTiming = gameObject.GetComponent <DuplicateNotes>().timings[i][nextNoteIndex[i]];
             if (gameObject.GetComponent <DuplicateNotes>().FetchCollectionFromKeyIndex(i).ContainsKey(nextNoteIndex[i]))
             {
                 targetNote[i] = gameObject.GetComponent <DuplicateNotes>().FetchCollectionFromKeyIndex(i)[nextNoteIndex[i]];
             }
             else
             {
                 targetNote[i] = null;
             }
             if (targetNote[i] != null && Vector3.Distance(targetNote[i].transform.position, new Vector3(0, 0, 0)) < deleteRange)
             {
                 Debug.Log("DELETED -> DISTANCE : " + Vector3.Distance(targetNote[i].transform.position, new Vector3(0, 0, 0)));
                 MyUtilities.TweenDestroy(targetNote[i]);
                 DuplicateNotes.notesCount[i]--;
                 gameObject.GetComponent <DuplicateNotes>().FetchCollectionFromKeyIndex(i).Remove(nextNoteIndex[i]);
                 Debug.Log("DELETE -> TARGET : " + targetNote[i]);
                 ScoreStore.GetComponent <StoreScore>().AddScore(0);
                 nextNoteIndex[i]++;
             }
         }
     }
 }
Example #7
0
    protected override void RowUpdate(int rowIndex)
    {
        GridViewRow row = grid.Rows[rowIndex];

        var newValues = this.GetValues(row);

        connec = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + GetDirectory() + userDir + MAIN_USER_DATABASE + ";");
        OleDbCommand cmd = new OleDbCommand("UPDATE tblOperFrTo SET ProdDesc=?, fromopname = ?, ToOpName = ?, Per = ? WHERE RecID = ?;", connec);


        {
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("ProdDesc", MyUtilities.clean(newValues[FIELDS[1]].ToString()));
            cmd.Parameters.AddWithValue("FromOpName", MyUtilities.clean(newValues[FIELDS[2]].ToString()));
            cmd.Parameters.AddWithValue("ToOpName", MyUtilities.clean(newValues[FIELDS[3]].ToString()));
            cmd.Parameters.AddWithValue("Per", MyUtilities.clean(newValues[FIELDS[4]].ToString()));
            cmd.Parameters.AddWithValue(FIELDS[0], grid.DataKeys[row.RowIndex][FIELDS[0]]);
            try {
                connec.Open();
                int result = cmd.ExecuteNonQuery();

                grid.EditIndex = -1;

                this.SetData();
                connec.Close();
            } catch {
                try {
                    connec.Close();
                    connec = null;
                } catch { }
                Master.ShowErrorMessage(DbUse.INSERT_DATA_ERROR_MSG);
            }
        }
    }
Example #8
0
        public bool databaseContainsUser(String username, String password)
        {
            SqlCommand cmd = new SqlCommand
                                 ("SELECT dbo.FN_DATABASE_CONTAINS_USER(@USER_NAME, @USER_PASSWORD)",
                                 Program.DBConnection.Connection);

            cmd.Parameters.AddWithValue("@USER_NAME", username);
            cmd.Parameters.AddWithValue("@USER_PASSWORD", MyUtilities.encrypt(password));

            try
            {
                Program.DBConnection.Connect();
                if ((bool)cmd.ExecuteScalar())
                {
                    return(true);
                }
            }
            catch (SqlException e)
            {
                throw e;
            }
            finally
            {
                Program.DBConnection.Disconnect();
            }

            return(false);
        }
Example #9
0
    public static void LoadLevelData()
    {
        // PreLoad Allthings
        if (DataLoaded)
        {
            return;
        }
        // Level pass require
        int[,] rawData = MyUtilities.ParseFile("MapData/config_aim_data", 6);

        for (int i = 0; i < rawData.GetLength(0); i++)
        {
            LevelRequire.Add(i + 1, rawData[i, 2]);
        }

        // Level star target
        rawData = MyUtilities.ParseFile("MapData/config_star_evaluate_data", 5);
        for (int i = 0; i < rawData.GetLength(0); i++)
        {
            StarTarget.Add(i + 1, new int[] { rawData[i, 1], rawData[i, 2], rawData[i, 3], rawData[i, 4] });
        }

        // Pre load bubble
        rawData = MyUtilities.ParseFile("MapData/pre_five_bubble_data", 6);
        for (int i = 0; i < rawData.GetLength(0); i++)
        {
            PreBubble.Add(i + 1, new int[] { rawData[i, 1], rawData[i, 2], rawData[i, 3], rawData[i, 4], rawData[i, 5] });
        }

        // Points from combo
        PointReward = MyUtilities.ParseFile("MapData/ScoreRulesData", 3);

        DataLoaded = true;
    }
Example #10
0
        /// <summary>
        /// Initialize.
        /// </summary>
        public void Initialize(GameObject gameObject)
        {
            mGameObject = gameObject;

            if (mGameObject != null)
            {
                GameObject tipsRoot = MyUtilities.FindObjectInFirstLayer(mGameObject, ELoadingType.Tips.ToString());
                if (tipsRoot != null)
                {
                    GameObject description = MyUtilities.FindObject(tipsRoot, "Description");
                    if (description != null)
                    {
                        mDescription = description.GetComponent <Text>();
                    }

                    GameObject tips = MyUtilities.FindObject(tipsRoot, "Tips");
                    if (tips != null)
                    {
                        mTips = tips.GetComponent <Text>();
                    }

                    GameObject cancel = MyUtilities.FindObject(tipsRoot, "ButtonCancel");
                    if (cancel != null)
                    {
                        mButtonCancel = cancel.GetComponent <MyUGUIButton>();
                        mButtonCancel.OnEventPointerClick.RemoveAllListeners();
                        mButtonCancel.OnEventPointerClick.AddListener(_OnClickCancel);
                    }
                }
            }
        }
Example #11
0
    /// <summary>
    /// Gets user input from the vertical / horizontal axis based on the angle of the surface blob is on
    /// </summary>
    /// <returns>The input.</returns>
    private float getInput()
    {
        if (inputCheck() && canMove)
        {
            // between 45 & -45, 135 & -135 = h, else v
            // between 45 & 315, 135 & 225

            float myAngle    = MyUtilities.AngleInDegrees(Vector2.zero, _myDown);
            float multiplier = 1;

            if (myAngle >= 45 && myAngle <= 225)
            {
                multiplier = -1;
            }

            // if angle is +/- 45 degrees from 0 or 180, return vertical axis
            if (myAngle <= 45 && myAngle >= 0 || myAngle <= 360 && myAngle >= 315 ||
                myAngle >= 135 && myAngle <= 225)
            {
                // return the vertical axis
                return(controllingPlayer.vertical * multiplier);
            }
            else
            {
                // return the vertical axis

                return(controllingPlayer.horizontal * multiplier);
            }
        }
        else
        {
            return(0);
        }
    }
Example #12
0
    /// <summary>
    /// Draws and modified throw trajecory.
    /// </summary>
    void drawAndModifyThrowTrajecory()
    {
        // prevent character movement
        _character.canMove = false;

        // angle and facing
        float facedThrowAngle = _currentThrowAngle;                     // default to current throw angle
        float facing          = _character.facing.x;

        // reverse if facing left
        if (facing < 0)
        {
            facedThrowAngle = Mathf.Abs(facedThrowAngle - 180);
        }


        // draw path
        Collider2D collider      = _carriedObject.GetComponent <Collider2D>();
        Vector3    startPos      = _carryPosition.position;
        Vector2    startVelocity = MyUtilities.NormalizedVectorFromAngle(facedThrowAngle) * throwForce;

        DrawTrajectory(startPos, startVelocity);

        // adjust path with left / right / up /  down input
        adjustAngle();
    }
Example #13
0
    protected void UpdateRow(GridViewRow row)
    {
        TextBox txtMail    = row.FindControl("txtMail") as TextBox;
        TextBox txtCompany = row.FindControl("txtCompany") as TextBox;

        if (txtMail == null || txtCompany == null)
        {
            return;
        }
        string email       = txtMail.Text;
        string company     = MyUtilities.clean(txtCompany.Text);
        string updateQuery = "UPDATE userlist INNER JOIN usercred ON userlist.id = usercred.id SET userlist.company = ?, usercred.mail = ? WHERE userlist.id = ?;";

        try {
            using (OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["MySQLConnStr"].ConnectionString)) {
                connection.Open();
                using (OdbcCommand command = new OdbcCommand(updateQuery, connection)) {
                    command.Parameters.AddWithValue("company", company);
                    command.Parameters.AddWithValue("mail", email);
                    command.Parameters.AddWithValue("id", gridUsers.DataKeys[row.RowIndex]["id"]);
                    try {
                        command.ExecuteNonQuery();
                        gridUsers.EditIndex = -1;
                        command.Dispose();
                    } catch (Exception ex) {
                        throw new Exception("Error in getting data using sql query: " + updateQuery + ". " + ex.Message, ex);
                    }
                }
                connection.Close();
            }
        } catch (Exception ex) {
            logFiles.ErrorLog(ex);
            ShowErrorMessage("An internal error has occured. Cannot open database connection.");
        }
    }
Example #14
0
 // called from floor generation
 public void CreateMap()
 {
     fogMask  = MyUtilities.GetPixelCircle(Vector2.zero, (int)(PlayerController.range));
     markings = new Dictionary <GameObject, Vector2Int>();
     InitializeMaps();
     ConfigureTextures();
 }
Example #15
0
    protected void LoadTreesGraph()
    {
        string treeImgFullPath = GetDirectory() + userDir + "Graphs//" + MyUtilities.TREES_IMG_NAME;
        string treeImgRelPath  = "App_Data/" + MyUtilities.clean(userDir, '\\') + "/Graphs/" + MyUtilities.TREES_IMG_NAME;

        string browserPath    = GetMainDirectory() + BROWSER_DIR + "//" + userDir + "Graphs//" + MyUtilities.TREES_IMG_NAME;
        string browserRelPath = BROWSER_DIR + "/" + MyUtilities.clean(userDir, '\\') + "/Graphs/" + MyUtilities.TREES_IMG_NAME + "?" + DateTime.Now.Ticks;

        if (File.Exists(treeImgFullPath))
        {
            try {
                try {
                    File.Delete(browserPath);
                } catch (Exception) { }
                File.Copy(treeImgFullPath, browserPath);
            } catch (Exception) {}
            Bitmap         image      = new Bitmap(browserPath);
            int            width      = image.Width;
            double         zoom       = double.Parse(dlZoom.SelectedValue) / 100;
            int            finalWidth = (int)Math.Round(width * zoom);
            LiteralControl lit        = new LiteralControl("<img src=\"" + browserRelPath + "\" alt=\"Trees Graph\" //style=\"width:" + finalWidth + "px; margin-bottom:20px;\" />");
            pictureHolder.Controls.Add(lit);
            image.Dispose();
        }
        else
        {
            Master.ShowErrorMessage("No data available. Please run MPX first.");
        }
    }
Example #16
0
 // idle
 protected override void idleBehavior()
 {
     if (MyUtilities.CalcChancePerDeltaTime(turnChanceDuringIdle))
     {
         setFacing(-facing.x);
     }
 }
Example #17
0
        public void testAddItemToListMismatchTypes()
        {
            List <int> intList    = new List <int>();
            string     testString = "This is a test";

            MyUtilities.AddItemToList(testString, intList);
        }
Example #18
0
        public void testFileExistsInvalidPath()
        {
            string filepath = @"c:\test\test.txt";
            bool   result   = MyUtilities.ValidFilePath(filepath);

            Assert.IsFalse(result);
        }
Example #19
0
        public void testDBExistsInvalidPath()
        {
            string filepath = Directory.GetCurrentDirectory() + Path.PathSeparator + "HotTipsterDatabase.sqlite";
            bool   result   = MyUtilities.ValidFilePath(filepath);

            Assert.IsFalse(result);
        }
Example #20
0
    // Use this for initialization

    void Start()
    {
        MyUtilities utils = new MyUtilities();

        utils.AddValues(2, 3);
        Debug.Log("2 + 3 = " + utils.c);
    }
    // Update is called once per frame
    void Update()
    {
        float x = _width + MyUtilities.Oscillation(xDistort, xPeriod, 0, Time.time);
        float y = _height + MyUtilities.Oscillation(yDistort, yPeriod, 0, Time.time);

        transform.localScale = new Vector3(x, y, transform.localScale.z);
    }
Example #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // Browser detection and redirecting to error page
     if (Request.Browser.Browser.ToLower() == "ie" && Convert.ToDouble(Request.Browser.Version) < 7)
     {
         SPUtility.TransferToErrorPage("To view this report use later versions of IE 6.0");
     }
     else
     {
         try
         {
             string siteurl      = MyUtilities.ProjectServerInstanceURL(SPContext.Current);
             var    Resource_Svc = new Resource()
             {
                 AllowAutoRedirect = true,
                 Url = siteurl + "/_vti_bin/psi/resource.asmx",
                 UseDefaultCredentials = true
             };
             var result = MyUtilities.GetGovernanceReport(siteurl, Resource_Svc.GetCurrentUserUid());
             //Repeater1.DataSource = result;
             //Repeater1.DataBind();
             JSONData.Text = result.Rows.Count > 0 ? MyUtilities.Serialize(result) : "";
         }
         catch (Exception ex)
         {
             MyUtilities.ErrorLog(ex.Message, EventLogEntryType.Error);
         }
     }
 }
Example #23
0
    // Use this for initialization
    void Start()
    {
        MyUtilities utils = new MyUtilities();

        utils.AddValues(2, 3);
        print("2 + 3 = " + utils.c);
    }
Example #24
0
        public void testFileExistsValidFilePath()
        {
            string filepath = @"C:\Users\carra\Documents\HotTipster\BadDataTestFile.txt";
            bool   result   = MyUtilities.ValidFilePath(filepath);

            Assert.IsTrue(result);
        }
        /// <summary>
        /// Create a template game object.
        /// </summary>
        public static GameObject CreateTemplate()
        {
            GameObject obj = new GameObject(PREFAB_NAME);

            RectTransform root_rect = obj.AddComponent <RectTransform>();

            MyUtilities.Anchor(ref root_rect, MyUtilities.EAnchorPreset.DualStretch, MyUtilities.EAnchorPivot.MiddleCenter, Vector2.zero, Vector2.zero);

#if UNITY_EDITOR
            Animator root_animator = obj.AddComponent <Animator>();
            string[] paths         = new string[] { "Assets/MyClasses", "Assets/Core/MyClasses", "Assets/Plugin/MyClasses", "Assets/Plugins/MyClasses", "Assets/Framework/MyClasses", "Assets/Frameworks/MyClasses" };
            for (int i = 0; i < paths.Length; i++)
            {
                if (System.IO.File.Exists(paths[i] + "/Sources/Animations/my_animator_flying_message.controller"))
                {
                    root_animator.runtimeAnimatorController = (RuntimeAnimatorController)UnityEditor.AssetDatabase.LoadAssetAtPath(paths[i] + "/Sources/Animations/my_animator_flying_message.controller", typeof(RuntimeAnimatorController));
                    Debug.LogError("[" + typeof(MyUGUIFlyingMessage).Name + "] CreateTemplate(): please setup \"my_animator_flying_message\" controller.");
                    Debug.LogError("[" + typeof(MyUGUIFlyingMessage).Name + "] CreateTemplate(): mapping \"my_animation_flying_message_short_fly_from_bot\" motion for \"ShortFlyFromBot\" state.");
                    Debug.LogError("[" + typeof(MyUGUIFlyingMessage).Name + "] CreateTemplate(): mapping \"my_animation_flying_message_long_fly_from_bot\" motion for \"LongFlyFromBot\" state.");
                    Debug.LogError("[" + typeof(MyUGUIFlyingMessage).Name + "] CreateTemplate(): mapping \"my_animation_flying_message_short_fly_from_mid\" motion for \"ShortFlyFromMid\" state.");
                    Debug.LogError("[" + typeof(MyUGUIFlyingMessage).Name + "] CreateTemplate(): mapping \"my_animation_flying_message_long_fly_from_mid\" motion for \"LongFlyFromBot\" state.");
                    break;
                }
            }
#endif

            CanvasGroup root_canvasGroup = obj.AddComponent <CanvasGroup>();
            root_canvasGroup.alpha          = 1;
            root_canvasGroup.interactable   = false;
            root_canvasGroup.blocksRaycasts = false;

            GameObject text = new GameObject("Text");
            text.transform.SetParent(root_rect.transform, false);

            RectTransform text_rect = text.AddComponent <RectTransform>();
            MyUtilities.Anchor(ref text_rect, MyUtilities.EAnchorPreset.HorizontalStretchMiddle, MyUtilities.EAnchorPivot.MiddleCenter, -400, 50, 0, 0);

            Text text_text = text.AddComponent <Text>();
            text_text.text               = "This is flying message";
            text_text.color              = Color.white;
            text_text.font               = Resources.GetBuiltinResource <Font>("Arial.ttf");
            text_text.fontSize           = 50;
            text_text.alignment          = TextAnchor.MiddleCenter;
            text_text.horizontalOverflow = HorizontalWrapMode.Wrap;
            text_text.verticalOverflow   = VerticalWrapMode.Overflow;
            text_text.raycastTarget      = false;

            Outline text_outline = text.AddComponent <Outline>();
            text_outline.effectColor     = Color.black;
            text_outline.effectDistance  = new Vector2(2, 2);
            text_outline.useGraphicAlpha = false;

            Shadow text_shadow = text.AddComponent <Shadow>();
            text_shadow.effectColor     = Color.black;
            text_shadow.effectDistance  = new Vector2(1, -2);
            text_shadow.useGraphicAlpha = false;

            return(obj);
        }
Example #26
0
        static void Main(string[] args)
        {
            try
            {
                MyUtilities.WriteLineColor("Приложение для отправки сообщений через SMTP-сервер\n", 10);

                // 1. Формируем входные параметры сообщения (From, To, Subject, Body) и SMTP клиента (Server)

                string From   = "*****@*****.**";                                                        // адрес отправителя сообщения
                string To     = "*****@*****.**";                                                      // адрес получателя сообщения
                string server = "smtp.gmail.com";                                                               // адрес SMPT сервера

                // 1.1. Данные первого отправленного сообщения

                //string Subject = "Новые предложения к Новому году!";
                //string Body = "Дорогие друзья!\nБлизится Новый год и нужно много успеть!\nСпешите приобрести лучшие подарки к Новому году для всей семьи! ";

                // 1.2. Данные второго отправленного сообщения

                string Subject = "Тестовое задание по \"Сетевому программированию\"";
                string Body    = "Домашнее задание №5\nСоздать приложение. Используя MailMessage и SmtpClient отправить через сторонний " +
                                 "smtp-serverver(например smtp.gmail.com), сообщение на свою собственную почту.\nНа экран вывести Диалог с smtp-сервером, " +
                                 "и время через сколько было обработано письмо.\n\nОтправка сообщений уже реализована, сообщения доходят до адресата)))\n" +
                                 "К сожалению, реализация ответа от SMTP сервера средствами C# через создание POP3-клиента на данный момент невозможна";

                // 2. Создание сообщения
                MailMessage post = new (From, To, Subject, Body);

                // Вводим пароль для доступа к приложению через аккаунт
                MyUtilities.WriteLineColor("Введите пароль к приложению", 10);

                // пароль вводим через ввод с клавиатуры (так безопасней)
                string mypassword = Console.ReadLine();
                Console.WriteLine();

                // 3. Создаем SMTP-клиент для передачи сообщения через SMTP-сервер
                SmtpClient client = new (server, 587);
                client.Credentials = new NetworkCredential("*****@*****.**", mypassword);

                client.EnableSsl = true;
                //client.Timeout = 0;
                //client.UseDefaultCredentials = true;

                try
                {
                    // 4. Отправляем сообщение
                    client.Send(post);
                    MyUtilities.WriteLineColor("Сообщение успешно оправлено", 10);
                }
                catch (Exception cl)
                {
                    MyUtilities.WriteLineColor($"Сообщение не отправлено. Причина:  {cl.Message}", 12);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Упс! Что-то пошло не так!\nКод ошибки:  {ex.Message}");
            }
        }
    protected bool InsertRoutingLine(string[] entries)
    {
        bool wasInserted = false;

        for (int i = 0; i < entries.Length; i++)
        {
            entries[i] = MyUtilities.clean(entries[i]);
            if (entries[i].Trim().Length > 0)
            {
                entries[i] = entries[i].Trim();
            }
        }
        connec = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + GetDirectory() + userDir + MAIN_USER_DATABASE + ";");
        string           command  = "INSERT into tblOperFrTo (PartFore, OpNumF, OpNumT, Per, fromopname, ToOpName, ProdDesc) VALUES ( ?, ?, ?, ?, ?, ?, ?);";
        OleDbCommand     cmd      = new OleDbCommand(command, connec);
        OleDbCommand     comm2    = new OleDbCommand("SELECT ProdID FROM tblprodfore WHERE ProdDesc = '" + dropListProducts.SelectedItem.Text + "';", connec);
        OleDbDataAdapter adapter2 = new OleDbDataAdapter(comm2);

        {
            try {
                connec.Open();
                DataTable ds  = new DataTable();
                DataTable ds2 = new DataTable();
                DataTable ds3 = new DataTable();

                adapter2.Fill(ds2);
                OleDbCommand     comm    = new OleDbCommand("SELECT OpID FROM tbloper WHERE ProdFore = " + ds2.Rows[0]["ProdID"] + " AND OpNam = '" + entries[0] + "';", connec);
                OleDbDataAdapter adapter = new OleDbDataAdapter(comm);
                adapter.Fill(ds);

                OleDbCommand     comm3    = new OleDbCommand("SELECT OpID FROM tbloper WHERE ProdFore = " + ds2.Rows[0]["ProdID"] + " AND OpNam = '" + entries[1] + "';", connec);
                OleDbDataAdapter adapter3 = new OleDbDataAdapter(comm3);
                adapter3.Fill(ds3);

                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("PartFore", ds2.Rows[0]["ProdID"]);
                cmd.Parameters.AddWithValue("OpNumF", ds.Rows[0]["OpID"]);
                cmd.Parameters.AddWithValue("OpNumT", ds3.Rows[0]["OpID"]);
                cmd.Parameters.AddWithValue("Per", entries[2]);
                cmd.Parameters.AddWithValue("fromopname", entries[0].ToUpper());
                cmd.Parameters.AddWithValue("ToOpName", entries[1].ToUpper());
                cmd.Parameters.AddWithValue("ProdDesc", dropListProducts.SelectedItem.Text);

                int result = cmd.ExecuteNonQuery();
                grid.EditIndex = -1;

                this.SetData();
                wasInserted = true;
                connec.Close();
            } catch {
                try {
                    connec.Close();
                    connec = null;
                } catch { }
                SaveInsertValues(grid.FooterRow, TEXT_BOX_IDS);
            }
        }
        return(wasInserted);
    }
Example #28
0
        public void testTrimArrayStrings()
        {
            string[] testArray = { "  remove blank spaces at beginning and end of string   " };
            string   expected  = "remove blank spaces at beginning and end of string";

            string[] resultArray = MyUtilities.TrimArrayStrings(testArray);
            Assert.AreEqual(resultArray[0], expected);
        }
Example #29
0
 public CapNhatPhong_UI()
 {
     InitializeComponent();
     phongBUS     = new PhongBUS();
     loaiPhongBUS = new LoaiPhongBUS();
     tinhTrangBUS = new TinhTrangBUS();
     myUtilities  = new MyUtilities();
 }
Example #30
0
    /// <summary>
    /// If direction is within the allowed sticky angle
    /// </summary>
    /// <returns><c>true</c>, if sticky margin was withined, <c>false</c> otherwise.</returns>
    /// <param name="normal">Normal.</param>
    bool withinStickyAngle(Vector3 normal)
    {
        float normalAngle = MyUtilities.AngleInDegrees(Vector2.zero, -normal);
        float downAngle   = MyUtilities.AngleInDegrees(Vector2.zero, _myDown);
        float difference  = Mathf.Abs(normalAngle - downAngle);

        return(difference <= stickyAngle);
    }
Example #31
0
 // Use this for initialization
 void Start()
 {
     MyUtilities utils = new MyUtilities();
     utils.AddValues(2, 3);
     Debug.Log("2 + 3 = " + utils.c);
 }